Bug 1920460 - WebRTC backport: PipeWire camera: get max FPS for each format when specified as list r=pehrsons,webrtc-reviewers

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.

This is a simple backport of an WebRTC upstream change.

Upstream commit: 3aa47cfd30dc965446cf1405bb062b756a62e6d1

Differential Revision: https://phabricator.services.mozilla.com/D223112
This commit is contained in:
Jan Grulich 2024-09-24 11:20:02 +00:00
parent 4f3878bfa8
commit 9d035f7287
2 changed files with 11 additions and 2 deletions

View File

@ -17,6 +17,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"
@ -152,9 +154,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;
}
}

View File

@ -0,0 +1 @@
We cherry-picked this in bug 1920460.