diff --git a/types/dom-webcodecs/test/dom-webcodecs-tests.ts b/types/dom-webcodecs/test/dom-webcodecs-tests.ts index 3b12f93e4b8022..df504eba787e84 100644 --- a/types/dom-webcodecs/test/dom-webcodecs-tests.ts +++ b/types/dom-webcodecs/test/dom-webcodecs-tests.ts @@ -128,6 +128,11 @@ AudioDecoder.isConfigSupported(futureAudioDecoderConfig); // $ExpectType void audioDecoder.configure(futureAudioDecoderConfig); +audioDecoder.ondequeue = () => ""; + +// $ExpectType void +audioDecoder.addEventListener("dequeue", (e) => e, { once: true }); + genericCodec(audioDecoder); ////////////////////////////////////////////////// @@ -223,6 +228,9 @@ audioEncoder.configure(futureAudioEncoderConfig); // $ExpectType void audioEncoder.encode(audioFrame); +// $ExpectType void +audioEncoder.addEventListener("dequeue", (e) => e, { once: true }); + // $ExpectType void audioFrame.close(); @@ -424,6 +432,9 @@ videoDecoder.configure(futureVideoDecoderConfig); genericCodec(videoDecoder); +// $ExpectType void +videoDecoder.addEventListener("dequeue", () => {}, { once: true }); + // $ExpectType void videoDecoder.decode(encodedVideoChunk); @@ -544,6 +555,9 @@ videoEncoder.configure(futureVideoEncoderConfig); // $ExpectType number videoEncoder.encodeQueueSize; +// $ExpectType void +videoEncoder.addEventListener("dequeue", () => {}, { once: true }); + // $ExpectType void videoEncoder.encode(videoFrame); diff --git a/types/dom-webcodecs/webcodecs.generated.d.ts b/types/dom-webcodecs/webcodecs.generated.d.ts index 08113ce3824ec3..a30ca8333a5b65 100644 --- a/types/dom-webcodecs/webcodecs.generated.d.ts +++ b/types/dom-webcodecs/webcodecs.generated.d.ts @@ -208,15 +208,40 @@ declare var AudioData: { new(init: AudioDataInit): AudioData; }; +interface AudioDecoderEventMap { + "dequeue": Event; +} + /** Available only in secure contexts. */ interface AudioDecoder { readonly decodeQueueSize: number; readonly state: CodecState; + ondequeue: ((this: AudioDecoder, ev: Event) => any) | null; close(): void; configure(config: AudioDecoderConfig): void; decode(chunk: EncodedAudioChunk): void; flush(): Promise; reset(): void; + addEventListener( + type: K, + listener: (this: AudioDecoder, ev: AudioDecoderEventMap[K]) => any, + options?: boolean | AddEventListenerOptions, + ): void; + addEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | AddEventListenerOptions, + ): void; + removeEventListener( + type: K, + listener: (this: AudioDecoder, ev: AudioDecoderEventMap[K]) => any, + options?: boolean | EventListenerOptions, + ): void; + removeEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | EventListenerOptions, + ): void; } declare var AudioDecoder: { @@ -225,15 +250,40 @@ declare var AudioDecoder: { isConfigSupported(config: AudioDecoderConfig): Promise; }; +interface AudioEncoderEventMap { + "dequeue": Event; +} + /** Available only in secure contexts. */ interface AudioEncoder { readonly encodeQueueSize: number; readonly state: CodecState; + ondequeue: ((this: AudioEncoder, ev: Event) => any) | null; close(): void; configure(config: AudioEncoderConfig): void; encode(data: AudioData): void; flush(): Promise; reset(): void; + addEventListener( + type: K, + listener: (this: AudioEncoder, ev: AudioEncoderEventMap[K]) => any, + options?: boolean | AddEventListenerOptions, + ): void; + addEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | AddEventListenerOptions, + ): void; + removeEventListener( + type: K, + listener: (this: AudioEncoder, ev: AudioEncoderEventMap[K]) => any, + options?: boolean | EventListenerOptions, + ): void; + removeEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | EventListenerOptions, + ): void; } declare var AudioEncoder: { @@ -323,15 +373,40 @@ declare var VideoColorSpace: { new(init?: VideoColorSpaceInit): VideoColorSpace; }; +interface VideoDecoderEventMap { + "dequeue": Event; +} + /** Available only in secure contexts. */ interface VideoDecoder { readonly decodeQueueSize: number; readonly state: CodecState; + ondequeue: ((this: VideoDecoder, ev: Event) => any) | null; close(): void; configure(config: VideoDecoderConfig): void; decode(chunk: EncodedVideoChunk): void; flush(): Promise; reset(): void; + addEventListener( + type: K, + listener: (this: VideoDecoder, ev: VideoDecoderEventMap[K]) => any, + options?: boolean | AddEventListenerOptions, + ): void; + addEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | AddEventListenerOptions, + ): void; + removeEventListener( + type: K, + listener: (this: VideoDecoder, ev: VideoDecoderEventMap[K]) => any, + options?: boolean | EventListenerOptions, + ): void; + removeEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | EventListenerOptions, + ): void; } declare var VideoDecoder: { @@ -340,15 +415,40 @@ declare var VideoDecoder: { isConfigSupported(config: VideoDecoderConfig): Promise; }; +interface VideoEncoderEventMap { + "dequeue": Event; +} + /** Available only in secure contexts. */ interface VideoEncoder { readonly encodeQueueSize: number; readonly state: CodecState; close(): void; + ondequeue: ((this: VideoEncoder, ev: Event) => any) | null; configure(config: VideoEncoderConfig): void; encode(frame: VideoFrame, options?: VideoEncoderEncodeOptions): void; flush(): Promise; reset(): void; + addEventListener( + type: K, + listener: (this: VideoEncoder, ev: VideoEncoderEventMap[K]) => any, + options?: boolean | AddEventListenerOptions, + ): void; + addEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | AddEventListenerOptions, + ): void; + removeEventListener( + type: K, + listener: (this: VideoEncoder, ev: VideoEncoderEventMap[K]) => any, + options?: boolean | EventListenerOptions, + ): void; + removeEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | EventListenerOptions, + ): void; } declare var VideoEncoder: {