Skip to content

Commit a991ba0

Browse files
committed
Address the common algorithms (transform setter, RTCRtpTransform)
1 parent 48b9e6c commit a991ba0

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed

index.bs

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,39 @@ partial interface RTCRtpReceiver {
9393
};
9494
</pre>
9595

96-
This allows manipulation of encoded frames in the media pipeline
97-
between the processing steps of an {{RTCRtpSender}}'s underlying
98-
<dfn>encoder</dfn> and <dfn>packetizer</dfn>, and/or
96+
This allows manipulation of <dfn>encoded frames</dfn> in the media
97+
pipeline between the processing steps of an {{RTCRtpSender}}'s
98+
underlying <dfn>encoder</dfn> and <dfn>packetizer</dfn>, and/or
9999
between an {{RTCRtpReceiver}}'s underlying <dfn>depacketizer</dfn>
100100
and <dfn>decoder</dfn>.
101101

102-
## Extension operation ## {#operation}
102+
The [=encoder=] and [=depacketizer=] each have a
103+
<dfn>[[transformFrameAlgorithm]]</dfn> internal slot initialized to
104+
the <dfn>passthrough algorithm</dfn> which, given an [=encoded frame=]
105+
|frame|, is to return |frame|.
106+
107+
Whenever the [=encoder=] outputs a [=encoded frame|frame=], the user
108+
agent MUST invoke the [=encoder=].[=[[transformFrameAlgorithm]]=] with
109+
it and pass the result to the associated [=packetizer=] in place of
110+
the original frame.
103111

104-
At the time when a codec is initialized as part of the encoder, and the
105-
corresponding flag is set in the {{RTCPeerConnection}}'s {{RTCConfiguration}}
106-
argument, ensure that the codec is disabled and produces no output.
112+
Whenever the [=depacketizer=] outputs a [=encoded frame|frame=], the
113+
user agent MUST invoke the [=depacketizer=].[=[[transformFrameAlgorithm]]=]
114+
with it and pass the result to the associated [=decoder=] in place of
115+
the original frame.
116+
117+
## Extension operation ## {#operation}
107118

108119
At construction of each {{RTCRtpSender}} or {{RTCRtpReceiver}}, run the following steps:
109120
1. Initialize [=this=].`[[transform]]` to null.
110121
1. Initialize [=this=].`[[pipeToController]]` to null.
122+
1. Initialize [=this=].`[[frameSource]]` to [=this=]'s [=encoder=] if [=this=] is an {{RTCRtpSender}} or [=this=]'s [=depacketizer=] otherwise.
111123
1. [=Queue a task=] to run the following steps:
112124
1. If [=this=].`[[pipeToController]]` is not null, abort these steps.
113-
2. Set [=this=].`[[pipeToController]]` to a new {{AbortController}}.
114-
<!-- FIXME: Fix aborting. -->
115-
<p class="note">TODO: Specify details of how
116-
[=this=].`[[pipeToController]]` aborts streaming in the worker.</p>
125+
1. Set [=this=].`[[pipeToController]]` to a new {{AbortController}}.
126+
1. Let |frameSource| be [=this=].`[[frameSource]]`.
127+
1. [=In parallel=], set |frameSource|.[=[[transformFrameAlgorithm]]=] to the
128+
[=passthrough algorithm=].
117129

118130
### Stream processing ### {#stream-processing}
119131

@@ -173,9 +185,7 @@ As [$writeEncodedData$] ensures that the transform cannot reorder frames, this w
173185

174186
## Extension attribute ## {#attribute}
175187

176-
A RTCRtpTransform has private slots:
177-
* `[[readable]]` of type {{ReadableStream}}.
178-
* `[[writable]]` of type {{WritableStream}}.
188+
An RTCRtpTransform has a private slot:
179189
* `[[owner]]` of type {{RTCRtpSender}} or {{RTCRtpReceiver}}, initialized to null.
180190

181191
Each RTCRtpTransform has an <dfn abstract-op for=RTCRtpTransform>association steps</dfn> set, which is empty by default.
@@ -185,28 +195,23 @@ The <dfn attribute for="RTCRtpSender,RTCRtpReceiver">transform</dfn> getter step
185195

