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

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

Issue 399743002: Cast: Implement priority packets in PacedSender (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 6 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
« no previous file with comments | « media/cast/net/pacing/paced_sender.h ('k') | media/cast/net/pacing/paced_sender_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/net/pacing/paced_sender.cc
diff --git a/media/cast/net/pacing/paced_sender.cc b/media/cast/net/pacing/paced_sender.cc
index 245e29a46aff648862552180dd7c857826c0f759..89a69272dc9edf3123c6653908615892bcf8d815 100644
--- a/media/cast/net/pacing/paced_sender.cc
+++ b/media/cast/net/pacing/paced_sender.cc
@@ -60,13 +60,24 @@ void PacedSender::RegisterVideoSsrc(uint32 video_ssrc) {
video_ssrc_ = video_ssrc;
}
+void PacedSender::RegisterPrioritySsrc(uint32 ssrc) {
+ priority_ssrcs_.push_back(ssrc);
+}
+
bool PacedSender::SendPackets(const SendPacketVector& packets) {
if (packets.empty()) {
return true;
}
+ const bool high_priority = IsHighPriority(packets.begin()->first);
for (size_t i = 0; i < packets.size(); i++) {
- packet_list_[packets[i].first] =
- make_pair(PacketType_Normal, packets[i].second);
+ DCHECK(IsHighPriority(packets[i].first) == high_priority);
+ if (high_priority) {
+ priority_packet_list_[packets[i].first] =
+ make_pair(PacketType_Normal, packets[i].second);
+ } else {
+ packet_list_[packets[i].first] =
+ make_pair(PacketType_Normal, packets[i].second);
+ }
}
if (state_ == State_Unblocked) {
SendStoredPackets();
@@ -79,6 +90,7 @@ bool PacedSender::ResendPackets(const SendPacketVector& packets,
if (packets.empty()) {
return true;
}
+ const bool high_priority = IsHighPriority(packets.begin()->first);
base::TimeTicks now = clock_->NowTicks();
for (size_t i = 0; i < packets.size(); i++) {
std::map<PacketKey, base::TimeTicks>::const_iterator j =
@@ -89,8 +101,14 @@ bool PacedSender::ResendPackets(const SendPacketVector& packets,
continue;
}
- packet_list_[packets[i].first] =
- make_pair(PacketType_Resend, packets[i].second);
+ DCHECK(IsHighPriority(packets[i].first) == high_priority);
+ if (high_priority) {
+ priority_packet_list_[packets[i].first] =
+ make_pair(PacketType_Resend, packets[i].second);
+ } else {
+ packet_list_[packets[i].first] =
+ make_pair(PacketType_Resend, packets[i].second);
+ }
}
if (state_ == State_Unblocked) {
SendStoredPackets();
@@ -100,7 +118,8 @@ bool PacedSender::ResendPackets(const SendPacketVector& packets,
bool PacedSender::SendRtcpPacket(uint32 ssrc, PacketRef packet) {
if (state_ == State_TransportBlocked) {
- packet_list_[PacedPacketSender::MakePacketKey(base::TimeTicks(), ssrc, 0)] =
+ priority_packet_list_[
+ PacedPacketSender::MakePacketKey(base::TimeTicks(), ssrc, 0)] =
make_pair(PacketType_RTCP, packet);
} else {
// We pass the RTCP packets straight through.
@@ -110,33 +129,39 @@ bool PacedSender::SendRtcpPacket(uint32 ssrc, PacketRef packet) {
weak_factory_.GetWeakPtr()))) {
state_ = State_TransportBlocked;
}
-
}
return true;
}
void PacedSender::CancelSendingPacket(const PacketKey& packet_key) {
packet_list_.erase(packet_key);
+ priority_packet_list_.erase(packet_key);
}
-PacketRef PacedSender::GetNextPacket(PacketType* packet_type,
+PacketRef PacedSender::PopNextPacket(PacketType* packet_type,
PacketKey* packet_key) {
- std::map<PacketKey, std::pair<PacketType, PacketRef> >::iterator i;
- i = packet_list_.begin();
- DCHECK(i != packet_list_.end());
+ PacketList* list = !priority_packet_list_.empty() ?
+ &priority_packet_list_ : &packet_list_;
+ DCHECK(!list->empty());
+ PacketList::iterator i = list->begin();
*packet_type = i->second.first;
*packet_key = i->first;
PacketRef ret = i->second.second;
- packet_list_.erase(i);
+ list->erase(i);
return ret;
}
+bool PacedSender::IsHighPriority(const PacketKey& packet_key) const {
+ return std::find(priority_ssrcs_.begin(), priority_ssrcs_.end(),
+ packet_key.second.first) != priority_ssrcs_.end();
+}
+
bool PacedSender::empty() const {
- return packet_list_.empty();
+ return packet_list_.empty() && priority_packet_list_.empty();
}
size_t PacedSender::size() const {
- return packet_list_.size();
+ return packet_list_.size() + priority_packet_list_.size();
}
// This function can be called from three places:
@@ -199,7 +224,7 @@ void PacedSender::SendStoredPackets() {
}
PacketType packet_type;
PacketKey packet_key;
- PacketRef packet = GetNextPacket(&packet_type, &packet_key);
+ PacketRef packet = PopNextPacket(&packet_type, &packet_key);
sent_time_[packet_key] = now;
sent_time_buffer_[packet_key] = now;
« no previous file with comments | « media/cast/net/pacing/paced_sender.h ('k') | media/cast/net/pacing/paced_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698