OLD | NEW |
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 name:UIDeviceOrientationDidChangeNotification | 107 name:UIDeviceOrientationDidChangeNotification |
108 object:nil]; | 108 object:nil]; |
109 [center addObserver:self | 109 [center addObserver:self |
110 selector:@selector(handleCaptureSessionInterruption:) | 110 selector:@selector(handleCaptureSessionInterruption:) |
111 name:AVCaptureSessionWasInterruptedNotification | 111 name:AVCaptureSessionWasInterruptedNotification |
112 object:_captureSession]; | 112 object:_captureSession]; |
113 [center addObserver:self | 113 [center addObserver:self |
114 selector:@selector(handleCaptureSessionInterruptionEnded:) | 114 selector:@selector(handleCaptureSessionInterruptionEnded:) |
115 name:AVCaptureSessionInterruptionEndedNotification | 115 name:AVCaptureSessionInterruptionEndedNotification |
116 object:_captureSession]; | 116 object:_captureSession]; |
| 117 [center addObserver:self |
| 118 selector:@selector(handleApplicationDidBecomeActive:) |
| 119 name:UIApplicationDidBecomeActiveNotification |
| 120 object:[UIApplication sharedApplication]]; |
117 #endif | 121 #endif |
118 [center addObserver:self | 122 [center addObserver:self |
119 selector:@selector(handleCaptureSessionRuntimeError:) | 123 selector:@selector(handleCaptureSessionRuntimeError:) |
120 name:AVCaptureSessionRuntimeErrorNotification | 124 name:AVCaptureSessionRuntimeErrorNotification |
121 object:_captureSession]; | 125 object:_captureSession]; |
122 [center addObserver:self | 126 [center addObserver:self |
123 selector:@selector(handleCaptureSessionDidStartRunning:) | 127 selector:@selector(handleCaptureSessionDidStartRunning:) |
124 name:AVCaptureSessionDidStartRunningNotification | 128 name:AVCaptureSessionDidStartRunningNotification |
125 object:_captureSession]; | 129 object:_captureSession]; |
126 [center addObserver:self | 130 [center addObserver:self |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 - (void)handleNonFatalError { | 348 - (void)handleNonFatalError { |
345 [RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeCaptureSession | 349 [RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeCaptureSession |
346 block:^{ | 350 block:^{ |
347 if (self.hasStarted) { | 351 if (self.hasStarted) { |
348 RTCLog(@"Restarting capture session after error."); | 352 RTCLog(@"Restarting capture session after error."); |
349 [self.captureSession startRunning]; | 353 [self.captureSession startRunning]; |
350 } | 354 } |
351 }]; | 355 }]; |
352 } | 356 } |
353 | 357 |
| 358 #if TARGET_OS_IPHONE |
| 359 |
| 360 #pragma mark - UIApplication notifications |
| 361 |
| 362 - (void)handleApplicationDidBecomeActive:(NSNotification *)notification { |
| 363 [RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeCaptureSession |
| 364 block:^{ |
| 365 if (self.hasStarted && !self.captureSession.isRunning) { |
| 366 RTCLog(@"Restarting capture session on active."); |
| 367 [self.captureSession startRunning]; |
| 368 } |
| 369 }]; |
| 370 } |
| 371 |
| 372 #endif // TARGET_OS_IPHONE |
| 373 |
354 #pragma mark - Private | 374 #pragma mark - Private |
355 | 375 |
356 - (BOOL)setupCaptureSession { | 376 - (BOOL)setupCaptureSession { |
357 AVCaptureSession *captureSession = [[AVCaptureSession alloc] init]; | 377 AVCaptureSession *captureSession = [[AVCaptureSession alloc] init]; |
358 #if defined(__IPHONE_7_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0 | 378 #if defined(__IPHONE_7_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0 |
359 NSString *version = [[UIDevice currentDevice] systemVersion]; | 379 NSString *version = [[UIDevice currentDevice] systemVersion]; |
360 if ([version integerValue] >= 7) { | 380 if ([version integerValue] >= 7) { |
361 captureSession.usesApplicationAudioSession = NO; | 381 captureSession.usesApplicationAudioSession = NO; |
362 } | 382 } |
363 #endif | 383 #endif |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 } | 745 } |
726 | 746 |
727 OnFrame(cricket::WebRtcVideoFrame(buffer, webrtc::kVideoRotation_0, | 747 OnFrame(cricket::WebRtcVideoFrame(buffer, webrtc::kVideoRotation_0, |
728 translated_camera_time_us, 0), | 748 translated_camera_time_us, 0), |
729 captured_width, captured_height); | 749 captured_width, captured_height); |
730 | 750 |
731 CVBufferRelease(image_buffer); | 751 CVBufferRelease(image_buffer); |
732 } | 752 } |
733 | 753 |
734 } // namespace webrtc | 754 } // namespace webrtc |
OLD | NEW |