-
Notifications
You must be signed in to change notification settings - Fork 19
API shape for creating a WHATWG Stream from a MediaStreamTrack #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Note this issue is solely over shape: A new interface object with a constructor track argument, vs. a new track attribute: await new MediaStreamTrackProcessor({track}).readable.pipeThrough(transformer).pipeTo(writable); vs. await new track.readable.pipeThrough(transformer).pipeTo(writable); Naming and exposure ( |
Audio exposure is also orthogonal (video-only for now to reflect consensus). |
The rest of the platform follows the pattern of "we set a stream's destination to an object":
In all those cases, a MediaStreamTrack that hasn't been attached generates nothing; a MediaStreamTrack can also be attached to multiple destinations simultaneously, and will generate content for all. I think it is good to retain the pattern of "a MediaStreamTrack attaches to its destination, it isn't a destination". (Please open separate issues on exposure and audio, where consensus has not been declared.) |
I agree a track is neither a source nor a sink. It's a connector. But so are WHATWG readables/writables.
Tracks exist to be "attached". They're square plugs built for the square receptacles in the MST sources and sinks APIs. Developers at a semantic level use them to describe a chain or a tree:
Similarly, readables exist be be piped. They're round plugs built for round receptacles (writables). Again, developers use them to describe a chain or a tree:
So we need an adapter. The question is: is it a brick, or a smart cable?
Yes, MSTP has this advantage over track.readable (I had a slide on track.createReadable()) — But the fan-out is also arguably a liability. As I believe @aboba observed regarding tee(): why solve it when we have track.clone()? Consider:
vs.
|
@alvestrand To answer your original question, there are some differences which are worth discussing:
|
What fanout is a liability and why? So, to summarize:
|
See slide. More 1-to-many relationships than necessary is a complexity cost in any API. Track and readable are both connectors, and trivially instantiated with clone or tee already. This begs the question why we need more connective tissue.
Or just clone the track (which mirrors advice given to avoid tee()). E.g. why have frame resolution control on one object and buffering on another? Flexibility from a deeper tree has a complexity cost , so if we don't need it, we should avoid it, and KISS. Counter-argument: cloning a track comes at a cost of having to manage constraints separately, so an application that didn't want that might appreciate the extra object. It also requires not forgetting to call I think this comes down to ergonomics and preference. A readable is already lockable, so by default there's no resource overhead until a readable is used. However, I have some concerns about what happens when the readable becomes errored. MSTP doesn't appear to talk about that. |
I disagree. The "complexity cost" you mention is negligible IMO, and the ability to have different processors with different configurations more than offsets that "cost".
How do you configure it differently with a readable field? Or are you suggesting adding any config params that control the readable field as additional fields in MST?
I don't know if I understand this sentence, but I don't see any deeper tree here. 1:N gives you a single tree of depth 2 if you want multiple readables. 1:1 with clone gives you N trees of depth 2. If anything, the latter is a lot more complex.
That's my point.
track.readable has a minor ergonomic advantage in some cases, at the cost of being a lot more complex for other nontrivial but very valid use cases. In terms of preference, I prefer the other point in the tradeoff. |
Flag warning: As we've discussed a lot, tee() is not trivial, and not suitable as-is for video streams. I think @jan-ivar took the token to write (in Javascript) a suitable replacement that would be satisfactory in the video streams context, for possible incorporation into the Streams spec. |
The consensus documented is that we have a MediaStreamTrackProcesor that takes a MediaStreamTrack as a constructor argument and produces a WHATWG stream. |
Two shapes have been proposed:
Arguments on which to base a decision are needed.
The text was updated successfully, but these errors were encountered: