Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(989)

Side by Side Diff: webrtc/api/objc/RTCAVFoundationVideoSource.mm

Issue 1766653002: Replace SetCapturer and SetCaptureDevice by SetSource. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased, no longer any proxy object changes. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/api/mediastreamprovider.h ('k') | webrtc/api/rtpsender.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 {
18 webrtc::AVFoundationVideoCapturer *_capturer;
19 }
18 20
19 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory 21 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
20 constraints:(RTCMediaConstraints *)constraints { 22 constraints:(RTCMediaConstraints *)constraints {
21 NSParameterAssert(factory); 23 NSParameterAssert(factory);
22 rtc::scoped_ptr<webrtc::AVFoundationVideoCapturer> capturer; 24 // We pass ownership of the capturer to the source, but since we own
23 capturer.reset(new webrtc::AVFoundationVideoCapturer()); 25 // the source, it should be ok to keep a raw pointer to the
26 // capturer.
27 _capturer = new webrtc::AVFoundationVideoCapturer();
24 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source = 28 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source =
25 factory.nativeFactory->CreateVideoSource( 29 factory.nativeFactory->CreateVideoSource(
26 capturer.release(), constraints.nativeConstraints.get()); 30 _capturer, constraints.nativeConstraints.get());
31
27 return [super initWithNativeVideoSource:source]; 32 return [super initWithNativeVideoSource:source];
28 } 33 }
29 34
30 - (BOOL)canUseBackCamera { 35 - (BOOL)canUseBackCamera {
31 return self.capturer->CanUseBackCamera(); 36 return self.capturer->CanUseBackCamera();
32 } 37 }
33 38
34 - (BOOL)useBackCamera { 39 - (BOOL)useBackCamera {
35 return self.capturer->GetUseBackCamera(); 40 return self.capturer->GetUseBackCamera();
36 } 41 }
37 42
38 - (void)setUseBackCamera:(BOOL)useBackCamera { 43 - (void)setUseBackCamera:(BOOL)useBackCamera {
39 self.capturer->SetUseBackCamera(useBackCamera); 44 self.capturer->SetUseBackCamera(useBackCamera);
40 } 45 }
41 46
42 - (AVCaptureSession *)captureSession { 47 - (AVCaptureSession *)captureSession {
43 return self.capturer->GetCaptureSession(); 48 return self.capturer->GetCaptureSession();
44 } 49 }
45 50
46 - (webrtc::AVFoundationVideoCapturer *)capturer { 51 - (webrtc::AVFoundationVideoCapturer *)capturer {
47 cricket::VideoCapturer *capturer = self.nativeVideoSource->GetVideoCapturer(); 52 return _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 } 53 }
54 54
55 @end 55 @end
OLDNEW
« no previous file with comments | « webrtc/api/mediastreamprovider.h ('k') | webrtc/api/rtpsender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698