Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get_buffered_amount() to WebRTCDataChannel (GDNative) #43

Merged
merged 1 commit into from
Sep 22, 2021

Conversation

dsnopek
Copy link
Contributor

@dsnopek dsnopek commented Jul 20, 2021

This is a companion to these PRs:

This requires a minor change to godot-headers in order to compile:

diff --git a/net/godot_webrtc.h b/net/godot_webrtc.h
index 15e2df8..d5260cc 100644
--- a/net/godot_webrtc.h
+++ b/net/godot_webrtc.h
@@ -108,6 +108,13 @@ typedef struct {
        void *next; /* For extension? */
 } godot_net_webrtc_data_channel;
 
+/* Extensions to WebRTCDataChannel */
+typedef struct {
+       int (*get_buffered_amount)(const void *);
+
+       void *next; /* For extension? */
+} godot_net_webrtc_data_channel_ext;
+
 /* Set the default GDNative library */
 godot_error GDAPI godot_net_set_webrtc_library(const godot_net_webrtc_library *);
 /* Binds a WebRTCPeerConnectionGDNative to the provided interface */

As explained on the Godot 4.x PR, this has some backwards compatibility challenges. The godot_net_webrtc_data_channel struct changes, which will cause old version of the GDNative plugin to not work until updated, and also updated versions of the GDNative plugin won't work with older versions of Godot. So, I'm not sure how to handle that...

UPDATE: Backcompat is now handled per suggestion from @Faless!

@dsnopek dsnopek changed the title Add get_buffered_amount() to WebRTCDataChannel Add get_buffered_amount() to WebRTCDataChannel (GDNative) Jul 20, 2021
@dsnopek
Copy link
Contributor Author

dsnopek commented Jul 21, 2021

Here's a PR to godot-headers that should allow this to actually build:

godotengine/godot-headers#94

@Faless
Copy link
Collaborator

Faless commented Jul 21, 2021

I think for now you can add that struct in this repository (without updating godot-cpp).
In src/net/WebRTCDataChannelNative.hpp:

#if GODOT_NET_WEBRTC_API_MAJOR == 3 && GODOT_NET_WEBRTC_API_MINOR < 4
extern "C" {
/* Extensions to WebRTCDataChannel */
typedef struct {
	int (*get_buffered_amount)(const void *);

	void *next; /* For extension? */
} godot_net_webrtc_data_channel_ext;
}
#endif

See my comment godotengine/godot#50659 (comment)

@dsnopek
Copy link
Contributor Author

dsnopek commented Jul 21, 2021

Alright, I added the conditional definition of the struct.

@Faless
Copy link
Collaborator

Faless commented Sep 22, 2021

Woah, sorry, I forgot to merge this it seems 😞 .

@Faless Faless merged commit 8c18112 into godotengine:master Sep 22, 2021
@Faless
Copy link
Collaborator

Faless commented Sep 22, 2021

Thanks!

@dsnopek
Copy link
Contributor Author

dsnopek commented Sep 22, 2021

Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants