In DeviceInfoDS check that out vars were set

Bug: chromium:1441804
Change-Id: Id07cb61519315d77c2d7cdab1053efaaf7473e1a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/304060
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39982}
This commit is contained in:
Andreas Pehrson 2023-05-02 11:49:38 +02:00 committed by WebRTC LUCI CQ
parent 5e531b407d
commit 6fc1ae58be
2 changed files with 10 additions and 6 deletions

View File

@ -439,9 +439,9 @@ int32_t DeviceInfoDS::CreateCapabilityMap(const char* deviceUniqueIdUTF8)
}
if (hrVC == S_OK) {
LONGLONG* frameDurationList;
LONGLONG maxFPS;
long listSize;
LONGLONG* frameDurationList = NULL;
LONGLONG maxFPS = 0;
long listSize = 0;
SIZE size;
size.cx = capability.width;
size.cy = capability.height;
@ -454,9 +454,10 @@ int32_t DeviceInfoDS::CreateCapabilityMap(const char* deviceUniqueIdUTF8)
hrVC = videoControlConfig->GetFrameRateList(
outputCapturePin, tmp, size, &listSize, &frameDurationList);
// On some odd cameras, you may get a 0 for duration.
// GetMaxOfFrameArray returns the lowest duration (highest FPS)
if (hrVC == S_OK && listSize > 0 &&
// On some odd cameras, you may get a 0 for duration. Some others may
// not update the out vars. GetMaxOfFrameArray returns the lowest
// duration (highest FPS), or 0 if there was no list with elements.
if (hrVC == S_OK &&
0 != (maxFPS = GetMaxOfFrameArray(frameDurationList, listSize))) {
capability.maxFPS = static_cast<int>(10000000 / maxFPS);
capability.supportFrameRateControl = true;

View File

@ -21,6 +21,9 @@ namespace webrtc {
namespace videocapturemodule {
// This returns minimum :), which will give max frame rate...
LONGLONG GetMaxOfFrameArray(LONGLONG* maxFps, long size) {
if (!maxFps || size <= 0) {
return 0;
}
LONGLONG maxFPS = maxFps[0];
for (int i = 0; i < size; i++) {
if (maxFPS > maxFps[i])