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

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm

Issue 2966023002: Injectable Obj-C video codecs (Closed)
Patch Set: Fix formatting and build targets. Created 3 years, 5 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
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 "RTCPeerConnectionFactory+Private.h" 11 #import "RTCPeerConnectionFactory+Private.h"
12 12
13 #import "NSString+StdString.h" 13 #import "NSString+StdString.h"
14 #import "RTCAVFoundationVideoSource+Private.h"
14 #import "RTCAudioSource+Private.h" 15 #import "RTCAudioSource+Private.h"
15 #import "RTCAudioTrack+Private.h" 16 #import "RTCAudioTrack+Private.h"
16 #import "RTCMediaConstraints+Private.h" 17 #import "RTCMediaConstraints+Private.h"
17 #import "RTCMediaStream+Private.h" 18 #import "RTCMediaStream+Private.h"
18 #import "RTCPeerConnection+Private.h" 19 #import "RTCPeerConnection+Private.h"
19 #import "RTCVideoSource+Private.h" 20 #import "RTCVideoSource+Private.h"
20 #import "RTCVideoTrack+Private.h" 21 #import "RTCVideoTrack+Private.h"
21 #import "RTCAVFoundationVideoSource+Private.h"
22 #import "WebRTC/RTCLogging.h" 22 #import "WebRTC/RTCLogging.h"
23 #import "WebRTC/RTCVideoCodecFactory.h"
24 #import "WebRTC/RTCVideoCodecH264.h"
23 25
26 #ifndef HAVE_NO_MEDIA
27 #include "PeerConnection/objc_video_decoder_factory.h"
28 #include "PeerConnection/objc_video_encoder_factory.h"
29 #endif
24 #include "Video/objcvideotracksource.h" 30 #include "Video/objcvideotracksource.h"
25 #include "VideoToolbox/videocodecfactory.h"
26 #include "webrtc/api/videosourceproxy.h" 31 #include "webrtc/api/videosourceproxy.h"
27 // Adding the nogncheck to disable the including header check. 32 // Adding the nogncheck to disable the including header check.
28 // The no-media version PeerConnectionFactory doesn't depend on media related 33 // The no-media version PeerConnectionFactory doesn't depend on media related
29 // C++ target. 34 // C++ target.
30 // TODO(zhihuang): Remove nogncheck once MediaEngineInterface is moved to C++ 35 // TODO(zhihuang): Remove nogncheck once MediaEngineInterface is moved to C++
31 // API layer. 36 // API layer.
32 #include "webrtc/media/engine/webrtcmediaengine.h" // nogncheck 37 #include "webrtc/media/engine/webrtcmediaengine.h" // nogncheck
33 38
34 @implementation RTCPeerConnectionFactory { 39 @implementation RTCPeerConnectionFactory {
35 std::unique_ptr<rtc::Thread> _networkThread; 40 std::unique_ptr<rtc::Thread> _networkThread;
36 std::unique_ptr<rtc::Thread> _workerThread; 41 std::unique_ptr<rtc::Thread> _workerThread;
37 std::unique_ptr<rtc::Thread> _signalingThread; 42 std::unique_ptr<rtc::Thread> _signalingThread;
38 BOOL _hasStartedAecDump; 43 BOOL _hasStartedAecDump;
39 } 44 }
40 45
41 @synthesize nativeFactory = _nativeFactory; 46 @synthesize nativeFactory = _nativeFactory;
42 47
43 - (instancetype)init { 48 - (instancetype)init {
44 if ((self = [super init])) { 49 return [self initWithEncoderFactory:[[RTCVideoEncoderFactoryH264 alloc] init]
50 decoderFactory:[[RTCVideoDecoderFactoryH264 alloc] init]] ;
51 }
52
53 - (instancetype)initWithEncoderFactory:(id<RTCVideoEncoderFactory>)encoderFactor y
54 decoderFactory:(id<RTCVideoDecoderFactory>)decoderFactor y {
55 if (self = [super init]) {
45 _networkThread = rtc::Thread::CreateWithSocketServer(); 56 _networkThread = rtc::Thread::CreateWithSocketServer();
46 BOOL result = _networkThread->Start(); 57 BOOL result = _networkThread->Start();
47 NSAssert(result, @"Failed to start network thread."); 58 NSAssert(result, @"Failed to start network thread.");
48 59
49 _workerThread = rtc::Thread::Create(); 60 _workerThread = rtc::Thread::Create();
50 result = _workerThread->Start(); 61 result = _workerThread->Start();
51 NSAssert(result, @"Failed to start worker thread."); 62 NSAssert(result, @"Failed to start worker thread.");
52 63
53 _signalingThread = rtc::Thread::Create(); 64 _signalingThread = rtc::Thread::Create();
54 result = _signalingThread->Start(); 65 result = _signalingThread->Start();
55 NSAssert(result, @"Failed to start signaling thread."); 66 NSAssert(result, @"Failed to start signaling thread.");
56 #ifdef HAVE_NO_MEDIA 67 #ifdef HAVE_NO_MEDIA
57 _nativeFactory = webrtc::CreateModularPeerConnectionFactory( 68 _nativeFactory = webrtc::CreateModularPeerConnectionFactory(
58 _networkThread.get(), 69 _networkThread.get(),
59 _workerThread.get(), 70 _workerThread.get(),
60 _signalingThread.get(), 71 _signalingThread.get(),
61 nullptr, // default_adm 72 nullptr, // default_adm
62 nullptr, // audio_encoder_factory 73 nullptr, // audio_encoder_factory
63 nullptr, // audio_decoder_factory 74 nullptr, // audio_decoder_factory
64 nullptr, // video_encoder_factory 75 nullptr, // video_encoder_factory
65 nullptr, // video_decoder_factory 76 nullptr, // video_decoder_factory
66 nullptr, // audio_mixer 77 nullptr, // audio_mixer
67 std::unique_ptr<cricket::MediaEngineInterface>(), 78 std::unique_ptr<cricket::MediaEngineInterface>(),
68 std::unique_ptr<webrtc::CallFactoryInterface>(), 79 std::unique_ptr<webrtc::CallFactoryInterface>(),
69 std::unique_ptr<webrtc::RtcEventLogFactoryInterface>()); 80 std::unique_ptr<webrtc::RtcEventLogFactoryInterface>());
70 #else 81 #else
71 const auto encoder_factory = new webrtc::VideoToolboxVideoEncoderFactory(); 82 const auto encoder_factory = new webrtc::ObjCVideoEncoderFactory(encoderFact ory);
72 const auto decoder_factory = new webrtc::VideoToolboxVideoDecoderFactory(); 83 const auto decoder_factory = new webrtc::ObjCVideoDecoderFactory(decoderFact ory);
73 84
74 // Ownership of encoder/decoder factories is passed on to the 85 // Ownership of encoder/decoder factories is passed on to the
75 // peerconnectionfactory, that handles deleting them. 86 // peerconnectionfactory, that handles deleting them.
76 _nativeFactory = webrtc::CreatePeerConnectionFactory( 87 _nativeFactory = webrtc::CreatePeerConnectionFactory(
77 _networkThread.get(), _workerThread.get(), _signalingThread.get(), 88 _networkThread.get(), _workerThread.get(), _signalingThread.get(),
78 nullptr, encoder_factory, decoder_factory); 89 nullptr, encoder_factory, decoder_factory);
79 #endif 90 #endif
80 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); 91 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!");
81 } 92 }
82 return self; 93 return self;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 _hasStartedAecDump = _nativeFactory->StartAecDump(fd, maxSizeInBytes); 174 _hasStartedAecDump = _nativeFactory->StartAecDump(fd, maxSizeInBytes);
164 return _hasStartedAecDump; 175 return _hasStartedAecDump;
165 } 176 }
166 177
167 - (void)stopAecDump { 178 - (void)stopAecDump {
168 _nativeFactory->StopAecDump(); 179 _nativeFactory->StopAecDump();
169 _hasStartedAecDump = NO; 180 _hasStartedAecDump = NO;
170 } 181 }
171 182
172 @end 183 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698