diff --git a/modules/desktop_capture/linux/wayland/screen_capture_portal_interface.h b/modules/desktop_capture/linux/wayland/screen_capture_portal_interface.h index 76cbd276c9..efb2ff2e2b 100644 --- a/modules/desktop_capture/linux/wayland/screen_capture_portal_interface.h +++ b/modules/desktop_capture/linux/wayland/screen_capture_portal_interface.h @@ -20,7 +20,9 @@ namespace xdg_portal { class ScreenCapturePortalInterface { public: virtual ~ScreenCapturePortalInterface() {} + // Gets details about the session such as session handle. virtual xdg_portal::SessionDetails GetSessionDetails() = 0; + // Starts the portal setup. virtual void Start() = 0; }; diff --git a/modules/desktop_capture/linux/wayland/screencast_portal.cc b/modules/desktop_capture/linux/wayland/screencast_portal.cc index ab516a7f4d..eeb691ac3c 100644 --- a/modules/desktop_capture/linux/wayland/screencast_portal.cc +++ b/modules/desktop_capture/linux/wayland/screencast_portal.cc @@ -116,7 +116,7 @@ xdg_portal::SessionDetails ScreenCastPortal::GetSessionDetails() { return {}; // No-op } -void ScreenCastPortal::PortalFailed(RequestResponse result) { +void ScreenCastPortal::OnPortalDone(RequestResponse result) { notifier_->OnScreenCastRequestResult(result, pw_stream_node_id_, pw_fd_); } @@ -240,7 +240,7 @@ void ScreenCastPortal::OnSourcesRequested(GDBusProxy* proxy, if (g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED)) return; RTC_LOG(LS_ERROR) << "Failed to request the sources: " << error->message; - that->PortalFailed(RequestResponse::kError); + that->OnPortalDone(RequestResponse::kError); return; } @@ -255,7 +255,7 @@ void ScreenCastPortal::OnSourcesRequested(GDBusProxy* proxy, that->sources_request_signal_id_); that->sources_request_signal_id_ = 0; } - that->PortalFailed(RequestResponse::kError); + that->OnPortalDone(RequestResponse::kError); return; } @@ -281,7 +281,7 @@ void ScreenCastPortal::OnSourcesRequestResponseSignal( if (portal_response) { RTC_LOG(LS_ERROR) << "Failed to select sources for the screen cast session."; - that->PortalFailed(RequestResponse::kError); + that->OnPortalDone(RequestResponse::kError); return; } @@ -321,7 +321,7 @@ void ScreenCastPortal::OnStartRequestResponseSignal(GDBusConnection* connection, response_data.receive()); if (portal_response || !response_data) { RTC_LOG(LS_ERROR) << "Failed to start the screen cast session."; - that->PortalFailed(static_cast(portal_response)); + that->OnPortalDone(static_cast(portal_response)); return; } @@ -388,7 +388,7 @@ void ScreenCastPortal::OnOpenPipeWireRemoteRequested(GDBusProxy* proxy, return; RTC_LOG(LS_ERROR) << "Failed to open the PipeWire remote: " << error->message; - that->PortalFailed(RequestResponse::kError); + that->OnPortalDone(RequestResponse::kError); return; } @@ -400,12 +400,11 @@ void ScreenCastPortal::OnOpenPipeWireRemoteRequested(GDBusProxy* proxy, if (that->pw_fd_ == -1) { RTC_LOG(LS_ERROR) << "Failed to get file descriptor from the list: " << error->message; - that->PortalFailed(RequestResponse::kError); + that->OnPortalDone(RequestResponse::kError); return; } - that->notifier_->OnScreenCastRequestResult( - RequestResponse::kSuccess, that->pw_stream_node_id_, that->pw_fd_); + that->OnPortalDone(RequestResponse::kSuccess); } } // namespace webrtc diff --git a/modules/desktop_capture/linux/wayland/screencast_portal.h b/modules/desktop_capture/linux/wayland/screencast_portal.h index 3d86006050..a1156947d6 100644 --- a/modules/desktop_capture/linux/wayland/screencast_portal.h +++ b/modules/desktop_capture/linux/wayland/screencast_portal.h @@ -92,7 +92,7 @@ class ScreenCastPortal : public xdg_portal::ScreenCapturePortalInterface { xdg_portal::SessionDetails GetSessionDetails() override; // Method to notify the reason for failure of a portal request. - void PortalFailed(xdg_portal::RequestResponse result); + void OnPortalDone(xdg_portal::RequestResponse result); // Sends a create session request to the portal. void SessionRequest(GDBusProxy* proxy); diff --git a/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.cc b/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.cc index ca98044c97..4fdf54abce 100644 --- a/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.cc +++ b/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.cc @@ -17,6 +17,8 @@ namespace xdg_portal { std::string RequestResponseToString(RequestResponse request) { switch (request) { + case RequestResponse::kUnknown: + return "kUnknown"; case RequestResponse::kSuccess: return "kSuccess"; case RequestResponse::kUserCancelled: diff --git a/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h b/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h index 98979c1f40..c4b3a58096 100644 --- a/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h +++ b/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h @@ -64,6 +64,8 @@ using SessionStartRequestedHandler = void (*)(GDBusProxy*, // Contains type of responses that can be observed when making a request to // a desktop portal interface. enum class RequestResponse { + // Unknown, the initialized status. + kUnknown, // Success, the request is carried out. kSuccess, // The user cancelled the interaction. @@ -133,7 +135,7 @@ void RequestSessionUsingProxy(T* portal, return; RTC_LOG(LS_ERROR) << "Failed to get a proxy for the portal: " << error->message; - portal->PortalFailed(RequestResponse::kError); + portal->OnPortalDone(RequestResponse::kError); return; } @@ -155,7 +157,7 @@ void SessionRequestHandler(T* portal, if (g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED)) return; RTC_LOG(LS_ERROR) << "Failed to session: " << error->message; - portal->PortalFailed(RequestResponse::kError); + portal->OnPortalDone(RequestResponse::kError); return; } @@ -167,7 +169,7 @@ void SessionRequestHandler(T* portal, if (!handle) { RTC_LOG(LS_ERROR) << "Failed to initialize the session."; portal->UnsubscribeSignalHandlers(); - portal->PortalFailed(RequestResponse::kError); + portal->OnPortalDone(RequestResponse::kError); return; } } @@ -192,7 +194,7 @@ void SessionRequestResponseSignalHelper( if (session_handle.empty() || portal_response) { RTC_LOG(LS_ERROR) << "Failed to request the session subscription."; - portal->PortalFailed(RequestResponse::kError); + portal->OnPortalDone(RequestResponse::kError); return; } @@ -213,7 +215,7 @@ void StartRequestedHandler(T* portal, GDBusProxy* proxy, GAsyncResult* result) { return; RTC_LOG(LS_ERROR) << "Failed to start the portal session: " << error->message; - portal->PortalFailed(RequestResponse::kError); + portal->OnPortalDone(RequestResponse::kError); return; } @@ -222,7 +224,7 @@ void StartRequestedHandler(T* portal, GDBusProxy* proxy, GAsyncResult* result) { if (!handle) { RTC_LOG(LS_ERROR) << "Failed to initialize the start portal session."; portal->UnsubscribeSignalHandlers(); - portal->PortalFailed(RequestResponse::kError); + portal->OnPortalDone(RequestResponse::kError); return; }