Re: [mediacapture-screen-share] Identification of Captured Application By Capturer (#166)

@eladalon1983, @jan-ivar, following on yesterday's meeting, here are examples that I hope clarifies what I have in mind.
First example is targeting a fixed protocol, second example is for custom web-application protocols.

1. MediaSession-based communication.
```
// MediaSession related API
partial interface MediaSession {
    MediaSessionProxyRules proxyRules;
} 
partial interface MediaSessionProxyRules {
    maplike<USVString, sequence<MediaSessionAction>>;
}

partial dictionary MediaSessionActionDetails {
    USVString origin;
}

interface MediaSessionProxy {
    attribute USVString origin;
    attribute sequence<MediaSessionAction> actions;
    attribute EventHandler onproxychange;

    Promise<undefined> triggerAction(MediaSessionAction);
}

// getDisplayMedia bootstrapping API, based on https://github.com/w3c/mediacapture-screen-share/issues/190.
partial interface GetDisplayMediaResultEvent {
    attribute MediaSessionProxy mediaSession;
}
partial interface MediaDevices {
    attribute EventHandler ongetdisplaymediaresult;
}
```
Capturee is exposing its origin through MediaSessionProxy.origin to capturers whose origin is granted by capturee's MediaSessionProxyRules.
Capturer exposes its origin to capturee when sending an action to capturee (through actionDetails.origin, which remains empty for UA triggered actions).
Handling of capturee navigation is done through onproxychange, similarly to change of MediaSession or MediaSession rules.
triggerAction would reject if, at the time of firing the corresponding event, the MediaSession is no longer active or the action no longer matches the MediaSession proxy rules. 
previousslide/nextslide could be handled as previoustrack/nexttrack.

2. MessageChannel-based communication

```
dictionary GetDisplayMediaCapturer {
    USVString origin;
    MessagePort port;
}
callback GetDisplayMediaChannelCallback = undefined(GetDisplayMediaCapturer capturer);
partial interface MediaDevices {
    undefined setGetDisplayMediaChannelCallback(USVString or sequence<USVString>, GetDisplayMediaChannelCallback callback);
}

interface CaptureeProxy {
    attribute USVString origin;
    attribute EventHandler onproxychange;

    Promise<MessagePort> openChannel();
}

// getDisplayMedia bootstrapping API, based on https://github.com/w3c/mediacapture-screen-share/issues/190.
partial interface GetDisplayMediaResultEvent {
    attribute CaptureeProxy capturee;
}
partial interface MediaDevices {
    attribute EventHandler ongetdisplaymediaresult;
}
```
Capturee is exposing its origin through CaptureeProxy.origin to capturers whose origin is granted by capturee through setGetDisplayMediaChannelCallback.
setGetDisplayMediaChannelCallback is limited to first-party iframes.
Capturer exposes its origin to capturee when calling openChannel (which may fail in some cases, like navigation or change of channel callback origins, or if CaptureeProxy.origin is empty).
After that, capturee and capturer uses the MessageChannel ports to directly communicate one with each other.
Handling of capturee navigation is done through onproxychange and calling openChannel again.
CaptureeProxy is neutered when the getDisplayMedia track source is ended.
previousslide/nextslide would be handled through capturee-specific messages that capturer needs to understand.

-- 
GitHub Notification of comment by youennf
Please view or discuss this issue at https://github.com/w3c/mediacapture-screen-share/issues/166#issuecomment-1016301880 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 10:35:49 UTC