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 std::shared_ptr<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 std::shared_ptr<webrtc::AudioDecoderFactory> decoder_factory, |
| 533 VoEWrapper* voe_wrapper) |
| 534 : adm_(adm), |
| 535 decoder_factory_(std::move(decoder_factory)), |
| 536 voe_wrapper_(voe_wrapper) { |
531 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 537 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
532 LOG(LS_INFO) << "WebRtcVoiceEngine::WebRtcVoiceEngine"; | 538 LOG(LS_INFO) << "WebRtcVoiceEngine::WebRtcVoiceEngine"; |
533 RTC_DCHECK(voe_wrapper); | 539 RTC_DCHECK(voe_wrapper); |
534 | 540 |
535 signal_thread_checker_.DetachFromThread(); | 541 signal_thread_checker_.DetachFromThread(); |
536 | 542 |
537 // Load our audio codec list. | 543 // Load our audio codec list. |
538 LOG(LS_INFO) << "Supported codecs in order of preference:"; | 544 LOG(LS_INFO) << "Supported codecs in order of preference:"; |
539 codecs_ = WebRtcVoiceCodecs::SupportedCodecs(); | 545 codecs_ = WebRtcVoiceCodecs::SupportedCodecs(); |
540 for (const AudioCodec& codec : codecs_) { | 546 for (const AudioCodec& codec : codecs_) { |
541 LOG(LS_INFO) << ToString(codec); | 547 LOG(LS_INFO) << ToString(codec); |
542 } | 548 } |
543 | 549 |
544 voe_config_.Set<webrtc::VoicePacing>(new webrtc::VoicePacing(true)); | 550 voe_config_.Set<webrtc::VoicePacing>(new webrtc::VoicePacing(true)); |
545 | 551 |
546 // Temporarily turn logging level up for the Init() call. | 552 // Temporarily turn logging level up for the Init() call. |
547 webrtc::Trace::SetTraceCallback(this); | 553 webrtc::Trace::SetTraceCallback(this); |
548 webrtc::Trace::set_level_filter(kElevatedTraceFilter); | 554 webrtc::Trace::set_level_filter(kElevatedTraceFilter); |
549 LOG(LS_INFO) << webrtc::VoiceEngine::GetVersionString(); | 555 LOG(LS_INFO) << webrtc::VoiceEngine::GetVersionString(); |
550 RTC_CHECK_EQ(0, voe_wrapper_->base()->Init(adm_.get())); | 556 RTC_CHECK_EQ(0, voe_wrapper_->base()->Init(adm_.get(), nullptr, |
| 557 decoder_factory_)); |
551 webrtc::Trace::set_level_filter(kDefaultTraceFilter); | 558 webrtc::Trace::set_level_filter(kDefaultTraceFilter); |
552 | 559 |
553 // No ADM supplied? Get the default one from VoE. | 560 // No ADM supplied? Get the default one from VoE. |
554 if (!adm_) { | 561 if (!adm_) { |
555 adm_ = voe_wrapper_->base()->audio_device_module(); | 562 adm_ = voe_wrapper_->base()->audio_device_module(); |
556 } | 563 } |
557 RTC_DCHECK(adm_); | 564 RTC_DCHECK(adm_); |
558 | 565 |
559 // Save the default AGC configuration settings. This must happen before | 566 // Save the default AGC configuration settings. This must happen before |
560 // calling ApplyOptions or the default will be overwritten. | 567 // calling ApplyOptions or the default will be overwritten. |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 // goes away. | 1253 // goes away. |
1247 AudioSource* source_ = nullptr; | 1254 AudioSource* source_ = nullptr; |
1248 bool send_ = false; | 1255 bool send_ = false; |
1249 webrtc::RtpParameters rtp_parameters_; | 1256 webrtc::RtpParameters rtp_parameters_; |
1250 | 1257 |
1251 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream); | 1258 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream); |
1252 }; | 1259 }; |
1253 | 1260 |
1254 class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream { | 1261 class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream { |
1255 public: | 1262 public: |
1256 WebRtcAudioReceiveStream(int ch, | 1263 WebRtcAudioReceiveStream( |
1257 uint32_t remote_ssrc, | 1264 int ch, |
1258 uint32_t local_ssrc, | 1265 uint32_t remote_ssrc, |
1259 bool use_transport_cc, | 1266 uint32_t local_ssrc, |
1260 const std::string& sync_group, | 1267 bool use_transport_cc, |
1261 const std::vector<webrtc::RtpExtension>& extensions, | 1268 const std::string& sync_group, |
1262 webrtc::Call* call) | 1269 const std::vector<webrtc::RtpExtension>& extensions, |
| 1270 webrtc::Call* call, |
| 1271 std::shared_ptr<webrtc::AudioDecoderFactory> decoder_factory) |
1263 : call_(call), config_() { | 1272 : call_(call), config_() { |
1264 RTC_DCHECK_GE(ch, 0); | 1273 RTC_DCHECK_GE(ch, 0); |
1265 RTC_DCHECK(call); | 1274 RTC_DCHECK(call); |
1266 config_.rtp.remote_ssrc = remote_ssrc; | 1275 config_.rtp.remote_ssrc = remote_ssrc; |
1267 config_.rtp.local_ssrc = local_ssrc; | 1276 config_.rtp.local_ssrc = local_ssrc; |
1268 config_.voe_channel_id = ch; | 1277 config_.voe_channel_id = ch; |
1269 config_.sync_group = sync_group; | 1278 config_.sync_group = sync_group; |
| 1279 config_.decoder_factory = std::move(decoder_factory); |
1270 RecreateAudioReceiveStream(use_transport_cc, extensions); | 1280 RecreateAudioReceiveStream(use_transport_cc, extensions); |
1271 } | 1281 } |
1272 | 1282 |
1273 ~WebRtcAudioReceiveStream() { | 1283 ~WebRtcAudioReceiveStream() { |
1274 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1284 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1275 call_->DestroyAudioReceiveStream(stream_); | 1285 call_->DestroyAudioReceiveStream(stream_); |
1276 } | 1286 } |
1277 | 1287 |
1278 void RecreateAudioReceiveStream( | 1288 void RecreateAudioReceiveStream( |
1279 const std::vector<webrtc::RtpExtension>& extensions) { | 1289 const std::vector<webrtc::RtpExtension>& extensions) { |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2089 // can obtain RTT from the send channel) | 2099 // can obtain RTT from the send channel) |
2090 engine()->voe()->base()->AssociateSendChannel(channel, send_channel); | 2100 engine()->voe()->base()->AssociateSendChannel(channel, send_channel); |
2091 LOG(LS_INFO) << "VoiceEngine channel #" << channel | 2101 LOG(LS_INFO) << "VoiceEngine channel #" << channel |
2092 << " is associated with channel #" << send_channel << "."; | 2102 << " is associated with channel #" << send_channel << "."; |
2093 } | 2103 } |
2094 | 2104 |
2095 recv_streams_.insert(std::make_pair( | 2105 recv_streams_.insert(std::make_pair( |
2096 ssrc, new WebRtcAudioReceiveStream(channel, ssrc, receiver_reports_ssrc_, | 2106 ssrc, new WebRtcAudioReceiveStream(channel, ssrc, receiver_reports_ssrc_, |
2097 recv_transport_cc_enabled_, | 2107 recv_transport_cc_enabled_, |
2098 sp.sync_label, recv_rtp_extensions_, | 2108 sp.sync_label, recv_rtp_extensions_, |
2099 call_))); | 2109 call_, engine_->decoder_factory_))); |
2100 | 2110 |
2101 SetNack(channel, send_codec_spec_.nack_enabled); | 2111 SetNack(channel, send_codec_spec_.nack_enabled); |
2102 SetPlayout(channel, playout_); | 2112 SetPlayout(channel, playout_); |
2103 | 2113 |
2104 return true; | 2114 return true; |
2105 } | 2115 } |
2106 | 2116 |
2107 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { | 2117 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { |
2108 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream"); | 2118 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream"); |
2109 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2119 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2556 } | 2566 } |
2557 } else { | 2567 } else { |
2558 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 2568 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
2559 engine()->voe()->base()->StopPlayout(channel); | 2569 engine()->voe()->base()->StopPlayout(channel); |
2560 } | 2570 } |
2561 return true; | 2571 return true; |
2562 } | 2572 } |
2563 } // namespace cricket | 2573 } // namespace cricket |
2564 | 2574 |
2565 #endif // HAVE_WEBRTC_VOICE | 2575 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |