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/call/rtp_transport_controller.h" |
22 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 23 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
23 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | 24 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" |
24 #include "webrtc/modules/pacing/paced_sender.h" | 25 #include "webrtc/modules/pacing/paced_sender.h" |
25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
26 #include "webrtc/voice_engine/channel_proxy.h" | 27 #include "webrtc/voice_engine/channel_proxy.h" |
27 #include "webrtc/voice_engine/include/voe_base.h" | 28 #include "webrtc/voice_engine/include/voe_base.h" |
28 #include "webrtc/voice_engine/include/voe_volume_control.h" | 29 #include "webrtc/voice_engine/include/voe_volume_control.h" |
29 #include "webrtc/voice_engine/voice_engine_impl.h" | 30 #include "webrtc/voice_engine/voice_engine_impl.h" |
30 | 31 |
31 namespace webrtc { | 32 namespace webrtc { |
32 | 33 |
33 namespace { | 34 namespace { |
34 | 35 |
35 constexpr char kOpusCodecName[] = "opus"; | 36 constexpr char kOpusCodecName[] = "opus"; |
36 | 37 |
37 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) { | 38 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) { |
38 return (_stricmp(codec.plname, ref_name) == 0); | 39 return (_stricmp(codec.plname, ref_name) == 0); |
39 } | 40 } |
40 } // namespace | 41 } // namespace |
41 | 42 |
42 namespace internal { | 43 namespace internal { |
43 AudioSendStream::AudioSendStream( | 44 AudioSendStream::AudioSendStream( |
44 const webrtc::AudioSendStream::Config& config, | 45 const webrtc::AudioSendStream::Config& config, |
45 const rtc::scoped_refptr<webrtc::AudioState>& audio_state, | 46 const rtc::scoped_refptr<webrtc::AudioState>& audio_state, |
46 rtc::TaskQueue* worker_queue, | 47 rtc::TaskQueue* worker_queue, |
47 PacketRouter* packet_router, | 48 RtpTransportControllerSendInterface* transport, |
48 CongestionController* congestion_controller, | |
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 transport_(transport) { |
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(transport); |
| 61 RTC_DCHECK(transport->congestion_controller()); |
61 | 62 |
62 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); | 63 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); |
63 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id); | 64 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id); |
64 channel_proxy_->SetRtcEventLog(event_log); | 65 channel_proxy_->SetRtcEventLog(event_log); |
65 channel_proxy_->SetRtcpRttStats(rtcp_rtt_stats); | 66 channel_proxy_->SetRtcpRttStats(rtcp_rtt_stats); |
66 channel_proxy_->SetRTCPStatus(true); | 67 channel_proxy_->SetRTCPStatus(true); |
67 channel_proxy_->SetLocalSSRC(config.rtp.ssrc); | 68 channel_proxy_->SetLocalSSRC(config.rtp.ssrc); |
68 channel_proxy_->SetRTCP_CNAME(config.rtp.c_name); | 69 channel_proxy_->SetRTCP_CNAME(config.rtp.c_name); |
69 // TODO(solenberg): Config NACK history window (which is a packet count), | 70 // TODO(solenberg): Config NACK history window (which is a packet count), |
70 // using the actual packet size for the configured codec. | 71 // using the actual packet size for the configured codec. |
71 channel_proxy_->SetNACKStatus(config_.rtp.nack.rtp_history_ms != 0, | 72 channel_proxy_->SetNACKStatus(config_.rtp.nack.rtp_history_ms != 0, |
72 config_.rtp.nack.rtp_history_ms / 20); | 73 config_.rtp.nack.rtp_history_ms / 20); |
73 | 74 |
74 channel_proxy_->RegisterExternalTransport(config.send_transport); | 75 channel_proxy_->RegisterExternalTransport(config.send_transport); |
75 | 76 |
76 for (const auto& extension : config.rtp.extensions) { | 77 for (const auto& extension : config.rtp.extensions) { |
77 if (extension.uri == RtpExtension::kAudioLevelUri) { | 78 if (extension.uri == RtpExtension::kAudioLevelUri) { |
78 channel_proxy_->SetSendAudioLevelIndicationStatus(true, extension.id); | 79 channel_proxy_->SetSendAudioLevelIndicationStatus(true, extension.id); |
79 } else if (extension.uri == RtpExtension::kTransportSequenceNumberUri) { | 80 } else if (extension.uri == RtpExtension::kTransportSequenceNumberUri) { |
80 channel_proxy_->EnableSendTransportSequenceNumber(extension.id); | 81 channel_proxy_->EnableSendTransportSequenceNumber(extension.id); |
81 congestion_controller->EnablePeriodicAlrProbing(true); | 82 transport->congestion_controller()->EnablePeriodicAlrProbing(true); |
82 bandwidth_observer_.reset(congestion_controller->GetBitrateController() | 83 bandwidth_observer_.reset(transport->congestion_controller() |
| 84 ->GetBitrateController() |
83 ->CreateRtcpBandwidthObserver()); | 85 ->CreateRtcpBandwidthObserver()); |
84 } else { | 86 } else { |
85 RTC_NOTREACHED() << "Registering unsupported RTP extension."; | 87 RTC_NOTREACHED() << "Registering unsupported RTP extension."; |
86 } | 88 } |
87 } | 89 } |
88 channel_proxy_->RegisterSenderCongestionControlObjects( | 90 channel_proxy_->RegisterSenderCongestionControlObjects( |
89 congestion_controller->pacer(), | 91 transport, bandwidth_observer_.get()); |
90 congestion_controller->GetTransportFeedbackObserver(), packet_router, | |
91 bandwidth_observer_.get()); | |
92 if (!SetupSendCodec()) { | 92 if (!SetupSendCodec()) { |
93 LOG(LS_ERROR) << "Failed to set up send codec state."; | 93 LOG(LS_ERROR) << "Failed to set up send codec state."; |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 AudioSendStream::~AudioSendStream() { | 97 AudioSendStream::~AudioSendStream() { |
98 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 98 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
99 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); | 99 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); |
100 channel_proxy_->DeRegisterExternalTransport(); | 100 channel_proxy_->DeRegisterExternalTransport(); |
101 channel_proxy_->ResetCongestionControlObjects(); | 101 channel_proxy_->ResetCongestionControlObjects(); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 return 0; | 253 return 0; |
254 } | 254 } |
255 | 255 |
256 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { | 256 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { |
257 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 257 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
258 return config_; | 258 return config_; |
259 } | 259 } |
260 | 260 |
261 void AudioSendStream::SetTransportOverhead(int transport_overhead_per_packet) { | 261 void AudioSendStream::SetTransportOverhead(int transport_overhead_per_packet) { |
262 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 262 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
263 congestion_controller_->SetTransportOverhead(transport_overhead_per_packet); | 263 transport_->congestion_controller()->SetTransportOverhead( |
| 264 transport_overhead_per_packet); |
264 channel_proxy_->SetTransportOverhead(transport_overhead_per_packet); | 265 channel_proxy_->SetTransportOverhead(transport_overhead_per_packet); |
265 } | 266 } |
266 | 267 |
267 VoiceEngine* AudioSendStream::voice_engine() const { | 268 VoiceEngine* AudioSendStream::voice_engine() const { |
268 internal::AudioState* audio_state = | 269 internal::AudioState* audio_state = |
269 static_cast<internal::AudioState*>(audio_state_.get()); | 270 static_cast<internal::AudioState*>(audio_state_.get()); |
270 VoiceEngine* voice_engine = audio_state->voice_engine(); | 271 VoiceEngine* voice_engine = audio_state->voice_engine(); |
271 RTC_DCHECK(voice_engine); | 272 RTC_DCHECK(voice_engine); |
272 return voice_engine; | 273 return voice_engine; |
273 } | 274 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 LOG(LS_WARNING) << "SetVADStatus() failed."; | 380 LOG(LS_WARNING) << "SetVADStatus() failed."; |
380 return false; | 381 return false; |
381 } | 382 } |
382 } | 383 } |
383 } | 384 } |
384 return true; | 385 return true; |
385 } | 386 } |
386 | 387 |
387 } // namespace internal | 388 } // namespace internal |
388 } // namespace webrtc | 389 } // namespace webrtc |
OLD | NEW |