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

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/RTCCameraVideoCapturer.m

Issue 2811643006: Reconfigure capture session in a single transaction. (Closed)
Patch Set: Reconfigure capture session in a single transaction. Created 3 years, 8 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 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 } 371 }
372 372
373 - (void)reconfigureCaptureSessionInput { 373 - (void)reconfigureCaptureSessionInput {
374 NSError *error = nil; 374 NSError *error = nil;
375 AVCaptureDeviceInput *input = 375 AVCaptureDeviceInput *input =
376 [AVCaptureDeviceInput deviceInputWithDevice:_currentDevice error:&error]; 376 [AVCaptureDeviceInput deviceInputWithDevice:_currentDevice error:&error];
377 if (!input) { 377 if (!input) {
378 RTCLogError(@"Failed to create front camera input: %@", error.localizedDescr iption); 378 RTCLogError(@"Failed to create front camera input: %@", error.localizedDescr iption);
379 return; 379 return;
380 } 380 }
381 [_captureSession beginConfiguration];
381 for (AVCaptureDeviceInput *oldInput in [_captureSession.inputs copy]) { 382 for (AVCaptureDeviceInput *oldInput in [_captureSession.inputs copy]) {
382 [_captureSession removeInput:oldInput]; 383 [_captureSession removeInput:oldInput];
383 } 384 }
384 if ([_captureSession canAddInput:input]) { 385 if ([_captureSession canAddInput:input]) {
385 [_captureSession addInput:input]; 386 [_captureSession addInput:input];
386 } else { 387 } else {
387 RTCLogError(@"Cannot add camera as an input to the session."); 388 RTCLogError(@"Cannot add camera as an input to the session.");
388 return;
389 } 389 }
390 [_captureSession commitConfiguration];
390 } 391 }
391 392
392 - (void)updateOrientation { 393 - (void)updateOrientation {
393 #if TARGET_OS_IPHONE 394 #if TARGET_OS_IPHONE
394 BOOL usingFrontCamera = _currentDevice.position == AVCaptureDevicePositionFron t; 395 BOOL usingFrontCamera = _currentDevice.position == AVCaptureDevicePositionFron t;
395 switch ([UIDevice currentDevice].orientation) { 396 switch ([UIDevice currentDevice].orientation) {
396 case UIDeviceOrientationPortrait: 397 case UIDeviceOrientationPortrait:
397 _rotation = RTCVideoRotation_90; 398 _rotation = RTCVideoRotation_90;
398 break; 399 break;
399 case UIDeviceOrientationPortraitUpsideDown: 400 case UIDeviceOrientationPortraitUpsideDown:
400 _rotation = RTCVideoRotation_270; 401 _rotation = RTCVideoRotation_270;
401 break; 402 break;
402 case UIDeviceOrientationLandscapeLeft: 403 case UIDeviceOrientationLandscapeLeft:
403 _rotation = usingFrontCamera ? RTCVideoRotation_180 : RTCVideoRotation_0; 404 _rotation = usingFrontCamera ? RTCVideoRotation_180 : RTCVideoRotation_0;
404 break; 405 break;
405 case UIDeviceOrientationLandscapeRight: 406 case UIDeviceOrientationLandscapeRight:
406 _rotation = usingFrontCamera ? RTCVideoRotation_0 : RTCVideoRotation_180; 407 _rotation = usingFrontCamera ? RTCVideoRotation_0 : RTCVideoRotation_180;
407 break; 408 break;
408 case UIDeviceOrientationFaceUp: 409 case UIDeviceOrientationFaceUp:
409 case UIDeviceOrientationFaceDown: 410 case UIDeviceOrientationFaceDown:
410 case UIDeviceOrientationUnknown: 411 case UIDeviceOrientationUnknown:
411 // Ignore. 412 // Ignore.
412 break; 413 break;
413 } 414 }
414 #endif 415 #endif
415 } 416 }
416 417
417 @end 418 @end
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