Bug 1308412 - fix setCaptureHeight() failure; r=jib, jesup draft
authorMunro Mengjue Chiang <mchiang@mozilla.com>
Wed, 26 Oct 2016 18:08:51 +0800
changeset 430133 9e930bb832628972333da6a57267448b42cd6d41
parent 429666 73b577db58085413cb1be4b0ec4f852f4e0f7575
child 535132 dab00878f336422a13dcfee8c148f28758d470e2
push id33747
push usermchiang@mozilla.com
push dateThu, 27 Oct 2016 07:17:42 +0000
reviewersjib, jesup
bugs1308412
milestone52.0a1
Bug 1308412 - fix setCaptureHeight() failure; r=jib, jesup 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