42 lines
1.6 KiB
Diff
42 lines
1.6 KiB
Diff
|
diff --git a/third_party/libwebrtc/modules/video_capture/linux/pipewire_session.cc b/third_party/libwebrtc/modules/video_capture/linux/pipewire_session.cc
|
||
|
--- a/third_party/libwebrtc/modules/video_capture/linux/pipewire_session.cc
|
||
|
+++ b/third_party/libwebrtc/modules/video_capture/linux/pipewire_session.cc
|
||
|
@@ -352,10 +352,17 @@
|
||
|
const char* type,
|
||
|
uint32_t version,
|
||
|
const spa_dict* props) {
|
||
|
PipeWireSession* that = static_cast<PipeWireSession*>(data);
|
||
|
|
||
|
+ // Skip already added nodes to avoid duplicate camera entries
|
||
|
+ if (std::find_if(that->nodes_.begin(), that->nodes_.end(),
|
||
|
+ [id](const PipeWireNode& node) {
|
||
|
+ return node.id() == id;
|
||
|
+ }) != that->nodes_.end())
|
||
|
+ return;
|
||
|
+
|
||
|
if (type != absl::string_view(PW_TYPE_INTERFACE_Node))
|
||
|
return;
|
||
|
|
||
|
if (!spa_dict_lookup(props, PW_KEY_NODE_DESCRIPTION))
|
||
|
return;
|
||
|
@@ -370,16 +377,14 @@
|
||
|
|
||
|
// static
|
||
|
void PipeWireSession::OnRegistryGlobalRemove(void* data, uint32_t id) {
|
||
|
PipeWireSession* that = static_cast<PipeWireSession*>(data);
|
||
|
|
||
|
- for (auto it = that->nodes_.begin(); it != that->nodes().end(); ++it) {
|
||
|
- if ((*it).id() == id) {
|
||
|
- that->nodes_.erase(it);
|
||
|
- break;
|
||
|
- }
|
||
|
- }
|
||
|
+ auto it = std::remove_if(
|
||
|
+ that->nodes_.begin(), that->nodes_.end(),
|
||
|
+ [id](const PipeWireNode& node) { return node.id() == id; });
|
||
|
+ that->nodes_.erase(it, that->nodes_.end());
|
||
|
}
|
||
|
|
||
|
void PipeWireSession::Finish(VideoCaptureOptions::Status status) {
|
||
|
webrtc::MutexLock lock(&callback_lock_);
|