Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. RTCRtpReceiver
  4. getStats()

RTCRtpReceiver: getStats() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨March 2019⁩.

TheRTCRtpReceiver methodgetStats() asynchronously requests anRTCStatsReport object which provides statistics about incoming traffic on the owningRTCPeerConnection, returning aPromise whose fulfillment handler will be called once the results are available.

Syntax

js
getStats()

Parameters

None.

Return value

A JavaScriptPromise which is fulfilled once the statistics are available.The promise's fulfillment handler receives as a parameter aRTCStatsReport object containing the collected statistics.

The returned statistics include those from all streams which are coming in through theRTCRtpReceiver, as well as any of their dependencies.

These might include, for example, statistics withtypes:inbound-rtp,candidate-pair,local-candidate,remote-candidate.

Examples

This simple example obtains the statistics for anRTCRtpReceiver and updates an element'sinnerText to display the number of packets lost.

js
receiver.getStats().then((stats) => {  document.getElementById("lost-packets").innerText = stats.packetsLost;});

Specifications

Specification
WebRTC: Real-Time Communication in Browsers
# widl-RTCRtpReceiver-getStats-Promise-RTCStatsReport

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp