OLD | NEW |
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 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 for (PacketIterator it = start; it != packet_after_end; ++it) { | 319 for (PacketIterator it = start; it != packet_after_end; ++it) { |
320 bytes_to_delete += (*it).sizeBytes; | 320 bytes_to_delete += (*it).sizeBytes; |
321 (*it).sizeBytes = 0; | 321 (*it).sizeBytes = 0; |
322 (*it).dataPtr = NULL; | 322 (*it).dataPtr = NULL; |
323 } | 323 } |
324 if (bytes_to_delete > 0) | 324 if (bytes_to_delete > 0) |
325 ShiftSubsequentPackets(end, -static_cast<int>(bytes_to_delete)); | 325 ShiftSubsequentPackets(end, -static_cast<int>(bytes_to_delete)); |
326 return bytes_to_delete; | 326 return bytes_to_delete; |
327 } | 327 } |
328 | 328 |
329 size_t VCMSessionInfo::BuildVP8FragmentationHeader( | |
330 uint8_t* frame_buffer, | |
331 size_t frame_buffer_length, | |
332 RTPFragmentationHeader* fragmentation) { | |
333 size_t new_length = 0; | |
334 // Allocate space for max number of partitions | |
335 fragmentation->VerifyAndAllocateFragmentationHeader(kMaxVP8Partitions); | |
336 fragmentation->fragmentationVectorSize = 0; | |
337 memset(fragmentation->fragmentationLength, 0, | |
338 kMaxVP8Partitions * sizeof(size_t)); | |
339 if (packets_.empty()) | |
340 return new_length; | |
341 PacketIterator it = FindNextPartitionBeginning(packets_.begin()); | |
342 while (it != packets_.end()) { | |
343 const int partition_id = (*it).video_header.codecHeader.VP8.partitionId; | |
344 PacketIterator partition_end = FindPartitionEnd(it); | |
345 fragmentation->fragmentationOffset[partition_id] = | |
346 (*it).dataPtr - frame_buffer; | |
347 assert(fragmentation->fragmentationOffset[partition_id] < | |
348 frame_buffer_length); | |
349 fragmentation->fragmentationLength[partition_id] = | |
350 (*partition_end).dataPtr + (*partition_end).sizeBytes - (*it).dataPtr; | |
351 assert(fragmentation->fragmentationLength[partition_id] <= | |
352 frame_buffer_length); | |
353 new_length += fragmentation->fragmentationLength[partition_id]; | |
354 ++partition_end; | |
355 it = FindNextPartitionBeginning(partition_end); | |
356 if (partition_id + 1 > fragmentation->fragmentationVectorSize) | |
357 fragmentation->fragmentationVectorSize = partition_id + 1; | |
358 } | |
359 // Set all empty fragments to start where the previous fragment ends, | |
360 // and have zero length. | |
361 if (fragmentation->fragmentationLength[0] == 0) | |
362 fragmentation->fragmentationOffset[0] = 0; | |
363 for (int i = 1; i < fragmentation->fragmentationVectorSize; ++i) { | |
364 if (fragmentation->fragmentationLength[i] == 0) | |
365 fragmentation->fragmentationOffset[i] = | |
366 fragmentation->fragmentationOffset[i - 1] + | |
367 fragmentation->fragmentationLength[i - 1]; | |
368 assert(i == 0 || | |
369 fragmentation->fragmentationOffset[i] >= | |
370 fragmentation->fragmentationOffset[i - 1]); | |
371 } | |
372 assert(new_length <= frame_buffer_length); | |
373 return new_length; | |
374 } | |
375 | |
376 VCMSessionInfo::PacketIterator VCMSessionInfo::FindNextPartitionBeginning( | 329 VCMSessionInfo::PacketIterator VCMSessionInfo::FindNextPartitionBeginning( |
377 PacketIterator it) const { | 330 PacketIterator it) const { |
378 while (it != packets_.end()) { | 331 while (it != packets_.end()) { |
379 if ((*it).video_header.codecHeader.VP8.beginningOfPartition) { | 332 if ((*it).video_header.codecHeader.VP8.beginningOfPartition) { |
380 return it; | 333 return it; |
381 } | 334 } |
382 ++it; | 335 ++it; |
383 } | 336 } |
384 return it; | 337 return it; |
385 } | 338 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 if (empty_seq_num_high_ == -1) | 505 if (empty_seq_num_high_ == -1) |
553 empty_seq_num_high_ = seq_num; | 506 empty_seq_num_high_ = seq_num; |
554 else | 507 else |
555 empty_seq_num_high_ = LatestSequenceNumber(seq_num, empty_seq_num_high_); | 508 empty_seq_num_high_ = LatestSequenceNumber(seq_num, empty_seq_num_high_); |
556 if (empty_seq_num_low_ == -1 || | 509 if (empty_seq_num_low_ == -1 || |
557 IsNewerSequenceNumber(empty_seq_num_low_, seq_num)) | 510 IsNewerSequenceNumber(empty_seq_num_low_, seq_num)) |
558 empty_seq_num_low_ = seq_num; | 511 empty_seq_num_low_ = seq_num; |
559 } | 512 } |
560 | 513 |
561 } // namespace webrtc | 514 } // namespace webrtc |
OLD | NEW |