| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 |
| 11 #include "webrtc/audio/audio_send_stream.h" | 11 #include "webrtc/audio/audio_send_stream.h" |
| 12 | 12 |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "webrtc/audio/audio_state.h" | 15 #include "webrtc/audio/audio_state.h" |
| 16 #include "webrtc/audio/conversion.h" | 16 #include "webrtc/audio/conversion.h" |
| 17 #include "webrtc/audio/scoped_voe_interface.h" | 17 #include "webrtc/audio/scoped_voe_interface.h" |
| 18 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
| 19 #include "webrtc/base/event.h" | 19 #include "webrtc/base/event.h" |
| 20 #include "webrtc/base/logging.h" | 20 #include "webrtc/base/logging.h" |
| 21 #include "webrtc/base/task_queue.h" | 21 #include "webrtc/base/task_queue.h" |
| 22 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 22 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
| 23 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | 23 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont
roller.h" |
| 24 #include "webrtc/modules/pacing/paced_sender.h" | 24 #include "webrtc/modules/pacing/paced_sender.h" |
| 25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 26 #include "webrtc/voice_engine/channel_proxy.h" | 26 #include "webrtc/voice_engine/channel_proxy.h" |
| 27 #include "webrtc/voice_engine/include/voe_base.h" | 27 #include "webrtc/voice_engine/include/voe_base.h" |
| 28 #include "webrtc/voice_engine/transmit_mixer.h" | 28 #include "webrtc/voice_engine/transmit_mixer.h" |
| 29 #include "webrtc/voice_engine/voice_engine_impl.h" | 29 #include "webrtc/voice_engine/voice_engine_impl.h" |
| 30 | 30 |
| 31 namespace webrtc { | 31 namespace webrtc { |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 constexpr char kOpusCodecName[] = "opus"; | 35 constexpr char kOpusCodecName[] = "opus"; |
| 36 | 36 |
| 37 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) { | 37 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) { |
| 38 return (STR_CASE_CMP(codec.plname, ref_name) == 0); | 38 return (STR_CASE_CMP(codec.plname, ref_name) == 0); |
| 39 } | 39 } |
| 40 } // namespace | 40 } // namespace |
| 41 | 41 |
| 42 namespace internal { | 42 namespace internal { |
| 43 AudioSendStream::AudioSendStream( | 43 AudioSendStream::AudioSendStream( |
| 44 const webrtc::AudioSendStream::Config& config, | 44 const webrtc::AudioSendStream::Config& config, |
| 45 const rtc::scoped_refptr<webrtc::AudioState>& audio_state, | 45 const rtc::scoped_refptr<webrtc::AudioState>& audio_state, |
| 46 rtc::TaskQueue* worker_queue, | 46 rtc::TaskQueue* worker_queue, |
| 47 PacketRouter* packet_router, | 47 PacketRouter* packet_router, |
| 48 CongestionController* congestion_controller, | 48 SendSideCongestionController* send_side_cc, |
| 49 BitrateAllocator* bitrate_allocator, | 49 BitrateAllocator* bitrate_allocator, |
| 50 RtcEventLog* event_log, | 50 RtcEventLog* event_log, |
| 51 RtcpRttStats* rtcp_rtt_stats) | 51 RtcpRttStats* rtcp_rtt_stats) |
| 52 : worker_queue_(worker_queue), | 52 : worker_queue_(worker_queue), |
| 53 config_(config), | 53 config_(config), |
| 54 audio_state_(audio_state), | 54 audio_state_(audio_state), |
| 55 bitrate_allocator_(bitrate_allocator), | 55 bitrate_allocator_(bitrate_allocator), |
| 56 congestion_controller_(congestion_controller) { | 56 send_side_cc_(send_side_cc) { |
| 57 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString(); | 57 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString(); |
| 58 RTC_DCHECK_NE(config_.voe_channel_id, -1); | 58 RTC_DCHECK_NE(config_.voe_channel_id, -1); |
| 59 RTC_DCHECK(audio_state_.get()); | 59 RTC_DCHECK(audio_state_.get()); |
| 60 RTC_DCHECK(congestion_controller); | 60 RTC_DCHECK(send_side_cc); |
| 61 | 61 |
| 62 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); | 62 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); |
| 63 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id); | 63 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id); |
| 64 channel_proxy_->SetRtcEventLog(event_log); | 64 channel_proxy_->SetRtcEventLog(event_log); |
| 65 channel_proxy_->SetRtcpRttStats(rtcp_rtt_stats); | 65 channel_proxy_->SetRtcpRttStats(rtcp_rtt_stats); |
| 66 channel_proxy_->SetRTCPStatus(true); | 66 channel_proxy_->SetRTCPStatus(true); |
| 67 channel_proxy_->SetLocalSSRC(config.rtp.ssrc); | 67 channel_proxy_->SetLocalSSRC(config.rtp.ssrc); |
| 68 channel_proxy_->SetRTCP_CNAME(config.rtp.c_name); | 68 channel_proxy_->SetRTCP_CNAME(config.rtp.c_name); |
| 69 // TODO(solenberg): Config NACK history window (which is a packet count), | 69 // TODO(solenberg): Config NACK history window (which is a packet count), |
| 70 // using the actual packet size for the configured codec. | 70 // using the actual packet size for the configured codec. |
| 71 channel_proxy_->SetNACKStatus(config_.rtp.nack.rtp_history_ms != 0, | 71 channel_proxy_->SetNACKStatus(config_.rtp.nack.rtp_history_ms != 0, |
| 72 config_.rtp.nack.rtp_history_ms / 20); | 72 config_.rtp.nack.rtp_history_ms / 20); |
| 73 | 73 |
| 74 channel_proxy_->RegisterExternalTransport(config.send_transport); | 74 channel_proxy_->RegisterExternalTransport(config.send_transport); |
| 75 | 75 |
| 76 for (const auto& extension : config.rtp.extensions) { | 76 for (const auto& extension : config.rtp.extensions) { |
| 77 if (extension.uri == RtpExtension::kAudioLevelUri) { | 77 if (extension.uri == RtpExtension::kAudioLevelUri) { |
| 78 channel_proxy_->SetSendAudioLevelIndicationStatus(true, extension.id); | 78 channel_proxy_->SetSendAudioLevelIndicationStatus(true, extension.id); |
| 79 } else if (extension.uri == RtpExtension::kTransportSequenceNumberUri) { | 79 } else if (extension.uri == RtpExtension::kTransportSequenceNumberUri) { |
| 80 channel_proxy_->EnableSendTransportSequenceNumber(extension.id); | 80 channel_proxy_->EnableSendTransportSequenceNumber(extension.id); |
| 81 congestion_controller->EnablePeriodicAlrProbing(true); | 81 send_side_cc->EnablePeriodicAlrProbing(true); |
| 82 bandwidth_observer_.reset(congestion_controller->GetBitrateController() | 82 bandwidth_observer_.reset( |
| 83 ->CreateRtcpBandwidthObserver()); | 83 send_side_cc->GetBitrateController()->CreateRtcpBandwidthObserver()); |
| 84 } else { | 84 } else { |
| 85 RTC_NOTREACHED() << "Registering unsupported RTP extension."; | 85 RTC_NOTREACHED() << "Registering unsupported RTP extension."; |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 channel_proxy_->RegisterSenderCongestionControlObjects( | 88 channel_proxy_->RegisterSenderCongestionControlObjects( |
| 89 congestion_controller->pacer(), congestion_controller, packet_router, | 89 send_side_cc->pacer(), send_side_cc, packet_router, |
| 90 bandwidth_observer_.get()); | 90 bandwidth_observer_.get()); |
| 91 if (!SetupSendCodec()) { | 91 if (!SetupSendCodec()) { |
| 92 LOG(LS_ERROR) << "Failed to set up send codec state."; | 92 LOG(LS_ERROR) << "Failed to set up send codec state."; |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 AudioSendStream::~AudioSendStream() { | 96 AudioSendStream::~AudioSendStream() { |
| 97 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 97 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 98 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); | 98 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); |
| 99 channel_proxy_->DeRegisterExternalTransport(); | 99 channel_proxy_->DeRegisterExternalTransport(); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 return 0; | 247 return 0; |
| 248 } | 248 } |
| 249 | 249 |
| 250 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { | 250 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { |
| 251 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 251 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 252 return config_; | 252 return config_; |
| 253 } | 253 } |
| 254 | 254 |
| 255 void AudioSendStream::SetTransportOverhead(int transport_overhead_per_packet) { | 255 void AudioSendStream::SetTransportOverhead(int transport_overhead_per_packet) { |
| 256 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 256 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 257 congestion_controller_->SetTransportOverhead(transport_overhead_per_packet); | 257 send_side_cc_->SetTransportOverhead(transport_overhead_per_packet); |
| 258 channel_proxy_->SetTransportOverhead(transport_overhead_per_packet); | 258 channel_proxy_->SetTransportOverhead(transport_overhead_per_packet); |
| 259 } | 259 } |
| 260 | 260 |
| 261 VoiceEngine* AudioSendStream::voice_engine() const { | 261 VoiceEngine* AudioSendStream::voice_engine() const { |
| 262 internal::AudioState* audio_state = | 262 internal::AudioState* audio_state = |
| 263 static_cast<internal::AudioState*>(audio_state_.get()); | 263 static_cast<internal::AudioState*>(audio_state_.get()); |
| 264 VoiceEngine* voice_engine = audio_state->voice_engine(); | 264 VoiceEngine* voice_engine = audio_state->voice_engine(); |
| 265 RTC_DCHECK(voice_engine); | 265 RTC_DCHECK(voice_engine); |
| 266 return voice_engine; | 266 return voice_engine; |
| 267 } | 267 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 LOG(LS_WARNING) << "SetVADStatus() failed."; | 373 LOG(LS_WARNING) << "SetVADStatus() failed."; |
| 374 return false; | 374 return false; |
| 375 } | 375 } |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 return true; | 378 return true; |
| 379 } | 379 } |
| 380 | 380 |
| 381 } // namespace internal | 381 } // namespace internal |
| 382 } // namespace webrtc | 382 } // namespace webrtc |
| OLD | NEW |