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

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

Issue 1639253007: Validates sending RTCP before RTP. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: adjusted RtpRtcpImplTest to comply with stricter conditions for Sender Report Created 4 years, 10 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
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 288 }
289 289
290 TEST_F(RtpRtcpImplTest, Rtt) { 290 TEST_F(RtpRtcpImplTest, Rtt) {
291 RTPHeader header; 291 RTPHeader header;
292 header.timestamp = 1; 292 header.timestamp = 1;
293 header.sequenceNumber = 123; 293 header.sequenceNumber = 123;
294 header.ssrc = kSenderSsrc; 294 header.ssrc = kSenderSsrc;
295 header.headerLength = 12; 295 header.headerLength = 12;
296 receiver_.receive_statistics_->IncomingPacket(header, 100, false); 296 receiver_.receive_statistics_->IncomingPacket(header, 100, false);
297 297
298 // Send Frame before sending a SR.
299 SendFrame(&sender_, kBaseLayerTid);
298 // Sender module should send a SR. 300 // Sender module should send a SR.
299 EXPECT_EQ(0, sender_.impl_->SendRTCP(kRtcpReport)); 301 EXPECT_EQ(0, sender_.impl_->SendRTCP(kRtcpReport));
300 302
301 // Receiver module should send a RR with a response to the last received SR. 303 // Receiver module should send a RR with a response to the last received SR.
302 clock_.AdvanceTimeMilliseconds(1000); 304 clock_.AdvanceTimeMilliseconds(1000);
303 EXPECT_EQ(0, receiver_.impl_->SendRTCP(kRtcpReport)); 305 EXPECT_EQ(0, receiver_.impl_->SendRTCP(kRtcpReport));
304 306
305 // Verify RTT. 307 // Verify RTT.
306 int64_t rtt; 308 int64_t rtt;
307 int64_t avg_rtt; 309 int64_t avg_rtt;
(...skipping 25 matching lines...) Expand all
333 } 335 }
334 336
335 TEST_F(RtpRtcpImplTest, RttForReceiverOnly) { 337 TEST_F(RtpRtcpImplTest, RttForReceiverOnly) {
336 receiver_.impl_->SetRtcpXrRrtrStatus(true); 338 receiver_.impl_->SetRtcpXrRrtrStatus(true);
337 339
338 // Receiver module should send a Receiver time reference report (RTRR). 340 // Receiver module should send a Receiver time reference report (RTRR).
339 EXPECT_EQ(0, receiver_.impl_->SendRTCP(kRtcpReport)); 341 EXPECT_EQ(0, receiver_.impl_->SendRTCP(kRtcpReport));
340 342
341 // Sender module should send a response to the last received RTRR (DLRR). 343 // Sender module should send a response to the last received RTRR (DLRR).
342 clock_.AdvanceTimeMilliseconds(1000); 344 clock_.AdvanceTimeMilliseconds(1000);
345 // Send Frame before sending a SR.
346 SendFrame(&sender_, kBaseLayerTid);
343 EXPECT_EQ(0, sender_.impl_->SendRTCP(kRtcpReport)); 347 EXPECT_EQ(0, sender_.impl_->SendRTCP(kRtcpReport));
344 348
345 // Verify RTT. 349 // Verify RTT.
346 EXPECT_EQ(0, receiver_.rtt_stats_.LastProcessedRtt()); 350 EXPECT_EQ(0, receiver_.rtt_stats_.LastProcessedRtt());
347 EXPECT_EQ(0, receiver_.impl_->rtt_ms()); 351 EXPECT_EQ(0, receiver_.impl_->rtt_ms());
348 receiver_.impl_->Process(); 352 receiver_.impl_->Process();
349 EXPECT_EQ(2 * kOneWayNetworkDelayMs, receiver_.rtt_stats_.LastProcessedRtt()); 353 EXPECT_EQ(2 * kOneWayNetworkDelayMs, receiver_.rtt_stats_.LastProcessedRtt());
350 EXPECT_EQ(2 * kOneWayNetworkDelayMs, receiver_.impl_->rtt_ms()); 354 EXPECT_EQ(2 * kOneWayNetworkDelayMs, receiver_.impl_->rtt_ms());
351 } 355 }
352 356
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 rtp3.first_packet_time_ms = kStartTimeMs + 10; 455 rtp3.first_packet_time_ms = kStartTimeMs + 10;
452 sum.Add(rtp3); 456 sum.Add(rtp3);
453 EXPECT_EQ(kStartTimeMs, sum.first_packet_time_ms); // Holds oldest time. 457 EXPECT_EQ(kStartTimeMs, sum.first_packet_time_ms); // Holds oldest time.
454 } 458 }
455 459
456 TEST_F(RtpRtcpImplTest, SendsInitialNackList) { 460 TEST_F(RtpRtcpImplTest, SendsInitialNackList) {
457 // Send module sends a NACK. 461 // Send module sends a NACK.
458 const uint16_t kNackLength = 1; 462 const uint16_t kNackLength = 1;
459 uint16_t nack_list[kNackLength] = {123}; 463 uint16_t nack_list[kNackLength] = {123};
460 EXPECT_EQ(0U, sender_.RtcpSent().nack_packets); 464 EXPECT_EQ(0U, sender_.RtcpSent().nack_packets);
465 // Send Frame before sending a compound RTCP that starts with SR.
466 SendFrame(&sender_, kBaseLayerTid);
461 EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list, kNackLength)); 467 EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list, kNackLength));
462 EXPECT_EQ(1U, sender_.RtcpSent().nack_packets); 468 EXPECT_EQ(1U, sender_.RtcpSent().nack_packets);
463 EXPECT_THAT(sender_.LastNackListSent(), ElementsAre(123)); 469 EXPECT_THAT(sender_.LastNackListSent(), ElementsAre(123));
464 } 470 }
465 471
466 TEST_F(RtpRtcpImplTest, SendsExtendedNackList) { 472 TEST_F(RtpRtcpImplTest, SendsExtendedNackList) {
467 // Send module sends a NACK. 473 // Send module sends a NACK.
468 const uint16_t kNackLength = 1; 474 const uint16_t kNackLength = 1;
469 uint16_t nack_list[kNackLength] = {123}; 475 uint16_t nack_list[kNackLength] = {123};
470 EXPECT_EQ(0U, sender_.RtcpSent().nack_packets); 476 EXPECT_EQ(0U, sender_.RtcpSent().nack_packets);
477 // Send Frame before sending a compound RTCP that starts with SR.
478 SendFrame(&sender_, kBaseLayerTid);
471 EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list, kNackLength)); 479 EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list, kNackLength));
472 EXPECT_EQ(1U, sender_.RtcpSent().nack_packets); 480 EXPECT_EQ(1U, sender_.RtcpSent().nack_packets);
473 EXPECT_THAT(sender_.LastNackListSent(), ElementsAre(123)); 481 EXPECT_THAT(sender_.LastNackListSent(), ElementsAre(123));
474 482
475 // Same list not re-send. 483 // Same list not re-send.
476 EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list, kNackLength)); 484 EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list, kNackLength));
477 EXPECT_EQ(1U, sender_.RtcpSent().nack_packets); 485 EXPECT_EQ(1U, sender_.RtcpSent().nack_packets);
478 EXPECT_THAT(sender_.LastNackListSent(), ElementsAre(123)); 486 EXPECT_THAT(sender_.LastNackListSent(), ElementsAre(123));
479 487
480 // Only extended list sent. 488 // Only extended list sent.
481 const uint16_t kNackExtLength = 2; 489 const uint16_t kNackExtLength = 2;
482 uint16_t nack_list_ext[kNackExtLength] = {123, 124}; 490 uint16_t nack_list_ext[kNackExtLength] = {123, 124};
483 EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list_ext, kNackExtLength)); 491 EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list_ext, kNackExtLength));
484 EXPECT_EQ(2U, sender_.RtcpSent().nack_packets); 492 EXPECT_EQ(2U, sender_.RtcpSent().nack_packets);
485 EXPECT_THAT(sender_.LastNackListSent(), ElementsAre(124)); 493 EXPECT_THAT(sender_.LastNackListSent(), ElementsAre(124));
486 } 494 }
487 495
488 TEST_F(RtpRtcpImplTest, ReSendsNackListAfterRttMs) { 496 TEST_F(RtpRtcpImplTest, ReSendsNackListAfterRttMs) {
489 sender_.transport_.SimulateNetworkDelay(0, &clock_); 497 sender_.transport_.SimulateNetworkDelay(0, &clock_);
490 // Send module sends a NACK. 498 // Send module sends a NACK.
491 const uint16_t kNackLength = 2; 499 const uint16_t kNackLength = 2;
492 uint16_t nack_list[kNackLength] = {123, 125}; 500 uint16_t nack_list[kNackLength] = {123, 125};
493 EXPECT_EQ(0U, sender_.RtcpSent().nack_packets); 501 EXPECT_EQ(0U, sender_.RtcpSent().nack_packets);
502 // Send Frame before sending a compound RTCP that starts with SR.
503 SendFrame(&sender_, kBaseLayerTid);
494 EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list, kNackLength)); 504 EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list, kNackLength));
495 EXPECT_EQ(1U, sender_.RtcpSent().nack_packets); 505 EXPECT_EQ(1U, sender_.RtcpSent().nack_packets);
496 EXPECT_THAT(sender_.LastNackListSent(), ElementsAre(123, 125)); 506 EXPECT_THAT(sender_.LastNackListSent(), ElementsAre(123, 125));
497 507
498 // Same list not re-send, rtt interval has not passed. 508 // Same list not re-send, rtt interval has not passed.
499 const int kStartupRttMs = 100; 509 const int kStartupRttMs = 100;
500 clock_.AdvanceTimeMilliseconds(kStartupRttMs); 510 clock_.AdvanceTimeMilliseconds(kStartupRttMs);
501 EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list, kNackLength)); 511 EXPECT_EQ(0, sender_.impl_->SendNACK(nack_list, kNackLength));
502 EXPECT_EQ(1U, sender_.RtcpSent().nack_packets); 512 EXPECT_EQ(1U, sender_.RtcpSent().nack_packets);
503 513
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 EXPECT_EQ(6U, receiver_.RtcpSent().unique_nack_requests); 551 EXPECT_EQ(6U, receiver_.RtcpSent().unique_nack_requests);
542 EXPECT_THAT(receiver_.LastNackListSent(), ElementsAre(11, 18, 20, 21)); 552 EXPECT_THAT(receiver_.LastNackListSent(), ElementsAre(11, 18, 20, 21));
543 553
544 // Send module receives the request. 554 // Send module receives the request.
545 EXPECT_EQ(2U, sender_.RtcpReceived().nack_packets); 555 EXPECT_EQ(2U, sender_.RtcpReceived().nack_packets);
546 EXPECT_EQ(8U, sender_.RtcpReceived().nack_requests); 556 EXPECT_EQ(8U, sender_.RtcpReceived().nack_requests);
547 EXPECT_EQ(6U, sender_.RtcpReceived().unique_nack_requests); 557 EXPECT_EQ(6U, sender_.RtcpReceived().unique_nack_requests);
548 EXPECT_EQ(75, sender_.RtcpReceived().UniqueNackRequestsInPercent()); 558 EXPECT_EQ(75, sender_.RtcpReceived().UniqueNackRequestsInPercent());
549 } 559 }
550 } // namespace webrtc 560 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698