diff options
| author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2021-09-08 01:00:47 +0200 |
|---|---|---|
| committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2021-09-24 21:23:43 +0200 |
| commit | 6cb81543d4049e870ae43619fa1787362706a95c (patch) | |
| tree | db3a87b537fc46c84e76caa331a2a729ab06a385 /modules/webrtc/webrtc_peer_connection.cpp | |
| parent | 25226329bea7bada0b113068d3324fc0ce0fa8bd (diff) | |
| download | redot-engine-6cb81543d4049e870ae43619fa1787362706a95c.tar.gz | |
[Net] Expose WebRTC classes to extensions.
Diffstat (limited to 'modules/webrtc/webrtc_peer_connection.cpp')
| -rw-r--r-- | modules/webrtc/webrtc_peer_connection.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/modules/webrtc/webrtc_peer_connection.cpp b/modules/webrtc/webrtc_peer_connection.cpp index 3e2938bf7d..ad28aa76c7 100644 --- a/modules/webrtc/webrtc_peer_connection.cpp +++ b/modules/webrtc/webrtc_peer_connection.cpp @@ -30,17 +30,29 @@ #include "webrtc_peer_connection.h" -WebRTCPeerConnection *(*WebRTCPeerConnection::_create)() = nullptr; +#ifdef JAVASCRIPT_ENABLED +#include "webrtc_peer_connection_js.h" +#else +#include "webrtc_peer_connection_extension.h" +#endif -Ref<WebRTCPeerConnection> WebRTCPeerConnection::create_ref() { - return create(); +StringName WebRTCPeerConnection::default_extension; + +void WebRTCPeerConnection::set_default_extension(const StringName &p_extension) { + default_extension = p_extension; } WebRTCPeerConnection *WebRTCPeerConnection::create() { - if (!_create) { - return nullptr; +#ifdef JAVASCRIPT_ENABLED + return memnew(WebRTCPeerConnectionJS); +#else + if (default_extension == String()) { + WARN_PRINT_ONCE("No default WebRTC extension configured."); + return memnew(WebRTCPeerConnectionExtension); } - return _create(); + Object *obj = ClassDB::instantiate(default_extension); + return Object::cast_to<WebRTCPeerConnectionExtension>(obj); +#endif } void WebRTCPeerConnection::_bind_methods() { |
