1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/* -*- 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
* https://w3c.github.io/webcodecs/#videoencoder
*
* 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
* https://w3c.github.io/webcodecs/codec_registry.html. Those members are
* 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
// https://w3c.github.io/webcodecs/avc_codec_registration.html
enum AvcBitstreamFormat {
"annexb",
"avc",
};
// AVC (H264)-specific
// https://w3c.github.io/webcodecs/avc_codec_registration.html
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
// https://w3c.github.io/webcodecs/avc_codec_registration.html
AvcEncoderConfig avc;
};
dictionary VideoEncoderEncodeOptions {
boolean keyFrame = false;
// AVC (H264)-specific
// https://w3c.github.io/webcodecs/avc_codec_registration.html
VideoEncoderEncodeOptionsForAvc avc;
};
// AVC (H264)-specific
// https://w3c.github.io/webcodecs/avc_codec_registration.html
dictionary VideoEncoderEncodeOptionsForAvc {
unsigned short? quantizer;
};
enum VideoEncoderBitrateMode {
"constant",
"variable",
// AVC (H264)-specific
// https://w3c.github.io/webcodecs/avc_codec_registration.html
"quantizer"
};
enum LatencyMode {
"quality",
"realtime"
};
dictionary VideoEncoderSupport {
boolean supported;
VideoEncoderConfig config;
};
dictionary EncodedVideoChunkMetadata {
VideoDecoderConfig decoderConfig;
SvcOutputMetadata svc;
// Not implemented https://bugzilla.mozilla.org/show_bug.cgi?id=1867067
// BufferSource alphaSideData;
};
dictionary SvcOutputMetadata {
unsigned long temporalLayerId;
};
|