godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.13k stars 93 forks source link

Merge webrtc-native as the default WebRTC extension for desktop platforms #6699

Open marc-weber1 opened 1 year ago

marc-weber1 commented 1 year ago

Describe the project you are working on

I am working on a GDExtension - https://github.com/marc-weber1/godot_rtc_voip - that would be used for P2P voice chat in "lobbies" for Godot 4, e.g. a first person shooter where you can hear other players speak, by spawning AudioStreams for each VOIP connection that can be put in any AudioStreamPlayer and using an AudioStreamMicrophone as input.

Describe the problem or limitation you are having in your project

Currently, webrtc-native needs to be compiled separately and installed as an extension, which was done because a dependency libdatachannel was not fully MIT licensed - which has been fixed as of https://github.com/paullouisageneau/libdatachannel/pull/822 since it switched to mbedTLS from openSSL. If you try to use WebRTC without installing the extension, the following warning shows up: image

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Merge the GDExtension version of https://github.com/godotengine/webrtc-native into the next version of Godot engine as the default WebRTC provider for Windows, Linux, and MacOS (?).

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

I'm not sure exactly how the GDExtension version of webrtc-native would need to be transformed to get it into a format similar to the web version - https://github.com/godotengine/godot/blob/master/modules/webrtc/webrtc_peer_connection_js.cpp - but it seems like some refactoring would need to be done, since a GDExtension can't be merged directly into Godot (?). It definitely needs to switch from openSSL to mbedTLS. More testing would probably need to be done on the code in webrtc-native as well, to make sure it will be compatible with Godot 4.1 or any version this could be merged into.

If this enhancement will not be used often, can it be worked around with a few lines of script?

It can be worked around by just installing the extension.

Is there a reason why this should be core and not an add-on in the asset library?

It is arguable whether Godot should have built-in voice chat compatibility, but WebRTC seems like one of Godot's primary networking features. In the docs - https://docs.godotengine.org/en/stable/tutorials/networking/webrtc.html - it even seems to imply that this is a feature that should be available cross-platform. If Godot has built-in support for WebRTC on HTML5, it should have it on every other platform as well, if possible.

Calinou commented 1 year ago

WebRTC comes with a lot of added complexity, which may not be worth the added binary size. This is especially the case if most projects don't use it (ENet has less overhead and tends to perform better).

dsnopek commented 1 year ago

IMO, the webrtc-native extension should remain an extension, given that so few games depend on it.

(And I say this as someone who has a game on Steam that uses the webrtc-native extension ;-))

goatchurchprime commented 1 year ago

It would be a lot nicer if it was installed from the AssetLib (like other complicated libraries, such as OpenXR), rather than having to copy it across from a tar unzip file.

Calinou commented 1 year ago

It would be a lot nicer if it was installed from the AssetLib (like other complicated libraries, such as OpenXR), rather than having to copy it across from a tar unzip file.

I believe it should be possible to distribute webrtc-native on the asset library, since there's already a binary release with all supported platforms uploaded to GitHub Releases: https://github.com/godotengine/webrtc-native/releases/tag/1.0.1-stable

cc @Faless

Faless commented 9 months ago

The plugin was recently made available via the asset library: Godot 4.1+ Godot 3.5