From bf3a9b3cce1ad388be2c69e7caaabbb1850218bb Mon Sep 17 00:00:00 2001 From: "vikasmarwaha@webrtc.org" Date: Thu, 21 Feb 2013 20:25:54 +0000 Subject: [PATCH] Fix for WebRTC Issue 1384. Some cameras return 0 fps for all capabilities which causes divide-by-zero. Review URL: https://webrtc-codereview.appspot.com/1101013 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3558 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../modules/video_capture/windows/device_info_ds.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/webrtc/modules/video_capture/windows/device_info_ds.cc b/webrtc/modules/video_capture/windows/device_info_ds.cc index b23d214e5..8bc0bdb38 100644 --- a/webrtc/modules/video_capture/windows/device_info_ds.cc +++ b/webrtc/modules/video_capture/windows/device_info_ds.cc @@ -570,7 +570,8 @@ WebRtc_Word32 DeviceInfoDS::CreateCapabilityMap( if (hrVC == S_OK) { - LONGLONG *maxFps; // array + LONGLONG *frameDurationList; + LONGLONG maxFps; long listSize; SIZE size; size.cx = capability->width; @@ -584,11 +585,14 @@ WebRtc_Word32 DeviceInfoDS::CreateCapabilityMap( hrVC = videoControlConfig->GetFrameRateList(outputCapturePin, tmp, size, &listSize, - &maxFps); + &frameDurationList); - if (hrVC == S_OK && listSize > 0) + // On some odd cameras, you may get a 0 for duration. + // GetMaxOfFrameArray returns the lowest duration (highest FPS) + if (hrVC == S_OK && listSize > 0 && + 0 != (maxFPS = GetMaxOfFrameArray(frameDurationList, + listSize))) { - LONGLONG maxFPS = GetMaxOfFrameArray(maxFps, listSize); capability->maxFPS = static_cast (10000000 / maxFPS); capability->supportFrameRateControl = true;