Skip to content
0.2.0-dev Download ZIP
93 lines ·4.0 KB Raw
1/**************************************************************************/
2/* webrtc_peer_connection.h */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#pragma once
32
33#include "webrtc_data_channel.h"
34
35class WebRTCPeerConnection : public RefCounted {
36 GDCLASS(WebRTCPeerConnection, RefCounted);
37
38public:
39 enum ConnectionState {
40 STATE_NEW,
41 STATE_CONNECTING,
42 STATE_CONNECTED,
43 STATE_DISCONNECTED,
44 STATE_FAILED,
45 STATE_CLOSED
46 };
47
48 enum GatheringState {
49 GATHERING_STATE_NEW,
50 GATHERING_STATE_GATHERING,
51 GATHERING_STATE_COMPLETE,
52 };
53
54 enum SignalingState {
55 SIGNALING_STATE_STABLE,
56 SIGNALING_STATE_HAVE_LOCAL_OFFER,
57 SIGNALING_STATE_HAVE_REMOTE_OFFER,
58 SIGNALING_STATE_HAVE_LOCAL_PRANSWER,
59 SIGNALING_STATE_HAVE_REMOTE_PRANSWER,
60 SIGNALING_STATE_CLOSED,
61 };
62
63private:
64 static StringName default_extension;
65
66protected:
67 static void _bind_methods();
68
69public:
70 static void set_default_extension(const StringName &p_name);
71
72 virtual ConnectionState get_connection_state() const = 0;
73 virtual GatheringState get_gathering_state() const = 0;
74 virtual SignalingState get_signaling_state() const = 0;
75
76 virtual Error initialize(const Dictionary &p_config = Dictionary()) = 0;
77 virtual Ref<WebRTCDataChannel> create_data_channel(const String &p_label, const Dictionary &p_options = Dictionary()) = 0;
78 virtual Error create_offer() = 0;
79 virtual Error set_remote_description(const String &p_type, const String &p_sdp) = 0;
80 virtual Error set_local_description(const String &p_type, const String &p_sdp) = 0;
81 virtual Error add_ice_candidate(const String &p_sdp_mid_name, int p_sdp_mline_index_name, const String &p_sdp_name) = 0;
82 virtual Error poll() = 0;
83 virtual void close() = 0;
84
85 static WebRTCPeerConnection *create(bool p_notify_postinitialize = true);
86
87 WebRTCPeerConnection();
88 ~WebRTCPeerConnection();
89};
90
91VARIANT_ENUM_CAST(WebRTCPeerConnection::ConnectionState);
92VARIANT_ENUM_CAST(WebRTCPeerConnection::GatheringState);
93VARIANT_ENUM_CAST(WebRTCPeerConnection::SignalingState);