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