diff options
author | Michał Zarach <michalzaq12@gmail.com> | 2022-11-24 17:32:45 +0100 |
---|---|---|
committer | WebRTC LUCI CQ <webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-11-29 23:06:44 +0000 |
commit | 3f2a3b19e3de1531fed98a6d8295f89a79f6d969 (patch) | |
tree | 7eb693813ace5e8ea81a99cf26d10d0cc3a1840d | |
parent | 03bccbe62d60d9f40284e5a1c62ee13801e06a6a (diff) | |
download | webrtc-3f2a3b19e3de1531fed98a6d8295f89a79f6d969.tar.gz |
[DesktopCapture]: Allow toggling the visibility of the cursor
This is a change needed to implement (cursor: 'never') https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings/cursor
constraint.
Bug: chromium:1007177
Change-Id: Id7fae62de180d46a3874856978a3fda559aa6477
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/282861
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#38770}
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | modules/desktop_capture/win/wgc_capture_session.cc | 11 | ||||
-rw-r--r-- | modules/desktop_capture/win/wgc_capture_session.h | 2 | ||||
-rw-r--r-- | modules/desktop_capture/win/wgc_capturer_win.cc | 12 | ||||
-rw-r--r-- | modules/desktop_capture/win/wgc_capturer_win.h | 5 |
5 files changed, 23 insertions, 8 deletions
@@ -79,6 +79,7 @@ Maksim Sisov <msisov@igalia.com> Maxim Pavlov <pavllovmax@gmail.com> Maxim Potapov <vopatop.skam@gmail.com> Michael Iedema <michael@kapsulate.com> +Michał Zarach <michalzaq12@gmail.com> Michel Promonet <michel.promonet.1@gmail.com> Miguel Paris <mparisdiaz@gmail.com> Mike Gilbert <floppymaster@gmail.com> diff --git a/modules/desktop_capture/win/wgc_capture_session.cc b/modules/desktop_capture/win/wgc_capture_session.cc index 831257b4d4..e16529167f 100644 --- a/modules/desktop_capture/win/wgc_capture_session.cc +++ b/modules/desktop_capture/win/wgc_capture_session.cc @@ -105,7 +105,7 @@ WgcCaptureSession::~WgcCaptureSession() { RemoveEventHandlers(); } -HRESULT WgcCaptureSession::StartCapture() { +HRESULT WgcCaptureSession::StartCapture(const DesktopCaptureOptions& options) { RTC_DCHECK_RUN_ON(&sequence_checker_); RTC_DCHECK(!is_capture_started_); @@ -187,6 +187,15 @@ HRESULT WgcCaptureSession::StartCapture() { return hr; } + if (!options.prefer_cursor_embedded()) { + ComPtr<ABI::Windows::Graphics::Capture::IGraphicsCaptureSession2> session2; + if (SUCCEEDED(session_->QueryInterface( + ABI::Windows::Graphics::Capture::IID_IGraphicsCaptureSession2, + &session2))) { + session2->put_IsCursorCaptureEnabled(false); + } + } + hr = session_->StartCapture(); if (FAILED(hr)) { RTC_LOG(LS_ERROR) << "Failed to start CaptureSession: " << hr; diff --git a/modules/desktop_capture/win/wgc_capture_session.h b/modules/desktop_capture/win/wgc_capture_session.h index 27d412baf9..dfe1fa60bb 100644 --- a/modules/desktop_capture/win/wgc_capture_session.h +++ b/modules/desktop_capture/win/wgc_capture_session.h @@ -39,7 +39,7 @@ class WgcCaptureSession final { ~WgcCaptureSession(); - HRESULT StartCapture(); + HRESULT StartCapture(const DesktopCaptureOptions& options); // Returns a frame from the frame pool, if any are present. HRESULT GetFrame(std::unique_ptr<DesktopFrame>* output_frame); diff --git a/modules/desktop_capture/win/wgc_capturer_win.cc b/modules/desktop_capture/win/wgc_capturer_win.cc index ce5eb6b31f..8ec6a29f23 100644 --- a/modules/desktop_capture/win/wgc_capturer_win.cc +++ b/modules/desktop_capture/win/wgc_capturer_win.cc @@ -140,10 +140,12 @@ bool IsWgcSupported(CaptureType capture_type) { } WgcCapturerWin::WgcCapturerWin( + const DesktopCaptureOptions& options, std::unique_ptr<WgcCaptureSourceFactory> source_factory, std::unique_ptr<SourceEnumerator> source_enumerator, bool allow_delayed_capturable_check) - : source_factory_(std::move(source_factory)), + : options_(options), + source_factory_(std::move(source_factory)), source_enumerator_(std::move(source_enumerator)), allow_delayed_capturable_check_(allow_delayed_capturable_check) { if (!core_messaging_library_) @@ -166,7 +168,7 @@ std::unique_ptr<DesktopCapturer> WgcCapturerWin::CreateRawWindowCapturer( const DesktopCaptureOptions& options, bool allow_delayed_capturable_check) { return std::make_unique<WgcCapturerWin>( - std::make_unique<WgcWindowSourceFactory>(), + options, std::make_unique<WgcWindowSourceFactory>(), std::make_unique<WindowEnumerator>( options.enumerate_current_process_windows()), allow_delayed_capturable_check); @@ -176,7 +178,7 @@ std::unique_ptr<DesktopCapturer> WgcCapturerWin::CreateRawWindowCapturer( std::unique_ptr<DesktopCapturer> WgcCapturerWin::CreateRawScreenCapturer( const DesktopCaptureOptions& options) { return std::make_unique<WgcCapturerWin>( - std::make_unique<WgcScreenSourceFactory>(), + options, std::make_unique<WgcScreenSourceFactory>(), std::make_unique<ScreenEnumerator>(), false); } @@ -309,7 +311,7 @@ void WgcCapturerWin::CaptureFrame() { } if (!capture_session->IsCaptureStarted()) { - hr = capture_session->StartCapture(); + hr = capture_session->StartCapture(options_); if (FAILED(hr)) { RTC_LOG(LS_ERROR) << "Failed to start capture: " << hr; ongoing_captures_.erase(capture_source_->GetSourceId()); @@ -344,7 +346,7 @@ void WgcCapturerWin::CaptureFrame() { capture_time_ms); frame->set_capture_time_ms(capture_time_ms); frame->set_capturer_id(DesktopCapturerId::kWgcCapturerWin); - frame->set_may_contain_cursor(true); + frame->set_may_contain_cursor(options_.prefer_cursor_embedded()); frame->set_top_left(capture_source_->GetTopLeft()); RecordWgcCapturerResult(WgcCapturerResult::kSuccess); callback_->OnCaptureResult(DesktopCapturer::Result::SUCCESS, diff --git a/modules/desktop_capture/win/wgc_capturer_win.h b/modules/desktop_capture/win/wgc_capturer_win.h index d9ee9d3fc6..30253d9db6 100644 --- a/modules/desktop_capture/win/wgc_capturer_win.h +++ b/modules/desktop_capture/win/wgc_capturer_win.h @@ -83,7 +83,8 @@ class ScreenEnumerator final : public SourceEnumerator { // capturer appropriate for the type of source they want to capture. class WgcCapturerWin : public DesktopCapturer { public: - WgcCapturerWin(std::unique_ptr<WgcCaptureSourceFactory> source_factory, + WgcCapturerWin(const DesktopCaptureOptions& options, + std::unique_ptr<WgcCaptureSourceFactory> source_factory, std::unique_ptr<SourceEnumerator> source_enumerator, bool allow_delayed_capturable_check); @@ -114,6 +115,8 @@ class WgcCapturerWin : public DesktopCapturer { DispatcherQueueOptions, ABI::Windows::System::IDispatcherQueueController**); + DesktopCaptureOptions options_; + // We need to either create or ensure that someone else created a // `DispatcherQueue` on the current thread so that events will be delivered // on the current thread rather than an arbitrary thread. A |