| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 if (IsMediaSubTypeSupported(mediaSubType)) { | 108 if (IsMediaSubTypeSupported(mediaSubType)) { |
| 109 [eligibleDeviceFormats addObject:format]; | 109 [eligibleDeviceFormats addObject:format]; |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 return eligibleDeviceFormats; | 113 return eligibleDeviceFormats; |
| 114 } | 114 } |
| 115 | 115 |
| 116 - (void)startCaptureWithDevice:(AVCaptureDevice *)device | 116 - (void)startCaptureWithDevice:(AVCaptureDevice *)device |
| 117 format:(AVCaptureDeviceFormat *)format | 117 format:(AVCaptureDeviceFormat *)format |
| 118 fps:(int)fps { | 118 fps:(NSInteger)fps { |
| 119 _willBeRunning = true; | 119 _willBeRunning = true; |
| 120 [RTCDispatcher | 120 [RTCDispatcher |
| 121 dispatchAsyncOnType:RTCDispatcherTypeCaptureSession | 121 dispatchAsyncOnType:RTCDispatcherTypeCaptureSession |
| 122 block:^{ | 122 block:^{ |
| 123 RTCLogInfo("startCaptureWithDevice %@ @ %d fps", format, f
ps); | 123 RTCLogInfo("startCaptureWithDevice %@ @ %zd fps", format,
fps); |
| 124 | 124 |
| 125 #if TARGET_OS_IPHONE | 125 #if TARGET_OS_IPHONE |
| 126 [[UIDevice currentDevice] beginGeneratingDeviceOrientation
Notifications]; | 126 [[UIDevice currentDevice] beginGeneratingDeviceOrientation
Notifications]; |
| 127 #endif | 127 #endif |
| 128 | 128 |
| 129 _currentDevice = device; | 129 _currentDevice = device; |
| 130 | 130 |
| 131 NSError *error = nil; | 131 NSError *error = nil; |
| 132 if ([_currentDevice lockForConfiguration:&error]) { | 132 if ([_currentDevice lockForConfiguration:&error]) { |
| 133 [self updateDeviceCaptureFormat:format fps:fps]; | 133 [self updateDeviceCaptureFormat:format fps:fps]; |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 // TODO(denicija): Remove this color conversion and use the original capture
format directly. | 353 // TODO(denicija): Remove this color conversion and use the original capture
format directly. |
| 354 kCVPixelBufferPixelFormatTypeKey : @(kCVPixelFormatType_420YpCbCr8BiPlanarFu
llRange) | 354 kCVPixelBufferPixelFormatTypeKey : @(kCVPixelFormatType_420YpCbCr8BiPlanarFu
llRange) |
| 355 }; | 355 }; |
| 356 videoDataOutput.alwaysDiscardsLateVideoFrames = NO; | 356 videoDataOutput.alwaysDiscardsLateVideoFrames = NO; |
| 357 [videoDataOutput setSampleBufferDelegate:self queue:self.frameQueue]; | 357 [videoDataOutput setSampleBufferDelegate:self queue:self.frameQueue]; |
| 358 _videoDataOutput = videoDataOutput; | 358 _videoDataOutput = videoDataOutput; |
| 359 } | 359 } |
| 360 | 360 |
| 361 #pragma mark - Private, called inside capture queue | 361 #pragma mark - Private, called inside capture queue |
| 362 | 362 |
| 363 - (void)updateDeviceCaptureFormat:(AVCaptureDeviceFormat *)format fps:(int)fps { | 363 - (void)updateDeviceCaptureFormat:(AVCaptureDeviceFormat *)format fps:(NSInteger
)fps { |
| 364 NSAssert([RTCDispatcher isOnQueueForType:RTCDispatcherTypeCaptureSession], | 364 NSAssert([RTCDispatcher isOnQueueForType:RTCDispatcherTypeCaptureSession], |
| 365 @"updateDeviceCaptureFormat must be called on the capture queue."); | 365 @"updateDeviceCaptureFormat must be called on the capture queue."); |
| 366 @try { | 366 @try { |
| 367 _currentDevice.activeFormat = format; | 367 _currentDevice.activeFormat = format; |
| 368 _currentDevice.activeVideoMinFrameDuration = CMTimeMake(1, fps); | 368 _currentDevice.activeVideoMinFrameDuration = CMTimeMake(1, fps); |
| 369 } @catch (NSException *exception) { | 369 } @catch (NSException *exception) { |
| 370 RTCLogError(@"Failed to set active format!\n User info:%@", exception.userIn
fo); | 370 RTCLogError(@"Failed to set active format!\n User info:%@", exception.userIn
fo); |
| 371 return; | 371 return; |
| 372 } | 372 } |
| 373 } | 373 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 case UIDeviceOrientationFaceUp: | 415 case UIDeviceOrientationFaceUp: |
| 416 case UIDeviceOrientationFaceDown: | 416 case UIDeviceOrientationFaceDown: |
| 417 case UIDeviceOrientationUnknown: | 417 case UIDeviceOrientationUnknown: |
| 418 // Ignore. | 418 // Ignore. |
| 419 break; | 419 break; |
| 420 } | 420 } |
| 421 #endif | 421 #endif |
| 422 } | 422 } |
| 423 | 423 |
| 424 @end | 424 @end |
| OLD | NEW |