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

Method reset

src/video_encoder.ts:664–696  ·  view source on GitHub ↗

* Resets the encoder to an unconfigured state.

()

Source from the content-addressed store, hash-verified

662 * Resets the encoder to an unconfigured state.
663 */
664 reset() {
665 // Spec 6.6: Reset VideoEncoder (with exception)
666 // 1. If state is "closed", throw an InvalidStateError.
667 if (this._state === 'closed') {
668 throw new DOMException('Cannot reset closed encoder', 'InvalidStateError');
669 }
670
671 // 2. Set state to "unconfigured".
672 this._state = 'unconfigured';
673
674 // 3. Signal [[codec implementation]] to cease producing output (invalidate ID).
675 this.currentConfigId++;
676
677 // 4. Remove all control messages (handled by ID check).
678
679 // 5. If [[encodeQueueSize]] is greater than zero...
680 if (this._encodeQueueSize > 0) {
681 this._encodeQueueSize = 0;
682 this.decrementQueue();
683 }
684
685 // 6. For each promise in [[pending flush promises]]: Reject promise with exception.
686 for (const p of this.pendingFlushResolvers) {
687 p.reject(new DOMException('Encoder reset', 'AbortError'));
688 }
689 this.pendingFlushResolvers = [];
690
691 this.config = null;
692 this.codecContext?.freeContext();
693 this.codecContext = null;
694 this.chunkOutputted = false;
695 this.colorSpaceSet = false;
696 }
697
698 private handleAsyncError(e: unknown) {
699 const error = e instanceof DOMException

Callers

nothing calls this directly

Calls 1

decrementQueueMethod · 0.95

Tested by

no test coverage detected