Source code

Revision control

Copy as Markdown

Other Tools

/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
*
* Some members of this API are codec-specific, in which case the source of the
* IDL are in the codec-specific registry entries, that are listed in
* commented with a link of the document in which the member is listed.
*/
[Exposed=(Window,DedicatedWorker), SecureContext, Pref="dom.media.webcodecs.enabled"]
interface VideoEncoder : EventTarget {
[Throws]
constructor(VideoEncoderInit init);
readonly attribute CodecState state;
readonly attribute unsigned long encodeQueueSize;
attribute EventHandler ondequeue;
[Throws]
undefined configure(VideoEncoderConfig config);
[Throws, BinaryName="VideoEncoder::EncodeVideoFrame"]
undefined encode(VideoFrame frame , optional VideoEncoderEncodeOptions options = {});
[Throws]
Promise<undefined> flush();
[Throws]
undefined reset();
[Throws]
undefined close();
[NewObject, Throws]
static Promise<VideoEncoderSupport> isConfigSupported(VideoEncoderConfig config);
};
dictionary VideoEncoderInit {
required EncodedVideoChunkOutputCallback output;
required WebCodecsErrorCallback error;
};
callback EncodedVideoChunkOutputCallback =
undefined (EncodedVideoChunk chunk,
optional EncodedVideoChunkMetadata metadata = {});
// AVC (H264)-specific
enum AvcBitstreamFormat {
"annexb",
"avc",
};
// AVC (H264)-specific
dictionary AvcEncoderConfig {
AvcBitstreamFormat format = "avc";
};
dictionary VideoEncoderConfig {
required DOMString codec;
required [EnforceRange] unsigned long width;
required [EnforceRange] unsigned long height;
[EnforceRange] unsigned long displayWidth;
[EnforceRange] unsigned long displayHeight;
[EnforceRange] unsigned long long bitrate;
double framerate;
HardwareAcceleration hardwareAcceleration = "no-preference";
AlphaOption alpha = "discard";
DOMString scalabilityMode;
VideoEncoderBitrateMode bitrateMode = "variable";
LatencyMode latencyMode = "quality";
DOMString contentHint;
// AVC (H264)-specific
AvcEncoderConfig avc;
};
dictionary VideoEncoderEncodeOptions {
boolean keyFrame = false;
// AVC (H264)-specific
VideoEncoderEncodeOptionsForAvc avc;
};
// AVC (H264)-specific
dictionary VideoEncoderEncodeOptionsForAvc {
unsigned short? quantizer;
};
enum VideoEncoderBitrateMode {
"constant",
"variable",
// AVC (H264)-specific
"quantizer"
};
enum LatencyMode {
"quality",
"realtime"
};
dictionary VideoEncoderSupport {
boolean supported;
VideoEncoderConfig config;
};
dictionary EncodedVideoChunkMetadata {
VideoDecoderConfig decoderConfig;
SvcOutputMetadata svc;
// BufferSource alphaSideData;
};
dictionary SvcOutputMetadata {
unsigned long temporalLayerId;
};