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

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

Issue 2539213003: Support external audio mixer. (Closed)
Patch Set: Created 4 years 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 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( 53 rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
54 rtc::Thread* network_thread, 54 rtc::Thread* network_thread,
55 rtc::Thread* worker_thread, 55 rtc::Thread* worker_thread,
56 rtc::Thread* signaling_thread, 56 rtc::Thread* signaling_thread,
57 AudioDeviceModule* default_adm, 57 AudioDeviceModule* default_adm,
58 cricket::WebRtcVideoEncoderFactory* encoder_factory, 58 cricket::WebRtcVideoEncoderFactory* encoder_factory,
59 cricket::WebRtcVideoDecoderFactory* decoder_factory) { 59 cricket::WebRtcVideoDecoderFactory* decoder_factory) {
60 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( 60 rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
61 new rtc::RefCountedObject<PeerConnectionFactory>( 61 new rtc::RefCountedObject<PeerConnectionFactory>(
62 network_thread, 62 network_thread, worker_thread, signaling_thread, default_adm,
63 worker_thread, 63 CreateBuiltinAudioDecoderFactory(), encoder_factory, decoder_factory,
64 signaling_thread, 64 nullptr));
65 default_adm,
66 CreateBuiltinAudioDecoderFactory(),
67 encoder_factory,
68 decoder_factory));
69 65
70 // Call Initialize synchronously but make sure its executed on 66 // Call Initialize synchronously but make sure its executed on
71 // |signaling_thread|. 67 // |signaling_thread|.
72 MethodCall0<PeerConnectionFactory, bool> call( 68 MethodCall0<PeerConnectionFactory, bool> call(
73 pc_factory.get(), 69 pc_factory.get(),
74 &PeerConnectionFactory::Initialize); 70 &PeerConnectionFactory::Initialize);
75 bool result = call.Marshal(RTC_FROM_HERE, signaling_thread); 71 bool result = call.Marshal(RTC_FROM_HERE, signaling_thread);
76 72
77 if (!result) { 73 if (!result) {
78 return nullptr; 74 return nullptr;
79 } 75 }
80 return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory); 76 return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory);
81 } 77 }
82 78
83 PeerConnectionFactory::PeerConnectionFactory() 79 PeerConnectionFactory::PeerConnectionFactory()
84 : owns_ptrs_(true), 80 : owns_ptrs_(true),
85 wraps_current_thread_(false), 81 wraps_current_thread_(false),
86 network_thread_(rtc::Thread::CreateWithSocketServer().release()), 82 network_thread_(rtc::Thread::CreateWithSocketServer().release()),
87 worker_thread_(rtc::Thread::Create().release()), 83 worker_thread_(rtc::Thread::Create().release()),
88 signaling_thread_(rtc::Thread::Current()), 84 signaling_thread_(rtc::Thread::Current()),
89 audio_decoder_factory_(CreateBuiltinAudioDecoderFactory()) { 85 audio_decoder_factory_(CreateBuiltinAudioDecoderFactory()) {
90 if (!signaling_thread_) { 86 if (!signaling_thread_) {
91 signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread(); 87 signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread();
92 wraps_current_thread_ = true; 88 wraps_current_thread_ = true;
93 } 89 }
94 network_thread_->Start(); 90 network_thread_->Start();
95 worker_thread_->Start(); 91 worker_thread_->Start();
96 } 92 }
97 93
94 rtc::scoped_refptr<PeerConnectionFactoryInterface>
95 CreatePeerConnectionFactoryWithAudioMixer(
96 rtc::Thread* network_thread,
97 rtc::Thread* worker_thread,
98 rtc::Thread* signaling_thread,
99 AudioDeviceModule* default_adm,
100 cricket::WebRtcVideoEncoderFactory* encoder_factory,
101 cricket::WebRtcVideoDecoderFactory* decoder_factory,
102 rtc::scoped_refptr<AudioMixer> audio_mixer) {
103 rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
104 new rtc::RefCountedObject<PeerConnectionFactory>(
105 network_thread, worker_thread, signaling_thread, default_adm,
106 CreateBuiltinAudioDecoderFactory(), encoder_factory, decoder_factory,
107 audio_mixer));
108
109 // Call Initialize synchronously but make sure its executed on
aleloi 2016/12/05 14:03:08 its -> it's
GeorgeZ 2016/12/05 17:56:18 Done.
110 // |signaling_thread|.
111 MethodCall0<PeerConnectionFactory, bool> call(
112 pc_factory.get(), &PeerConnectionFactory::Initialize);
113 bool result = call.Marshal(RTC_FROM_HERE, signaling_thread);
114
115 if (!result) {
116 return nullptr;
117 }
118 return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory);
119 }
120
98 PeerConnectionFactory::PeerConnectionFactory( 121 PeerConnectionFactory::PeerConnectionFactory(
99 rtc::Thread* network_thread, 122 rtc::Thread* network_thread,
100 rtc::Thread* worker_thread, 123 rtc::Thread* worker_thread,
101 rtc::Thread* signaling_thread, 124 rtc::Thread* signaling_thread,
102 AudioDeviceModule* default_adm, 125 AudioDeviceModule* default_adm,
103 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& 126 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>&
104 audio_decoder_factory, 127 audio_decoder_factory,
105 cricket::WebRtcVideoEncoderFactory* video_encoder_factory, 128 cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
106 cricket::WebRtcVideoDecoderFactory* video_decoder_factory) 129 cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
130 rtc::scoped_refptr<AudioMixer> audio_mixer)
107 : owns_ptrs_(false), 131 : owns_ptrs_(false),
108 wraps_current_thread_(false), 132 wraps_current_thread_(false),
109 network_thread_(network_thread), 133 network_thread_(network_thread),
110 worker_thread_(worker_thread), 134 worker_thread_(worker_thread),
111 signaling_thread_(signaling_thread), 135 signaling_thread_(signaling_thread),
112 default_adm_(default_adm), 136 default_adm_(default_adm),
113 audio_decoder_factory_(audio_decoder_factory), 137 audio_decoder_factory_(audio_decoder_factory),
114 video_encoder_factory_(video_encoder_factory), 138 video_encoder_factory_(video_encoder_factory),
115 video_decoder_factory_(video_decoder_factory) { 139 video_decoder_factory_(video_decoder_factory),
140 external_audio_mixer_(audio_mixer) {
116 RTC_DCHECK(network_thread); 141 RTC_DCHECK(network_thread);
117 RTC_DCHECK(worker_thread); 142 RTC_DCHECK(worker_thread);
118 RTC_DCHECK(signaling_thread); 143 RTC_DCHECK(signaling_thread);
119 // TODO: Currently there is no way creating an external adm in 144 // TODO: Currently there is no way creating an external adm in
120 // libjingle source tree. So we can 't currently assert if this is NULL. 145 // libjingle source tree. So we can 't currently assert if this is NULL.
121 // ASSERT(default_adm != NULL); 146 // ASSERT(default_adm != NULL);
122 } 147 }
123 148
124 PeerConnectionFactory::~PeerConnectionFactory() { 149 PeerConnectionFactory::~PeerConnectionFactory() {
125 RTC_DCHECK(signaling_thread_->IsCurrent()); 150 RTC_DCHECK(signaling_thread_->IsCurrent());
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 return worker_thread_; 354 return worker_thread_;
330 } 355 }
331 356
332 rtc::Thread* PeerConnectionFactory::network_thread() { 357 rtc::Thread* PeerConnectionFactory::network_thread() {
333 return network_thread_; 358 return network_thread_;
334 } 359 }
335 360
336 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { 361 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() {
337 ASSERT(worker_thread_ == rtc::Thread::Current()); 362 ASSERT(worker_thread_ == rtc::Thread::Current());
338 return cricket::WebRtcMediaEngineFactory::Create( 363 return cricket::WebRtcMediaEngineFactory::Create(
339 default_adm_.get(), 364 default_adm_.get(), audio_decoder_factory_, video_encoder_factory_.get(),
340 audio_decoder_factory_, 365 video_decoder_factory_.get(), external_audio_mixer_);
341 video_encoder_factory_.get(),
342 video_decoder_factory_.get());
343 } 366 }
344 367
345 } // namespace webrtc 368 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698