fishjam-dev / membrane_webrtc_plugin

Membrane plugin for sending and receiving media with WebRTC
Apache License 2.0
24 stars 3 forks source link

Support data channels #11

Open mat-hek opened 3 years ago

mat-hek commented 3 years ago

Having data channels will enable membrane users to send custom data over WebRTC, but it will also let us avoid using signalling for sending some media-related data, like marking active speakers.

This may require improvements in https://github.com/membraneframework/ex_dtls and support for SCTP protocol.

madawei2699 commented 1 year ago

Hi @mat-hek I want to implement the webRTC datachannel with the SCTP protocol, as I know, maybe needs these tasks:

Is that so? I would appreciate if you could give any help.

mickel8 commented 1 year ago

Hi @madawei2699, sounds good but it would be nice to think more about passing messages from one data channel to another inside SFU. At the moment, engine supports publishing audio and video tracks only, data channels would require some changes in this API.

madawei2699 commented 1 year ago

Hi @madawei2699,

sounds good but it would be nice to think more about passing messages from one data channel to another inside SFU. At the moment, engine supports publishing audio and video tracks only, data channels would require some changes in this API.

Hi @mickel8 Thanks for your advice. It seems one feature needs to change many repos, so maybe better to use Monorepo to organize the codebase? How do you think?

mat-hek commented 1 year ago

@mickel8 indeed, but I think that can be the last part. Hi @madawei2699, glad you'd like to contribute that. Regarding DTLS, it's going to be: ICE <-> DTLS <-> SCTP <-> ... That means:

Apart from RFC, this may be helpful: https://webrtcforthecurious.com/docs/07-data-communication/ Feel free to ask if you have any doubts ;)

madawei2699 commented 1 year ago

@mat-hek Thanks for giving so deeply details. Seems to support the webRTC data channel, we need to do these tasks:

Any comments?

mat-hek commented 1 year ago

Almost. Here is how I see it, the top pipeline shows how it's now, and the bottom is my view of how it's going to be:

image

So we need

In the webrtc_plugin you'll need to negotiate data channels in SDP, which is quite tricky. I'd probably start from there to actually get a data channel from a browser. Once you have that, try to decrypt what you receive using DTLS and finally handle SCTP. Then the other way round ;)

madawei2699 commented 1 year ago

Thanks @mat-hek Now it is more clear to me. I can try start to implement the ex_libsctp, do you think possible to call some c SCTP library or must need to implement full protocol by pure elixir?

mat-hek commented 1 year ago

I think it's best to have a POC with minimal effort to validate objectives. So I'd rather use something ready if possible, at least for now. I'd also check the Erlang implementation, maybe ask at the erlang forum - maybe there's a way to use it.

madawei2699 commented 1 year ago

Ok, that make sense, I will try this approach first, and will post updates in here.

bugnano commented 1 year ago

another huge advantage of supporting data channels would be that it will be possible to use Membrane to create a real-time game server. For example the game is a client that uses https://github.com/geckosio/geckos.io , and the server can be implemented in Elixir instead of JS, which would be a huge plus