firefox/libwebrtc-allow-videocapturemodulepipewire-be-shared-with-more-consumers.patch

67 lines
2.4 KiB
Diff

diff --git a/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.h b/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.h
--- a/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.h
+++ b/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.h
@@ -48,10 +48,11 @@
const rtc::scoped_refptr<PipeWireSession> session_
RTC_GUARDED_BY(capture_checker_);
int node_id_ RTC_GUARDED_BY(capture_checker_);
VideoCaptureCapability configured_capability_
RTC_GUARDED_BY(pipewire_checker_);
+ bool initialized_ RTC_GUARDED_BY(capture_checker_);
bool started_ RTC_GUARDED_BY(api_lock_);
struct pw_stream* stream_ RTC_GUARDED_BY(pipewire_checker_) = nullptr;
struct spa_hook stream_listener_ RTC_GUARDED_BY(pipewire_checker_);
};
diff --git a/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc b/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc
--- a/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc
+++ b/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc
@@ -46,11 +46,14 @@
return VideoType::kUnknown;
}
VideoCaptureModulePipeWire::VideoCaptureModulePipeWire(
VideoCaptureOptions* options)
- : VideoCaptureImpl(), session_(options->pipewire_session()) {}
+ : VideoCaptureImpl(),
+ session_(options->pipewire_session()),
+ initialized_(false),
+ started_(false) {}
VideoCaptureModulePipeWire::~VideoCaptureModulePipeWire() {
RTC_DCHECK_RUN_ON(&api_checker_);
StopCapture();
@@ -119,10 +122,18 @@
int32_t VideoCaptureModulePipeWire::StartCapture(
const VideoCaptureCapability& capability) {
RTC_CHECK_RUNS_SERIALIZED(&capture_checker_);
RTC_DCHECK_RUN_ON(&api_checker_);
+ if (initialized_) {
+ if (capability == _requestedCapability) {
+ return 0;
+ } else {
+ StopCapture();
+ }
+ }
+
uint8_t buffer[1024] = {};
RTC_LOG(LS_VERBOSE) << "Creating new PipeWire stream for node " << node_id_;
PipeWireThreadLoopLock thread_loop_lock(session_->pw_main_loop_);
@@ -169,10 +180,12 @@
<< spa_strerror(res);
return -1;
}
_requestedCapability = capability;
+ initialized_ = true;
+
return 0;
}
int32_t VideoCaptureModulePipeWire::StopCapture() {
RTC_CHECK_RUNS_SERIALIZED(&capture_checker_);