Skip to content

Commit 4221a73

Browse files
committed
Make use of the pullAlgorithm by rewriting readEncodedData to return a promise.
Set the highWaterMark to Infinity to keep the same behavior (no backpressure) and add a note about this. Fixes w3c#187.
1 parent 4bd0792 commit 4221a73

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

index.bs

+12-7
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ argument, ensure that the codec is disabled and produces no output.
8686
At construction of each {{RTCRtpSender}} or {{RTCRtpReceiver}}, run the following steps:
8787
2. Initialize [=this=].`[[transform]]` to null.
8888
3. Initialize [=this=].`[[readable]]` to a new {{ReadableStream}}.
89-
4. <a dfn for="ReadableStream">Set up</a> [=this=].`[[readable]]`. [=this=].`[[readable]]` is provided frames using the [$readEncodedData$] algorithm given |this| as parameter.
89+
4. <a dfn for="ReadableStream">Set up</a> [=this=].`[[readable]]`. [=this=].`[[readable]]` with its [=ReadableStream/set up/pullAlgorithm=] set to [$readEncodedData$] given |this| as parameter and its [=ReadableStream/set up/highWaterMark=] set to <code>Infinity</code>.
90+
<p class="note">highWaterMark is set to Infinity to explicitly disable backpressure. The goal is to limit buffering as much as possible.</p>
9091
5. Set [=this=].`[[readable]]`.`[[owner]]` to |this|.
9192
6. Initialize [=this=].`[[writable]]` to a new {{WritableStream}}.
9293
7. <a dfn for="WritableStream">Set up</a> [=this=].`[[writable]]` with its [=WritableStream/set up/writeAlgorithm=] set to [$writeEncodedData$] given |this| as parameter and its [=WritableStream/set up/sizeAlgorithm=] to an algorithm that returns <code>0</code>.
@@ -104,12 +105,16 @@ At construction of each {{RTCRtpSender}} or {{RTCRtpReceiver}}, run the followin
104105
### Stream processing ### {#stream-processing}
105106

106107
The <dfn abstract-op>readEncodedData</dfn> algorithm is given a |rtcObject| as parameter. It is defined by running the following steps:
107-
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}}.
108-
1. Increment |rtcObject|.`[[lastEnqueuedFrameCounter]]` by <code>1</code>.
109-
1. Let |frame| be the newly produced frame.
110-
1. Set |frame|.`[[owner]]` to |rtcObject|.
111-
1. Set |frame|.`[[counter]]` to |rtcObject|.`[[lastEnqueuedFrameCounter]]`.
112-
1. [=ReadableStream/Enqueue=] |frame| in |rtcObject|.`[[readable]]`.
108+
1. Let |p| be a new promise.
109+
1. Run the following steps in parallel:
110+
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}}.
111+
1. Increment |rtcObject|.`[[lastEnqueuedFrameCounter]]` by <code>1</code>.
112+
1. Let |frame| be the newly produced frame.
113+
1. Set |frame|.`[[owner]]` to |rtcObject|.
114+
1. Set |frame|.`[[counter]]` to |rtcObject|.`[[lastEnqueuedFrameCounter]]`.
115+
1. [=ReadableStream/Enqueue=] |frame| into |rtcObject|.`[[readable]]`.
116+
1. Resolve |p| with <code>undefined</code>.
117+
1. return |p|.
113118

114119
The <dfn abstract-op>writeEncodedData</dfn> algorithm is given a |rtcObject| as parameter and a |frame| as input. It is defined by running the following steps:
115120
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.

0 commit comments

Comments
 (0)