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

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm

Issue 2206773002: Use 352x288 for iPhone 4S. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 11 matching lines...) Expand all
22 #import "WebRTC/UIDevice+RTCDevice.h" 22 #import "WebRTC/UIDevice+RTCDevice.h"
23 #endif 23 #endif
24 24
25 #include "webrtc/base/bind.h" 25 #include "webrtc/base/bind.h"
26 #include "webrtc/base/checks.h" 26 #include "webrtc/base/checks.h"
27 #include "webrtc/base/thread.h" 27 #include "webrtc/base/thread.h"
28 #include "webrtc/common_video/include/corevideo_frame_buffer.h" 28 #include "webrtc/common_video/include/corevideo_frame_buffer.h"
29 29
30 // TODO(tkchin): support other formats. 30 // TODO(tkchin): support other formats.
31 static NSString *const kDefaultPreset = AVCaptureSessionPreset640x480; 31 static NSString *const kDefaultPreset = AVCaptureSessionPreset640x480;
32 static NSString *const kIPhone4SPreset = AVCaptureSessionPreset352x288;
32 static cricket::VideoFormat const kDefaultFormat = 33 static cricket::VideoFormat const kDefaultFormat =
33 cricket::VideoFormat(640, 34 cricket::VideoFormat(640,
34 480, 35 480,
35 cricket::VideoFormat::FpsToInterval(30), 36 cricket::VideoFormat::FpsToInterval(30),
36 cricket::FOURCC_NV12); 37 cricket::FOURCC_NV12);
37 // iPhone4S is too slow to handle 30fps. 38 // iPhone4S is too slow to handle 30fps.
38 static cricket::VideoFormat const kIPhone4SFormat = 39 static cricket::VideoFormat const kIPhone4SFormat =
39 cricket::VideoFormat(640, 40 cricket::VideoFormat(352,
40 480, 41 288,
41 cricket::VideoFormat::FpsToInterval(15), 42 cricket::VideoFormat::FpsToInterval(15),
42 cricket::FOURCC_NV12); 43 cricket::FOURCC_NV12);
43 44
44 // This class used to capture frames using AVFoundation APIs on iOS. It is meant 45 // This class used to capture frames using AVFoundation APIs on iOS. It is meant
45 // to be owned by an instance of AVFoundationVideoCapturer. The reason for this 46 // to be owned by an instance of AVFoundationVideoCapturer. The reason for this
46 // because other webrtc objects own cricket::VideoCapturer, which is not 47 // because other webrtc objects own cricket::VideoCapturer, which is not
47 // ref counted. To prevent bad behavior we do not expose this class directly. 48 // ref counted. To prevent bad behavior we do not expose this class directly.
48 @interface RTCAVFoundationVideoCapturerInternal : NSObject 49 @interface RTCAVFoundationVideoCapturerInternal : NSObject
49 <AVCaptureVideoDataOutputSampleBufferDelegate> 50 <AVCaptureVideoDataOutputSampleBufferDelegate>
50 51
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 #pragma mark - Private 354 #pragma mark - Private
354 355
355 - (BOOL)setupCaptureSession { 356 - (BOOL)setupCaptureSession {
356 AVCaptureSession *captureSession = [[AVCaptureSession alloc] init]; 357 AVCaptureSession *captureSession = [[AVCaptureSession alloc] init];
357 #if defined(__IPHONE_7_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0 358 #if defined(__IPHONE_7_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0
358 NSString *version = [[UIDevice currentDevice] systemVersion]; 359 NSString *version = [[UIDevice currentDevice] systemVersion];
359 if ([version integerValue] >= 7) { 360 if ([version integerValue] >= 7) {
360 captureSession.usesApplicationAudioSession = NO; 361 captureSession.usesApplicationAudioSession = NO;
361 } 362 }
362 #endif 363 #endif
363 if (![captureSession canSetSessionPreset:kDefaultPreset]) { 364 NSString *preset = kDefaultPreset;
365 #if TARGET_OS_IPHONE
366 if ([UIDevice deviceType] == RTCDeviceTypeIPhone4S) {
367 preset = kIPhone4SPreset;
368 }
369 #endif
370 if (![captureSession canSetSessionPreset:preset]) {
364 RTCLogError(@"Session preset unsupported."); 371 RTCLogError(@"Session preset unsupported.");
365 return NO; 372 return NO;
366 } 373 }
367 captureSession.sessionPreset = kDefaultPreset; 374 captureSession.sessionPreset = preset;
368 375
369 // Add the output. 376 // Add the output.
370 AVCaptureVideoDataOutput *videoDataOutput = [self videoDataOutput]; 377 AVCaptureVideoDataOutput *videoDataOutput = [self videoDataOutput];
371 if (![captureSession canAddOutput:videoDataOutput]) { 378 if (![captureSession canAddOutput:videoDataOutput]) {
372 RTCLogError(@"Video data output unsupported."); 379 RTCLogError(@"Video data output unsupported.");
373 return NO; 380 return NO;
374 } 381 }
375 [captureSession addOutput:videoDataOutput]; 382 [captureSession addOutput:videoDataOutput];
376 383
377 // Get the front and back cameras. If there isn't a front camera 384 // Get the front and back cameras. If there isn't a front camera
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 570
564 struct AVFoundationFrame { 571 struct AVFoundationFrame {
565 AVFoundationFrame(CVImageBufferRef buffer, int64_t time) 572 AVFoundationFrame(CVImageBufferRef buffer, int64_t time)
566 : image_buffer(buffer), capture_time(time) {} 573 : image_buffer(buffer), capture_time(time) {}
567 CVImageBufferRef image_buffer; 574 CVImageBufferRef image_buffer;
568 int64_t capture_time; 575 int64_t capture_time;
569 }; 576 };
570 577
571 AVFoundationVideoCapturer::AVFoundationVideoCapturer() 578 AVFoundationVideoCapturer::AVFoundationVideoCapturer()
572 : _capturer(nil), _startThread(nullptr) { 579 : _capturer(nil), _startThread(nullptr) {
573 // Set our supported formats. This matches kDefaultPreset. 580 // Set our supported formats. This matches preset.
574 std::vector<cricket::VideoFormat> supported_formats; 581 std::vector<cricket::VideoFormat> supported_formats;
575 #if TARGET_OS_IPHONE 582 #if TARGET_OS_IPHONE
576 if ([UIDevice deviceType] == RTCDeviceTypeIPhone4S) { 583 if ([UIDevice deviceType] == RTCDeviceTypeIPhone4S) {
577 supported_formats.push_back(cricket::VideoFormat(kIPhone4SFormat)); 584 supported_formats.push_back(cricket::VideoFormat(kIPhone4SFormat));
578 } else { 585 } else {
579 supported_formats.push_back(cricket::VideoFormat(kDefaultFormat)); 586 supported_formats.push_back(cricket::VideoFormat(kDefaultFormat));
580 } 587 }
581 #else 588 #else
582 supported_formats.push_back(cricket::VideoFormat(kDefaultFormat)); 589 supported_formats.push_back(cricket::VideoFormat(kDefaultFormat));
583 #endif 590 #endif
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 } 725 }
719 726
720 OnFrame(cricket::WebRtcVideoFrame(buffer, webrtc::kVideoRotation_0, 727 OnFrame(cricket::WebRtcVideoFrame(buffer, webrtc::kVideoRotation_0,
721 translated_camera_time_us, 0), 728 translated_camera_time_us, 0),
722 captured_width, captured_height); 729 captured_width, captured_height);
723 730
724 CVBufferRelease(image_buffer); 731 CVBufferRelease(image_buffer);
725 } 732 }
726 733
727 } // namespace webrtc 734 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698