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:
const {data} = await new Promise(r => worker.onmessage);
video2.srcObject = new MediaStream([data.track]);
};
The worker pipes the camera track.readable through a video processing step into a writable VideoTrackSource source, whose resulting source.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 its source.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.
From https://github.com/alvestrand/mediacapture-transform/issues/59 (see link for earlier discussion):
Please conduct further WG discussion here, so that discussion is tracked.