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

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

Issue 3006993002: Delete Rtx-related methods from RTPPayloadRegistry. (Closed)
Patch Set: Update RtpRtcpRtxNackTest. Created 3 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 <algorithm> 11 #include <algorithm>
12 #include <iterator> 12 #include <iterator>
13 #include <list> 13 #include <list>
14 #include <memory> 14 #include <memory>
15 #include <set> 15 #include <set>
16 16
17 #include "webrtc/api/call/transport.h" 17 #include "webrtc/api/call/transport.h"
18 #include "webrtc/call/rtp_stream_receiver_controller.h"
19 #include "webrtc/call/rtx_receive_stream.h"
18 #include "webrtc/common_types.h" 20 #include "webrtc/common_types.h"
19 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" 21 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
20 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
21 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
22 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
24 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
24 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h"
25 #include "webrtc/rtc_base/rate_limiter.h" 25 #include "webrtc/rtc_base/rate_limiter.h"
26 #include "webrtc/test/gtest.h" 26 #include "webrtc/test/gtest.h"
27 27
28 namespace webrtc { 28 namespace webrtc {
29 29
30 const int kVideoNackListSize = 30; 30 const int kVideoNackListSize = 30;
31 const uint32_t kTestSsrc = 3456; 31 const uint32_t kTestSsrc = 3456;
32 const uint32_t kTestRtxSsrc = kTestSsrc + 1;
32 const uint16_t kTestSequenceNumber = 2345; 33 const uint16_t kTestSequenceNumber = 2345;
33 const uint32_t kTestNumberOfPackets = 1350; 34 const uint32_t kTestNumberOfPackets = 1350;
34 const int kTestNumberOfRtxPackets = 149; 35 const int kTestNumberOfRtxPackets = 149;
35 const int kNumFrames = 30; 36 const int kNumFrames = 30;
36 const int kPayloadType = 123; 37 const int kPayloadType = 123;
37 const int kRtxPayloadType = 98; 38 const int kRtxPayloadType = 98;
38 const int64_t kMaxRttMs = 1000; 39 const int64_t kMaxRttMs = 1000;
39 40
40 class VerifyingRtxReceiver : public RtpData { 41 class VerifyingMediaStream : public RtpPacketSinkInterface {
41 public: 42 public:
42 VerifyingRtxReceiver() {} 43 VerifyingMediaStream() {}
43 44
44 int32_t OnReceivedPayloadData( 45 void OnRtpPacket(const RtpPacketReceived& packet) override {
45 const uint8_t* data,
46 size_t size,
47 const webrtc::WebRtcRTPHeader* rtp_header) override {
48 if (!sequence_numbers_.empty()) 46 if (!sequence_numbers_.empty())
49 EXPECT_EQ(kTestSsrc, rtp_header->header.ssrc); 47 EXPECT_EQ(kTestSsrc, packet.Ssrc());
50 sequence_numbers_.push_back(rtp_header->header.sequenceNumber); 48
51 return 0; 49 sequence_numbers_.push_back(packet.SequenceNumber());
52 } 50 }
53 std::list<uint16_t> sequence_numbers_; 51 std::list<uint16_t> sequence_numbers_;
54 }; 52 };
55 53
56 class TestRtpFeedback : public NullRtpFeedback {
57 public:
58 explicit TestRtpFeedback(RtpRtcp* rtp_rtcp) : rtp_rtcp_(rtp_rtcp) {}
59 virtual ~TestRtpFeedback() {}
60
61 void OnIncomingSSRCChanged(uint32_t ssrc) override {
62 rtp_rtcp_->SetRemoteSSRC(ssrc);
63 }
64
65 private:
66 RtpRtcp* rtp_rtcp_;
67 };
68
69 class RtxLoopBackTransport : public webrtc::Transport { 54 class RtxLoopBackTransport : public webrtc::Transport {
70 public: 55 public:
71 explicit RtxLoopBackTransport(uint32_t rtx_ssrc) 56 explicit RtxLoopBackTransport(uint32_t rtx_ssrc)
72 : count_(0), 57 : count_(0),
73 packet_loss_(0), 58 packet_loss_(0),
74 consecutive_drop_start_(0), 59 consecutive_drop_start_(0),
75 consecutive_drop_end_(0), 60 consecutive_drop_end_(0),
76 rtx_ssrc_(rtx_ssrc), 61 rtx_ssrc_(rtx_ssrc),
77 count_rtx_ssrc_(0), 62 count_rtx_ssrc_(0),
78 rtp_payload_registry_(NULL),
79 rtp_receiver_(NULL),
80 module_(NULL) {} 63 module_(NULL) {}
81 64
82 void SetSendModule(RtpRtcp* rtpRtcpModule, 65 void SetSendModule(RtpRtcp* rtpRtcpModule) {
83 RTPPayloadRegistry* rtp_payload_registry,
84 RtpReceiver* receiver) {
85 module_ = rtpRtcpModule; 66 module_ = rtpRtcpModule;
86 rtp_payload_registry_ = rtp_payload_registry;
87 rtp_receiver_ = receiver;
88 } 67 }
89 68
90 void DropEveryNthPacket(int n) { packet_loss_ = n; } 69 void DropEveryNthPacket(int n) { packet_loss_ = n; }
91 70
92 void DropConsecutivePackets(int start, int total) { 71 void DropConsecutivePackets(int start, int total) {
93 consecutive_drop_start_ = start; 72 consecutive_drop_start_ = start;
94 consecutive_drop_end_ = start + total; 73 consecutive_drop_end_ = start + total;
95 packet_loss_ = 0; 74 packet_loss_ = 0;
96 } 75 }
97 76
98 bool SendRtp(const uint8_t* data, 77 bool SendRtp(const uint8_t* data,
99 size_t len, 78 size_t len,
100 const PacketOptions& options) override { 79 const PacketOptions& options) override {
101 count_++; 80 count_++;
102 const unsigned char* ptr = static_cast<const unsigned char*>(data); 81 RtpPacketReceived packet;
103 uint32_t ssrc = (ptr[8] << 24) + (ptr[9] << 16) + (ptr[10] << 8) + ptr[11]; 82 if (!packet.Parse(data, len))
104 if (ssrc == rtx_ssrc_) 83 return false;
84 if (packet.Ssrc() == rtx_ssrc_) {
105 count_rtx_ssrc_++; 85 count_rtx_ssrc_++;
106 uint16_t sequence_number = (ptr[2] << 8) + ptr[3]; 86 } else {
107 size_t packet_length = len; 87 // For non-RTX packets only.
108 uint8_t restored_packet[1500];
109 RTPHeader header;
110 std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
111 if (!parser->Parse(ptr, len, &header)) {
112 return false;
113 }
114
115 if (!rtp_payload_registry_->IsRtx(header)) {
116 // Don't store retransmitted packets since we compare it to the list
117 // created by the receiver.
118 expected_sequence_numbers_.insert(expected_sequence_numbers_.end(), 88 expected_sequence_numbers_.insert(expected_sequence_numbers_.end(),
119 sequence_number); 89 packet.SequenceNumber());
120 } 90 }
121 if (packet_loss_ > 0) { 91 if (packet_loss_ > 0) {
122 if ((count_ % packet_loss_) == 0) { 92 if ((count_ % packet_loss_) == 0) {
123 return true; 93 return true;
124 } 94 }
125 } else if (count_ >= consecutive_drop_start_ && 95 } else if (count_ >= consecutive_drop_start_ &&
126 count_ < consecutive_drop_end_) { 96 count_ < consecutive_drop_end_) {
127 return true; 97 return true;
128 } 98 }
129 if (rtp_payload_registry_->IsRtx(header)) { 99 EXPECT_TRUE(stream_receiver_controller_.OnRtpPacket(packet));
130 // Remove the RTX header and parse the original RTP header.
131 EXPECT_TRUE(rtp_payload_registry_->RestoreOriginalPacket(
132 restored_packet, ptr, &packet_length, rtp_receiver_->SSRC(), header));
133 if (!parser->Parse(restored_packet, packet_length, &header)) {
134 return false;
135 }
136 ptr = restored_packet;
137 } else {
138 rtp_payload_registry_->SetIncomingPayloadType(header);
139 }
140
141 PayloadUnion payload_specific;
142 if (!rtp_payload_registry_->GetPayloadSpecifics(header.payloadType,
143 &payload_specific)) {
144 return false;
145 }
146 if (!rtp_receiver_->IncomingRtpPacket(header, ptr + header.headerLength,
147 packet_length - header.headerLength,
148 payload_specific, true)) {
149 return false;
150 }
151 return true; 100 return true;
152 } 101 }
153 102
154 bool SendRtcp(const uint8_t* data, size_t len) override { 103 bool SendRtcp(const uint8_t* data, size_t len) override {
155 return module_->IncomingRtcpPacket((const uint8_t*)data, len) == 0; 104 return module_->IncomingRtcpPacket((const uint8_t*)data, len) == 0;
156 } 105 }
157 int count_; 106 int count_;
158 int packet_loss_; 107 int packet_loss_;
159 int consecutive_drop_start_; 108 int consecutive_drop_start_;
160 int consecutive_drop_end_; 109 int consecutive_drop_end_;
161 uint32_t rtx_ssrc_; 110 uint32_t rtx_ssrc_;
162 int count_rtx_ssrc_; 111 int count_rtx_ssrc_;
163 RTPPayloadRegistry* rtp_payload_registry_;
164 RtpReceiver* rtp_receiver_;
165 RtpRtcp* module_; 112 RtpRtcp* module_;
113 RtpStreamReceiverController stream_receiver_controller_;
166 std::set<uint16_t> expected_sequence_numbers_; 114 std::set<uint16_t> expected_sequence_numbers_;
167 }; 115 };
168 116
169 class RtpRtcpRtxNackTest : public ::testing::Test { 117 class RtpRtcpRtxNackTest : public ::testing::Test {
170 protected: 118 protected:
171 RtpRtcpRtxNackTest() 119 RtpRtcpRtxNackTest()
172 : rtp_rtcp_module_(nullptr), 120 : rtp_rtcp_module_(nullptr),
173 transport_(kTestSsrc + 1), 121 transport_(kTestRtxSsrc),
174 receiver_(), 122 rtx_stream_(&media_stream_,
123 rtx_associated_payload_types_,
124 kTestSsrc),
175 payload_data_length(sizeof(payload_data)), 125 payload_data_length(sizeof(payload_data)),
176 fake_clock(123456), 126 fake_clock(123456),
177 retransmission_rate_limiter_(&fake_clock, kMaxRttMs) {} 127 retransmission_rate_limiter_(&fake_clock, kMaxRttMs) {}
178 ~RtpRtcpRtxNackTest() {} 128 ~RtpRtcpRtxNackTest() {}
179 129
180 void SetUp() override { 130 void SetUp() override {
181 RtpRtcp::Configuration configuration; 131 RtpRtcp::Configuration configuration;
182 configuration.audio = false; 132 configuration.audio = false;
183 configuration.clock = &fake_clock; 133 configuration.clock = &fake_clock;
184 receive_statistics_.reset(ReceiveStatistics::Create(&fake_clock)); 134 receive_statistics_.reset(ReceiveStatistics::Create(&fake_clock));
185 configuration.receive_statistics = receive_statistics_.get(); 135 configuration.receive_statistics = receive_statistics_.get();
186 configuration.outgoing_transport = &transport_; 136 configuration.outgoing_transport = &transport_;
187 configuration.retransmission_rate_limiter = &retransmission_rate_limiter_; 137 configuration.retransmission_rate_limiter = &retransmission_rate_limiter_;
188 rtp_rtcp_module_ = RtpRtcp::CreateRtpRtcp(configuration); 138 rtp_rtcp_module_ = RtpRtcp::CreateRtpRtcp(configuration);
189 139
190 rtp_feedback_.reset(new TestRtpFeedback(rtp_rtcp_module_));
191
192 rtp_receiver_.reset(RtpReceiver::CreateVideoReceiver(
193 &fake_clock, &receiver_, rtp_feedback_.get(), &rtp_payload_registry_));
194
195 rtp_rtcp_module_->SetSSRC(kTestSsrc); 140 rtp_rtcp_module_->SetSSRC(kTestSsrc);
196 rtp_rtcp_module_->SetRTCPStatus(RtcpMode::kCompound); 141 rtp_rtcp_module_->SetRTCPStatus(RtcpMode::kCompound);
197 rtp_rtcp_module_->SetStorePacketsStatus(true, 600); 142 rtp_rtcp_module_->SetStorePacketsStatus(true, 600);
198 EXPECT_EQ(0, rtp_rtcp_module_->SetSendingStatus(true)); 143 EXPECT_EQ(0, rtp_rtcp_module_->SetSendingStatus(true));
199 rtp_rtcp_module_->SetSequenceNumber(kTestSequenceNumber); 144 rtp_rtcp_module_->SetSequenceNumber(kTestSequenceNumber);
200 rtp_rtcp_module_->SetStartTimestamp(111111); 145 rtp_rtcp_module_->SetStartTimestamp(111111);
201 146
202 transport_.SetSendModule(rtp_rtcp_module_, &rtp_payload_registry_, 147 // Used for NACK processing.
203 rtp_receiver_.get()); 148 // TODO(nisse): Unclear on which side? It's confusing to use a
149 // single rtp_rtcp module for both send and receive side.
150 rtp_rtcp_module_->SetRemoteSSRC(kTestSsrc);
204 151
205 VideoCodec video_codec; 152 rtp_rtcp_module_->RegisterVideoSendPayload(kPayloadType, "video");
206 memset(&video_codec, 0, sizeof(video_codec));
207 video_codec.plType = kPayloadType;
208 memcpy(video_codec.plName, "I420", 5);
209
210 EXPECT_EQ(0, rtp_rtcp_module_->RegisterSendPayload(video_codec));
211 rtp_rtcp_module_->SetRtxSendPayloadType(kRtxPayloadType, kPayloadType); 153 rtp_rtcp_module_->SetRtxSendPayloadType(kRtxPayloadType, kPayloadType);
212 EXPECT_EQ(0, rtp_payload_registry_.RegisterReceivePayload(video_codec)); 154 transport_.SetSendModule(rtp_rtcp_module_);
213 rtp_payload_registry_.SetRtxPayloadType(kRtxPayloadType, kPayloadType); 155 media_receiver_ = transport_.stream_receiver_controller_.CreateReceiver(
156 kTestSsrc, &media_stream_);
214 157
215 for (size_t n = 0; n < payload_data_length; n++) { 158 for (size_t n = 0; n < payload_data_length; n++) {
216 payload_data[n] = n % 10; 159 payload_data[n] = n % 10;
217 } 160 }
218 } 161 }
219 162
220 int BuildNackList(uint16_t* nack_list) { 163 int BuildNackList(uint16_t* nack_list) {
221 receiver_.sequence_numbers_.sort(); 164 media_stream_.sequence_numbers_.sort();
222 std::list<uint16_t> missing_sequence_numbers; 165 std::list<uint16_t> missing_sequence_numbers;
223 std::list<uint16_t>::iterator it = receiver_.sequence_numbers_.begin(); 166 std::list<uint16_t>::iterator it = media_stream_.sequence_numbers_.begin();
224 167
225 while (it != receiver_.sequence_numbers_.end()) { 168 while (it != media_stream_.sequence_numbers_.end()) {
226 uint16_t sequence_number_1 = *it; 169 uint16_t sequence_number_1 = *it;
227 ++it; 170 ++it;
228 if (it != receiver_.sequence_numbers_.end()) { 171 if (it != media_stream_.sequence_numbers_.end()) {
229 uint16_t sequence_number_2 = *it; 172 uint16_t sequence_number_2 = *it;
230 // Add all missing sequence numbers to list 173 // Add all missing sequence numbers to list
231 for (uint16_t i = sequence_number_1 + 1; i < sequence_number_2; ++i) { 174 for (uint16_t i = sequence_number_1 + 1; i < sequence_number_2; ++i) {
232 missing_sequence_numbers.push_back(i); 175 missing_sequence_numbers.push_back(i);
233 } 176 }
234 } 177 }
235 } 178 }
236 int n = 0; 179 int n = 0;
237 for (it = missing_sequence_numbers.begin(); 180 for (it = missing_sequence_numbers.begin();
238 it != missing_sequence_numbers.end(); ++it) { 181 it != missing_sequence_numbers.end(); ++it) {
239 nack_list[n++] = (*it); 182 nack_list[n++] = (*it);
240 } 183 }
241 return n; 184 return n;
242 } 185 }
243 186
244 bool ExpectedPacketsReceived() { 187 bool ExpectedPacketsReceived() {
245 std::list<uint16_t> received_sorted; 188 std::list<uint16_t> received_sorted;
246 std::copy(receiver_.sequence_numbers_.begin(), 189 std::copy(media_stream_.sequence_numbers_.begin(),
247 receiver_.sequence_numbers_.end(), 190 media_stream_.sequence_numbers_.end(),
248 std::back_inserter(received_sorted)); 191 std::back_inserter(received_sorted));
249 received_sorted.sort(); 192 received_sorted.sort();
250 return received_sorted.size() == 193 return received_sorted.size() ==
251 transport_.expected_sequence_numbers_.size() && 194 transport_.expected_sequence_numbers_.size() &&
252 std::equal(received_sorted.begin(), received_sorted.end(), 195 std::equal(received_sorted.begin(), received_sorted.end(),
253 transport_.expected_sequence_numbers_.begin()); 196 transport_.expected_sequence_numbers_.begin());
254 } 197 }
255 198
256 void RunRtxTest(RtxMode rtx_method, int loss) { 199 void RunRtxTest(RtxMode rtx_method, int loss) {
257 rtp_payload_registry_.SetRtxSsrc(kTestSsrc + 1); 200 rtx_receiver_ = transport_.stream_receiver_controller_.CreateReceiver(
201 kTestRtxSsrc, &rtx_stream_);
258 rtp_rtcp_module_->SetRtxSendStatus(rtx_method); 202 rtp_rtcp_module_->SetRtxSendStatus(rtx_method);
259 rtp_rtcp_module_->SetRtxSsrc(kTestSsrc + 1); 203 rtp_rtcp_module_->SetRtxSsrc(kTestRtxSsrc);
260 transport_.DropEveryNthPacket(loss); 204 transport_.DropEveryNthPacket(loss);
261 uint32_t timestamp = 3000; 205 uint32_t timestamp = 3000;
262 uint16_t nack_list[kVideoNackListSize]; 206 uint16_t nack_list[kVideoNackListSize];
263 for (int frame = 0; frame < kNumFrames; ++frame) { 207 for (int frame = 0; frame < kNumFrames; ++frame) {
264 EXPECT_TRUE(rtp_rtcp_module_->SendOutgoingData( 208 EXPECT_TRUE(rtp_rtcp_module_->SendOutgoingData(
265 webrtc::kVideoFrameDelta, kPayloadType, timestamp, timestamp / 90, 209 webrtc::kVideoFrameDelta, kPayloadType, timestamp, timestamp / 90,
266 payload_data, payload_data_length, nullptr, nullptr, nullptr)); 210 payload_data, payload_data_length, nullptr, nullptr, nullptr));
267 // Min required delay until retransmit = 5 + RTT ms (RTT = 0). 211 // Min required delay until retransmit = 5 + RTT ms (RTT = 0).
268 fake_clock.AdvanceTimeMilliseconds(5); 212 fake_clock.AdvanceTimeMilliseconds(5);
269 int length = BuildNackList(nack_list); 213 int length = BuildNackList(nack_list);
270 if (length > 0) 214 if (length > 0)
271 rtp_rtcp_module_->SendNACK(nack_list, length); 215 rtp_rtcp_module_->SendNACK(nack_list, length);
272 fake_clock.AdvanceTimeMilliseconds(28); // 33ms - 5ms delay. 216 fake_clock.AdvanceTimeMilliseconds(28); // 33ms - 5ms delay.
273 rtp_rtcp_module_->Process(); 217 rtp_rtcp_module_->Process();
274 // Prepare next frame. 218 // Prepare next frame.
275 timestamp += 3000; 219 timestamp += 3000;
276 } 220 }
277 receiver_.sequence_numbers_.sort(); 221 media_stream_.sequence_numbers_.sort();
278 } 222 }
279 223
280 void TearDown() override { delete rtp_rtcp_module_; } 224 void TearDown() override { delete rtp_rtcp_module_; }
281 225
282 std::unique_ptr<ReceiveStatistics> receive_statistics_; 226 std::unique_ptr<ReceiveStatistics> receive_statistics_;
283 RTPPayloadRegistry rtp_payload_registry_;
284 std::unique_ptr<RtpReceiver> rtp_receiver_;
285 RtpRtcp* rtp_rtcp_module_; 227 RtpRtcp* rtp_rtcp_module_;
286 std::unique_ptr<TestRtpFeedback> rtp_feedback_;
287 RtxLoopBackTransport transport_; 228 RtxLoopBackTransport transport_;
288 VerifyingRtxReceiver receiver_; 229 const std::map<int, int> rtx_associated_payload_types_ =
230 {{kRtxPayloadType, kPayloadType}};
231 VerifyingMediaStream media_stream_;
232 RtxReceiveStream rtx_stream_;
289 uint8_t payload_data[65000]; 233 uint8_t payload_data[65000];
290 size_t payload_data_length; 234 size_t payload_data_length;
291 SimulatedClock fake_clock; 235 SimulatedClock fake_clock;
292 RateLimiter retransmission_rate_limiter_; 236 RateLimiter retransmission_rate_limiter_;
237 std::unique_ptr<RtpStreamReceiverInterface> media_receiver_;
238 std::unique_ptr<RtpStreamReceiverInterface> rtx_receiver_;
293 }; 239 };
294 240
295 TEST_F(RtpRtcpRtxNackTest, LongNackList) { 241 TEST_F(RtpRtcpRtxNackTest, LongNackList) {
296 const int kNumPacketsToDrop = 900; 242 const int kNumPacketsToDrop = 900;
297 const int kNumRequiredRtcp = 4; 243 const int kNumRequiredRtcp = 4;
298 uint32_t timestamp = 3000; 244 uint32_t timestamp = 3000;
299 uint16_t nack_list[kNumPacketsToDrop]; 245 uint16_t nack_list[kNumPacketsToDrop];
300 // Disable StorePackets to be able to set a larger packet history. 246 // Disable StorePackets to be able to set a larger packet history.
301 rtp_rtcp_module_->SetStorePacketsStatus(false, 0); 247 rtp_rtcp_module_->SetStorePacketsStatus(false, 0);
302 // Enable StorePackets with a packet history of 2000 packets. 248 // Enable StorePackets with a packet history of 2000 packets.
303 rtp_rtcp_module_->SetStorePacketsStatus(true, 2000); 249 rtp_rtcp_module_->SetStorePacketsStatus(true, 2000);
304 // Drop 900 packets from the second one so that we get a NACK list which is 250 // Drop 900 packets from the second one so that we get a NACK list which is
305 // big enough to require 4 RTCP packets to be fully transmitted to the sender. 251 // big enough to require 4 RTCP packets to be fully transmitted to the sender.
306 transport_.DropConsecutivePackets(2, kNumPacketsToDrop); 252 transport_.DropConsecutivePackets(2, kNumPacketsToDrop);
307 // Send 30 frames which at the default size is roughly what we need to get 253 // Send 30 frames which at the default size is roughly what we need to get
308 // enough packets. 254 // enough packets.
309 for (int frame = 0; frame < kNumFrames; ++frame) { 255 for (int frame = 0; frame < kNumFrames; ++frame) {
310 EXPECT_TRUE(rtp_rtcp_module_->SendOutgoingData( 256 EXPECT_TRUE(rtp_rtcp_module_->SendOutgoingData(
311 webrtc::kVideoFrameDelta, kPayloadType, timestamp, timestamp / 90, 257 webrtc::kVideoFrameDelta, kPayloadType, timestamp, timestamp / 90,
312 payload_data, payload_data_length, nullptr, nullptr, nullptr)); 258 payload_data, payload_data_length, nullptr, nullptr, nullptr));
313 // Prepare next frame. 259 // Prepare next frame.
314 timestamp += 3000; 260 timestamp += 3000;
315 fake_clock.AdvanceTimeMilliseconds(33); 261 fake_clock.AdvanceTimeMilliseconds(33);
316 rtp_rtcp_module_->Process(); 262 rtp_rtcp_module_->Process();
317 } 263 }
318 EXPECT_FALSE(transport_.expected_sequence_numbers_.empty()); 264 EXPECT_FALSE(transport_.expected_sequence_numbers_.empty());
319 EXPECT_FALSE(receiver_.sequence_numbers_.empty()); 265 EXPECT_FALSE(media_stream_.sequence_numbers_.empty());
320 size_t last_receive_count = receiver_.sequence_numbers_.size(); 266 size_t last_receive_count = media_stream_.sequence_numbers_.size();
321 int length = BuildNackList(nack_list); 267 int length = BuildNackList(nack_list);
322 for (int i = 0; i < kNumRequiredRtcp - 1; ++i) { 268 for (int i = 0; i < kNumRequiredRtcp - 1; ++i) {
323 rtp_rtcp_module_->SendNACK(nack_list, length); 269 rtp_rtcp_module_->SendNACK(nack_list, length);
324 EXPECT_GT(receiver_.sequence_numbers_.size(), last_receive_count); 270 EXPECT_GT(media_stream_.sequence_numbers_.size(), last_receive_count);
325 last_receive_count = receiver_.sequence_numbers_.size(); 271 last_receive_count = media_stream_.sequence_numbers_.size();
326 EXPECT_FALSE(ExpectedPacketsReceived()); 272 EXPECT_FALSE(ExpectedPacketsReceived());
327 } 273 }
328 rtp_rtcp_module_->SendNACK(nack_list, length); 274 rtp_rtcp_module_->SendNACK(nack_list, length);
329 EXPECT_GT(receiver_.sequence_numbers_.size(), last_receive_count); 275 EXPECT_GT(media_stream_.sequence_numbers_.size(), last_receive_count);
330 EXPECT_TRUE(ExpectedPacketsReceived()); 276 EXPECT_TRUE(ExpectedPacketsReceived());
331 } 277 }
332 278
333 TEST_F(RtpRtcpRtxNackTest, RtxNack) { 279 TEST_F(RtpRtcpRtxNackTest, RtxNack) {
334 RunRtxTest(kRtxRetransmitted, 10); 280 RunRtxTest(kRtxRetransmitted, 10);
335 EXPECT_EQ(kTestSequenceNumber, *(receiver_.sequence_numbers_.begin())); 281 EXPECT_EQ(kTestSequenceNumber, *(media_stream_.sequence_numbers_.begin()));
336 EXPECT_EQ(kTestSequenceNumber + kTestNumberOfPackets - 1, 282 EXPECT_EQ(kTestSequenceNumber + kTestNumberOfPackets - 1,
337 *(receiver_.sequence_numbers_.rbegin())); 283 *(media_stream_.sequence_numbers_.rbegin()));
338 EXPECT_EQ(kTestNumberOfPackets, receiver_.sequence_numbers_.size()); 284 EXPECT_EQ(kTestNumberOfPackets, media_stream_.sequence_numbers_.size());
339 EXPECT_EQ(kTestNumberOfRtxPackets, transport_.count_rtx_ssrc_); 285 EXPECT_EQ(kTestNumberOfRtxPackets, transport_.count_rtx_ssrc_);
340 EXPECT_TRUE(ExpectedPacketsReceived()); 286 EXPECT_TRUE(ExpectedPacketsReceived());
341 } 287 }
342 288
343 } // namespace webrtc 289 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698