From 3aa47cfd30dc965446cf1405bb062b756a62e6d1 Mon Sep 17 00:00:00 2001 From: Jan Grulich Date: Thu, 19 Sep 2024 12:13:46 +0200 Subject: [PATCH] PipeWire camera: get max FPS for each format when specified as list In many cases, the framerate can be specified as list of possible values and in that case, we would end up with max FPS to be set to 0 as this case was not handled. Bug: webrtc:42225999 Change-Id: I036af6db1da3309b1310b754504369e8fe392d09 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/362961 Commit-Queue: Jan Grulich Reviewed-by: Andreas Pehrson Reviewed-by: Ilya Nikolaevskiy Cr-Commit-Position: refs/heads/main@{#43057} --- modules/video_capture/linux/pipewire_session.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/video_capture/linux/pipewire_session.cc b/modules/video_capture/linux/pipewire_session.cc index e9f7f765a5..85ccb289d8 100644 --- a/modules/video_capture/linux/pipewire_session.cc +++ b/modules/video_capture/linux/pipewire_session.cc @@ -16,6 +16,8 @@ #include #include +#include + #include "common_video/libyuv/include/webrtc_libyuv.h" #include "modules/video_capture/device_info_impl.h" #include "rtc_base/logging.h" @@ -151,9 +153,15 @@ void PipeWireNode::OnNodeParam(void* data, fract = static_cast(SPA_POD_BODY(val)); - if (choice == SPA_CHOICE_None) + if (choice == SPA_CHOICE_None) { cap.maxFPS = 1.0 * fract[0].num / fract[0].denom; - else if (choice == SPA_CHOICE_Range && fract[1].num > 0) + } else if (choice == SPA_CHOICE_Enum) { + for (uint32_t i = 1; i < n_items; i++) { + cap.maxFPS = std::max( + static_cast(1.0 * fract[i].num / fract[i].denom), + cap.maxFPS); + } + } else if (choice == SPA_CHOICE_Range && fract[1].num > 0) cap.maxFPS = 1.0 * fract[1].num / fract[1].denom; } }