mediacapture-extensions icon indicating copy to clipboard operation
mediacapture-extensions copied to clipboard

Make MediaStreamTrack serializable

Open jan-ivar opened this issue 3 years ago • 8 comments

@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.

jan-ivar avatar Oct 13 '21 22:10 jan-ivar