OLD | NEW |
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 Loading... |
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 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 // goes away. | 1273 // goes away. |
1269 AudioSource* source_ = nullptr; | 1274 AudioSource* source_ = nullptr; |
1270 bool send_ = false; | 1275 bool send_ = false; |
1271 webrtc::RtpParameters rtp_parameters_; | 1276 webrtc::RtpParameters rtp_parameters_; |
1272 | 1277 |
1273 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream); | 1278 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream); |
1274 }; | 1279 }; |
1275 | 1280 |
1276 class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream { | 1281 class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream { |
1277 public: | 1282 public: |
1278 WebRtcAudioReceiveStream(int ch, | 1283 WebRtcAudioReceiveStream( |
1279 uint32_t remote_ssrc, | 1284 int ch, |
1280 uint32_t local_ssrc, | 1285 uint32_t remote_ssrc, |
1281 bool use_transport_cc, | 1286 uint32_t local_ssrc, |
1282 const std::string& sync_group, | 1287 bool use_transport_cc, |
1283 const std::vector<webrtc::RtpExtension>& extensions, | 1288 const std::string& sync_group, |
1284 webrtc::Call* call, | 1289 const std::vector<webrtc::RtpExtension>& extensions, |
1285 webrtc::Transport* rtcp_send_transport) | 1290 webrtc::Call* call, |
| 1291 webrtc::Transport* rtcp_send_transport, |
| 1292 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory) |
1286 : call_(call), config_() { | 1293 : call_(call), config_() { |
1287 RTC_DCHECK_GE(ch, 0); | 1294 RTC_DCHECK_GE(ch, 0); |
1288 RTC_DCHECK(call); | 1295 RTC_DCHECK(call); |
1289 config_.rtp.remote_ssrc = remote_ssrc; | 1296 config_.rtp.remote_ssrc = remote_ssrc; |
1290 config_.rtp.local_ssrc = local_ssrc; | 1297 config_.rtp.local_ssrc = local_ssrc; |
1291 config_.rtcp_send_transport = rtcp_send_transport; | 1298 config_.rtcp_send_transport = rtcp_send_transport; |
1292 config_.voe_channel_id = ch; | 1299 config_.voe_channel_id = ch; |
1293 config_.sync_group = sync_group; | 1300 config_.sync_group = sync_group; |
| 1301 config_.decoder_factory = decoder_factory; |
1294 RecreateAudioReceiveStream(use_transport_cc, extensions); | 1302 RecreateAudioReceiveStream(use_transport_cc, extensions); |
1295 } | 1303 } |
1296 | 1304 |
1297 ~WebRtcAudioReceiveStream() { | 1305 ~WebRtcAudioReceiveStream() { |
1298 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1306 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1299 call_->DestroyAudioReceiveStream(stream_); | 1307 call_->DestroyAudioReceiveStream(stream_); |
1300 } | 1308 } |
1301 | 1309 |
1302 void RecreateAudioReceiveStream( | 1310 void RecreateAudioReceiveStream( |
1303 const std::vector<webrtc::RtpExtension>& extensions) { | 1311 const std::vector<webrtc::RtpExtension>& extensions) { |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2161 // can obtain RTT from the send channel) | 2169 // can obtain RTT from the send channel) |
2162 engine()->voe()->base()->AssociateSendChannel(channel, send_channel); | 2170 engine()->voe()->base()->AssociateSendChannel(channel, send_channel); |
2163 LOG(LS_INFO) << "VoiceEngine channel #" << channel | 2171 LOG(LS_INFO) << "VoiceEngine channel #" << channel |
2164 << " is associated with channel #" << send_channel << "."; | 2172 << " is associated with channel #" << send_channel << "."; |
2165 } | 2173 } |
2166 | 2174 |
2167 recv_streams_.insert(std::make_pair( | 2175 recv_streams_.insert(std::make_pair( |
2168 ssrc, new WebRtcAudioReceiveStream(channel, ssrc, receiver_reports_ssrc_, | 2176 ssrc, new WebRtcAudioReceiveStream(channel, ssrc, receiver_reports_ssrc_, |
2169 recv_transport_cc_enabled_, | 2177 recv_transport_cc_enabled_, |
2170 sp.sync_label, recv_rtp_extensions_, | 2178 sp.sync_label, recv_rtp_extensions_, |
2171 call_, this))); | 2179 call_, this, |
| 2180 engine()->decoder_factory_))); |
2172 | 2181 |
2173 SetNack(channel, send_codec_spec_.nack_enabled); | 2182 SetNack(channel, send_codec_spec_.nack_enabled); |
2174 SetPlayout(channel, playout_); | 2183 SetPlayout(channel, playout_); |
2175 | 2184 |
2176 return true; | 2185 return true; |
2177 } | 2186 } |
2178 | 2187 |
2179 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { | 2188 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { |
2180 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream"); | 2189 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream"); |
2181 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2190 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2628 } | 2637 } |
2629 } else { | 2638 } else { |
2630 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 2639 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
2631 engine()->voe()->base()->StopPlayout(channel); | 2640 engine()->voe()->base()->StopPlayout(channel); |
2632 } | 2641 } |
2633 return true; | 2642 return true; |
2634 } | 2643 } |
2635 } // namespace cricket | 2644 } // namespace cricket |
2636 | 2645 |
2637 #endif // HAVE_WEBRTC_VOICE | 2646 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |