Skip to content

Commit e095dc2

Browse files
authored
🤖 Merge PR DefinitelyTyped#73966 dom-webcodecs: Add rotation and flip field to VideoDecoderConfig and VideoFrame by @AbacusIsMad
1 parent dfb5030 commit e095dc2

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

‎types/dom-webcodecs/test/dom-webcodecs-tests.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,12 @@ const videoDecoderConfig: VideoDecoderConfig = {
363363
codec: "avc1.64000c",
364364
};
365365

366+
const videoDecoderConfigWithRotationAndFlip: VideoDecoderConfig = {
367+
codec: "avc1.64000c",
368+
rotation: 180,
369+
flip: false,
370+
};
371+
366372
// @ts-expect-error
367373
VideoDecoder.isConfigSupported();
368374

@@ -376,6 +382,13 @@ VideoDecoder.isConfigSupported(videoDecoderConfig).then((result: VideoDecoderSup
376382
result.config;
377383
});
378384

385+
VideoDecoder.isConfigSupported(videoDecoderConfigWithRotationAndFlip).then((result: VideoDecoderSupport) => {
386+
// $ExpectType boolean | undefined
387+
result.supported;
388+
// $ExpectType VideoDecoderConfig | undefined
389+
result.config;
390+
});
391+
379392
function videoOutput(output: VideoFrame): void {
380393
// $ExpectType number | undefined
381394
output.visibleRect?.width;
@@ -418,6 +431,9 @@ videoDecoder.configure({ description: new Uint8Array(0) });
418431
// $ExpectType void
419432
videoDecoder.configure(videoDecoderConfig);
420433

434+
// $ExpectType void
435+
videoDecoder.configure(videoDecoderConfigWithRotationAndFlip);
436+
421437
// additional properties are allowed
422438
const futureVideoDecoderConfig = {
423439
codec: "avc1.64000c",
@@ -593,6 +609,10 @@ videoFrame.visibleRect?.height;
593609
videoFrame.displayWidth;
594610
// $ExpectType number
595611
videoFrame.displayHeight;
612+
// $ExpectType number | undefined
613+
videoFrame.rotation;
614+
// $ExpectType boolean | undefined
615+
videoFrame.flip;
596616

597617
// @ts-expect-error
598618
new VideoFrame(new ArrayBuffer(1024), {

‎types/dom-webcodecs/webcodecs.generated.d.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ interface VideoDecoderConfig {
121121
displayAspectWidth?: number | undefined;
122122
hardwareAcceleration?: HardwarePreference | undefined;
123123
optimizeForLatency?: boolean | undefined;
124+
rotation?: number | undefined;
125+
flip?: boolean | undefined;
124126
}
125127

126128
interface VideoDecoderInit {
@@ -427,6 +429,7 @@ interface VideoFrame {
427429
readonly timestamp: number;
428430
readonly visibleRect: DOMRectReadOnly | null;
429431
readonly rotation?: number;
432+
readonly flip?: boolean;
430433
allocationSize(options?: VideoFrameCopyToOptions): number;
431434
clone(): VideoFrame;
432435
close(): void;

0 commit comments

Comments
 (0)