Closed jan-ivar closed 3 years ago
This illustrates use cases for transferrable MediaStreamTrack. But can't MST transfer also be used with MSTP/MSTG? Trying to understand the differences unique to the alternative stream-based API.
can't MST transfer also be used with MSTP/MSTG? Trying to understand the differences unique to the alternative stream-based API.
MSTP/MSTG is _"not an adopted working group document"_ because it
Those are the two main blockers this proposal aims to address. I've added some intro slides on the importance of this.
MSTP/MSTG was also written before transferable MST, making it awkwardly backwards and unfriendly to workers: A worker shouldn't have to ask main thread to access a track it already has, or to create a new one from a source of frames it has.
The benefits slide now solely covers benefits over MSTP/MSTG:
Benefits
- Simpler API taking advantage of transferable MST
- Fewer new API objects to learn. Friendly to workers
- Satisfies core principles from a worker POV, without main-thread entangled APIs (“worker see, worker do”)
- Doesn’t block realtime media pipeline on main thread by default
- Source stays in worker, separate from its track(s). Clean xfer
- applyConstraints available in the worker
- Parity+ with MSTP/MSTG features & brevity (e.g. 41 lines)
- Doesn’t need transferable streams UA “optimizations”
- Source.muted attribute
@alvestrand can you transfer this to mediacapture-extensions? I seem unable to.
I don't seem to have that power either, despite having admin rights on the webrtc-extensions repo.
https://docs.github.com/en/issues/tracking-your-work-with-issues/transferring-an-issue-to-another-repository says that you can't transfer issues between user repos and org repos (or between orgs), so I guess you'll just have to file a new one and point back to this discussion.
Closed in favor of https://github.com/w3c/mediacapture-extensions/issues/38.
As requested, this is to discuss our upcoming proposal, which I've written up as a standards document, with 3 examples.
This brief explainer isn't a substitute for that doc or the slides, but walks through a 41-line fiddle:
Since tracks are transferable, instead of of creating all tracks ahead of time and transferring their streams, we simply transfer the camera track to the worker:
...and receive a processed track in return:
The worker pipes the camera
track.readable
through a video processing step into a writable VideoTrackSourcesource
, whose resultingsource.track
it transfers back with postMessage.This avoids exposing data on main thread by default. The
source
(and the real-time media pipeline) stays in the worker, while itssource.track
(a control surface) can be transferred to the main thread.track.clone()
inherits the same source.This aligns with mediacapture-main's sources and sinks model, which separates a source from its track, and makes it easy to extend the source interface later.
The slides go on to show how clone() and applyConstraints() used in the worker help avoid needing the
tee()
function.