Bug 1308412 - fix setCaptureHeight() failure; r=jesup,jib
authorMunro Mengjue Chiang <mchiang@mozilla.com>
Wed, 26 Oct 2016 18:08:51 +0800
changeset 319725 0b1ae9f4f07bd823d91fadc1b2eac168e37363ca
parent 319724 0680e3176fa56b00a75d187b9b338546371486a8
child 319726 1b996ae995fe59435b44e478878eae995cd44394
push id20748
push userphilringnalda@gmail.com
push dateFri, 28 Oct 2016 03:39:55 +0000
treeherderfx-team@715360440695 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, jib
bugs1308412
milestone52.0a1
Bug 1308412 - fix setCaptureHeight() failure; r=jesup,jib MozReview-Commit-ID: 47mgoY4sOSw
media/webrtc/trunk/webrtc/modules/video_capture/mac/avfoundation/video_capture_avfoundation_info_objc.mm
--- a/media/webrtc/trunk/webrtc/modules/video_capture/mac/avfoundation/video_capture_avfoundation_info_objc.mm
+++ b/media/webrtc/trunk/webrtc/modules/video_capture/mac/avfoundation/video_capture_avfoundation_info_objc.mm
@@ -157,17 +157,24 @@ using namespace videocapturemodule;
     for ( AVFrameRateRange* range in format.videoSupportedFrameRateRanges ) {
         if ( range.maxFrameRate > maxFrameRateRange.maxFrameRate ) {
             maxFrameRateRange = range;
         }
     }
 
     *width = videoDimensions.width;
     *height = videoDimensions.height;
-    *maxFPS = maxFrameRateRange.maxFrameRate;
+
+    // This is to fix setCaptureHeight() which fails for some webcams supporting non-integer framerates.
+    // In setCaptureHeight(), we match the best framerate range by searching a range whose max framerate
+    // is most close to (but smaller than or equal to) the target. Since maxFPS of capability is integer,
+    // we fill in the capability maxFPS with the floor value (e.g., 29) of the real supported fps
+    // (e.g., 29.97). If the target is set to 29, we failed to match the best format with max framerate
+    // 29.97 since it is over the target. Therefore, we need to return a ceiling value as the maxFPS here.
+    *maxFPS = static_cast<int32_t>(ceil(maxFrameRateRange.maxFrameRate));
     *rawType = [VideoCaptureMacAVFoundationUtility fourCCToRawVideoType:CMFormatDescriptionGetMediaSubType(format.formatDescription)];
 
     return [NSNumber numberWithInt:0];
 }
 
 - (NSNumber*)getDeviceNamesFromIndex:(uint32_t)index
     DefaultName:(char*)deviceName
     WithLength:(uint32_t)deviceNameLength