AVFoundation: correctly set default frame rate on OSX.

On OSX, it's not possible to reset the frame rate to the default value
by passing kCMTimeInvalid, so just set the first value from the
supported frame rates.

Change-Id: I984101c2a95e13053228e56f19b353e716eb2b67
Reviewed-by: Christian Stromme <christian.stromme@qt.io>
This commit is contained in:
Yoann Lopes
2016-03-11 15:26:05 +01:00
committed by Yoann Lopes
parent 4fa23e08a1
commit a4656b06eb

View File

@@ -489,10 +489,17 @@ void qt_set_framerate_limits(AVCaptureDevice *captureDevice, qreal minFPS, qreal
// settings for this format, kCMTimeInvalid on OS X ends with a runtime
// exception:
// "The activeVideoMinFrameDuration passed is not supported by the device."
// Instead, use the first item in the supported frame rates.
#ifdef Q_OS_IOS
[captureDevice setActiveVideoMinFrameDuration:minFrameDuration];
[captureDevice setActiveVideoMaxFrameDuration:maxFrameDuration];
#else // Q_OS_OSX
if (CMTimeCompare(minFrameDuration, kCMTimeInvalid) == 0
&& CMTimeCompare(maxFrameDuration, kCMTimeInvalid) == 0) {
AVFrameRateRange *range = captureDevice.activeFormat.videoSupportedFrameRateRanges.firstObject;
minFrameDuration = range.minFrameDuration;
maxFrameDuration = range.maxFrameDuration;
}
if (CMTimeCompare(minFrameDuration, kCMTimeInvalid))
[captureDevice setActiveVideoMinFrameDuration:minFrameDuration];