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

Unified Diff: media/cast/transport/pacing/paced_sender.cc

Issue 343523005: Cast: Avoid retransmit if we sent the same packet recently (less than RTT) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: store time before send, not after Created 6 years, 6 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: media/cast/transport/pacing/paced_sender.cc
diff --git a/media/cast/transport/pacing/paced_sender.cc b/media/cast/transport/pacing/paced_sender.cc
index 10b42240759a3fd2c2580f802a7ed3b1e8b473ea..2d76fc08cd4a45d3c4092e97b43fc31f06d34ac3 100644
--- a/media/cast/transport/pacing/paced_sender.cc
+++ b/media/cast/transport/pacing/paced_sender.cc
@@ -73,11 +73,21 @@ bool PacedSender::SendPackets(const SendPacketVector& packets) {
return true;
}
-bool PacedSender::ResendPackets(const SendPacketVector& packets) {
+bool PacedSender::ResendPackets(const SendPacketVector& packets,
+ base::TimeDelta rtt) {
if (packets.empty()) {
return true;
}
+ base::TimeTicks now = clock_->NowTicks();
for (size_t i = 0; i < packets.size(); i++) {
+ std::map<PacketKey, base::TimeTicks>::const_iterator j =
+ sent_time_.find(packets[i].first);
+
+ if (j != sent_time_.end() && now - j->second < rtt) {
+ // TODO(hubbe): Log this.
+ continue;
+ }
+
packet_list_[packets[i].first] =
make_pair(PacketType_Resend, packets[i].second);
}
@@ -108,11 +118,13 @@ void PacedSender::CancelSendingPacket(const PacketKey& packet_key) {
packet_list_.erase(packet_key);
}
-PacketRef PacedSender::GetNextPacket(PacketType* packet_type) {
+PacketRef PacedSender::GetNextPacket(PacketType* packet_type,
+ PacketKey* packet_key) {
std::map<PacketKey, std::pair<PacketType, PacketRef> >::iterator i;
i = packet_list_.begin();
DCHECK(i != packet_list_.end());
*packet_type = i->second.first;
+ *packet_key = i->first;
PacketRef ret = i->second.second;
packet_list_.erase(i);
return ret;
@@ -185,7 +197,10 @@ void PacedSender::SendStoredPackets() {
return;
}
PacketType packet_type;
- PacketRef packet = GetNextPacket(&packet_type);
+ PacketKey packet_key;
+ PacketRef packet = GetNextPacket(&packet_type, &packet_key);
+ sent_time_[packet_key] = now;
+ sent_time_buffer_[packet_key] = now;
switch (packet_type) {
case PacketType_Resend:
@@ -203,6 +218,11 @@ void PacedSender::SendStoredPackets() {
}
current_burst_size_++;
}
+ // Keep ~1 second of data (1000 packets)
+ if (sent_time_buffer_.size() > kMaxBurstSize * 1000 / kPacingIntervalMs) {
+ sent_time_.swap(sent_time_buffer_);
+ sent_time_buffer_.clear();
+ }
state_ = State_Unblocked;
}

Powered by Google App Engine
This is Rietveld 408576698