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

Side by Side Diff: webrtc/media/engine/webrtcvoiceengine.cc

Issue 1991233004: Moved creation of AudioDecoderFactory to inside PeerConnectionFactory. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@audio-decoder-factory-injections-3
Patch Set: Created 4 years, 7 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 (c) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 {kRedCodecName, 8000, 1, 127, false, {}}, 513 {kRedCodecName, 8000, 1, 127, false, {}},
514 {kDtmfCodecName, 8000, 1, 126, false, {}}, 514 {kDtmfCodecName, 8000, 1, 126, false, {}},
515 }; 515 };
516 } // namespace { 516 } // namespace {
517 517
518 bool WebRtcVoiceEngine::ToCodecInst(const AudioCodec& in, 518 bool WebRtcVoiceEngine::ToCodecInst(const AudioCodec& in,
519 webrtc::CodecInst* out) { 519 webrtc::CodecInst* out) {
520 return WebRtcVoiceCodecs::ToCodecInst(in, out); 520 return WebRtcVoiceCodecs::ToCodecInst(in, out);
521 } 521 }
522 522
523 WebRtcVoiceEngine::WebRtcVoiceEngine(webrtc::AudioDeviceModule* adm) 523 WebRtcVoiceEngine::WebRtcVoiceEngine(
524 : WebRtcVoiceEngine(adm, new VoEWrapper()) { 524 webrtc::AudioDeviceModule* adm,
525 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory)
526 : WebRtcVoiceEngine(adm, decoder_factory, new VoEWrapper()) {
525 audio_state_ = webrtc::AudioState::Create(MakeAudioStateConfig(voe())); 527 audio_state_ = webrtc::AudioState::Create(MakeAudioStateConfig(voe()));
526 } 528 }
527 529
528 WebRtcVoiceEngine::WebRtcVoiceEngine(webrtc::AudioDeviceModule* adm, 530 WebRtcVoiceEngine::WebRtcVoiceEngine(
529 VoEWrapper* voe_wrapper) 531 webrtc::AudioDeviceModule* adm,
530 : adm_(adm), voe_wrapper_(voe_wrapper) { 532 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory,
533 VoEWrapper* voe_wrapper)
534 : adm_(adm), decoder_factory_(decoder_factory), voe_wrapper_(voe_wrapper) {
531 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 535 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
532 LOG(LS_INFO) << "WebRtcVoiceEngine::WebRtcVoiceEngine"; 536 LOG(LS_INFO) << "WebRtcVoiceEngine::WebRtcVoiceEngine";
533 RTC_DCHECK(voe_wrapper); 537 RTC_DCHECK(voe_wrapper);
534 538
535 signal_thread_checker_.DetachFromThread(); 539 signal_thread_checker_.DetachFromThread();
536 540
537 // Load our audio codec list. 541 // Load our audio codec list.
538 LOG(LS_INFO) << "Supported codecs in order of preference:"; 542 LOG(LS_INFO) << "Supported codecs in order of preference:";
539 codecs_ = WebRtcVoiceCodecs::SupportedCodecs(); 543 codecs_ = WebRtcVoiceCodecs::SupportedCodecs();
540 for (const AudioCodec& codec : codecs_) { 544 for (const AudioCodec& codec : codecs_) {
541 LOG(LS_INFO) << ToString(codec); 545 LOG(LS_INFO) << ToString(codec);
542 } 546 }
543 547
544 voe_config_.Set<webrtc::VoicePacing>(new webrtc::VoicePacing(true)); 548 voe_config_.Set<webrtc::VoicePacing>(new webrtc::VoicePacing(true));
545 549
546 // Temporarily turn logging level up for the Init() call. 550 // Temporarily turn logging level up for the Init() call.
547 webrtc::Trace::SetTraceCallback(this); 551 webrtc::Trace::SetTraceCallback(this);
548 webrtc::Trace::set_level_filter(kElevatedTraceFilter); 552 webrtc::Trace::set_level_filter(kElevatedTraceFilter);
549 LOG(LS_INFO) << webrtc::VoiceEngine::GetVersionString(); 553 LOG(LS_INFO) << webrtc::VoiceEngine::GetVersionString();
550 RTC_CHECK_EQ(0, voe_wrapper_->base()->Init(adm_.get())); 554 RTC_CHECK_EQ(0, voe_wrapper_->base()->Init(adm_.get(), nullptr,
555 decoder_factory_));
551 webrtc::Trace::set_level_filter(kDefaultTraceFilter); 556 webrtc::Trace::set_level_filter(kDefaultTraceFilter);
552 557
553 // No ADM supplied? Get the default one from VoE. 558 // No ADM supplied? Get the default one from VoE.
554 if (!adm_) { 559 if (!adm_) {
555 adm_ = voe_wrapper_->base()->audio_device_module(); 560 adm_ = voe_wrapper_->base()->audio_device_module();
556 } 561 }
557 RTC_DCHECK(adm_); 562 RTC_DCHECK(adm_);
558 563
559 // Save the default AGC configuration settings. This must happen before 564 // Save the default AGC configuration settings. This must happen before
560 // calling ApplyOptions or the default will be overwritten. 565 // calling ApplyOptions or the default will be overwritten.
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 // goes away. 1272 // goes away.
1268 AudioSource* source_ = nullptr; 1273 AudioSource* source_ = nullptr;
1269 bool send_ = false; 1274 bool send_ = false;
1270 webrtc::RtpParameters rtp_parameters_; 1275 webrtc::RtpParameters rtp_parameters_;
1271 1276
1272 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream); 1277 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream);
1273 }; 1278 };
1274 1279
1275 class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream { 1280 class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
1276 public: 1281 public:
1277 WebRtcAudioReceiveStream(int ch, 1282 WebRtcAudioReceiveStream(
1278 uint32_t remote_ssrc, 1283 int ch,
1279 uint32_t local_ssrc, 1284 uint32_t remote_ssrc,
1280 bool use_transport_cc, 1285 uint32_t local_ssrc,
1281 const std::string& sync_group, 1286 bool use_transport_cc,
1282 const std::vector<webrtc::RtpExtension>& extensions, 1287 const std::string& sync_group,
1283 webrtc::Call* call, 1288 const std::vector<webrtc::RtpExtension>& extensions,
1284 webrtc::Transport* rtcp_send_transport) 1289 webrtc::Call* call,
1290 webrtc::Transport* rtcp_send_transport,
1291 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory)
1285 : call_(call), config_() { 1292 : call_(call), config_() {
1286 RTC_DCHECK_GE(ch, 0); 1293 RTC_DCHECK_GE(ch, 0);
1287 RTC_DCHECK(call); 1294 RTC_DCHECK(call);
1288 config_.rtp.remote_ssrc = remote_ssrc; 1295 config_.rtp.remote_ssrc = remote_ssrc;
1289 config_.rtp.local_ssrc = local_ssrc; 1296 config_.rtp.local_ssrc = local_ssrc;
1290 config_.rtcp_send_transport = rtcp_send_transport; 1297 config_.rtcp_send_transport = rtcp_send_transport;
1291 config_.voe_channel_id = ch; 1298 config_.voe_channel_id = ch;
1292 config_.sync_group = sync_group; 1299 config_.sync_group = sync_group;
1300 config_.decoder_factory = decoder_factory;
1293 RecreateAudioReceiveStream(use_transport_cc, extensions); 1301 RecreateAudioReceiveStream(use_transport_cc, extensions);
1294 } 1302 }
1295 1303
1296 ~WebRtcAudioReceiveStream() { 1304 ~WebRtcAudioReceiveStream() {
1297 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1305 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1298 call_->DestroyAudioReceiveStream(stream_); 1306 call_->DestroyAudioReceiveStream(stream_);
1299 } 1307 }
1300 1308
1301 void RecreateAudioReceiveStream( 1309 void RecreateAudioReceiveStream(
1302 const std::vector<webrtc::RtpExtension>& extensions) { 1310 const std::vector<webrtc::RtpExtension>& extensions) {
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
2160 // can obtain RTT from the send channel) 2168 // can obtain RTT from the send channel)
2161 engine()->voe()->base()->AssociateSendChannel(channel, send_channel); 2169 engine()->voe()->base()->AssociateSendChannel(channel, send_channel);
2162 LOG(LS_INFO) << "VoiceEngine channel #" << channel 2170 LOG(LS_INFO) << "VoiceEngine channel #" << channel
2163 << " is associated with channel #" << send_channel << "."; 2171 << " is associated with channel #" << send_channel << ".";
2164 } 2172 }
2165 2173
2166 recv_streams_.insert(std::make_pair( 2174 recv_streams_.insert(std::make_pair(
2167 ssrc, new WebRtcAudioReceiveStream(channel, ssrc, receiver_reports_ssrc_, 2175 ssrc, new WebRtcAudioReceiveStream(channel, ssrc, receiver_reports_ssrc_,
2168 recv_transport_cc_enabled_, 2176 recv_transport_cc_enabled_,
2169 sp.sync_label, recv_rtp_extensions_, 2177 sp.sync_label, recv_rtp_extensions_,
2170 call_, this))); 2178 call_, this,
2179 engine_->decoder_factory_)));
2171 2180
2172 SetNack(channel, send_codec_spec_.nack_enabled); 2181 SetNack(channel, send_codec_spec_.nack_enabled);
2173 SetPlayout(channel, playout_); 2182 SetPlayout(channel, playout_);
2174 2183
2175 return true; 2184 return true;
2176 } 2185 }
2177 2186
2178 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { 2187 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) {
2179 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream"); 2188 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream");
2180 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2189 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
2627 } 2636 }
2628 } else { 2637 } else {
2629 LOG(LS_INFO) << "Stopping playout for channel #" << channel; 2638 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
2630 engine()->voe()->base()->StopPlayout(channel); 2639 engine()->voe()->base()->StopPlayout(channel);
2631 } 2640 }
2632 return true; 2641 return true;
2633 } 2642 }
2634 } // namespace cricket 2643 } // namespace cricket
2635 2644
2636 #endif // HAVE_WEBRTC_VOICE 2645 #endif // HAVE_WEBRTC_VOICE
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698