Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to gracefully switch between networks in WebRTC?

Suppose I have an established PeerConnection on Wifi. How to gracefully switch network to mobile without interrupting the session?

I obviously can stop everything and renegotiate the session, but I don't thing that this is the solution.

There are also iceConnectionReceivingTimeout and iceBackupCandidatePairPingInterval parameters which seems to be designed exactly for that case, but unfortunately I cannot find any hints on how to use them apart from this post. Apparently just setting them does not do anything.

like image 674
user1256821 Avatar asked Dec 12 '16 10:12

user1256821


People also ask

How to switch between WebRTC screen sharing and camera screen recording?

MP4 file or HLS stream will record the screen or your camera according to your preference. You can watch the stream live on web panel via HLS. We just add some simple functions to js/webrtc_adaptor.js file to seamless switch between WebRTC screen sharing and camera.

Why should I use WebRTC for one-to-many streaming?

Using WebRTC for one-to-many streaming makes life easy for users. Because there is no need to install any third-party software in-stream publishing. In addition, to make life even easier is the seamless switch between WebRTC Screen Sharing & Camera .

How to enable WebRTC on Opera browser?

To enable WebRTC in the web browser settings, hover over the name Opera in the top left corner and open Preferences. Now, type “ WebRTC ” in the search field and enable the first option in the resulting list. In some cases, Opera blocks the WebRTC technology and to solve this problem, it is enough to check the above WebRTC settings.

What happens to the destination stream when it passes to WebRTC?

So destination stream will be passed with WebRtc but you will be able to add/remove other MediaSources. And as the stream passes to WebRtc will remain the same there is not need to worry about re renegotiation. here is helper to easyly connect/disconnect streams.


1 Answers

As mentioned before, You can't. However, if you are using the newest WebRTC from chromium there is a way to minimize the delay.

The fastest available option is to catch the network change event and restart the connection by recreating the offer in the same RTCPeerConnection with an iceRestart: true flag and sending it to the participant.

https://w3c.github.io/webrtc-pc/#dom-rtcofferoptions

This will automatically trigger the renegotiation by generating and using new values for the ICE username & password fragments - ufrag/pwd.

NOTE

Performing an ICE restart is recommended when iceConnectionState transitions to "failed". An application may additionally choose to listen for the iceConnectionState transition to "disconnected" and then use other sources of information (such as using getStats to measure if the number of bytes sent or received over the next couple of seconds increases) to determine whether an ICE restart is advisable.

like image 188
Mariusz Beltowski Avatar answered Sep 29 '22 03:09

Mariusz Beltowski