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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/forward_error_correction.cc

Issue 2101253002: Unit test for media packet reordering in ForwardErrorCorrection. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@flexfec-pt1c_renames-and-fixes
Patch Set: Rebase. Created 4 years, 4 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
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 for (uint16_t byte_idx = 0; byte_idx < mask_size_bytes; ++byte_idx) { 516 for (uint16_t byte_idx = 0; byte_idx < mask_size_bytes; ++byte_idx) {
517 uint8_t packet_mask = fec_packet->pkt->data[12 + byte_idx]; 517 uint8_t packet_mask = fec_packet->pkt->data[12 + byte_idx];
518 for (uint16_t bit_idx = 0; bit_idx < 8; ++bit_idx) { 518 for (uint16_t bit_idx = 0; bit_idx < 8; ++bit_idx) {
519 if (packet_mask & (1 << (7 - bit_idx))) { 519 if (packet_mask & (1 << (7 - bit_idx))) {
520 std::unique_ptr<ProtectedPacket> protected_packet( 520 std::unique_ptr<ProtectedPacket> protected_packet(
521 new ProtectedPacket()); 521 new ProtectedPacket());
522 // This wraps naturally with the sequence number. 522 // This wraps naturally with the sequence number.
523 protected_packet->seq_num = 523 protected_packet->seq_num =
524 static_cast<uint16_t>(seq_num_base + (byte_idx << 3) + bit_idx); 524 static_cast<uint16_t>(seq_num_base + (byte_idx << 3) + bit_idx);
525 protected_packet->pkt = nullptr; 525 protected_packet->pkt = nullptr;
526 // Note that |protected_pkt_list| is sorted (according to sequence
527 // number) by construction.
526 fec_packet->protected_packets.push_back(std::move(protected_packet)); 528 fec_packet->protected_packets.push_back(std::move(protected_packet));
527 } 529 }
528 } 530 }
529 } 531 }
530 if (fec_packet->protected_packets.empty()) { 532 if (fec_packet->protected_packets.empty()) {
531 // All-zero packet mask; we can discard this FEC packet. 533 // All-zero packet mask; we can discard this FEC packet.
532 LOG(LS_WARNING) << "Received FEC packet has an all-zero packet mask."; 534 LOG(LS_WARNING) << "Received FEC packet has an all-zero packet mask.";
533 } else { 535 } else {
534 AssignRecoveredPackets(fec_packet.get(), recovered_packets); 536 AssignRecoveredPackets(fec_packet.get(), recovered_packets);
535 // TODO(holmer): Consider replacing this with a binary search for the right 537 // TODO(holmer): Consider replacing this with a binary search for the right
536 // position, and then just insert the new packet. Would get rid of the sort. 538 // position, and then just insert the new packet. Would get rid of the sort.
539 //
540 // For correct decoding, |fec_packet_list_| does not necessarily
541 // need to be sorted by sequence number (see decoding algorithm in
542 // AttemptRecover()), but by keeping it sorted we try to recover the
543 // oldest lost packets first.
537 received_fec_packets_.push_back(std::move(fec_packet)); 544 received_fec_packets_.push_back(std::move(fec_packet));
538 received_fec_packets_.sort(SortablePacket::LessThan()); 545 received_fec_packets_.sort(SortablePacket::LessThan());
539 if (received_fec_packets_.size() > kMaxFecPackets) { 546 if (received_fec_packets_.size() > kMaxFecPackets) {
540 received_fec_packets_.pop_front(); 547 received_fec_packets_.pop_front();
541 } 548 }
542 RTC_DCHECK_LE(received_fec_packets_.size(), kMaxFecPackets); 549 RTC_DCHECK_LE(received_fec_packets_.size(), kMaxFecPackets);
543 } 550 }
544 } 551 }
545 552
546 void ForwardErrorCorrection::AssignRecoveredPackets( 553 void ForwardErrorCorrection::AssignRecoveredPackets(
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 } 803 }
797 InsertPackets(received_packets, recovered_packets); 804 InsertPackets(received_packets, recovered_packets);
798 AttemptRecover(recovered_packets); 805 AttemptRecover(recovered_packets);
799 return 0; 806 return 0;
800 } 807 }
801 808
802 size_t ForwardErrorCorrection::PacketOverhead() { 809 size_t ForwardErrorCorrection::PacketOverhead() {
803 return kFecHeaderSize + kUlpHeaderSizeLBitSet; 810 return kFecHeaderSize + kUlpHeaderSizeLBitSet;
804 } 811 }
805 } // namespace webrtc 812 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698