Commit 870df28b authored by Jan Grulich's avatar Jan Grulich Committed by Chromium LUCI CQ

Improve screen sharing with PipeWire on Linux Wayland session

Current scenario when PipeWire desktop capturer is used:
Chromium picker dialog is created with screen and window capturer. Each
capturer makes an xdg-desktop-portal call, showing another picker
dialog. Once user confirms both pickers on xdg-desktop-portal side, yet
another picker is shown as a new capturer is created for the web page
itself.

With this change:
Chromium picker dialog is created, but only screen capturer will be
created as with xdg-desktop-portal the picker will handle both screens
and windows. Also in the chromium picker, the "window" tab creating
window capturer expects a list of windows and doesn't show previews,
but we need actually to behave exactly like the "screen" tab and show
preview of selected window. Then again, yet another picker from
xdg-desktop-portal is shown as a new capturer is created for the web
page itself.

Bug: chromium:1157006
Change-Id: I39eafc72eb46da7868d1114b5c106030c22787a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2578840
Commit-Queue: mark a. foltz <mfoltz@chromium.org>
Reviewed-by: default avatarmark a. foltz <mfoltz@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836814}
parent f91be88e
...@@ -441,6 +441,7 @@ James Stanley <james@apphaus.co.uk> ...@@ -441,6 +441,7 @@ James Stanley <james@apphaus.co.uk>
James Vega <vega.james@gmail.com> James Vega <vega.james@gmail.com>
James Wei <james.wei@intel.com> James Wei <james.wei@intel.com>
James Willcox <jwillcox@litl.com> James Willcox <jwillcox@litl.com>
Jan Grulich <grulja@gmail.com>
Jan Rucka <ruckajan10@gmail.com> Jan Rucka <ruckajan10@gmail.com>
Jan Sauer <jan@jansauer.de> Jan Sauer <jan@jansauer.de>
Janusz Majnert <jmajnert@gmail.com> Janusz Majnert <jmajnert@gmail.com>
......
...@@ -120,6 +120,14 @@ DesktopCaptureChooseDesktopMediaFunctionBase::Execute( ...@@ -120,6 +120,14 @@ DesktopCaptureChooseDesktopMediaFunctionBase::Execute(
} }
} }
// Avoid offering window-capture as a separate source, since PipeWire's
// content-picker will offer both screen and window sources.
// See crbug.com/1157006.
if (content::desktop_capture::CanUsePipeWire() &&
base::Contains(media_types, content::DesktopMediaID::TYPE_SCREEN)) {
base::Erase(media_types, content::DesktopMediaID::TYPE_WINDOW);
}
DesktopMediaPickerController::DoneCallback callback = base::BindOnce( DesktopMediaPickerController::DoneCallback callback = base::BindOnce(
&DesktopCaptureChooseDesktopMediaFunctionBase::OnPickerDialogResults, &DesktopCaptureChooseDesktopMediaFunctionBase::OnPickerDialogResults,
this, origin, web_contents); this, origin, web_contents);
......
...@@ -216,6 +216,14 @@ void DisplayMediaAccessHandler::ProcessQueuedAccessRequest( ...@@ -216,6 +216,14 @@ void DisplayMediaAccessHandler::ProcessQueuedAccessRequest(
content::DesktopMediaID::TYPE_SCREEN, content::DesktopMediaID::TYPE_SCREEN,
content::DesktopMediaID::TYPE_WINDOW, content::DesktopMediaID::TYPE_WINDOW,
content::DesktopMediaID::TYPE_WEB_CONTENTS}; content::DesktopMediaID::TYPE_WEB_CONTENTS};
// Avoid offering window-capture as a separate source, since PipeWire's
// content-picker will offer both screen and window sources.
// See crbug.com/1157006.
if (content::desktop_capture::CanUsePipeWire()) {
base::Erase(media_types, content::DesktopMediaID::TYPE_WINDOW);
}
auto source_lists = picker_factory_->CreateMediaList(media_types); auto source_lists = picker_factory_->CreateMediaList(media_types);
DesktopMediaPicker::DoneCallback done_callback = DesktopMediaPicker::DoneCallback done_callback =
......
...@@ -65,5 +65,14 @@ std::unique_ptr<webrtc::DesktopCapturer> CreateWindowCapturer() { ...@@ -65,5 +65,14 @@ std::unique_ptr<webrtc::DesktopCapturer> CreateWindowCapturer() {
#endif #endif
} }
bool CanUsePipeWire() {
#if defined(WEBRTC_USE_PIPEWIRE)
return webrtc::DesktopCapturer::IsRunningUnderWayland() &&
base::FeatureList::IsEnabled(features::kWebRtcPipeWireCapturer);
#else
return false;
#endif
}
} // namespace desktop_capture } // namespace desktop_capture
} // namespace content } // namespace content
...@@ -19,6 +19,12 @@ CONTENT_EXPORT webrtc::DesktopCaptureOptions CreateDesktopCaptureOptions(); ...@@ -19,6 +19,12 @@ CONTENT_EXPORT webrtc::DesktopCaptureOptions CreateDesktopCaptureOptions();
CONTENT_EXPORT std::unique_ptr<webrtc::DesktopCapturer> CreateScreenCapturer(); CONTENT_EXPORT std::unique_ptr<webrtc::DesktopCapturer> CreateScreenCapturer();
CONTENT_EXPORT std::unique_ptr<webrtc::DesktopCapturer> CreateWindowCapturer(); CONTENT_EXPORT std::unique_ptr<webrtc::DesktopCapturer> CreateWindowCapturer();
// Returns whether we can use PipeWire capturer based on:
// 1) We run Linux Wayland session
// 2) WebRTC is built with PipeWire enabled
// 3) Chromium has features::kWebRtcPipeWireCapturer enabled
CONTENT_EXPORT bool CanUsePipeWire();
} // namespace desktop_capture } // namespace desktop_capture
} // namespace content } // namespace content
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment