[mediacapture-region] Can the MediaStreamTrack list its cropping regions directly? (#6)

youennf has just created a new issue for https://github.com/w3c/mediacapture-region:

== Can the MediaStreamTrack list its cropping regions directly? ==
When trying to apply a region to a track, you currently do not know whether the region can be used for the track.
This might be getting more complex if transferring the MediaStreamTrack say to a worker. You then need to transfer the regions where you transfer the track. This might be worse if allowing cropping for any tab in the future. This also goes against the idea of tracks being descriptive in their capabilities.

It would seem more natural if the regions could be retrieved directly from the track itself.

Here is an API example that could illustrate this:
interface MediaStreamTrackRegion {
    USVString origin;
    DOMString name;

partial interface MediaStreamTrack {
    readonly attribute sequence<MediaStreamTrackRegion> regions;
    attribute EventHandler onregionschange;

    Promise<undefined> cropTo(MediaStreamTrackRegion);

The main issue with that idea is that this might require to expose an API on the capturee-side, so that the MediaStreamTrack source can explicitly list its regions. This is the part I am most annoyed with, in particular with regards to the handling of third-party iframes. Here is nonetheless an API example to illustrate what could be done if the source is a browser tab:

dictionary TabRegion {
    required Element or DOMString target;
    USVString or sequence<USVString> origins; // ‘self’ by default, can be ‘*’, an origin or a list of origins.
interface MediaDevicesTabRegions {
    maplike<DOMString, TabRegion>;
partial navigator MediaDevices {
    readonly attribute regions;

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

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

Received on Wednesday, 19 January 2022 11:31:26 UTC