5.3 RTCRtpReceiver
Interface
The RTCRtpReceiver
interface allows an application to inspect the receipt of a MediaStreamTrack
.
To create an RTCRtpReceiver with a string, kind, run the following steps:
Let receiver be a new
RTCRtpReceiver
object.Let track be a new
MediaStreamTrack
object [GETUSERMEDIA]. The source of track is a remote source provided by receiver. Note that the track.id
is generated by the user agent and does not map to any track IDs on the remote side.Initialize track.kind to kind.
Initialize track.label to the result of concatenating the string
"remote "
with kind.Initialize track.readyState to
live
.Initialize track.muted to
true
. See the MediaStreamTrack section about how themuted
attribute reflects if aMediaStreamTrack
is receiving media data or not.Let receiver have a [[ReceiverTrack]] internal slot initialized to track.
Let receiver have a [[ReceiverTransport]] internal slot initialized to
null
.Let receiver have a [[LastStableStateReceiverTransport]] internal slot initialized to
null
.Let receiver have an [[AssociatedRemoteMediaStreams]] internal slot, representing a list of
MediaStream
objects that theMediaStreamTrack
object of this receiver is associated with, and initialized to an empty list.Let receiver have a [[LastStableStateAssociatedRemoteMediaStreams]] internal slot and initialize it to an empty list.
Let receiver have a [[ReceiveCodecs]] internal slot, representing a list of
RTCRtpCodecParameters
dictionaries, and initialized to an empty list.Let receiver have a [[LastStableStateReceiveCodecs]] internal slot and initialize it to an empty list.
Return receiver.
- WebIDL[Exposed=Window]
- interface
RTCRtpReceiver
{- readonly attribute MediaStreamTrack
track
;- readonly attribute
RTCDtlsTransport
?transport
;- static
RTCRtpCapabilities
?getCapabilities
(DOMString kind);RTCRtpReceiveParameters
getParameters
();- sequence<
RTCRtpContributingSource
>getContributingSources
();- sequence<
RTCRtpSynchronizationSource
>getSynchronizationSources
();- Promise<
RTCStatsReport
>getStats
();- };
Attributes
track
of type MediaStreamTrack
, readonly
The track
attribute is the track that is associated with this RTCRtpReceiver
object receiver.
Note that track
.stop()
is final, although clones are not affected. Since receiver.track
.stop()
does not implicitly stop receiver, Receiver Reports continue to be sent. On getting, the attribute MUST return the value of the [[ReceiverTrack]] slot.
transport
of type RTCDtlsTransport
, readonly, nullable
The transport
attribute is the transport over which media for the receiver’s track
is received in the form of RTP packets. Prior to construction of the RTCDtlsTransport
object, the transport
attribute will be null
. When bundling is used, multiple RTCRtpReceiver
objects will share one transport
and will all receive RTP and RTCP over the same transport.
On getting, the attribute MUST return the value of the [[ReceiverTransport]] slot.
Methods
getCapabilities
, static
The getCapabilities
()
method returns the most optimistic view of the capabilities of the system for receiving media of the given kind. It does not reserve any resources, ports, or other state but is meant to provide a way to discover the types of capabilities of the browser including which codecs may be supported. User agents MUST support kind values of "audio"
and "video"
. If the system has no capabilities corresponding to the value of the kind argument, getCapabilities
returns null
.
These capabilities provide generally persistent cross-origin information on the device and thus increases the fingerprinting surface of the application. In privacy-sensitive contexts, browsers can consider mitigations such as reporting only a common subset of the capabilities.
Note
The codec capabilities returned affect the setCodecPreferences
()
algorithm and what inputs it throws InvalidModificationError
on, and should also be consistent with information revealed by createOffer
()
and createAnswer
()
about codecs negotiated for reception, to ensure any privacy mitigations are effective.
getParameters
The getParameters
()
method returns the RTCRtpReceiver
object’s current parameters for how track
is decoded.
When getParameters
is called, the RTCRtpReceiveParameters
dictionary is constructed as follows:
- The
headerExtensions
sequence is populated based on the header extensions that the receiver is currently prepared to receive. codecs
is set to the value of the [[ReceiveCodecs]] internal slot.Note
Both the local and remote description may affect this list of codecs. For example, if three codecs are offered, the receiver will be prepared to receive each of them and will return them all from
getParameters
. But if the remote endpoint only answers with two, the absent codec will no longer be returned bygetParameters
as the receiver no longer needs to be prepared to receive it.rtcp
.reducedSize
is set totrue
if the receiver is currently prepared to receive reduced-size RTCP packets, andfalse
otherwise.rtcp
.cname
is left out.
getContributingSources
Returns an RTCRtpContributingSource
for each unique CSRC identifier received by this RTCRtpReceiver
in the last 10 seconds, in descending timestamp
order.
getSynchronizationSources
Returns an RTCRtpSynchronizationSource
for each unique SSRC identifier received by this RTCRtpReceiver
in the last 10 seconds, in descending timestamp
order.
getStats
Gathers stats for this receiver only and reports the result asynchronously.
When the getStats
()
method is invoked, the user agent MUST run the following steps:
Let selector be the
RTCRtpReceiver
object on which the method was invoked.Let p be a new promise, and run the following steps in parallel:
Gather the stats indicated by selector according to the stats selection algorithm.
Resolve p with the resulting
RTCStatsReport
object, containing the gathered stats.
Return p.
The RTCRtpContributingSource
and RTCRtpSynchronizationSource
dictionaries contain information about a given contributing source (CSRC) or synchronization source (SSRC) respectively. When an audio or video frame from one or more RTP packets is delivered to the RTCRtpReceiver
‘s MediaStreamTrack
, the user agent MUST queue a task to update the relevant information for the RTCRtpContributingSource
and RTCRtpSynchronizationSource
dictionaries based on the content of those packets. The information relevant to the RTCRtpSynchronizationSource
dictionary corresponding to the SSRC identifier, is updated each time, and if an RTP packet contains CSRC identifiers, then the information relevant to the RTCRtpContributingSource
dictionaries corresponding to those CSRC identifiers is also updated. The user agent MUST process RTP packets in order of ascending RTP timestamps. The user agent MUST keep information from RTP packets delivered to the RTCRtpReceiver
‘s MediaStreamTrack
in the previous 10 seconds.
Note
Even if the MediaStreamTrack
is not attached to any sink for playout, getSynchronizationSources
and getContributingSources
returns up-to-date information as long as the track is not ended; sinks are not a prerequisite for decoding RTP packets.
Note
As stated in the conformance section, requirements phrased as algorithms may be implemented in any manner so long as the end result is equivalent. So, an implementation does not need to literally queue a task for every frame, as long as the end result is that within a single event loop task execution, all returned RTCRtpSynchronizationSource
and RTCRtpContributingSource
dictionaries for a particular RTCRtpReceiver
contain information from a single point in the RTP stream.
- WebIDLdictionary
RTCRtpContributingSource
{- required DOMHighResTimeStamp
timestamp
;- required unsigned long
source
;- double
audioLevel
;- required unsigned long
rtpTimestamp
;- };
Dictionary RTCRtpContributingSource Members
timestamp
of type DOMHighResTimeStamp
, required
The timestamp
indicating the most recent time a frame from an RTP packet, originating from this source, was delivered to the RTCRtpReceiver
‘s MediaStreamTrack
. The timestamp
is defined as Performance
.timeOrigin
+ Performance
.now
()
at that time.
source
of type unsigned long, required
The CSRC or SSRC identifier of the contributing or synchronization source.
audioLevel
of type double
Only present for audio receivers. This is a value between 0..1 (linear), where 1.0 represents 0 dBov, 0 represents silence, and 0.5 represents approximately 6 dBSPL change in the sound pressure level from 0 dBov.
For CSRCs, this MUST be converted from the level value defined in [RFC6465] if the RFC 6465 header extension is present, otherwise this member MUST be absent.
For SSRCs, this MUST be converted from the level value defined in [RFC6464]. If the RFC 6464 header extension is not present in the received packets (such as if the other endpoint is not a user agent or is a legacy endpoint), this value SHOULD be absent.
Both RFCs define the level as an integral value from 0 to 127 representing the audio level in negative decibels relative to the loudest signal that the system could possibly encode. Thus, 0 represents the loudest signal the system could possibly encode, and 127 represents silence.
To convert these values to the linear 0..1 range, a value of 127 is converted to 0, and all other values are converted using the equation: 10^(-rfc_level/20)
.
rtpTimestamp
of type unsigned long, required
The last RTP timestamp, as defined in [RFC3550] Section 5.1, of the media played out at timestamp.
- WebIDL dictionary
RTCRtpSynchronizationSource
:RTCRtpContributingSource
{- };
The RTCRtpSynchronizationSource
dictionary is expected to serve as an extension point for the specification to surface data only available in SSRCs.