mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Allow splitting PipeWire picker into Screen and Window options
Now that we've added the ability to open and close the PipeWire picker to the DesktopCapture interface, we can split the picker back into a Window and a Screen picker rather than just having the one combined picker. This will allow for a better user experience, as we can create a picker targeted to what the users actually want to share. Bug: chromium:1351570 Change-Id: I5bec22912ae01c1b0b0709a4979b4698226a2a66 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/273541 Reviewed-by: Mark Foltz <mfoltz@chromium.org> Commit-Queue: Alexander Cooper <alcooper@chromium.org> Cr-Commit-Position: refs/heads/main@{#38000}
This commit is contained in:
parent
665875b0d8
commit
07a392eb11
6 changed files with 71 additions and 28 deletions
|
@ -16,6 +16,7 @@
|
|||
#include "modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "screencast_portal.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
@ -27,12 +28,10 @@ using xdg_portal::SessionDetails;
|
|||
|
||||
} // namespace
|
||||
|
||||
BaseCapturerPipeWire::BaseCapturerPipeWire(const DesktopCaptureOptions& options)
|
||||
: BaseCapturerPipeWire(
|
||||
options,
|
||||
std::make_unique<ScreenCastPortal>(
|
||||
ScreenCastPortal::CaptureSourceType::kAnyScreenContent,
|
||||
this)) {
|
||||
BaseCapturerPipeWire::BaseCapturerPipeWire(const DesktopCaptureOptions& options,
|
||||
CaptureType type)
|
||||
: BaseCapturerPipeWire(options,
|
||||
std::make_unique<ScreenCastPortal>(type, this)) {
|
||||
is_screencast_portal_ = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class BaseCapturerPipeWire : public DesktopCapturer,
|
|||
public DelegatedSourceListController,
|
||||
public ScreenCastPortal::PortalNotifier {
|
||||
public:
|
||||
explicit BaseCapturerPipeWire(const DesktopCaptureOptions& options);
|
||||
BaseCapturerPipeWire(const DesktopCaptureOptions& options, CaptureType type);
|
||||
BaseCapturerPipeWire(
|
||||
const DesktopCaptureOptions& options,
|
||||
std::unique_ptr<xdg_portal::ScreenCapturePortalInterface> portal);
|
||||
|
|
|
@ -31,29 +31,62 @@ using xdg_portal::StartSessionRequest;
|
|||
using xdg_portal::TearDownSession;
|
||||
using xdg_portal::RequestResponseFromPortalResponse;
|
||||
|
||||
ScreenCastPortal::CaptureSourceType ToCaptureSourceType(CaptureType type) {
|
||||
switch (type) {
|
||||
case CaptureType::kScreen:
|
||||
return ScreenCastPortal::CaptureSourceType::kScreen;
|
||||
case CaptureType::kWindow:
|
||||
return ScreenCastPortal::CaptureSourceType::kWindow;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(https://crbug.com/1359411): Migrate downstream consumers off of
|
||||
// CaptureSourceType and delete this.
|
||||
CaptureType ToCaptureType(ScreenCastPortal::CaptureSourceType source_type) {
|
||||
switch (source_type) {
|
||||
case ScreenCastPortal::CaptureSourceType::kScreen:
|
||||
return CaptureType::kScreen;
|
||||
case ScreenCastPortal::CaptureSourceType::kWindow:
|
||||
return CaptureType::kWindow;
|
||||
default:
|
||||
RTC_DCHECK_NOTREACHED();
|
||||
return CaptureType::kScreen;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ScreenCastPortal::ScreenCastPortal(
|
||||
ScreenCastPortal::CaptureSourceType source_type,
|
||||
PortalNotifier* notifier)
|
||||
: ScreenCastPortal(source_type,
|
||||
ScreenCastPortal::ScreenCastPortal(CaptureType type, PortalNotifier* notifier)
|
||||
: ScreenCastPortal(type,
|
||||
notifier,
|
||||
OnProxyRequested,
|
||||
OnSourcesRequestResponseSignal,
|
||||
this) {}
|
||||
|
||||
ScreenCastPortal::ScreenCastPortal(
|
||||
CaptureType type,
|
||||
PortalNotifier* notifier,
|
||||
ProxyRequestResponseHandler proxy_request_response_handler,
|
||||
SourcesRequestResponseSignalHandler sources_request_response_signal_handler,
|
||||
gpointer user_data)
|
||||
: notifier_(notifier),
|
||||
capture_source_type_(ToCaptureSourceType(type)),
|
||||
proxy_request_response_handler_(proxy_request_response_handler),
|
||||
sources_request_response_signal_handler_(
|
||||
sources_request_response_signal_handler),
|
||||
user_data_(user_data) {}
|
||||
|
||||
ScreenCastPortal::ScreenCastPortal(
|
||||
CaptureSourceType source_type,
|
||||
PortalNotifier* notifier,
|
||||
ProxyRequestResponseHandler proxy_request_response_handler,
|
||||
SourcesRequestResponseSignalHandler sources_request_response_signal_handler,
|
||||
gpointer user_data)
|
||||
: notifier_(notifier),
|
||||
capture_source_type_(source_type),
|
||||
proxy_request_response_handler_(proxy_request_response_handler),
|
||||
sources_request_response_signal_handler_(
|
||||
sources_request_response_signal_handler),
|
||||
user_data_(user_data) {}
|
||||
: ScreenCastPortal(ToCaptureType(source_type),
|
||||
notifier,
|
||||
proxy_request_response_handler,
|
||||
sources_request_response_signal_handler,
|
||||
user_data) {}
|
||||
|
||||
ScreenCastPortal::~ScreenCastPortal() {
|
||||
Stop();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "modules/desktop_capture/desktop_capture_types.h"
|
||||
#include "modules/desktop_capture/linux/wayland/portal_request_response.h"
|
||||
#include "modules/desktop_capture/linux/wayland/screen_capture_portal_interface.h"
|
||||
#include "modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h"
|
||||
|
@ -40,6 +41,7 @@ class ScreenCastPortal : public xdg_portal::ScreenCapturePortalInterface {
|
|||
// Values are set based on source type property in
|
||||
// xdg-desktop-portal/screencast
|
||||
// https://github.com/flatpak/xdg-desktop-portal/blob/master/data/org.freedesktop.portal.ScreenCast.xml
|
||||
// TODO(https://crbug.com/1359411): Make this private.
|
||||
enum class CaptureSourceType : uint32_t {
|
||||
kScreen = 0b01,
|
||||
kWindow = 0b10,
|
||||
|
@ -86,15 +88,22 @@ class ScreenCastPortal : public xdg_portal::ScreenCapturePortalInterface {
|
|||
virtual ~PortalNotifier() = default;
|
||||
};
|
||||
|
||||
explicit ScreenCastPortal(ScreenCastPortal::CaptureSourceType source_type,
|
||||
PortalNotifier* notifier);
|
||||
explicit ScreenCastPortal(
|
||||
CaptureSourceType source_type,
|
||||
PortalNotifier* notifier,
|
||||
ProxyRequestResponseHandler proxy_request_response_handler,
|
||||
SourcesRequestResponseSignalHandler
|
||||
sources_request_response_signal_handler,
|
||||
gpointer user_data);
|
||||
ScreenCastPortal(CaptureType type, PortalNotifier* notifier);
|
||||
ScreenCastPortal(CaptureType type,
|
||||
PortalNotifier* notifier,
|
||||
ProxyRequestResponseHandler proxy_request_response_handler,
|
||||
SourcesRequestResponseSignalHandler
|
||||
sources_request_response_signal_handler,
|
||||
gpointer user_data);
|
||||
|
||||
// TODO(https://crbug.com/1359411): Migrate downstream consumers off of
|
||||
// CaptureSourceType and delete this.
|
||||
ScreenCastPortal(CaptureSourceType source_type,
|
||||
PortalNotifier* notifier,
|
||||
ProxyRequestResponseHandler proxy_request_response_handler,
|
||||
SourcesRequestResponseSignalHandler
|
||||
sources_request_response_signal_handler,
|
||||
gpointer user_data);
|
||||
~ScreenCastPortal();
|
||||
|
||||
// Initialize ScreenCastPortal with series of DBus calls where we try to
|
||||
|
|
|
@ -28,7 +28,8 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
|
|||
const DesktopCaptureOptions& options) {
|
||||
#if defined(WEBRTC_USE_PIPEWIRE)
|
||||
if (options.allow_pipewire() && DesktopCapturer::IsRunningUnderWayland()) {
|
||||
return std::make_unique<BaseCapturerPipeWire>(options);
|
||||
return std::make_unique<BaseCapturerPipeWire>(options,
|
||||
CaptureType::kScreen);
|
||||
}
|
||||
#endif // defined(WEBRTC_USE_PIPEWIRE)
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer(
|
|||
const DesktopCaptureOptions& options) {
|
||||
#if defined(WEBRTC_USE_PIPEWIRE)
|
||||
if (options.allow_pipewire() && DesktopCapturer::IsRunningUnderWayland()) {
|
||||
return std::make_unique<BaseCapturerPipeWire>(options);
|
||||
return std::make_unique<BaseCapturerPipeWire>(options,
|
||||
CaptureType::kWindow);
|
||||
}
|
||||
#endif // defined(WEBRTC_USE_PIPEWIRE)
|
||||
|
||||
|
|
Loading…
Reference in a new issue