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 <grulja@gmail.com>
Reviewed-by: Andreas Pehrson <apehrson@mozilla.com>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43057}
This commit is contained in:
Jan Grulich 2024-09-19 12:13:46 +02:00 committed by WebRTC LUCI CQ
parent 1b8a7b2b7f
commit 3aa47cfd30

View File

@ -16,6 +16,8 @@
#include <spa/param/video/raw.h>
#include <spa/pod/parser.h>
#include <algorithm>
#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_fraction*>(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<int32_t>(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;
}
}