Re: [mediacapture-screen-share] Provide a means to select only part of a screen to capture (#105)

@danjenkins Another issue is that even though https://github.com/w3c/mediacapture-screen-share/pull/114 fixed https://github.com/w3c/mediacapture-screen-share/issues/108 in the specification, Chromium still captures UI, which means that given an HTML element that is effective a green square, simulating the window on your 4k monitor, the first frame can still include the UI - which is not expected to be exposed in the capture 
![download (3)](https://user-images.githubusercontent.com/4174848/94290878-a9685200-ff0f-11ea-9d87-771fb59f4aa6.png). See the green square in the first image when capturing the entire screen, and the prompt itself captured, which should be the position of the green square, which is the only part of the screen that is expected to be captured. Test a basic implementation for yourself. Try with and without `await new Promise(resolve => setTimeout(resolve, 7000));` to observe the prompt, which can include other screen not intended to be captured, captured nonetheless

```
document.body.style="padding:0;margin:0";
document.body.innerHTML = '<div style="position:relative;display:block;left:calc(50vw);top:calc(50vh);background:green;width:200px;height:200px"></div>';

onclick = e => navigator.mediaDevices.getDisplayMedia({video:true})
.then(async stream => {
  // wait for prompt to fade out
  await document.body.requestFullscreen();
  await new Promise(resolve => setTimeout(resolve, 7000));
  const [track] = stream.getVideoTracks();
  const imageCapture = new ImageCapture(track);
  const frame = await imageCapture.grabFrame();
  const canvas = document.createElement('canvas');
  const ctx = canvas.getContext('bitmaprenderer');
  const {width, height} = frame;
  const {x, y, width: w, height: h} = document.querySelector('div').getBoundingClientRect();
  console.log(x,y,w,h);
  const bitmap = await createImageBitmap(frame, x, y, w, h);
  canvas.width = w;
  canvas.height = h;
  // repeat this process to create a video from ImageBitmap's
  ctx.transferFromImageBitmap(bitmap);
  track.stop();
  document.body.appendChild(canvas);
  document.exitFullscreen();
});
```
In the case of capturing the `window` on the 4k monitor would try using "Application" capture to capture Chromium instance window instead of the "Entire Screen". Though note the issue relevant to un-documented and un-specified behaviour of Chromium implementation firing `mute` and `unmute` events on the `MediaStreamTrack` when no activity is "rendered" in the application.

-- 
GitHub Notification of comment by guest271314
Please view or discuss this issue at https://github.com/w3c/mediacapture-screen-share/issues/105#issuecomment-699040329 using your GitHub account


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

Received on Friday, 25 September 2020 16:57:17 UTC