forked from w3c/webcodecs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebidl.txt
215 lines (172 loc) · 6.24 KB
/
webidl.txt
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
// WARNING: This is just some ideas of how it could look. Don't take it too seriously yet.
// TODO(when writing spec):
// - Specify that encoding and decoding must happen off the main thread.
[Constructor(MediaStreamTrack track)]
interface AudioTrackReader {
readonly attribute ReadableStream readable; // of DecodedAudioPacket
}
interface DecodedAudioPacket {
readonly attribute MediaTime timestamp;
// Sample count == duration.value
// Sample rate == duration.scale
readonly attribute MediaTime duration;
readonly attribute unsigned long channelCount
}
[Constructor(AudioEncoderParams params)]
interface AudioEncoder {
void setParameters(AudioEncoderParams params);
readonly attribute WritableStream writable; // DecodedAudioPacket
readonly attribute ReadableStream readable; // EncodedAudioPacket
}
dictionary AudioEncoderParams {
DOMString mimeType;
// not supported by all codecs
// null/unset means use the codec default
unsigned long? bitsPerSecond;
// codec-specific
// null/unset means use the codec default
unsigned long? complexity;
// probably opus-specific
bool fec = false; // enabled or not
bool dtx = false; // enabled or not
bool cbr = false; // cbr or not (vbr if not)
bool speechMode = false; // speech-specific mode or not
}
[Constructor(BufferSource data, MediaTime timestamp)]
interface EncodedAudioPacket {
readonly attribute MediaTime timestamp;
readonly attribute Uint8Array data;
}
[Constructor(AudioDecoderParams params)]
interface AudioDecoder {
readonly attribute WritableStream writable; // EncodedAudioPacket
readonly attribute ReadableStream readable; // DecodedAudioPacket
attribute EventHandler onerror;
}
dictionary AudioDecoderParams {
DOMString codec; // For example, "opus"
// Defaults are codec-specific
unsigned long? sampleRate;
unsigned long? channelCount;
// Optional byte data required to initialize audio decoders
// such as Vorbis codebooks.
BufferSource? extraData;
// Duration decoder must decode before the decoded data is valid
MediaTime? seekPreRoll;
// Duration decoder should discard before returning decoded data.
// Can include both decoder delay as well as padding added during
// encoding.
MediaTime? codecDelay;
}
[Constructor()]
interface AudioTrackWriter {
readonly attribute WritableStream writable; // of DecodedAudioPacket
readonly attribute MediaStreamTrack track;
}
[Constructor(MediaStreamTrack track)]
interface VideoTrackReader {
readonly attribute ReadableStream readable; // of DecodedVideoFrame
}
interface DecodedVideoFrame {
readonly attribute MediaTime timestamp;
readonly attribute ImageData imageData;
}
[Constructor(VideoEncoderParams params)]
interface VideoEncoder {
void setParameters(VideoEncoderParams params);
void generateKeyFrame(optional sequence<DOMString> layerIds);
readonly attribute WritableStream writable; // DecodedVideoFrame
readonly attribute ReadableStream readable; // EncodedVideoFrame
attribute EventHandler onerror;
}
dictionary VideoEncoderParams {
// Cannot be changed once set
DOMString mimeType;
// Can be used to initialize the encoder faster
// than waiting for the first frame
unsigned long? expectedWidth;
unsigned long? expectedHeight;
// unset/null means the encoder will pick
// target will be exceeded for key frames
unsigned long bitsPerSecond;
VideoEncodeContentMode contentMode;
sequence<VideoEncodeLayer> layers;
}
enum VideoEncodeContentMode {
"screen" // For screen sharing/recording
"default" // Everything else
}
dictionary VideoEncodeLayer {
// Referenced in .dependsOn and EncodedVideoFrame.encoded.layerId
DOMString id;
// Identifies the temporal slots this layer applies to
// For example, with two temporal layers, typically one
// Layer will have [0] and one [1].
// But in more complex patterns with 4 temporal slots
// One layer might fit in [0], another [2], and another [1, 3]
sequence<unsigned long> temporalSlots;
// The layer IDs of the layers this layer depends on.
// Note that you likely want a layer to depend on itself
// Otherwise, a base layer would be all key frames.
sequence<DOMString> dependsOn;
// How much to scale down resolution before encoding
double scaleDownBy;
// If unset, the codec will guess how much you want
// (Diving up the total bitrate between the layers based on size
// and framerate)
unsigned long? bitsPerSecond;
}
[Constructor(BufferSource data, MediaTime timestamp)]
interface EncodedVideoFrame {
readonly attribute Uint8Array data;
readonly attribute MediaTime timestamp;
// Info provided as a result from the encoder
// Not needed as input to a decoder
readonly attribute VideoEncodeResult? encoded;
}
interface VideoEncodeResult {
// If using multiple layers, which layer is it?
readonly attribute DOMString? layerId;
// Whether or not it's a key frame meaning it depends on
// no other frames
readonly attribute bool keyFrame;
}
[Constructor(VideoDecoderParams params)]
interface VideoDecoder {
readonly attribute WritableStream writable; // EncodedVideoFrame
readonly attribute ReadableStream readable; // DecodedVideoFrame
attribute EventHandler onerror;
}
dictionary VideoDecoderParams {
DOMString mimeType;
// Can be used to initialize the decoder faster
// than waiting for the first frame
unsigned long long? expectedWidth;
unsigned long long? expectedHeight;
// Optional byte data required to initialize video decoders
// such as H264 with SPS and PPS.
BufferSource? extraData;
}
[Constructor()]
interface VideoTrackWriter {
readonly attribute WritableStream writable; // of DecodedVideoFrame
readonly attribute MediaStreamTrack track;
}
[Constructor(unsigned long long value, unsigned long long scale)]
interface MediaTime {
readonly attribute unsigned long long value;
readonly attribute unsigned long long scale;
}
interface ImageEncoder {
Promise<EncodedImageData> encode(ImageData imageData);
}
interface ImageDecoder {
Promise<ImageData> decode(EncodedImageData or ReadableStream);
}
[Constructor(ReadableStream readable)]
interface EncodedImageData {
readonly attribute ReadableStream readable; // of bytes
}
partial interface ImageData {
readonly attribute ReadableStream readable; // of bytes
}