大网数据广告活动
Web 标准与前端开发

RTCRemoteInboundRtpStreamStats

· 52CE 我爱测

The **`RTCRemoteInboundRtpStreamStats`** dictionary of the WebRTC API is used to report statistics from the remote endpoint about a particular incoming RTP stream. These will correspond to an outgoing RTP stream at the local end of the RTCPeerConnection.

WebRTC

The RTCRemoteInboundRtpStreamStats dictionary of the WebRTC API is used to report statistics from the remote endpoint about a particular incoming RTP stream. These will correspond to an outgoing RTP stream at the local end of the RTCPeerConnection.

The statistics can be obtained by iterating the RTCStatsReport returned by RTCPeerConnection.getStats() or RTCRtpReceiver.getStats() until you find a report with the type of remote-inbound-rtp.

Instance properties

Remote inbound specific statistics

  • RTCRemoteInboundRtpStreamStats.fractionLost
    • : A number indicating the fraction of packets lost for this SSRC since the last sender or receiver report.
  • RTCRemoteInboundRtpStreamStats.localId
  • RTCRemoteInboundRtpStreamStats.roundTripTime
    • : A number that indicates the estimated round trip time (RTT) for this SSRC, in seconds. This property will not exist until valid RTT data has been received.
  • RTCRemoteInboundRtpStreamStats.roundTripTimeMeasurements
  • RTCRemoteInboundRtpStreamStats.totalRoundTripTime
    • : A number indicating the cumulative sum of all round trip time measurements since the beginning of the session, in seconds. The average round trip time can be computed by dividing totalRoundTripTime by roundTripTimeMeasurements.

Received RTP stream statistics

  • RTCRemoteInboundRtpStreamStats.jitter
    • : A number indicating the jitter for this synchronization source, measured in seconds.
  • RTCRemoteInboundRtpStreamStats.packetsLost
    • : An integer indicating the total number of RTP packets lost for this SSRC, as measured at the remote endpoint. This value can be negative if duplicate packets were received.
  • RTCRemoteInboundRtpStreamStats.packetsReceived
    • : A positive integer indicating the total number of RTP packets received for this SSRC, including retransmissions.

Common RTP stream statistics

  • RTCRemoteInboundRtpStreamStats.codecId
    • : A string that uniquely identifies the object that was inspected to produce the RTCCodecStats object associated with this RTP stream.
  • RTCRemoteInboundRtpStreamStats.kind
    • : A string indicating whether the MediaStreamTrack associated with the stream is an audio or a video track.
  • RTCRemoteInboundRtpStreamStats.ssrc
    • : A positive integer that identifies the SSRC of the RTP packets in this stream.
  • RTCRemoteInboundRtpStreamStats.transportId
    • : A string that uniquely identifies the object which was inspected to produce the RTCTransportStats object associated with this RTP stream.

Common instance properties

The following properties are common to all WebRTC statistics objects.

  • RTCRemoteInboundRtpStreamStats.id
    • : A string that uniquely identifies the object that is being monitored to produce this set of statistics.
  • RTCRemoteInboundRtpStreamStats.timestamp
    • : A DOMHighResTimeStamp object indicating the time at which the sample was taken for this statistics object.
  • RTCRemoteInboundRtpStreamStats.type
    • : A string with the value "inbound-rtp", indicating the type of statistics that the object contains.

Examples

Given a variable peerConnection that is an instance of an RTCPeerConnection, the code below uses await to wait for the statistics report, and then iterates it using RTCStatsReport.forEach(). It then filters the dictionaries for just those reports that have the type of remote-inbound-rtp and logs the result.

const stats = await myPeerConnection.getStats();

stats.forEach((report) => {
  if (report.type === "remote-inbound-rtp") {
    console.log("Remote Inbound RTP Stream Stats:");
    console.log(`id: ${report.id}`);
    console.log(`timestamp: ${report.timestamp}`);
    console.log(`transportId: ${report.transportId}`);
    console.log(`ssrc: ${report.ssrc}`);
    console.log(`kind: ${report.kind}`);
    console.log(`codecId: ${report.codecId}`);
    console.log(`packetsReceived: ${report.packetsReceived}`);
    console.log(`packetsLost: ${report.packetsLost}`);
    console.log(`jitter: ${report.jitter}`);
    console.log(`totalRoundTripTime: ${report.totalRoundTripTime}`);
    console.log(
      `roundTripTimeMeasurements: ${report.roundTripTimeMeasurements}`,
    );
    console.log(`roundTripTime: ${report.roundTripTime}`);
    console.log(`localId: ${report.localId}`);
    console.log(`fractionLost: ${report.fractionLost}`);
  }
});

Specifications

Browser compatibility

See also

  • RTCStatsReport

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。