OLD | NEW |
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 130 } |
131 | 131 |
132 void PacketBuffer::FindFrames(uint16_t seq_num) { | 132 void PacketBuffer::FindFrames(uint16_t seq_num) { |
133 size_t index = seq_num % size_; | 133 size_t index = seq_num % size_; |
134 while (IsContinuous(seq_num)) { | 134 while (IsContinuous(seq_num)) { |
135 sequence_buffer_[index].continuous = true; | 135 sequence_buffer_[index].continuous = true; |
136 | 136 |
137 // If all packets of the frame is continuous, find the first packet of the | 137 // If all packets of the frame is continuous, find the first packet of the |
138 // frame and create an RtpFrameObject. | 138 // frame and create an RtpFrameObject. |
139 if (sequence_buffer_[index].frame_end) { | 139 if (sequence_buffer_[index].frame_end) { |
140 int start_index = index; | 140 size_t frame_size = 0; |
| 141 int max_nack_count = -1; |
141 uint16_t start_seq_num = seq_num; | 142 uint16_t start_seq_num = seq_num; |
142 | 143 |
143 while (!sequence_buffer_[start_index].frame_begin) { | 144 // Find the start index by searching backward until the packet with |
| 145 // the |frame_begin| flag is set. |
| 146 int start_index = index; |
| 147 while (true) { |
| 148 frame_size += data_buffer_[start_index].sizeBytes; |
| 149 max_nack_count = std::max( |
| 150 max_nack_count, data_buffer_[start_index].timesNacked); |
144 sequence_buffer_[start_index].frame_created = true; | 151 sequence_buffer_[start_index].frame_created = true; |
| 152 |
| 153 if (sequence_buffer_[start_index].frame_begin) |
| 154 break; |
| 155 |
145 start_index = start_index > 0 ? start_index - 1 : size_ - 1; | 156 start_index = start_index > 0 ? start_index - 1 : size_ - 1; |
146 start_seq_num--; | 157 start_seq_num--; |
147 } | 158 } |
148 sequence_buffer_[start_index].frame_created = true; | |
149 | 159 |
150 std::unique_ptr<RtpFrameObject> frame( | 160 std::unique_ptr<RtpFrameObject> frame(new RtpFrameObject( |
151 new RtpFrameObject(this, start_seq_num, seq_num)); | 161 this, start_seq_num, seq_num, frame_size, max_nack_count)); |
152 reference_finder_.ManageFrame(std::move(frame)); | 162 reference_finder_.ManageFrame(std::move(frame)); |
153 } | 163 } |
154 | 164 |
155 index = (index + 1) % size_; | 165 index = (index + 1) % size_; |
156 ++seq_num; | 166 ++seq_num; |
157 } | 167 } |
158 } | 168 } |
159 | 169 |
160 void PacketBuffer::ReturnFrame(RtpFrameObject* frame) { | 170 void PacketBuffer::ReturnFrame(RtpFrameObject* frame) { |
161 rtc::CritScope lock(&crit_); | 171 rtc::CritScope lock(&crit_); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 void PacketBuffer::Clear() { | 224 void PacketBuffer::Clear() { |
215 rtc::CritScope lock(&crit_); | 225 rtc::CritScope lock(&crit_); |
216 for (size_t i = 0; i < size_; ++i) | 226 for (size_t i = 0; i < size_; ++i) |
217 sequence_buffer_[i].used = false; | 227 sequence_buffer_[i].used = false; |
218 | 228 |
219 first_packet_received_ = false; | 229 first_packet_received_ = false; |
220 } | 230 } |
221 | 231 |
222 } // namespace video_coding | 232 } // namespace video_coding |
223 } // namespace webrtc | 233 } // namespace webrtc |
OLD | NEW |