186196
The `transform` setter steps are:
187197
1. Let |transform| be the argument to the setter.
188-
1. Let |checkedTransform| set to |transform| if it is not null or to an [=identity transform stream=] otherwise.
189-
1. If |checkedTransform|.`[[owner]]` is not null, throw a {{InvalidStateError}} and abort these steps.
190-
1. Let |reader| be the result of [=ReadableStream/getting a reader=] for |checkedTransform|.`[[readable]]`.
191-
1. Let |writer| be the result of [=WritableStream/getting a writer=] for |checkedTransform|.`[[writable]]`.
192-
1. Set |checkedTransform|.`[[owner]]` to [=this=].
198+
1. If |transform| is not null and |transform|.`[[owner]]` is not null, throw a {{InvalidStateError}} and abort these steps.
199+
1. Set |transform|.`[[owner]]` to [=this=].
193200
1. Initialize |newPipeToController| to a new {{AbortController}}.
194201
1. If [=this=].`[[pipeToController]]` is not null, run the following steps:
195-
1. [=AbortSignal/Add=] the [$chain transform algorithm$] to [=this=].`[[pipeToController]]`'s [=AbortController/signal=].
202+
1. [=AbortSignal/Add=] the [$apply transform$] to [=this=].`[[pipeToController]]`'s [=AbortController/signal=].
196203
2. [=AbortController/signal abort=] on [=this=].`[[pipeToController]]`.
197-
1. Else, run the [$chain transform algorithm$] steps.
204+
1. Else, run the [$apply transform$] steps.
198205
1. Set [=this=].`[[pipeToController]]` to |newPipeToController|.
199206
1. Set [=this=].`[[transform]]` to |transform|.
200207
1. Run the steps in the set of [$association steps$] of |transform| with [=this=].
201208

202-
The <dfn abstract-op>chain transform algorithm</dfn> steps are defined as:
209+
The <dfn abstract-op>apply transform</dfn> steps are defined as:
203210
1. If |newPipeToController|'s [=AbortController/signal=] is [=AbortSignal/aborted=], abort these steps.
204-
2. [=ReadableStreamDefaultReader/Release=] |reader|.
205-
3. [=WritableStreamDefaultWriter/Release=] |writer|.
206-
4. [=Assert=] that |newPipeToController| is the same object as |rtcObject|.`[[pipeToController]]`.
207-
<!-- FIXME: Use pipeTo algorithm when available. -->
208-
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|'s [=AbortController/signal=].
209-
6. Call <a href="https://streams.spec.whatwg.org/#readable-stream-pipe-to">pipeTo</a> with |checkedTransform|.`[[readable]]`, |rtcObject|.`[[writable]]`, preventClose equal to true, preventAbort equal to true, preventCancel equal to false and |newPipeToController|'s [=AbortController/signal=].
211+
1. [=Assert=] that |newPipeToController| is the same object as |rtcObject|.`[[pipeToController]]`.
212+
<!-- FIXME: Fix aborting. -->
213+
<p class="note">TODO: Specify details of how
214+
[=this=].`[[pipeToController]]` replaces the transform in the media pipeline.</p>
210215

211216
This algorithm is defined so that transforms can be updated dynamically.
212217
There is no guarantee on which frame will happen the switch from the previous transform to the new transform.
@@ -931,7 +936,7 @@ The <dfn constructor for="RTCRtpScriptTransform" lt="RTCRtpScriptTransform(worke
931936

932937
Each {{RTCRtpScriptTransform}} has the following set of [$association steps$], given |rtcObject|:
933938
1. Let |transform| be the {{RTCRtpScriptTransform}} object that owns the [$association steps$].
934-
1. Let |frameSource| be |rtcObject|'s [=encoder=] if |rtcObject| is an {{RTCRtpSender}} or |rtcObject|'s [=depacketizer=] otherwise.
939+
1. Let |frameSource| be |rtcObject|'s `[[frameSource=]]`.
935940
1. [=Queue a task=] on the DOM manipulation [=task source=] |worker|'s global scope to run the following steps:
936941
1. Let |transformer| be the {{RTCRtpScriptTransformer}} object associated to |transform|.
937942
1. Set |transformer|.{{[[frameSource]]}} to |frameSource|.

0 commit comments

Comments
 (0)