8.2 RTCPeerConnection Interface Extensions
The Statistics API extends the RTCPeerConnection
interface as described below.
- WebIDL partial interface
RTCPeerConnection
{- Promise<
RTCStatsReport
>getStats
(optional MediaStreamTrack? selector = null);- };
Methods
getStats
Gathers stats for the given selector and reports the result asynchronously.
When the getStats
()
method is invoked, the user agent MUST run the following steps:
Let selectorArg be the method’s first argument.
Let connection be the
RTCPeerConnection
object on which the method was invoked.If selectorArg is
null
, let selector benull
.If selectorArg is a
MediaStreamTrack
let selector be anRTCRtpSender
orRTCRtpReceiver
on connection whichtrack
attribute matches selectorArg. If no such sender or receiver exists, or if more than one sender or receiver fit this criteria, return a promise rejected with a newly createdInvalidAccessError
.Let p be a new promise.
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.