Skip to content

Commit bff486f

Browse files
committed
Further style improvements and make sure to create pipeToController before using it
1 parent 79d96aa commit bff486f

File tree

1 file changed

+37
-35
lines changed

1 file changed

+37
-35
lines changed

index.bs

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ SFrameTransform includes GenericTransformStream;
134134
[Exposed=(Window)]
135135
interface RTCRtpScriptTransform {
136136
constructor(Worker worker, optional object options);
137+
// FIXME: add messaging methods.
137138
};
138139

139140
typedef (SFrameTransform or RTCRtpScriptTransform) RTCRtpTransform;
@@ -160,31 +161,31 @@ argument, ensure that the codec is disabled and produces no output.
160161
### Stream creation ### {#stream-creation}
161162

162163
At construction of each {{RTCRtpSender}} or {{RTCRtpReceiver}}, run the following steps:
163-
1. Initialize `[[Streams]]` to null.
164-
2. Initialize `[[transform]]` to null.
165-
3. Initialize `[[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.
166-
4. Set `[[readable]]`.`[[owner]]` to |this|.
167-
5. Initialize `[[writable]]` to the result of [=WritableStream/creating=] a {{WritableStream}}, its [=WritableStream/create/writeAlgorithm=] set to [=writeEncodedData=] given |this| as parameter.
168-
6. Set `[[writable]]`.`[[owner]]` to |this|.
169-
7. Initialize `[[pipeToController]]` to null.
170-
8. Initialize `[[lastReceivedFrameTimestamp]]` to zero.
164+
1. Initialize [=this=].`[[Streams]]` to null.
165+
2. Initialize [=this=].`[[transform]]` to null.
166+
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.
167+
4. Set [=this=].`[[readable]]`.`[[owner]]` to |this|.
168+
5. Initialize [=this=].`[[writable]]` to the result of [=WritableStream/creating=] a {{WritableStream}}, its [=WritableStream/create/writeAlgorithm=] set to [=writeEncodedData=] given |this| as parameter.
169+
6. Set [=this=].`[[writable]]`.`[[owner]]` to |this|.
170+
7. Initialize [=this=].`[[pipeToController]]` to null.
171+
8. Initialize [=this=].`[[lastReceivedFrameTimestamp]]` to zero.
171172
9. If the {{RTCPeerConnection}}'s configuration does not have {{RTCConfiguration/encodedInsertableStreams}} set to "true", queue a task to run the following steps:
172-
1. If `[[pipeToController]]` is not null, abort these steps.
173-
2. Call <a href="https://streams.spec.whatwg.org/#readable-stream-pipe-to">pipeTo</a> with `[[readable]]`, `[[writable]]`, preventClose equal to true, preventAbort equal to true, preventCancel equal to true and `[[pipeToController]]`.signal.
173+
1. If [=this=].`[[pipeToController]]` is not null, abort these steps.
174+
2. Set [=this=].`[[pipeToController]]` to a new {{AbortController}}.
175+
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.
174176

175177
When {{RTCRtpSender/createEncodedStreams}}() is
176178
called, run the following steps:
177179

178-
1. If the {{RTCPeerConnection}}'s configuration does not have {{RTCConfiguration/encodedInsertableStreams}} set to "true", throw an {{InvalidStateError}} and abort these steps.
180+
1. If the {{RTCPeerConnection}}'s configuration does not have {{RTCConfiguration/encodedInsertableStreams}} set to "true", throw an "{{InvalidAccessError}}" {{DOMException}} and abort these steps.
179181
2. If the data source does not permit access, throw an "{{InvalidAccessError}}" {{DOMException}} and abort these steps.
180-
3. If `[[Streams]]` is not null, throw an {{InvalidStateError}}.
181-
4. If `[[pipeToController]]` is not null, throw an {{InvalidStateError}}.
182-
5. Create an {{RTCInsertableStreams}} object |s|.
183-
6. Set |s|.{{RTCInsertableStreams/readable}} to `[[readable]]`.
184-
7. Set |s|.{{RTCInsertableStreams/writable}} to `[[writable]]`.
182+
3. If [=this=].`[[Streams]]` is not null, throw an "{{InvalidAccessError}}" {{DOMException}}.
183+
4. If [=this=].`[[pipeToController]]` is not null, throw an "{{InvalidAccessError}}" {{DOMException}}.
184+
5. Set [=this=].`[[Streams]]` to an {{RTCInsertableStreams}} object.
185+
6. Set [=this=].`[[Streams]]`.{{RTCInsertableStreams/readable}} to [=this=].`[[readable]]`.
186+
7. Set [=this=].`[[Streams]]`.{{RTCInsertableStreams/writable}} to [=this=].`[[writable]]`.
185187
8. Enable the encoded data source.
186-
9. Store |s| in the internal slot `[[Streams]]`.
187-
10. Return |s|
188+
10. Return [=this=].`[[Streams]]`.
188189

189190
### Stream processing ### {#stream-processing}
190191

@@ -213,20 +214,20 @@ On getting the transform attribute, the user agent MUST run the following steps:
213214
On setting the transform attribute, the user agent MUST run the following steps:
214215
1. Let |rtcObject| be the {{RTCRtpReceiver}} or {{RTCRtpSender}} on which the setter is invoked.
215216
2. Let |transform| be the argument to the setter.
216-
3. Let |checkedTransform| set to |transform| if it is not null or to an <a href="https://streams.spec.whatwg.org/#identity-transform-stream">identity transform</a> otherwise.
217-
3. Let |reader| be the result of <a href="https://streams.spec.whatwg.org/#readablestream-get-a-reader">getting a reader</a> for |checkedTransform|.`[[readable]]`.
218-
4. Let |writer| be the result of <a href="https://streams.spec.whatwg.org/#writablestream-get-a-writer">getting a writer</a> for |checkedTransform|.`[[writable]]`.
219-
5. Initialize |newPipeToController| to a new AbortController.
217+
3. Let |checkedTransform| set to |transform| if it is not null or to an [=identity transform stream=] otherwise.
218+
3. Let |reader| be the result of [=ReadableStream/getting a reader=] for |checkedTransform|.`[[readable]]`.
219+
4. Let |writer| be the result of [=WritableStream/getting a writer=] for |checkedTransform|.`[[writable]]`.
220+
5. Initialize |newPipeToController| to a new {{AbortController}}.
220221
6. If |rtcObject|.`[[pipeToController]]` is not null, run the following steps:
221-
1. <a href="https://dom.spec.whatwg.org/#abortsignal-add">Add</a> the [=chain transform algorithm=] to |rtcObject|.`[[pipeToController]]`:
222-
2. Call <a href="https://dom.spec.whatwg.org/#abortsignal-signal-abort">abort</a> on |rtcObject|.`[[pipeToController]]`.
222+
1. [=AbortSignal/Add=] the [=chain transform algorithm=] to |rtcObject|.`[[pipeToController]]`:
223+
2. [=AbortSignal/signal abort=] |rtcObject|.`[[pipeToController]]`.
223224
7. Else, run the [=chain transform algorithm=] steps.
224225
8. Set |rtcObject|.`[[pipeToController]]` to |newPipeToController|.
225226
9. Set |rtcObject|.`[[transform]]` to |transform|.
226227

227228
The <dfn>chain transform algorithm</dfn> steps are defined as:
228-
1. If |newPipeToController| <a href="https://dom.spec.whatwg.org/#abortsignal-aborted-flag">aborted flag</a> is true, abort these steps.
229-
2. Call <a href="https://streams.spec.whatwg.org/#readablestreamdefaultreader-release">release</a> with |reader|.
229+
1. If |newPipeToController|'s [=AbortSignal/aborted flag=] is true, abort these steps.
230+
2. [=ReadableStreamDefaultReader/Release=] |reader|.
230231
3. [=WritableStreamDefaultWriter/Release=] |writer|.
231232
4. Assert that |newPipeToController| is the same object as |rtcObject|.`[[pipeToController]]`.
232233
5. Call <a href="https://streams.spec.whatwg.org/#readable-stream-pipe-to">pipeTo</a> with |rtcObject|.`[[readable]]`, |checkedTransform|.`[[writable]]`, preventClose equal to false, preventAbort equal to false, preventCancel equal to true and |newPipeToController|.signal.
@@ -242,11 +243,11 @@ Similarly, if a web application sets the transform synchronously at creation of
242243

243244
The <dfn constructor for="SFrameTransform" lt="SFrameTransform(options)"><code>new SFrameTransform(<var>options</var>)</code></dfn> constructor steps are:
244245
1. Let |transformAlgorithm| be an algorithm which takes a |frame| as input and runs the <a href="#sframe-transform-algorithm">SFrame transform algorithm</a> with |this| and |frame|.
245-
2. Set |this|.<a href="https://streams.spec.whatwg.org/#generictransformstream-transform">`[[transform]]`</a> to the result of [=TransformStream/creating=] a {{TransformStream}}, with [=TransformStream/create/transformAlgorithm=] set to |transformAlgorithm|.
246+
2. Set |this|.`[[transform]]` to the result of [=TransformStream/creating=] a {{TransformStream}}, with [=TransformStream/create/transformAlgorithm=] set to |transformAlgorithm|.
246247
3. Let |options| be the method's first argument.
247248
4. Set |this|.`[[role]]` to |options|["{{SFrameTransportOptions/role}}"].
248-
5. Set |this|.`[[readable]]` to |this|.<a href="https://streams.spec.whatwg.org/#generictransformstream-transform">`[[transform]]`</a>.`[[readable]]`.
249-
6. Set |this|.`[[writable]]` to |this|.<a href="https://streams.spec.whatwg.org/#generictransformstream-transform">`[[transform]]`</a>.`[[writable]]`.
249+
5. Set |this|.`[[readable]]` to |this|.`[[transform]]`.`[[readable]]`.
250+
6. Set |this|.`[[writable]]` to |this|.`[[transform]]`.`[[writable]]`.
250251

251252
## SFrame transform algorithm ## {#sframe-transform-algorithm}
252253

@@ -263,16 +264,17 @@ The SFrame transform algorithm, given |sframe| as a SFrameTransform object and |
263264
10. If |frame| is an ArrayBuffer, set |frame| to |buffer|.
264265
11. If |frame| is an {{RTCEncodedAudioFrame}}, set |frame|.{{RTCEncodedAudioFrame/data}} to |buffer|.
265266
12. If |frame| is an {{RTCEncodedVideoFrame}}, set |frame|.{{RTCEncodedVideoFrame/data}} to |buffer|.
266-
13. <a href="https://streams.spec.whatwg.org/#transformstream-enqueue">Enqueue</a> |frame| in |sframe|.`[[transform]]`.
267+
13. [=ReadableStream/Enqueue=] |frame| in |sframe|.`[[transform]]`.
267268

268269
# RTCRtpScriptTransform # {#scriptTransform}
269270

270271
The <dfn constructor for="RTCRtpScriptTransform" lt="RTCRtpScriptTransform(worker, options)"><code>new RTCRtpScriptTransform(<var>worker</var>, <var>options</var>)</code></dfn> constructor steps are:
271-
1. Create two <a href="https://streams.spec.whatwg.org/#identity-transform-stream">identity transforms</a> named |t1| and |t2|.
272-
2. Set |this|.`[[writable]]` to |t1|.`[[writable]]`.
273-
3. Set |this|.`[[readable]]` to |t2|.`[[readable]]`.
274-
4. FIXME: transfer |t1|.`[[readable]]` and |t2|.`[[writable]]` to the dedicated worker.
275-
5. FIXME: Create counterpart of |this| in dedicated worker, for instance expose transfered |t1|.`[[readable]]` and |t2|.`[[writable]]`.
272+
1. Set |t1| to an [=identity transform stream=].
273+
2. Set |t2| to an [=identity transform stream=].
274+
3. Set |this|.`[[writable]]` to |t1|.`[[writable]]`.
275+
4. Set |this|.`[[readable]]` to |t2|.`[[readable]]`.
276+
5. FIXME: transfer |t1|.`[[readable]]` and |t2|.`[[writable]]` to the dedicated worker.
277+
6. FIXME: Create counterpart of |this| in dedicated worker, for instance expose transfered |t1|.`[[readable]]` and |t2|.`[[writable]]`.
276278

277279
# Privacy and security considerations # {#privacy}
278280

0 commit comments

Comments
 (0)