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..2e7928630739317790ed8894bd0fd65683481e4e 100644 |
--- a/media/cast/net/pacing/paced_sender.cc |
+++ b/media/cast/net/pacing/paced_sender.cc |
@@ -60,13 +60,22 @@ 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; |
} |
for (size_t i = 0; i < packets.size(); i++) { |
- packet_list_[packets[i].first] = |
- make_pair(PacketType_Normal, packets[i].second); |
+ if (IsHighPriority(packets[i].first)) { |
miu
2014/07/16 22:55:55
Will a SendPacketVector ever contain packets from
Alpha Left Google
2014/07/17 00:12:56
Done.
|
+ 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(); |
@@ -89,8 +98,13 @@ bool PacedSender::ResendPackets(const SendPacketVector& packets, |
continue; |
} |
- packet_list_[packets[i].first] = |
- make_pair(PacketType_Resend, packets[i].second); |
+ if (IsHighPriority(packets[i].first)) { |
miu
2014/07/16 22:55:55
ditto re: redundant IsHighPriority() calls.
Alpha Left Google
2014/07/17 00:12:56
Done.
|
+ 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 +114,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 +125,42 @@ 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, |
miu
2014/07/16 22:55:56
naming: This method should be called PopNextPacket
Alpha Left Google
2014/07/17 00:12:56
Done.
|
PacketKey* packet_key) { |
- std::map<PacketKey, std::pair<PacketType, PacketRef> >::iterator i; |
- i = packet_list_.begin(); |
- DCHECK(i != packet_list_.end()); |
+ DCHECK(!priority_packet_list_.empty() || |
miu
2014/07/16 22:55:56
Don't need this DCHECK, since the one a few lines
Alpha Left Google
2014/07/17 00:12:56
Done.
|
+ !packet_list_.empty()); |
+ PacketList* list = !priority_packet_list_.empty() ? |
+ &priority_packet_list_ : &packet_list_; |
+ DCHECK(!list->empty()); |
+ PacketList::iterator i; |
+ i = list->begin(); |
miu
2014/07/16 22:55:55
Please merge this with the line above.
Alpha Left Google
2014/07/17 00:12:56
Done.
|
*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: |