From 0003fde4d1ef67e7ae4e243fb00171613a1512bd Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Mon, 4 Mar 2024 15:02:20 +1100 Subject: [PATCH 01/13] RTCAudioSourceStats - make consistent, improve docs on kind property, mark optional audio source stats --- .../web/api/rtcaudiosourcestats/audiolevel/index.md | 2 +- files/en-us/web/api/rtcaudiosourcestats/index.md | 10 +++++----- files/en-us/web/api/rtcaudiosourcestats/kind/index.md | 4 ++-- .../api/rtcaudiosourcestats/totalaudioenergy/index.md | 2 +- .../rtcaudiosourcestats/totalsamplesduration/index.md | 2 +- .../api/rtcaudiosourcestats/trackidentifier/index.md | 2 +- files/en-us/web/api/rtcaudiosourcestats/type/index.md | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/files/en-us/web/api/rtcaudiosourcestats/audiolevel/index.md b/files/en-us/web/api/rtcaudiosourcestats/audiolevel/index.md index e32c2919d27fe37..d04711f864da9e8 100644 --- a/files/en-us/web/api/rtcaudiosourcestats/audiolevel/index.md +++ b/files/en-us/web/api/rtcaudiosourcestats/audiolevel/index.md @@ -10,7 +10,7 @@ browser-compat: api.RTCStatsReport.type_media-source.audioLevel {{APIRef("WebRTC")}}{{SeeCompatTable}} -The {{domxref("RTCAudioSourceStats")}} dictionary's **`audioLevel`** property represents the audio level of the media source. +The **`audioLevel`** property of the {{domxref("RTCAudioSourceStats")}} dictionary represents the audio level of the media source. The level is averaged over some small implementation-dependent interval. Users can alternatively calculate the average audio level over some arbitrary duration using the algorithm described in the [`RTCAudioSourceStats` description](/en-US/docs/Web/API/RTCAudioSourceStats#description). diff --git a/files/en-us/web/api/rtcaudiosourcestats/index.md b/files/en-us/web/api/rtcaudiosourcestats/index.md index c1b65a3e6d529dc..83a211999c58e73 100644 --- a/files/en-us/web/api/rtcaudiosourcestats/index.md +++ b/files/en-us/web/api/rtcaudiosourcestats/index.md @@ -7,7 +7,7 @@ browser-compat: api.RTCStatsReport.type_media-source {{APIRef("WebRTC")}} -The [WebRTC API](/en-US/docs/Web/API/WebRTC_API)'s **`RTCAudioSourceStats`** dictionary provides information about an audio track that is attached to one or more senders. +The **`RTCAudioSourceStats`** dictionary of the [WebRTC API](/en-US/docs/Web/API/WebRTC_API) provides statistics information about an audio track that is attached to one or more senders. These statistics can be obtained by iterating the {{domxref("RTCStatsReport")}} returned by {{domxref("RTCRtpSender.getStats()")}} or {{domxref("RTCPeerConnection.getStats()")}} until you find a report with the [`type`](#type) of `media-source` and a [`kind`](#kind) of `audio`. @@ -15,11 +15,11 @@ These statistics can be obtained by iterating the {{domxref("RTCStatsReport")}} ## Instance properties -- {{domxref("RTCAudioSourceStats.audioLevel", "audioLevel")}} {{Experimental_Inline}} +- {{domxref("RTCAudioSourceStats.audioLevel", "audioLevel")}} {{Experimental_Inline}}{{optional_inline}} - : A number that represents the audio level of the media source. -- {{domxref("RTCAudioSourceStats.totalAudioEnergy", "totalAudioEnergy")}} {{Experimental_Inline}} +- {{domxref("RTCAudioSourceStats.totalAudioEnergy", "totalAudioEnergy")}} {{Experimental_Inline}}{{optional_inline}} - : A number that represents the total audio energy of the media source over the lifetime of the stats object. -- {{domxref("RTCAudioSourceStats.totalSamplesDuration", "totalSamplesDuration")}} {{Experimental_Inline}} +- {{domxref("RTCAudioSourceStats.totalSamplesDuration", "totalSamplesDuration")}} {{Experimental_Inline}}{{optional_inline}} - : A number that represents the total duration of all samples produced by the media source over the lifetime of the stats object. The following properties are present in both `RTCAudioSourceStats` and {{domxref("RTCVideoSourceStats")}}: @@ -27,7 +27,7 @@ The following properties are present in both `RTCAudioSourceStats` and {{domxref - {{domxref("RTCAudioSourceStats.trackIdentifier", "trackIdentifier")}} - : A string that contains the [`id`](/en-US/docs/Web/API/MediaStreamTrack/id) value of the [`MediaStreamTrack`](/en-US/docs/Web/API/MediaStreamTrack) associated with the audio source. - {{domxref("RTCAudioSourceStats.kind", "kind")}} - - : A string indicating whether this object represents stats for a video source or a media source. For an `RTCAudioSourceStats` this will always be `audio`. + - : A string indicating the kind of media source. For an `RTCAudioSourceStats` this will always be `audio`. ### Common instance properties diff --git a/files/en-us/web/api/rtcaudiosourcestats/kind/index.md b/files/en-us/web/api/rtcaudiosourcestats/kind/index.md index cd75502f477851f..14cccd16f029dc1 100644 --- a/files/en-us/web/api/rtcaudiosourcestats/kind/index.md +++ b/files/en-us/web/api/rtcaudiosourcestats/kind/index.md @@ -8,9 +8,9 @@ browser-compat: api.RTCStatsReport.type_media-source.kind {{APIRef("WebRTC")}} -The {{domxref("RTCAudioSourceStats")}} dictionary's **`kind`** property is a string value that is used to differentiate `audio` and `video` media sources. +The **`kind`** property of the {{domxref("RTCAudioSourceStats")}} dictionary is a string with the value `audio`. -Along with the {{domxref("RTCAudioSourceStats.type", "type")}}, this identifies the object as an {{domxref("RTCAudioSourceStats")}} object when iterating the {{domxref("RTCStatsReport")}} returned by {{domxref("RTCRtpSender.getStats()")}} or {{domxref("RTCPeerConnection.getStats()")}}. +The `kind` is used to differentiate between audio and video media sources when iterating an {{domxref("RTCStatsReport")}}, which both have a {{domxref("RTCAudioSourceStats.type", "type")}} of `media-source` (a `kind` of `video` indicates an {{domxref("RTCVideoSourceStats")}} object). ## Value diff --git a/files/en-us/web/api/rtcaudiosourcestats/totalaudioenergy/index.md b/files/en-us/web/api/rtcaudiosourcestats/totalaudioenergy/index.md index 0731a660842edbb..fcb8f5b649be3af 100644 --- a/files/en-us/web/api/rtcaudiosourcestats/totalaudioenergy/index.md +++ b/files/en-us/web/api/rtcaudiosourcestats/totalaudioenergy/index.md @@ -10,7 +10,7 @@ browser-compat: api.RTCStatsReport.type_media-source.totalAudioEnergy {{APIRef("WebRTC")}}{{SeeCompatTable}} -The {{domxref("RTCAudioSourceStats")}} dictionary's **`totalAudioEnergy`** property represents the total audio energy of the media source over the lifetime of this stats object. +The **`totalAudioEnergy`** property of the {{domxref("RTCAudioSourceStats")}} dictionary represents the total audio energy of the media source over the lifetime of this stats object. The total energy across a particular duration can be determined by subtracting the value of this property returned by two different `getStats()` calls. diff --git a/files/en-us/web/api/rtcaudiosourcestats/totalsamplesduration/index.md b/files/en-us/web/api/rtcaudiosourcestats/totalsamplesduration/index.md index 9e36735d9920875..4299d0191f7f0ad 100644 --- a/files/en-us/web/api/rtcaudiosourcestats/totalsamplesduration/index.md +++ b/files/en-us/web/api/rtcaudiosourcestats/totalsamplesduration/index.md @@ -10,7 +10,7 @@ browser-compat: api.RTCStatsReport.type_media-source.totalSamplesDuration {{APIRef("WebRTC")}}{{SeeCompatTable}} -The {{domxref("RTCAudioSourceStats")}} dictionary's **`totalSamplesDuration`** property represents the combined duration of all samples produced by the media source over the lifetime of this stats object, in seconds. +The **`totalSamplesDuration`** property of the {{domxref("RTCAudioSourceStats")}} dictionary represents the combined duration of all samples produced by the media source over the lifetime of this stats object, in seconds. It does not include samples dropped before reaching this media source. This can be used with {{domxref("RTCAudioSourceStats.totalAudioEnergy", "totalAudioEnergy")}} to compute an [average audio level over different intervals](/en-US/docs/Web/API/RTCAudioSourceStats#description). diff --git a/files/en-us/web/api/rtcaudiosourcestats/trackidentifier/index.md b/files/en-us/web/api/rtcaudiosourcestats/trackidentifier/index.md index 24755a4f38773cb..6530b5a901dc361 100644 --- a/files/en-us/web/api/rtcaudiosourcestats/trackidentifier/index.md +++ b/files/en-us/web/api/rtcaudiosourcestats/trackidentifier/index.md @@ -8,7 +8,7 @@ browser-compat: api.RTCStatsReport.type_media-source.trackIdentifier {{APIRef("WebRTC")}} -The {{domxref("RTCAudioSourceStats")}} dictionary's property **`trackIdentifier`** contains the `id` attribute of the associated [`MediaStreamTrack`](/en-US/docs/Web/API/MediaStreamTrack). +The **`trackIdentifier`** property of the {{domxref("RTCAudioSourceStats")}} dictionary contains the `id` attribute of the associated [`MediaStreamTrack`](/en-US/docs/Web/API/MediaStreamTrack). ## Value diff --git a/files/en-us/web/api/rtcaudiosourcestats/type/index.md b/files/en-us/web/api/rtcaudiosourcestats/type/index.md index 409b3b4db3ef003..516477e8910aee5 100644 --- a/files/en-us/web/api/rtcaudiosourcestats/type/index.md +++ b/files/en-us/web/api/rtcaudiosourcestats/type/index.md @@ -8,7 +8,7 @@ browser-compat: api.RTCStatsReport.type_media-source.type {{APIRef("WebRTC")}} -The {{domxref("RTCAudioSourceStats")}} dictionary's property **`type`** is a string with value `media-source`. +The **`type`** property of the {{domxref("RTCAudioSourceStats")}} dictionary is a string with value `media-source`. The type of `media-source` identifies the type of statistics as either {{domxref("RTCAudioSourceStats")}} or {{domxref("RTCVideoSourceStats")}} when iterating the {{domxref("RTCStatsReport")}} returned by {{domxref("RTCRtpSender.getStats()")}} or {{domxref("RTCPeerConnection.getStats()")}}. The type of stats can further be differentiated using the {{domxref("RTCAudioSourceStats.kind", "kind")}}, which will be `audio` for `RTCAudioSourceStats`. From 0721d9ebfb1489a6cc8208b5f8065f96609cfd46 Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Mon, 4 Mar 2024 17:08:35 +1100 Subject: [PATCH 02/13] RTCVideoSourceStats - draft --- .../framespersecond/index.md | 46 +++++++++++ .../web/api/rtcvideosourcestats/id/index.md | 27 +++++++ .../web/api/rtcvideosourcestats/index.md | 79 +++++++++++++++++++ .../web/api/rtcvideosourcestats/kind/index.md | 25 ++++++ .../rtcvideosourcestats/timestamp/index.md | 27 +++++++ .../trackidentifier/index.md | 23 ++++++ .../web/api/rtcvideosourcestats/type/index.md | 26 ++++++ 7 files changed, 253 insertions(+) create mode 100644 files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md create mode 100644 files/en-us/web/api/rtcvideosourcestats/id/index.md create mode 100644 files/en-us/web/api/rtcvideosourcestats/index.md create mode 100644 files/en-us/web/api/rtcvideosourcestats/kind/index.md create mode 100644 files/en-us/web/api/rtcvideosourcestats/timestamp/index.md create mode 100644 files/en-us/web/api/rtcvideosourcestats/trackidentifier/index.md create mode 100644 files/en-us/web/api/rtcvideosourcestats/type/index.md diff --git a/files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md b/files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md new file mode 100644 index 000000000000000..deb10447fbf8e2f --- /dev/null +++ b/files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md @@ -0,0 +1,46 @@ +--- +title: "RTCVideoSourceStats: framesPerSecond property" +short-title: framesPerSecond +slug: Web/API/RTCVideoSourceStats/framesPerSecond +page-type: web-api-instance-property +browser-compat: api.RTCStatsReport.type_media-source.framesPerSecond +--- + +{{APIRef("WebRTC")}} + +The **`framesPerSecond`** property of the {{domxref("RTCVideoSourceStats")}} dictionary indicates the number of frames from this video source in the last second. + +The property is not defined on the stats object for the first second of its lifetime. + +## Value + +A number indicating the frames from this source in the last second. + +## Examples + +This example shows how you might iterate the stats object returned from `RTCRtpSender.getStats()` to get the video source stats, and then extract the `framesPerSecond`. + +```js +// where sender is an RTCRtpSender +const stats = await sender.getStats(); +let videoSourceStats = null; + +stats.forEach((report) => { + if (report.type === "media-source" && report.kind==="video") { + videoSourceStats = report; + break; + } +}); + +// Note, test is conditional because +// framesPerSecond does not exist in the first second +const fps = videoSourceStats?.framesPerSecond; +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/rtcvideosourcestats/id/index.md b/files/en-us/web/api/rtcvideosourcestats/id/index.md new file mode 100644 index 000000000000000..4a810151194d99d --- /dev/null +++ b/files/en-us/web/api/rtcvideosourcestats/id/index.md @@ -0,0 +1,27 @@ +--- +title: "RTCVideoSourceStats: id property" +short-title: id +slug: Web/API/RTCVideoSourceStats/id +page-type: web-api-instance-property +browser-compat: api.RTCStatsReport.type_media-source.id +--- + +{{APIRef("WebRTC")}} + +The **`id`** property of the {{domxref("RTCVideoSourceStats")}} dictionary is a string which 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 `RTCVideoSourceStats` 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}} diff --git a/files/en-us/web/api/rtcvideosourcestats/index.md b/files/en-us/web/api/rtcvideosourcestats/index.md new file mode 100644 index 000000000000000..844c0325f4e7088 --- /dev/null +++ b/files/en-us/web/api/rtcvideosourcestats/index.md @@ -0,0 +1,79 @@ +--- +title: RTCVideoSourceStats +slug: Web/API/RTCVideoSourceStats +page-type: web-api-interface +browser-compat: api.RTCStatsReport.type_media-source +--- + +{{APIRef("WebRTC")}} + +The **`RTCVideoSourceStats`** dictionary of the [WebRTC API](/en-US/docs/Web/API/WebRTC_API) provides statistics information about a video track that is attached to one or more senders. + +These statistics can be obtained by iterating the {{domxref("RTCStatsReport")}} returned by {{domxref("RTCRtpSender.getStats()")}} or {{domxref("RTCPeerConnection.getStats()")}} until you find a report with the [`type`](#type) of `media-source` and a [`kind`](#kind) of `video`. + +> **Note:** For video information about remotely sourced tracks (that are being received), see {{domxref("RTCInboundRtpStreamStats")}}. + +## Instance properties + +- {{domxref("RTCVideoSourceStats.frames", "frames")}} + - : A positive number that indicates the total number of frames from this video source. +- {{domxref("RTCVideoSourceStats.framesPerSecond", "framesPerSecond")}} + - : A number that represents the number of frames from this video source in the last second. +- {{domxref("RTCVideoSourceStats.height", "height")}} + - : A positive number that represents the height, in pixels, of the last frame originating from this source. + This property is not defined on the stats option until after the first frame has been produced. +- {{domxref("RTCVideoSourceStats.width", "width")}} + - : A number that represents thewidth, in pixels, of the last frame originating from this source. + This property is not defined on the stats option until after the first frame has been produced. + +The following properties are present in both `RTCVideoSourceStats` and {{domxref("RTCAudioSourceStats")}}: + +- {{domxref("RTCVideoSourceStats.trackIdentifier", "trackIdentifier")}} + - : A string that contains the [`id`](/en-US/docs/Web/API/MediaStreamTrack/id) value of the [`MediaStreamTrack`](/en-US/docs/Web/API/MediaStreamTrack) associated with the audio source. +- {{domxref("RTCVideoSourceStats.kind", "kind")}} + - : A string indicating the kind of media source. For an `RTCVideoSourceStats` this will always be `video`. + +### Common instance properties + +The following properties are common to all statistics objects. + +- {{domxref("RTCVideoSourceStats.id", "id")}} + - : A string that uniquely identifies the object that is being monitored to produce this set of statistics. +- {{domxref("RTCVideoSourceStats.timestamp", "timestamp")}} + - : A {{domxref("DOMHighResTimeStamp")}} object indicating the time at which the sample was taken for this statistics object. +- {{domxref("RTCVideoSourceStats.type", "type")}} + - : A string with the value `"media-source"`, indicating that the object is an instance of either {{domxref("RTCVideoSourceStats")}} or {{domxref("RTCVideoSourceStats")}}. + +## Description + +The interface provides statistics about an audio media source attached to one or more senders. +The information includes Xxxxx. + +## Examples + +This example shows how you might iterate the stats object returned from `RTCRtpSender.getStats()` to get the video source stats, and then extract the `framesPerSecond`. + +```js +// where sender is an RTCRtpSender +const stats = await sender.getStats(); +let videoSourceStats = null; + +stats.forEach((report) => { + if (report.type === "media-source" && report.kind==="video") { + videoSourceStats = report; + break; + } +}); + +// Note, test is conditional. +// framesPerSecond does not exist in the first second +const fps = videoSourceStats?.framesPerSecond; +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/rtcvideosourcestats/kind/index.md b/files/en-us/web/api/rtcvideosourcestats/kind/index.md new file mode 100644 index 000000000000000..8edc99bd56007e3 --- /dev/null +++ b/files/en-us/web/api/rtcvideosourcestats/kind/index.md @@ -0,0 +1,25 @@ +--- +title: "RTCVideoSourceStats: kind property" +short-title: kind +slug: Web/API/RTCVideoSourceStats/kind +page-type: web-api-instance-property +browser-compat: api.RTCStatsReport.type_media-source.kind +--- + +{{APIRef("WebRTC")}} + +The **`kind`** property of the {{domxref("RTCVideoSourceStats")}} dictionary is a string with the value `video`. + +The `kind` is used to differentiate between audio and video media sources when iterating an {{domxref("RTCStatsReport")}}, which both have a {{domxref("RTCVideoSourceStats.type", "type")}} of `media-source` (a `kind` of `audio` indicates an {{domxref("RTCAudioSourceStats")}} object). + +## Value + +A string with the value `video`. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/rtcvideosourcestats/timestamp/index.md b/files/en-us/web/api/rtcvideosourcestats/timestamp/index.md new file mode 100644 index 000000000000000..d1048507fc3d7da --- /dev/null +++ b/files/en-us/web/api/rtcvideosourcestats/timestamp/index.md @@ -0,0 +1,27 @@ +--- +title: "RTCVideoSourceStats: timestamp property" +short-title: timestamp +slug: Web/API/RTCVideoSourceStats/timestamp +page-type: web-api-instance-property +browser-compat: api.RTCStatsReport.type_media-source.timestamp +--- + +{{APIRef("WebRTC")}} + +The **`timestamp`** property of the {{domxref("RTCVideoSourceStats")}} dictionary is a {{domxref("DOMHighResTimeStamp")}} object specifying the time at which the data in the object was sampled. + +The time is given in milliseconds elapsed since the first moment of January 1, 1970, UTC (also known as [Unix time](/en-US/docs/Glossary/Unix_time)). + +## Value + +A {{domxref("DOMHighResTimeStamp")}} value indicating the time at which the activity described by the statistics in this object was recorded, in milliseconds elapsed since the beginning of January 1, 1970, UTC. + +The value should be accurate to within a few milliseconds but may not be entirely precise, either because of hardware or operating system limitations or because of [fingerprinting](/en-US/docs/Glossary/Fingerprinting) protection in the form of reduced clock precision or accuracy. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/rtcvideosourcestats/trackidentifier/index.md b/files/en-us/web/api/rtcvideosourcestats/trackidentifier/index.md new file mode 100644 index 000000000000000..be7fd5f8df28901 --- /dev/null +++ b/files/en-us/web/api/rtcvideosourcestats/trackidentifier/index.md @@ -0,0 +1,23 @@ +--- +title: "RTCVideoSourceStats: trackIdentifier property" +short-title: trackIdentifier +slug: Web/API/RTCVideoSourceStats/trackIdentifier +page-type: web-api-instance-property +browser-compat: api.RTCStatsReport.type_media-source.trackIdentifier +--- + +{{APIRef("WebRTC")}} + +The **`trackIdentifier`** property of the {{domxref("RTCVideoSourceStats")}} dictionary contains the `id` attribute of the associated [`MediaStreamTrack`](/en-US/docs/Web/API/MediaStreamTrack). + +## Value + +A string containing the value of the associated [`MediaStreamTrack.id`](/en-US/docs/Web/API/MediaStreamTrack/id). + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/rtcvideosourcestats/type/index.md b/files/en-us/web/api/rtcvideosourcestats/type/index.md new file mode 100644 index 000000000000000..8a7cd59bbea2834 --- /dev/null +++ b/files/en-us/web/api/rtcvideosourcestats/type/index.md @@ -0,0 +1,26 @@ +--- +title: "RTCVideoSourceStats: type property" +short-title: type +slug: Web/API/RTCVideoSourceStats/type +page-type: web-api-instance-property +browser-compat: api.RTCStatsReport.type_media-source.type +--- + +{{APIRef("WebRTC")}} + +The **`type`** property of the {{domxref("RTCVideoSourceStats")}} dictionary is a string with value `media-source`. + +The type of `media-source` identifies the type of statistics as either {{domxref("RTCAudioSourceStats")}} or {{domxref("RTCVideoSourceStats")}} when iterating the {{domxref("RTCStatsReport")}} returned by {{domxref("RTCRtpSender.getStats()")}} or {{domxref("RTCPeerConnection.getStats()")}}. +The type of stats can further be differentiated using the {{domxref("RTCVideoSourceStats.kind", "kind")}}, which will be `video` for `RTCVideoSourceStats`. + +## Value + +A string with the value `media-source`. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} From 6fa2a92adc17b7006dd1bf287d4ff9f485aa6c68 Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Tue, 5 Mar 2024 12:17:52 +1100 Subject: [PATCH 03/13] Add remainder of Video source updates --- .../web/api/rtcaudiosourcestats/index.md | 4 +- .../api/rtcvideosourcestats/frames/index.md | 42 +++++++++++++++++ .../api/rtcvideosourcestats/height/index.md | 46 +++++++++++++++++++ .../web/api/rtcvideosourcestats/index.md | 35 ++++++++------ .../api/rtcvideosourcestats/width/index.md | 46 +++++++++++++++++++ 5 files changed, 157 insertions(+), 16 deletions(-) create mode 100644 files/en-us/web/api/rtcvideosourcestats/frames/index.md create mode 100644 files/en-us/web/api/rtcvideosourcestats/height/index.md create mode 100644 files/en-us/web/api/rtcvideosourcestats/width/index.md diff --git a/files/en-us/web/api/rtcaudiosourcestats/index.md b/files/en-us/web/api/rtcaudiosourcestats/index.md index 83a211999c58e73..9e893e27a5c76a8 100644 --- a/files/en-us/web/api/rtcaudiosourcestats/index.md +++ b/files/en-us/web/api/rtcaudiosourcestats/index.md @@ -7,7 +7,7 @@ browser-compat: api.RTCStatsReport.type_media-source {{APIRef("WebRTC")}} -The **`RTCAudioSourceStats`** dictionary of the [WebRTC API](/en-US/docs/Web/API/WebRTC_API) provides statistics information about an audio track that is attached to one or more senders. +The **`RTCAudioSourceStats`** dictionary of the [WebRTC API](/en-US/docs/Web/API/WebRTC_API) provides statistics information about an audio track ({{domxref("MediaStreamTrack")}}) that is attached to one or more senders ({{domxref("RTCRtpSender")}}). These statistics can be obtained by iterating the {{domxref("RTCStatsReport")}} returned by {{domxref("RTCRtpSender.getStats()")}} or {{domxref("RTCPeerConnection.getStats()")}} until you find a report with the [`type`](#type) of `media-source` and a [`kind`](#kind) of `audio`. @@ -22,6 +22,8 @@ These statistics can be obtained by iterating the {{domxref("RTCStatsReport")}} - {{domxref("RTCAudioSourceStats.totalSamplesDuration", "totalSamplesDuration")}} {{Experimental_Inline}}{{optional_inline}} - : A number that represents the total duration of all samples produced by the media source over the lifetime of the stats object. +### Common media-source properties + The following properties are present in both `RTCAudioSourceStats` and {{domxref("RTCVideoSourceStats")}}: - {{domxref("RTCAudioSourceStats.trackIdentifier", "trackIdentifier")}} diff --git a/files/en-us/web/api/rtcvideosourcestats/frames/index.md b/files/en-us/web/api/rtcvideosourcestats/frames/index.md new file mode 100644 index 000000000000000..2f037226649812e --- /dev/null +++ b/files/en-us/web/api/rtcvideosourcestats/frames/index.md @@ -0,0 +1,42 @@ +--- +title: "RTCVideoSourceStats: frames property" +short-title: frames +slug: Web/API/RTCVideoSourceStats/frames +page-type: web-api-instance-property +browser-compat: api.RTCStatsReport.type_media-source.frames +--- + +{{APIRef("WebRTC")}} + +The **`frames`** property of the {{domxref("RTCVideoSourceStats")}} dictionary indicates the total number of frames sent from this video source over its lifetime. + +## Value + +A number indicating the total number of frames from this source. + +## Examples + +This example shows how you might iterate the stats object returned from `RTCRtpSender.getStats()` to get the video source stats, and then extract the `frames`. + +```js +// where sender is an RTCRtpSender +const stats = await sender.getStats(); +let videoSourceStats = null; + +stats.forEach((report) => { + if (report.type === "media-source" && report.kind==="video") { + videoSourceStats = report; + break; + } +}); + +const frames = videoSourceStats.frames; +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/rtcvideosourcestats/height/index.md b/files/en-us/web/api/rtcvideosourcestats/height/index.md new file mode 100644 index 000000000000000..86469752ec31f80 --- /dev/null +++ b/files/en-us/web/api/rtcvideosourcestats/height/index.md @@ -0,0 +1,46 @@ +--- +title: "RTCVideoSourceStats: height property" +short-title: height +slug: Web/API/RTCVideoSourceStats/height +page-type: web-api-instance-property +browser-compat: api.RTCStatsReport.type_media-source.height +--- + +{{APIRef("WebRTC")}} + +The **`height`** property of the {{domxref("RTCVideoSourceStats")}} dictionary indicates the height, in pixels, of the last frame originating from this source. + +This property is not defined on the stats object until after the first frame has been produced. + +## Value + +A positive number indicating the height, in pixels. + +## Examples + +This example shows how you might iterate the stats object returned from `RTCRtpSender.getStats()` to get the video source stats, and then extract the `height`. + +```js +// where sender is an RTCRtpSender +const stats = await sender.getStats(); +let videoSourceStats = null; + +stats.forEach((report) => { + if (report.type === "media-source" && report.kind==="video") { + videoSourceStats = report; + break; + } +}); + +// Note, test is conditional because the property +// 'height' does not exist until frames are being produced. +const height = videoSourceStats?.height; +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/rtcvideosourcestats/index.md b/files/en-us/web/api/rtcvideosourcestats/index.md index 844c0325f4e7088..0bb20c2fb0dc341 100644 --- a/files/en-us/web/api/rtcvideosourcestats/index.md +++ b/files/en-us/web/api/rtcvideosourcestats/index.md @@ -7,7 +7,7 @@ browser-compat: api.RTCStatsReport.type_media-source {{APIRef("WebRTC")}} -The **`RTCVideoSourceStats`** dictionary of the [WebRTC API](/en-US/docs/Web/API/WebRTC_API) provides statistics information about a video track that is attached to one or more senders. +The **`RTCVideoSourceStats`** dictionary of the [WebRTC API](/en-US/docs/Web/API/WebRTC_API) provides statistics information about a video track ({{domxref("MediaStreamTrack")}}) that is attached to one or more senders ({{domxref("RTCRtpSender")}}). These statistics can be obtained by iterating the {{domxref("RTCStatsReport")}} returned by {{domxref("RTCRtpSender.getStats()")}} or {{domxref("RTCPeerConnection.getStats()")}} until you find a report with the [`type`](#type) of `media-source` and a [`kind`](#kind) of `video`. @@ -15,21 +15,24 @@ These statistics can be obtained by iterating the {{domxref("RTCStatsReport")}} ## Instance properties -- {{domxref("RTCVideoSourceStats.frames", "frames")}} - - : A positive number that indicates the total number of frames from this video source. -- {{domxref("RTCVideoSourceStats.framesPerSecond", "framesPerSecond")}} - - : A number that represents the number of frames from this video source in the last second. -- {{domxref("RTCVideoSourceStats.height", "height")}} +- {{domxref("RTCVideoSourceStats.frames", "frames")}} {{optional_inline}} + - : A positive number that indicates the total number of frames sent from this video source. +- {{domxref("RTCVideoSourceStats.framesPerSecond", "framesPerSecond")}} {{optional_inline}} + - : A number that represents the number of frames sent from this video source in the last second. + This property is not defined on this stats object for the first second of its existence. +- {{domxref("RTCVideoSourceStats.height", "height")}} {{optional_inline}} - : A positive number that represents the height, in pixels, of the last frame originating from this source. - This property is not defined on the stats option until after the first frame has been produced. -- {{domxref("RTCVideoSourceStats.width", "width")}} + This property is not defined on this stats object until after the first frame has been produced. +- {{domxref("RTCVideoSourceStats.width", "width")}} {{optional_inline}} - : A number that represents thewidth, in pixels, of the last frame originating from this source. - This property is not defined on the stats option until after the first frame has been produced. + This property is not defined on this stats object until after the first frame has been produced. + +### Common media-source properties The following properties are present in both `RTCVideoSourceStats` and {{domxref("RTCAudioSourceStats")}}: - {{domxref("RTCVideoSourceStats.trackIdentifier", "trackIdentifier")}} - - : A string that contains the [`id`](/en-US/docs/Web/API/MediaStreamTrack/id) value of the [`MediaStreamTrack`](/en-US/docs/Web/API/MediaStreamTrack) associated with the audio source. + - : A string that contains the [`id`](/en-US/docs/Web/API/MediaStreamTrack/id) value of the [`MediaStreamTrack`](/en-US/docs/Web/API/MediaStreamTrack) associated with the video source. - {{domxref("RTCVideoSourceStats.kind", "kind")}} - : A string indicating the kind of media source. For an `RTCVideoSourceStats` this will always be `video`. @@ -46,12 +49,12 @@ The following properties are common to all statistics objects. ## Description -The interface provides statistics about an audio media source attached to one or more senders. -The information includes Xxxxx. +The interface provides statistics about a video media source attached to one or more senders. +The information includes a identifier for the associated `MediaStreamTrack`, along with the height and width of the last frame sent from the source, the number of frames sent from the source, and the frame rate. ## Examples -This example shows how you might iterate the stats object returned from `RTCRtpSender.getStats()` to get the video source stats, and then extract the `framesPerSecond`. +This example shows how you might iterate the stats object returned from `RTCRtpSender.getStats()` to get the video-specific media-source stats. ```js // where sender is an RTCRtpSender @@ -65,9 +68,11 @@ stats.forEach((report) => { } }); -// Note, test is conditional. -// framesPerSecond does not exist in the first second +// framesPerSecond, width, height, may initially be defined on the stats object +const frames = videoSourceStats.frames; const fps = videoSourceStats?.framesPerSecond; +const width = videoSourceStats?.width; +const height = videoSourceStats?.height; ``` ## Specifications diff --git a/files/en-us/web/api/rtcvideosourcestats/width/index.md b/files/en-us/web/api/rtcvideosourcestats/width/index.md new file mode 100644 index 000000000000000..f647e4f74cd2f4f --- /dev/null +++ b/files/en-us/web/api/rtcvideosourcestats/width/index.md @@ -0,0 +1,46 @@ +--- +title: "RTCVideoSourceStats: width property" +short-title: width +slug: Web/API/RTCVideoSourceStats/width +page-type: web-api-instance-property +browser-compat: api.RTCStatsReport.type_media-source.width +--- + +{{APIRef("WebRTC")}} + +The **`width`** property of the {{domxref("RTCVideoSourceStats")}} dictionary indicates the width, in pixels, of the last frame originating from this source. + +This property is not defined on the stats object until after the first frame has been produced. + +## Value + +A positive number indicating the width, in pixels. + +## Examples + +This example shows how you might iterate the stats object returned from `RTCRtpSender.getStats()` to get the video source stats, and then extract the `width`. + +```js +// where sender is an RTCRtpSender +const stats = await sender.getStats(); +let videoSourceStats = null; + +stats.forEach((report) => { + if (report.type === "media-source" && report.kind==="video") { + videoSourceStats = report; + break; + } +}); + +// Note, test is conditional because the property +// 'width' does not exist until frames are being produced. +const height = videoSourceStats?.width; +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} From 6968d9a8ff57e37c1434729b9db674e124956a60 Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Mon, 18 Mar 2024 13:59:06 +1100 Subject: [PATCH 04/13] Add spec-urls for audiosource and videosource --- files/en-us/web/api/rtcaudiosourcestats/index.md | 1 + files/en-us/web/api/rtcvideosourcestats/index.md | 1 + files/jsondata/GroupData.json | 1 + 3 files changed, 3 insertions(+) diff --git a/files/en-us/web/api/rtcaudiosourcestats/index.md b/files/en-us/web/api/rtcaudiosourcestats/index.md index 9e893e27a5c76a8..7375216a8f96044 100644 --- a/files/en-us/web/api/rtcaudiosourcestats/index.md +++ b/files/en-us/web/api/rtcaudiosourcestats/index.md @@ -3,6 +3,7 @@ title: RTCAudioSourceStats slug: Web/API/RTCAudioSourceStats page-type: web-api-interface browser-compat: api.RTCStatsReport.type_media-source +spec-urls: https://w3c.github.io/webrtc-stats/#dom-rtcaudiosourcestats --- {{APIRef("WebRTC")}} diff --git a/files/en-us/web/api/rtcvideosourcestats/index.md b/files/en-us/web/api/rtcvideosourcestats/index.md index 0bb20c2fb0dc341..17588c283eba1e4 100644 --- a/files/en-us/web/api/rtcvideosourcestats/index.md +++ b/files/en-us/web/api/rtcvideosourcestats/index.md @@ -3,6 +3,7 @@ title: RTCVideoSourceStats slug: Web/API/RTCVideoSourceStats page-type: web-api-interface browser-compat: api.RTCStatsReport.type_media-source +spec-urls: https://w3c.github.io/webrtc-stats/#dom-rtcvideosourcestats --- {{APIRef("WebRTC")}} diff --git a/files/jsondata/GroupData.json b/files/jsondata/GroupData.json index 8998da9996fd62b..0d3b86113e32955 100644 --- a/files/jsondata/GroupData.json +++ b/files/jsondata/GroupData.json @@ -2121,6 +2121,7 @@ "RTCInboundRtpStreamStats", "RTCIceCandidateStats", "RTCAudioSourceStats", + "RTCVideoSourceStats", "RTCOutboundRtpStreamStats", "RTCPeerConnectionStats", "RTCRemoteOutboundRtpStreamStats" From 09063a7fe2a6f5641deecb80a2e49f0bda340581 Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Mon, 18 Mar 2024 14:09:07 +1100 Subject: [PATCH 05/13] Make kind consistent --- files/en-us/web/api/rtcaudiosourcestats/index.md | 2 +- files/en-us/web/api/rtcvideosourcestats/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/files/en-us/web/api/rtcaudiosourcestats/index.md b/files/en-us/web/api/rtcaudiosourcestats/index.md index 7375216a8f96044..55ce5dd787058f4 100644 --- a/files/en-us/web/api/rtcaudiosourcestats/index.md +++ b/files/en-us/web/api/rtcaudiosourcestats/index.md @@ -30,7 +30,7 @@ The following properties are present in both `RTCAudioSourceStats` and {{domxref - {{domxref("RTCAudioSourceStats.trackIdentifier", "trackIdentifier")}} - : A string that contains the [`id`](/en-US/docs/Web/API/MediaStreamTrack/id) value of the [`MediaStreamTrack`](/en-US/docs/Web/API/MediaStreamTrack) associated with the audio source. - {{domxref("RTCAudioSourceStats.kind", "kind")}} - - : A string indicating the kind of media source. For an `RTCAudioSourceStats` this will always be `audio`. + - : A string indicating whether this object represents stats for a video source or a media source. For an `RTCAudioSourceStats` this will always be `audio`. ### Common instance properties diff --git a/files/en-us/web/api/rtcvideosourcestats/index.md b/files/en-us/web/api/rtcvideosourcestats/index.md index 17588c283eba1e4..f43f21a6f92e43f 100644 --- a/files/en-us/web/api/rtcvideosourcestats/index.md +++ b/files/en-us/web/api/rtcvideosourcestats/index.md @@ -35,7 +35,7 @@ The following properties are present in both `RTCVideoSourceStats` and {{domxref - {{domxref("RTCVideoSourceStats.trackIdentifier", "trackIdentifier")}} - : A string that contains the [`id`](/en-US/docs/Web/API/MediaStreamTrack/id) value of the [`MediaStreamTrack`](/en-US/docs/Web/API/MediaStreamTrack) associated with the video source. - {{domxref("RTCVideoSourceStats.kind", "kind")}} - - : A string indicating the kind of media source. For an `RTCVideoSourceStats` this will always be `video`. + - : A string indicating whether this object represents stats for a video source or a media source. For an `RTCVideoSourceStats` this will always be `video`. ### Common instance properties From 839665d701b1389c8ad107d2da5f4db6f5cca242 Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Mon, 18 Mar 2024 14:22:16 +1100 Subject: [PATCH 06/13] Fix missing frames case --- files/en-us/web/api/rtcvideosourcestats/frames/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/api/rtcvideosourcestats/frames/index.md b/files/en-us/web/api/rtcvideosourcestats/frames/index.md index 2f037226649812e..e8c1800c1e41297 100644 --- a/files/en-us/web/api/rtcvideosourcestats/frames/index.md +++ b/files/en-us/web/api/rtcvideosourcestats/frames/index.md @@ -30,7 +30,7 @@ stats.forEach((report) => { } }); -const frames = videoSourceStats.frames; +const frames = videoSourceStats?.frames; ``` ## Specifications From a7f7878f95fb2ba87c1064e5790a1b2daafec9bd Mon Sep 17 00:00:00 2001 From: wbamberg Date: Sun, 17 Mar 2024 20:35:17 -0700 Subject: [PATCH 07/13] Update files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md Co-authored-by: Hamish Willee --- .../en-us/web/api/rtcvideosourcestats/framespersecond/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md b/files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md index deb10447fbf8e2f..4944400cc420673 100644 --- a/files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md +++ b/files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md @@ -8,7 +8,7 @@ browser-compat: api.RTCStatsReport.type_media-source.framesPerSecond {{APIRef("WebRTC")}} -The **`framesPerSecond`** property of the {{domxref("RTCVideoSourceStats")}} dictionary indicates the number of frames from this video source in the last second. +The **`framesPerSecond`** property of the {{domxref("RTCVideoSourceStats")}} dictionary indicates the number of frames originating from this video source in the last second. The property is not defined on the stats object for the first second of its lifetime. From ada47463bb08efb805f824384aa1222bb02033fc Mon Sep 17 00:00:00 2001 From: wbamberg Date: Sun, 17 Mar 2024 20:40:12 -0700 Subject: [PATCH 08/13] Update files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md Co-authored-by: Hamish Willee --- .../en-us/web/api/rtcvideosourcestats/framespersecond/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md b/files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md index 4944400cc420673..013b856abb0f4f7 100644 --- a/files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md +++ b/files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md @@ -14,7 +14,7 @@ The property is not defined on the stats object for the first second of its life ## Value -A number indicating the frames from this source in the last second. +A number indicating the frames originating from this source in the last second. ## Examples From 4009de9994b1abca7bccc36d0c60ed30cb7810e2 Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Mon, 18 Mar 2024 15:06:45 +1100 Subject: [PATCH 09/13] Update files/en-us/web/api/rtcvideosourcestats/index.md Co-authored-by: wbamberg --- files/en-us/web/api/rtcvideosourcestats/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/api/rtcvideosourcestats/index.md b/files/en-us/web/api/rtcvideosourcestats/index.md index f43f21a6f92e43f..90ccc8542c854f4 100644 --- a/files/en-us/web/api/rtcvideosourcestats/index.md +++ b/files/en-us/web/api/rtcvideosourcestats/index.md @@ -25,7 +25,7 @@ These statistics can be obtained by iterating the {{domxref("RTCStatsReport")}} - : A positive number that represents the height, in pixels, of the last frame originating from this source. This property is not defined on this stats object until after the first frame has been produced. - {{domxref("RTCVideoSourceStats.width", "width")}} {{optional_inline}} - - : A number that represents thewidth, in pixels, of the last frame originating from this source. + - : A number that represents the width, in pixels, of the last frame originating from this source. This property is not defined on this stats object until after the first frame has been produced. ### Common media-source properties From 4ef125bff40c1d728fd12bddd870e8771e89f48b Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Mon, 18 Mar 2024 15:07:13 +1100 Subject: [PATCH 10/13] Apply suggestions from code review --- files/en-us/web/api/rtcvideosourcestats/frames/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/en-us/web/api/rtcvideosourcestats/frames/index.md b/files/en-us/web/api/rtcvideosourcestats/frames/index.md index e8c1800c1e41297..637fc2c64e83194 100644 --- a/files/en-us/web/api/rtcvideosourcestats/frames/index.md +++ b/files/en-us/web/api/rtcvideosourcestats/frames/index.md @@ -8,11 +8,11 @@ browser-compat: api.RTCStatsReport.type_media-source.frames {{APIRef("WebRTC")}} -The **`frames`** property of the {{domxref("RTCVideoSourceStats")}} dictionary indicates the total number of frames sent from this video source over its lifetime. +The **`frames`** property of the {{domxref("RTCVideoSourceStats")}} dictionary indicates the total number of frames originating from this video source over its lifetime. ## Value -A number indicating the total number of frames from this source. +A number indicating the total number of frames originating from this source. ## Examples From 1d559cef9394fce49fb3e545ae5ae749d22927c6 Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Mon, 18 Mar 2024 15:14:40 +1100 Subject: [PATCH 11/13] Update files/en-us/web/api/rtcvideosourcestats/index.md --- files/en-us/web/api/rtcvideosourcestats/index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/files/en-us/web/api/rtcvideosourcestats/index.md b/files/en-us/web/api/rtcvideosourcestats/index.md index 90ccc8542c854f4..3ed684901500334 100644 --- a/files/en-us/web/api/rtcvideosourcestats/index.md +++ b/files/en-us/web/api/rtcvideosourcestats/index.md @@ -17,15 +17,15 @@ These statistics can be obtained by iterating the {{domxref("RTCStatsReport")}} ## Instance properties - {{domxref("RTCVideoSourceStats.frames", "frames")}} {{optional_inline}} - - : A positive number that indicates the total number of frames sent from this video source. + - : A positive number that indicates the total number of frames originating from this video source. - {{domxref("RTCVideoSourceStats.framesPerSecond", "framesPerSecond")}} {{optional_inline}} - - : A number that represents the number of frames sent from this video source in the last second. + - : A positive number that represents the number of frames originating from this video source in the last second. This property is not defined on this stats object for the first second of its existence. - {{domxref("RTCVideoSourceStats.height", "height")}} {{optional_inline}} - - : A positive number that represents the height, in pixels, of the last frame originating from this source. + - : A number that represents the height, in pixels, of the last frame originating from this source. This property is not defined on this stats object until after the first frame has been produced. - {{domxref("RTCVideoSourceStats.width", "width")}} {{optional_inline}} - - : A number that represents the width, in pixels, of the last frame originating from this source. + - : A number that represents the width, in pixels, of the most recent frame originating from this source. This property is not defined on this stats object until after the first frame has been produced. ### Common media-source properties From 6c610391c3e4ffd57008f56492df48c0ed8fccd6 Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Mon, 18 Mar 2024 16:29:17 +1100 Subject: [PATCH 12/13] Improve conditional comment a'la wbamberg suggestion --- .../web/api/rtcvideosourcestats/framespersecond/index.md | 4 ++-- files/en-us/web/api/rtcvideosourcestats/height/index.md | 4 ++-- files/en-us/web/api/rtcvideosourcestats/width/index.md | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md b/files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md index 013b856abb0f4f7..fe6d64ca845966e 100644 --- a/files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md +++ b/files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md @@ -32,8 +32,8 @@ stats.forEach((report) => { } }); -// Note, test is conditional because -// framesPerSecond does not exist in the first second +// Note, test is conditional in case the stats object +// does not include video source stats const fps = videoSourceStats?.framesPerSecond; ``` diff --git a/files/en-us/web/api/rtcvideosourcestats/height/index.md b/files/en-us/web/api/rtcvideosourcestats/height/index.md index 86469752ec31f80..0de53bdf39309b1 100644 --- a/files/en-us/web/api/rtcvideosourcestats/height/index.md +++ b/files/en-us/web/api/rtcvideosourcestats/height/index.md @@ -32,8 +32,8 @@ stats.forEach((report) => { } }); -// Note, test is conditional because the property -// 'height' does not exist until frames are being produced. +// Note, test is conditional in case the stats object +// does not include video source stats const height = videoSourceStats?.height; ``` diff --git a/files/en-us/web/api/rtcvideosourcestats/width/index.md b/files/en-us/web/api/rtcvideosourcestats/width/index.md index f647e4f74cd2f4f..ce1e253c876aa23 100644 --- a/files/en-us/web/api/rtcvideosourcestats/width/index.md +++ b/files/en-us/web/api/rtcvideosourcestats/width/index.md @@ -32,8 +32,8 @@ stats.forEach((report) => { } }); -// Note, test is conditional because the property -// 'width' does not exist until frames are being produced. +// Note, test is conditional in case the stats object +// does not include video source stats const height = videoSourceStats?.width; ``` From c459884a40b3f10fcd9395ad4b65fb3c856c4819 Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Tue, 19 Mar 2024 10:59:14 +1100 Subject: [PATCH 13/13] Update files/en-us/web/api/rtcvideosourcestats/index.md Co-authored-by: wbamberg --- files/en-us/web/api/rtcvideosourcestats/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/en-us/web/api/rtcvideosourcestats/index.md b/files/en-us/web/api/rtcvideosourcestats/index.md index 3ed684901500334..af77603e063d55e 100644 --- a/files/en-us/web/api/rtcvideosourcestats/index.md +++ b/files/en-us/web/api/rtcvideosourcestats/index.md @@ -69,8 +69,8 @@ stats.forEach((report) => { } }); -// framesPerSecond, width, height, may initially be defined on the stats object -const frames = videoSourceStats.frames; +// videoSourceStats will be null if the report did not include video source stats +const frames = videoSourceStats?.frames; const fps = videoSourceStats?.framesPerSecond; const width = videoSourceStats?.width; const height = videoSourceStats?.height;