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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // If all packets of the frame is continuous, find the first packet of the | 204 // If all packets of the frame is continuous, find the first packet of the |
205 // frame and create an RtpFrameObject. | 205 // frame and create an RtpFrameObject. |
206 if (sequence_buffer_[index].frame_end) { | 206 if (sequence_buffer_[index].frame_end) { |
207 size_t frame_size = 0; | 207 size_t frame_size = 0; |
208 int max_nack_count = -1; | 208 int max_nack_count = -1; |
209 uint16_t start_seq_num = seq_num; | 209 uint16_t start_seq_num = seq_num; |
210 | 210 |
211 // Find the start index by searching backward until the packet with | 211 // Find the start index by searching backward until the packet with |
212 // the |frame_begin| flag is set. | 212 // the |frame_begin| flag is set. |
213 int start_index = index; | 213 int start_index = index; |
| 214 |
| 215 bool is_h264 = data_buffer_[start_index].codec == kVideoCodecH264; |
| 216 int64_t frame_timestamp = data_buffer_[start_index].timestamp; |
214 while (true) { | 217 while (true) { |
215 frame_size += data_buffer_[start_index].sizeBytes; | 218 frame_size += data_buffer_[start_index].sizeBytes; |
216 max_nack_count = | 219 max_nack_count = |
217 std::max(max_nack_count, data_buffer_[start_index].timesNacked); | 220 std::max(max_nack_count, data_buffer_[start_index].timesNacked); |
218 sequence_buffer_[start_index].frame_created = true; | 221 sequence_buffer_[start_index].frame_created = true; |
219 | 222 |
220 if (sequence_buffer_[start_index].frame_begin) | 223 if (!is_h264 && sequence_buffer_[start_index].frame_begin) |
221 break; | 224 break; |
222 | 225 |
223 start_index = start_index > 0 ? start_index - 1 : size_ - 1; | 226 start_index = start_index > 0 ? start_index - 1 : size_ - 1; |
224 start_seq_num--; | 227 |
| 228 // In the case of H264 we don't have a frame_begin bit (yes, |
| 229 // |frame_begin| might be set to true but that is a lie). So instead |
| 230 // we traverese backwards as long as we have a previous packet and |
| 231 // the timestamp of that packet is the same as this one. This may cause |
| 232 // the PacketBuffer to hand out incomplete frames. |
| 233 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=7106 |
| 234 // |
| 235 // Since we ignore the |frame_begin| flag of the inserted packets |
| 236 // we check that |start_index != static_cast<int>(index)| to make sure |
| 237 // that we don't get stuck in a loop if the packet buffer is filled |
| 238 // with packets of the same timestamp. |
| 239 if (is_h264 && start_index != static_cast<int>(index) && |
| 240 (!sequence_buffer_[start_index].used || |
| 241 data_buffer_[start_index].timestamp != frame_timestamp)) { |
| 242 break; |
| 243 } |
| 244 |
| 245 --start_seq_num; |
225 } | 246 } |
226 | 247 |
227 found_frames.emplace_back( | 248 found_frames.emplace_back( |
228 new RtpFrameObject(this, start_seq_num, seq_num, frame_size, | 249 new RtpFrameObject(this, start_seq_num, seq_num, frame_size, |
229 max_nack_count, clock_->TimeInMilliseconds())); | 250 max_nack_count, clock_->TimeInMilliseconds())); |
230 } | 251 } |
231 ++seq_num; | 252 ++seq_num; |
232 ++packets_tested; | 253 ++packets_tested; |
233 } | 254 } |
234 return found_frames; | 255 return found_frames; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 int PacketBuffer::Release() const { | 311 int PacketBuffer::Release() const { |
291 int count = rtc::AtomicOps::Decrement(&ref_count_); | 312 int count = rtc::AtomicOps::Decrement(&ref_count_); |
292 if (!count) { | 313 if (!count) { |
293 delete this; | 314 delete this; |
294 } | 315 } |
295 return count; | 316 return count; |
296 } | 317 } |
297 | 318 |
298 } // namespace video_coding | 319 } // namespace video_coding |
299 } // namespace webrtc | 320 } // namespace webrtc |
OLD | NEW |