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

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

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

Powered by Google App Engine
This is Rietveld 408576698