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