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

Side by Side Diff: webrtc/modules/video_coding/packet_buffer.cc

Issue 1988653002: PacketBuffer now can save how many times a packet has been nacked. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 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 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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
(...skipping 19 matching lines...) Expand all
30 first_packet_received_(false), 30 first_packet_received_(false),
31 data_buffer_(start_buffer_size), 31 data_buffer_(start_buffer_size),
32 sequence_buffer_(start_buffer_size), 32 sequence_buffer_(start_buffer_size),
33 reference_finder_(frame_callback) { 33 reference_finder_(frame_callback) {
34 RTC_DCHECK_LE(start_buffer_size, max_buffer_size); 34 RTC_DCHECK_LE(start_buffer_size, max_buffer_size);
35 // Buffer size must always be a power of 2. 35 // Buffer size must always be a power of 2.
36 RTC_DCHECK((start_buffer_size & (start_buffer_size - 1)) == 0); 36 RTC_DCHECK((start_buffer_size & (start_buffer_size - 1)) == 0);
37 RTC_DCHECK((max_buffer_size & (max_buffer_size - 1)) == 0); 37 RTC_DCHECK((max_buffer_size & (max_buffer_size - 1)) == 0);
38 } 38 }
39 39
40 bool PacketBuffer::InsertPacket(const VCMPacket& packet) { 40 bool PacketBuffer::InsertPacket(const VCMPacket& packet, int times_nacked) {
41 rtc::CritScope lock(&crit_); 41 rtc::CritScope lock(&crit_);
42 uint16_t seq_num = packet.seqNum; 42 uint16_t seq_num = packet.seqNum;
43 size_t index = seq_num % size_; 43 size_t index = seq_num % size_;
44 44
45 if (!first_packet_received_) { 45 if (!first_packet_received_) {
46 first_seq_num_ = seq_num - 1; 46 first_seq_num_ = seq_num - 1;
47 last_seq_num_ = seq_num; 47 last_seq_num_ = seq_num;
48 first_packet_received_ = true; 48 first_packet_received_ = true;
49 } 49 }
50 50
(...skipping 14 matching lines...) Expand all
65 65
66 if (AheadOf(seq_num, last_seq_num_)) 66 if (AheadOf(seq_num, last_seq_num_))
67 last_seq_num_ = seq_num; 67 last_seq_num_ = seq_num;
68 68
69 sequence_buffer_[index].frame_begin = packet.isFirstPacket; 69 sequence_buffer_[index].frame_begin = packet.isFirstPacket;
70 sequence_buffer_[index].frame_end = packet.markerBit; 70 sequence_buffer_[index].frame_end = packet.markerBit;
71 sequence_buffer_[index].seq_num = packet.seqNum; 71 sequence_buffer_[index].seq_num = packet.seqNum;
72 sequence_buffer_[index].continuous = false; 72 sequence_buffer_[index].continuous = false;
73 sequence_buffer_[index].frame_created = false; 73 sequence_buffer_[index].frame_created = false;
74 sequence_buffer_[index].used = true; 74 sequence_buffer_[index].used = true;
75 sequence_buffer_[index].times_nacked = times_nacked;
75 data_buffer_[index] = packet; 76 data_buffer_[index] = packet;
76 77
77 FindFrames(seq_num); 78 FindFrames(seq_num);
78 return true; 79 return true;
79 } 80 }
80 81
81 void PacketBuffer::ClearTo(uint16_t seq_num) { 82 void PacketBuffer::ClearTo(uint16_t seq_num) {
82 rtc::CritScope lock(&crit_); 83 rtc::CritScope lock(&crit_);
83 size_t index = first_seq_num_ % size_; 84 size_t index = first_seq_num_ % size_;
84 while (AheadOf<uint16_t>(seq_num, first_seq_num_ + 1)) { 85 while (AheadOf<uint16_t>(seq_num, first_seq_num_ + 1)) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 132
132 void PacketBuffer::FindFrames(uint16_t seq_num) { 133 void PacketBuffer::FindFrames(uint16_t seq_num) {
133 size_t index = seq_num % size_; 134 size_t index = seq_num % size_;
134 while (IsContinuous(seq_num)) { 135 while (IsContinuous(seq_num)) {
135 sequence_buffer_[index].continuous = true; 136 sequence_buffer_[index].continuous = true;
136 137
137 // If all packets of the frame is continuous, find the first packet of the 138 // If all packets of the frame is continuous, find the first packet of the
138 // frame and create an RtpFrameObject. 139 // frame and create an RtpFrameObject.
139 if (sequence_buffer_[index].frame_end) { 140 if (sequence_buffer_[index].frame_end) {
140 int start_index = index; 141 int start_index = index;
142 size_t combined_size = 0;
stefan-webrtc 2016/05/20 13:10:23 Should this be frame_size instead?
philipel 2016/05/23 09:19:22 Done.
143 int8_t max_nack_count = -1;
141 uint16_t start_seq_num = seq_num; 144 uint16_t start_seq_num = seq_num;
142 145
143 while (!sequence_buffer_[start_index].frame_begin) { 146 while (!sequence_buffer_[start_index].frame_begin) {
147 combined_size += data_buffer_[start_index].sizeBytes;
148 max_nack_count = std::max<int8_t>(
149 max_nack_count, sequence_buffer_[start_index].times_nacked);
144 sequence_buffer_[start_index].frame_created = true; 150 sequence_buffer_[start_index].frame_created = true;
145 start_index = start_index > 0 ? start_index - 1 : size_ - 1; 151 start_index = start_index > 0 ? start_index - 1 : size_ - 1;
stefan-webrtc 2016/05/20 13:10:23 start_index seems like a bad variable name as it d
philipel 2016/05/23 09:19:22 Hard to find a better name, I added a comment abou
146 start_seq_num--; 152 start_seq_num--;
147 } 153 }
154 combined_size += data_buffer_[start_index].sizeBytes;
155 max_nack_count = std::max<int8_t>(
156 max_nack_count, sequence_buffer_[start_index].times_nacked);
148 sequence_buffer_[start_index].frame_created = true; 157 sequence_buffer_[start_index].frame_created = true;
149 158
150 std::unique_ptr<RtpFrameObject> frame( 159 std::unique_ptr<RtpFrameObject> frame(new RtpFrameObject(
151 new RtpFrameObject(this, start_seq_num, seq_num)); 160 this, start_seq_num, seq_num, combined_size, max_nack_count));
152 reference_finder_.ManageFrame(std::move(frame)); 161 reference_finder_.ManageFrame(std::move(frame));
153 } 162 }
154 163
155 index = (index + 1) % size_; 164 index = (index + 1) % size_;
156 ++seq_num; 165 ++seq_num;
157 } 166 }
158 } 167 }
159 168
160 void PacketBuffer::ReturnFrame(RtpFrameObject* frame) { 169 void PacketBuffer::ReturnFrame(RtpFrameObject* frame) {
161 rtc::CritScope lock(&crit_); 170 rtc::CritScope lock(&crit_);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 void PacketBuffer::Clear() { 223 void PacketBuffer::Clear() {
215 rtc::CritScope lock(&crit_); 224 rtc::CritScope lock(&crit_);
216 for (size_t i = 0; i < size_; ++i) 225 for (size_t i = 0; i < size_; ++i)
217 sequence_buffer_[i].used = false; 226 sequence_buffer_[i].used = false;
218 227
219 first_packet_received_ = false; 228 first_packet_received_ = false;
220 } 229 }
221 230
222 } // namespace video_coding 231 } // namespace video_coding
223 } // namespace webrtc 232 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698