apps icon indicating copy to clipboard operation
apps copied to clipboard

[Nexus] Renegotiate TODO

Open ddbnl opened this issue 10 months ago • 1 comments

The nexus app has helped me a lot with understanding WebRTC, but I've gotten stuck at adding a new track to an existing connection (goal is to share camera and screen at the same time). Tracing through the code I found that there is a "TODO: renegotiate" line in the following file, which I believe could help me if implemented.

I've tried to implement it myself with no luck as a beginner to WebRTC; would it be possible to fill in this function, or give a clue regarding how to go about implementing it? I don't mind making a PR if I manage to fix it with some hints :)

Thanks for the great example app.

ddbnl avatar Mar 30 '25 20:03 ddbnl

Hi @ddbnl,

the renegotiation process is all about exchanging a new SDP offer and answer between two parties. If you have established WebRTC connection and you add a new track (e.g. a screenshare), all you need to do is to generate a new SDP offer and exchange it with the other side.

Keep in mind that some actions might require renegotiation and some other might not. Whenever a renegotiation is needed, :negotiation_needed message is fired.

We have a couple of tests that perform renegotiation, you can see them here: https://github.com/elixir-webrtc/ex_webrtc/blob/master/test/ex_webrtc/renegotiation_test.exs

If you look carefully, you will see that when we want to re-negotiate, we just call once again negotiate function :)

https://github.com/elixir-webrtc/ex_webrtc/blob/master/test/ex_webrtc/renegotiation_test.exs#L24

You might also want to take a look at: https://hexdocs.pm/ex_webrtc/modifying.html or https://webrtc.github.io/samples/src/content/peerconnection/negotiate-timing/

Hope this helps!

mickel8 avatar Mar 31 '25 07:03 mickel8