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

Side by Side Diff: media/cast/transport/rtp_sender/rtp_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: re-upping to trick build system Created 6 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cast/transport/rtp_sender/rtp_sender.h" 5 #include "media/cast/transport/rtp_sender/rtp_sender.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "media/cast/transport/cast_transport_defines.h" 9 #include "media/cast/transport/cast_transport_defines.h"
10 #include "media/cast/transport/pacing/paced_sender.h" 10 #include "media/cast/transport/pacing/paced_sender.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 void RtpSender::ResendPackets( 73 void RtpSender::ResendPackets(
74 const MissingFramesAndPacketsMap& missing_frames_and_packets) { 74 const MissingFramesAndPacketsMap& missing_frames_and_packets) {
75 DCHECK(storage_); 75 DCHECK(storage_);
76 // Iterate over all frames in the list. 76 // Iterate over all frames in the list.
77 for (MissingFramesAndPacketsMap::const_iterator it = 77 for (MissingFramesAndPacketsMap::const_iterator it =
78 missing_frames_and_packets.begin(); 78 missing_frames_and_packets.begin();
79 it != missing_frames_and_packets.end(); 79 it != missing_frames_and_packets.end();
80 ++it) { 80 ++it) {
81 PacketList packets_to_resend; 81 SendPacketVector packets_to_resend;
82 uint8 frame_id = it->first; 82 uint8 frame_id = it->first;
83 const PacketIdSet& packets_set = it->second; 83 const PacketIdSet& packets_set = it->second;
84 bool success = false; 84 bool success = false;
85 85
86 if (packets_set.empty()) { 86 if (packets_set.empty()) {
87 VLOG(3) << "Missing all packets in frame " << static_cast<int>(frame_id); 87 VLOG(3) << "Missing all packets in frame " << static_cast<int>(frame_id);
88 88
89 uint16 packet_id = 0; 89 uint16 packet_id = 0;
90 do { 90 do {
91 // Get packet from storage. 91 // Get packet from storage.
92 success = storage_->GetPacket(frame_id, packet_id, &packets_to_resend); 92 success = storage_->GetPacket(frame_id, packet_id, &packets_to_resend);
93 93
94 // Resend packet to the network. 94 // Resend packet to the network.
95 if (success) { 95 if (success) {
96 VLOG(3) << "Resend " << static_cast<int>(frame_id) << ":" 96 VLOG(3) << "Resend " << static_cast<int>(frame_id) << ":"
97 << packet_id; 97 << packet_id;
98 // Set a unique incremental sequence number for every packet. 98 // Set a unique incremental sequence number for every packet.
99 PacketRef packet = packets_to_resend.back(); 99 PacketRef packet = packets_to_resend.back().second;
100 UpdateSequenceNumber(&packet->data); 100 UpdateSequenceNumber(&packet->data);
101 // Set the size as correspond to each frame. 101 // Set the size as correspond to each frame.
102 ++packet_id; 102 ++packet_id;
103 } 103 }
104 } while (success); 104 } while (success);
105 } else { 105 } else {
106 // Iterate over all of the packets in the frame. 106 // Iterate over all of the packets in the frame.
107 for (PacketIdSet::const_iterator set_it = packets_set.begin(); 107 for (PacketIdSet::const_iterator set_it = packets_set.begin();
108 set_it != packets_set.end(); 108 set_it != packets_set.end();
109 ++set_it) { 109 ++set_it) {
110 uint16 packet_id = *set_it; 110 uint16 packet_id = *set_it;
111 success = storage_->GetPacket(frame_id, packet_id, &packets_to_resend); 111 success = storage_->GetPacket(frame_id, packet_id, &packets_to_resend);
112 112
113 // Resend packet to the network. 113 // Resend packet to the network.
114 if (success) { 114 if (success) {
115 VLOG(3) << "Resend " << static_cast<int>(frame_id) << ":" 115 VLOG(3) << "Resend " << static_cast<int>(frame_id) << ":"
116 << packet_id; 116 << packet_id;
117 PacketRef packet = packets_to_resend.back(); 117 PacketRef packet = packets_to_resend.back().second;
118 UpdateSequenceNumber(&packet->data); 118 UpdateSequenceNumber(&packet->data);
119 } 119 }
120 } 120 }
121 } 121 }
122 transport_->ResendPackets(packets_to_resend); 122 transport_->ResendPackets(packets_to_resend);
123 } 123 }
124 } 124 }
125 125
126 void RtpSender::UpdateSequenceNumber(Packet* packet) { 126 void RtpSender::UpdateSequenceNumber(Packet* packet) {
127 uint16 new_sequence_number = packetizer_->NextSequenceNumber(); 127 uint16 new_sequence_number = packetizer_->NextSequenceNumber();
(...skipping 22 matching lines...) Expand all
150 packetizer_->LastSentTimestamp(&time_sent, &rtp_timestamp); 150 packetizer_->LastSentTimestamp(&time_sent, &rtp_timestamp);
151 sender_info.send_packet_count = packetizer_->send_packets_count(); 151 sender_info.send_packet_count = packetizer_->send_packets_count();
152 sender_info.send_octet_count = packetizer_->send_octet_count(); 152 sender_info.send_octet_count = packetizer_->send_octet_count();
153 stats_callback_.Run(sender_info, time_sent, rtp_timestamp); 153 stats_callback_.Run(sender_info, time_sent, rtp_timestamp);
154 ScheduleNextStatsReport(); 154 ScheduleNextStatsReport();
155 } 155 }
156 156
157 } // namespace transport 157 } // namespace transport
158 } // namespace cast 158 } // namespace cast
159 } // namespace media 159 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/transport/rtp_sender/rtp_packetizer/rtp_packetizer.cc ('k') | media/cast/video_receiver/video_receiver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698