Chromium Code Reviews| Index: talk/app/webrtc/objc/RTCCameraPreviewView.mm |
| diff --git a/talk/app/webrtc/objc/RTCCameraPreviewView.mm b/talk/app/webrtc/objc/RTCCameraPreviewView.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e982be2e462a27b7a9732ec872336910af798330 |
| --- /dev/null |
| +++ b/talk/app/webrtc/objc/RTCCameraPreviewView.mm |
| @@ -0,0 +1,51 @@ |
| +/* |
| + * Copyright 2015 The WebRTC Project Authors. All rights reserved. |
| + * |
| + * Use of this source code is governed by a BSD-style license |
| + * that can be found in the LICENSE file in the root of the source |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| + */ |
| +#if !defined(__has_feature) || !__has_feature(objc_arc) |
|
tkchin_webrtc
2015/12/04 22:19:42
nit: add blank line
Chuck
2015/12/05 00:21:23
Done.
|
| +#error "This file requires ARC support." |
| +#endif |
| + |
| +#import "RTCCameraPreviewView.h" |
| + |
| +#import <AVFoundation/AVFoundation.h> |
| + |
| +#import "RTCAVFoundationVideoSource+Internal.h" |
| + |
| +@implementation RTCCameraPreviewView |
| + |
| +@synthesize videoSource = _videoSource; |
| + |
| ++ (Class)layerClass { |
| + return [AVCaptureVideoPreviewLayer class]; |
| +} |
| + |
| + |
|
tkchin_webrtc
2015/12/04 22:19:41
nit: remove blank line
Chuck
2015/12/05 00:21:23
Done.
|
| +- (void)setVideoSource:(RTCAVFoundationVideoSource *)videoSource { |
| + if (_videoSource == videoSource) { |
|
tkchin_webrtc
2015/12/04 22:19:41
Suggest not making this class depend on that parti
Chuck
2015/12/05 00:21:23
Done.
|
| + return; |
| + } |
| + _videoSource = videoSource; |
| + AVCaptureSession *captureSession = videoSource.captureSession; |
| + AVCaptureVideoPreviewLayer *previewLayer = [self previewLayer]; |
| + if (!videoSource) { |
| + previewLayer.session = nil; |
| + return; |
| + } |
| + dispatch_async(videoSource.captureSessionQueue, ^{ |
| + previewLayer.session = captureSession; |
| + }); |
| +} |
| + |
| +#pragma mark - Private |
| + |
| +- (AVCaptureVideoPreviewLayer *)previewLayer { |
| + return (AVCaptureVideoPreviewLayer *)self.layer; |
| +} |
| + |
| +@end |