The current version of the API requires track transferability, but this shouldn't be necessary.
Currently, tracks are useless on workers except for this API, so we shouldn't add that as a requirement.
A way to keep the API worker first which has several benefits is to follow the postMessage-like approach of webrtc-encoded-transform.
Something (subject to discussion) like:
For MediaStreamTrackProcessor:
// main
navigator.mediaDevices.createTrackProcessor(myWorker, mytrack, myOptions, [myOptions]);`
// worker
ontrackprocessor = event => {
let processor = event.processor;
// Process frames using processor. `event.options` has the data sent via myOptions for extra configuration.
}
For VideoTrackGenerator:
// main
let generatedTrack = navigator.mediaDevices.createVideoTrackGenerator(myWorker, myOptions, [myOptions]);`
// worker
ontvideorackgenerator = event => {
let generator = event.generator;
// generate frames for `generatedTrack`. `event.options` has the data sent via myOptions for extra configuration.
}
The current version of the API requires track transferability, but this shouldn't be necessary.
Currently, tracks are useless on workers except for this API, so we shouldn't add that as a requirement.
A way to keep the API worker first which has several benefits is to follow the postMessage-like approach of webrtc-encoded-transform.
Something (subject to discussion) like:
For MediaStreamTrackProcessor:
For VideoTrackGenerator: