haysc | edd8fef | 2015-12-08 11:08:39 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
tkchin | 9eeb624 | 2016-04-27 01:54:20 -0700 | [diff] [blame] | 11 | #import "WebRTC/RTCCameraPreviewView.h" |
haysc | edd8fef | 2015-12-08 11:08:39 -0800 | [diff] [blame] | 12 | |
| 13 | #import <AVFoundation/AVFoundation.h> |
| 14 | |
tkchin | 9eeb624 | 2016-04-27 01:54:20 -0700 | [diff] [blame] | 15 | #import "RTCDispatcher+Private.h" |
haysc | edd8fef | 2015-12-08 11:08:39 -0800 | [diff] [blame] | 16 | |
| 17 | @implementation RTCCameraPreviewView |
| 18 | |
| 19 | @synthesize captureSession = _captureSession; |
| 20 | |
| 21 | + (Class)layerClass { |
| 22 | return [AVCaptureVideoPreviewLayer class]; |
| 23 | } |
| 24 | |
| 25 | - (void)setCaptureSession:(AVCaptureSession *)captureSession { |
| 26 | if (_captureSession == captureSession) { |
| 27 | return; |
| 28 | } |
| 29 | _captureSession = captureSession; |
| 30 | AVCaptureVideoPreviewLayer *previewLayer = [self previewLayer]; |
| 31 | [RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeCaptureSession |
| 32 | block:^{ |
| 33 | previewLayer.session = captureSession; |
| 34 | }]; |
| 35 | } |
| 36 | |
| 37 | #pragma mark - Private |
| 38 | |
| 39 | - (AVCaptureVideoPreviewLayer *)previewLayer { |
| 40 | return (AVCaptureVideoPreviewLayer *)self.layer; |
| 41 | } |
| 42 | |
| 43 | @end |