| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 protected_packets.push_back({15, 3, 41, 0}); | 71 protected_packets.push_back({15, 3, 41, 0}); |
| 72 protected_packets.push_back({14, 1, 43, 0}); | 72 protected_packets.push_back({14, 1, 43, 0}); |
| 73 protected_packets.push_back({19, 0, 48, 0}); | 73 protected_packets.push_back({19, 0, 48, 0}); |
| 74 protected_packets.push_back({19, 0, 50, 0}); | 74 protected_packets.push_back({19, 0, 50, 0}); |
| 75 protected_packets.push_back({14, 3, 51, 0}); | 75 protected_packets.push_back({14, 3, 51, 0}); |
| 76 protected_packets.push_back({13, 8, 52, 0}); | 76 protected_packets.push_back({13, 8, 52, 0}); |
| 77 protected_packets.push_back({19, 2, 53, 0}); | 77 protected_packets.push_back({19, 2, 53, 0}); |
| 78 protected_packets.push_back({12, 3, 54, 0}); | 78 protected_packets.push_back({12, 3, 54, 0}); |
| 79 protected_packets.push_back({21, 0, 55, 0}); | 79 protected_packets.push_back({21, 0, 55, 0}); |
| 80 protected_packets.push_back({13, 3, 57, 1}); | 80 protected_packets.push_back({13, 3, 57, 1}); |
| 81 FecProtectionParams params = {117, 3, kFecMaskBursty}; | 81 FecProtectionParams params = {117, 0, 3, kFecMaskBursty}; |
| 82 producer_->SetFecParameters(¶ms, 0); | 82 producer_->SetFecParameters(¶ms, 0); |
| 83 uint8_t packet[28] = {0}; | 83 uint8_t packet[28] = {0}; |
| 84 for (Packet p : protected_packets) { | 84 for (Packet p : protected_packets) { |
| 85 if (p.marker_bit) { | 85 if (p.marker_bit) { |
| 86 packet[1] |= 0x80; | 86 packet[1] |= 0x80; |
| 87 } else { | 87 } else { |
| 88 packet[1] &= ~0x80; | 88 packet[1] &= ~0x80; |
| 89 } | 89 } |
| 90 ByteWriter<uint16_t>::WriteBigEndian(&packet[2], p.seq_num); | 90 ByteWriter<uint16_t>::WriteBigEndian(&packet[2], p.seq_num); |
| 91 producer_->AddRtpPacketAndGenerateFec(packet, p.payload_size, | 91 producer_->AddRtpPacketAndGenerateFec(packet, p.payload_size, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 104 } | 104 } |
| 105 | 105 |
| 106 TEST_F(ProducerFecTest, OneFrameFec) { | 106 TEST_F(ProducerFecTest, OneFrameFec) { |
| 107 // The number of media packets (|kNumPackets|), number of frames (one for | 107 // The number of media packets (|kNumPackets|), number of frames (one for |
| 108 // this test), and the protection factor (|params->fec_rate|) are set to make | 108 // this test), and the protection factor (|params->fec_rate|) are set to make |
| 109 // sure the conditions for generating FEC are satisfied. This means: | 109 // sure the conditions for generating FEC are satisfied. This means: |
| 110 // (1) protection factor is high enough so that actual overhead over 1 frame | 110 // (1) protection factor is high enough so that actual overhead over 1 frame |
| 111 // of packets is within |kMaxExcessOverhead|, and (2) the total number of | 111 // of packets is within |kMaxExcessOverhead|, and (2) the total number of |
| 112 // media packets for 1 frame is at least |minimum_media_packets_fec_|. | 112 // media packets for 1 frame is at least |minimum_media_packets_fec_|. |
| 113 const int kNumPackets = 4; | 113 const int kNumPackets = 4; |
| 114 FecProtectionParams params = {15, 3, kFecMaskRandom}; | 114 FecProtectionParams params = {15, false, 3}; |
| 115 std::list<test::RawRtpPacket*> rtp_packets; | 115 std::list<test::RawRtpPacket*> rtp_packets; |
| 116 generator_->NewFrame(kNumPackets); | 116 generator_->NewFrame(kNumPackets); |
| 117 producer_->SetFecParameters(¶ms, 0); // Expecting one FEC packet. | 117 producer_->SetFecParameters(¶ms, 0); // Expecting one FEC packet. |
| 118 uint32_t last_timestamp = 0; | 118 uint32_t last_timestamp = 0; |
| 119 for (int i = 0; i < kNumPackets; ++i) { | 119 for (int i = 0; i < kNumPackets; ++i) { |
| 120 test::RawRtpPacket* rtp_packet = generator_->NextPacket(i, 10); | 120 test::RawRtpPacket* rtp_packet = generator_->NextPacket(i, 10); |
| 121 rtp_packets.push_back(rtp_packet); | 121 rtp_packets.push_back(rtp_packet); |
| 122 EXPECT_EQ(0, producer_->AddRtpPacketAndGenerateFec(rtp_packet->data, | 122 EXPECT_EQ(0, producer_->AddRtpPacketAndGenerateFec(rtp_packet->data, |
| 123 rtp_packet->length, | 123 rtp_packet->length, |
| 124 kRtpHeaderSize)); | 124 kRtpHeaderSize)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 145 // The number of media packets/frame (|kNumPackets|), the number of frames | 145 // The number of media packets/frame (|kNumPackets|), the number of frames |
| 146 // (|kNumFrames|), and the protection factor (|params->fec_rate|) are set to | 146 // (|kNumFrames|), and the protection factor (|params->fec_rate|) are set to |
| 147 // make sure the conditions for generating FEC are satisfied. This means: | 147 // make sure the conditions for generating FEC are satisfied. This means: |
| 148 // (1) protection factor is high enough so that actual overhead over | 148 // (1) protection factor is high enough so that actual overhead over |
| 149 // |kNumFrames| is within |kMaxExcessOverhead|, and (2) the total number of | 149 // |kNumFrames| is within |kMaxExcessOverhead|, and (2) the total number of |
| 150 // media packets for |kNumFrames| frames is at least | 150 // media packets for |kNumFrames| frames is at least |
| 151 // |minimum_media_packets_fec_|. | 151 // |minimum_media_packets_fec_|. |
| 152 const int kNumPackets = 2; | 152 const int kNumPackets = 2; |
| 153 const int kNumFrames = 2; | 153 const int kNumFrames = 2; |
| 154 | 154 |
| 155 FecProtectionParams params = {15, 3, kFecMaskRandom}; | 155 FecProtectionParams params = {15, 0, 3}; |
| 156 std::list<test::RawRtpPacket*> rtp_packets; | 156 std::list<test::RawRtpPacket*> rtp_packets; |
| 157 producer_->SetFecParameters(¶ms, 0); // Expecting one FEC packet. | 157 producer_->SetFecParameters(¶ms, 0); // Expecting one FEC packet. |
| 158 uint32_t last_timestamp = 0; | 158 uint32_t last_timestamp = 0; |
| 159 for (int i = 0; i < kNumFrames; ++i) { | 159 for (int i = 0; i < kNumFrames; ++i) { |
| 160 generator_->NewFrame(kNumPackets); | 160 generator_->NewFrame(kNumPackets); |
| 161 for (int j = 0; j < kNumPackets; ++j) { | 161 for (int j = 0; j < kNumPackets; ++j) { |
| 162 test::RawRtpPacket* rtp_packet = | 162 test::RawRtpPacket* rtp_packet = |
| 163 generator_->NextPacket(i * kNumPackets + j, 10); | 163 generator_->NextPacket(i * kNumPackets + j, 10); |
| 164 rtp_packets.push_back(rtp_packet); | 164 rtp_packets.push_back(rtp_packet); |
| 165 EXPECT_EQ(0, producer_->AddRtpPacketAndGenerateFec(rtp_packet->data, | 165 EXPECT_EQ(0, producer_->AddRtpPacketAndGenerateFec(rtp_packet->data, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 kRedPayloadType, | 197 kRedPayloadType, |
| 198 packet->header.header.payloadType, | 198 packet->header.header.payloadType, |
| 199 red_packet.get(), | 199 red_packet.get(), |
| 200 true); // Marker bit set. | 200 true); // Marker bit set. |
| 201 for (int i = 0; i < 10; ++i) | 201 for (int i = 0; i < 10; ++i) |
| 202 EXPECT_EQ(i, red_packet->data()[kRtpHeaderSize + 1 + i]); | 202 EXPECT_EQ(i, red_packet->data()[kRtpHeaderSize + 1 + i]); |
| 203 delete packet; | 203 delete packet; |
| 204 } | 204 } |
| 205 | 205 |
| 206 } // namespace webrtc | 206 } // namespace webrtc |
| OLD | NEW |