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

Side by Side Diff: media/cast/transport/rtp_sender/rtp_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: got 500 responses when uploading, uploading again 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 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 return true; 68 return true;
69 } 69 }
70 70
71 void RtpSender::SendFrame(const EncodedFrame& frame) { 71 void RtpSender::SendFrame(const EncodedFrame& frame) {
72 DCHECK(packetizer_); 72 DCHECK(packetizer_);
73 packetizer_->SendFrameAsPackets(frame); 73 packetizer_->SendFrameAsPackets(frame);
74 } 74 }
75 75
76 void RtpSender::ResendPackets( 76 void RtpSender::ResendPackets(
77 const MissingFramesAndPacketsMap& missing_frames_and_packets, 77 const MissingFramesAndPacketsMap& missing_frames_and_packets,
78 bool cancel_rtx_if_not_in_list) { 78 bool cancel_rtx_if_not_in_list,
79 base::TimeDelta rtt) {
79 DCHECK(storage_); 80 DCHECK(storage_);
80 // Iterate over all frames in the list. 81 // Iterate over all frames in the list.
81 for (MissingFramesAndPacketsMap::const_iterator it = 82 for (MissingFramesAndPacketsMap::const_iterator it =
82 missing_frames_and_packets.begin(); 83 missing_frames_and_packets.begin();
83 it != missing_frames_and_packets.end(); 84 it != missing_frames_and_packets.end();
84 ++it) { 85 ++it) {
85 SendPacketVector packets_to_resend; 86 SendPacketVector packets_to_resend;
86 uint8 frame_id = it->first; 87 uint8 frame_id = it->first;
87 // Set of packets that the receiver wants us to re-send. 88 // Set of packets that the receiver wants us to re-send.
88 // If empty, we need to re-send all packets for this frame. 89 // If empty, we need to re-send all packets for this frame.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 VLOG(3) << "Resend " << static_cast<int>(frame_id) << ":" 123 VLOG(3) << "Resend " << static_cast<int>(frame_id) << ":"
123 << packet_id; 124 << packet_id;
124 // Set a unique incremental sequence number for every packet. 125 // Set a unique incremental sequence number for every packet.
125 PacketRef packet_copy = FastCopyPacket(it->second); 126 PacketRef packet_copy = FastCopyPacket(it->second);
126 UpdateSequenceNumber(&packet_copy->data); 127 UpdateSequenceNumber(&packet_copy->data);
127 packets_to_resend.push_back(std::make_pair(packet_key, packet_copy)); 128 packets_to_resend.push_back(std::make_pair(packet_key, packet_copy));
128 } else if (cancel_rtx_if_not_in_list) { 129 } else if (cancel_rtx_if_not_in_list) {
129 transport_->CancelSendingPacket(it->first); 130 transport_->CancelSendingPacket(it->first);
130 } 131 }
131 } 132 }
132 transport_->ResendPackets(packets_to_resend); 133 transport_->ResendPackets(packets_to_resend, rtt);
133 } 134 }
134 } 135 }
135 136
136 void RtpSender::UpdateSequenceNumber(Packet* packet) { 137 void RtpSender::UpdateSequenceNumber(Packet* packet) {
137 uint16 new_sequence_number = packetizer_->NextSequenceNumber(); 138 uint16 new_sequence_number = packetizer_->NextSequenceNumber();
138 int index = 2; 139 int index = 2;
139 (*packet)[index] = (static_cast<uint8>(new_sequence_number)); 140 (*packet)[index] = (static_cast<uint8>(new_sequence_number));
140 (*packet)[index + 1] = (static_cast<uint8>(new_sequence_number >> 8)); 141 (*packet)[index + 1] = (static_cast<uint8>(new_sequence_number >> 8));
141 } 142 }
142 143
143 } // namespace transport 144 } // namespace transport
144 } // namespace cast 145 } // namespace cast
145 } // namespace media 146 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698