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

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

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

Powered by Google App Engine
This is Rietveld 408576698