Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/WebRTCLibDataChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ using namespace godot;
using namespace godot_webrtc;

// DataChannel
#ifdef GDNATIVE_WEBRTC
WebRTCLibDataChannel *WebRTCLibDataChannel::new_data_channel(std::shared_ptr<rtc::DataChannel> p_channel, bool p_negotiated) {
#else
Ref<WebRTCLibDataChannel> WebRTCLibDataChannel::new_data_channel(std::shared_ptr<rtc::DataChannel> p_channel, bool p_negotiated) {
#endif
// Invalid channel result in NULL return
ERR_FAIL_COND_V(!p_channel, nullptr);

Expand All @@ -62,7 +66,7 @@ WebRTCLibDataChannel *WebRTCLibDataChannel::new_data_channel(std::shared_ptr<rtc
native->set_script(script);
WebRTCLibDataChannel *out = native->cast_to<WebRTCLibDataChannel>(native);
#else
WebRTCLibDataChannel *out = memnew(WebRTCLibDataChannel);
Ref<WebRTCLibDataChannel> out = memnew(WebRTCLibDataChannel);
#endif
// Bind the library data channel to our object.
out->bind_channel(p_channel, p_negotiated);
Expand Down
4 changes: 4 additions & 0 deletions src/WebRTCLibDataChannel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ class WebRTCLibDataChannel : public godot::WebRTCDataChannelExtension {
}

public:
#ifdef GDNATIVE_WEBRTC
static WebRTCLibDataChannel *new_data_channel(std::shared_ptr<rtc::DataChannel> p_channel, bool p_negotiated);
#else
static godot::Ref<WebRTCLibDataChannel> new_data_channel(std::shared_ptr<rtc::DataChannel> p_channel, bool p_negotiated);
#endif

/* PacketPeer */
virtual godot::Error _get_packet(const uint8_t **r_buffer, int32_t *r_len) override;
Expand Down
5 changes: 5 additions & 0 deletions src/WebRTCLibPeerConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,13 @@ Ref<WebRTCDataChannel> WebRTCLibPeerConnection::_create_data_channel(const Strin
std::shared_ptr<rtc::DataChannel> ch = peer_connection->createDataChannel(p_channel.utf8().get_data(), config);
ERR_FAIL_COND_V(ch == nullptr, nullptr);

#ifdef GDNATIVE_WEBRTC
WebRTCLibDataChannel *wrapper = WebRTCLibDataChannel::new_data_channel(ch, ch->id().has_value());
ERR_FAIL_COND_V(wrapper == nullptr, nullptr);
#else
Ref<WebRTCLibDataChannel> wrapper = WebRTCLibDataChannel::new_data_channel(ch, ch->id().has_value());
ERR_FAIL_COND_V(wrapper.is_null(), nullptr);
#endif
return wrapper;
} catch (const std::exception &e) {
ERR_PRINT(e.what());
Expand Down
Loading