Skip to content

webrtcbin: Basic ICE Restarts

fauxsoup1 requested to merge fauxsoup1/gst-plugins-bad:1.18 into master

What you should be aware of: I don't know what I'm doing. Going into this I was very unfamiliar with the webrtcbin internals. I understand them much better now, but I'm still not confident in what I've produced. I'm also generally not diligent enough to write C these days (curse you, memory management); I've probably introduced small memory leaks by forgetting to free returned copies of values, or else unref that which must be unreffed.

Regardless, I want to at least kick this off. I reached out on the mailing list looking for help with this, but kept at it as well, and this is the result.

As far as I am aware, this only supports manually initiated ICE restarts when acting as the initiator.

First, we utilize the create-offer signal's options structure to pass in a restart flag. That restart flag is propagated into appropriate locations to tweak the behavior of webrtcbin to:

  • generate new ice-pwd and ice-ufrag values
  • ensure the creation of a new sdp media section with the correct ufrag and pwd

Next, we update GstWebRTCICE such that when it sets the new credentials, it compares them to the prior credentials, and if they are changed will invoke the new gst_webrtc_ice_stream_restart on the appropriate stream.

gst_webrtc_ice_stream_restart does a few things:

  • Resets the stream's gathering state (come to think of it, this may not be necessary)
  • Invoke nice_agent_restart_stream with the appropriate stream_id
  • Retrieve the full list of local candidates for NICE_COMPONENT_TYPE_RTP and NICE_COMPONENT_TYPE_RTCP
  • Re-signals said candidates through a dirty hack

The dirty hack is commented in the changes. I am deeply ashamed to have thought of it, and I await your collective judgement.

Edited by fauxsoup1

Merge request reports

Loading