From 0708187b788ac9d41b7082993b2b0fe81d7f6151 Mon Sep 17 00:00:00 2001 From: Youenn Fablet Date: Mon, 29 Jan 2024 11:05:45 +0100 Subject: [PATCH] Allow UA to clamp maxBufferSize to a value between 1 and the value provided by the web page --- index.bs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/index.bs b/index.bs index b6b222a..e728de5 100644 --- a/index.bs +++ b/index.bs @@ -152,13 +152,21 @@ application that have not yet been handled. 1. If |init|.{{MediaStreamTrackProcessorInit/track}} is not a valid {{MediaStreamTrack}}, throw a {{TypeError}}. -2. Let |processor| be a new {{MediaStreamTrackProcessor}} object. -3. Assign |init|.{{MediaStreamTrackProcessorInit/track}} to |processor|.`[[track]]`. -4. If |init|.{{MediaStreamTrackProcessorInit/maxBufferSize}} has a integer value greater than or equal to 1, assign it to |processor|.`[[maxBufferSize]]`. -6. Set the `[[queue]]` internal slot of |processor| to an empty [=queue=]. -7. Set |processor|.`[[numPendingReads]]` to 0. -8. Set |processor|.`[[isClosed]]` to false. -9. Return |processor|. +1. Let |maxBufferSize| be 1. +1. If |init|.{{MediaStreamTrackProcessorInit/maxBufferSize}} has an integer value greater than 1, run the following substeps: + 1. Set |maxBufferSize| to |init|.{{MediaStreamTrackProcessorInit/maxBufferSize}}. + 1. The user agent MAY decide to clamp |maxBufferSize| to a lower value, but no lower than 1. +

+ Clamping |maxBufferSize| can be useful for some sources like cameras, for instance in case + they can only use a limited number of VideoFrames at any given time. +

+1. Let |processor| be a new {{MediaStreamTrackProcessor}} object. +1. Set |processor|.`[[track]]` to |init|.{{MediaStreamTrackProcessorInit/track}}. +1. Set |processor|.`[[maxBufferSize]]` to |maxBufferSize|. +1. Set |processor|.`[[queue]]` to an empty [=queue=]. +1. Set |processor|.`[[numPendingReads]]` to 0. +1. Set |processor|.`[[isClosed]]` to false. +1. Return |processor|. ### Attributes ### {#attributes-processor}
@@ -204,7 +212,7 @@ with |processor| as parameter. The handleNewFrame algorithm is given a |processor| as input. It is defined by running the following steps: -1. If |processor|.`[[maxBufferSize]]` has a value and |processor|.`[[queue]]` has |processor|.`[[maxBufferSize]]` elements, [=queue/dequeue=] an item from |processor|.`[[queue]]`. +1. If |processor|.`[[queue]]` has |processor|.`[[maxBufferSize]]` elements, [=queue/dequeue=] an item from |processor|.`[[queue]]`. 2. [=queue/Enqueue=] the new frame in |processor|.`[[queue]]`. 3. [=Queue a task=] to run the [=maybeReadFrame=] algorithm with |processor| as parameter.