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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_packet_history.cc

Issue 1414563003: Remove time constraint on first retransmit of a packet. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Updated unit tests Created 5 years, 2 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 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_history.h" 11 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_history.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 #include <stdlib.h> 14 #include <stdlib.h>
15 #include <string.h> // memset 15 #include <string.h> // memset
16 #include <limits> 16 #include <limits>
17 #include <set> 17 #include <set>
18 18
19 #include "webrtc/base/checks.h"
19 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" 20 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
20 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 21 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
21 #include "webrtc/system_wrappers/interface/logging.h" 22 #include "webrtc/system_wrappers/interface/logging.h"
22 23
23 namespace webrtc { 24 namespace webrtc {
24 25
25 static const int kMinPacketRequestBytes = 50; 26 static const int kMinPacketRequestBytes = 50;
26 27
27 RTPPacketHistory::RTPPacketHistory(Clock* clock) 28 RTPPacketHistory::RTPPacketHistory(Clock* clock)
28 : clock_(clock), 29 : clock_(clock),
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // TODO(sprang): Overhaul this class and get rid of this copy step. 112 // TODO(sprang): Overhaul this class and get rid of this copy step.
112 // (Finally introduce the RtpPacket class?) 113 // (Finally introduce the RtpPacket class?)
113 memcpy(stored_packets_[prev_index_].data, packet, packet_length); 114 memcpy(stored_packets_[prev_index_].data, packet, packet_length);
114 stored_packets_[prev_index_].length = packet_length; 115 stored_packets_[prev_index_].length = packet_length;
115 116
116 stored_packets_[prev_index_].sequence_number = seq_num; 117 stored_packets_[prev_index_].sequence_number = seq_num;
117 stored_packets_[prev_index_].time_ms = 118 stored_packets_[prev_index_].time_ms =
118 (capture_time_ms > 0) ? capture_time_ms : clock_->TimeInMilliseconds(); 119 (capture_time_ms > 0) ? capture_time_ms : clock_->TimeInMilliseconds();
119 stored_packets_[prev_index_].send_time = 0; // Packet not sent. 120 stored_packets_[prev_index_].send_time = 0; // Packet not sent.
120 stored_packets_[prev_index_].storage_type = type; 121 stored_packets_[prev_index_].storage_type = type;
122 stored_packets_[prev_index_].has_been_retransmitted = false;
121 123
122 ++prev_index_; 124 ++prev_index_;
123 if (prev_index_ >= stored_packets_.size()) { 125 if (prev_index_ >= stored_packets_.size()) {
124 prev_index_ = 0; 126 prev_index_ = 0;
125 } 127 }
126 return 0; 128 return 0;
127 } 129 }
128 130
129 bool RTPPacketHistory::HasRTPPacket(uint16_t sequence_number) const { 131 bool RTPPacketHistory::HasRTPPacket(uint16_t sequence_number) const {
130 CriticalSectionScoped cs(critsect_.get()); 132 CriticalSectionScoped cs(critsect_.get());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 return true; 168 return true;
167 } 169 }
168 170
169 bool RTPPacketHistory::GetPacketAndSetSendTime(uint16_t sequence_number, 171 bool RTPPacketHistory::GetPacketAndSetSendTime(uint16_t sequence_number,
170 int64_t min_elapsed_time_ms, 172 int64_t min_elapsed_time_ms,
171 bool retransmit, 173 bool retransmit,
172 uint8_t* packet, 174 uint8_t* packet,
173 size_t* packet_length, 175 size_t* packet_length,
174 int64_t* stored_time_ms) { 176 int64_t* stored_time_ms) {
175 CriticalSectionScoped cs(critsect_.get()); 177 CriticalSectionScoped cs(critsect_.get());
176 assert(*packet_length >= IP_PACKET_SIZE); 178 RTC_CHECK_GE(*packet_length, static_cast<size_t>(IP_PACKET_SIZE));
177 if (!store_) { 179 if (!store_)
178 return false; 180 return false;
179 }
180 181
181 int32_t index = 0; 182 int32_t index = 0;
182 bool found = FindSeqNum(sequence_number, &index); 183 bool found = FindSeqNum(sequence_number, &index);
183 if (!found) { 184 if (!found) {
184 LOG(LS_WARNING) << "No match for getting seqNum " << sequence_number; 185 LOG(LS_WARNING) << "No match for getting seqNum " << sequence_number;
185 return false; 186 return false;
186 } 187 }
187 188
188 size_t length = stored_packets_[index].length; 189 size_t length = stored_packets_[index].length;
189 assert(length <= IP_PACKET_SIZE); 190 assert(length <= IP_PACKET_SIZE);
190 if (length == 0) { 191 if (length == 0) {
191 LOG(LS_WARNING) << "No match for getting seqNum " << sequence_number 192 LOG(LS_WARNING) << "No match for getting seqNum " << sequence_number
192 << ", len " << length; 193 << ", len " << length;
193 return false; 194 return false;
194 } 195 }
195 196
196 // Verify elapsed time since last retrieve. 197 // Verify elapsed time since last retrieve, but only for retransmissions and
198 // always send packet upon first retransmission request.
197 int64_t now = clock_->TimeInMilliseconds(); 199 int64_t now = clock_->TimeInMilliseconds();
198 if (min_elapsed_time_ms > 0 && 200 if (min_elapsed_time_ms > 0 && retransmit &&
201 stored_packets_[index].has_been_retransmitted &&
199 ((now - stored_packets_[index].send_time) < min_elapsed_time_ms)) { 202 ((now - stored_packets_[index].send_time) < min_elapsed_time_ms)) {
200 return false; 203 return false;
201 } 204 }
202 205
203 if (retransmit && stored_packets_[index].storage_type == kDontRetransmit) { 206 if (retransmit) {
204 // No bytes copied since this packet shouldn't be retransmitted or is 207 if (stored_packets_[index].storage_type == kDontRetransmit) {
205 // of zero size. 208 // No bytes copied since this packet shouldn't be retransmitted or is
206 return false; 209 // of zero size.
210 return false;
211 }
212 stored_packets_[index].has_been_retransmitted = true;
207 } 213 }
208 stored_packets_[index].send_time = clock_->TimeInMilliseconds(); 214 stored_packets_[index].send_time = clock_->TimeInMilliseconds();
209 GetPacket(index, packet, packet_length, stored_time_ms); 215 GetPacket(index, packet, packet_length, stored_time_ms);
210 return true; 216 return true;
211 } 217 }
212 218
213 void RTPPacketHistory::GetPacket(int index, 219 void RTPPacketHistory::GetPacket(int index,
214 uint8_t* packet, 220 uint8_t* packet,
215 size_t* packet_length, 221 size_t* packet_length,
216 int64_t* stored_time_ms) const { 222 int64_t* stored_time_ms) const {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 min_diff = diff; 290 min_diff = diff;
285 best_index = static_cast<int>(i); 291 best_index = static_cast<int>(i);
286 } 292 }
287 } 293 }
288 return best_index; 294 return best_index;
289 } 295 }
290 296
291 RTPPacketHistory::StoredPacket::StoredPacket() {} 297 RTPPacketHistory::StoredPacket::StoredPacket() {}
292 298
293 } // namespace webrtc 299 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_packet_history.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698