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:
- Let transceivers be the result of executing the algorithm.
- Let senders be a new empty sequence.
- For each transceiver in transceivers,
- If transceiver.[[Stopped]] is
false
, add transceiver. to senders.
- If transceiver.[[Stopped]] is
- 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:
- Let transceivers be the result of executing the
CollectTransceivers
algorithm. - Let receivers be a new empty sequence.
- For each transceiver in transceivers,
- If transceiver. is
false
, add transceiver.[[Receiver]] to receivers.
- If transceiver. is
- 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:
- Let transceivers be a new sequence consisting of all objects in this
RTCPeerConnection
object’s , in insertion order. - 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:
Let connection be the object on which this method was invoked.
Let track be the
MediaStreamTrack
object indicated by the method’s first argument.Let kind be track.kind.
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.
If connection.[[IsClosed]] is
true
, anInvalidStateError
.Let senders be the result of executing the algorithm. If an
RTCRtpSender
for track already exists in senders, anInvalidAccessError
.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 assendrecv
orsendonly
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 ““.
If sender is not
null
, run the following steps to use that sender:Set sender.[[SenderTrack]] to track.
Set sender. to an empty set.
For each stream in streams, add stream.id to [[AssociatedMediaStreamIds]] if it’s not already there.
If transceiver. is “
recvonly
“, set transceiver. to “sendrecv
“.If transceiver. is “
inactive
“, set transceiver. to “sendonly
“.
If sender is
null
, run the following steps:with track, kind and streams, and let sender be the result.
Create an RTCRtpReceiver with kind, and let receiver be the result.
with sender, receiver and an
RTCRtpTransceiverDirection
value of ““, and let transceiver be the result.Add transceiver to connection’s set of transceivers.
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.Update the negotiation-needed flag for connection.
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:
Let sender be the argument to .
Let connection be the
RTCPeerConnection
object on which the method was invoked.If connection. is
true
, throw an .If sender was not created by connection, throw an .
Let senders be the result of executing the
CollectSenders
algorithm.If sender is not in senders (which indicates its transceiver was stopped or removed due to of
type
““), then abort these steps.If sender.[[SenderTrack]] is null, abort these steps.
Set sender. to null.
Let transceiver be the
RTCRtpTransceiver
object corresponding to sender.If transceiver. is “
sendrecv
“, set transceiver. to “recvonly
“.If transceiver. is “
sendonly
“, set transceiver. to “inactive
“.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:
Let init be the second argument.
Let streams be init..
Let sendEncodings be init.
sendEncodings
.Let direction be init..
If the first argument is a string, let it be kind and run the following steps:
If kind is not a legal
MediaStreamTrack
kind
, aTypeError
.Let track be
null
.
If the first argument is a , let it be track and let kind be track.kind.
If connection.[[IsClosed]] is
true
, anInvalidStateError
.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 ). WhensetRemoteDescription
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’ssender
.()
will reflect the encodings negotiated.Create an RTCRtpReceiver with kind and let receiver be the result.
with sender, receiver and direction, and let transceiver be the result.
Add transceiver to connection’s set of transceivers.
for connection.
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:
with transceiver.[[Receiver]], msids, addList, and removeList.
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.If direction is ““ or “
inactive
“, set transceiver. tofalse
.If direction is “
sendonly
“ or ““, and transceiver.[[FiredDirection]] is either ““ or “recvonly
“, for the media description, with transceiver and muteTracks.Set transceiver. to direction.
To process the addition of a remote track given an RTCRtpTransceiver
transceiver and trackEventInits, run the following steps:
Let receiver be transceiver..
Let track be receiver.[[ReceiverTrack]].
Let streams be receiver..
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:
Let receiver be transceiver.[[Receiver]].
Let track be receiver..
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:
Let connection be the object associated with receiver.
For each MSID in msids, unless a
MediaStream
object has previously been created with thatid
for this connection, create a object with thatid
.Let streams be a list of the objects created for this connection with the
id
s corresponding to msids.Let track be receiver..
For each stream in receiver.[[AssociatedRemoteMediaStreams]] that is not present in streams, add stream and track as a pair to removeList.
Set receiver. to streams.