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

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

Issue 2966023002: Injectable Obj-C video codecs (Closed)
Patch Set: Support nil encoder / decoder. 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 #ifndef HAVE_NO_MEDIA
25 #import "WebRTC/RTCVideoCodecH264.h"
26 #endif
23 27
28 #include "PeerConnection/objc_video_decoder_factory.h"
29 #include "PeerConnection/objc_video_encoder_factory.h"
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 #ifdef HAVE_NO_MEDIA
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]) {
45 _networkThread = rtc::Thread::CreateWithSocketServer(); 60 _networkThread = rtc::Thread::CreateWithSocketServer();
46 BOOL result = _networkThread->Start(); 61 BOOL result = _networkThread->Start();
47 NSAssert(result, @"Failed to start network thread."); 62 NSAssert(result, @"Failed to start network thread.");
48 63
49 _workerThread = rtc::Thread::Create(); 64 _workerThread = rtc::Thread::Create();
50 result = _workerThread->Start(); 65 result = _workerThread->Start();
51 NSAssert(result, @"Failed to start worker thread."); 66 NSAssert(result, @"Failed to start worker thread.");
52 67
53 _signalingThread = rtc::Thread::Create(); 68 _signalingThread = rtc::Thread::Create();
54 result = _signalingThread->Start(); 69 result = _signalingThread->Start();
55 NSAssert(result, @"Failed to start signaling thread."); 70 NSAssert(result, @"Failed to start signaling thread.");
56 #ifdef HAVE_NO_MEDIA 71 #ifdef HAVE_NO_MEDIA
57 _nativeFactory = webrtc::CreateModularPeerConnectionFactory( 72 _nativeFactory = webrtc::CreateModularPeerConnectionFactory(
58 _networkThread.get(), 73 _networkThread.get(),
59 _workerThread.get(), 74 _workerThread.get(),
60 _signalingThread.get(), 75 _signalingThread.get(),
61 nullptr, // default_adm 76 nullptr, // default_adm
62 nullptr, // audio_encoder_factory 77 nullptr, // audio_encoder_factory
63 nullptr, // audio_decoder_factory 78 nullptr, // audio_decoder_factory
64 nullptr, // video_encoder_factory 79 nullptr, // video_encoder_factory
65 nullptr, // video_decoder_factory 80 nullptr, // video_decoder_factory
66 nullptr, // audio_mixer 81 nullptr, // audio_mixer
67 std::unique_ptr<cricket::MediaEngineInterface>(), 82 std::unique_ptr<cricket::MediaEngineInterface>(),
68 std::unique_ptr<webrtc::CallFactoryInterface>(), 83 std::unique_ptr<webrtc::CallFactoryInterface>(),
69 std::unique_ptr<webrtc::RtcEventLogFactoryInterface>()); 84 std::unique_ptr<webrtc::RtcEventLogFactoryInterface>());
70 #else 85 #else
71 const auto encoder_factory = new webrtc::VideoToolboxVideoEncoderFactory(); 86 cricket::WebRtcVideoEncoderFactory *encoder_factory = nullptr;
72 const auto decoder_factory = new webrtc::VideoToolboxVideoDecoderFactory(); 87 cricket::WebRtcVideoDecoderFactory *decoder_factory = nullptr;
88 if (encoderFactory) {
89 encoder_factory = new webrtc::ObjCVideoEncoderFactory(encoderFactory);
90 }
91 if (decoderFactory) {
92 decoder_factory = new webrtc::ObjCVideoDecoderFactory(decoderFactory);
93 }
73 94
74 // Ownership of encoder/decoder factories is passed on to the 95 // Ownership of encoder/decoder factories is passed on to the
75 // peerconnectionfactory, that handles deleting them. 96 // peerconnectionfactory, that handles deleting them.
76 _nativeFactory = webrtc::CreatePeerConnectionFactory( 97 _nativeFactory = webrtc::CreatePeerConnectionFactory(
77 _networkThread.get(), _workerThread.get(), _signalingThread.get(), 98 _networkThread.get(), _workerThread.get(), _signalingThread.get(),
78 nullptr, encoder_factory, decoder_factory); 99 nullptr, encoder_factory, decoder_factory);
79 #endif 100 #endif
80 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); 101 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!");
81 } 102 }
82 return self; 103 return self;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 _hasStartedAecDump = _nativeFactory->StartAecDump(fd, maxSizeInBytes); 184 _hasStartedAecDump = _nativeFactory->StartAecDump(fd, maxSizeInBytes);
164 return _hasStartedAecDump; 185 return _hasStartedAecDump;
165 } 186 }
166 187
167 - (void)stopAecDump { 188 - (void)stopAecDump {
168 _nativeFactory->StopAecDump(); 189 _nativeFactory->StopAecDump();
169 _hasStartedAecDump = NO; 190 _hasStartedAecDump = NO;
170 } 191 }
171 192
172 @end 193 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698