Re: Issue 155: Implicit gatherer/listener

Peter Thatcher said: 

"Here's an idea:

When the app needs the browser to know the gatherer is RTCP before gathering (presumably so that the browser can do some kind of not-specified-by-the-standard "+1 port" behavior), couldn't it just not call IceGatherer.gather() and instead wait and call IceTransport.start?  It would delay gathering RTCP candidates 0.5RTT, but RTCP isn't as time-sensitive as RTP.  Would it be that big of a deal?"

[BA] The RTCIceGatherer object has no gather method; gathering begins on construction of the RTCIceGatherer object and the candidates are queued until an onlocalcandidate event handler is supplied. While iceTransport.component is determined on creation  (e.g. RTCP for an ICE Transported created via .createAssociatedTransport, RTP otherwise), an RTCIceGatherer does not have a component attribute. 

While ice.start does require that an RTCIceGatherer be supplied as an argument, the same RTCIceGatherer can be used as an rgument to multiple .start calls for different RTCIceTransports (e.g. in the forking case).  In Example 6, there is no longer the concept that an RTCIceGatherer is implicitly created by .createAssociatedTransport;  the RTCIceGatherer is always explicitly created, though it may be reused. 

Example 6

// Example to demonstrate forking when RTP and RTCP are not multiplexed. 
// Create ICE gather objects
var gatherOptions = new RTCIceGatherOptions(); 
gatherOptions.gatherPolicy = RTCIceGatherPolicy.relay; 
gatherOptions.iceservers = ... ; 
var iceRtpGatherer = new RTCIceGatherer(gatherOptions);
var iceRtcpGatherer = new RTCIceGatherer(gatherOptions); 
// Prepare to signal local candidates
iceRtpGatherer.onlocalcandidate = function (event)  {mySendLocalCandidate(iceBaseRtpTransport, event.candidate)}; 
iceRtcpGatherer.onlocalcandidate = function (event)  {mySendLocalCandidate(iceBaseRtcpTransport, event.candidate)}; 

mySendInitiate(
{
   "icertp": iceRtpGatherer.getLocalParameters(),
   "icertcp": iceRtcpGatherer.getLocalParameters()
 },
  function(response) {
  // We may get N responses
  // Create the ICE RTP and RTCP transports
  var iceRtpTransport = new RTCIceTransport();
  var iceRtcpTransport = iceRtpTransport.createAssociatedTransport();
  // Create the ICE Transport Controller object and add the RTP and RTCP Ice Transports to it
  var controller = new RTCIceTransportController();
  controller.addTransport(iceRtpTransport);
  controller.addTransport(iceRtcpTransport);
  // Start the RTP and RTCP ICE transports
  iceRtpTransport.start(iceRtpGatherer, response.icertp, RTCIceRole.controlling);
  iceRtcpTransport.start(iceRtcpGatherer, response.icertcp, RTCIceRole.controlling); 
  // Now we can handle remote ICE candidates
  mySignaller.onRemoteCandidate = function(remote) {
   if (remote.component === RTCIceComponent.RTP){
     iceRtpTransport.addRemoteCandidate(remote.candidate);
     } else {
      iceRtcpTransport.addRemoteCandidate(remote.candidate);
     };
  }

  // ... setup DTLS, RTP, SCTP, etc.
});

function mySendLocalCandidate(transport, candidate){
   mySignaller.mySendLocalCandidate({
   "candidate": candidate,
   "component": transport.component
   });

Received on Tuesday, 14 October 2014 22:13:46 UTC