dd1d2c
diff --git a/config/system-headers.mozbuild b/config/system-headers.mozbuild
dd1d2c
index 2081d0c683a4..641133bf1ea4 100644
dd1d2c
--- a/config/system-headers.mozbuild
dd1d2c
+++ b/config/system-headers.mozbuild
dd1d2c
@@ -314,6 +314,7 @@ system_headers = [
dd1d2c
     'Gestalt.h',
dd1d2c
     'getopt.h',
dd1d2c
     'gio/gio.h',
dd1d2c
+    'gio/gunixfdlist.h',
dd1d2c
     'glibconfig.h',
dd1d2c
     'glib.h',
dd1d2c
     'glib-object.h',
dd1d2c
@@ -607,6 +608,7 @@ system_headers = [
dd1d2c
     'Pgenerr.h',
dd1d2c
     'PGenErr.h',
dd1d2c
     'Ph.h',
dd1d2c
+    'pipewire/pipewire.h',
dd1d2c
     'pixman.h',
dd1d2c
     'pk11func.h',
dd1d2c
     'pk11pqg.h',
dd1d2c
diff --git a/media/webrtc/trunk/webrtc/modules/desktop_capture/BUILD.gn b/media/webrtc/trunk/webrtc/modules/desktop_capture/BUILD.gn
dd1d2c
index ba885217b3ba..201d3b755221 100644
dd1d2c
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/BUILD.gn
dd1d2c
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/BUILD.gn
dd1d2c
@@ -158,7 +158,7 @@ if (rtc_include_tests) {
dd1d2c
 if (is_linux) {
dd1d2c
   if (rtc_use_pipewire) {
dd1d2c
     pkg_config("pipewire") {
dd1d2c
-      packages = [ "libpipewire-0.2" ]
dd1d2c
+      packages = [ "libpipewire-0.3" ]
dd1d2c
 
dd1d2c
       defines = [ "WEBRTC_USE_PIPEWIRE" ]
dd1d2c
     }
dd1d2c
diff --git a/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build b/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build
dd1d2c
index 90b40431c7e4..d844aa79d591 100644
dd1d2c
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build
dd1d2c
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build
dd1d2c
@@ -194,6 +194,30 @@ if CONFIG["OS_TARGET"] == "Linux":
dd1d2c
         "/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_linux.cc"
dd1d2c
     ]
dd1d2c
 
dd1d2c
+# PipeWire specific files
dd1d2c
+if CONFIG["OS_TARGET"] == "Linux":
dd1d2c
+
dd1d2c
+    DEFINES["WEBRTC_USE_PIPEWIRE"] = "1"
dd1d2c
+
dd1d2c
+    OS_LIBS += [
dd1d2c
+        "rt",
dd1d2c
+        "pipewire-0.3",
dd1d2c
+        "glib-2.0",
dd1d2c
+        "gio-2.0",
dd1d2c
+        "gobject-2.0"
dd1d2c
+    ]
dd1d2c
+
dd1d2c
+    CXXFLAGS += CONFIG['TK_CFLAGS']
dd1d2c
+    CXXFLAGS += [ "-I/usr/include/pipewire-0.3" ]
dd1d2c
+    CXXFLAGS += [ "-I/usr/include/spa-0.2" ]
dd1d2c
+
dd1d2c
+    UNIFIED_SOURCES += [
dd1d2c
+        "/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc",
dd1d2c
+        "/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc",
dd1d2c
+        "/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc"
dd1d2c
+    ]
dd1d2c
+
dd1d2c
+
dd1d2c
 if CONFIG["OS_TARGET"] == "NetBSD":
dd1d2c
 
dd1d2c
     DEFINES["USE_X11"] = "1"
dd1d2c
diff --git a/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_options.h b/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_options.h
dd1d2c
index 1eb8ead26efa..316468eed1fc 100644
dd1d2c
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_options.h
dd1d2c
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_options.h
dd1d2c
@@ -141,7 +141,7 @@ class DesktopCaptureOptions {
dd1d2c
   bool disable_effects_ = true;
dd1d2c
   bool detect_updated_region_ = false;
dd1d2c
 #if defined(WEBRTC_USE_PIPEWIRE)
dd1d2c
-  bool allow_pipewire_ = false;
dd1d2c
+  bool allow_pipewire_ = true;
dd1d2c
 #endif
dd1d2c
 };
dd1d2c
 
dd1d2c
diff --git a/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc b/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc
dd1d2c
index 379341c833de..76349f1fbd4d 100644
dd1d2c
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc
dd1d2c
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc
dd1d2c
@@ -15,8 +15,11 @@
dd1d2c
 
dd1d2c
 #include <spa/param/format-utils.h>
dd1d2c
 #include <spa/param/props.h>
dd1d2c
-#include <spa/param/video/raw-utils.h>
dd1d2c
-#include <spa/support/type-map.h>
dd1d2c
+
dd1d2c
+#include <linux/dma-buf.h>
dd1d2c
+#include <sys/mman.h>
dd1d2c
+#include <sys/ioctl.h>
dd1d2c
+#include <sys/syscall.h>
dd1d2c
 
dd1d2c
 #include <memory>
dd1d2c
 #include <utility>
dd1d2c
@@ -36,31 +39,36 @@ const char kSessionInterfaceName[] = "org.freedesktop.portal.Session";
dd1d2c
 const char kRequestInterfaceName[] = "org.freedesktop.portal.Request";
dd1d2c
 const char kScreenCastInterfaceName[] = "org.freedesktop.portal.ScreenCast";
dd1d2c
 
dd1d2c
-// static
dd1d2c
-void BaseCapturerPipeWire::OnStateChanged(void* data,
dd1d2c
-                                          pw_remote_state old_state,
dd1d2c
-                                          pw_remote_state state,
dd1d2c
-                                          const char* error_message) {
dd1d2c
-  BaseCapturerPipeWire* that = static_cast<BaseCapturerPipeWire*>(data);
dd1d2c
-  RTC_DCHECK(that);
dd1d2c
 
dd1d2c
-  switch (state) {
dd1d2c
-    case PW_REMOTE_STATE_ERROR:
dd1d2c
-      RTC_LOG(LS_ERROR) << "PipeWire remote state error: " << error_message;
dd1d2c
-      break;
dd1d2c
-    case PW_REMOTE_STATE_CONNECTED:
dd1d2c
-      RTC_LOG(LS_INFO) << "PipeWire remote state: connected.";
dd1d2c
-      that->CreateReceivingStream();
dd1d2c
-      break;
dd1d2c
-    case PW_REMOTE_STATE_CONNECTING:
dd1d2c
-      RTC_LOG(LS_INFO) << "PipeWire remote state: connecting.";
dd1d2c
+// static
dd1d2c
+void BaseCapturerPipeWire::SyncDmaBuf(int fd, uint64_t start_or_end) {
dd1d2c
+  struct dma_buf_sync sync = { 0 };
dd1d2c
+
dd1d2c
+  sync.flags = start_or_end | DMA_BUF_SYNC_READ;
dd1d2c
+
dd1d2c
+  while(true) {
dd1d2c
+    int ret;
dd1d2c
+    ret = ioctl (fd, DMA_BUF_IOCTL_SYNC, &sync);
dd1d2c
+    if (ret == -1 && errno == EINTR) {
dd1d2c
+      continue;
dd1d2c
+    } else if (ret == -1) {
dd1d2c
+      RTC_LOG(LS_ERROR) << "Failed to synchronize DMA buffer: " << g_strerror(errno);
dd1d2c
       break;
dd1d2c
-    case PW_REMOTE_STATE_UNCONNECTED:
dd1d2c
-      RTC_LOG(LS_INFO) << "PipeWire remote state: unconnected.";
dd1d2c
+    } else {
dd1d2c
       break;
dd1d2c
+    }
dd1d2c
   }
dd1d2c
 }
dd1d2c
 
dd1d2c
+// static
dd1d2c
+void BaseCapturerPipeWire::OnCoreError(void *data,
dd1d2c
+                                       uint32_t id,
dd1d2c
+                                       int seq,
dd1d2c
+                                       int res,
dd1d2c
+                                       const char *message) {
dd1d2c
+  RTC_LOG(LS_ERROR) << "core error: " << message;
dd1d2c
+}
dd1d2c
+
dd1d2c
 // static
dd1d2c
 void BaseCapturerPipeWire::OnStreamStateChanged(void* data,
dd1d2c
                                                 pw_stream_state old_state,
dd1d2c
@@ -73,76 +81,54 @@ void BaseCapturerPipeWire::OnStreamStateChanged(void* data,
dd1d2c
     case PW_STREAM_STATE_ERROR:
dd1d2c
       RTC_LOG(LS_ERROR) << "PipeWire stream state error: " << error_message;
dd1d2c
       break;
dd1d2c
-    case PW_STREAM_STATE_CONFIGURE:
dd1d2c
-      pw_stream_set_active(that->pw_stream_, true);
dd1d2c
-      break;
dd1d2c
-    case PW_STREAM_STATE_UNCONNECTED:
dd1d2c
-    case PW_STREAM_STATE_CONNECTING:
dd1d2c
-    case PW_STREAM_STATE_READY:
dd1d2c
     case PW_STREAM_STATE_PAUSED:
dd1d2c
     case PW_STREAM_STATE_STREAMING:
dd1d2c
+    case PW_STREAM_STATE_UNCONNECTED:
dd1d2c
+    case PW_STREAM_STATE_CONNECTING:
dd1d2c
       break;
dd1d2c
   }
dd1d2c
 }
dd1d2c
 
dd1d2c
 // static
dd1d2c
-void BaseCapturerPipeWire::OnStreamFormatChanged(void* data,
dd1d2c
-                                                 const struct spa_pod* format) {
dd1d2c
+void BaseCapturerPipeWire::OnStreamParamChanged(void *data, uint32_t id,
dd1d2c
+                                                const struct spa_pod *format) {
dd1d2c
   BaseCapturerPipeWire* that = static_cast<BaseCapturerPipeWire*>(data);
dd1d2c
   RTC_DCHECK(that);
dd1d2c
 
dd1d2c
-  RTC_LOG(LS_INFO) << "PipeWire stream format changed.";
dd1d2c
+  RTC_LOG(LS_INFO) << "PipeWire stream param changed.";
dd1d2c
 
dd1d2c
-  if (!format) {
dd1d2c
-    pw_stream_finish_format(that->pw_stream_, /*res=*/0, /*params=*/nullptr,
dd1d2c
-                            /*n_params=*/0);
dd1d2c
+  if (!format || id != SPA_PARAM_Format) {
dd1d2c
     return;
dd1d2c
   }
dd1d2c
 
dd1d2c
-  that->spa_video_format_ = new spa_video_info_raw();
dd1d2c
-  spa_format_video_raw_parse(format, that->spa_video_format_,
dd1d2c
-                             &that->pw_type_->format_video);
dd1d2c
+  spa_format_video_raw_parse(format, &that->spa_video_format_);
dd1d2c
 
dd1d2c
-  auto width = that->spa_video_format_->size.width;
dd1d2c
-  auto height = that->spa_video_format_->size.height;
dd1d2c
+  auto width = that->spa_video_format_.size.width;
dd1d2c
+  auto height = that->spa_video_format_.size.height;
dd1d2c
   auto stride = SPA_ROUND_UP_N(width * kBytesPerPixel, 4);
dd1d2c
   auto size = height * stride;
dd1d2c
 
dd1d2c
+  that->desktop_size_ = DesktopSize(width, height);
dd1d2c
+
dd1d2c
   uint8_t buffer[1024] = {};
dd1d2c
   auto builder = spa_pod_builder{buffer, sizeof(buffer)};
dd1d2c
 
dd1d2c
   // Setup buffers and meta header for new format.
dd1d2c
-  const struct spa_pod* params[2];
dd1d2c
-  params[0] = reinterpret_cast<spa_pod*>(spa_pod_builder_object(
dd1d2c
-      &builder,
dd1d2c
-      // id to enumerate buffer requirements
dd1d2c
-      that->pw_core_type_->param.idBuffers,
dd1d2c
-      that->pw_core_type_->param_buffers.Buffers,
dd1d2c
-      // Size: specified as integer (i) and set to specified size
dd1d2c
-      ":", that->pw_core_type_->param_buffers.size, "i", size,
dd1d2c
-      // Stride: specified as integer (i) and set to specified stride
dd1d2c
-      ":", that->pw_core_type_->param_buffers.stride, "i", stride,
dd1d2c
-      // Buffers: specifies how many buffers we want to deal with, set as
dd1d2c
-      // integer (i) where preferred number is 8, then allowed number is defined
dd1d2c
-      // as range (r) from min and max values and it is undecided (u) to allow
dd1d2c
-      // negotiation
dd1d2c
-      ":", that->pw_core_type_->param_buffers.buffers, "iru", 8,
dd1d2c
-      SPA_POD_PROP_MIN_MAX(1, 32),
dd1d2c
-      // Align: memory alignment of the buffer, set as integer (i) to specified
dd1d2c
-      // value
dd1d2c
-      ":", that->pw_core_type_->param_buffers.align, "i", 16));
dd1d2c
-  params[1] = reinterpret_cast<spa_pod*>(spa_pod_builder_object(
dd1d2c
-      &builder,
dd1d2c
-      // id to enumerate supported metadata
dd1d2c
-      that->pw_core_type_->param.idMeta, that->pw_core_type_->param_meta.Meta,
dd1d2c
-      // Type: specified as id or enum (I)
dd1d2c
-      ":", that->pw_core_type_->param_meta.type, "I",
dd1d2c
-      that->pw_core_type_->meta.Header,
dd1d2c
-      // Size: size of the metadata, specified as integer (i)
dd1d2c
-      ":", that->pw_core_type_->param_meta.size, "i",
dd1d2c
-      sizeof(struct spa_meta_header)));
dd1d2c
-
dd1d2c
-  pw_stream_finish_format(that->pw_stream_, /*res=*/0, params, /*n_params=*/2);
dd1d2c
+  const struct spa_pod* params[3];
dd1d2c
+  params[0] = reinterpret_cast<spa_pod *>(spa_pod_builder_add_object(&builder,
dd1d2c
+              SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
dd1d2c
+              SPA_PARAM_BUFFERS_size, SPA_POD_Int(size),
dd1d2c
+              SPA_PARAM_BUFFERS_stride, SPA_POD_Int(stride),
dd1d2c
+              SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(8, 1, 32)));
dd1d2c
+  params[1] = reinterpret_cast<spa_pod *>(spa_pod_builder_add_object(&builder,
dd1d2c
+              SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
dd1d2c
+              SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Header),
dd1d2c
+              SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_header))));
dd1d2c
+  params[2] = reinterpret_cast<spa_pod *>(spa_pod_builder_add_object(&builder,
dd1d2c
+              SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
dd1d2c
+              SPA_PARAM_META_type, SPA_POD_Id (SPA_META_VideoCrop),
dd1d2c
+              SPA_PARAM_META_size, SPA_POD_Int (sizeof(struct spa_meta_region))));
dd1d2c
+  pw_stream_update_params(that->pw_stream_, params, 3);
dd1d2c
 }
dd1d2c
 
dd1d2c
 // static
dd1d2c
@@ -150,15 +136,25 @@ void BaseCapturerPipeWire::OnStreamProcess(void* data) {
dd1d2c
   BaseCapturerPipeWire* that = static_cast<BaseCapturerPipeWire*>(data);
dd1d2c
   RTC_DCHECK(that);
dd1d2c
 
dd1d2c
-  pw_buffer* buf = nullptr;
dd1d2c
+  struct pw_buffer *next_buffer;
dd1d2c
+  struct pw_buffer *buffer = nullptr;
dd1d2c
+
dd1d2c
+  next_buffer = pw_stream_dequeue_buffer(that->pw_stream_);
dd1d2c
+  while (next_buffer) {
dd1d2c
+    buffer = next_buffer;
dd1d2c
+    next_buffer = pw_stream_dequeue_buffer(that->pw_stream_);
dd1d2c
 
dd1d2c
-  if (!(buf = pw_stream_dequeue_buffer(that->pw_stream_))) {
dd1d2c
+    if (next_buffer)
dd1d2c
+      pw_stream_queue_buffer (that->pw_stream_, buffer);
dd1d2c
+  }
dd1d2c
+
dd1d2c
+  if (!buffer) {
dd1d2c
     return;
dd1d2c
   }
dd1d2c
 
dd1d2c
-  that->HandleBuffer(buf);
dd1d2c
+  that->HandleBuffer(buffer);
dd1d2c
 
dd1d2c
-  pw_stream_queue_buffer(that->pw_stream_, buf);
dd1d2c
+  pw_stream_queue_buffer(that->pw_stream_, buffer);
dd1d2c
 }
dd1d2c
 
dd1d2c
 BaseCapturerPipeWire::BaseCapturerPipeWire(CaptureSourceType source_type)
dd1d2c
@@ -169,38 +165,22 @@ BaseCapturerPipeWire::~BaseCapturerPipeWire() {
dd1d2c
     pw_thread_loop_stop(pw_main_loop_);
dd1d2c
   }
dd1d2c
 
dd1d2c
-  if (pw_type_) {
dd1d2c
-    delete pw_type_;
dd1d2c
-  }
dd1d2c
-
dd1d2c
-  if (spa_video_format_) {
dd1d2c
-    delete spa_video_format_;
dd1d2c
-  }
dd1d2c
-
dd1d2c
   if (pw_stream_) {
dd1d2c
     pw_stream_destroy(pw_stream_);
dd1d2c
   }
dd1d2c
 
dd1d2c
-  if (pw_remote_) {
dd1d2c
-    pw_remote_destroy(pw_remote_);
dd1d2c
+  if (pw_core_) {
dd1d2c
+    pw_core_disconnect(pw_core_);
dd1d2c
   }
dd1d2c
 
dd1d2c
-  if (pw_core_) {
dd1d2c
-    pw_core_destroy(pw_core_);
dd1d2c
+  if (pw_context_) {
dd1d2c
+    pw_context_destroy(pw_context_);
dd1d2c
   }
dd1d2c
 
dd1d2c
   if (pw_main_loop_) {
dd1d2c
     pw_thread_loop_destroy(pw_main_loop_);
dd1d2c
   }
dd1d2c
 
dd1d2c
-  if (pw_loop_) {
dd1d2c
-    pw_loop_destroy(pw_loop_);
dd1d2c
-  }
dd1d2c
-
dd1d2c
-  if (current_frame_) {
dd1d2c
-    free(current_frame_);
dd1d2c
-  }
dd1d2c
-
dd1d2c
   if (start_request_signal_id_) {
dd1d2c
     g_dbus_connection_signal_unsubscribe(connection_, start_request_signal_id_);
dd1d2c
   }
dd1d2c
@@ -250,27 +230,35 @@ void BaseCapturerPipeWire::InitPortal() {
dd1d2c
 void BaseCapturerPipeWire::InitPipeWire() {
dd1d2c
   pw_init(/*argc=*/nullptr, /*argc=*/nullptr);
dd1d2c
 
dd1d2c
-  pw_loop_ = pw_loop_new(/*properties=*/nullptr);
dd1d2c
-  pw_main_loop_ = pw_thread_loop_new(pw_loop_, "pipewire-main-loop");
dd1d2c
-
dd1d2c
-  pw_core_ = pw_core_new(pw_loop_, /*properties=*/nullptr);
dd1d2c
-  pw_core_type_ = pw_core_get_type(pw_core_);
dd1d2c
-  pw_remote_ = pw_remote_new(pw_core_, nullptr, /*user_data_size=*/0);
dd1d2c
+  pw_main_loop_ = pw_thread_loop_new("pipewire-main-loop", nullptr);
dd1d2c
+  pw_context_ = pw_context_new(pw_thread_loop_get_loop(pw_main_loop_), nullptr, 0);
dd1d2c
+  if (!pw_context_) {
dd1d2c
+    RTC_LOG(LS_ERROR) << "Failed to create PipeWire context";
dd1d2c
+    return;
dd1d2c
+  }
dd1d2c
 
dd1d2c
-  InitPipeWireTypes();
dd1d2c
+  pw_core_ = pw_context_connect(pw_context_, nullptr, 0);
dd1d2c
+  if (!pw_core_) {
dd1d2c
+    RTC_LOG(LS_ERROR) << "Failed to connect PipeWire context";
dd1d2c
+    return;
dd1d2c
+  }
dd1d2c
 
dd1d2c
   // Initialize event handlers, remote end and stream-related.
dd1d2c
-  pw_remote_events_.version = PW_VERSION_REMOTE_EVENTS;
dd1d2c
-  pw_remote_events_.state_changed = &OnStateChanged;
dd1d2c
+  pw_core_events_.version = PW_VERSION_CORE_EVENTS;
dd1d2c
+  pw_core_events_.error = &OnCoreError;
dd1d2c
 
dd1d2c
   pw_stream_events_.version = PW_VERSION_STREAM_EVENTS;
dd1d2c
   pw_stream_events_.state_changed = &OnStreamStateChanged;
dd1d2c
-  pw_stream_events_.format_changed = &OnStreamFormatChanged;
dd1d2c
+  pw_stream_events_.param_changed = &OnStreamParamChanged;
dd1d2c
   pw_stream_events_.process = &OnStreamProcess;
dd1d2c
 
dd1d2c
-  pw_remote_add_listener(pw_remote_, &spa_remote_listener_, &pw_remote_events_,
dd1d2c
-                         this);
dd1d2c
-  pw_remote_connect_fd(pw_remote_, pw_fd_);
dd1d2c
+  pw_core_add_listener(pw_core_, &spa_core_listener_, &pw_core_events_, this);
dd1d2c
+
dd1d2c
+  pw_stream_ = CreateReceivingStream();
dd1d2c
+  if (!pw_stream_) {
dd1d2c
+    RTC_LOG(LS_ERROR) << "Failed to create PipeWire stream";
dd1d2c
+    return;
dd1d2c
+  }
dd1d2c
 
dd1d2c
   if (pw_thread_loop_start(pw_main_loop_) < 0) {
dd1d2c
     RTC_LOG(LS_ERROR) << "Failed to start main PipeWire loop";
dd1d2c
@@ -278,81 +266,132 @@ void BaseCapturerPipeWire::InitPipeWire() {
dd1d2c
   }
dd1d2c
 }
dd1d2c
 
dd1d2c
-void BaseCapturerPipeWire::InitPipeWireTypes() {
dd1d2c
-  spa_type_map* map = pw_core_type_->map;
dd1d2c
-  pw_type_ = new PipeWireType();
dd1d2c
-
dd1d2c
-  spa_type_media_type_map(map, &pw_type_->media_type);
dd1d2c
-  spa_type_media_subtype_map(map, &pw_type_->media_subtype);
dd1d2c
-  spa_type_format_video_map(map, &pw_type_->format_video);
dd1d2c
-  spa_type_video_format_map(map, &pw_type_->video_format);
dd1d2c
-}
dd1d2c
-
dd1d2c
-void BaseCapturerPipeWire::CreateReceivingStream() {
dd1d2c
+pw_stream* BaseCapturerPipeWire::CreateReceivingStream() {
dd1d2c
   spa_rectangle pwMinScreenBounds = spa_rectangle{1, 1};
dd1d2c
-  spa_rectangle pwScreenBounds =
dd1d2c
-      spa_rectangle{static_cast<uint32_t>(desktop_size_.width()),
dd1d2c
-                    static_cast<uint32_t>(desktop_size_.height())};
dd1d2c
+  spa_rectangle pwMaxScreenBounds = spa_rectangle{INT32_MAX, INT32_MAX};
dd1d2c
 
dd1d2c
-  spa_fraction pwFrameRateMin = spa_fraction{0, 1};
dd1d2c
-  spa_fraction pwFrameRateMax = spa_fraction{60, 1};
dd1d2c
+  auto stream = pw_stream_new(pw_core_, "webrtc-pipewire-stream", nullptr);
dd1d2c
 
dd1d2c
-  pw_properties* reuseProps = pw_properties_new("pipewire.client.reuse", "1",
dd1d2c
-                                                /*end of varargs*/ nullptr);
dd1d2c
-  pw_stream_ = pw_stream_new(pw_remote_, "webrtc-consume-stream", reuseProps);
dd1d2c
+  if (!stream) {
dd1d2c
+    RTC_LOG(LS_ERROR) << "Could not create receiving stream.";
dd1d2c
+    return nullptr;
dd1d2c
+  }
dd1d2c
 
dd1d2c
   uint8_t buffer[1024] = {};
dd1d2c
-  const spa_pod* params[1];
dd1d2c
-  spa_pod_builder builder = spa_pod_builder{buffer, sizeof(buffer)};
dd1d2c
-  params[0] = reinterpret_cast<spa_pod*>(spa_pod_builder_object(
dd1d2c
-      &builder,
dd1d2c
-      // id to enumerate formats
dd1d2c
-      pw_core_type_->param.idEnumFormat, pw_core_type_->spa_format, "I",
dd1d2c
-      pw_type_->media_type.video, "I", pw_type_->media_subtype.raw,
dd1d2c
-      // Video format: specified as id or enum (I), preferred format is BGRx,
dd1d2c
-      // then allowed formats are enumerated (e) and the format is undecided (u)
dd1d2c
-      // to allow negotiation
dd1d2c
-      ":", pw_type_->format_video.format, "Ieu", pw_type_->video_format.BGRx,
dd1d2c
-      SPA_POD_PROP_ENUM(2, pw_type_->video_format.RGBx,
dd1d2c
-                        pw_type_->video_format.BGRx),
dd1d2c
-      // Video size: specified as rectangle (R), preferred size is specified as
dd1d2c
-      // first parameter, then allowed size is defined as range (r) from min and
dd1d2c
-      // max values and the format is undecided (u) to allow negotiation
dd1d2c
-      ":", pw_type_->format_video.size, "Rru", &pwScreenBounds, 2,
dd1d2c
-      &pwMinScreenBounds, &pwScreenBounds,
dd1d2c
-      // Frame rate: specified as fraction (F) and set to minimum frame rate
dd1d2c
-      // value
dd1d2c
-      ":", pw_type_->format_video.framerate, "F", &pwFrameRateMin,
dd1d2c
-      // Max frame rate: specified as fraction (F), preferred frame rate is set
dd1d2c
-      // to maximum value, then allowed frame rate is defined as range (r) from
dd1d2c
-      // min and max values and it is undecided (u) to allow negotiation
dd1d2c
-      ":", pw_type_->format_video.max_framerate, "Fru", &pwFrameRateMax, 2,
dd1d2c
-      &pwFrameRateMin, &pwFrameRateMax));
dd1d2c
-
dd1d2c
-  pw_stream_add_listener(pw_stream_, &spa_stream_listener_, &pw_stream_events_,
dd1d2c
-                         this);
dd1d2c
+  const spa_pod* params[2];
dd1d2c
+  spa_pod_builder builder = SPA_POD_BUILDER_INIT(buffer, sizeof (buffer));
dd1d2c
+
dd1d2c
+  params[0] = reinterpret_cast<spa_pod *>(spa_pod_builder_add_object(&builder,
dd1d2c
+              SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
dd1d2c
+              SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_video),
dd1d2c
+              SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
dd1d2c
+              SPA_FORMAT_VIDEO_format, SPA_POD_CHOICE_ENUM_Id(5, SPA_VIDEO_FORMAT_BGRx, SPA_VIDEO_FORMAT_RGBx, SPA_VIDEO_FORMAT_RGBA,
dd1d2c
+                                                                 SPA_VIDEO_FORMAT_BGRx, SPA_VIDEO_FORMAT_BGRA),
dd1d2c
+              SPA_FORMAT_VIDEO_size, SPA_POD_CHOICE_RANGE_Rectangle(&pwMinScreenBounds,
dd1d2c
+                                                                    &pwMinScreenBounds,
dd1d2c
+                                                                    &pwMaxScreenBounds),
dd1d2c
+              0));
dd1d2c
+  pw_stream_add_listener(stream, &spa_stream_listener_, &pw_stream_events_, this);
dd1d2c
+
dd1d2c
   pw_stream_flags flags = static_cast<pw_stream_flags>(
dd1d2c
-      PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_INACTIVE |
dd1d2c
-      PW_STREAM_FLAG_MAP_BUFFERS);
dd1d2c
-  if (pw_stream_connect(pw_stream_, PW_DIRECTION_INPUT, /*port_path=*/nullptr,
dd1d2c
-                        flags, params,
dd1d2c
-                        /*n_params=*/1) != 0) {
dd1d2c
+      PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_INACTIVE);
dd1d2c
+
dd1d2c
+  if (pw_stream_connect(stream, PW_DIRECTION_INPUT, pw_stream_node_id_, PW_STREAM_FLAG_AUTOCONNECT, params, 1) != 0) {
dd1d2c
     RTC_LOG(LS_ERROR) << "Could not connect receiving stream.";
dd1d2c
     portal_init_failed_ = true;
dd1d2c
-    return;
dd1d2c
   }
dd1d2c
+
dd1d2c
+  return stream;
dd1d2c
 }
dd1d2c
 
dd1d2c
 void BaseCapturerPipeWire::HandleBuffer(pw_buffer* buffer) {
dd1d2c
+  struct spa_meta_region* video_crop;
dd1d2c
   spa_buffer* spaBuffer = buffer->buffer;
dd1d2c
-  void* src = nullptr;
dd1d2c
+  uint8_t *map = nullptr;
dd1d2c
+  uint8_t* src = nullptr;
dd1d2c
+  uint8_t* dst = nullptr;
dd1d2c
+
dd1d2c
+  if (spaBuffer->datas[0].chunk->size == 0) {
dd1d2c
+    map = nullptr;
dd1d2c
+    src = nullptr;
dd1d2c
+  } else if (spaBuffer->datas[0].type == SPA_DATA_MemFd) {
dd1d2c
+    map = static_cast<uint8_t*>(mmap(
dd1d2c
+        nullptr, spaBuffer->datas[0].maxsize + spaBuffer->datas[0].mapoffset,
dd1d2c
+        PROT_READ, MAP_PRIVATE, spaBuffer->datas[0].fd, 0));
dd1d2c
+
dd1d2c
+    if (map == MAP_FAILED) {
dd1d2c
+      RTC_LOG(LS_ERROR) << "Failed to mmap the memory: " << std::strerror(errno);
dd1d2c
+      return;
dd1d2c
+    }
dd1d2c
+
dd1d2c
+    src = SPA_MEMBER(map, spaBuffer->datas[0].mapoffset, uint8_t);
dd1d2c
+  } else if (spaBuffer->datas[0].type == SPA_DATA_DmaBuf) {
dd1d2c
+    int fd;
dd1d2c
+    fd = spaBuffer->datas[0].fd;
dd1d2c
 
dd1d2c
-  if (!(src = spaBuffer->datas[0].data)) {
dd1d2c
+    map = static_cast<uint8_t*>(mmap(
dd1d2c
+        nullptr, spaBuffer->datas[0].maxsize + spaBuffer->datas[0].mapoffset,
dd1d2c
+        PROT_READ, MAP_PRIVATE, fd, 0));
dd1d2c
+
dd1d2c
+    if (map == MAP_FAILED) {
dd1d2c
+      RTC_LOG(LS_ERROR) << "Failed to mmap the memory: " << std::strerror(errno);
dd1d2c
+      return;
dd1d2c
+    }
dd1d2c
+
dd1d2c
+    SyncDmaBuf(fd, DMA_BUF_SYNC_START);
dd1d2c
+
dd1d2c
+    src = SPA_MEMBER(map, spaBuffer->datas[0].mapoffset, uint8_t);
dd1d2c
+  } else if (spaBuffer->datas[0].type == SPA_DATA_MemPtr) {
dd1d2c
+    map = nullptr;
dd1d2c
+    src = static_cast<uint8_t*>(spaBuffer->datas[0].data);
dd1d2c
+  } else {
dd1d2c
     return;
dd1d2c
   }
dd1d2c
 
dd1d2c
-  uint32_t maxSize = spaBuffer->datas[0].maxsize;
dd1d2c
-  int32_t srcStride = spaBuffer->datas[0].chunk->stride;
dd1d2c
+  if (!src) {
dd1d2c
+    return;
dd1d2c
+  }
dd1d2c
+
dd1d2c
+  DesktopSize prev_crop_size = DesktopSize(0, 0);
dd1d2c
+  if (video_crop_size_initialized_) {
dd1d2c
+    prev_crop_size = video_crop_size_;
dd1d2c
+  }  
dd1d2c
+
dd1d2c
+  if ((video_crop = static_cast<struct spa_meta_region*>(
dd1d2c
+           spa_buffer_find_meta_data(spaBuffer, SPA_META_VideoCrop, sizeof(*video_crop))))) {
dd1d2c
+    RTC_DCHECK(video_crop->region.size.width <= desktop_size_.width() &&
dd1d2c
+               video_crop->region.size.height <= desktop_size_.height());
dd1d2c
+    if ((video_crop->region.size.width != desktop_size_.width() ||
dd1d2c
+        video_crop->region.size.height != desktop_size_.height()) && video_crop->region.size.width && video_crop->region.size.height) {
dd1d2c
+      video_crop_size_ = DesktopSize(video_crop->region.size.width, video_crop->region.size.height);
dd1d2c
+      video_crop_size_initialized_ = true;
dd1d2c
+    } else {
dd1d2c
+      video_crop_size_initialized_ = false;
dd1d2c
+    }
dd1d2c
+  } else {
dd1d2c
+    video_crop_size_initialized_ = false;
dd1d2c
+  }
dd1d2c
+
dd1d2c
+  size_t frame_size;
dd1d2c
+  if (video_crop_size_initialized_) {
dd1d2c
+    frame_size =
dd1d2c
+        video_crop_size_.width() * video_crop_size_.height() * kBytesPerPixel;
dd1d2c
+  } else {
dd1d2c
+    frame_size =
dd1d2c
+        desktop_size_.width() * desktop_size_.height() * kBytesPerPixel;
dd1d2c
+  }
dd1d2c
+
dd1d2c
+  if (!current_frame_ ||
dd1d2c
+      (video_crop_size_initialized_ && !video_crop_size_.equals(prev_crop_size))) {
dd1d2c
+    current_frame_ = std::make_unique<uint8_t[]>(frame_size);
dd1d2c
+  }
dd1d2c
+  RTC_DCHECK(current_frame_ != nullptr);
dd1d2c
+
dd1d2c
+  const int32_t dstStride = video_crop_size_initialized_
dd1d2c
+                                ? video_crop_size_.width() * kBytesPerPixel
dd1d2c
+                                : desktop_size_.width() * kBytesPerPixel;
dd1d2c
+  const int32_t srcStride = spaBuffer->datas[0].chunk->stride;
dd1d2c
+
dd1d2c
   if (srcStride != (desktop_size_.width() * kBytesPerPixel)) {
dd1d2c
     RTC_LOG(LS_ERROR) << "Got buffer with stride different from screen stride: "
dd1d2c
                       << srcStride
dd1d2c
@@ -361,21 +400,40 @@ void BaseCapturerPipeWire::HandleBuffer(pw_buffer* buffer) {
dd1d2c
     return;
dd1d2c
   }
dd1d2c
 
dd1d2c
-  if (!current_frame_) {
dd1d2c
-    current_frame_ = static_cast<uint8_t*>(malloc(maxSize));
dd1d2c
+  dst = current_frame_.get();
dd1d2c
+
dd1d2c
+  // Adjust source content based on crop video position
dd1d2c
+  if (video_crop_size_initialized_ &&
dd1d2c
+      (video_crop->region.position.y + video_crop_size_.height() <= desktop_size_.height())) {
dd1d2c
+    for (int i = 0; i < video_crop->region.position.y; ++i) {
dd1d2c
+      src += srcStride;
dd1d2c
+    }
dd1d2c
+  }
dd1d2c
+  const int xOffset =
dd1d2c
+      video_crop_size_initialized_ && (video_crop->region.position.x + video_crop_size_.width() <=
dd1d2c
+                           desktop_size_.width())
dd1d2c
+          ? video_crop->region.position.x * kBytesPerPixel
dd1d2c
+          : 0;
dd1d2c
+  const int height = video_crop_size_initialized_ ? video_crop_size_.height() : desktop_size_.height();
dd1d2c
+  for (int i = 0; i < height; ++i) {
dd1d2c
+    // Adjust source content based on crop video position if needed
dd1d2c
+    src += xOffset;
dd1d2c
+    std::memcpy(dst, src, dstStride);
dd1d2c
+    // If both sides decided to go with the RGBx format we need to convert it to
dd1d2c
+    // BGRx to match color format expected by WebRTC.
dd1d2c
+    if (spa_video_format_.format == SPA_VIDEO_FORMAT_RGBx ||
dd1d2c
+        spa_video_format_.format == SPA_VIDEO_FORMAT_RGBA) {
dd1d2c
+      ConvertRGBxToBGRx(dst, dstStride);
dd1d2c
+    }
dd1d2c
+    src += srcStride - xOffset;
dd1d2c
+    dst += dstStride;
dd1d2c
   }
dd1d2c
-  RTC_DCHECK(current_frame_ != nullptr);
dd1d2c
 
dd1d2c
-  // If both sides decided to go with the RGBx format we need to convert it to
dd1d2c
-  // BGRx to match color format expected by WebRTC.
dd1d2c
-  if (spa_video_format_->format == pw_type_->video_format.RGBx) {
dd1d2c
-    uint8_t* tempFrame = static_cast<uint8_t*>(malloc(maxSize));
dd1d2c
-    std::memcpy(tempFrame, src, maxSize);
dd1d2c
-    ConvertRGBxToBGRx(tempFrame, maxSize);
dd1d2c
-    std::memcpy(current_frame_, tempFrame, maxSize);
dd1d2c
-    free(tempFrame);
dd1d2c
-  } else {
dd1d2c
-    std::memcpy(current_frame_, src, maxSize);
dd1d2c
+  if (map) {
dd1d2c
+    if (spaBuffer->datas[0].type == SPA_DATA_DmaBuf) {
dd1d2c
+      SyncDmaBuf(spaBuffer->datas[0].fd, DMA_BUF_SYNC_END);
dd1d2c
+    }
dd1d2c
+    munmap(map, spaBuffer->datas[0].maxsize + spaBuffer->datas[0].mapoffset);
dd1d2c
   }
dd1d2c
 }
dd1d2c
 
dd1d2c
@@ -725,10 +783,7 @@ void BaseCapturerPipeWire::OnStartRequestResponseSignal(
dd1d2c
       g_variant_get(variant, "(u@a{sv})", &stream_id, &options);
dd1d2c
       RTC_DCHECK(options != nullptr);
dd1d2c
 
dd1d2c
-      g_variant_lookup(options, "size", "(ii)", &width, &height);
dd1d2c
-
dd1d2c
-      that->desktop_size_.set(width, height);
dd1d2c
-
dd1d2c
+      that->pw_stream_node_id_ = stream_id;
dd1d2c
       g_variant_unref(options);
dd1d2c
       g_variant_unref(variant);
dd1d2c
     }
dd1d2c
@@ -813,10 +868,15 @@ void BaseCapturerPipeWire::CaptureFrame() {
dd1d2c
     return;
dd1d2c
   }
dd1d2c
 
dd1d2c
-  std::unique_ptr<DesktopFrame> result(new BasicDesktopFrame(desktop_size_));
dd1d2c
+  DesktopSize frame_size = desktop_size_;
dd1d2c
+  if (video_crop_size_initialized_) {
dd1d2c
+    frame_size = video_crop_size_;
dd1d2c
+  }
dd1d2c
+  
dd1d2c
+  std::unique_ptr<DesktopFrame> result(new BasicDesktopFrame(frame_size));
dd1d2c
   result->CopyPixelsFrom(
dd1d2c
-      current_frame_, (desktop_size_.width() * kBytesPerPixel),
dd1d2c
-      DesktopRect::MakeWH(desktop_size_.width(), desktop_size_.height()));
dd1d2c
+      current_frame_.get(), (frame_size.width() * kBytesPerPixel),
dd1d2c
+      DesktopRect::MakeWH(frame_size.width(), frame_size.height()));
dd1d2c
   if (!result) {
dd1d2c
     callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr);
dd1d2c
     return;
dd1d2c
@@ -837,4 +897,22 @@ bool BaseCapturerPipeWire::SelectSource(SourceId id) {
dd1d2c
   return true;
dd1d2c
 }
dd1d2c
 
dd1d2c
+// static
dd1d2c
+std::unique_ptr<DesktopCapturer>
dd1d2c
+BaseCapturerPipeWire::CreateRawScreenCapturer(
dd1d2c
+    const DesktopCaptureOptions& options) {
dd1d2c
+  std::unique_ptr<BaseCapturerPipeWire> capturer =
dd1d2c
+      std::make_unique<BaseCapturerPipeWire>(BaseCapturerPipeWire::CaptureSourceType::kAny);
dd1d2c
+  return std::move(capturer);}
dd1d2c
+
dd1d2c
+// static
dd1d2c
+std::unique_ptr<DesktopCapturer>
dd1d2c
+BaseCapturerPipeWire::CreateRawWindowCapturer(
dd1d2c
+    const DesktopCaptureOptions& options) {
dd1d2c
+
dd1d2c
+  std::unique_ptr<BaseCapturerPipeWire> capturer =
dd1d2c
+      std::make_unique<BaseCapturerPipeWire>(BaseCapturerPipeWire::CaptureSourceType::kAny);
dd1d2c
+  return std::move(capturer);
dd1d2c
+}
dd1d2c
+
dd1d2c
 }  // namespace webrtc
dd1d2c
diff --git a/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.h b/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.h
dd1d2c
index 56b101acbaa6..de54157d1a2a 100644
dd1d2c
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.h
dd1d2c
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.h
dd1d2c
@@ -22,17 +22,13 @@
dd1d2c
 
dd1d2c
 namespace webrtc {
dd1d2c
 
dd1d2c
-class PipeWireType {
dd1d2c
- public:
dd1d2c
-  spa_type_media_type media_type;
dd1d2c
-  spa_type_media_subtype media_subtype;
dd1d2c
-  spa_type_format_video format_video;
dd1d2c
-  spa_type_video_format video_format;
dd1d2c
-};
dd1d2c
-
dd1d2c
 class BaseCapturerPipeWire : public DesktopCapturer {
dd1d2c
  public:
dd1d2c
-  enum CaptureSourceType { Screen = 1, Window };
dd1d2c
+  enum CaptureSourceType : uint32_t {
dd1d2c
+    kScreen = 0b01,
dd1d2c
+    kWindow = 0b10,
dd1d2c
+    kAny = 0b11
dd1d2c
+  };
dd1d2c
 
dd1d2c
   explicit BaseCapturerPipeWire(CaptureSourceType source_type);
dd1d2c
   ~BaseCapturerPipeWire() override;
dd1d2c
@@ -43,28 +39,32 @@ class BaseCapturerPipeWire : public DesktopCapturer {
dd1d2c
   bool GetSourceList(SourceList* sources) override;
dd1d2c
   bool SelectSource(SourceId id) override;
dd1d2c
 
dd1d2c
+  static std::unique_ptr<DesktopCapturer> CreateRawScreenCapturer(
dd1d2c
+      const DesktopCaptureOptions& options);
dd1d2c
+
dd1d2c
+  static std::unique_ptr<DesktopCapturer> CreateRawWindowCapturer(
dd1d2c
+      const DesktopCaptureOptions& options);
dd1d2c
+
dd1d2c
  private:
dd1d2c
   // PipeWire types -->
dd1d2c
+  pw_context* pw_context_ = nullptr;
dd1d2c
   pw_core* pw_core_ = nullptr;
dd1d2c
-  pw_type* pw_core_type_ = nullptr;
dd1d2c
   pw_stream* pw_stream_ = nullptr;
dd1d2c
-  pw_remote* pw_remote_ = nullptr;
dd1d2c
-  pw_loop* pw_loop_ = nullptr;
dd1d2c
   pw_thread_loop* pw_main_loop_ = nullptr;
dd1d2c
-  PipeWireType* pw_type_ = nullptr;
dd1d2c
 
dd1d2c
+  spa_hook spa_core_listener_ = {};
dd1d2c
   spa_hook spa_stream_listener_ = {};
dd1d2c
-  spa_hook spa_remote_listener_ = {};
dd1d2c
 
dd1d2c
+  pw_core_events pw_core_events_ = {};
dd1d2c
   pw_stream_events pw_stream_events_ = {};
dd1d2c
-  pw_remote_events pw_remote_events_ = {};
dd1d2c
 
dd1d2c
-  spa_video_info_raw* spa_video_format_ = nullptr;
dd1d2c
+  struct spa_video_info_raw spa_video_format_;
dd1d2c
 
dd1d2c
+  guint32 pw_stream_node_id_ = 0;
dd1d2c
   gint32 pw_fd_ = -1;
dd1d2c
 
dd1d2c
   CaptureSourceType capture_source_type_ =
dd1d2c
-      BaseCapturerPipeWire::CaptureSourceType::Screen;
dd1d2c
+      BaseCapturerPipeWire::CaptureSourceType::kAny;
dd1d2c
 
dd1d2c
   // <-- end of PipeWire types
dd1d2c
 
dd1d2c
@@ -78,33 +78,37 @@ class BaseCapturerPipeWire : public DesktopCapturer {
dd1d2c
   guint sources_request_signal_id_ = 0;
dd1d2c
   guint start_request_signal_id_ = 0;
dd1d2c
 
dd1d2c
+  bool video_crop_size_initialized_ = false;
dd1d2c
+  DesktopSize video_crop_size_;;
dd1d2c
   DesktopSize desktop_size_ = {};
dd1d2c
   DesktopCaptureOptions options_ = {};
dd1d2c
 
dd1d2c
-  uint8_t* current_frame_ = nullptr;
dd1d2c
+  std::unique_ptr<uint8_t[]> current_frame_;
dd1d2c
   Callback* callback_ = nullptr;
dd1d2c
 
dd1d2c
   bool portal_init_failed_ = false;
dd1d2c
 
dd1d2c
   void InitPortal();
dd1d2c
   void InitPipeWire();
dd1d2c
-  void InitPipeWireTypes();
dd1d2c
 
dd1d2c
-  void CreateReceivingStream();
dd1d2c
+  pw_stream* CreateReceivingStream();
dd1d2c
   void HandleBuffer(pw_buffer* buffer);
dd1d2c
 
dd1d2c
   void ConvertRGBxToBGRx(uint8_t* frame, uint32_t size);
dd1d2c
 
dd1d2c
-  static void OnStateChanged(void* data,
dd1d2c
-                             pw_remote_state old_state,
dd1d2c
-                             pw_remote_state state,
dd1d2c
-                             const char* error);
dd1d2c
+  static void SyncDmaBuf(int fd, uint64_t start_or_end);
dd1d2c
+  static void OnCoreError(void *data,
dd1d2c
+                          uint32_t id,
dd1d2c
+                          int seq,
dd1d2c
+                          int res,
dd1d2c
+                          const char *message);
dd1d2c
+  static void OnStreamParamChanged(void *data,
dd1d2c
+                                   uint32_t id,
dd1d2c
+                                   const struct spa_pod *format);
dd1d2c
   static void OnStreamStateChanged(void* data,
dd1d2c
                                    pw_stream_state old_state,
dd1d2c
                                    pw_stream_state state,
dd1d2c
                                    const char* error_message);
dd1d2c
-
dd1d2c
-  static void OnStreamFormatChanged(void* data, const struct spa_pod* format);
dd1d2c
   static void OnStreamProcess(void* data);
dd1d2c
   static void OnNewBuffer(void* data, uint32_t id);
dd1d2c
 
dd1d2c
diff --git a/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc b/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc
dd1d2c
index 26956fc67dc8..3813d697bb38 100644
dd1d2c
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc
dd1d2c
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc
dd1d2c
@@ -15,7 +15,7 @@
dd1d2c
 namespace webrtc {
dd1d2c
 
dd1d2c
 ScreenCapturerPipeWire::ScreenCapturerPipeWire()
dd1d2c
-    : BaseCapturerPipeWire(BaseCapturerPipeWire::CaptureSourceType::Screen) {}
dd1d2c
+    : BaseCapturerPipeWire(BaseCapturerPipeWire::CaptureSourceType::kScreen) {}
dd1d2c
 ScreenCapturerPipeWire::~ScreenCapturerPipeWire() {}
dd1d2c
 
dd1d2c
 // static
dd1d2c
diff --git a/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc b/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc
dd1d2c
index 35436475cb4d..c43a1f1a0c4e 100644
dd1d2c
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc
dd1d2c
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc
dd1d2c
@@ -15,7 +15,7 @@
dd1d2c
 namespace webrtc {
dd1d2c
 
dd1d2c
 WindowCapturerPipeWire::WindowCapturerPipeWire()
dd1d2c
-    : BaseCapturerPipeWire(BaseCapturerPipeWire::CaptureSourceType::Window) {}
dd1d2c
+    : BaseCapturerPipeWire(BaseCapturerPipeWire::CaptureSourceType::kWindow) {}
dd1d2c
 WindowCapturerPipeWire::~WindowCapturerPipeWire() {}
dd1d2c
 
dd1d2c
 // static
dd1d2c
diff --git a/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_linux.cc b/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_linux.cc
dd1d2c
index cf8a9dd0e0db..d27fab8d28d9 100644
dd1d2c
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_linux.cc
dd1d2c
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_linux.cc
dd1d2c
@@ -26,7 +26,7 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
dd1d2c
     const DesktopCaptureOptions& options) {
dd1d2c
 #if defined(WEBRTC_USE_PIPEWIRE)
dd1d2c
   if (options.allow_pipewire() && DesktopCapturer::IsRunningUnderWayland()) {
dd1d2c
-    return ScreenCapturerPipeWire::CreateRawScreenCapturer(options);
dd1d2c
+    return BaseCapturerPipeWire::CreateRawScreenCapturer(options);
dd1d2c
   }
dd1d2c
 #endif  // defined(WEBRTC_USE_PIPEWIRE)
dd1d2c
 
dd1d2c
diff --git a/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_linux.cc b/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_linux.cc
dd1d2c
index 82359e50c2db..bb9724cf7cc2 100644
dd1d2c
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_linux.cc
dd1d2c
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_linux.cc
dd1d2c
@@ -26,7 +26,7 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer(
dd1d2c
     const DesktopCaptureOptions& options) {
dd1d2c
 #if defined(WEBRTC_USE_PIPEWIRE)
dd1d2c
   if (options.allow_pipewire() && DesktopCapturer::IsRunningUnderWayland()) {
dd1d2c
-    return WindowCapturerPipeWire::CreateRawWindowCapturer(options);
dd1d2c
+    return BaseCapturerPipeWire::CreateRawWindowCapturer(options);
dd1d2c
   }
dd1d2c
 #endif  // defined(WEBRTC_USE_PIPEWIRE)
dd1d2c