Chromium Code Reviews| 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. | |
|
stefan-webrtc
2017/02/02 15:50:07
Can't we still make sure that the frame begin bit
| |
| 233 // | |
| 234 // Since we ignore the |frame_begin| flag of the inserted packets | |
| 235 // we check that |start_index != static_cast<int>(index)| to make sure | |
| 236 // that we don't get stuck in a loop if the packet buffer is filled | |
| 237 // with packets of the same timestamp.3 | |
|
stefan-webrtc
2017/02/02 15:50:07
Remove 3
| |
| 238 if (is_h264 && start_index != static_cast<int>(index) && | |
| 239 (!sequence_buffer_[start_index].used || | |
| 240 data_buffer_[start_index].timestamp != frame_timestamp)) { | |
| 241 break; | |
| 242 } | |
| 243 | |
| 244 --start_seq_num; | |
| 225 } | 245 } |
| 226 | 246 |
| 227 found_frames.emplace_back( | 247 found_frames.emplace_back( |
| 228 new RtpFrameObject(this, start_seq_num, seq_num, frame_size, | 248 new RtpFrameObject(this, start_seq_num, seq_num, frame_size, |
| 229 max_nack_count, clock_->TimeInMilliseconds())); | 249 max_nack_count, clock_->TimeInMilliseconds())); |
| 230 } | 250 } |
| 231 ++seq_num; | 251 ++seq_num; |
| 232 ++packets_tested; | 252 ++packets_tested; |
| 233 } | 253 } |
| 234 return found_frames; | 254 return found_frames; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 int PacketBuffer::Release() const { | 310 int PacketBuffer::Release() const { |
| 291 int count = rtc::AtomicOps::Decrement(&ref_count_); | 311 int count = rtc::AtomicOps::Decrement(&ref_count_); |
| 292 if (!count) { | 312 if (!count) { |
| 293 delete this; | 313 delete this; |
| 294 } | 314 } |
| 295 return count; | 315 return count; |
| 296 } | 316 } |
| 297 | 317 |
| 298 } // namespace video_coding | 318 } // namespace video_coding |
| 299 } // namespace webrtc | 319 } // namespace webrtc |
| OLD | NEW |