MCPcopy Create free account
hub / github.com/Vanilagy/webcodecs-polyfill / decode

Method decode

src/video_decoder.ts:226–248  ·  view source on GitHub ↗

* Queues an encoded video chunk to be decoded.

(chunk: EncodedVideoChunk)

Source from the content-addressed store, hash-verified

224 * Queues an encoded video chunk to be decoded.
225 */
226 decode(chunk: EncodedVideoChunk) {
227 // Spec 4.5: If [[state]] is not "configured", throw an InvalidStateError.
228 if (this._state !== 'configured') {
229 throw new DOMException('Decoder is not configured', 'InvalidStateError');
230 }
231
232 // Spec 4.5: If [[key chunk required]] is true:
233 if (this.keyChunkRequired) {
234 // If chunk.type is not key, throw a DataError.
235 if (chunk.type !== 'key') {
236 throw new DOMException('Key frame required', 'DataError');
237 }
238 // Otherwise, assign false to [[key chunk required]].
239 this.keyChunkRequired = false;
240 }
241
242 // Spec 4.5: Increment [[decodeQueueSize]].
243 this._decodeQueueSize++;
244
245 // Spec 4.5: Queue a control message to decode the chunk.
246 this.decodeInternal(chunk)
247 .catch(e => this.handleAsyncError(e));
248 }
249
250 private outputFrame(currentConfigId: number) {
251 if (this.currentConfigId !== currentConfigId) {

Callers

nothing calls this directly

Calls 2

decodeInternalMethod · 0.95
handleAsyncErrorMethod · 0.95

Tested by

no test coverage detected