-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sending userNameFragment in candidate ? Example 5 #237
Comments
Example 4 defines the mySendLocalCandidate method: function mySendLocalCandidate(candidate, component, kind, parameters) {
// Set default values
kind = kind || "all";
component = component || RTCIceComponent.RTP;
parameters = parameters || null;
// Signal the local candidate
mySignaller.mySendLocalCandidate({
"candidate": candidate,
"component": component,
"kind": kind,
"parameters": parameters
});
} If we also send parameters, then Example 5 should look like this: // 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, "audio", iceRtpGatherer.getLocalParameters());
};
iceRtcpGatherer.onlocalcandidate = function(event) {
mySendLocalCandidate(event.candidate, RTCIceComponent.RTCP, "audio", iceRtpGatherer.getLocalParameters());
};
// 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
// The RTP and RTCP ICE parameters are the same, so only the RTP parameters are used
iceRtpTransport.start(iceRtpGatherer, response.icertp, RTCIceRole.controlling);
iceRtcpTransport.start(iceRtcpGatherer, response.icertp, 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({
// The RTP and RTCP local parameters are the same so we do not need to send both
"icertp": iceRtpGatherer.getLocalParameters()
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have question about Example 5
https://github.com/openpeer/ortc/blob/master/ortc.html#L1523
this code checked userNameFragment at each candidate from
remote.params
.this means when local oncandidate happens, we need to send it to peer with userNameFragment like this ?
in that case, we need to send getLocalParameter result twice ?
1 at send candidate, 2 at send parameters.
The text was updated successfully, but these errors were encountered: