Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Unified Diff: webrtc/modules/video_coding/nack_module.cc

Issue 1972123002: Nack count returned on OnReceivedPacket. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Renamed |last_seq_num_| to |newest_seq_num_|. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/video_coding/nack_module.h ('k') | webrtc/modules/video_coding/nack_module_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/video_coding/nack_module.cc
diff --git a/webrtc/modules/video_coding/nack_module.cc b/webrtc/modules/video_coding/nack_module.cc
index 1b12afe0f0df2690ed8f0a47f6ff2eb13ac961ba..99d33ce9ab5019ebe64fee435b576a91ce5f6f22 100644
--- a/webrtc/modules/video_coding/nack_module.cc
+++ b/webrtc/modules/video_coding/nack_module.cc
@@ -49,17 +49,17 @@ NackModule::NackModule(Clock* clock,
running_(true),
initialized_(false),
rtt_ms_(kDefaultRttMs),
- last_seq_num_(0),
+ newest_seq_num_(0),
next_process_time_ms_(-1) {
RTC_DCHECK(clock_);
RTC_DCHECK(nack_sender_);
RTC_DCHECK(keyframe_request_sender_);
}
-void NackModule::OnReceivedPacket(const VCMPacket& packet) {
+int NackModule::OnReceivedPacket(const VCMPacket& packet) {
rtc::CritScope lock(&crit_);
if (!running_)
- return;
+ return -1;
uint16_t seq_num = packet.seqNum;
// TODO(philipel): When the packet includes information whether it is
// retransmitted or not, use that value instead. For
@@ -69,40 +69,48 @@ void NackModule::OnReceivedPacket(const VCMPacket& packet) {
bool is_keyframe = packet.isFirstPacket && packet.frameType == kVideoFrameKey;
if (!initialized_) {
- last_seq_num_ = seq_num;
+ newest_seq_num_ = seq_num;
if (is_keyframe)
keyframe_list_.insert(seq_num);
initialized_ = true;
- return;
+ return 0;
}
- if (seq_num == last_seq_num_)
- return;
+ // Since the |newest_seq_num_| is a packet we have actually received we know
+ // that packet has never been Nacked.
+ if (seq_num == newest_seq_num_)
+ return 0;
- if (AheadOf(last_seq_num_, seq_num)) {
+ if (AheadOf(newest_seq_num_, seq_num)) {
// An out of order packet has been received.
- nack_list_.erase(seq_num);
+ auto nack_list_it = nack_list_.find(seq_num);
+ if (nack_list_it != nack_list_.end()) {
+ int nacks_sent_for_packet = nack_list_it->second.retries;
stefan-webrtc 2016/05/12 14:27:44 Comment on this special case. Something like "Pack
+ nack_list_.erase(nack_list_it);
+ return nacks_sent_for_packet;
+ }
if (!is_retransmitted)
UpdateReorderingStatistics(seq_num);
- return;
- } else {
- AddPacketsToNack(last_seq_num_ + 1, seq_num);
- last_seq_num_ = seq_num;
+ return 0;
+ }
+ AddPacketsToNack(newest_seq_num_ + 1, seq_num);
+ newest_seq_num_ = seq_num;
- // Keep track of new keyframes.
- if (is_keyframe)
- keyframe_list_.insert(seq_num);
+ // Keep track of new keyframes.
+ if (is_keyframe)
+ keyframe_list_.insert(seq_num);
- // And remove old ones so we don't accumulate keyframes.
- auto it = keyframe_list_.lower_bound(seq_num - kMaxPacketAge);
- if (it != keyframe_list_.begin())
- keyframe_list_.erase(keyframe_list_.begin(), it);
+ // And remove old ones so we don't accumulate keyframes.
+ auto it = keyframe_list_.lower_bound(seq_num - kMaxPacketAge);
+ if (it != keyframe_list_.begin())
+ keyframe_list_.erase(keyframe_list_.begin(), it);
- // Are there any nacks that are waiting for this seq_num.
- std::vector<uint16_t> nack_batch = GetNackBatch(kSeqNumOnly);
- if (!nack_batch.empty())
- nack_sender_->SendNack(nack_batch);
- }
+ // Are there any nacks that are waiting for this seq_num.
+ std::vector<uint16_t> nack_batch = GetNackBatch(kSeqNumOnly);
+ if (!nack_batch.empty())
+ nack_sender_->SendNack(nack_batch);
+
+ return 0;
}
void NackModule::ClearUpTo(uint16_t seq_num) {
@@ -215,7 +223,7 @@ std::vector<uint16_t> NackModule::GetNackBatch(NackFilterOptions options) {
auto it = nack_list_.begin();
while (it != nack_list_.end()) {
if (consider_seq_num && it->second.sent_at_time == -1 &&
- AheadOrAt(last_seq_num_, it->second.send_at_seq_num)) {
+ AheadOrAt(newest_seq_num_, it->second.send_at_seq_num)) {
nack_batch.emplace_back(it->second.seq_num);
++it->second.retries;
it->second.sent_at_time = now_ms;
@@ -248,8 +256,8 @@ std::vector<uint16_t> NackModule::GetNackBatch(NackFilterOptions options) {
}
void NackModule::UpdateReorderingStatistics(uint16_t seq_num) {
- RTC_DCHECK(AheadOf(last_seq_num_, seq_num));
- uint16_t diff = ReverseDiff(last_seq_num_, seq_num);
+ RTC_DCHECK(AheadOf(newest_seq_num_, seq_num));
+ uint16_t diff = ReverseDiff(newest_seq_num_, seq_num);
reordering_histogram_.Add(diff);
}
« no previous file with comments | « webrtc/modules/video_coding/nack_module.h ('k') | webrtc/modules/video_coding/nack_module_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698