Attributes

    ontrack of type EventHandler

    The event type of this event handler is .

    Methods

    getSenders

    Returns a sequence of RTCRtpSender objects representing the RTP senders that belong to non-stopped objects currently attached to this RTCPeerConnection object.

    When the method is invoked, the user agent MUST return the result of executing the CollectSenders algorithm.

    We define the CollectSenders algorithm as follows:

    1. Let transceivers be the result of executing the algorithm.
    2. Let senders be a new empty sequence.
    3. For each transceiver in transceivers,
      1. If transceiver.[[Stopped]] is false, add transceiver. to senders.
    4. Return senders.

    getReceivers

    Returns a sequence of RTCRtpReceiver objects representing the RTP receivers that belong to non-stopped objects currently attached to this RTCPeerConnection object.

    When the method is invoked, the user agent MUST run the following steps:

    1. Let transceivers be the result of executing the CollectTransceivers algorithm.
    2. Let receivers be a new empty sequence.
    3. For each transceiver in transceivers,
      1. If transceiver. is false, add transceiver.[[Receiver]] to receivers.
    4. Return receivers.

    getTransceivers

    Returns a sequence of objects representing the RTP transceivers that are currently attached to this RTCPeerConnection object.

    The method MUST return the result of executing the CollectTransceivers algorithm.

    We define the CollectTransceivers algorithm as follows:

    1. Let transceivers be a new sequence consisting of all objects in this RTCPeerConnection object’s , in insertion order.
    2. Return transceivers.

    addTrack

    Adds a new track to the RTCPeerConnection, and indicates that it is contained in the specified s.

    When the addTrack method is invoked, the user agent MUST run the following steps:

    1. Let connection be the object on which this method was invoked.

    2. Let track be the MediaStreamTrack object indicated by the method’s first argument.

    3. Let kind be track.kind.

    4. Let streams be a list of objects constructed from the method’s remaining arguments, or an empty list if the method was called with a single argument.

    5. If connection.[[IsClosed]] is true, an InvalidStateError.

    6. Let senders be the result of executing the algorithm. If an RTCRtpSender for track already exists in senders, an InvalidAccessError.

    7. The steps below describe how to determine if an existing sender can be reused. Doing so will cause future calls to and createAnswer to mark the corresponding as sendrecv or sendonly and add the MSID of the sender’s streams, as defined in [RFC8829] ( and section 5.3.2.).

      If any object in senders matches all the following criteria, let sender be that object, or null otherwise:

      • The sender’s track is null.

      • The transceiver kind of the , associated with the sender, matches kind.

      • The [[Stopping]] slot of the associated with the sender is false.

      • The sender has never been used to send. More precisely, the [[CurrentDirection]] slot of the associated with the sender has never had a value of “sendrecv“ or ““.

    8. If sender is not null, run the following steps to use that sender:

      1. Set sender.[[SenderTrack]] to track.

      2. Set sender. to an empty set.

      3. For each stream in streams, add stream.id to [[AssociatedMediaStreamIds]] if it’s not already there.

      4. If transceiver. is “recvonly“, set transceiver. to “sendrecv“.

      5. If transceiver. is “inactive“, set transceiver. to “sendonly“.

    9. If sender is null, run the following steps:

      1. with track, kind and streams, and let sender be the result.

      2. Create an RTCRtpReceiver with kind, and let receiver be the result.

      3. with sender, receiver and an RTCRtpTransceiverDirection value of ““, and let transceiver be the result.

      4. Add transceiver to connection’s set of transceivers.

    10. A track could have contents that are inaccessible to the application. This can be due to anything that would make a track . These tracks can be supplied to the addTrack() method, and have an created for them, but content MUST NOT be transmitted. Silence (audio), black frames (video) or equivalently absent content is sent in place of track content.

    11. Update the negotiation-needed flag for connection.

    12. Return sender.

    removeTrack

    Stops sending media from sender. The will still appear in getSenders. Doing so will cause future calls to to mark the media description for the corresponding transceiver as ““ or “inactive“, as defined in [] (section 5.2.2.).

    When the other peer stops sending a track in this manner, the track is removed from any remote s that were initially revealed in the track event, and if the MediaStreamTrack is not already muted, a mute event is fired at the track.

    Note

    The same effect as () can be achieved by setting the RTCRtpTransceiver. attribute of the corresponding transceiver and invoking RTCRtpSender.(null) on the sender. One minor difference is that () is asynchronous and () is synchronous.

    When the removeTrack method is invoked, the user agent MUST run the following steps:

    1. Let sender be the argument to .

    2. Let connection be the RTCPeerConnection object on which the method was invoked.

    3. If connection. is true, throw an .

    4. If sender was not created by connection, throw an .

    5. Let senders be the result of executing the CollectSenders algorithm.

    6. If sender is not in senders (which indicates its transceiver was stopped or removed due to of type ““), then abort these steps.

    7. If sender.[[SenderTrack]] is null, abort these steps.

    8. Set sender. to null.

    9. Let transceiver be the RTCRtpTransceiver object corresponding to sender.

    10. If transceiver. is “sendrecv“, set transceiver. to “recvonly“.

    11. If transceiver. is “sendonly“, set transceiver. to “inactive“.

    12. for connection.

    addTransceiver

    Create a new RTCRtpTransceiver and add it to the .

    Adding a transceiver will cause future calls to createOffer to add a for the corresponding transceiver, as defined in [RFC8829] ().

    The initial value of mid is null. may later change it to a non-null value.

    The sendEncodings argument can be used to specify the number of offered simulcast encodings, and optionally their RIDs and encoding parameters.

    When this method is invoked, the user agent MUST run the following steps:

    1. Let init be the second argument.

    2. Let streams be init..

    3. Let sendEncodings be init.sendEncodings.

    4. Let direction be init..

    5. If the first argument is a string, let it be kind and run the following steps:

      1. If kind is not a legal MediaStreamTrack kind, a TypeError.

      2. Let track be null.

    6. If the first argument is a , let it be track and let kind be track.kind.

    7. If connection.[[IsClosed]] is true, an InvalidStateError.

    8. with track, kind, streams and sendEncodings and let sender be the result.

      If sendEncodings is set, then subsequent calls to createOffer will be configured to send multiple RTP encodings as defined in [] (section 5.2.2. and ). When setRemoteDescription is called with a corresponding remote description that is able to receive multiple RTP encodings as defined in [] (section 3.7.), the may send multiple RTP encodings and the parameters retrieved via the transceiver’s sender.() will reflect the encodings negotiated.

    9. Create an RTCRtpReceiver with kind and let receiver be the result.

    10. with sender, receiver and direction, and let transceiver be the result.

    11. Add transceiver to connection’s set of transceivers.

    12. for connection.

    13. Return transceiver.

    Dictionary RTCRtpTransceiverInit Members

    direction of type RTCRtpTransceiverDirection, defaulting to ““

    The direction of the RTCRtpTransceiver.

    streams of type sequence<>

    When the remote PeerConnection’s track event fires corresponding to the RTCRtpReceiver being added, these are the streams that will be put in the event.

    sendEncodings of type sequence<>

    A sequence containing parameters for sending RTP encodings of media.

    5.1.1 Processing Remote MediaStreamTracks

    An application can reject incoming media descriptions by setting the transceiver’s direction to either “inactive“ to turn off both directions temporarily, or to ““ to reject only the incoming side. To permanently reject an m-line in a manner that makes it available for reuse, the application would need to call RTCRtpTransceiver.() and subsequently initiate negotiation from its end.

    To process remote tracks given an RTCRtpTransceiver transceiver, direction, msids, addList, removeList, and trackEventInits, run the following steps:

    1. with transceiver.[[Receiver]], msids, addList, and removeList.

    2. If direction is ““ or “recvonly“ and transceiver. is neither “sendrecv“ nor ““, or the previous step increased the length of addList, process the addition of a remote track with transceiver and trackEventInits.

    3. If direction is ““ or “inactive“, set transceiver. to false.

    4. If direction is “sendonly“ or ““, and transceiver.[[FiredDirection]] is either ““ or “recvonly“, for the media description, with transceiver and muteTracks.

    5. Set transceiver. to direction.

    To process the addition of a remote track given an RTCRtpTransceiver transceiver and trackEventInits, run the following steps:

    1. Let receiver be transceiver..

    2. Let track be receiver.[[ReceiverTrack]].

    3. Let streams be receiver..

    4. Create a new RTCTrackEventInit dictionary with receiver, track, streams and transceiver as members and add it to trackEventInits.

    To process the removal of a remote track with an transceiver and muteTracks, run the following steps:

    1. Let receiver be transceiver.[[Receiver]].

    2. Let track be receiver..

    3. If track.muted is false, add track to muteTracks.

    To set the associated remote streams given RTCRtpReceiver receiver, msids, addList, and removeList, run the following steps:

    1. Let connection be the object associated with receiver.

    2. For each MSID in msids, unless a MediaStream object has previously been created with that id for this connection, create a object with that id.

    3. Let streams be a list of the objects created for this connection with the ids corresponding to msids.

    4. Let track be receiver..

    5. For each stream in receiver.[[AssociatedRemoteMediaStreams]] that is not present in streams, add stream and track as a pair to removeList.

    6. Set receiver. to streams.