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 |
11 #import "WebRTC/RTCCameraPreviewView.h" | 11 #import "WebRTC/RTCCameraPreviewView.h" |
12 | 12 |
13 #import <AVFoundation/AVFoundation.h> | 13 #import <AVFoundation/AVFoundation.h> |
14 #import <UIKit/UIKit.h> | 14 #import <UIKit/UIKit.h> |
15 | 15 |
16 #import "RTCDispatcher+Private.h" | 16 #import "RTCDispatcher+Private.h" |
17 | 17 |
18 @implementation RTCCameraPreviewView | 18 @implementation RTCCameraPreviewView |
19 | 19 |
20 @synthesize captureSession = _captureSession; | 20 @synthesize captureSession = _captureSession; |
21 | 21 |
22 + (Class)layerClass { | 22 + (Class)layerClass { |
23 return [AVCaptureVideoPreviewLayer class]; | 23 return [AVCaptureVideoPreviewLayer class]; |
24 } | 24 } |
25 | 25 |
26 - (void)setCaptureSession:(AVCaptureSession *)captureSession { | 26 - (void)setCaptureSession:(AVCaptureSession *)captureSession { |
27 if (_captureSession == captureSession) { | 27 if (_captureSession == captureSession) { |
28 return; | 28 return; |
29 } | 29 } |
30 _captureSession = captureSession; | 30 [RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeMain |
31 AVCaptureVideoPreviewLayer *previewLayer = [self previewLayer]; | |
32 [RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeCaptureSession | |
33 block:^{ | 31 block:^{ |
34 previewLayer.session = captureSession; | 32 _captureSession = captureSession; |
| 33 AVCaptureVideoPreviewLayer *previewLayer = [self previewLayer]; |
| 34 [RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeCaptureSession |
| 35 block:^{ |
| 36 previewLayer.session = captureSession; |
| 37 }]; |
35 }]; | 38 }]; |
36 } | 39 } |
37 | 40 |
38 - (void)layoutSubviews { | 41 - (void)layoutSubviews { |
39 [super layoutSubviews]; | 42 [super layoutSubviews]; |
40 | 43 |
41 // Update the video orientation based on the device orientation. | 44 // Update the video orientation based on the device orientation. |
42 [self setCorrectVideoOrientation]; | 45 [self setCorrectVideoOrientation]; |
43 } | 46 } |
44 | 47 |
(...skipping 21 matching lines...) Expand all Loading... |
66 } | 69 } |
67 } | 70 } |
68 | 71 |
69 #pragma mark - Private | 72 #pragma mark - Private |
70 | 73 |
71 - (AVCaptureVideoPreviewLayer *)previewLayer { | 74 - (AVCaptureVideoPreviewLayer *)previewLayer { |
72 return (AVCaptureVideoPreviewLayer *)self.layer; | 75 return (AVCaptureVideoPreviewLayer *)self.layer; |
73 } | 76 } |
74 | 77 |
75 @end | 78 @end |
OLD | NEW |