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 |
11 #include <list> | 11 #include <list> |
12 #include <vector> | |
12 | 13 |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | |
14 #include "webrtc/modules/rtp_rtcp/source/fec_test_helper.h" | 16 #include "webrtc/modules/rtp_rtcp/source/fec_test_helper.h" |
15 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h" | 17 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h" |
16 #include "webrtc/modules/rtp_rtcp/source/producer_fec.h" | 18 #include "webrtc/modules/rtp_rtcp/source/producer_fec.h" |
17 | 19 |
18 namespace webrtc { | 20 namespace webrtc { |
19 | 21 |
20 void VerifyHeader(uint16_t seq_num, | 22 void VerifyHeader(uint16_t seq_num, |
21 uint32_t timestamp, | 23 uint32_t timestamp, |
22 int red_pltype, | 24 int red_pltype, |
23 int fec_pltype, | 25 int fec_pltype, |
(...skipping 23 matching lines...) Expand all Loading... | |
47 virtual void TearDown() { | 49 virtual void TearDown() { |
48 delete producer_; | 50 delete producer_; |
49 delete fec_; | 51 delete fec_; |
50 delete generator_; | 52 delete generator_; |
51 } | 53 } |
52 ForwardErrorCorrection* fec_; | 54 ForwardErrorCorrection* fec_; |
53 ProducerFec* producer_; | 55 ProducerFec* producer_; |
54 FrameGenerator* generator_; | 56 FrameGenerator* generator_; |
55 }; | 57 }; |
56 | 58 |
59 TEST_F(ProducerFecTest, NoEmptyFecWithSeqNumGaps) { | |
60 struct Packet { | |
61 size_t header_size; | |
62 size_t payload_size; | |
63 uint16_t seq_num; | |
64 bool marker_bit; | |
65 }; | |
66 std::vector<Packet> protected_packets; | |
67 protected_packets.push_back({15, 3, 41, 0}); | |
pbos-webrtc
2015/12/11 14:42:04
Can this list be minimized? :)
stefan-webrtc
2015/12/11 14:50:56
Somewhat.
| |
68 protected_packets.push_back({14, 1, 43, 0}); | |
69 protected_packets.push_back({19, 0, 48, 0}); | |
70 protected_packets.push_back({19, 0, 50, 0}); | |
71 protected_packets.push_back({14, 3, 51, 0}); | |
72 protected_packets.push_back({13, 8, 52, 0}); | |
73 protected_packets.push_back({19, 2, 53, 0}); | |
74 protected_packets.push_back({12, 3, 54, 0}); | |
75 protected_packets.push_back({21, 0, 55, 0}); | |
76 protected_packets.push_back({13, 3, 57, 0}); | |
77 protected_packets.push_back({13, 3, 58, 0}); | |
78 protected_packets.push_back({15, 9, 59, 0}); | |
79 protected_packets.push_back({12, 3, 60, 1}); | |
80 FecProtectionParams params = {117, 0, 3, kFecMaskBursty}; | |
81 producer_->SetFecParameters(¶ms, 0); | |
82 uint8_t packet[28] = {0}; | |
83 for (Packet p : protected_packets) { | |
84 if (p.marker_bit) { | |
85 packet[1] |= 0x80; | |
86 } else { | |
87 packet[1] &= ~0x80; | |
88 } | |
89 ByteWriter<uint16_t>::WriteBigEndian(&packet[2], p.seq_num); | |
90 producer_->AddRtpPacketAndGenerateFec(packet, p.payload_size, | |
91 p.header_size); | |
92 uint16_t num_fec_packets = producer_->NumAvailableFecPackets(); | |
93 std::vector<RedPacket*> fec_packets; | |
94 if (num_fec_packets > 0) { | |
95 fec_packets = | |
96 producer_->GetFecPackets(kRedPayloadType, 99, 100, p.header_size); | |
97 EXPECT_EQ(num_fec_packets, fec_packets.size()); | |
98 } | |
99 for (RedPacket* fec_packet : fec_packets) { | |
100 delete fec_packet; | |
101 } | |
102 } | |
103 } | |
104 | |
57 TEST_F(ProducerFecTest, OneFrameFec) { | 105 TEST_F(ProducerFecTest, OneFrameFec) { |
58 // The number of media packets (|kNumPackets|), number of frames (one for | 106 // The number of media packets (|kNumPackets|), number of frames (one for |
59 // this test), and the protection factor (|params->fec_rate|) are set to make | 107 // this test), and the protection factor (|params->fec_rate|) are set to make |
60 // sure the conditions for generating FEC are satisfied. This means: | 108 // sure the conditions for generating FEC are satisfied. This means: |
61 // (1) protection factor is high enough so that actual overhead over 1 frame | 109 // (1) protection factor is high enough so that actual overhead over 1 frame |
62 // of packets is within |kMaxExcessOverhead|, and (2) the total number of | 110 // of packets is within |kMaxExcessOverhead|, and (2) the total number of |
63 // media packets for 1 frame is at least |minimum_media_packets_fec_|. | 111 // media packets for 1 frame is at least |minimum_media_packets_fec_|. |
64 const int kNumPackets = 4; | 112 const int kNumPackets = 4; |
65 FecProtectionParams params = {15, false, 3}; | 113 FecProtectionParams params = {15, false, 3}; |
66 std::list<RtpPacket*> rtp_packets; | 114 std::list<RtpPacket*> rtp_packets; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 kRedPayloadType, | 195 kRedPayloadType, |
148 packet->header.header.payloadType, | 196 packet->header.header.payloadType, |
149 red_packet.get(), | 197 red_packet.get(), |
150 true); // Marker bit set. | 198 true); // Marker bit set. |
151 for (int i = 0; i < 10; ++i) | 199 for (int i = 0; i < 10; ++i) |
152 EXPECT_EQ(i, red_packet->data()[kRtpHeaderSize + 1 + i]); | 200 EXPECT_EQ(i, red_packet->data()[kRtpHeaderSize + 1 + i]); |
153 delete packet; | 201 delete packet; |
154 } | 202 } |
155 | 203 |
156 } // namespace webrtc | 204 } // namespace webrtc |
OLD | NEW |