Reland "Add about flag for enabling the PipeWire support in WebRTC"
This is a reland of 8788015d2b2efa354c641f4e0ed38fba726f3ae7
Unit tests are fixed in the reland.
Original change's description:
> Add about flag for enabling the PipeWire support in WebRTC
>
> Add a new enable-webrtc-pipewire-capturer about flag, that when
> enabled, will allow to use the PipeWire media server for providing
> the screen content for screen casting when user is running on Wayland
> display server on Linux.
>
> The flag is disabled by default, due to the user experience as it
> involves two extra confirmation dialogs outside of Chromium - requested
> by Weiyong Yao. It could change the default, once it goes through Chromium
> UI review.
>
> Bug: 682122
> Reviewed-on: https://chromium-review.googlesource.com/c/1365444
> Reviewed-by: Weiyong Yao <braveyao@chromium.org>
> Reviewed-by: Jochen Eisinger <jochen@chromium.org>
> Commit-Queue: Tomáš Popela <tomas.popela@gmail.com>
> Cr-Commit-Position: refs/heads/master@{#615886}
Bug: 682122
Change-Id: Ie5d0bf4945f621121c14e95a4addad3afac5bec1
Reviewed-on: https://chromium-review.googlesource.com/c/1402441
Reviewed-by: Weiyong Yao <braveyao@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Tomáš Popela <tomas.popela@gmail.com>
Cr-Commit-Position: refs/heads/master@{#622491}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 1adb1a8a..bcbf67da 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -25,6 +25,7 @@
import("//rlz/buildflags/buildflags.gni")
import("//sandbox/features.gni")
import("//third_party/protobuf/proto_library.gni")
+import("//third_party/webrtc/webrtc.gni")
import("//third_party/widevine/cdm/widevine.gni")
import("//ui/base/ui_features.gni")
@@ -3498,6 +3499,11 @@
"media/webrtc/window_icon_util_ozone.cc",
]
}
+
+ if (rtc_use_pipewire) {
+ configs +=
+ [ "//third_party/webrtc/modules/desktop_capture:pipewire_config" ]
+ }
}
if (is_posix || is_fuchsia) {
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 6031f3f8..b45b5e3 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -1239,6 +1239,12 @@
flag_descriptions::kWebrtcHwVP8EncodingName,
flag_descriptions::kWebrtcHwVP8EncodingDescription, kOsAndroid | kOsCrOS,
FEATURE_VALUE_TYPE(features::kWebRtcHWVP8Encoding)},
+#if defined(WEBRTC_USE_PIPEWIRE)
+ {"enable-webrtc-pipewire-capturer",
+ flag_descriptions::kWebrtcPipeWireCapturerName,
+ flag_descriptions::kWebrtcPipeWireCapturerDescription, kOsLinux,
+ FEATURE_VALUE_TYPE(features::kWebRtcPipeWireCapturer)},
+#endif // defined(WEBRTC_USE_PIPEWIRE)
#if !defined(OS_ANDROID)
{"enable-webrtc-remote-event-log",
flag_descriptions::kWebRtcRemoteEventLogName,
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json
index 0a56fcfa..516216f9 100644
--- a/chrome/browser/flag-metadata.json
+++ b/chrome/browser/flag-metadata.json
@@ -3381,5 +3381,10 @@
"name": "xr-sandbox",
// "owners": [ "your-team" ],
"expiry_milestone": 76
+ },
+ {
+ "name": "enable-webrtc-pipewire-capturer",
+ // "owners": [ "tomas.popela@gmail.com" ],
+ "expiry_milestone": 76
}
]
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index 2d14424..2a7af47 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -3740,6 +3740,15 @@
#endif // BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
+#if defined(WEBRTC_USE_PIPEWIRE)
+
+extern const char kWebrtcPipeWireCapturerName[] = "WebRTC PipeWire support";
+extern const char kWebrtcPipeWireCapturerDescription[] =
+ "When enabled the WebRTC will use the PipeWire multimedia server for "
+ "capturing the desktop content on the Wayland display server.";
+
+#endif // #if defined(WEBRTC_USE_PIPEWIRE)
+
// ============================================================================
// Don't just add flags to the end, put them in the right section in
// alphabetical order just like the header file.
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index 16b9ac2..e60ca20 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -2271,6 +2271,13 @@
#endif // BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
+#if defined(WEBRTC_USE_PIPEWIRE)
+
+extern const char kWebrtcPipeWireCapturerName[];
+extern const char kWebrtcPipeWireCapturerDescription[];
+
+#endif // #if defined(WEBRTC_USE_PIPEWIRE)
+
// ============================================================================
// Don't just add flags to the end, put them in the right section in
// alphabetical order. See top instructions for more.
diff --git a/content/public/browser/BUILD.gn b/content/public/browser/BUILD.gn
index a5d3de71..b0de165 100644
--- a/content/public/browser/BUILD.gn
+++ b/content/public/browser/BUILD.gn
@@ -4,6 +4,7 @@
import("//build/config/jumbo.gni")
import("//build/config/ui.gni")
+import("//third_party/webrtc/webrtc.gni")
# See //content/BUILD.gn for how this works.
group("browser") {
@@ -339,6 +340,11 @@
"//content:content_implementation",
]
+ if (rtc_use_pipewire) {
+ configs +=
+ [ "//third_party/webrtc/modules/desktop_capture:pipewire_config" ]
+ }
+
public_deps = [
"//components/download/public/common:public",
"//content/public/common:common_sources",
diff --git a/content/public/browser/desktop_capture.cc b/content/public/browser/desktop_capture.cc
index 2d41880..95bc55c 100644
--- a/content/public/browser/desktop_capture.cc
+++ b/content/public/browser/desktop_capture.cc
@@ -30,6 +30,11 @@
options.set_allow_iosurface(true);
}
#endif
+#if defined(WEBRTC_USE_PIPEWIRE)
+ if (base::FeatureList::IsEnabled(features::kWebRtcPipeWireCapturer)) {
+ options.set_allow_pipewire(true);
+ }
+#endif // defined(WEBRTC_USE_PIPEWIRE)
return options;
}
diff --git a/content/public/common/BUILD.gn b/content/public/common/BUILD.gn
index f7058c25..f3049d6 100644
--- a/content/public/common/BUILD.gn
+++ b/content/public/common/BUILD.gn
@@ -299,6 +299,11 @@
public_deps += [ "//media/capture/video/chromeos/public" ]
}
+ if (rtc_use_pipewire) {
+ configs +=
+ [ "//third_party/webrtc/modules/desktop_capture:pipewire_config" ]
+ }
+
# //content/common needs to include public headers.
allow_circular_includes_from = [
":interfaces",
diff --git a/content/public/common/content_features.cc b/content/public/common/content_features.cc
index 3c9ef94..521ce76c 100644
--- a/content/public/common/content_features.cc
+++ b/content/public/common/content_features.cc
@@ -704,6 +704,13 @@
base::FEATURE_DISABLED_BY_DEFAULT};
#endif // defined(OS_MACOSX)
+#if defined(WEBRTC_USE_PIPEWIRE)
+// Controls whether the PipeWire support for screen capturing is enabled on the
+// Wayland display server.
+const base::Feature kWebRtcPipeWireCapturer{"WebRTCPipeWireCapturer",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+#endif // defined(WEBRTC_USE_PIPEWIRE)
+
enum class VideoCaptureServiceConfiguration {
kEnabledForOutOfProcess,
kEnabledForBrowserProcess,
diff --git a/content/public/common/content_features.h b/content/public/common/content_features.h
index 5a7731c..d4c77f15b 100644
--- a/content/public/common/content_features.h
+++ b/content/public/common/content_features.h
@@ -168,6 +168,10 @@
CONTENT_EXPORT extern const base::Feature kTextSuggestionsTouchBar;
#endif // defined(OS_MACOSX)
+#if defined(WEBRTC_USE_PIPEWIRE)
+CONTENT_EXPORT extern const base::Feature kWebRtcPipeWireCapturer;
+#endif // defined(WEBRTC_USE_PIPEWIRE)
+
// DON'T ADD RANDOM STUFF HERE. Put it in the main section above in
// alphabetical order, or in one of the ifdefs (also in order in each section).
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml
index c9ad469..abfebea 100644
--- a/tools/metrics/histograms/enums.xml
+++ b/tools/metrics/histograms/enums.xml
@@ -30670,6 +30670,7 @@
<int value="-1433452630" label="AllowRemoteContextForNotifications:enabled"/>
<int value="-1433087548" label="enable-app-install-alerts"/>
<int value="-1431563697" label="WebPaymentsMethodSectionOrderV2:enabled"/>
+ <int value="-1428589407" label="WebRTCPipeWireCapturer:disabled"/>
<int value="-1426817842" label="BlockTabUnders:enabled"/>
<int value="-1426150007" label="ignore-previews-blacklist"/>
<int value="-1426034869" label="NoCreditCardAbort:enabled"/>
@@ -31131,6 +31132,7 @@
<int value="-641719457" label="disable-compositor-touch-hit-testing"/>
<int value="-639026783" label="disable-gpu-appcontainer"/>
<int value="-638952203" label="RendererSideResourceScheduler:disabled"/>
+ <int value="-633274640" label="WebRTCPipeWireCapturer:enabled"/>
<int value="-632030508" label="NativeWindowNavButtons:disabled"/>
<int value="-631740127" label="inert-visual-viewport"/>
<int value="-624221121" label="CommandLineOnNonRooted:enabled"/>