1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
From: Jan Grulich <jgrulich@redhat.com>
Date: Fri, 2 Feb 2024 11:47:00 +0000
Subject: Bug 1876896 - WebRTC backport: Allow VideoCaptureModulePipeWire to be
shared with more consumers r=pehrsons,webrtc-reviewers
This is a simple backport of an WebRTC upstream change.
Upstream commit: 958c9ac546f33716d097b5092515dcac705151d3
Differential Revision: https://phabricator.services.mozilla.com/D200142
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2ba2ef65280b2e6f246fed24d6986718981744f5
---
.../video_capture/linux/video_capture_pipewire.cc | 15 ++++++++++++++-
.../video_capture/linux/video_capture_pipewire.h | 1 +
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/modules/video_capture/linux/video_capture_pipewire.cc b/modules/video_capture/linux/video_capture_pipewire.cc
index 9d47e3ddbf..fb813e331f 100644
--- a/modules/video_capture/linux/video_capture_pipewire.cc
+++ b/modules/video_capture/linux/video_capture_pipewire.cc
@@ -48,7 +48,10 @@ VideoType VideoCaptureModulePipeWire::PipeWireRawFormatToVideoType(
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_);
@@ -121,6 +124,14 @@ int32_t VideoCaptureModulePipeWire::StartCapture(
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_;
@@ -171,6 +182,8 @@ int32_t VideoCaptureModulePipeWire::StartCapture(
}
_requestedCapability = capability;
+ initialized_ = true;
+
return 0;
}
diff --git a/modules/video_capture/linux/video_capture_pipewire.h b/modules/video_capture/linux/video_capture_pipewire.h
index 620ee520ca..5d6794ed65 100644
--- a/modules/video_capture/linux/video_capture_pipewire.h
+++ b/modules/video_capture/linux/video_capture_pipewire.h
@@ -50,6 +50,7 @@ class VideoCaptureModulePipeWire : public VideoCaptureImpl {
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;
|