From 143ffa4bd5b4ee0a136105670c1237bde40c524d Mon Sep 17 00:00:00 2001 From: "tkchin@webrtc.org" Date: Thu, 18 Sep 2014 21:44:54 +0000 Subject: [PATCH] Update iOS video capture to use non-deprecated APIs. BUG=3626 R=glaznev@webrtc.org Review URL: https://webrtc-codereview.appspot.com/17279004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7229 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../ios/rtc_video_capture_ios_objc.mm | 27 ++++++++++++++++--- .../modules/video_capture/video_capture.gypi | 6 ----- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.mm b/webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.mm index ac90b72ad..b5c53b19f 100644 --- a/webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.mm +++ b/webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.mm @@ -204,12 +204,31 @@ using namespace webrtc::videocapturemodule; [_captureSession setSessionPreset:captureQuality]; // take care of capture framerate now + NSArray* sessionInputs = _captureSession.inputs; + AVCaptureDeviceInput* deviceInput = [sessionInputs count] > 0 ? + sessionInputs[0] : nil; + AVCaptureDevice* inputDevice = deviceInput.device; + if (inputDevice) { + AVCaptureDeviceFormat* activeFormat = inputDevice.activeFormat; + NSArray* supportedRanges = activeFormat.videoSupportedFrameRateRanges; + AVFrameRateRange* targetRange = [supportedRanges count] > 0 ? + supportedRanges[0] : nil; + // Find the largest supported framerate less than capability maxFPS. + for (AVFrameRateRange* range in supportedRanges) { + if (range.maxFrameRate <= _capability.maxFPS && + targetRange.maxFrameRate <= range.maxFrameRate) { + targetRange = range; + } + } + if (targetRange && [inputDevice lockForConfiguration:NULL]) { + inputDevice.activeVideoMinFrameDuration = targetRange.minFrameDuration; + inputDevice.activeVideoMaxFrameDuration = targetRange.minFrameDuration; + [inputDevice unlockForConfiguration]; + } + } + _connection = [currentOutput connectionWithMediaType:AVMediaTypeVideo]; [self setRelativeVideoOrientation]; - CMTime cm_time = {1, _capability.maxFPS, kCMTimeFlags_Valid, 0}; - - [_connection setVideoMinFrameDuration:cm_time]; - [_connection setVideoMaxFrameDuration:cm_time]; // finished configuring, commit settings to AVCaptureSession. [_captureSession commitConfiguration]; diff --git a/webrtc/modules/video_capture/video_capture.gypi b/webrtc/modules/video_capture/video_capture.gypi index e57d97a34..888d7727b 100644 --- a/webrtc/modules/video_capture/video_capture.gypi +++ b/webrtc/modules/video_capture/video_capture.gypi @@ -138,12 +138,6 @@ ], 'xcode_settings': { 'CLANG_ENABLE_OBJC_ARC': 'YES', - 'WARNING_CFLAGS': [ - # To avoid warnings for deprecated videoMinFrameDuration and - # videoMaxFrameDuration properties in iOS 7.0. - # See webrtc:3705 for more details. - '-Wno-deprecated-declarations', - ], }, 'all_dependent_settings': { 'xcode_settings': {