webcodecs.idl (14607B)
1 // GENERATED CONTENT - DO NOT EDIT 2 // Content was automatically extracted by Reffy into webref 3 // (https://github.com/w3c/webref) 4 // Source: WebCodecs (https://w3c.github.io/webcodecs/) 5 6 [Exposed=(Window,DedicatedWorker), SecureContext] 7 interface AudioDecoder : EventTarget { 8 constructor(AudioDecoderInit init); 9 10 readonly attribute CodecState state; 11 readonly attribute unsigned long decodeQueueSize; 12 attribute EventHandler ondequeue; 13 14 undefined configure(AudioDecoderConfig config); 15 undefined decode(EncodedAudioChunk chunk); 16 Promise<undefined> flush(); 17 undefined reset(); 18 undefined close(); 19 20 static Promise<AudioDecoderSupport> isConfigSupported(AudioDecoderConfig config); 21 }; 22 23 dictionary AudioDecoderInit { 24 required AudioDataOutputCallback output; 25 required WebCodecsErrorCallback error; 26 }; 27 28 callback AudioDataOutputCallback = undefined(AudioData output); 29 30 [Exposed=(Window,DedicatedWorker), SecureContext] 31 interface VideoDecoder : EventTarget { 32 constructor(VideoDecoderInit init); 33 34 readonly attribute CodecState state; 35 readonly attribute unsigned long decodeQueueSize; 36 attribute EventHandler ondequeue; 37 38 undefined configure(VideoDecoderConfig config); 39 undefined decode(EncodedVideoChunk chunk); 40 Promise<undefined> flush(); 41 undefined reset(); 42 undefined close(); 43 44 static Promise<VideoDecoderSupport> isConfigSupported(VideoDecoderConfig config); 45 }; 46 47 dictionary VideoDecoderInit { 48 required VideoFrameOutputCallback output; 49 required WebCodecsErrorCallback error; 50 }; 51 52 callback VideoFrameOutputCallback = undefined(VideoFrame output); 53 54 [Exposed=(Window,DedicatedWorker), SecureContext] 55 interface AudioEncoder : EventTarget { 56 constructor(AudioEncoderInit init); 57 58 readonly attribute CodecState state; 59 readonly attribute unsigned long encodeQueueSize; 60 attribute EventHandler ondequeue; 61 62 undefined configure(AudioEncoderConfig config); 63 undefined encode(AudioData data); 64 Promise<undefined> flush(); 65 undefined reset(); 66 undefined close(); 67 68 static Promise<AudioEncoderSupport> isConfigSupported(AudioEncoderConfig config); 69 }; 70 71 dictionary AudioEncoderInit { 72 required EncodedAudioChunkOutputCallback output; 73 required WebCodecsErrorCallback error; 74 }; 75 76 callback EncodedAudioChunkOutputCallback = 77 undefined (EncodedAudioChunk output, 78 optional EncodedAudioChunkMetadata metadata = {}); 79 80 dictionary EncodedAudioChunkMetadata { 81 AudioDecoderConfig decoderConfig; 82 }; 83 84 [Exposed=(Window,DedicatedWorker), SecureContext] 85 interface VideoEncoder : EventTarget { 86 constructor(VideoEncoderInit init); 87 88 readonly attribute CodecState state; 89 readonly attribute unsigned long encodeQueueSize; 90 attribute EventHandler ondequeue; 91 92 undefined configure(VideoEncoderConfig config); 93 undefined encode(VideoFrame frame, optional VideoEncoderEncodeOptions options = {}); 94 Promise<undefined> flush(); 95 undefined reset(); 96 undefined close(); 97 98 static Promise<VideoEncoderSupport> isConfigSupported(VideoEncoderConfig config); 99 }; 100 101 dictionary VideoEncoderInit { 102 required EncodedVideoChunkOutputCallback output; 103 required WebCodecsErrorCallback error; 104 }; 105 106 callback EncodedVideoChunkOutputCallback = 107 undefined (EncodedVideoChunk chunk, 108 optional EncodedVideoChunkMetadata metadata = {}); 109 110 dictionary EncodedVideoChunkMetadata { 111 VideoDecoderConfig decoderConfig; 112 SvcOutputMetadata svc; 113 BufferSource alphaSideData; 114 }; 115 116 dictionary SvcOutputMetadata { 117 unsigned long temporalLayerId; 118 }; 119 120 dictionary AudioDecoderSupport { 121 boolean supported; 122 AudioDecoderConfig config; 123 }; 124 125 dictionary VideoDecoderSupport { 126 boolean supported; 127 VideoDecoderConfig config; 128 }; 129 130 dictionary AudioEncoderSupport { 131 boolean supported; 132 AudioEncoderConfig config; 133 }; 134 135 dictionary VideoEncoderSupport { 136 boolean supported; 137 VideoEncoderConfig config; 138 }; 139 140 dictionary AudioDecoderConfig { 141 required DOMString codec; 142 [EnforceRange] required unsigned long sampleRate; 143 [EnforceRange] required unsigned long numberOfChannels; 144 AllowSharedBufferSource description; 145 }; 146 147 dictionary VideoDecoderConfig { 148 required DOMString codec; 149 AllowSharedBufferSource description; 150 [EnforceRange] unsigned long codedWidth; 151 [EnforceRange] unsigned long codedHeight; 152 [EnforceRange] unsigned long displayAspectWidth; 153 [EnforceRange] unsigned long displayAspectHeight; 154 VideoColorSpaceInit colorSpace; 155 HardwareAcceleration hardwareAcceleration = "no-preference"; 156 boolean optimizeForLatency; 157 double rotation = 0; 158 boolean flip = false; 159 }; 160 161 dictionary AudioEncoderConfig { 162 required DOMString codec; 163 [EnforceRange] required unsigned long sampleRate; 164 [EnforceRange] required unsigned long numberOfChannels; 165 [EnforceRange] unsigned long long bitrate; 166 BitrateMode bitrateMode = "variable"; 167 }; 168 169 dictionary VideoEncoderConfig { 170 required DOMString codec; 171 [EnforceRange] required unsigned long width; 172 [EnforceRange] required unsigned long height; 173 [EnforceRange] unsigned long displayWidth; 174 [EnforceRange] unsigned long displayHeight; 175 [EnforceRange] unsigned long long bitrate; 176 double framerate; 177 HardwareAcceleration hardwareAcceleration = "no-preference"; 178 AlphaOption alpha = "discard"; 179 DOMString scalabilityMode; 180 VideoEncoderBitrateMode bitrateMode = "variable"; 181 LatencyMode latencyMode = "quality"; 182 DOMString contentHint; 183 }; 184 185 enum HardwareAcceleration { 186 "no-preference", 187 "prefer-hardware", 188 "prefer-software", 189 }; 190 191 enum AlphaOption { 192 "keep", 193 "discard", 194 }; 195 196 enum LatencyMode { 197 "quality", 198 "realtime" 199 }; 200 201 dictionary VideoEncoderEncodeOptions { 202 boolean keyFrame = false; 203 }; 204 205 enum VideoEncoderBitrateMode { 206 "constant", 207 "variable", 208 "quantizer" 209 }; 210 211 enum CodecState { 212 "unconfigured", 213 "configured", 214 "closed" 215 }; 216 217 callback WebCodecsErrorCallback = undefined(DOMException error); 218 219 [Exposed=(Window,DedicatedWorker), Serializable] 220 interface EncodedAudioChunk { 221 constructor(EncodedAudioChunkInit init); 222 readonly attribute EncodedAudioChunkType type; 223 readonly attribute long long timestamp; // microseconds 224 readonly attribute unsigned long long? duration; // microseconds 225 readonly attribute unsigned long byteLength; 226 227 undefined copyTo(AllowSharedBufferSource destination); 228 }; 229 230 dictionary EncodedAudioChunkInit { 231 required EncodedAudioChunkType type; 232 [EnforceRange] required long long timestamp; // microseconds 233 [EnforceRange] unsigned long long duration; // microseconds 234 required AllowSharedBufferSource data; 235 sequence<ArrayBuffer> transfer = []; 236 }; 237 238 enum EncodedAudioChunkType { 239 "key", 240 "delta", 241 }; 242 243 [Exposed=(Window,DedicatedWorker), Serializable] 244 interface EncodedVideoChunk { 245 constructor(EncodedVideoChunkInit init); 246 readonly attribute EncodedVideoChunkType type; 247 readonly attribute long long timestamp; // microseconds 248 readonly attribute unsigned long long? duration; // microseconds 249 readonly attribute unsigned long byteLength; 250 251 undefined copyTo(AllowSharedBufferSource destination); 252 }; 253 254 dictionary EncodedVideoChunkInit { 255 required EncodedVideoChunkType type; 256 [EnforceRange] required long long timestamp; // microseconds 257 [EnforceRange] unsigned long long duration; // microseconds 258 required AllowSharedBufferSource data; 259 sequence<ArrayBuffer> transfer = []; 260 }; 261 262 enum EncodedVideoChunkType { 263 "key", 264 "delta", 265 }; 266 267 [Exposed=(Window,DedicatedWorker), Serializable, Transferable] 268 interface AudioData { 269 constructor(AudioDataInit init); 270 271 readonly attribute AudioSampleFormat? format; 272 readonly attribute float sampleRate; 273 readonly attribute unsigned long numberOfFrames; 274 readonly attribute unsigned long numberOfChannels; 275 readonly attribute unsigned long long duration; // microseconds 276 readonly attribute long long timestamp; // microseconds 277 278 unsigned long allocationSize(AudioDataCopyToOptions options); 279 undefined copyTo(AllowSharedBufferSource destination, AudioDataCopyToOptions options); 280 AudioData clone(); 281 undefined close(); 282 }; 283 284 dictionary AudioDataInit { 285 required AudioSampleFormat format; 286 required float sampleRate; 287 [EnforceRange] required unsigned long numberOfFrames; 288 [EnforceRange] required unsigned long numberOfChannels; 289 [EnforceRange] required long long timestamp; // microseconds 290 required BufferSource data; 291 sequence<ArrayBuffer> transfer = []; 292 }; 293 294 dictionary AudioDataCopyToOptions { 295 [EnforceRange] required unsigned long planeIndex; 296 [EnforceRange] unsigned long frameOffset = 0; 297 [EnforceRange] unsigned long frameCount; 298 AudioSampleFormat format; 299 }; 300 301 enum AudioSampleFormat { 302 "u8", 303 "s16", 304 "s32", 305 "f32", 306 "u8-planar", 307 "s16-planar", 308 "s32-planar", 309 "f32-planar", 310 }; 311 312 [Exposed=(Window,DedicatedWorker), Serializable, Transferable] 313 interface VideoFrame { 314 constructor(CanvasImageSource image, optional VideoFrameInit init = {}); 315 constructor(AllowSharedBufferSource data, VideoFrameBufferInit init); 316 317 readonly attribute VideoPixelFormat? format; 318 readonly attribute unsigned long codedWidth; 319 readonly attribute unsigned long codedHeight; 320 readonly attribute DOMRectReadOnly? codedRect; 321 readonly attribute DOMRectReadOnly? visibleRect; 322 readonly attribute double rotation; 323 readonly attribute boolean flip; 324 readonly attribute unsigned long displayWidth; 325 readonly attribute unsigned long displayHeight; 326 readonly attribute unsigned long long? duration; // microseconds 327 readonly attribute long long timestamp; // microseconds 328 readonly attribute VideoColorSpace colorSpace; 329 330 VideoFrameMetadata metadata(); 331 332 unsigned long allocationSize( 333 optional VideoFrameCopyToOptions options = {}); 334 Promise<sequence<PlaneLayout>> copyTo( 335 AllowSharedBufferSource destination, 336 optional VideoFrameCopyToOptions options = {}); 337 VideoFrame clone(); 338 undefined close(); 339 }; 340 341 dictionary VideoFrameInit { 342 unsigned long long duration; // microseconds 343 long long timestamp; // microseconds 344 AlphaOption alpha = "keep"; 345 346 // Default matches image. May be used to efficiently crop. Will trigger 347 // new computation of displayWidth and displayHeight using image's pixel 348 // aspect ratio unless an explicit displayWidth and displayHeight are given. 349 DOMRectInit visibleRect; 350 351 double rotation = 0; 352 boolean flip = false; 353 354 // Default matches image unless visibleRect is provided. 355 [EnforceRange] unsigned long displayWidth; 356 [EnforceRange] unsigned long displayHeight; 357 358 VideoFrameMetadata metadata; 359 }; 360 361 dictionary VideoFrameBufferInit { 362 required VideoPixelFormat format; 363 required [EnforceRange] unsigned long codedWidth; 364 required [EnforceRange] unsigned long codedHeight; 365 required [EnforceRange] long long timestamp; // microseconds 366 [EnforceRange] unsigned long long duration; // microseconds 367 368 // Default layout is tightly-packed. 369 sequence<PlaneLayout> layout; 370 371 // Default visible rect is coded size positioned at (0,0) 372 DOMRectInit visibleRect; 373 374 double rotation = 0; 375 boolean flip = false; 376 377 // Default display dimensions match visibleRect. 378 [EnforceRange] unsigned long displayWidth; 379 [EnforceRange] unsigned long displayHeight; 380 381 VideoColorSpaceInit colorSpace; 382 383 sequence<ArrayBuffer> transfer = []; 384 385 VideoFrameMetadata metadata; 386 }; 387 388 dictionary VideoFrameMetadata { 389 // Possible members are recorded in the VideoFrame Metadata Registry. 390 }; 391 392 dictionary VideoFrameCopyToOptions { 393 DOMRectInit rect; 394 sequence<PlaneLayout> layout; 395 VideoPixelFormat format; 396 PredefinedColorSpace colorSpace; 397 }; 398 399 dictionary PlaneLayout { 400 [EnforceRange] required unsigned long offset; 401 [EnforceRange] required unsigned long stride; 402 }; 403 404 enum VideoPixelFormat { 405 // 4:2:0 Y, U, V 406 "I420", 407 "I420P10", 408 "I420P12", 409 // 4:2:0 Y, U, V, A 410 "I420A", 411 "I420AP10", 412 "I420AP12", 413 // 4:2:2 Y, U, V 414 "I422", 415 "I422P10", 416 "I422P12", 417 // 4:2:2 Y, U, V, A 418 "I422A", 419 "I422AP10", 420 "I422AP12", 421 // 4:4:4 Y, U, V 422 "I444", 423 "I444P10", 424 "I444P12", 425 // 4:4:4 Y, U, V, A 426 "I444A", 427 "I444AP10", 428 "I444AP12", 429 // 4:2:0 Y, UV 430 "NV12", 431 // 4:4:4 RGBA 432 "RGBA", 433 // 4:4:4 RGBX (opaque) 434 "RGBX", 435 // 4:4:4 BGRA 436 "BGRA", 437 // 4:4:4 BGRX (opaque) 438 "BGRX", 439 }; 440 441 [Exposed=(Window,DedicatedWorker)] 442 interface VideoColorSpace { 443 constructor(optional VideoColorSpaceInit init = {}); 444 445 readonly attribute VideoColorPrimaries? primaries; 446 readonly attribute VideoTransferCharacteristics? transfer; 447 readonly attribute VideoMatrixCoefficients? matrix; 448 readonly attribute boolean? fullRange; 449 450 [Default] VideoColorSpaceInit toJSON(); 451 }; 452 453 dictionary VideoColorSpaceInit { 454 VideoColorPrimaries? primaries = null; 455 VideoTransferCharacteristics? transfer = null; 456 VideoMatrixCoefficients? matrix = null; 457 boolean? fullRange = null; 458 }; 459 460 enum VideoColorPrimaries { 461 "bt709", 462 "bt470bg", 463 "smpte170m", 464 "bt2020", 465 "smpte432", 466 }; 467 468 enum VideoTransferCharacteristics { 469 "bt709", 470 "smpte170m", 471 "iec61966-2-1", 472 "linear", 473 "pq", 474 "hlg", 475 }; 476 477 enum VideoMatrixCoefficients { 478 "rgb", 479 "bt709", 480 "bt470bg", 481 "smpte170m", 482 "bt2020-ncl", 483 }; 484 485 [Exposed=(Window,DedicatedWorker), SecureContext] 486 interface ImageDecoder { 487 constructor(ImageDecoderInit init); 488 489 readonly attribute DOMString type; 490 readonly attribute boolean complete; 491 readonly attribute Promise<undefined> completed; 492 readonly attribute ImageTrackList tracks; 493 494 Promise<ImageDecodeResult> decode(optional ImageDecodeOptions options = {}); 495 undefined reset(); 496 undefined close(); 497 498 static Promise<boolean> isTypeSupported(DOMString type); 499 }; 500 501 typedef (AllowSharedBufferSource or ReadableStream) ImageBufferSource; 502 dictionary ImageDecoderInit { 503 required DOMString type; 504 required ImageBufferSource data; 505 ColorSpaceConversion colorSpaceConversion = "default"; 506 [EnforceRange] unsigned long desiredWidth; 507 [EnforceRange] unsigned long desiredHeight; 508 boolean preferAnimation; 509 sequence<ArrayBuffer> transfer = []; 510 }; 511 512 dictionary ImageDecodeOptions { 513 [EnforceRange] unsigned long frameIndex = 0; 514 boolean completeFramesOnly = true; 515 }; 516 517 dictionary ImageDecodeResult { 518 required VideoFrame image; 519 required boolean complete; 520 }; 521 522 [Exposed=(Window,DedicatedWorker), SecureContext] 523 interface ImageTrackList { 524 getter ImageTrack (unsigned long index); 525 526 readonly attribute Promise<undefined> ready; 527 readonly attribute unsigned long length; 528 readonly attribute long selectedIndex; 529 readonly attribute ImageTrack? selectedTrack; 530 }; 531 532 [Exposed=(Window,DedicatedWorker), SecureContext] 533 interface ImageTrack { 534 readonly attribute boolean animated; 535 readonly attribute unsigned long frameCount; 536 readonly attribute unrestricted float repetitionCount; 537 attribute boolean selected; 538 };