Allow VideoCaptureModulePipeWire to be shared with more consumers
This allows to share an instance of VideoCaptureModulePipeWire which is what browsers usually do when the same camera is being shared with more than one consumer. This matches V4L2 implementation. Bug: webrtc:15211 Change-Id: I2ae466739c2649029e76a29e6f16aad1014e9d42 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/306964 Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Jan Grulich <grulja@gmail.com> Cr-Commit-Position: refs/heads/main@{#41639}
This commit is contained in:
parent
365cf14407
commit
958c9ac546
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user