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 #if !defined(__has_feature) || !__has_feature(objc_arc) | 11 #import "WebRTC/RTCCameraPreviewView.h" |
12 #error "This file requires ARC support." | |
13 #endif | |
14 | |
15 #import "webrtc/base/objc/RTCCameraPreviewView.h" | |
16 | 12 |
17 #import <AVFoundation/AVFoundation.h> | 13 #import <AVFoundation/AVFoundation.h> |
18 | 14 |
19 #import "webrtc/base/objc/RTCDispatcher.h" | 15 #import "RTCDispatcher+Private.h" |
20 | 16 |
21 @implementation RTCCameraPreviewView | 17 @implementation RTCCameraPreviewView |
22 | 18 |
23 @synthesize captureSession = _captureSession; | 19 @synthesize captureSession = _captureSession; |
24 | 20 |
25 + (Class)layerClass { | 21 + (Class)layerClass { |
26 return [AVCaptureVideoPreviewLayer class]; | 22 return [AVCaptureVideoPreviewLayer class]; |
27 } | 23 } |
28 | 24 |
29 - (void)setCaptureSession:(AVCaptureSession *)captureSession { | 25 - (void)setCaptureSession:(AVCaptureSession *)captureSession { |
30 if (_captureSession == captureSession) { | 26 if (_captureSession == captureSession) { |
31 return; | 27 return; |
32 } | 28 } |
33 _captureSession = captureSession; | 29 _captureSession = captureSession; |
34 AVCaptureVideoPreviewLayer *previewLayer = [self previewLayer]; | 30 AVCaptureVideoPreviewLayer *previewLayer = [self previewLayer]; |
35 [RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeCaptureSession | 31 [RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeCaptureSession |
36 block:^{ | 32 block:^{ |
37 previewLayer.session = captureSession; | 33 previewLayer.session = captureSession; |
38 }]; | 34 }]; |
39 } | 35 } |
40 | 36 |
41 #pragma mark - Private | 37 #pragma mark - Private |
42 | 38 |
43 - (AVCaptureVideoPreviewLayer *)previewLayer { | 39 - (AVCaptureVideoPreviewLayer *)previewLayer { |
44 return (AVCaptureVideoPreviewLayer *)self.layer; | 40 return (AVCaptureVideoPreviewLayer *)self.layer; |
45 } | 41 } |
46 | 42 |
47 @end | 43 @end |
OLD | NEW |