mediacapture-extensions
mediacapture-extensions copied to clipboard
Make MediaStreamTrack serializable
@annevk says most objects that are transferable are also serializable.
MediaStreamTrack has a custom clone()
method today, like VideoFrame has. But VideoFrame is serializable while MediaStreamTrack is not.
After looking over our custom clone algorithm in https://github.com/w3c/mediacapture-main/pull/821, it seems semantically compatible to me, and since tracks are already transferable, I think it would make sense to make them serializable as well. This should simplify our algorithms, and make the following work:
const stream = await navigator.mediaDevices.getUserMedia({video: true});
const [track] = stream.getVideoTracks();
const clone = structuredClone(track);
Today this produces DataCloneError: The object could not be cloned.
in Firefox Nightly.