godotengine / webrtc-native

The official GDNative WebRTC implementation for non-html exports.
MIT License
210 stars 34 forks source link

Switch to libdatachannel as RTC library. Add GDExtension support. #51

Closed Faless closed 2 years ago

Faless commented 2 years ago

We can finally ditch that ugly mess that's the chromium WebRTC library thanks to a sane implementation: libdatachannel.

This PR also adds GDExtension (godot 4) support. See the updated README.

Draft status:

~See here for prebuilt binaries (current master as of writing, but might break before Godot 4 is released)~.

See here for Godot 4.0 alpha-10 and Godot 3.5 builds.

dsnopek commented 2 years ago

I compiled the Godot 3 version per your instructions on Twitter (scons godot_version=3 arch=x86_64) and it worked in a couple minutes of testing with a real game! It's nice not to see the see console spam that the Google implementation generates. :-)

I'll try to test the Godot 4 version soon as well.

dsnopek commented 2 years ago

I haven't managed to do a really solid test of the Godot 4 version yet, but I just wanted to point out that the paths are mostly wrong in the *.gdextension files in the binary release linked in the issue description. It's got them all with "x86_32" in their filenames, rather than the correct architecture:

linux.x86_64 = "res://webrtc_debug/lib/libwebrtc_native.linux.debug.x86_32.so"
linux.x86 = "res://webrtc_debug/lib/libwebrtc_native.linux.debug.x86_32.so"
osx.x86_64 = "res://webrtc_debug/lib/libwebrtc_native.osx.debug.x86_32.dylib"
osx.arm64 = "res://webrtc_debug/lib/libwebrtc_native.osx.debug.x86_32.dylib"
windows.x86_64 = "res://webrtc_debug/lib/libwebrtc_native.windows.debug.x86_32.dll"
windows.x86 = "res://webrtc_debug/lib/libwebrtc_native.windows.debug.x86_32.dll"
android.armv7 = "res://webrtc_debug/lib/libwebrtc_native.android.debug.x86_32.so"
android.arm64 = "res://webrtc_debug/lib/libwebrtc_native.android.debug.x86_32.so"
android.x86_64 = "res://webrtc_debug/lib/libwebrtc_native.android.debug.x86_32.so"
android.x86 = "res://webrtc_debug/lib/libwebrtc_native.android.debug.x86_32.so"
ios.arm64 = "res://webrtc_debug/lib/libwebrtc_native.ios.debug.x86_32.dylib"
ios.x86_64 = "res://webrtc_debug/lib/libwebrtc_native.ios.debug.x86_32.simulator.dylib"

My system is Linux 64-bit, so when it tried to load the GDExtension I got this error: Can't open dynamic library: /home/dsnopek/games/godot4-nakama-webrtc/webrtc_debug/lib/libwebrtc_native.linux.debug.x86_32.so. Error: /home/dsnopek/games/godot4-nakama-webrtc/webrtc_debug/lib/libwebrtc_native.linux.debug.x86_32.so: wrong ELF class: ELFCLASS32

After I corrected the path, it appears to be loading correctly.

Faless commented 2 years ago

Thanks for trying out the PR! The paths should be fixed now.

dsnopek commented 2 years ago

The paths should be fixed now.

Awesome, thanks!

I've started porting a small-ish WebRTC project to Godot 4. I was hoping to get it done today, but that may have been a little optimistic. :-) I'll come back to it on the weekend, and let you know how it goes!

dsnopek commented 2 years ago

I ported my "WebRTC and Nakama addon" to Godot 4:

https://gitlab.com/snopek-games/godot-nakama-webrtc/-/commits/godot-4

... and, using the binary builds linked above, got the demo game actually working!

Skimming the code changes, everything seems fine to me. It's very clever how you have it supporting both GDNative and GDExtension :-)

fire commented 2 years ago

https://github.com/godotengine/godot/pull/61839 merged

Faless commented 2 years ago

~Updated the test release~ Now released as alpha with both GDExtenstion (4.0-alpha10) and GDNative (3.5) version.