- From: Jan-Ivar Bruaroey via GitHub <sysbot+gh@w3.org>
- Date: Mon, 02 Dec 2024 21:31:32 +0000
- To: public-webrtc-logs@w3.org
Let's compare without a "before" preview element, which seems more realistic. Current spec (22 lines): ```js start.onclick = async () => { const stream = await navigator.mediaDevices.getUserMedia({video: true}); const [before] = stream.getVideoTracks(); const worker = new Worker(`data:text/javascript,(${work.toString()})()`); worker.postMessage({before}, [before]); const {data: {after}} = await new Promise(r => worker.onmessage = r); video.srcObject = new MediaStream([after]); stop.onclick = () => after.stop(); }; function work() { onmessage = async ({data: {before}}) => { const {writable, track} = new VideoTrackGenerator(); self.postMessage({after: track}, [track]); const {readable} = new MediaStreamTrackProcessor({track: before}); try { await readable.pipeThrough(new TransformStream({transform})).pipeTo(writable); } finally { before.stop(); } }; } ``` vs. bespoke API (17 lines): ```js start.onclick = async () => { const stream = await navigator.mediaDevices.getUserMedia({video: true}); const [before] = stream.getVideoTracks(); const worker = new Worker(`data:text/javascript,(${work.toString()})()`); const after = navigator.mediaDevices.createVideoTrackGeneratorAndProcessor(worker, before); video.srcObject = new MediaStream([after]); stop.onclick = () => { before.stop(); after.stop(); } }; function work() { oncapturetransform = async ({processor, generator}) => { await processor.readable.pipeThrough({transform}).pipeTo(generator.writable); } } ``` Two new redundant APIs (`navigator.mediaDevices.createVideoTrackGeneratorAndProcessor` and `oncapturetransform`) to trade 5 lines of code for an encapsulation problem does not seem like a win. -- GitHub Notification of comment by jan-ivar Please view or discuss this issue at https://github.com/w3c/mediacapture-transform/issues/116#issuecomment-2512939227 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Monday, 2 December 2024 21:31:33 UTC