Chromium Code Reviews| 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 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 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 // TODO(elad.alon): Subsequent CL will make these values experiment-dependent. | |
| 44 constexpr size_t kPacketLossTrackerMaxWindowSizeMs = 15000; | |
| 45 constexpr size_t kPlrMinNumAckedPackets = 50; | |
|
the sun
2017/03/22 12:06:42
In this context, the abbreviations PLR and RPLR wi
elad.alon_webrtc.org
2017/03/22 14:34:47
Done.
| |
| 46 constexpr size_t kRplrMinNumAckedPairs = 40; | |
| 47 | |
| 43 AudioSendStream::AudioSendStream( | 48 AudioSendStream::AudioSendStream( |
| 44 const webrtc::AudioSendStream::Config& config, | 49 const webrtc::AudioSendStream::Config& config, |
| 45 const rtc::scoped_refptr<webrtc::AudioState>& audio_state, | 50 const rtc::scoped_refptr<webrtc::AudioState>& audio_state, |
| 46 rtc::TaskQueue* worker_queue, | 51 rtc::TaskQueue* worker_queue, |
| 47 PacketRouter* packet_router, | 52 PacketRouter* packet_router, |
| 48 SendSideCongestionController* send_side_cc, | 53 SendSideCongestionController* send_side_cc, |
| 49 BitrateAllocator* bitrate_allocator, | 54 BitrateAllocator* bitrate_allocator, |
| 50 RtcEventLog* event_log, | 55 RtcEventLog* event_log, |
| 51 RtcpRttStats* rtcp_rtt_stats) | 56 RtcpRttStats* rtcp_rtt_stats) |
| 52 : worker_queue_(worker_queue), | 57 : clock_(Clock::GetRealTimeClock()), |
|
the sun
2017/03/22 12:06:42
Remove.
elad.alon_webrtc.org
2017/03/22 14:34:46
Done.
| |
| 58 worker_queue_(worker_queue), | |
| 53 config_(config), | 59 config_(config), |
| 54 audio_state_(audio_state), | 60 audio_state_(audio_state), |
| 55 bitrate_allocator_(bitrate_allocator), | 61 bitrate_allocator_(bitrate_allocator), |
| 56 send_side_cc_(send_side_cc) { | 62 send_side_cc_(send_side_cc), |
| 63 packet_loss_tracker_(kPacketLossTrackerMaxWindowSizeMs, | |
| 64 kPlrMinNumAckedPackets, | |
| 65 kRplrMinNumAckedPairs) { | |
| 57 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString(); | 66 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString(); |
| 58 RTC_DCHECK_NE(config_.voe_channel_id, -1); | 67 RTC_DCHECK_NE(config_.voe_channel_id, -1); |
| 59 RTC_DCHECK(audio_state_.get()); | 68 RTC_DCHECK(audio_state_.get()); |
| 60 RTC_DCHECK(send_side_cc); | 69 RTC_DCHECK(send_side_cc); |
| 61 | 70 |
| 62 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); | 71 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); |
| 63 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id); | 72 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id); |
| 64 channel_proxy_->SetRtcEventLog(event_log); | 73 channel_proxy_->SetRtcEventLog(event_log); |
| 65 channel_proxy_->SetRtcpRttStats(rtcp_rtt_stats); | 74 channel_proxy_->SetRtcpRttStats(rtcp_rtt_stats); |
| 66 channel_proxy_->SetRTCPStatus(true); | 75 channel_proxy_->SetRTCPStatus(true); |
| 67 channel_proxy_->SetLocalSSRC(config.rtp.ssrc); | 76 channel_proxy_->SetLocalSSRC(config.rtp.ssrc); |
| 68 channel_proxy_->SetRTCP_CNAME(config.rtp.c_name); | 77 channel_proxy_->SetRTCP_CNAME(config.rtp.c_name); |
| 69 // TODO(solenberg): Config NACK history window (which is a packet count), | 78 // TODO(solenberg): Config NACK history window (which is a packet count), |
| 70 // using the actual packet size for the configured codec. | 79 // using the actual packet size for the configured codec. |
| 71 channel_proxy_->SetNACKStatus(config_.rtp.nack.rtp_history_ms != 0, | 80 channel_proxy_->SetNACKStatus(config_.rtp.nack.rtp_history_ms != 0, |
| 72 config_.rtp.nack.rtp_history_ms / 20); | 81 config_.rtp.nack.rtp_history_ms / 20); |
| 73 | 82 |
| 74 channel_proxy_->RegisterExternalTransport(config.send_transport); | 83 channel_proxy_->RegisterExternalTransport(config.send_transport); |
| 84 send_side_cc_->RegisterTransportFeedbackAdapterObserver(this); | |
| 75 | 85 |
| 76 for (const auto& extension : config.rtp.extensions) { | 86 for (const auto& extension : config.rtp.extensions) { |
| 77 if (extension.uri == RtpExtension::kAudioLevelUri) { | 87 if (extension.uri == RtpExtension::kAudioLevelUri) { |
| 78 channel_proxy_->SetSendAudioLevelIndicationStatus(true, extension.id); | 88 channel_proxy_->SetSendAudioLevelIndicationStatus(true, extension.id); |
| 79 } else if (extension.uri == RtpExtension::kTransportSequenceNumberUri) { | 89 } else if (extension.uri == RtpExtension::kTransportSequenceNumberUri) { |
| 80 channel_proxy_->EnableSendTransportSequenceNumber(extension.id); | 90 channel_proxy_->EnableSendTransportSequenceNumber(extension.id); |
| 81 send_side_cc->EnablePeriodicAlrProbing(true); | 91 send_side_cc->EnablePeriodicAlrProbing(true); |
| 82 bandwidth_observer_.reset( | 92 bandwidth_observer_.reset( |
| 83 send_side_cc->GetBitrateController()->CreateRtcpBandwidthObserver()); | 93 send_side_cc->GetBitrateController()->CreateRtcpBandwidthObserver()); |
| 84 } else { | 94 } else { |
| 85 RTC_NOTREACHED() << "Registering unsupported RTP extension."; | 95 RTC_NOTREACHED() << "Registering unsupported RTP extension."; |
| 86 } | 96 } |
| 87 } | 97 } |
| 88 channel_proxy_->RegisterSenderCongestionControlObjects( | 98 channel_proxy_->RegisterSenderCongestionControlObjects( |
| 89 send_side_cc->pacer(), send_side_cc, packet_router, | 99 send_side_cc->pacer(), send_side_cc, packet_router, |
| 90 bandwidth_observer_.get()); | 100 bandwidth_observer_.get()); |
| 91 if (!SetupSendCodec()) { | 101 if (!SetupSendCodec()) { |
| 92 LOG(LS_ERROR) << "Failed to set up send codec state."; | 102 LOG(LS_ERROR) << "Failed to set up send codec state."; |
| 93 } | 103 } |
| 94 } | 104 } |
| 95 | 105 |
| 96 AudioSendStream::~AudioSendStream() { | 106 AudioSendStream::~AudioSendStream() { |
| 97 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 107 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 98 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); | 108 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); |
| 109 send_side_cc_->DeRegisterTransportFeedbackAdapterObserver(this); | |
| 99 channel_proxy_->DeRegisterExternalTransport(); | 110 channel_proxy_->DeRegisterExternalTransport(); |
| 100 channel_proxy_->ResetCongestionControlObjects(); | 111 channel_proxy_->ResetCongestionControlObjects(); |
| 101 channel_proxy_->SetRtcEventLog(nullptr); | 112 channel_proxy_->SetRtcEventLog(nullptr); |
| 102 channel_proxy_->SetRtcpRttStats(nullptr); | 113 channel_proxy_->SetRtcpRttStats(nullptr); |
| 103 } | 114 } |
| 104 | 115 |
| 105 void AudioSendStream::Start() { | 116 void AudioSendStream::Start() { |
| 106 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 117 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 107 if (config_.min_bitrate_bps != -1 && config_.max_bitrate_bps != -1) { | 118 if (config_.min_bitrate_bps != -1 && config_.max_bitrate_bps != -1) { |
| 108 RTC_DCHECK_GE(config_.max_bitrate_bps, config_.min_bitrate_bps); | 119 RTC_DCHECK_GE(config_.max_bitrate_bps, config_.min_bitrate_bps); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 if (bitrate_bps > max_bitrate_bps) | 251 if (bitrate_bps > max_bitrate_bps) |
| 241 bitrate_bps = max_bitrate_bps; | 252 bitrate_bps = max_bitrate_bps; |
| 242 | 253 |
| 243 channel_proxy_->SetBitrate(bitrate_bps, probing_interval_ms); | 254 channel_proxy_->SetBitrate(bitrate_bps, probing_interval_ms); |
| 244 | 255 |
| 245 // The amount of audio protection is not exposed by the encoder, hence | 256 // The amount of audio protection is not exposed by the encoder, hence |
| 246 // always returning 0. | 257 // always returning 0. |
| 247 return 0; | 258 return 0; |
| 248 } | 259 } |
| 249 | 260 |
| 261 void AudioSendStream::OnPacketAdded(uint32_t ssrc, uint16_t seq_num) { | |
|
the sun
2017/03/22 12:06:42
Add thread checkers to document on which thread(s)
elad.alon_webrtc.org
2017/03/22 14:34:46
Done.
| |
| 262 // Only packets that belong to this stream are of interest. | |
| 263 if (ssrc == config_.rtp.ssrc) { | |
| 264 rtc::CritScope lock(&packet_loss_tracker_cs_); | |
| 265 packet_loss_tracker_.OnPacketAdded(seq_num, clock_->TimeInMilliseconds()); | |
| 266 // TODO(elad.alon): Take care of the following known issue - this could | |
|
the sun
2017/03/22 12:06:42
Which following issues?
elad.alon_webrtc.org
2017/03/22 14:34:46
The one immediately after the hyphen. Minyue has a
minyue-webrtc
2017/03/22 16:27:40
The work "following" makes people think an issue o
elad.alon_webrtc.org
2017/03/22 16:34:19
I think the wording of the latest patchset (PS24)
the sun
2017/03/23 11:11:14
The wording has not changed in the sense that the
elad.alon_webrtc.org
2017/03/23 13:37:30
Minyue, I'm going to take up this suggestion, as i
minyue-webrtc
2017/03/23 13:57:16
You are to make it
// TODO(elad.alon): This could
elad.alon_webrtc.org
2017/03/23 18:04:23
OK
| |
| 267 // potentially reset the window, setting both PLR and RPLR to unknown. | |
| 268 } | |
| 269 } | |
| 270 | |
| 271 void AudioSendStream::OnNewTransportFeedbackVector( | |
| 272 const std::vector<PacketFeedback>& packet_feedback_vector) { | |
| 273 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 274 rtc::CritScope lock(&packet_loss_tracker_cs_); | |
|
the sun
2017/03/22 12:06:42
packet_loss_tracker_ and channel_proxy_ are both s
elad.alon_webrtc.org
2017/03/22 14:34:46
PLT internals. OnPacketAdded() and OnNewTransportF
the sun
2017/03/23 11:11:14
This one is interesting and tricky.
On one hand I
elad.alon_webrtc.org
2017/03/23 13:37:30
One additional thing to consider is that the CL im
minyue-webrtc
2017/03/23 13:57:16
The "greater reward" isn't big. It is not a big de
| |
| 275 packet_loss_tracker_.OnNewTransportFeedbackVector(packet_feedback_vector); | |
| 276 const auto plr = packet_loss_tracker_.GetPacketLossRate(); | |
| 277 // TODO(elad.alon): Resolve the following known issue - if PLR goes back | |
| 278 // to unknown, no indication is given that the previously sent value is no | |
| 279 // longer relevant. This will be taken care of with some refactoring which is | |
| 280 // now being done. | |
| 281 if (plr) { | |
| 282 channel_proxy_->OnTwccBasedUplinkPacketLossRate(*plr); | |
| 283 } | |
| 284 } | |
| 285 | |
| 250 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { | 286 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { |
| 251 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 287 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 252 return config_; | 288 return config_; |
| 253 } | 289 } |
| 254 | 290 |
| 255 void AudioSendStream::SetTransportOverhead(int transport_overhead_per_packet) { | 291 void AudioSendStream::SetTransportOverhead(int transport_overhead_per_packet) { |
| 256 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 292 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 257 send_side_cc_->SetTransportOverhead(transport_overhead_per_packet); | 293 send_side_cc_->SetTransportOverhead(transport_overhead_per_packet); |
| 258 channel_proxy_->SetTransportOverhead(transport_overhead_per_packet); | 294 channel_proxy_->SetTransportOverhead(transport_overhead_per_packet); |
| 259 } | 295 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 LOG(LS_WARNING) << "SetVADStatus() failed."; | 409 LOG(LS_WARNING) << "SetVADStatus() failed."; |
| 374 return false; | 410 return false; |
| 375 } | 411 } |
| 376 } | 412 } |
| 377 } | 413 } |
| 378 return true; | 414 return true; |
| 379 } | 415 } |
| 380 | 416 |
| 381 } // namespace internal | 417 } // namespace internal |
| 382 } // namespace webrtc | 418 } // namespace webrtc |
| OLD | NEW |