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..55ce5dd787058f4 100644 --- a/files/en-us/web/api/rtcaudiosourcestats/index.md +++ b/files/en-us/web/api/rtcaudiosourcestats/index.md @@ -3,11 +3,12 @@ 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")}} -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 ({{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`. @@ -15,13 +16,15 @@ 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. +### 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/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`. 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..637fc2c64e83194 --- /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 originating from this video source over its lifetime. + +## Value + +A number indicating the total number of frames originating 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/framespersecond/index.md b/files/en-us/web/api/rtcvideosourcestats/framespersecond/index.md new file mode 100644 index 000000000000000..fe6d64ca845966e --- /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 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. + +## Value + +A number indicating the frames originating 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 in case the stats object +// does not include video source stats +const fps = videoSourceStats?.framesPerSecond; +``` + +## 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..0de53bdf39309b1 --- /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 in case the stats object +// does not include video source stats +const height = videoSourceStats?.height; +``` + +## 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..af77603e063d55e --- /dev/null +++ b/files/en-us/web/api/rtcvideosourcestats/index.md @@ -0,0 +1,85 @@ +--- +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")}} + +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`. + +> **Note:** For video information about remotely sourced tracks (that are being received), see {{domxref("RTCInboundRtpStreamStats")}}. + +## Instance properties + +- {{domxref("RTCVideoSourceStats.frames", "frames")}} {{optional_inline}} + - : A positive number that indicates the total number of frames originating from this video source. +- {{domxref("RTCVideoSourceStats.framesPerSecond", "framesPerSecond")}} {{optional_inline}} + - : 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 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 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 + +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 video source. +- {{domxref("RTCVideoSourceStats.kind", "kind")}} + - : 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 + +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 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-specific media-source stats. + +```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; + } +}); + +// 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; +``` + +## 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}} 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..ce1e253c876aa23 --- /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 in case the stats object +// does not include video source stats +const height = videoSourceStats?.width; +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/jsondata/GroupData.json b/files/jsondata/GroupData.json index 3e5fb619b4df4c5..8ad2fa4efff395d 100644 --- a/files/jsondata/GroupData.json +++ b/files/jsondata/GroupData.json @@ -2131,6 +2131,7 @@ "RTCInboundRtpStreamStats", "RTCIceCandidateStats", "RTCAudioSourceStats", + "RTCVideoSourceStats", "RTCCodecStats", "RTCOutboundRtpStreamStats", "RTCPeerConnectionStats",