Index: webrtc/audio/audio_send_stream.cc |
diff --git a/webrtc/audio/audio_send_stream.cc b/webrtc/audio/audio_send_stream.cc |
index 6364202aa65ccc573acbb76e29034e813d5e32a3..a146ceb8e977bc0d8f302dd665d2e46dff669f43 100644 |
--- a/webrtc/audio/audio_send_stream.cc |
+++ b/webrtc/audio/audio_send_stream.cc |
@@ -40,6 +40,11 @@ bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) { |
} // namespace |
namespace internal { |
+// TODO(elad.alon): Subsequent CL will make these values experiment-dependent. |
+constexpr size_t kPacketLossTrackerMaxWindowSizeMs = 15000; |
+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.
|
+constexpr size_t kRplrMinNumAckedPairs = 40; |
+ |
AudioSendStream::AudioSendStream( |
const webrtc::AudioSendStream::Config& config, |
const rtc::scoped_refptr<webrtc::AudioState>& audio_state, |
@@ -49,11 +54,15 @@ AudioSendStream::AudioSendStream( |
BitrateAllocator* bitrate_allocator, |
RtcEventLog* event_log, |
RtcpRttStats* rtcp_rtt_stats) |
- : worker_queue_(worker_queue), |
+ : clock_(Clock::GetRealTimeClock()), |
the sun
2017/03/22 12:06:42
Remove.
elad.alon_webrtc.org
2017/03/22 14:34:46
Done.
|
+ worker_queue_(worker_queue), |
config_(config), |
audio_state_(audio_state), |
bitrate_allocator_(bitrate_allocator), |
- send_side_cc_(send_side_cc) { |
+ send_side_cc_(send_side_cc), |
+ packet_loss_tracker_(kPacketLossTrackerMaxWindowSizeMs, |
+ kPlrMinNumAckedPackets, |
+ kRplrMinNumAckedPairs) { |
LOG(LS_INFO) << "AudioSendStream: " << config_.ToString(); |
RTC_DCHECK_NE(config_.voe_channel_id, -1); |
RTC_DCHECK(audio_state_.get()); |
@@ -72,6 +81,7 @@ AudioSendStream::AudioSendStream( |
config_.rtp.nack.rtp_history_ms / 20); |
channel_proxy_->RegisterExternalTransport(config.send_transport); |
+ send_side_cc_->RegisterTransportFeedbackAdapterObserver(this); |
for (const auto& extension : config.rtp.extensions) { |
if (extension.uri == RtpExtension::kAudioLevelUri) { |
@@ -96,6 +106,7 @@ AudioSendStream::AudioSendStream( |
AudioSendStream::~AudioSendStream() { |
RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); |
+ send_side_cc_->DeRegisterTransportFeedbackAdapterObserver(this); |
channel_proxy_->DeRegisterExternalTransport(); |
channel_proxy_->ResetCongestionControlObjects(); |
channel_proxy_->SetRtcEventLog(nullptr); |
@@ -247,6 +258,31 @@ uint32_t AudioSendStream::OnBitrateUpdated(uint32_t bitrate_bps, |
return 0; |
} |
+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.
|
+ // Only packets that belong to this stream are of interest. |
+ if (ssrc == config_.rtp.ssrc) { |
+ rtc::CritScope lock(&packet_loss_tracker_cs_); |
+ packet_loss_tracker_.OnPacketAdded(seq_num, clock_->TimeInMilliseconds()); |
+ // 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
|
+ // potentially reset the window, setting both PLR and RPLR to unknown. |
+ } |
+} |
+ |
+void AudioSendStream::OnNewTransportFeedbackVector( |
+ const std::vector<PacketFeedback>& packet_feedback_vector) { |
+ RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ 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
|
+ packet_loss_tracker_.OnNewTransportFeedbackVector(packet_feedback_vector); |
+ const auto plr = packet_loss_tracker_.GetPacketLossRate(); |
+ // TODO(elad.alon): Resolve the following known issue - if PLR goes back |
+ // to unknown, no indication is given that the previously sent value is no |
+ // longer relevant. This will be taken care of with some refactoring which is |
+ // now being done. |
+ if (plr) { |
+ channel_proxy_->OnTwccBasedUplinkPacketLossRate(*plr); |
+ } |
+} |
+ |
const webrtc::AudioSendStream::Config& AudioSendStream::config() const { |
RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
return config_; |