OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2016 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 |
11 #import "RTCAVFoundationVideoCapturerInternal.h" | 11 #import "RTCAVFoundationVideoCapturerInternal.h" |
12 | 12 |
13 #import <Foundation/Foundation.h> | 13 #import <Foundation/Foundation.h> |
14 #if TARGET_OS_IPHONE | 14 #if TARGET_OS_IPHONE |
15 #import <UIKit/UIKit.h> | 15 #import <UIKit/UIKit.h> |
| 16 #import "WebRTC/UIDevice+RTCDevice.h" |
16 #endif | 17 #endif |
17 | 18 |
18 #import "RTCDispatcher+Private.h" | 19 #import "RTCDispatcher+Private.h" |
19 #import "WebRTC/RTCLogging.h" | 20 #import "WebRTC/RTCLogging.h" |
20 | 21 |
21 #include "avfoundationformatmapper.h" | 22 #include "avfoundationformatmapper.h" |
22 | 23 |
23 @implementation RTCAVFoundationVideoCapturerInternal { | 24 @implementation RTCAVFoundationVideoCapturerInternal { |
24 // Keep pointers to inputs for convenience. | 25 // Keep pointers to inputs for convenience. |
25 AVCaptureDeviceInput *_frontCameraInput; | 26 AVCaptureDeviceInput *_frontCameraInput; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 fromConnection:(AVCaptureConnection *)connection { | 226 fromConnection:(AVCaptureConnection *)connection { |
226 RTCLogError(@"Dropped sample buffer."); | 227 RTCLogError(@"Dropped sample buffer."); |
227 } | 228 } |
228 | 229 |
229 #pragma mark - AVCaptureSession notifications | 230 #pragma mark - AVCaptureSession notifications |
230 | 231 |
231 - (void)handleCaptureSessionInterruption:(NSNotification *)notification { | 232 - (void)handleCaptureSessionInterruption:(NSNotification *)notification { |
232 NSString *reasonString = nil; | 233 NSString *reasonString = nil; |
233 #if defined(__IPHONE_9_0) && defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \ | 234 #if defined(__IPHONE_9_0) && defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \ |
234 __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_9_0 | 235 __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_9_0 |
235 NSNumber *reason = notification.userInfo[AVCaptureSessionInterruptionReasonKey
]; | 236 if ([UIDevice isIOS9OrLater]) { |
236 if (reason) { | 237 NSNumber *reason = notification.userInfo[AVCaptureSessionInterruptionReasonK
ey]; |
237 switch (reason.intValue) { | 238 if (reason) { |
238 case AVCaptureSessionInterruptionReasonVideoDeviceNotAvailableInBackground
: | 239 switch (reason.intValue) { |
239 reasonString = @"VideoDeviceNotAvailableInBackground"; | 240 case AVCaptureSessionInterruptionReasonVideoDeviceNotAvailableInBackgrou
nd: |
240 break; | 241 reasonString = @"VideoDeviceNotAvailableInBackground"; |
241 case AVCaptureSessionInterruptionReasonAudioDeviceInUseByAnotherClient: | 242 break; |
242 reasonString = @"AudioDeviceInUseByAnotherClient"; | 243 case AVCaptureSessionInterruptionReasonAudioDeviceInUseByAnotherClient: |
243 break; | 244 reasonString = @"AudioDeviceInUseByAnotherClient"; |
244 case AVCaptureSessionInterruptionReasonVideoDeviceInUseByAnotherClient: | 245 break; |
245 reasonString = @"VideoDeviceInUseByAnotherClient"; | 246 case AVCaptureSessionInterruptionReasonVideoDeviceInUseByAnotherClient: |
246 break; | 247 reasonString = @"VideoDeviceInUseByAnotherClient"; |
247 case AVCaptureSessionInterruptionReasonVideoDeviceNotAvailableWithMultiple
ForegroundApps: | 248 break; |
248 reasonString = @"VideoDeviceNotAvailableWithMultipleForegroundApps"; | 249 case AVCaptureSessionInterruptionReasonVideoDeviceNotAvailableWithMultip
leForegroundApps: |
249 break; | 250 reasonString = @"VideoDeviceNotAvailableWithMultipleForegroundApps"; |
| 251 break; |
| 252 } |
250 } | 253 } |
251 } | 254 } |
252 #endif | 255 #endif |
253 RTCLog(@"Capture session interrupted: %@", reasonString); | 256 RTCLog(@"Capture session interrupted: %@", reasonString); |
254 // TODO(tkchin): Handle this case. | 257 // TODO(tkchin): Handle this case. |
255 } | 258 } |
256 | 259 |
257 - (void)handleCaptureSessionInterruptionEnded:(NSNotification *)notification { | 260 - (void)handleCaptureSessionInterruptionEnded:(NSNotification *)notification { |
258 RTCLog(@"Capture session interruption ended."); | 261 RTCLog(@"Capture session interruption ended."); |
259 // TODO(tkchin): Handle this case. | 262 // TODO(tkchin): Handle this case. |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 AVCaptureDevice *newDevice = newInput.device; | 494 AVCaptureDevice *newDevice = newInput.device; |
492 const cricket::VideoFormat *format = | 495 const cricket::VideoFormat *format = |
493 _capturer->GetCaptureFormat(); | 496 _capturer->GetCaptureFormat(); |
494 webrtc::SetFormatForCaptureDevice( | 497 webrtc::SetFormatForCaptureDevice( |
495 newDevice, _captureSession, *format); | 498 newDevice, _captureSession, *format); |
496 [_captureSession commitConfiguration]; | 499 [_captureSession commitConfiguration]; |
497 }]; | 500 }]; |
498 } | 501 } |
499 | 502 |
500 @end | 503 @end |
OLD | NEW |