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

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

Issue 248493002: Cast: Deduplicate packets in paced sender and always send older packets first (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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 0af66d2fe2de5fbe944e9f1fb9b46da3d78a845a..70e174cbf3c0d3c8865fb3c44de15d7a9621b656 100644
--- a/media/cast/transport/pacing/paced_sender.cc
+++ b/media/cast/transport/pacing/paced_sender.cc
@@ -35,6 +35,13 @@ CastLoggingEvent GetLoggingEvent(bool is_audio, bool retransmit) {
} // namespace
+
+PacketKey PacedPacketSender::MakePacketKey(const base::TimeTicks& ticks,
+ unsigned int ssrc,
+ uint16 packet_id) {
+ return std::make_pair(ticks, std::make_pair(ssrc, packet_id));
+}
+
PacedSender::PacedSender(
base::TickClock* clock,
LoggingImpl* logging,
@@ -64,34 +71,38 @@ void PacedSender::RegisterVideoSsrc(uint32 video_ssrc) {
video_ssrc_ = video_ssrc;
}
-bool PacedSender::SendPackets(const PacketList& packets) {
+bool PacedSender::SendPackets(const SendPacketVector& packets) {
if (packets.empty()) {
return true;
}
- packet_list_.insert(packet_list_.end(), packets.begin(), packets.end());
+ for (size_t i = 0; i < packets.size(); i++) {
+ packet_list_[packets[i].first] =
+ make_pair(PacketType_Normal, packets[i].second);
+ }
if (state_ == State_Unblocked) {
SendStoredPackets();
}
return true;
}
-bool PacedSender::ResendPackets(const PacketList& packets) {
+bool PacedSender::ResendPackets(const SendPacketVector& packets) {
if (packets.empty()) {
return true;
}
- resend_packet_list_.insert(resend_packet_list_.end(),
- packets.begin(),
- packets.end());
+ for (size_t i = 0; i < packets.size(); i++) {
+ packet_list_[packets[i].first] =
+ make_pair(PacketType_Resend, packets[i].second);
+ }
if (state_ == State_Unblocked) {
SendStoredPackets();
}
return true;
}
-bool PacedSender::SendRtcpPacket(PacketRef packet) {
+bool PacedSender::SendRtcpPacket(unsigned int ssrc, PacketRef packet) {
if (state_ == State_TransportBlocked) {
-
- rtcp_packet_list_.push_back(packet);
+ packet_list_[PacedPacketSender::MakePacketKey(base::TimeTicks(), ssrc, 0)] =
+ make_pair(PacketType_RTCP, packet);
} else {
// We pass the RTCP packets straight through.
if (!transport_->SendPacket(
@@ -106,35 +117,20 @@ bool PacedSender::SendRtcpPacket(PacketRef packet) {
}
PacketRef PacedSender::GetNextPacket(PacketType* packet_type) {
- PacketRef ret;
- if (!rtcp_packet_list_.empty()) {
- ret = rtcp_packet_list_.front();
- rtcp_packet_list_.pop_front();
- *packet_type = PacketType_RTCP;
- } else if (!resend_packet_list_.empty()) {
- ret = resend_packet_list_.front();
- resend_packet_list_.pop_front();
- *packet_type = PacketType_Resend;
- } else if (!packet_list_.empty()) {
- ret = packet_list_.front();
- packet_list_.pop_front();
- *packet_type = PacketType_Normal;
- } else {
- NOTREACHED();
- }
+ std::map<PacketKey, std::pair<PacketType, PacketRef> >::iterator i;
+ i = packet_list_.begin();
+ *packet_type = i->second.first;
miu 2014/04/24 00:09:06 nit: Suggest DCHECK(i != packet_list_.end());
hubbe 2014/04/24 18:36:42 Done.
+ PacketRef ret = i->second.second;
+ packet_list_.erase(i);
return ret;
}
bool PacedSender::empty() const {
- return rtcp_packet_list_.empty() &&
- resend_packet_list_.empty() &&
- packet_list_.empty();
+ return packet_list_.empty();
}
size_t PacedSender::size() const {
- return rtcp_packet_list_.size() +
- resend_packet_list_.size() +
- packet_list_.size();
+ return packet_list_.size();
}
// This function can be called from three places:

Powered by Google App Engine
This is Rietveld 408576698