- From: Jan-Ivar Bruaroey via GitHub <sysbot+gh@w3.org>
- Date: Thu, 18 Apr 2024 21:21:07 +0000
- To: public-webrtc-logs@w3.org
With the optimization @youennf proposed, forgetting `stop()` seems like an existing problem. Having apps explicitly `stop()` tracks they're done is the web model today, which makes its side-effects well-established, predictable, and pilot errors easy to diagnose and fix. I'm not convinced introducing custom stopping-policies into the mix simplifies that responsibility. > ``` > controller.onnewsource = ({stream}) => { > video.srcObject = stream; > }; > const sessionStream = await getDisplayMedia({controller, someOtherOptIn: “include”, ...}); > sessionStream.getTracks().forEach(track => track.stop()); > ``` > The former is both less code and less error-prone than the latter. Ah, I missed earlier you said the event would fire for all new surfaces _"including the initial one"_! Having apps immediately stop tracks from getDisplayMedia() does look weird indeed. I like the session vs surface behaviors, but why do web developers need to pick between two types of tracks? It seems to artificially put injection off the table on subsequent switches once non-injection is chosen just once, without any apparent or inherent reason. I'd like to propose a more fluid model where web developer doesn't need to care about this on the initial getDisplayMedia call, and every track remains a candidate for injection: To inject everything (the UA optimizes stopping tracks surfaced in `sourceswitch`): ```js video.srcObject = await getDisplayMedia({controller, /*opt-in*/, ...}); ``` To never inject: ```js video.srcObject = await getDisplayMedia({controller, /*opt-in*/, ...}); controller.onsourceswitch = ({stream}) => { video.srcObject.getTracks().forEach(track => track.stop()); // stop old video.srcObject = stream; }; ``` To selectively inject: ```js video.srcObject = await getDisplayMedia({controller, /*opt-in*/, ...}); controller.onsourceswitch = ({stream}) => { if (tracksAreCompatible(video.srcObject, streams)) { stream.getTracks().forEach(track => track.stop()); // stop new } else { video.srcObject.getTracks().forEach(track => track.stop()); // stop old video.srcObject = stream; }; ``` -- GitHub Notification of comment by jan-ivar Please view or discuss this issue at https://github.com/w3c/mediacapture-screen-share-extensions/issues/4#issuecomment-2065344311 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 18 April 2024 21:21:08 UTC