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