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

Unified Diff: webrtc/modules/remote_bitrate_estimator/send_time_history.cc

Issue 2918323002: Add functionality which limits the number of bytes on the network. (Closed)
Patch Set: . Created 3 years, 5 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
Index: webrtc/modules/remote_bitrate_estimator/send_time_history.cc
diff --git a/webrtc/modules/remote_bitrate_estimator/send_time_history.cc b/webrtc/modules/remote_bitrate_estimator/send_time_history.cc
index 734a9207130116d78faec56706ac08f42f23a248..95b41b3ea3520b3cb9f431942d87e2fb724f1c83 100644
--- a/webrtc/modules/remote_bitrate_estimator/send_time_history.cc
+++ b/webrtc/modules/remote_bitrate_estimator/send_time_history.cc
@@ -18,7 +18,9 @@ namespace webrtc {
SendTimeHistory::SendTimeHistory(const Clock* clock,
int64_t packet_age_limit_ms)
- : clock_(clock), packet_age_limit_ms_(packet_age_limit_ms) {}
+ : clock_(clock),
+ packet_age_limit_ms_(packet_age_limit_ms),
+ latest_acked_seq_num_(-1) {}
SendTimeHistory::~SendTimeHistory() {}
@@ -52,6 +54,8 @@ bool SendTimeHistory::GetFeedback(PacketFeedback* packet_feedback,
RTC_DCHECK(packet_feedback);
int64_t unwrapped_seq_num =
seq_num_unwrapper_.Unwrap(packet_feedback->sequence_number);
+ latest_acked_seq_num_ = std::max(unwrapped_seq_num, latest_acked_seq_num_);
+ RTC_DCHECK_GE(latest_acked_seq_num_, 0);
auto it = history_.find(unwrapped_seq_num);
if (it == history_.end())
return false;
@@ -66,4 +70,21 @@ bool SendTimeHistory::GetFeedback(PacketFeedback* packet_feedback,
return true;
}
+size_t SendTimeHistory::GetOutstandingBytes(uint16_t local_net_id,
+ uint16_t remote_net_id) const {
+ size_t outstanding_bytes = 0;
+ auto unacked_it = history_.begin();
+ if (latest_acked_seq_num_ >= 0) {
+ unacked_it = history_.lower_bound(latest_acked_seq_num_);
+ }
+ for (; unacked_it != history_.end(); ++unacked_it) {
+ if (unacked_it->second.local_net_id == local_net_id &&
+ unacked_it->second.remote_net_id == remote_net_id &&
+ unacked_it->second.send_time_ms >= 0) {
+ outstanding_bytes += unacked_it->second.payload_size;
+ }
+ }
+ return outstanding_bytes;
+}
+
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698