I have exhausted all possibilities to get a stable WebRTC implementation working and am looking to get some advice.
All possible solutions to handling a working connection working cross-browser have been taken into consideration, e.g:
Basically I am asking for somebody to help out with maybe a diagram or step by step of the process in which ice SHOULD be handled in order to have a working solution for both chrome and firefox cross-browser (both up to date as of current posting time).
I have burned myself out of thinking of any other possibilities at this point and any help would be greatly appreciated.
Thanks, Dec :)
ICE candidates. As well as exchanging information about the media (discussed above in Offer/Answer and SDP), peers must exchange information about the network connection. This is known as an ICE candidate and details the available methods the peer is able to communicate (directly or through a TURN server).
The RTCIceCandidate interface—part of the WebRTC API—represents a candidate Interactive Connectivity Establishment (ICE) configuration which may be used to establish an RTCPeerConnection . An ICE candidate describes the protocols and routing needed for WebRTC to be able to communicate with a remote device.
Disable ICE Candidate Restrictions will prevent host ICE candidates from being filtered for new connection attempts. Use Mock Capture Devices will replace all capture devices with a mock “Bip-Bop” device for any future calls of getUserMedia .
ICE stands for Interactive Connectivity Establishment. It is a standard method of NAT traversal used in WebRTC. It is defined in IETF RFC 5245. ICE deals with the process of connecting media through NATs by conducting connectivity checks.
I sympathise with your frustrations.
For a RTCPeerConnection, after you call createOffer() and then setLocalDescription(), the ICE agent will start to gather ICE candidates. At this point you can decide whether to make use of Trickle ICE, where candidates are sent to the remote peer as soon as they are made available, or you can wait for all the candidates to be gathered (most of the tutorials I've come across seem to assume the trickle approach, but miss some details about to handle this correctly).
Trickle approach:
A new candidate is available when a RTCPeerConnectionIceEvent is fired:
peerConnection.onicecandidate = function(newRTCPeerConnectionIceEvent) {
var newCandidate = newRTCPeerConnectionIceEvent.candidate;
// send candidate to remote via signalling channel
}
At the remote end, candidates can be added to their peer connection:
peerConnection.addIceCandidate(RTCIceCandidate);
If you haven't already called setRemoteDescription on the remote peer connection, I believe an attempt to add a candidate too early will generate an error, as this will attempt to add it to the remoteDescription when it has not been set. See this Errors when ICE Candidates are received before answer is sent.
Non-trickle approach:
You can wait for all candidates to be gathered as follows:
peerConnection.onicecandidate = function(newRTCPeerConnectionIceEvent) {
if (newRTCPeerConnectionIceEvent.candidate === null) {
// send the offer (generated previously) to the remote peer
// the offer sdp should contain all the gathered candidates
}
}
See this link for a bit more discussion on this technique: http://muaz-khan.blogspot.co.uk/2015/01/disable-ice-trickling.html (see comment at bottom of the page about generating an answer sdp when the offer already contains all candidates).
Note that the signalling mechanism may influence your approach, ie whether there is any significant latency in your signalling or not. I think the trickle approach assumes that you are using low latency signalling, as it aims to reduce the call set-up time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With