Skip to content

feat: session.setDisplayMediaRequestHandler - #30702

Merged
nornagon merged 40 commits into
mainfrom
media-request-handler
Aug 22, 2022
Merged

nornagon merged 40 commits into
mainfrom
media-request-handler

Conversation

@nornagon

@nornagon nornagon commented Aug 25, 2021 •

Copy link
Copy Markdown
Contributor

Description of Change

This allows Electron apps to support responding to
navigator.mediaDevices.getDisplayMedia. Closes #16513.

Checklist

Release Notes

Notes: Added support for navigator.mediaDevices.getDisplayMedia via a new session handler, ses.setDisplayMediaRequestHandler.

@nornagon nornagon added no-backport semver/minor backwards-compatible functionality labels Aug 25, 2021
Comment thread docs/api/session.md Resolved
Comment thread docs/api/session.md Resolved
Comment thread docs/api/session.md Resolved

@zcbenz zcbenz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API looks good to me.

@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Sep 1, 2021
@nornagon

nornagon commented Sep 2, 2021 •

Copy link
Copy Markdown
Contributor Author

I have two vague concerns about this API.

  1. I think it might be possible to break (CHECK? UAF? Type confusion?) things by returning the wrong type of media streams here. If so we should add checks/throw/etc. to make it more dev-friendly.
  2. It's unclear to me how difficult it would be to build a "chooser"-type UI using this API, mimicking what Chrome shows. Is this API too intricate/powerful? Could we expose something simpler, perhaps technically a little less powerful but covering 99% of use cases in a much simpler-to-understand and less error-prone way?

For (2) here, by "intricate", I mean things like: how should an app differently handle deviceAccess, deviceUpdate and generateStream requests? What about openDevicePepperOnly? Should it be possible to return the video stream for a different tab for requests for displayVideoCaptureThisTab? etc.

Also, should this same API be responsible for handling navigator.mediaDevices.getUserMedia as well? If so, how is the app supposed to enumerate video/microphone devices?

@nornagon
nornagon marked this pull request as draft September 3, 2021 17:14
@nornagon

nornagon commented Sep 3, 2021

Copy link
Copy Markdown
Contributor Author

Converting to draft because I think this needs some thought before it's ready to be merged.

Comment thread docs/api/session.md Outdated
* `request` Object
* `frame` [WebFrameMain](web-frame-main.md) - frame that is requesting access to media
* `type` String - Type of request. Can be 'deviceAccess', 'deviceUpdate', 'generateStream' or 'openDevicePepperOnly'.
* `audioType` String - can be 'deviceAudioCapture', 'displayAudioCapture' or 'noService'.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these be 'device', 'display', and null? The 'AudioCapture' is redundant since the key is 'audioType'.

@nornagon

nornagon commented Mar 3, 2022

Copy link
Copy Markdown
Contributor Author

NB let's make sure we support applyConstraints and investigate adding cursor constraint support to Chrome per #30231 (comment)

@release-clerk

release-clerk Bot commented Aug 22, 2022

Copy link
Copy Markdown

Release Notes Persisted

Added support for navigator.mediaDevices.getDisplayMedia via a new session handler, ses.setDisplayMediaRequestHandler.

@jeanfbrito

Copy link
Copy Markdown

Hello!
Any idea of what version will have this released?

@nornagon

Copy link
Copy Markdown
Contributor Author

this is in v22.

@dtzxporter

Copy link
Copy Markdown

Does this support constraints like frameRate, width, height yet?

@nornagon

Copy link
Copy Markdown
Contributor Author

@dtzxporter are you having trouble with those?

@dtzxporter

dtzxporter commented Nov 29, 2022 •

Copy link
Copy Markdown

@nornagon I had just taken a look at the pull, in the tests it seemed to just supply true/false, I am mainly curious if passing constraints directly to getDisplayMedia are supported or if we have to use applyConstraints right now, (Which, is horribly broken in chrome/chromium)

@nornagon

Copy link
Copy Markdown
Contributor Author

@dtzxporter there's nothing in this PR that specifically supports or doesn't support those constraints; they should work the same as they do in chrome I believe.

@stefansundin

Copy link
Copy Markdown

@nornagon Hello. Sorry for the ping but I have two questions:

  1. What does loopbackWithMute mute exactly? I haven't been able to find information explaining what makes it different from just loopback.
  2. Is callback(undefined) the recommended way to reject the getDisplayMedia promise? Would be cool if there were both a resolve and reject callback, but maybe that's not very common in electron APIs.

Thanks!

@mattxie02

Copy link
Copy Markdown

@nornagon Does this include cursor constraints per #30702 (comment)?

SimonBrandner added a commit to element-hq/element-desktop that referenced this pull request Jul 14, 2023
See electron/electron#30702 - this has the benefit of the js-sdk and LiveKit not having to add custom logic for Electron

Signed-off-by: Šimon Brandner <[email protected]>
SimonBrandner added a commit to matrix-org/matrix-react-sdk that referenced this pull request Jul 14, 2023
See electron/electron#30702 - this has the benefit of the js-sdk and LiveKit not having to add custom logic for Electron

Signed-off-by: Šimon Brandner <[email protected]>
SimonBrandner added a commit to element-hq/element-web that referenced this pull request Jul 14, 2023
See electron/electron#30702 - this has the benefit of the js-sdk and LiveKit not having to add custom logic for Electron

Signed-off-by: Šimon Brandner <[email protected]>
github-merge-queue Bot pushed a commit to matrix-org/matrix-react-sdk that referenced this pull request Jul 14, 2023
See electron/electron#30702 - this has the benefit of the js-sdk and LiveKit not having to add custom logic for Electron

Signed-off-by: Šimon Brandner <[email protected]>
github-merge-queue Bot pushed a commit to matrix-org/matrix-react-sdk that referenced this pull request Jul 14, 2023
See electron/electron#30702 - this has the benefit of the js-sdk and LiveKit not having to add custom logic for Electron

Signed-off-by: Šimon Brandner <[email protected]>
github-merge-queue Bot pushed a commit to matrix-org/matrix-react-sdk that referenced this pull request Jul 14, 2023
See electron/electron#30702 - this has the benefit of the js-sdk and LiveKit not having to add custom logic for Electron

Signed-off-by: Šimon Brandner <[email protected]>
@codebytere codebytere mentioned this pull request Jul 18, 2024
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getDisplayMedia with Chrome 72 throwing Not Allowed