[WebRTC] Static extension registration.
This commit is contained in:
parent
7e0c54e292
commit
31d7e22466
@ -95,6 +95,13 @@
|
||||
Call this method frequently (e.g. in [method Node._process] or [method Node._physics_process]) to properly receive signals.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_default_extension" qualifiers="static">
|
||||
<return type="void" />
|
||||
<argument index="0" name="extension_class" type="StringName" />
|
||||
<description>
|
||||
Sets the [code]extension_class[/code] as the default [WebRTCPeerConnectionExtension] returned when creating a new [WebRTCPeerConnection].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_local_description">
|
||||
<return type="int" enum="Error" />
|
||||
<argument index="0" name="type" type="String" />
|
||||
|
@ -62,10 +62,5 @@
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="make_default">
|
||||
<return type="void" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
</class>
|
||||
|
@ -32,13 +32,14 @@
|
||||
|
||||
#ifdef JAVASCRIPT_ENABLED
|
||||
#include "webrtc_peer_connection_js.h"
|
||||
#else
|
||||
#include "webrtc_peer_connection_extension.h"
|
||||
#endif
|
||||
|
||||
#include "webrtc_peer_connection_extension.h"
|
||||
|
||||
StringName WebRTCPeerConnection::default_extension;
|
||||
|
||||
void WebRTCPeerConnection::set_default_extension(const StringName &p_extension) {
|
||||
ERR_FAIL_COND_MSG(!ClassDB::is_parent_class(p_extension, WebRTCPeerConnectionExtension::get_class_static()), vformat("Can't make %s the default WebRTC extension since it does not extend WebRTCPeerConnectionExtension.", p_extension));
|
||||
default_extension = p_extension;
|
||||
}
|
||||
|
||||
@ -56,6 +57,8 @@ WebRTCPeerConnection *WebRTCPeerConnection::create() {
|
||||
}
|
||||
|
||||
void WebRTCPeerConnection::_bind_methods() {
|
||||
ClassDB::bind_static_method(get_class_static(), D_METHOD("set_default_extension", "extension_class"), &WebRTCPeerConnectionExtension::set_default_extension);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("initialize", "configuration"), &WebRTCPeerConnection::initialize, DEFVAL(Dictionary()));
|
||||
ClassDB::bind_method(D_METHOD("create_data_channel", "label", "options"), &WebRTCPeerConnection::create_data_channel, DEFVAL(Dictionary()));
|
||||
ClassDB::bind_method(D_METHOD("create_offer"), &WebRTCPeerConnection::create_offer);
|
||||
|
@ -31,8 +31,6 @@
|
||||
#include "webrtc_peer_connection_extension.h"
|
||||
|
||||
void WebRTCPeerConnectionExtension::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("make_default"), &WebRTCPeerConnectionExtension::make_default);
|
||||
|
||||
GDVIRTUAL_BIND(_get_connection_state);
|
||||
GDVIRTUAL_BIND(_initialize, "p_config");
|
||||
GDVIRTUAL_BIND(_create_data_channel, "p_label", "p_config");
|
||||
@ -44,11 +42,6 @@ void WebRTCPeerConnectionExtension::_bind_methods() {
|
||||
GDVIRTUAL_BIND(_close);
|
||||
}
|
||||
|
||||
void WebRTCPeerConnectionExtension::make_default() {
|
||||
ERR_FAIL_COND_MSG(!_get_extension(), vformat("Can't make %s the default without extending it.", get_class()));
|
||||
WebRTCPeerConnection::set_default_extension(get_class());
|
||||
}
|
||||
|
||||
WebRTCPeerConnection::ConnectionState WebRTCPeerConnectionExtension::get_connection_state() const {
|
||||
int state;
|
||||
if (GDVIRTUAL_CALL(_get_connection_state, state)) {
|
||||
|
@ -44,8 +44,6 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void make_default();
|
||||
|
||||
virtual ConnectionState get_connection_state() const override;
|
||||
|
||||
virtual Error initialize(Dictionary p_config = Dictionary()) override;
|
||||
|
Loading…
Reference in New Issue
Block a user