Partager via


RTCIceTransport object

[Some information relates to pre-released product which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.]

Exposes information relating to Interactive Connectivity Establishment (ICE). An RTCIceTransport instance is associated to a transport object (such as RTCDtlsTransport), and provides RTC related methods to it.

Overview

An RTCIceTransport instance is associated to a transport object (such as RTCDtlsTransport), and provides RTC related methods to it. The Microsoft Edge implementation does not support the oncandidatepairchange event handler. Since Microsoft Edge only supports "half-trickle", Edge will not begin candidate pair checks until RTCIceComplete has been passed as an argument to addRemoteCandidate().

Note  Edge Interop Note: The Microsoft Edge ICE implementation only supports regular nomination. In connectivity checks that it sends, Edge will only set the USE-CANDIDATE flag for the selected pair. Also, Edge will only respond to the first connectivity check setting the USE-CANDIDATE flag, and will ignore all subsequent connectivity checks with the USE-CANDIDATE flag set.

 

Operation

An RTCIceTransport instance is constructed without any arguments.

Syntax

  var ice = new RTCIceTransport();

Members

The RTCIceTransport object has these types of members:

  • Events
  • Methods
  • Properties

Events

The RTCIceTransport object has these events.

Event Description
onicestatechange

This event fires any time the RTCIceTransportState changes.

RTCIceTransportStateChangedEvent

Represents events that fire in relation to RTCIceTransport object state changes (onicestatechange events).

 

Methods

The RTCIceTransport object has these methods.

Method Description
addRemoteCandidate

Add a remote candidate associated with the remote RTCIceTransport.

createAssociatedTransport

Create an associated RTCIceTransport for RTCP.

getNominatedCandidatePair

Retrieves the selected candidate pair on which media is flowing.

getRemoteCandidates

Retrieves the sequence of candidates associated with the remote RTCIceTransport.

getRemoteParameters

Obtain the current ICE parameters of the remote RTCIceTransport.

RTCDtlsTransportStop

Stops and closes the DTLS transport object.

setRemoteCandidates

Set the sequence of candidates associated with the remote RTCIceTransport.

start

Starts ICE candidate connectivity checks and transitions to "connected" state once complete.

 

Properties

The RTCIceTransport object has these properties.

Property Access type Description

component

Read-only

The component-id of the RTCIceTransport.

iceGatherer

Read-only

Describes the RTCIceGatherer constructor value.

role

Read-only

The current role of the ICE transport.

state

Read-only

The current state of the ICE transport.

 

Standards information

Interface Definition

[Constructor(optional RTCIceGatherer gatherer)]
interface RTCIceTransport : RTCStatsProvider {
    readonly    attribute RTCIceGatherer?      iceGatherer;
    readonly    attribute RTCIceRole           role;
    readonly    attribute RTCIceComponent      component;
    readonly    attribute RTCIceTransportState state;
    sequence<RTCIceCandidate> getRemoteCandidates ();
    RTCIceCandidatePair?      getNominatedCandidatePair ();
    void                      start (RTCIceGatherer gatherer, RTCIceParameters remoteParameters, optional RTCIceRole role);
    void                      stop ();
    RTCIceParameters?         getRemoteParameters ();
    RTCIceTransport           createAssociatedTransport ();
    void                      addRemoteCandidate (RTCIceGatherCandidate remoteCandidate);
    void                      setRemoteCandidates (sequence<RTCIceCandidate> remoteCandidates);
                attribute EventHandler?        onicestatechange;
};

Example

Demonstrates 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 iceRtpTransport = []; 
var iceRtcpTransport = []; 
var i = 0 ;
                            // Set up response function
mySignaller.onResponse = function(responseSignaller,response) {
                             // We may get N responses
                             // Create the ICE RTP and RTCP transports
  i = iceRtpTransport.push(new RTCIceTransport(iceRtpGatherer)) - 1;
  iceRtcpTransport.push(iceRtpTransport.createAssociatedTransport());
                            // Start the RTP and RTCP ICE transports so that outgoing ICE connectivity checks can begin
  iceRtpTransport[i].start(iceRtpGatherer, response.icertp, RTCIceRole.controlling);
  iceRtcpTransport[i].start(iceRtcpGatherer, response.icertcp, RTCIceRole.controlling); 
                            // 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 j = 0;
    for (j=0; j < iceTransport.length; j++){
      if (getRemoteParameters(iceTransport(j)).userNameFragment === remote.parameters.userNameFragment){
        if (remote.component === RTCIceComponent.RTP){
          iceRtpTransport[j].addRemoteCandidate(remote.candidate);
        } else {
          iceRtcpTransport[j].addRemoteCandidate(remote.candidate);
        }
      }
    } 
  };
}; 
mySignaller.send({
   "icertp": iceRtpGatherer.getLocalParameters(),
   "icertcp": iceRtcpGatherer.getLocalParameters()
});