Chromium Code Reviews| 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 "RTCAVFoundationVideoSource+Private.h" | 11 #import "RTCAVFoundationVideoSource+Private.h" |
| 12 | 12 |
| 13 #import "webrtc/api/objc/RTCMediaConstraints+Private.h" | 13 #import "webrtc/api/objc/RTCMediaConstraints+Private.h" |
| 14 #import "webrtc/api/objc/RTCPeerConnectionFactory+Private.h" | 14 #import "webrtc/api/objc/RTCPeerConnectionFactory+Private.h" |
| 15 #import "webrtc/api/objc/RTCVideoSource+Private.h" | 15 #import "webrtc/api/objc/RTCVideoSource+Private.h" |
| 16 | 16 |
| 17 @implementation RTCAVFoundationVideoSource | 17 @implementation RTCAVFoundationVideoSource |
|
tkchin_webrtc
2016/04/05 16:10:27
ditto
| |
| 18 | 18 |
| 19 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory | 19 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory |
| 20 constraints:(RTCMediaConstraints *)constraints { | 20 constraints:(RTCMediaConstraints *)constraints { |
| 21 NSParameterAssert(factory); | 21 NSParameterAssert(factory); |
| 22 rtc::scoped_ptr<webrtc::AVFoundationVideoCapturer> capturer; | 22 webrtc::AVFoundationVideoCapturer *capturer = |
| 23 capturer.reset(new webrtc::AVFoundationVideoCapturer()); | 23 new webrtc::AVFoundationVideoCapturer(); |
| 24 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source = | 24 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source = |
| 25 factory.nativeFactory->CreateVideoSource( | 25 factory.nativeFactory->CreateVideoSource( |
| 26 capturer.release(), constraints.nativeConstraints.get()); | 26 capturer, constraints.nativeConstraints.get()); |
| 27 // We pass ownership of the capturer to the source, but since we own | |
| 28 // the source, it should be ok to keep a raw pointer to the | |
| 29 // capturer. | |
| 30 _capturer = static_cast<void*>(capturer); | |
| 27 return [super initWithNativeVideoSource:source]; | 31 return [super initWithNativeVideoSource:source]; |
| 28 } | 32 } |
| 29 | 33 |
| 30 - (BOOL)canUseBackCamera { | 34 - (BOOL)canUseBackCamera { |
| 31 return self.capturer->CanUseBackCamera(); | 35 return self.capturer->CanUseBackCamera(); |
| 32 } | 36 } |
| 33 | 37 |
| 34 - (BOOL)useBackCamera { | 38 - (BOOL)useBackCamera { |
| 35 return self.capturer->GetUseBackCamera(); | 39 return self.capturer->GetUseBackCamera(); |
| 36 } | 40 } |
| 37 | 41 |
| 38 - (void)setUseBackCamera:(BOOL)useBackCamera { | 42 - (void)setUseBackCamera:(BOOL)useBackCamera { |
| 39 self.capturer->SetUseBackCamera(useBackCamera); | 43 self.capturer->SetUseBackCamera(useBackCamera); |
| 40 } | 44 } |
| 41 | 45 |
| 42 - (AVCaptureSession *)captureSession { | 46 - (AVCaptureSession *)captureSession { |
| 43 return self.capturer->GetCaptureSession(); | 47 return self.capturer->GetCaptureSession(); |
| 44 } | 48 } |
| 45 | 49 |
| 46 - (webrtc::AVFoundationVideoCapturer *)capturer { | 50 - (webrtc::AVFoundationVideoCapturer *)capturer { |
| 47 cricket::VideoCapturer *capturer = self.nativeVideoSource->GetVideoCapturer(); | 51 return static_cast<webrtc::AVFoundationVideoCapturer *>(_capturer); |
| 48 // This should be safe because no one should have changed the underlying video | |
| 49 // source. | |
| 50 webrtc::AVFoundationVideoCapturer *foundationCapturer = | |
| 51 static_cast<webrtc::AVFoundationVideoCapturer *>(capturer); | |
| 52 return foundationCapturer; | |
| 53 } | 52 } |
| 54 | 53 |
| 55 @end | 54 @end |
| OLD | NEW |