- From: Bernard Aboba <Bernard.Aboba@microsoft.com>
- Date: Sat, 12 Sep 2015 19:34:14 +0000
- To: "public-ortc@w3.org" <public-ortc@w3.org>
- Message-ID: <BLUPR03MB149BEE88181D6785C7DBFC3EC5F0@BLUPR03MB149.namprd03.prod.outlook.com>
>From Jxck: https://github.com/openpeer/ortc/issues/235 what is getRemoteParameters(iceTransport(j)) ? this seems kind of strange code. Examples 5, 6 and 7 with fixes applied: EXAMPLE 5 // Example to demonstrate forking when RTP and RTCP are not multiplexed, // so that both RTP and RTCP IceGatherer and IceTransport objects are needed. // Include some helper functions import "helper.js"; // Create ICE gather options var gatherOptions = new RTCIceGatherOptions(); gatherOptions.gatherPolicy = RTCIceGatherPolicy.relay; gatherOptions.iceservers = [ { urls: "stun:stun1.example.net" }, { urls: "turn:turn.example.org", username: "user", credential: "myPassword" } ]; // Create ICE gatherer objects var iceRtpGatherer = new RTCIceGatherer(gatherOptions); var iceRtcpGatherer = iceRtpGatherer.createAssociatedGatherer(); // Prepare to signal local candidates iceRtpGatherer.onlocalcandidate = function(event) { mySendLocalCandidate(event.candidate, RTCIceComponent.RTP); }; iceRtcpGatherer.onlocalcandidate = function(event) { mySendLocalCandidate(event.candidate, RTCIceComponent.RTCP); }; // Initialize the ICE transport arrays var iceRtpTransports = []; var iceRtcpTransports = []; // Set up response function mySignaller.onResponse = function(responseSignaller, response) { // We may get N responses // Create the ICE RTP and RTCP transports var iceRtpTransport = new RTCIceTransport(iceRtpGatherer); var iceRtcpTransport = iceRtpTransport.createAssociatedTransport(); // Start the RTP and RTCP ICE transports so that outgoing ICE connectivity checks can begin iceRtpTransport.start(iceRtpGatherer, response.icertp, RTCIceRole.controlling); iceRtcpTransport.start(iceRtcpGatherer, response.icertcp, RTCIceRole.controlling); iceRtpTransports.push(iceRtpTransport); iceRtcpTransports.push(iceRtcpTransport); // Prepare to add ICE candidates signalled by the remote peer responseSignaller.onRemoteCandidate = function(remote) { // Locate the ICE transport that the signaled candidate relates to by matching the userNameFragment. var transports; if (remote.component === RTCIceComponent.RTP) { transports = iceRtpTransports; } else { transports = iceRtcpTransports; } for (var j = 0; j < iceTransport.length; j++) { var transport = transports[j]; if (transport.getRemoteParameters().userNameFragment === remote.parameters.userNameFragment) transport.addREmoteCandidate(remote.candidate); } } }; }; mySignaller.send({ "icertp": iceRtpGatherer.getLocalParameters(), "icertcp": iceRtcpGatherer.getLocalParameters() }); EXAMPLE 6 // This is an example of how to offer ICE and DTLS parameters and // ICE candidates and get back ICE and DTLS parameters and ICE candidates, // and start both ICE and DTLS, when RTP and RTCP are multiplexed. // Assume that we have a way to signal (mySignaller). // Include some helper functions import "helper.js"; function initiate(mySignaller) { // Prepare the ICE gatherer var gatherOptions = new RTCIceGatherOptions(); gatherOptions.gatherPolicy = RTCIceGatherPolicy.all; gatherOptions.iceservers = [ { urls: "stun:stun1.example.net" }, { urls: "turn:turn.example.org", username: "user", credential: "myPassword" } ]; var iceGatherer = new RTCIceGatherer(gatherOptions); iceGatherer.onlocalcandidate = function(event) { mySignaller.mySendLocalCandidate(event.candidate); }; // Initialize the ICE and DTLS transport arrays var iceTransports = []; var dtlsTransports = []; // Prepare to handle remote ICE candidates mySignaller.onRemoteCandidate = function(remote) { // Figure out which IceTranport a remote candidate relates to by matching the userNameFragment/password var j = 0; for (j = 0; j < iceTransport.length; j++) { var transport = iceTransports[j]; if (transport.getRemoteParameters().userNameFragment === remote.parameters.userNameFragment) transport.addRemoteCandidate(remote.candidate); } } }; // ... create RtpSender/RtpReceiver objects as illustrated in Section 6.4 Example 7. mySignaller.mySendInitiate({ "ice": iceGatherer.getLocalParameters(), "dtls": dtls.getLocalParameters(), // ... marshall RtpSender/RtpReceiver capabilities as illustrated in Section 6.4 Example 7. }, function(remote) { // Create the ICE and DTLS transports var iceTransport = new RTCIceTransport(iceGatherer); iceTransport.start(iceGatherer, remote.ice, RTCIceRole.controlling); iceTransports.push(iceTransport); // Issue 211: See: https://github.com/openpeer/ortc/issues/211 // The statement below constructs a RTCDtlsTransport object with a new certificate // and fingerprint which does not match what was offered (and accepted by the remote peer). // As a result, the remote peer will not be able to verify the fingerprint. var dtlsTransport = new RTCDtlsTransport(iceTransport); dtlsTransport.start(remote.dtls); dtlsTransports.push(dtlsTransport); // ... configure RtpSender/RtpReceiver objects as illustrated in Section 6.4 Example 7. }); } EXAMPLE 7 // This is an example of how to answer with ICE and DTLS // and DTLS parameters and ICE candidates and start both ICE and DTLS, // assuming that RTP and RTCP are multiplexed. // Include some helper functions import "helper.js"; // Assume that remote info is signalled to us. function accept(mySignaller, remote) { var gatherOptions = new RTCIceGatherOptions(); gatherOptions.gatherPolicy = RTCIceGatherPolicy.all; gatherOptions.iceservers = [ { urls: "stun:stun1.example.net" }, { urls: "turn:turn.example.org", username: "user", credential: "myPassword" } ]; var iceGatherer = new RTCIceGatherer(gatherOptions); iceGatherer.onlocalcandidate = function(event) { mySignaller.mySendLocalCandidate(event.candidate); }; // Create ICE and DTLS transports var ice = new RTCIceTransport(iceGatherer); var dtls = new RTCDtlsTransport(ice); // Prepare to handle remote candidates mySignaller.onRemoteCandidate = function(remote) { ice.addRemoteCandidate(remote.candidate); }; // ... create RtpSender/RtpReceiver objects as illustrated in Section 6.4 Example 7. mySignaller.mySendAccept({ "ice": iceGatherer.getLocalParameters(), "dtls": dtls.getLocalParameters() // ... marshall RtpSender/RtpReceiver capabilities as illustrated in Section 6.4 Example 7. }); // Start the ICE transport with an implicit gather policy of "all" ice.start(iceGatherer, remote.ice, RTCIceRole.controlled); // Attempt to start the DTLS transport. Unfortunately the remote DtlsTransport will not have the same // certificate/fingerprint as was signaled in the Offer, so that fingerprint verification will fail. dtls.start(remote.dtls); // ... configure RtpSender/RtpReceiver objects as illustrated in Section 6.4 Example 7. }
Received on Saturday, 12 September 2015 19:34:48 UTC