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

Side by Side Diff: webrtc/pc/peerconnectionfactory.cc

Issue 2653343003: Add CreatePeerConnectionFactory overloads that take audio codec factory args (Closed)
Patch Set: Don't save the audio encoder factory, since it's just a fake Created 3 years, 10 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/pc/peerconnectionfactory.h ('k') | webrtc/pc/peerconnectioninterface_unittest.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 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2004 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
(...skipping 18 matching lines...) Expand all
29 #include "webrtc/p2p/client/basicportallocator.h" 29 #include "webrtc/p2p/client/basicportallocator.h"
30 #include "webrtc/pc/audiotrack.h" 30 #include "webrtc/pc/audiotrack.h"
31 #include "webrtc/pc/localaudiosource.h" 31 #include "webrtc/pc/localaudiosource.h"
32 #include "webrtc/pc/mediastream.h" 32 #include "webrtc/pc/mediastream.h"
33 #include "webrtc/pc/peerconnection.h" 33 #include "webrtc/pc/peerconnection.h"
34 #include "webrtc/pc/videocapturertracksource.h" 34 #include "webrtc/pc/videocapturertracksource.h"
35 #include "webrtc/pc/videotrack.h" 35 #include "webrtc/pc/videotrack.h"
36 36
37 namespace webrtc { 37 namespace webrtc {
38 38
39 rtc::scoped_refptr<PeerConnectionFactoryInterface> 39 rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
40 CreatePeerConnectionFactory() { 40 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
41 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory) {
41 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( 42 rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
42 new rtc::RefCountedObject<PeerConnectionFactory>()); 43 new rtc::RefCountedObject<PeerConnectionFactory>(audio_encoder_factory,
44 audio_decoder_factory));
43 45
44 RTC_CHECK(rtc::Thread::Current() == pc_factory->signaling_thread()); 46 RTC_CHECK(rtc::Thread::Current() == pc_factory->signaling_thread());
45 // The signaling thread is the current thread so we can 47 // The signaling thread is the current thread so we can
46 // safely call Initialize directly. 48 // safely call Initialize directly.
47 if (!pc_factory->Initialize()) { 49 if (!pc_factory->Initialize()) {
48 return nullptr; 50 return nullptr;
49 } 51 }
50 return PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(), 52 return PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(),
51 pc_factory); 53 pc_factory);
52 } 54 }
53 55
56 rtc::scoped_refptr<PeerConnectionFactoryInterface>
57 CreatePeerConnectionFactory() {
58 return CreatePeerConnectionFactory(CreateBuiltinAudioEncoderFactory(),
59 CreateBuiltinAudioDecoderFactory());
60 }
61
54 rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( 62 rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
55 rtc::Thread* network_thread, 63 rtc::Thread* network_thread,
56 rtc::Thread* worker_thread, 64 rtc::Thread* worker_thread,
65 rtc::Thread* signaling_thread,
66 AudioDeviceModule* default_adm,
67 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
68 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
69 cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
70 cricket::WebRtcVideoDecoderFactory* video_decoder_factory) {
71 return CreatePeerConnectionFactoryWithAudioMixer(
72 network_thread, worker_thread, signaling_thread, default_adm,
73 audio_encoder_factory, audio_decoder_factory, video_encoder_factory,
74 video_decoder_factory, nullptr);
75 }
76
77 rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
78 rtc::Thread* network_thread,
79 rtc::Thread* worker_thread,
57 rtc::Thread* signaling_thread, 80 rtc::Thread* signaling_thread,
58 AudioDeviceModule* default_adm, 81 AudioDeviceModule* default_adm,
59 cricket::WebRtcVideoEncoderFactory* encoder_factory, 82 cricket::WebRtcVideoEncoderFactory* encoder_factory,
60 cricket::WebRtcVideoDecoderFactory* decoder_factory) { 83 cricket::WebRtcVideoDecoderFactory* decoder_factory) {
61 return CreatePeerConnectionFactoryWithAudioMixer( 84 return CreatePeerConnectionFactoryWithAudioMixer(
62 network_thread, worker_thread, signaling_thread, default_adm, 85 network_thread, worker_thread, signaling_thread, default_adm,
63 encoder_factory, decoder_factory, nullptr); 86 encoder_factory, decoder_factory, nullptr);
64 } 87 }
65 88
66 PeerConnectionFactory::PeerConnectionFactory()
67 : owns_ptrs_(true),
68 wraps_current_thread_(false),
69 network_thread_(rtc::Thread::CreateWithSocketServer().release()),
70 worker_thread_(rtc::Thread::Create().release()),
71 signaling_thread_(rtc::Thread::Current()),
72 audio_decoder_factory_(CreateBuiltinAudioDecoderFactory()) {
73 if (!signaling_thread_) {
74 signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread();
75 wraps_current_thread_ = true;
76 }
77 network_thread_->Start();
78 worker_thread_->Start();
79 }
80
81 rtc::scoped_refptr<PeerConnectionFactoryInterface> 89 rtc::scoped_refptr<PeerConnectionFactoryInterface>
82 CreatePeerConnectionFactoryWithAudioMixer( 90 CreatePeerConnectionFactoryWithAudioMixer(
83 rtc::Thread* network_thread, 91 rtc::Thread* network_thread,
84 rtc::Thread* worker_thread, 92 rtc::Thread* worker_thread,
85 rtc::Thread* signaling_thread, 93 rtc::Thread* signaling_thread,
86 AudioDeviceModule* default_adm, 94 AudioDeviceModule* default_adm,
87 cricket::WebRtcVideoEncoderFactory* encoder_factory, 95 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
88 cricket::WebRtcVideoDecoderFactory* decoder_factory, 96 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
97 cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
98 cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
89 rtc::scoped_refptr<AudioMixer> audio_mixer) { 99 rtc::scoped_refptr<AudioMixer> audio_mixer) {
90 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( 100 rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
91 new rtc::RefCountedObject<PeerConnectionFactory>( 101 new rtc::RefCountedObject<PeerConnectionFactory>(
92 network_thread, worker_thread, signaling_thread, default_adm, 102 network_thread, worker_thread, signaling_thread, default_adm,
93 CreateBuiltinAudioDecoderFactory(), encoder_factory, decoder_factory, 103 audio_encoder_factory, audio_decoder_factory, video_encoder_factory,
94 audio_mixer)); 104 video_decoder_factory, audio_mixer));
95 105
96 // Call Initialize synchronously but make sure it is executed on 106 // Call Initialize synchronously but make sure it is executed on
97 // |signaling_thread|. 107 // |signaling_thread|.
98 MethodCall0<PeerConnectionFactory, bool> call( 108 MethodCall0<PeerConnectionFactory, bool> call(
99 pc_factory.get(), &PeerConnectionFactory::Initialize); 109 pc_factory.get(), &PeerConnectionFactory::Initialize);
100 bool result = call.Marshal(RTC_FROM_HERE, signaling_thread); 110 bool result = call.Marshal(RTC_FROM_HERE, signaling_thread);
101 111
102 if (!result) { 112 if (!result) {
103 return nullptr; 113 return nullptr;
104 } 114 }
105 return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory); 115 return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory);
106 } 116 }
107 117
118 rtc::scoped_refptr<PeerConnectionFactoryInterface>
119 CreatePeerConnectionFactoryWithAudioMixer(
120 rtc::Thread* network_thread,
121 rtc::Thread* worker_thread,
122 rtc::Thread* signaling_thread,
123 AudioDeviceModule* default_adm,
124 cricket::WebRtcVideoEncoderFactory* encoder_factory,
125 cricket::WebRtcVideoDecoderFactory* decoder_factory,
126 rtc::scoped_refptr<AudioMixer> audio_mixer) {
127 return CreatePeerConnectionFactoryWithAudioMixer(
128 network_thread, worker_thread, signaling_thread, default_adm,
129 CreateBuiltinAudioEncoderFactory(), CreateBuiltinAudioDecoderFactory(),
130 encoder_factory, decoder_factory, audio_mixer);
131 }
132
133 PeerConnectionFactory::PeerConnectionFactory(
134 rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
135 rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory)
136 : owns_ptrs_(true),
137 wraps_current_thread_(false),
138 network_thread_(rtc::Thread::CreateWithSocketServer().release()),
139 worker_thread_(rtc::Thread::Create().release()),
140 signaling_thread_(rtc::Thread::Current()),
141 audio_decoder_factory_(audio_decoder_factory) {
142 if (!signaling_thread_) {
ossu 2017/01/30 13:58:02 Perhaps add a TODO or similar comment here, indica
kwiberg-webrtc 2017/01/30 20:55:25 Done.
143 signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread();
144 wraps_current_thread_ = true;
145 }
146 network_thread_->Start();
147 worker_thread_->Start();
148 }
149
108 PeerConnectionFactory::PeerConnectionFactory( 150 PeerConnectionFactory::PeerConnectionFactory(
109 rtc::Thread* network_thread, 151 rtc::Thread* network_thread,
110 rtc::Thread* worker_thread, 152 rtc::Thread* worker_thread,
111 rtc::Thread* signaling_thread, 153 rtc::Thread* signaling_thread,
112 AudioDeviceModule* default_adm, 154 AudioDeviceModule* default_adm,
113 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& 155 rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
114 audio_decoder_factory, 156 rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory,
115 cricket::WebRtcVideoEncoderFactory* video_encoder_factory, 157 cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
116 cricket::WebRtcVideoDecoderFactory* video_decoder_factory, 158 cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
117 rtc::scoped_refptr<AudioMixer> audio_mixer) 159 rtc::scoped_refptr<AudioMixer> audio_mixer)
118 : owns_ptrs_(false), 160 : owns_ptrs_(false),
119 wraps_current_thread_(false), 161 wraps_current_thread_(false),
120 network_thread_(network_thread), 162 network_thread_(network_thread),
121 worker_thread_(worker_thread), 163 worker_thread_(worker_thread),
122 signaling_thread_(signaling_thread), 164 signaling_thread_(signaling_thread),
123 default_adm_(default_adm), 165 default_adm_(default_adm),
124 audio_decoder_factory_(audio_decoder_factory), 166 audio_decoder_factory_(audio_decoder_factory),
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 } 388 }
347 389
348 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { 390 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() {
349 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); 391 RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
350 return cricket::WebRtcMediaEngineFactory::Create( 392 return cricket::WebRtcMediaEngineFactory::Create(
351 default_adm_.get(), audio_decoder_factory_, video_encoder_factory_.get(), 393 default_adm_.get(), audio_decoder_factory_, video_encoder_factory_.get(),
352 video_decoder_factory_.get(), external_audio_mixer_); 394 video_decoder_factory_.get(), external_audio_mixer_);
353 } 395 }
354 396
355 } // namespace webrtc 397 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/pc/peerconnectionfactory.h ('k') | webrtc/pc/peerconnectioninterface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698