Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Unified Diff: webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm

Issue 2188883002: Use 15fps for iPhone 4S (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: guard ios only import. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm
diff --git a/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm b/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm
index 9b1a7832d248bdfa85dc6a5c01f2a222f8dcc92c..810bc622ac32e785dacbce3f1fdde31b61c301e6 100644
--- a/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm
+++ b/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm
@@ -18,6 +18,9 @@
#import "RTCDispatcher+Private.h"
#import "WebRTC/RTCLogging.h"
+#if TARGET_OS_IPHONE
+#import "WebRTC/UIDevice+RTCDevice.h"
+#endif
#include "webrtc/base/bind.h"
#include "webrtc/base/checks.h"
@@ -31,6 +34,12 @@ static cricket::VideoFormat const kDefaultFormat =
480,
cricket::VideoFormat::FpsToInterval(30),
cricket::FOURCC_NV12);
+// iPhone4S is too slow to handle 30fps.
+static cricket::VideoFormat const kIPhone4SFormat =
+ cricket::VideoFormat(640,
+ 480,
+ cricket::VideoFormat::FpsToInterval(15),
+ cricket::FOURCC_NV12);
// This class used to capture frames using AVFoundation APIs on iOS. It is meant
// to be owned by an instance of AVFoundationVideoCapturer. The reason for this
@@ -383,6 +392,11 @@ static cricket::VideoFormat const kDefaultFormat =
AVCaptureDeviceInput *input = self.useBackCamera ?
backCameraInput : frontCameraInput;
[captureSession addInput:input];
+#if TARGET_OS_IPHONE
+ if ([UIDevice deviceType] == RTCDeviceTypeIPhone4S) {
+ [self setMinFrameDuration:CMTimeMake(1, 15) forDevice:input.device];
+ }
+#endif
_captureSession = captureSession;
return YES;
}
@@ -465,6 +479,17 @@ static cricket::VideoFormat const kDefaultFormat =
return _backCameraInput;
}
+- (void)setMinFrameDuration:(CMTime)minFrameDuration
+ forDevice:(AVCaptureDevice *)device {
+ NSError *error = nil;
+ if (![device lockForConfiguration:&error]) {
+ RTCLogError(@"Failed to lock device for configuration. Error: %@", error.localizedDescription);
+ return;
+ }
+ device.activeVideoMinFrameDuration = minFrameDuration;
+ [device unlockForConfiguration];
+}
+
// Called from capture session queue.
- (void)updateOrientation {
AVCaptureConnection *connection =
@@ -520,6 +545,11 @@ static cricket::VideoFormat const kDefaultFormat =
}
[self updateOrientation];
[_captureSession commitConfiguration];
+#if TARGET_OS_IPHONE
+ if ([UIDevice deviceType] == RTCDeviceTypeIPhone4S) {
+ [self setMinFrameDuration:CMTimeMake(1, 15) forDevice:newInput.device];
+ }
+#endif
}];
}
@@ -541,9 +571,17 @@ struct AVFoundationFrame {
AVFoundationVideoCapturer::AVFoundationVideoCapturer()
: _capturer(nil), _startThread(nullptr) {
// Set our supported formats. This matches kDefaultPreset.
- std::vector<cricket::VideoFormat> supportedFormats;
- supportedFormats.push_back(cricket::VideoFormat(kDefaultFormat));
- SetSupportedFormats(supportedFormats);
+ std::vector<cricket::VideoFormat> supported_formats;
+#if TARGET_OS_IPHONE
+ if ([UIDevice deviceType] == RTCDeviceTypeIPhone4S) {
+ supported_formats.push_back(cricket::VideoFormat(kIPhone4SFormat));
+ } else {
+ supported_formats.push_back(cricket::VideoFormat(kDefaultFormat));
+ }
+#else
+ supported_formats.push_back(cricket::VideoFormat(kDefaultFormat));
+#endif
+ SetSupportedFormats(supported_formats);
_capturer =
[[RTCAVFoundationVideoCapturerInternal alloc] initWithCapturer:this];
}
@@ -562,7 +600,7 @@ cricket::CaptureState AVFoundationVideoCapturer::Start(
LOG(LS_ERROR) << "The capturer is already running.";
return cricket::CaptureState::CS_FAILED;
}
- if (format != kDefaultFormat) {
+ if (format != kDefaultFormat && format != kIPhone4SFormat) {
LOG(LS_ERROR) << "Unsupported format provided.";
return cricket::CaptureState::CS_FAILED;
}
« no previous file with comments | « webrtc/sdk/objc/Framework/Classes/UIDevice+RTCDevice.mm ('k') | webrtc/sdk/objc/Framework/Headers/WebRTC/UIDevice+RTCDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698