Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTCRemoteInboundRtpStreamStats - plus alignment with outbound #32657

Merged
merged 31 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3881033
RTCRemoteInboundRtpStreamStats: id
hamishwillee Mar 12, 2024
ca1e310
RTCRemoteInboundRtpStreamStats.timestamp
hamishwillee Mar 12, 2024
beb70b2
RTCRemoteInboundRtpStreamStats.type
hamishwillee Mar 12, 2024
bef50e1
RTCRemoteInboundRtpStreamStats.transportId
hamishwillee Mar 12, 2024
f076d94
RTCRemoteOuboundRtpStreamStats.transportId - match to inbound
hamishwillee Mar 12, 2024
3c9a7eb
RTCRemoteInboundRtpStreamStats.ssrc
hamishwillee Mar 12, 2024
6e60bce
RTCRemoteOutboundRtpStreamStats.ssrc - alignment
hamishwillee Mar 12, 2024
612d7ea
RTCRemoteInboundRtpStreamStats.kind
hamishwillee Mar 12, 2024
a787ea3
RTCRemoteOutboundRtpStreamStats.kind - alignment
hamishwillee Mar 12, 2024
63ddc88
Tweaks/aligment for transport id
hamishwillee Mar 12, 2024
913192b
RTCRemoteInboundRtpStreamStats.codecId
hamishwillee Mar 12, 2024
0366148
RTCRemoteOutboundRtpStreamStats.codecId - alignment
hamishwillee Mar 12, 2024
2e1ff32
RTCRemoteOutboundRtpStreamStats improve description
hamishwillee Mar 12, 2024
52b304a
RTCRemoteInboundRtpStreamStats - partial draft
hamishwillee Mar 12, 2024
48d9ec1
RTCRemoteInboundRtpStreamStats.jitter and glossary
hamishwillee Mar 15, 2024
8cca13c
RTCRemoteInboundRtpStreamStats.packetsLost
hamishwillee Mar 15, 2024
e92d083
RTCRemoteInboundRtpStreamStats.packetsReceived
hamishwillee Mar 15, 2024
de1961f
Minor fixes to timestamp
hamishwillee Mar 18, 2024
b51e1e4
rttmeasurements property
hamishwillee Mar 18, 2024
5bfeea8
Add RTCRemoteInboundStats to sidebar
hamishwillee Mar 18, 2024
ca0fcf0
Assorted minor improvements
hamishwillee Mar 18, 2024
a7989af
RTCRemoteInboutRtpStreamStats.totalrtt, localid, rttmeas
hamishwillee Mar 19, 2024
2924d6d
RTCRemoteOutboundRtpStreamStats - matching localid, rttmeas, totalrtt
hamishwillee Mar 19, 2024
1f4f368
RTCRemoteInboundRtpStreamStats.roundTripTime
hamishwillee Mar 19, 2024
88e529c
RTCRemoteInboundRtpStreamStats.fractionLost
hamishwillee Mar 19, 2024
f590282
Apply suggestions from code review
hamishwillee Jul 9, 2024
70661f0
Update files/en-us/web/api/rtcremoteinboundrtpstreamstats/index.md
hamishwillee Jul 9, 2024
2308288
Stat properties in alphabetic order. Fix NOTE to new form
hamishwillee Jul 30, 2024
b71598a
fractionLost - tidy and point solely to algorithm for info on how it …
hamishwillee Jul 30, 2024
02b0831
Note that the value is not precise, but is a useful indicator
hamishwillee Jul 30, 2024
21988c9
Apply suggestions from code review
hamishwillee Aug 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")}}
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")}}
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.
Comment on lines +21 to +25
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very helpful!


## 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.
Copy link
Collaborator Author

@hamishwillee hamishwillee Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE, I am confused here. For context RTCRemoteInboundRtpStreamStats are statistics from the remote system about inbound stream stats. In other words, the local end sent some information to the remote end. The remote end has reported some information back to say what it received.

So for remote inbound stats my understanding is that you're getting the packetsReceived as measured at the remote end. This will simply be all received packets since the beginning of the session including retransmissions.
This contrasts with RTCInboundRtpStreamStats.packetsRecieved which is the local end calculating stats for the inbound stream.

But the spec states for packetsReceived:

packetsReceived of type unsigned long long

Total number of RTP packets received for this SSRC. This includes retransmissions. At the receiving endpoint, this is calculated as defined in [RFC3550] section 6.4.1. At the sending endpoint the packetsReceived is estimated by subtracting the Cumulative Number of Packets Lost from the Extended Highest Sequence Number Received, both reported in the RTCP Receiver Report, and then subtracting the initial Extended Sequence Number that was sent to this SSRC in a RTCP Sender Report and then adding one, to mirror what is discussed in Appendix A.3 in [RFC3550], but for the sender side. If no RTCP Receiver Report has been received yet, then return 0.

IF we assume that by "receiving endpoint" we mean "whatever is calculating the packets received" then this works because a receiver just counts what packets it got - and that is then way we got back from the remote end in this report.

I THINK the bit about "at the sending endpoint ..." is irrelevant. I.e. you might calculate the packetsRecieved in that way at the sender, but that has nothing to do with this data we are reporting.


## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

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