Skip to content

Commit 709e0a0

Browse files
authored
Merge pull request #30 from alvestrand/why-streams
Add design considerations to explainer
2 parents 0eb724e + f217355 commit 709e0a0

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

explainer.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,54 @@ partial interface RTCRtpReceiver {
220220
};
221221

222222
</pre>
223+
224+
## Design considerations ##
225+
226+
This design is built upon the Streams API. This is a natural interface
227+
for stuff that can be considered a "sequence of objects", and has an ecosystem
228+
around it that allows some concerns to be handed off easily.
229+
230+
In particular:
231+
232+
* Sequencing comes naturally; streams are in-order entities.
233+
* With the Transferable Streams paradigm, changing what thread is doing
234+
the processing can be done in a manner that has been tested by others.
235+
* Since other users of Streams interfaces are going to deal with issues
236+
like efficient handover and WASM interaction, we can expect to leverage
237+
common solutions for these problems.
238+
239+
There are some challenges with the Streams interface:
240+
241+
* Queueing in response to backpressure isn't an appropriate reaction in a
242+
real-time environment. This can be mitigated at the sender by not queueing,
243+
preferring to discard frames or not generating them.
244+
* How to interface to congestion control signals, which travel in the
245+
opposite direction from the streams flow.
246+
* How to integrate error signalling and recovery, given that most of the
247+
time, breaking the pipeline is not an appropriate action.
248+
249+
These things may be solved by use of non-data "frames" (in the forward direction),
250+
by reverse streams of non-data "frames" (in the reverse direction), or by defining
251+
new interfaces based on events, promises or callbacks.
252+
253+
Experimentation with the prototype API seems to show that performance is
254+
adequate for real-time processing; the streaming part is not contributing
255+
very much to slowing down the pipelines.
256+
257+
## Alternatives to Streams ##
258+
One set of alternatives involve callback-based or event-based interfaces; those
259+
would require developing new interfaces that allow the relevant WebRTC
260+
objects to be visible in the worker context in order to do processing off
261+
the main thread. This would seem to be a significantly bigger specification
262+
and implementation effort.
263+
264+
Another path would involve specifying a worklet API, similar to the AudioWorklet,
265+
and specifying new APIs for connecting encoders and decoders to such worklets.
266+
This also seemed to involve a significantly larger set of new interfaces, with a
267+
correspondingly larger implementation effort, and would offer less flexibility
268+
in how the processing elements could be implemented.
269+
270+
271+
272+
273+

0 commit comments

Comments
 (0)