| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "webrtc_data_channel.h" |
| 34 |
|
| 35 |
class WebRTCPeerConnection : public RefCounted { |
| 36 |
GDCLASS(WebRTCPeerConnection, RefCounted); |
| 37 |
|
| 38 |
public: |
| 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 |
|
| 63 |
private: |
| 64 |
static StringName default_extension; |
| 65 |
|
| 66 |
protected: |
| 67 |
static void _bind_methods(); |
| 68 |
|
| 69 |
public: |
| 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 |
|
| 91 |
VARIANT_ENUM_CAST(WebRTCPeerConnection::ConnectionState); |
| 92 |
VARIANT_ENUM_CAST(WebRTCPeerConnection::GatheringState); |
| 93 |
VARIANT_ENUM_CAST(WebRTCPeerConnection::SignalingState); |