Skip to content

Commit

Permalink
RTCRemoteInboundRtpStreamStats - plus alignment with outbound (#32657)
Browse files Browse the repository at this point in the history
* RTCRemoteInboundRtpStreamStats: id

* RTCRemoteInboundRtpStreamStats.timestamp

* RTCRemoteInboundRtpStreamStats.type

* RTCRemoteInboundRtpStreamStats.transportId

* RTCRemoteOuboundRtpStreamStats.transportId - match to inbound

* RTCRemoteInboundRtpStreamStats.ssrc

* RTCRemoteOutboundRtpStreamStats.ssrc - alignment

* RTCRemoteInboundRtpStreamStats.kind

* RTCRemoteOutboundRtpStreamStats.kind - alignment

* Tweaks/aligment for transport id

* RTCRemoteInboundRtpStreamStats.codecId

* RTCRemoteOutboundRtpStreamStats.codecId - alignment

* RTCRemoteOutboundRtpStreamStats improve description

* RTCRemoteInboundRtpStreamStats - partial draft

* RTCRemoteInboundRtpStreamStats.jitter and glossary

* RTCRemoteInboundRtpStreamStats.packetsLost

* RTCRemoteInboundRtpStreamStats.packetsReceived

* Minor fixes to timestamp

* rttmeasurements property

* Add RTCRemoteInboundStats to sidebar

* Assorted minor improvements

* RTCRemoteInboutRtpStreamStats.totalrtt, localid, rttmeas

* RTCRemoteOutboundRtpStreamStats - matching localid, rttmeas, totalrtt

* RTCRemoteInboundRtpStreamStats.roundTripTime

* RTCRemoteInboundRtpStreamStats.fractionLost

* Apply suggestions from code review

Co-authored-by: wbamberg <will@bootbonnet.ca>

* Update files/en-us/web/api/rtcremoteinboundrtpstreamstats/index.md

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Stat properties in alphabetic order. Fix NOTE to new form

* fractionLost - tidy and point solely to algorithm for info on how it is calc.

* Note that the value is not precise, but is a  useful indicator

* Apply suggestions from code review

Co-authored-by: wbamberg <will@bootbonnet.ca>

---------

Co-authored-by: wbamberg <will@bootbonnet.ca>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 2, 2024
1 parent eb8f6c1 commit cd49415
Show file tree
Hide file tree
Showing 26 changed files with 691 additions and 45 deletions.
13 changes: 13 additions & 0 deletions files/en-us/glossary/jitter/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: Jitter
slug: Glossary/Jitter
page-type: glossary-definition
---

{{GlossarySidebar}}

**Jitter** is the term used in computer networking to refer to [packet delay variation](https://en.wikipedia.org/wiki/Packet_delay_variation) — the variance in the rate at which packets arrive at a destination (the average of the squared difference from the mean packet arrival rate).

"High jitter" indicates that packets are arriving at significantly varying rates, possibly due to network congestion, packet loss, and routing of packets in a stream through different paths.

High jitter can significantly degrade the performance of real-time web applications, including voice/video streaming and online gaming.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: "RTCRemoteInboundRtpStreamStats: codecId property"
short-title: codecId
slug: Web/API/RTCRemoteInboundRtpStreamStats/codecId
page-type: web-api-instance-property
browser-compat: api.RTCStatsReport.type_remote-outbound-rtp.codecId
---

{{APIRef("WebRTC")}}

The **`codecId`** property of the {{domxref("RTCRemoteInboundRtpStreamStats")}} dictionary is a string that uniquely identifies the object that was inspected to produce the data in the {{domxref("RTCCodecStats")}} for the {{Glossary("RTP")}} stream.

`RTCRemoteInboundRtpStreamStats` and `RTCCodecStats` objects are correlated by iterating the {{domxref("RTCStatsReport")}} to find the statistics objects where `RTCRemoteInboundRtpStreamStats.codecId` is equal to {{domxref("RTCCodecStats.id")}}.

## Value

A string that contains the {{domxref("RTCCodecStats.id","id")}} of the object that was inspected to produce the {{domxref("RTCCodecStats")}} object associated with this RTP stream.

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: "RTCRemoteInboundRtpStreamStats: fractionLost property"
short-title: fractionLost
slug: Web/API/RTCRemoteInboundRtpStreamStats/fractionLost
page-type: web-api-instance-property
browser-compat: api.RTCStatsReport.type_remote-inbound-rtp.fractionLost
---

{{APIRef("WebRTC")}}

The **`fractionLost`** property of the {{domxref("RTCRemoteInboundRtpStreamStats")}} dictionary provides a value that can be used to determine the fraction of packets lost for this [synchronization source (SSRC)](/en-US/docs/Web/API/RTCRemoteInboundRtpStreamStats/ssrc) in the last reporting interval.

To convert the value to a percentage, divide it by 256 and multiply by 100.
For example, a value of 20 indicates a 7.8% packet loss.

Note that the value may not be precisely accurate due to the way that it is calculated, but it does provides a quick and convenient measure of the link quality.

## Value

A number giving the fraction packet loss in the last reporting interval, multiplied by 256.
The value is 0 if the calculated packet loss is negative.

> [!NOTE]
> The value comes from the 8-bit `fraction lost` field of the last Sender Report (SR) or Receiver Report (RR) RTCP packet.
> The algorithm for calculating the value is defined in [RFC 3550, Appendix A.3: Determining Number of Packets Expected and Lost](https://datatracker.ietf.org/doc/html/rfc3550#appendix-A.3).
## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{rfc("3550","SR: Sender Report RTCP Packet", "6.4.1")}}
- {{rfc("3550","RR: Receiver Report RTCP Packet", "6.4.2")}}
27 changes: 27 additions & 0 deletions files/en-us/web/api/rtcremoteinboundrtpstreamstats/id/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: "RTCRemoteInboundRtpStreamStats: id property"
short-title: id
slug: Web/API/RTCRemoteInboundRtpStreamStats/id
page-type: web-api-instance-property
browser-compat: api.RTCStatsReport.type_remote-inbound-rtp.id
---

{{APIRef("WebRTC")}}

The **`id`** property of the {{domxref("RTCRemoteInboundRtpStreamStats")}} dictionary is a string that uniquely identifies the object for which this object provides statistics.

Using the `id`, you can correlate this statistics object with others, in order to monitor statistics over time for a given WebRTC object, such as an {{domxref("RTCPeerConnection")}}, or an {{domxref("RTCDataChannel")}}.

## Value

A string that uniquely identifies the object for which this `RTCRemoteInboundRtpStreamStats` object provides statistics.

The format of the ID string is not defined by the specification, so you cannot reliably make any assumptions about the contents of the string, or assume that the format of the string will remain unchanged for a given object type.

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}
113 changes: 113 additions & 0 deletions files/en-us/web/api/rtcremoteinboundrtpstreamstats/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
title: RTCRemoteInboundRtpStreamStats
slug: Web/API/RTCRemoteInboundRtpStreamStats
page-type: web-api-interface
browser-compat: api.RTCStatsReport.type_remote-inbound-rtp
---

{{APIRef("WebRTC")}}

The **`RTCRemoteInboundRtpStreamStats`** dictionary of the [WebRTC API](/en-US/docs/Web/API/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 {{domxref("RTCPeerConnection")}}.

The statistics can be obtained by iterating the {{domxref("RTCStatsReport")}} returned by {{domxref("RTCPeerConnection.getStats()")}} or {{domxref("RTCRtpReceiver.getStats()")}} until you find a report with the [`type`](#type) of `remote-inbound-rtp`.

## Instance properties

### Remote inbound specific statistics

<!-- RTCRemoteInboundRtpStreamStats -->

- {{domxref("RTCRemoteInboundRtpStreamStats.fractionLost", "fractionLost")}} {{optional_inline}}
- : A number indicating the fraction of packets lost for this SSRC since the last sender or receiver report.
- {{domxref("RTCRemoteInboundRtpStreamStats.localId", "localId")}} {{optional_inline}}
- : A string that is used to find the local {{domxref("RTCOutboundRtpStreamStats")}} object that shares the same [synchronization source (SSRC)](/en-US/docs/Web/API/RTCRemoteInboundRtpStreamStats/ssrc).
- {{domxref("RTCRemoteInboundRtpStreamStats.roundTripTime", "roundTripTime")}} {{optional_inline}}
- : 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.
- {{domxref("RTCRemoteInboundRtpStreamStats.roundTripTimeMeasurements", "roundTripTimeMeasurements")}} {{optional_inline}}
- : A positive integer indicating the total number of valid round trip time measurements received for this [synchronization source (SSRC)](#ssrc).
- {{domxref("RTCRemoteInboundRtpStreamStats.totalRoundTripTime", "totalRoundTripTime")}} {{optional_inline}}
- : 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`](#roundtriptimemeasurements).

### Received RTP stream statistics

<!-- RTCReceivedRtpStreamStats -->

- {{domxref("RTCRemoteInboundRtpStreamStats.jitter", "jitter")}} {{optional_inline}}
- : A number indicating the {{glossary("jitter", "packet jitter")}} for this synchronization source, measured in seconds.
- {{domxref("RTCRemoteInboundRtpStreamStats.packetsLost", "packetsLost")}} {{optional_inline}}
- : 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.
- {{domxref("RTCRemoteInboundRtpStreamStats.packetsReceived", "packetsReceived")}} {{optional_inline}}
- : A positive integer indicating the total number of RTP packets received for this SSRC, including retransmissions.

### Common RTP stream statistics

<!-- RTCRtpStreamStats -->

- {{domxref("RTCRemoteInboundRtpStreamStats.codecId", "codecId")}} {{optional_inline}}
- : A string that uniquely identifies the object that was inspected to produce the {{domxref("RTCCodecStats")}} object associated with this {{Glossary("RTP")}} stream.
- {{domxref("RTCRemoteInboundRtpStreamStats.kind", "kind")}}
- : A string indicating whether the {{domxref("MediaStreamTrack")}} associated with the stream is an audio or a video track.
- {{domxref("RTCRemoteInboundRtpStreamStats.ssrc", "ssrc")}}
- : A positive integer that identifies the SSRC of the RTP packets in this stream.
- {{domxref("RTCRemoteInboundRtpStreamStats.transportId", "transportId")}} {{optional_inline}}
- : A string that uniquely identifies the object which was inspected to produce the {{domxref("RTCTransportStats")}} object associated with this RTP stream.

### Common instance properties

The following properties are common to all WebRTC statistics objects.

<!-- RTCStats -->

- {{domxref("RTCRemoteInboundRtpStreamStats.id", "id")}}
- : A string that uniquely identifies the object that is being monitored to produce this set of statistics.
- {{domxref("RTCRemoteInboundRtpStreamStats.timestamp", "timestamp")}}
- : A {{domxref("DOMHighResTimeStamp")}} object indicating the time at which the sample was taken for this statistics object.
- {{domxref("RTCRemoteInboundRtpStreamStats.type", "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 {{domxref("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.

```js
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

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("RTCStatsReport")}}
32 changes: 32 additions & 0 deletions files/en-us/web/api/rtcremoteinboundrtpstreamstats/jitter/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: "RTCRemoteInboundRtpStreamStats: jitter property"
short-title: jitter
slug: Web/API/RTCRemoteInboundRtpStreamStats/jitter
page-type: web-api-instance-property
browser-compat: api.RTCStatsReport.type_remote-inbound-rtp.jitter
---

{{APIRef("WebRTC")}}

The **`jitter`** property of the {{domxref("RTCRemoteInboundRtpStreamStats")}} dictionary returns the {{glossary("Jitter", "packet jitter")}} for the [synchronization source (SSRC)](/en-US/docs/Web/API/RTCRemoteInboundRtpStreamStats/ssrc) as measured by the remote endpoint.

High packet jitter values indicate that packet arrival rates vary significantly, which may degrade video, audio, and other real-time communications over WebRTC.

## Value

Packet jitter, in seconds.

The value is calculated using the "interarrival jitter" algorithm described in {{RFC("3550", "", "6.4.1")}}.

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("RTCRemoteInboundRtpStreamStats.ssrc")}}
- {{domxref("RTCInboundRtpStreamStats.jitter")}}
31 changes: 31 additions & 0 deletions files/en-us/web/api/rtcremoteinboundrtpstreamstats/kind/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: "RTCRemoteInboundRtpStreamStats: kind property"
short-title: kind
slug: Web/API/RTCRemoteInboundRtpStreamStats/kind
page-type: web-api-instance-property
browser-compat: api.RTCStatsReport.type_remote-inbound-rtp.kind
---

{{APIRef("WebRTC")}}

The **`kind`** property of the {{domxref("RTCRemoteInboundRtpStreamStats")}} dictionary is a string indicating whether the described {{Glossary("RTP")}} stream contains audio or video media.

This string will always be the same as the {{domxref("MediaStreamTrack.kind", "kind")}} of the {{domxref("MediaStreamTrack")}} object carried by the stream.
It will also match the media type of the codec associated with this statistics objects (i.e. the MIME type of the associated codec's {{domxref("RTCCodecStats.mimeType")}} property).

## Value

The kind is always one of:

- `"audio"`
- : The stream contains audio media.
- `"video"`
- : The stream contains video media.

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: "RTCRemoteInboundRtpStreamStats: localId property"
short-title: localId
slug: Web/API/RTCRemoteInboundRtpStreamStats/localId
page-type: web-api-instance-property
browser-compat: api.RTCStatsReport.type_remote-inbound-rtp.localId
---

{{APIRef("WebRTC")}}

The {{domxref("RTCRemoteInboundRtpStreamStats")}} dictionary's **`localId`** property is a string that can be used to identify the {{domxref("RTCOutboundRtpStreamStats")}} object whose {{domxref("RTCOutboundRtpStreamStats.remoteId", "remoteId")}} matches this value.

Together, these two objects provide statistics about the inbound and outbound sides of the same [synchronization source (SSRC)](/en-US/docs/Web/API/RTCRemoteInboundRtpStreamStats/ssrc).

## Value

A string which can be compared to the value of an {{domxref("RTCOutboundRtpStreamStats")}} object's {{domxref("RTCOutboundRtpStreamStats.remoteId", "remoteId")}} property to see if the two represent statistics for each of the two sides of the same set of data sent by the local peer.

## Usage notes

You can think of the local and remote views of the same RTP stream as pairs, each of which has a reference back to the other one.
Thus, if an {{domxref("RTCStatsReport")}} includes an `remote-inbound-rtp` statistics object (of type `RTCRemoteInboundRtpStreamStats`), it should also have a corresponding `outbound-rtp` object.

Both of these provide information about the same batch of packets being sent from the local device to the remote peer.
The difference is that `outbound-rtp` offers statistics about the outgoing data from the local peer's perspective, while `remote-inbound-rtp` provides statistics about the same data from the perspective of the remote peer, as it is received.

## Examples

See the example in {{domxref("RTCRemoteOutboundRtpStreamStats.localId")}}.
This shows how to correlate statistics about data sent from the remote peer (from the perspective of the remote peer) with the incoming data from the perspective of the local peer.

The code to correlate send data from the perspective of the local peer and received data from the perspective of the remote peer would be almost the same, and can be inferred from that example.

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: "RTCRemoteInboundRtpStreamStats: packetsLost property"
short-title: packetsLost
slug: Web/API/RTCRemoteInboundRtpStreamStats/packetsLost
page-type: web-api-instance-property
browser-compat: api.RTCStatsReport.type_remote-inbound-rtp.packetsLost
---

{{APIRef("WebRTC")}}

The **`packetsLost`** property of the {{domxref("RTCRemoteInboundRtpStreamStats")}} dictionary returns the total number of {{Glossary("RTP")}} packets lost from the [synchronization source (SSRC)](/en-US/docs/Web/API/RTCRemoteInboundRtpStreamStats/ssrc), as reported by the remote endpoint, since the beginning of reception.

## Value

An integer value indicating the number of lost RTP packets.

This value can be negative.
It is determined by subtracting the number of packets received from the number of packets that are expected.
The number of packets that are expected is calculated in a way that assumes that all packets only need to be sent once (based on sequence numbers), while the number of packets received also includes any packets that had to be resent (and hence may be bigger).
For more information see the "cumulative number of packets lost" section in {{RFC("3550", "", "6.4.1")}}.

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("RTCRemoteInboundRtpStreamStats.ssrc")}}
- {{domxref("RTCInboundRtpStreamStats.packetsLost")}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: "RTCRemoteInboundRtpStreamStats: packetsReceived property"
short-title: packetsReceived
slug: Web/API/RTCRemoteInboundRtpStreamStats/packetsReceived
page-type: web-api-instance-property
browser-compat: api.RTCStatsReport.type_remote-inbound-rtp.packetsReceived
---

{{APIRef("WebRTC")}}

The **`packetsReceived`** property of the {{domxref("RTCRemoteInboundRtpStreamStats")}} dictionary returns the total number of {{Glossary("RTP")}} packets received from the [synchronization source (SSRC)](/en-US/docs/Web/API/RTCRemoteInboundRtpStreamStats/ssrc) of this stream by the remote endpoint, including retransmissions.

## Value

A positive integer value indicating the total number of received RTP packets at the remote endpoint.

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("RTCRemoteInboundRtpStreamStats.ssrc")}}
- {{domxref("RTCInboundRtpStreamStats.packetsReceived")}}
Loading

0 comments on commit cd49415

Please sign in to comment.