blob: 659973ff1804c280306221ff88a706dc9252f4b1 [file] [log] [blame]
hayscedd8fef2015-12-08 11:08:39 -08001/*
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
tkchin9eeb6242016-04-27 01:54:20 -070011#import "WebRTC/RTCCameraPreviewView.h"
hayscedd8fef2015-12-08 11:08:39 -080012
13#import <AVFoundation/AVFoundation.h>
14
tkchin9eeb6242016-04-27 01:54:20 -070015#import "RTCDispatcher+Private.h"
hayscedd8fef2015-12-08 11:08:39 -080016
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