1. Definitions
- Codec
-
Refers generically to an instance of
AudioDecoder,AudioEncoder,VideoDecoder, orVideoEncoder. - Key Chunk
-
An encoded chunk that does not depend on any other frames for decoding. Also commonly referred to as a "key frame".
- Internal Pending Output
-
Codec outputs such as
VideoFrames that currently reside in the internal pipeline of the underlying codec implementation. The underlying codec implementation MAY emit new outputs only when new inputs are provided. The underlying codec implementation MUST emit all outputs in response to a flush. - Codec System Resources
-
Resources including CPU memory, GPU memory, and exclusive handles to specific decoding/encoding hardware that MAY be allocated by the User Agent as part of codec configuration or generation of
AudioDataandVideoFrameobjects. Such resources MAY be quickly exhausted and SHOULD be released immediately when no longer in use. - Temporal Layer
-
A grouping of
EncodedVideoChunks whose timestamp cadence produces a particular framerate. SeescalabilityMode. - Progressive Image
-
An image that supports decoding to multiple levels of detail, with lower levels becoming available while the encoded data is not yet fully buffered.
- Progressive Image Frame Generation
-
A generational identifier for a given Progressive Image decoded output. Each successive generation adds additional detail to the decoded output. The mechanism for computing a frame’s generation is implementer defined.
- Primary Image Track
-
An image track that is marked by the given image file as being the default track. The mechanism for indicating a primary track is format defined.
- RGB Format
-
A
VideoPixelFormatcontaining red, green, and blue color channels in any order or layout (interleaved or planar), and irrespective of whether an alpha channel is present. - sRGB Color Space
-
A
VideoColorSpaceobject, initialized as follows:-
[[primaries]]is set tobt709, -
[[transfer]]is set toiec61966-2-1, -
[[matrix]]is set torgb, -
[[full range]]is set totrue
-
- Display P3 Color Space
-
A
VideoColorSpaceobject, initialized as follows:-
[[primaries]]is set tosmpte432, -
[[transfer]]is set toiec61966-2-1, -
[[matrix]]is set torgb, -
[[full range]]is set totrue
-
- REC709 Color Space
-
A
VideoColorSpaceobject, initialized as follows:-
[[primaries]]is set tobt709, -
[[transfer]]is set tobt709, -
[[matrix]]is set tobt709, -
[[full range]]is set tofalse
-
- Codec Saturation
-
The state of an underlying codec implementation where the number of active decoding or encoding requests has reached an implementation specific maximum such that it is temporarily unable to accept more work. The maximum may be any value greater than 1, including infinity (no maximum). While saturated, additional calls to
decode()orencode()will be buffered in the control message queue, and will increment the respectivedecodeQueueSizeandencodeQueueSizeattributes. The codec implementation will become unsaturated after making sufficient progress on the current workload.
2. Codec Processing Model
2.1. Background
The codec interfaces defined by the specification are designed such that new
codec tasks can be scheduled while previous tasks are still pending. For
example, web authors can call decode() without waiting for a previous
decode() to complete. This is achieved by offloading underlying codec tasks
to a separate parallel queue for parallel execution.
This section describes threading behaviors as they are visible from the perspective of web authors. Implementers can choose to use more threads, as long as the externally visible behaviors of blocking and sequencing are maintained as follows.
2.2. Control Messages
A control message defines a sequence of steps corresponding to a
method invocation on a codec instance (e.g. encode()).
A control message queue is a queue of control messages. Each codec instance has a control message queue stored in an internal slot named [[control message queue]].
Queuing a control message means enqueuing the message to a codec’s [[control message queue]]. Invoking codec methods will generally queue a control message to schedule work.
Running a control message means performing a sequence of steps specified by the method that enqueued the message.
The steps of a given control message can block processing later messages in the
control message queue. Each codec instance has a boolean internal slot named
[[message queue blocked]] that is set to true when this occurs. A
blocking message will conclude by setting [[message queue blocked]] to
false and rerunning the Process the control message queue steps.
All control messages will return either "processed" or "not processed".
Returning "processed" indicates the message steps are being (or have been)
executed and the message may be removed from the control message queue.
"not processed" indicates the message must not be processed at this time
and should remain in the control message queue to be retried later.
To Process the control message queue, run these steps:
-
While [[message queue blocked]] is
falseand [[control message queue]] is not empty:-
Let front message be the first message in [[control message queue]].
-
Let outcome be the result of running the control message steps described by front message.
-
If outcome equals
"not processed", break. -
Otherwise, dequeue front message from the [[control message queue]].
-
2.3. Codec Work Parallel Queue
Each codec instance has an internal slot named [[codec work queue]] that is a parallel queue.
Each codec instance has an internal slot named [[codec implementation]] that refers to the underlying platform encoder or decoder. Except for the initial assignment, any steps that reference [[codec implementation]] will be enqueued to the [[codec work queue]].
Each codec instance has a unique codec task source. Tasks queued from the [[codec work queue]] to the event loop will use the codec task source.
3. AudioDecoder Interface
[Exposed =(Window ,DedicatedWorker ),SecureContext ]interface :AudioDecoder EventTarget {constructor (AudioDecoderInit );init readonly attribute CodecState state ;readonly attribute unsigned long decodeQueueSize ;attribute EventHandler ondequeue ;undefined configure (AudioDecoderConfig );config undefined decode (EncodedAudioChunk );chunk Promise <undefined >flush ();undefined reset ();undefined close ();static Promise <AudioDecoderSupport >isConfigSupported (AudioDecoderConfig ); };config dictionary {AudioDecoderInit required AudioDataOutputCallback ;output required WebCodecsErrorCallback ; };error callback =AudioDataOutputCallback undefined (AudioData );output
3.1. Internal Slots
[[control message queue]]-
A queue of control messages to be performed upon this codec instance. See [[control message queue]].
[[message queue blocked]]-
A boolean indicating when processing the
[[control message queue]]is blocked by a pending control message. See [[message queue blocked]]. [[codec implementation]]-
Underlying decoder implementation provided by the User Agent. See [[codec implementation]].
[[codec work queue]]-
A parallel queue used for running parallel steps that reference the
[[codec implementation]]. See [[codec work queue]]. [[codec saturated]]-
A boolean indicating when the
[[codec implementation]]is unable to accept additional decoding work. [[output callback]]-
Callback given at construction for decoded outputs.
[[error callback]]-
Callback given at construction for decode errors.
[[key chunk required]]-
A boolean indicating that the next chunk passed to
decode()MUST describe a key chunk as indicated by[[type]]. [[state]]-
The current
CodecStateof thisAudioDecoder. [[decodeQueueSize]]-
The number of pending decode requests. This number will decrease as the underlying codec is ready to accept new input.
[[pending flush promises]]-
A list of unresolved promises returned by calls to
flush(). [[dequeue event scheduled]]-
A boolean indicating whether a
dequeueevent is already scheduled to fire. Used to avoid event spam.
3.2. Constructors
AudioDecoder(init)
-
Let d be a new
AudioDecoderobject. -
Assign a new queue to
[[control message queue]]. -
Assign
falseto[[message queue blocked]]. -
Assign
nullto[[codec implementation]]. -
Assign the result of starting a new parallel queue to
[[codec work queue]]. -
Assign
falseto[[codec saturated]]. -
Assign init.output to
[[output callback]]. -
Assign init.error to
[[error callback]]. -
Assign
trueto[[key chunk required]]. -
Assign
"unconfigured"to[[state]] -
Assign
0to[[decodeQueueSize]]. -
Assign a new list to
[[pending flush promises]]. -
Assign
falseto[[dequeue event scheduled]]. -
Return d.
3.3. Attributes
state, of type CodecState, readonly-
Returns the value of
[[state]]. decodeQueueSize, of type unsigned long, readonly-
Returns the value of
[[decodeQueueSize]]. ondequeue, of type EventHandler-
An event handler IDL attribute whose event handler event type is
dequeue.
3.4. Event Summary
dequeue-
Fired at the
AudioDecoderwhen thedecodeQueueSizehas decreased.
3.5. Methods
configure(config)-
Enqueues a control message to configure the audio decoder for decoding
chunks as described by config.
NOTE: This method will trigger a
NotSupportedErrorif the User Agent does not support config. Authors are encouraged to first check support by callingisConfigSupported()with config. User Agents don’t have to support any particular codec type or configuration.When invoked, run these steps:
-
If config is not a valid AudioDecoderConfig, throw a
TypeError. -
If
[[state]]is“closed”, throw anInvalidStateError. -
Set
[[state]]to"configured". -
Set
[[key chunk required]]totrue. -
Queue a control message to configure the decoder with config.
Running a control message to configure the decoder means running these steps:
-
Assign
trueto[[message queue blocked]]. -
Enqueue the following steps to
[[codec work queue]]:-
Let supported be the result of running the Check Configuration Support algorithm with config.
-
If supported is
false, queue a task to run the Close AudioDecoder algorithm withNotSupportedErrorand abort these steps. -
If needed, assign
[[codec implementation]]with an implementation supporting config. -
Configure
[[codec implementation]]with config. -
queue a task to run the following steps:
-
Assign
falseto[[message queue blocked]].
-
-
-
Return
"processed".
-
decode(chunk)-
Enqueues a control message to decode the given chunk.
When invoked, run these steps:
-
If
[[state]]is not"configured", throw anInvalidStateError. -
If
[[key chunk required]]istrue:-
Implementers SHOULD inspect the chunk’s
[[internal data]]to verify that it is truly a key chunk. If a mismatch is detected, throw aDataError. -
Otherwise, assign
falseto[[key chunk required]].
-
Increment
[[decodeQueueSize]]. -
Queue a control message to decode the chunk.
Running a control message to decode the chunk means performing these steps:
-
If
[[codec saturated]]equalstrue, return"not processed". -
If decoding chunk will cause the
[[codec implementation]]to become saturated, assigntrueto[[codec saturated]]. -
Decrement
[[decodeQueueSize]]and run the Schedule Dequeue Event algorithm. -
Enqueue the following steps to the
[[codec work queue]]:-
Attempt to use
[[codec implementation]]to decode the chunk. -
If decoding results in an error, queue a task to run the Close AudioDecoder algorithm with
EncodingErrorand return. -
If
[[codec saturated]]equalstrueand[[codec implementation]]is no longer saturated, queue a task to perform the following steps:-
Assign
falseto[[codec saturated]].
-
-
Let decoded outputs be a list of decoded audio data outputs emitted by
[[codec implementation]]. -
If decoded outputs is not empty, queue a task to run the Output AudioData algorithm with decoded outputs.
-
-
Return
"processed".
-
flush()-
Completes all control messages in the control message queue
and emits all outputs.
When invoked, run these steps:
-
If
[[state]]is not"configured", return a promise rejected withInvalidStateErrorDOMException. -
Set
[[key chunk required]]totrue. -
Let promise be a new Promise.
-
Append promise to
[[pending flush promises]]. -
Queue a control message to flush the codec with promise.
-
Return promise.
Running a control message to flush the codec means performing these steps with promise.
-
Enqueue the following steps to the
[[codec work queue]]:-
Signal
[[codec implementation]]to emit all internal pending outputs. -
Let decoded outputs be a list of decoded audio data outputs emitted by
[[codec implementation]]. -
Queue a task to perform these steps:
-
If decoded outputs is not empty, run the Output AudioData algorithm with decoded outputs.
-
Remove promise from
[[pending flush promises]]. -
Resolve promise.
-
-
-
Return
"processed".
-
reset()-
Immediately resets all state including configuration,
control messages in the control message queue, and all pending
callbacks.
When invoked, run the Reset AudioDecoder algorithm with an
AbortErrorDOMException. close()-
Immediately aborts all pending work and releases system resources.
Close is final.
When invoked, run the Close AudioDecoder algorithm with an
AbortErrorDOMException. isConfigSupported(config)-
Returns a promise indicating whether the provided config is supported by
the User Agent.
NOTE: The returned
AudioDecoderSupportconfigwill contain only the dictionary members that User Agent recognized. Unrecognized dictionary members will be ignored. Authors can detect unrecognized dictionary members by comparingconfigto their provided config.When invoked, run these steps:
-
If config is not a valid AudioDecoderConfig, return a promise rejected with
TypeError. -
Let p be a new Promise.
-
Let checkSupportQueue be the result of starting a new parallel queue.
-
Enqueue the following steps to checkSupportQueue:
-
Let supported be the result of running the Check Configuration Support algorithm with config.
-
Queue a task to run the following steps:
-
Let decoderSupport be a newly constructed
AudioDecoderSupport, initialized as follows:-
Set
configto the result of running the Clone Configuration algorithm with config. -
Set
supportedto supported.
-
-
Resolve p with decoderSupport.
-
-
-
Return p.
-
3.6. Algorithms
- Schedule Dequeue Event
-
-
If
[[dequeue event scheduled]]equalstrue, return. -
Assign
trueto[[dequeue event scheduled]]. -
Queue a task to run the following steps:
-
Assign
falseto[[dequeue event scheduled]].
-
- Output AudioData (with outputs)
-
Run these steps:
-
For each output in outputs:
-
Let data be an
AudioData, initialized as follows:-
Assign
falseto[[Detached]]. -
Let resource be the media resource described by output.
-
Let resourceReference be a reference to resource.
-
Assign resourceReference to
[[resource reference]]. -
Let timestamp be the
[[timestamp]]of theEncodedAudioChunkassociated with output. -
Assign timestamp to
[[timestamp]]. -
If output uses a recognized
AudioSampleFormat, assign that format to[[format]]. Otherwise, assignnullto[[format]]. -
Assign values to
[[sample rate]],[[number of frames]], and[[number of channels]]as determined by output.
-
-
Invoke
[[output callback]]with data.
-
-
- Reset AudioDecoder (with exception)
-
Run these steps:
-
If
[[state]]is"closed", throw anInvalidStateError. -
Set
[[state]]to"unconfigured". -
Signal
[[codec implementation]]to cease producing output for the previous configuration. -
Remove all control messages from the
[[control message queue]]. -
If
[[decodeQueueSize]]is greater than zero:-
Set
[[decodeQueueSize]]to zero. -
Run the Schedule Dequeue Event algorithm.
-
-
For each promise in
[[pending flush promises]]:-
Reject promise with exception.
-
Remove promise from
[[pending flush promises]].
-
-
- Close AudioDecoder (with exception)
-
Run these steps:
-
Run the Reset AudioDecoder algorithm with exception.
-
Set
[[state]]to"closed". -
Clear
[[codec implementation]]and release associated system resources. -
If exception is not an
AbortErrorDOMException, invoke the[[error callback]]with exception.
-
4. VideoDecoder Interface
[Exposed =(Window ,DedicatedWorker ),SecureContext ]interface :VideoDecoder EventTarget {constructor (VideoDecoderInit );init readonly attribute CodecState state ;readonly attribute unsigned long decodeQueueSize ;attribute EventHandler ondequeue ;undefined configure (VideoDecoderConfig );config undefined decode (EncodedVideoChunk );chunk Promise <undefined >flush ();undefined reset ();undefined close ();static Promise <VideoDecoderSupport >isConfigSupported (VideoDecoderConfig ); };config dictionary {VideoDecoderInit required VideoFrameOutputCallback ;output required WebCodecsErrorCallback ; };error callback =VideoFrameOutputCallback undefined (VideoFrame );output
4.1. Internal Slots
[[control message queue]]-
A queue of control messages to be performed upon this codec instance. See [[control message queue]].
[[message queue blocked]]-
A boolean indicating when processing the
[[control message queue]]is blocked by a pending control message. See [[message queue blocked]]. [[codec implementation]]-
Underlying decoder implementation provided by the User Agent. See [[codec implementation]].
[[codec work queue]]-
A parallel queue used for running parallel steps that reference the
[[codec implementation]]. See [[codec work queue]]. [[codec saturated]]-
A boolean indicating when the
[[codec implementation]]is unable to accept additional decoding work. [[output callback]]-
Callback given at construction for decoded outputs.
[[error callback]]-
Callback given at construction for decode errors.
[[active decoder config]]-
The
VideoDecoderConfigthat is actively applied. [[key chunk required]]-
A boolean indicating that the next chunk passed to
decode()MUST describe a key chunk as indicated bytype. [[state]]-
The current
CodecStateof thisVideoDecoder. [[decodeQueueSize]]-
The number of pending decode requests. This number will decrease as the underlying codec is ready to accept new input.
[[pending flush promises]]-
A list of unresolved promises returned by calls to
flush(). [[dequeue event scheduled]]-
A boolean indicating whether a
dequeueevent is already scheduled to fire. Used to avoid event spam.
4.2. Constructors
VideoDecoder(init)
-
Let d be a new
VideoDecoderobject. -
Assign a new queue to
[[control message queue]]. -
Assign
falseto[[message queue blocked]]. -
Assign
nullto[[codec implementation]]. -
Assign the result of starting a new parallel queue to
[[codec work queue]]. -
Assign
falseto[[codec saturated]]. -
Assign init.output to
[[output callback]]. -
Assign init.error to
[[error callback]]. -
Assign
nullto[[active decoder config]]. -
Assign
trueto[[key chunk required]]. -
Assign
"unconfigured"to[[state]] -
Assign
0to[[decodeQueueSize]]. -
Assign a new list to
[[pending flush promises]]. -
Assign
falseto[[dequeue event scheduled]]. -
Return d.
4.3. Attributes
state, of type CodecState, readonly-
Returns the value of
[[state]]. decodeQueueSize, of type unsigned long, readonly-
Returns the value of
[[decodeQueueSize]]. ondequeue, of type EventHandler-
An event handler IDL attribute whose event handler event type is
dequeue.
4.4. Event Summary
dequeue-
Fired at the
VideoDecoderwhen thedecodeQueueSizehas decreased.
4.5. Methods
configure(config)-
Enqueues a control message to configure the video decoder for decoding
chunks as described by config.
NOTE: This method will trigger a
NotSupportedErrorif the User Agent does not support config. Authors are encouraged to first check support by callingisConfigSupported()with config. User Agents don’t have to support any particular codec type or configuration.When invoked, run these steps:
-
If config is not a valid VideoDecoderConfig, throw a
TypeError. -
If
[[state]]is“closed”, throw anInvalidStateError. -
Set
[[state]]to"configured". -
Set
[[key chunk required]]totrue. -
Queue a control message to configure the decoder with config.
Running a control message to configure the decoder means running these steps:
-
Assign
trueto[[message queue blocked]]. -
Enqueue the following steps to
[[codec work queue]]:-
Let supported be the result of running the Check Configuration Support algorithm with config.
-
If supported is
false, queue a task to run the Close VideoDecoder algorithm withNotSupportedErrorand abort these steps. -
If needed, assign
[[codec implementation]]with an implementation supporting config. -
Configure
[[codec implementation]]with config. -
Assign config to
[[active decoder config]]. -
queue a task to run the following steps:
-
Assign
falseto[[message queue blocked]].
-
-
-
Return
"processed".
-
decode(chunk)-
Enqueues a control message to decode the given chunk.
NOTE: Authors are encouraged to call
close()on outputVideoFrames immediately when frames are no longer needed. The underlying media resources are owned by theVideoDecoderand failing to release them (or waiting for garbage collection) can cause decoding to stall.NOTE:
VideoDecoderrequires that frames are output in the order they expect to be presented, commonly known as presentation order. When using some[[codec implementation]]s the User Agent will have to reorder outputs into presentation order.When invoked, run these steps:
-
If
[[state]]is not"configured", throw anInvalidStateError. -
If
[[key chunk required]]istrue:-
Implementers SHOULD inspect the chunk’s
[[internal data]]to verify that it is truly a key chunk. If a mismatch is detected, throw aDataError. -
Otherwise, assign
falseto[[key chunk required]].
-
Increment
[[decodeQueueSize]]. -
Queue a control message to decode the chunk.
Running a control message to decode the chunk means performing these steps:
-
If
[[codec saturated]]equalstrue, return"not processed". -
If decoding chunk will cause the
[[codec implementation]]to become saturated, assigntrueto[[codec saturated]]. -
Decrement
[[decodeQueueSize]]and run the Schedule Dequeue Event algorithm. -
Enqueue the following steps to the
[[codec work queue]]:-
Attempt to use
[[codec implementation]]to decode the chunk. -
If decoding results in an error, queue a task to run the Close VideoDecoder algorithm with
EncodingErrorand return. -
If
[[codec saturated]]equalstrueand[[codec implementation]]is no longer saturated, queue a task to perform the following steps:-
Assign
falseto[[codec saturated]].
-
-
Let decoded outputs be a list of decoded video data outputs emitted by
[[codec implementation]]in presentation order. -
If decoded outputs is not empty, queue a task to run the Output VideoFrame algorithm with decoded outputs.
-
-
Return
"processed".
-
flush()-
Completes all control messages in the control message queue
and emits all outputs.
When invoked, run these steps:
-
If
[[state]]is not"configured", return a promise rejected withInvalidStateErrorDOMException. -
Set
[[key chunk required]]totrue. -
Let promise be a new Promise.
-
Append promise to
[[pending flush promises]]. -
Queue a control message to flush the codec with promise.
-
Return promise.
Running a control message to flush the codec means performing these steps with promise.
-
Enqueue the following steps to the
[[codec work queue]]:-
Signal
[[codec implementation]]to emit all internal pending outputs. -
Let decoded outputs be a list of decoded video data outputs emitted by
[[codec implementation]]. -
Queue a task to perform these steps:
-
If decoded outputs is not empty, run the Output VideoFrame algorithm with decoded outputs.
-
Remove promise from
[[pending flush promises]]. -
Resolve promise.
-
-
-
Return
"processed".
-
reset()-
Immediately resets all state including configuration,
control messages in the control message queue, and all pending
callbacks.
When invoked, run the Reset VideoDecoder algorithm with an
AbortErrorDOMException. close()-
Immediately aborts all pending work and releases system resources.
Close is final.
When invoked, run the Close VideoDecoder algorithm with an
AbortErrorDOMException. isConfigSupported(config)-
Returns a promise indicating whether the provided config is supported by
the User Agent.
NOTE: The returned
VideoDecoderSupportconfigwill contain only the dictionary members that User Agent recognized. Unrecognized dictionary members will be ignored. Authors can detect unrecognized dictionary members by comparingconfigto their provided config.When invoked, run these steps:
-
If config is not a valid VideoDecoderConfig, return a promise rejected with
TypeError. -
Let p be a new Promise.
-
Let checkSupportQueue be the result of starting a new parallel queue.
-
Enqueue the following steps to checkSupportQueue:
-
Let supported be the result of running the Check Configuration Support algorithm with config.
-
Queue a task to run the following steps:
-
Let decoderSupport be a newly constructed
VideoDecoderSupport, initialized as follows:-
Set
configto the result of running the Clone Configuration algorithm with config. -
Set
supportedto supported.
-
-
Resolve p with decoderSupport.
-
-
-
Return p.
-
4.6. Algorithms
- Schedule Dequeue Event
-
-
If
[[dequeue event scheduled]]equalstrue, return. -
Assign
trueto[[dequeue event scheduled]]. -
Queue a task to run the following steps:
-
Assign
falseto[[dequeue event scheduled]].
-
- Output VideoFrames (with outputs)
-
Run these steps:
-
For each output in outputs:
-
Let timestamp and duration be the
timestampanddurationfrom theEncodedVideoChunkassociated with output. -
Let displayAspectWidth and displayAspectHeight be undefined.
-
If
displayAspectWidthanddisplayAspectHeightexist in the[[active decoder config]], assign their values to displayAspectWidth and displayAspectHeight respectively. -
Let colorSpace be the
VideoColorSpacefor output as detected by the codec implementation. If noVideoColorSpaceis detected, let colorSpace beundefined.NOTE: The codec implementation can detect a
VideoColorSpaceby analyzing the bitstream. Detection is made on a best-effort basis. The exact method of detection is implementer defined and codec-specific. Authors can override the detectedVideoColorSpaceby providing acolorSpacein theVideoDecoderConfig. -
If
colorSpaceexists in the[[active decoder config]], assign its value to colorSpace. In that case, User Agents MAY replacenullmembers of colorSpace with the corresponding values detected by the codec implementation. FIXME: Properly specify the case ofnullmembers. -
Assign the values of
rotationandflipto rotation and flip respectively. -
Let frame be the result of running the Create a VideoFrame algorithm with output, timestamp, duration, displayAspectWidth, displayAspectHeight, colorSpace, rotation, and flip.
-
Invoke
[[output callback]]with frame.
-
-
- Reset VideoDecoder (with exception)
-
Run these steps:
-
If
stateis"closed", throw anInvalidStateError. -
Set
stateto"unconfigured". -
Signal
[[codec implementation]]to cease producing output for the previous configuration. -
Remove all control messages from the
[[control message queue]]. -
If
[[decodeQueueSize]]is greater than zero:-
Set
[[decodeQueueSize]]to zero. -
Run the Schedule Dequeue Event algorithm.
-
-
For each promise in
[[pending flush promises]]:-
Reject promise with exception.
-
Remove promise from
[[pending flush promises]].
-
-
- Close VideoDecoder (with exception)
-
Run these steps:
-
Run the Reset VideoDecoder algorithm with exception.
-
Set
stateto"closed". -
Clear
[[codec implementation]]and release associated system resources. -
If exception is not an
AbortErrorDOMException, invoke the[[error callback]]with exception.
-
5. AudioEncoder Interface
[Exposed =(Window ,DedicatedWorker ),SecureContext ]interface :AudioEncoder EventTarget {constructor (AudioEncoderInit );init readonly attribute CodecState state ;readonly attribute unsigned long encodeQueueSize ;attribute EventHandler ondequeue ;undefined configure (AudioEncoderConfig );config undefined encode (AudioData );data Promise <undefined >flush ();undefined reset ();undefined close ();static Promise <AudioEncoderSupport >isConfigSupported (AudioEncoderConfig ); };config dictionary {AudioEncoderInit required EncodedAudioChunkOutputCallback ;output required WebCodecsErrorCallback ; };error callback =EncodedAudioChunkOutputCallback undefined (EncodedAudioChunk ,output optional EncodedAudioChunkMetadata = {});metadata
5.1. Internal Slots
[[control message queue]]-
A queue of control messages to be performed upon this codec instance. See [[control message queue]].
[[message queue blocked]]-
A boolean indicating when processing the
[[control message queue]]is blocked by a pending control message. See [[message queue blocked]]. [[codec implementation]]-
Underlying encoder implementation provided by the User Agent. See [[codec implementation]].
[[codec work queue]]-
A parallel queue used for running parallel steps that reference the
[[codec implementation]]. See [[codec work queue]]. [[codec saturated]]-
A boolean indicating when the
[[codec implementation]]is unable to accept additional encoding work. [[output callback]]-
Callback given at construction for encoded outputs.
[[error callback]]-
Callback given at construction for encode errors.
[[active encoder config]]-
The
AudioEncoderConfigthat is actively applied. [[active output config]]-
The
AudioDecoderConfigthat describes how to decode the most recently emittedEncodedAudioChunk. [[state]]-
The current
CodecStateof thisAudioEncoder. [[encodeQueueSize]]-
The number of pending encode requests. This number will decrease as