Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#70300 [@types/dom-webcodecs] add missing "…
Browse files Browse the repository at this point in the history
…dequeue" event to (Video|Audio)(En/De)coder by @dumbmoron
  • Loading branch information
dumbmoron authored Oct 8, 2024
1 parent 0d19896 commit ca02214
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
14 changes: 14 additions & 0 deletions types/dom-webcodecs/test/dom-webcodecs-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

//////////////////////////////////////////////////
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -424,6 +432,9 @@ videoDecoder.configure(futureVideoDecoderConfig);

genericCodec(videoDecoder);

// $ExpectType void
videoDecoder.addEventListener("dequeue", () => {}, { once: true });

// $ExpectType void
videoDecoder.decode(encodedVideoChunk);

Expand Down Expand Up @@ -544,6 +555,9 @@ videoEncoder.configure(futureVideoEncoderConfig);
// $ExpectType number
videoEncoder.encodeQueueSize;

// $ExpectType void
videoEncoder.addEventListener("dequeue", () => {}, { once: true });

// $ExpectType void
videoEncoder.encode(videoFrame);

Expand Down
100 changes: 100 additions & 0 deletions types/dom-webcodecs/webcodecs.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>;
reset(): void;
addEventListener<K extends keyof AudioDecoderEventMap>(
type: K,
listener: (this: AudioDecoder, ev: AudioDecoderEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;
removeEventListener<K extends keyof AudioDecoderEventMap>(
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: {
Expand All @@ -225,15 +250,40 @@ declare var AudioDecoder: {
isConfigSupported(config: AudioDecoderConfig): Promise<AudioDecoderSupport>;
};

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<void>;
reset(): void;
addEventListener<K extends keyof AudioEncoderEventMap>(
type: K,
listener: (this: AudioEncoder, ev: AudioEncoderEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;
removeEventListener<K extends keyof AudioEncoderEventMap>(
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: {
Expand Down Expand Up @@ -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<void>;
reset(): void;
addEventListener<K extends keyof VideoDecoderEventMap>(
type: K,
listener: (this: VideoDecoder, ev: VideoDecoderEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;
removeEventListener<K extends keyof VideoDecoderEventMap>(
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: {
Expand All @@ -340,15 +415,40 @@ declare var VideoDecoder: {
isConfigSupported(config: VideoDecoderConfig): Promise<VideoDecoderSupport>;
};

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<void>;
reset(): void;
addEventListener<K extends keyof VideoEncoderEventMap>(
type: K,
listener: (this: VideoEncoder, ev: VideoEncoderEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;
removeEventListener<K extends keyof VideoEncoderEventMap>(
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: {
Expand Down

0 comments on commit ca02214

Please sign in to comment.