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

Support Screen capture #24

Merged
merged 4 commits into from
Jul 5, 2022

Conversation

dkubrakov
Copy link
Contributor

No description provided.

@dkubrakov
Copy link
Contributor Author

@dkubrakov dkubrakov mentioned this pull request May 23, 2022
- Windows Capture: CreateWindowCapturer()
@cloudwebrtc
Copy link
Member

cloudwebrtc commented May 25, 2022

hey @dkubrakov, that‘s awesome

Working example flutter-webrtc:
https://github.com/dkubrakov/flutter-webrtc/tree/feat/screen-capture

I tested this branch and it works, we need to return the thumbnail in Source, the underlying processing should be after getting the source list, applying to get a frame RTCVideoFrame for each source, and then get to the thumbnail.

I'm implementing DesktopCapture for macOS on another branch, https://github.com/webrtc-sdk/webrtc/blob/feat/support-screen-capture-for-mac/sdk/objc/components/capturer/RTCDesktopCapturer.h

I think we can synchronize and keep consistency at the dart level, and complete this feature.
Any idea can be discussed

@dkubrakov
Copy link
Contributor Author

At the moment, that's all.
After a while I will be able to return to this task (return the thumbnail in Source).
As an interface, I was targeting flutter-webrtc/flutter-webrtc#799.

https://github.com/dkubrakov/webrtc-interface/blob/feat/desktop-cpaturer/lib/src/desktop_capturer.dart
https://github.com/dkubrakov/flutter-webrtc/tree/feat/screen-capture
https://github.com/dkubrakov/libwebrtc/tree/feat/screen-capture

# Conflicts:
#	src/rtc_peerconnection_factory_impl.cc
@dkubrakov
Copy link
Contributor Author

Updated the release of screen capture, taking into account the upgrade to m97.
What prevents (still needs to be done) to add this feature?

  • There is a small difference in libvwebrtc (class RTCDesktopCapturer), how critical it is...

https://github.com/dkubrakov/libwebrtc/tree/feat/screen-capture
https://github.com/dkubrakov/flutter-webrtc/tree/feat/screen-capture
https://github.com/dkubrakov/webrtc-interface/tree/feat/desktop-cpaturer

@cloudwebrtc
Copy link
Member

cloudwebrtc commented Jun 18, 2022

@dkubrakov great work, I think we can merge after syncing both PRs, here I have some new changes.

1, I moved webrtc_interface/lib/src/desktop_capturer.dart to flutter_webrtc/lib/src/desktop_capturer.dart, because dart_webrtc uses getDisplayMedia to pop up screen/window selection dialog via browser api. so desktopCapture is only for desktop.

here is the PR for macOS.
https://github.com/flutter-webrtc/flutter-webrtc/pull/940/files

So we need to merge these two files.

2, I implemented full screen/window capture in macOS and supports thumbnail export, so I think you can refer to this code to generate thumbnails for windows part. (use libjpeg)

https://github.com/webrtc-sdk/webrtc/pull/24/files

I refer to electron and chromium to implement the DesktopMediaList, and DesktopMediaList::MediaSource interface. Use a generic ObjCDesktopCapturer class to capture Screen or Window.

objc_desktop_capture.h
objc_desktop_capture.mm
objc_desktop_media_list.h
objc_desktop_media_list.mm

BTW, If you need more timely discussion, you can add my Telegram ID. https://t.me/cloudwebrtc

@dkubrakov
Copy link
Contributor Author

dkubrakov commented Jun 27, 2022

Hello, @cloudwebrtc!

Fixed 1'st remark, also renamed to desktop_capturer_impl.dart.

https://github.com/dkubrakov/flutter-webrtc/blob/feat/screen-capture/lib/src/native/desktop_capturer_impl.dart

I did the thumbnail generation at the plugin level. This is much less expensive than implementing the DesktopMediaList, DesktopMediaList::MediaSource interface.

https://github.com/dkubrakov/flutter-webrtc/blob/feat/screen-capture/common/cpp/src/flutter_screen_capture.cc

Can we use it like this?

@cloudwebrtc
Copy link
Member

cloudwebrtc commented Jun 27, 2022

hey @dkubrakov, looks great, can you create a new PR for flutter-webrtc? I think we will be able to merge soon

I did the thumbnail generation at the plugin level. This is much less expensive than implementing the DesktopMediaList, DesktopMediaList::MediaSource interface.

At present, it is indeed possible to make consistent calls between windows and mac.

My intention to create thumbnails with libjpeg is for the upcoming `flutter Linux version, so we can make the Linux version achieve exactly the same screen-sharing functionality with almost no code changes, the Windows API is used in your PR, so this code will also need to be rewritten on the Linux platform.

I have committed the relevant common code to this branch
https://github.com/webrtc-sdk/libwebrtc/compare/feat/desktop-capture

would you mind merging this code into your branch to continue working on your PR? I guess this can reduce some workload.

@cloudwebrtc
Copy link
Member

Or you can create a flutter-webrtc PR first, I will merge it after the test is ok They also include this PR, then I will replace the libwebrtc part of the code with my PR, it will be a perfect feature for us to work together.

@dkubrakov
Copy link
Contributor Author

of course, it is here )

flutter-webrtc/flutter-webrtc#984

@cloudwebrtc cloudwebrtc merged commit 9074d26 into webrtc-sdk:master Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants