From 907c354424bd4a0d7ab065e474a6d00b8167882a Mon Sep 17 00:00:00 2001 From: Guido Urdaneta Date: Wed, 8 Apr 2026 17:45:20 +0200 Subject: [PATCH 1/9] Add frame counters --- index.bs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/index.bs b/index.bs index 4b54fab..a319324 100644 --- a/index.bs +++ b/index.bs @@ -126,6 +126,9 @@ interface MediaStreamTrackHandle { interface MediaStreamTrackProcessor { constructor(MediaStreamTrackProcessorInit init); readonly attribute ReadableStream readable; + readonly attribute unsigned long long droppedFrames; + readonly attribute unsigned long long deliveredFrames; + readonly attribute unsigned long long totalFrames; }; typedef (MediaStreamTrack or MediaStreamTrackHandle) MediaStreamTrackOrHandle; @@ -157,7 +160,12 @@ application that have not yet been handled.
`[[isClosed]]`
An boolean whose value indicates if the {{MediaStreamTrackProcessor}} is closed. -
+
`[[numDroppedFrames]]`
+
The number of frames dropped by this {{MediaStreamTrackProcessor}}.
+
`[[numDeliveredFrames]]`
+
The number of frames delivered by this {{MediaStreamTrackProcessor}}.
+
`[[numTotalFrames]]`
+
The number of frames received by this {{MediaStreamTrackProcessor}}.
### Constructor ### {#constructor-processor} @@ -183,6 +191,9 @@ application that have not yet been handled. 1. Set |processor|.`[[queue]]` to an empty [=queue=]. 1. Set |processor|.`[[numPendingReads]]` to 0. 1. Set |processor|.`[[isClosed]]` to false. +1. Set |processor|.`[[numDroppedFrames]]` to 0. +1. Set |processor|.`[[numDeliveredFrames]]` to 0. +1. Set |processor|.`[[numTotalFrames]]` to 0. 1. Return |processor|. ### Attributes ### {#attributes-processor} @@ -205,6 +216,7 @@ The maybeReadFrame algorithm is given a |processor| as input. It is d 1. Let |frame| be the result of [=queue/dequeueing=] a frame media data from |processor|.`[[queue]]`. 1. [=ReadableStream/Enqueue=] |frame| in |processor|.{{MediaStreamTrackProcessor/readable}}. 1. Decrement |processor|.`[[numPendingReads]]` by 1. +1. Increment |processor|.`[[numDeliveredFrames]]` by 1. 1. Go to step 1. The processorCancel algorithm is given a |processor| as input. @@ -222,6 +234,16 @@ It is defined by running the following steps: 1. Set |processor|.`[[isClosed]]` to true. + +
droppedFrames
+
Returns the value of |processor|.`[[numDroppedFrames]]`.
+ +
deliveredFrames
+
Returns the value of |processor|.`[[numDeliveredFrames]]`.
+ +
totalFrames
+
Returns the value of |processor|.`[[numTotalFrames]]`.
+ ### Handling interaction with the track ### {#processor-handling-interaction-with-track} @@ -234,8 +256,10 @@ It is defined by running the following steps: 1. If |processor|.`[[queue]]` has |processor|.`[[maxBufferSize]]` elements, run the following steps: 1. Let |droppedFrame| be the result of [=queue/dequeueing=] |processor|.`[[queue]]`. 1. Run the [=Close VideoFrame=] algorithm with |droppedFrame|. -2. [=queue/Enqueue=] the new frame media data in |processor|.`[[queue]]`. -3. [=Queue a task=] to run the [=maybeReadFrame=] algorithm with |processor| as parameter. + 1. Increment |processor|.`[[numDroppedFrames]]` by 1. +1. [=queue/Enqueue=] the new frame media data in |processor|.`[[queue]]`. +1. Increment |processor|.`[[numTotalFrames]]` by 1. +1. [=Queue a task=] to run the [=maybeReadFrame=] algorithm with |processor| as parameter. At any time, the UA MAY [=list/remove=] any frame from |processor|.`[[queue]]`. The UA may decide to remove frames from |processor|.`[[queue]]`, for example, From 8ab4487f56786ade78fd87570214431aee2bdb3c Mon Sep 17 00:00:00 2001 From: guidou Date: Thu, 9 Apr 2026 16:42:10 +0200 Subject: [PATCH 2/9] Apply suggestion from @jan-ivar Co-authored-by: Jan-Ivar Bruaroey --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index a319324..9d0781a 100644 --- a/index.bs +++ b/index.bs @@ -126,7 +126,7 @@ interface MediaStreamTrackHandle { interface MediaStreamTrackProcessor { constructor(MediaStreamTrackProcessorInit init); readonly attribute ReadableStream readable; - readonly attribute unsigned long long droppedFrames; + readonly attribute unsigned long long discardedFrames; readonly attribute unsigned long long deliveredFrames; readonly attribute unsigned long long totalFrames; }; From 348f09f988dab98bfb05ad0de943b281fd0fc23f Mon Sep 17 00:00:00 2001 From: guidou Date: Thu, 9 Apr 2026 16:45:14 +0200 Subject: [PATCH 3/9] Update index.bs --- index.bs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/index.bs b/index.bs index 9d0781a..155944d 100644 --- a/index.bs +++ b/index.bs @@ -127,7 +127,6 @@ interface MediaStreamTrackProcessor { constructor(MediaStreamTrackProcessorInit init); readonly attribute ReadableStream readable; readonly attribute unsigned long long discardedFrames; - readonly attribute unsigned long long deliveredFrames; readonly attribute unsigned long long totalFrames; }; @@ -160,10 +159,8 @@ application that have not yet been handled.
`[[isClosed]]`
An boolean whose value indicates if the {{MediaStreamTrackProcessor}} is closed. -
`[[numDroppedFrames]]`
-
The number of frames dropped by this {{MediaStreamTrackProcessor}}.
-
`[[numDeliveredFrames]]`
-
The number of frames delivered by this {{MediaStreamTrackProcessor}}.
+
`[[numDiscardedFrames]]`
+
The number of frames discarded by this {{MediaStreamTrackProcessor}}.
`[[numTotalFrames]]`
The number of frames received by this {{MediaStreamTrackProcessor}}.
@@ -191,8 +188,7 @@ application that have not yet been handled. 1. Set |processor|.`[[queue]]` to an empty [=queue=]. 1. Set |processor|.`[[numPendingReads]]` to 0. 1. Set |processor|.`[[isClosed]]` to false. -1. Set |processor|.`[[numDroppedFrames]]` to 0. -1. Set |processor|.`[[numDeliveredFrames]]` to 0. +1. Set |processor|.`[[numDiscardedFrames]]` to 0. 1. Set |processor|.`[[numTotalFrames]]` to 0. 1. Return |processor|. @@ -216,7 +212,6 @@ The maybeReadFrame algorithm is given a |processor| as input. It is d 1. Let |frame| be the result of [=queue/dequeueing=] a frame media data from |processor|.`[[queue]]`. 1. [=ReadableStream/Enqueue=] |frame| in |processor|.{{MediaStreamTrackProcessor/readable}}. 1. Decrement |processor|.`[[numPendingReads]]` by 1. -1. Increment |processor|.`[[numDeliveredFrames]]` by 1. 1. Go to step 1. The processorCancel algorithm is given a |processor| as input. @@ -235,11 +230,8 @@ It is defined by running the following steps: -
droppedFrames
-
Returns the value of |processor|.`[[numDroppedFrames]]`.
- -
deliveredFrames
-
Returns the value of |processor|.`[[numDeliveredFrames]]`.
+
discardedFrames
+
Returns the value of |processor|.`[[numDiscardedFrames]]`.
totalFrames
Returns the value of |processor|.`[[numTotalFrames]]`.
@@ -256,7 +248,7 @@ It is defined by running the following steps: 1. If |processor|.`[[queue]]` has |processor|.`[[maxBufferSize]]` elements, run the following steps: 1. Let |droppedFrame| be the result of [=queue/dequeueing=] |processor|.`[[queue]]`. 1. Run the [=Close VideoFrame=] algorithm with |droppedFrame|. - 1. Increment |processor|.`[[numDroppedFrames]]` by 1. + 1. Increment |processor|.`[[numDiscardedFrames]]` by 1. 1. [=queue/Enqueue=] the new frame media data in |processor|.`[[queue]]`. 1. Increment |processor|.`[[numTotalFrames]]` by 1. 1. [=Queue a task=] to run the [=maybeReadFrame=] algorithm with |processor| as parameter. From 3185e46bdd17ceab471b5565454274b6dc82dd82 Mon Sep 17 00:00:00 2001 From: guidou Date: Thu, 16 Apr 2026 16:14:44 +0200 Subject: [PATCH 4/9] Apply suggestion from @jan-ivar Co-authored-by: Jan-Ivar Bruaroey --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index 155944d..33d78f6 100644 --- a/index.bs +++ b/index.bs @@ -162,7 +162,7 @@ application that have not yet been handled.
`[[numDiscardedFrames]]`
The number of frames discarded by this {{MediaStreamTrackProcessor}}.
`[[numTotalFrames]]`
-
The number of frames received by this {{MediaStreamTrackProcessor}}.
+
The number of frames received by this {{MediaStreamTrackProcessor}} including discarded frames.
### Constructor ### {#constructor-processor} From 5697066259aa7ab58a7524ffb29bb83916020fa5 Mon Sep 17 00:00:00 2001 From: guidou Date: Thu, 16 Apr 2026 16:15:17 +0200 Subject: [PATCH 5/9] Apply suggestion from @youennf Co-authored-by: youennf --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index 33d78f6..3b7d9c4 100644 --- a/index.bs +++ b/index.bs @@ -249,7 +249,7 @@ It is defined by running the following steps: 1. Let |droppedFrame| be the result of [=queue/dequeueing=] |processor|.`[[queue]]`. 1. Run the [=Close VideoFrame=] algorithm with |droppedFrame|. 1. Increment |processor|.`[[numDiscardedFrames]]` by 1. -1. [=queue/Enqueue=] the new frame media data in |processor|.`[[queue]]`. +1. [=Queue/Enqueue=] the new frame media data in |processor|.`[[queue]]`. 1. Increment |processor|.`[[numTotalFrames]]` by 1. 1. [=Queue a task=] to run the [=maybeReadFrame=] algorithm with |processor| as parameter. From 6c098c8421869ab2f55a1c62447f4ff7bbe91f66 Mon Sep 17 00:00:00 2001 From: guidou Date: Thu, 16 Apr 2026 16:18:20 +0200 Subject: [PATCH 6/9] Update index.bs --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index 3b7d9c4..2e29dd5 100644 --- a/index.bs +++ b/index.bs @@ -249,8 +249,8 @@ It is defined by running the following steps: 1. Let |droppedFrame| be the result of [=queue/dequeueing=] |processor|.`[[queue]]`. 1. Run the [=Close VideoFrame=] algorithm with |droppedFrame|. 1. Increment |processor|.`[[numDiscardedFrames]]` by 1. -1. [=Queue/Enqueue=] the new frame media data in |processor|.`[[queue]]`. 1. Increment |processor|.`[[numTotalFrames]]` by 1. +1. [=Queue/Enqueue=] the new frame media data in |processor|.`[[queue]]`. 1. [=Queue a task=] to run the [=maybeReadFrame=] algorithm with |processor| as parameter. At any time, the UA MAY [=list/remove=] any frame from |processor|.`[[queue]]`. From 44cf1380f46a46492772804cbb620bbd764732b7 Mon Sep 17 00:00:00 2001 From: guidou Date: Thu, 16 Apr 2026 16:22:25 +0200 Subject: [PATCH 7/9] Update index.bs --- index.bs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.bs b/index.bs index 2e29dd5..30be646 100644 --- a/index.bs +++ b/index.bs @@ -99,9 +99,10 @@ the most recent one. The UA is also free to remove any frames from the queue at any time. The UA may remove frames in order to save resources or to improve performance in -specific situations. In all cases, frames that are not dropped -must be made available to the {{ReadableStream}} in the order in which -they arrive to the {{MediaStreamTrackProcessor}}. +specific situations. In this case, `[[numDiscardedFrames]]` MUST be incremented +accordingly. In all cases, frames that are not dropped must be made available +to the {{ReadableStream}} in the order in which they arrive to the +{{MediaStreamTrackProcessor}}. A {{MediaStreamTrackProcessor}} makes frames available to its associated {{ReadableStream}} only when a read request has been issued on From e9fa36f4c98bee221eeab6929ff2d1ccf56e4df4 Mon Sep 17 00:00:00 2001 From: guidou Date: Thu, 16 Apr 2026 16:25:15 +0200 Subject: [PATCH 8/9] Update index.bs --- index.bs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.bs b/index.bs index 30be646..c3bca4d 100644 --- a/index.bs +++ b/index.bs @@ -260,7 +260,8 @@ to prevent resource exhaustion or to improve performance in certain situations.

The application may detect that frames have been dropped by noticing that there -is a gap in the timestamps of the frames. +is a gap in the timestamps of the frames or by looking at +{{MediaStreamTrackProcessor/discardedFrames}}.

When the `[[track]]` of a {{MediaStreamTrackProcessor}} |processor| From 0967de4a814ac3cfec9d107471956020e88f38f7 Mon Sep 17 00:00:00 2001 From: guidou Date: Thu, 16 Apr 2026 16:31:04 +0200 Subject: [PATCH 9/9] Update index.bs --- index.bs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.bs b/index.bs index c3bca4d..12955b0 100644 --- a/index.bs +++ b/index.bs @@ -99,7 +99,7 @@ the most recent one. The UA is also free to remove any frames from the queue at any time. The UA may remove frames in order to save resources or to improve performance in -specific situations. In this case, `[[numDiscardedFrames]]` MUST be incremented +specific situations. In this case, `[[numDiscardedFrames]]` MUST be incremented accordingly. In all cases, frames that are not dropped must be made available to the {{ReadableStream}} in the order in which they arrive to the {{MediaStreamTrackProcessor}}. @@ -251,12 +251,13 @@ It is defined by running the following steps: 1. Run the [=Close VideoFrame=] algorithm with |droppedFrame|. 1. Increment |processor|.`[[numDiscardedFrames]]` by 1. 1. Increment |processor|.`[[numTotalFrames]]` by 1. -1. [=Queue/Enqueue=] the new frame media data in |processor|.`[[queue]]`. +1. [=queue/Enqueue=] the new frame media data in |processor|.`[[queue]]`. 1. [=Queue a task=] to run the [=maybeReadFrame=] algorithm with |processor| as parameter. At any time, the UA MAY [=list/remove=] any frame from |processor|.`[[queue]]`. The UA may decide to remove frames from |processor|.`[[queue]]`, for example, to prevent resource exhaustion or to improve performance in certain situations. +In this case, |processor|.`[[numDiscardedFrames]]` MUST be incremented accordingly.

The application may detect that frames have been dropped by noticing that there