[mediacapture-main] Make MediaStreamTrack serializable (#823)

jan-ivar has just created a new issue for https://github.com/w3c/mediacapture-main:

== Make MediaStreamTrack serializable ==
@annevk says most objects that are transferable are also serializable.

MediaStreamTrack has a custom `clone()` method today, like [VideoFrame](https://w3c.github.io/webcodecs/#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]( https://jsfiddle.net/jib1/6L3sj5xh/) 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.

Please view or discuss this issue at https://github.com/w3c/mediacapture-main/issues/823 using your GitHub account

Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 13 October 2021 22:56:38 UTC