You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: index.bs
+99-75Lines changed: 99 additions & 75 deletions
Original file line number
Diff line number
Diff line change
@@ -62,69 +62,13 @@ an additional API on {{RTCRtpSender}} and {{RTCRtpReceiver}} to
62
62
insert the processing into the pipeline.
63
63
64
64
<pre class="idl">
65
-
// New dictionary.
66
-
dictionary RTCInsertableStreams {
67
-
ReadableStream readable;
68
-
WritableStream writable;
69
-
};
70
-
71
-
// New enum for video frame types. Will eventually re-use the equivalent defined
72
-
// by WebCodecs.
73
-
enum RTCEncodedVideoFrameType {
74
-
"empty",
75
-
"key",
76
-
"delta",
77
-
};
78
-
79
-
dictionary RTCEncodedVideoFrameMetadata {
80
-
long long frameId;
81
-
sequence<long long> dependencies;
82
-
unsigned short width;
83
-
unsigned short height;
84
-
long spatialIndex;
85
-
long temporalIndex;
86
-
long synchronizationSource;
87
-
sequence<long> contributingSources;
88
-
};
89
-
90
-
// New interfaces to define encoded video and audio frames. Will eventually
91
-
// re-use or extend the equivalent defined in WebCodecs.
92
-
[Exposed=Window]
93
-
interface RTCEncodedVideoFrame {
94
-
readonly attribute RTCEncodedVideoFrameType type;
95
-
readonly attribute unsigned long long timestamp;
96
-
attribute ArrayBuffer data;
97
-
RTCEncodedVideoFrameMetadata getMetadata();
98
-
};
99
-
100
-
dictionary RTCEncodedAudioFrameMetadata {
101
-
long synchronizationSource;
102
-
sequence<long> contributingSources;
103
-
};
104
-
105
-
[Exposed=Window]
106
-
interface RTCEncodedAudioFrame {
107
-
readonly attribute unsigned long long timestamp;
108
-
attribute ArrayBuffer data;
109
-
RTCEncodedAudioFrameMetadata getMetadata();
110
-
};
111
-
112
-
113
-
// New fields in RTCConfiguration
114
-
partial dictionary RTCConfiguration {
115
-
boolean encodedInsertableStreams = false;
116
-
};
117
-
118
65
typedef (SFrameTransform or RTCRtpScriptTransform) RTCRtpTransform;
119
66
120
-
// New methods for RTCRtpSender and RTCRtpReceiver
121
67
partial interface RTCRtpSender {
122
-
RTCInsertableStreams createEncodedStreams();
123
68
attribute RTCRtpTransform? transform;
124
69
};
125
70
126
71
partial interface RTCRtpReceiver {
127
-
RTCInsertableStreams createEncodedStreams();
128
72
attribute RTCRtpTransform? transform;
129
73
};
130
74
</pre>
@@ -139,39 +83,27 @@ argument, ensure that the codec is disabled and produces no output.
139
83
### Stream creation ### {#stream-creation}
140
84
141
85
At construction of each {{RTCRtpSender}} or {{RTCRtpReceiver}}, run the following steps:
142
-
1. Initialize [=this=].`[[Streams]]` to null.
143
86
2. Initialize [=this=].`[[transform]]` to null.
144
-
3. Initialize [=this=].`[[readable]]` to the result of <a dfn for="ReadableStream">creating</a> a {{ReadableStream}}. `[[readable]]` is provided frames using the [=readEncodedData=] algorithm given |this| as parameter.
87
+
3. Initialize [=this=].`[[readable]]` to the result of <a dfn for="ReadableStream">creating</a> a {{ReadableStream}}. [=this=].`[[readable]]` is provided frames using the [=readEncodedData=] algorithm given |this| as parameter.
145
88
4. Set [=this=].`[[readable]]`.`[[owner]]` to |this|.
146
89
5. Initialize [=this=].`[[writable]]` to the result of [=WritableStream/creating=] a {{WritableStream}}, its [=WritableStream/create/writeAlgorithm=] set to [=writeEncodedData=] given |this| as parameter.
147
90
6. Set [=this=].`[[writable]]`.`[[owner]]` to |this|.
148
91
7. Initialize [=this=].`[[pipeToController]]` to null.
149
92
8. Initialize [=this=].`[[lastReceivedFrameTimestamp]]` to zero.
150
-
9. If the {{RTCPeerConnection}}'s configuration does not have {{RTCConfiguration/encodedInsertableStreams}} set to "true", queue a task to run the following steps:
93
+
9. [=Queue a task=] to run the following steps:
151
94
1. If [=this=].`[[pipeToController]]` is not null, abort these steps.
152
95
2. Set [=this=].`[[pipeToController]]` to a new {{AbortController}}.
153
96
<!-- FIXME: Use pipeTo algorithm when available. -->
154
97
3. Call <a href="https://streams.spec.whatwg.org/#readable-stream-pipe-to">pipeTo</a> with [=this=].`[[readable]]`, [=this=].`[[writable]]`, preventClose equal to true, preventAbort equal to true, preventCancel equal to true and [=this=].`[[pipeToController]]`.signal.
155
98
156
-
The <dfn method for="RTCRtpSender">createEncodedStreams()</dfn> method steps are:
157
-
158
-
1. If the {{RTCPeerConnection}}'s configuration does not have {{RTCConfiguration/encodedInsertableStreams}} set to "true", throw an "{{InvalidAccessError}}" {{DOMException}} and abort these steps.
159
-
2. If the data source does not permit access, throw an "{{InvalidAccessError}}" {{DOMException}} and abort these steps.
160
-
3. If [=this=].`[[Streams]]` is not null, throw an "{{InvalidAccessError}}" {{DOMException}}.
161
-
4. If [=this=].`[[pipeToController]]` is not null, throw an "{{InvalidAccessError}}" {{DOMException}}.
162
-
5. Set [=this=].`[[Streams]]` to an {{RTCInsertableStreams}} object.
163
-
6. Set [=this=].`[[Streams]]`.{{RTCInsertableStreams/readable}} to [=this=].`[[readable]]`.
164
-
7. Set [=this=].`[[Streams]]`.{{RTCInsertableStreams/writable}} to [=this=].`[[writable]]`.
165
-
8. Enable the encoded data source.
166
-
10. Return [=this=].`[[Streams]]`.
167
99
168
100
### Stream processing ### {#stream-processing}
169
101
170
102
The <dfn>readEncodedData</dfn> algorithm is given a |rtcObject| as parameter. It is defined by running the following steps:
171
103
1. Wait for a frame to be produced by |rtcObject|'s encoder if it is a {{RTCRtpSender}} or |rtcObject|'s packetizer if it is a {{RTCRtpReceiver}}.
172
104
2. Let |frame| be the newly produced frame.
173
105
3. Set |frame|.`[[owner]]` to |rtcObject|.
174
-
4. [=ReadableStream/enqueue=] |frame| in |rtcObject|.`[[readable]]`.
106
+
4. [=ReadableStream/Enqueue=] |frame| in |rtcObject|.`[[readable]]`.
175
107
176
108
The <dfn>writeEncodedData</dfn> algorithm is given a |rtcObject| as parameter and a |frame| as input. It is defined by running the following steps:
177
109
1. If |frame|.`[[owner]]` is not equal to |rtcObject|, abort these steps and return [=a promise resolved with=] undefined. A processor cannot create frames, or move frames between streams.
@@ -245,7 +177,7 @@ The <dfn constructor for="SFrameTransform" lt="SFrameTransform(options)"><code>n
245
177
5. Set |this|.`[[readable]]` to |this|.`[[transform]]`.`[[readable]]`.
246
178
6. Set |this|.`[[writable]]` to |this|.`[[transform]]`.`[[writable]]`.
3. Set |this|.`[[writable]]` to |t1|.`[[writable]]`.
289
284
4. Set |this|.`[[readable]]` to |t2|.`[[readable]]`.
290
-
5. FIXME: transfer |t1|.`[[readable]]` and |t2|.`[[writable]]` to the dedicated worker.
291
-
6. FIXME: Create counterpart of |this| in dedicated worker, for instance expose transfered |t1|.`[[readable]]` and |t2|.`[[writable]]`.
285
+
5. Let |serializedOptions| be the result of [$StructuredSerialize$](|object|).
286
+
6. Let |serializedReadable| be the result of [$StructuredSerializeWithTransfer$](|t1|.`[[readable]]`, « |t1|.`[[readable]]` »).
287
+
7. Let |serializedWritable| be the result of [$StructuredSerializeWithTransfer$](|t2|.`[[writable]]`, « |t2|.`[[writable]]` »).
288
+
8. [=Queue a task=] on the DOM manipulation [=task source=] |worker|'s global scope to run the following steps:
289
+
1. Let |transformerOptions| be the result of [$StructuredDeserialize$](|serializedOptions|, the current Realm).
290
+
2. Let |readable| be the result of [$StructuredDeserialize$](|serializedReadable|, the current Realm).
291
+
3. Let |writable| be the result of [$StructuredDeserialize$](|serializedWritable|, the current Realm).
292
+
4. Let |transformer| be a new {{RTCRtpScriptTransformer}}.
293
+
5. Set |transformer|.`[[options]]` to |transformerOptions|.
294
+
6. Set |transformer|.`[[readable]]` to |readable|.
295
+
7. Set |transformer|.`[[writable]]` to |writable|.
296
+
8. Let |event| be the result of [=creating an event=] with {{RTCTransformEvent}}.
297
+
9. Set |event|.type attribute to "rtctransform".
298
+
10. Set |event|.transformer to |transformer|.
299
+
11. Dispatch |event| on |worker|’s global scope.
300
+
301
+
// FIXME: Describe error handling (worker closing flag true at RTCRtpScriptTransform creation time. And worker being terminated while transform is processing data).
0 commit comments