Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: instantiate tab video tracks from BrowserCaptureMediaStreamTrack #39074

Merged

Conversation

brhenrique
Copy link
Contributor

@brhenrique brhenrique commented Jul 12, 2023

Description of Change

It seems display_surface in display_media_info wasn't correctly set when the display media source is a tab, which causes getDisplayMedia to return a MediaStreamTrack instead of BrowserCaptureMediaStreamTrack for browser sources.

Looking at the uses of DesktopMediaID::Parse in Chromium, it looks like the id it's supposed to receive is the id of a MediaStreamSource instead of the id of MediaStreamRequest.

With this change, it'll be possible to use the new Region Capture API with tab/browser capturing.

Fixes #36331

Before
Screenshot 2023-07-12 132812

After
Screenshot 2023-07-12 132940

Checklist

Release Notes

Notes: support Region Capture API with tab MediaStream

@welcome
Copy link

welcome bot commented Jul 12, 2023

💖 Thanks for opening this pull request! 💖

We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix.

Examples of commit messages with semantic prefixes:

  • fix: don't overwrite prevent_default if default wasn't prevented
  • feat: add app.isPackaged() method
  • docs: app.isDefaultProtocolClient is now available on Linux

Things that will help get your PR across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jul 12, 2023
@brhenrique brhenrique changed the title video track of tab sources should be a BrowserCaptureMediaStreamTrack instead of MediaStreamTrack fix: instantiate tab video tracks from BrowserCaptureMediaStreamTrack Jul 12, 2023
@brhenrique brhenrique force-pushed the fix-get-display-media-croppable-track branch from 7b3cf9f to e4612ca Compare July 12, 2023 18:37
@codebytere codebytere self-requested a review July 13, 2023 09:00
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jul 19, 2023
@VerteDinde VerteDinde self-requested a review July 26, 2023 00:29
@VerteDinde VerteDinde added the semver/patch backwards-compatible bug fixes label Jul 26, 2023
@codebytere
Copy link
Member

@brhenrique apologies for the delay - i've been a little busy but i haven't forgotten about this! i'll try to get to it next week :)

Copy link
Member

@zcbenz zcbenz left a comment

Choose a reason for hiding this comment

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

It seems that request.requested_video_device_id might be empty since it is just a request and the video_device.id is the actual chosen ID.

@codebytere codebytere added target/26-x-y PR should also be added to the "26-x-y" branch. target/27-x-y PR should also be added to the "27-x-y" branch. target/25-x-y PR should also be added to the "25-x-y" branch. labels Aug 23, 2023
@codebytere codebytere merged commit 2481f94 into electron:main Aug 23, 2023
22 checks passed
@welcome
Copy link

welcome bot commented Aug 23, 2023

Congrats on merging your first pull request! 🎉🎉🎉

@release-clerk
Copy link

release-clerk bot commented Aug 23, 2023

Release Notes Persisted

support Region Capture API with tab MediaStream

@trop
Copy link
Contributor

trop bot commented Aug 23, 2023

I have automatically backported this PR to "25-x-y", please check out #39617

@trop
Copy link
Contributor

trop bot commented Aug 23, 2023

I have automatically backported this PR to "26-x-y", please check out #39618

@trop
Copy link
Contributor

trop bot commented Aug 23, 2023

I have automatically backported this PR to "27-x-y", please check out #39619

@trop trop bot added in-flight/26-x-y in-flight/27-x-y and removed target/26-x-y PR should also be added to the "26-x-y" branch. labels Aug 23, 2023
@trop trop bot added merged/26-x-y PR was merged to the "26-x-y" branch. merged/25-x-y PR was merged to the "25-x-y" branch. merged/27-x-y PR was merged to the "27-x-y" branch. and removed target/27-x-y PR should also be added to the "27-x-y" branch. in-flight/26-x-y in-flight/25-x-y in-flight/27-x-y labels Aug 23, 2023
@BokFang
Copy link

BokFang commented Oct 19, 2023

@brhenrique
hello,I see you use getDisplayMedia to get a return BrowserCaptureMediaStreamTrack . But when I use your code in Electron renderer process, I got an Error which is "Uncaught (in promise) DOMException: Not supported".
How can I fix it?What is the correct way to use getDisplayMedia in Electron?
Thanks!

@brhenrique
Copy link
Contributor Author

@BokFang https://www.electronjs.org/docs/latest/api/session#sessetdisplaymediarequesthandlerhandler

@BokFang
Copy link

BokFang commented Oct 20, 2023

@brhenrique
It works.Thanks!

MrHuangJser pushed a commit to MrHuangJser/electron that referenced this pull request Dec 11, 2023
…electron#39074)

return BrowserCaptureMediaStreamTrack instead of MediaStreamTrack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged/25-x-y PR was merged to the "25-x-y" branch. merged/26-x-y PR was merged to the "26-x-y" branch. merged/27-x-y PR was merged to the "27-x-y" branch. semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: No BrowserCaptureMediaStreamTrack being returned when using preferCurrentTab
5 participants