| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/test/simple_test_tick_clock.h" | 7 #include "base/test/simple_test_tick_clock.h" |
| 8 #include "media/cast/cast_defines.h" | 8 #include "media/cast/cast_defines.h" |
| 9 #include "media/cast/cast_environment.h" | 9 #include "media/cast/cast_environment.h" |
| 10 #include "media/cast/rtcp/mock_rtcp_receiver_feedback.h" | 10 #include "media/cast/rtcp/mock_rtcp_receiver_feedback.h" |
| 11 #include "media/cast/rtcp/mock_rtcp_sender_feedback.h" | 11 #include "media/cast/rtcp/mock_rtcp_sender_feedback.h" |
| 12 #include "media/cast/rtcp/rtcp.h" | 12 #include "media/cast/rtcp/rtcp.h" |
| 13 #include "media/cast/rtcp/test_rtcp_packet_builder.h" | 13 #include "media/cast/rtcp/test_rtcp_packet_builder.h" |
| 14 #include "media/cast/test/fake_single_thread_task_runner.h" | 14 #include "media/cast/test/fake_single_thread_task_runner.h" |
| 15 #include "media/cast/transport/cast_transport_config.h" | 15 #include "media/cast/transport/cast_transport_config.h" |
| 16 #include "media/cast/transport/cast_transport_sender_impl.h" | 16 #include "media/cast/transport/cast_transport_sender_impl.h" |
| 17 #include "media/cast/transport/pacing/paced_sender.h" | 17 #include "media/cast/transport/pacing/paced_sender.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 19 | 19 |
| 20 namespace media { | 20 namespace media { |
| 21 namespace cast { | 21 namespace cast { |
| 22 | 22 |
| 23 using testing::_; | 23 using testing::_; |
| 24 | 24 |
| 25 static const uint32 kSenderSsrc = 0x10203; | 25 static const uint32 kSenderSsrc = 0x10203; |
| 26 static const uint32 kReceiverSsrc = 0x40506; | 26 static const uint32 kReceiverSsrc = 0x40506; |
| 27 static const std::string kCName("test@10.1.1.1"); | 27 static const std::string kCName("test@10.1.1.1"); |
| 28 static const uint32 kRtcpIntervalMs = 500; | 28 static const uint32 kRtcpIntervalMs = 500; |
| 29 static const int64 kStartMillisecond = INT64_C(12345678900000); | |
| 30 static const int64 kAddedDelay = 123; | 29 static const int64 kAddedDelay = 123; |
| 31 static const int64 kAddedShortDelay = 100; | 30 static const int64 kAddedShortDelay = 100; |
| 32 | 31 |
| 33 class RtcpTestPacketSender : public transport::PacketSender { | 32 class RtcpTestPacketSender : public transport::PacketSender { |
| 34 public: | 33 public: |
| 35 explicit RtcpTestPacketSender(base::SimpleTestTickClock* testing_clock) | 34 explicit RtcpTestPacketSender(base::SimpleTestTickClock* testing_clock) |
| 36 : drop_packets_(false), | 35 : drop_packets_(false), |
| 37 short_delay_(false), | 36 short_delay_(false), |
| 38 rtcp_receiver_(NULL), | 37 rtcp_receiver_(NULL), |
| 39 testing_clock_(testing_clock) {} | 38 testing_clock_(testing_clock) {} |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 transport_sender, | 135 transport_sender, |
| 137 paced_packet_sender, | 136 paced_packet_sender, |
| 138 rtp_receiver_statistics, | 137 rtp_receiver_statistics, |
| 139 rtcp_mode, | 138 rtcp_mode, |
| 140 rtcp_interval, | 139 rtcp_interval, |
| 141 local_ssrc, | 140 local_ssrc, |
| 142 remote_ssrc, | 141 remote_ssrc, |
| 143 c_name, | 142 c_name, |
| 144 true) {} | 143 true) {} |
| 145 | 144 |
| 146 using Rtcp::CheckForWrapAround; | 145 using Rtcp::OnReceivedNtp; |
| 147 using Rtcp::OnReceivedLipSyncInfo; | 146 using Rtcp::OnReceivedLipSyncInfo; |
| 148 }; | 147 }; |
| 149 | 148 |
| 150 class RtcpTest : public ::testing::Test { | 149 class RtcpTest : public ::testing::Test { |
| 151 protected: | 150 protected: |
| 152 RtcpTest() | 151 RtcpTest() |
| 153 : testing_clock_(new base::SimpleTestTickClock()), | 152 : testing_clock_(new base::SimpleTestTickClock()), |
| 154 task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)), | 153 task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)), |
| 155 cast_environment_(new CastEnvironment( | 154 cast_environment_(new CastEnvironment( |
| 156 scoped_ptr<base::TickClock>(testing_clock_).Pass(), | 155 scoped_ptr<base::TickClock>(testing_clock_).Pass(), |
| 157 task_runner_, | 156 task_runner_, |
| 158 task_runner_, | 157 task_runner_, |
| 159 task_runner_)), | 158 task_runner_)), |
| 160 sender_to_receiver_(testing_clock_), | 159 sender_to_receiver_(testing_clock_), |
| 161 receiver_to_sender_(cast_environment_, testing_clock_), | 160 receiver_to_sender_(cast_environment_, testing_clock_), |
| 162 rtp_sender_stats_(kVideoFrequency) { | 161 rtp_sender_stats_(kVideoFrequency) { |
| 163 testing_clock_->Advance( | 162 testing_clock_->Advance(base::TimeTicks::Now() - base::TimeTicks()); |
| 164 base::TimeDelta::FromMilliseconds(kStartMillisecond)); | |
| 165 net::IPEndPoint dummy_endpoint; | 163 net::IPEndPoint dummy_endpoint; |
| 166 transport_sender_.reset(new transport::CastTransportSenderImpl( | 164 transport_sender_.reset(new transport::CastTransportSenderImpl( |
| 167 NULL, | 165 NULL, |
| 168 testing_clock_, | 166 testing_clock_, |
| 169 dummy_endpoint, | 167 dummy_endpoint, |
| 170 base::Bind(&UpdateCastTransportStatus), | 168 base::Bind(&UpdateCastTransportStatus), |
| 171 transport::BulkRawEventsCallback(), | 169 transport::BulkRawEventsCallback(), |
| 172 base::TimeDelta(), | 170 base::TimeDelta(), |
| 173 task_runner_, | 171 task_runner_, |
| 174 &sender_to_receiver_)); | 172 &sender_to_receiver_)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 197 RtcpTestPacketSender sender_to_receiver_; | 195 RtcpTestPacketSender sender_to_receiver_; |
| 198 scoped_ptr<transport::CastTransportSenderImpl> transport_sender_; | 196 scoped_ptr<transport::CastTransportSenderImpl> transport_sender_; |
| 199 LocalRtcpTransport receiver_to_sender_; | 197 LocalRtcpTransport receiver_to_sender_; |
| 200 MockRtcpSenderFeedback mock_sender_feedback_; | 198 MockRtcpSenderFeedback mock_sender_feedback_; |
| 201 RtpSenderStatistics rtp_sender_stats_; | 199 RtpSenderStatistics rtp_sender_stats_; |
| 202 | 200 |
| 203 DISALLOW_COPY_AND_ASSIGN(RtcpTest); | 201 DISALLOW_COPY_AND_ASSIGN(RtcpTest); |
| 204 }; | 202 }; |
| 205 | 203 |
| 206 TEST_F(RtcpTest, TimeToSend) { | 204 TEST_F(RtcpTest, TimeToSend) { |
| 207 base::TimeTicks start_time; | 205 const base::TimeTicks start_time = cast_environment_->Clock()->NowTicks(); |
| 208 start_time += base::TimeDelta::FromMilliseconds(kStartMillisecond); | |
| 209 Rtcp rtcp(cast_environment_, | 206 Rtcp rtcp(cast_environment_, |
| 210 &mock_sender_feedback_, | 207 &mock_sender_feedback_, |
| 211 transport_sender_.get(), | 208 transport_sender_.get(), |
| 212 &receiver_to_sender_, | 209 &receiver_to_sender_, |
| 213 NULL, | 210 NULL, |
| 214 kRtcpCompound, | 211 kRtcpCompound, |
| 215 base::TimeDelta::FromMilliseconds(kRtcpIntervalMs), | 212 base::TimeDelta::FromMilliseconds(kRtcpIntervalMs), |
| 216 kSenderSsrc, | 213 kSenderSsrc, |
| 217 kReceiverSsrc, | 214 kReceiverSsrc, |
| 218 kCName, | 215 kCName, |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 | 500 |
| 504 EXPECT_TRUE(rtcp_receiver.Rtt(&rtt, &avg_rtt, &min_rtt, &max_rtt)); | 501 EXPECT_TRUE(rtcp_receiver.Rtt(&rtt, &avg_rtt, &min_rtt, &max_rtt)); |
| 505 EXPECT_NEAR(kAddedDelay + kAddedShortDelay, rtt.InMilliseconds(), 2); | 502 EXPECT_NEAR(kAddedDelay + kAddedShortDelay, rtt.InMilliseconds(), 2); |
| 506 } | 503 } |
| 507 | 504 |
| 508 TEST_F(RtcpTest, NtpAndTime) { | 505 TEST_F(RtcpTest, NtpAndTime) { |
| 509 const int64 kSecondsbetweenYear1900and2010 = INT64_C(40176 * 24 * 60 * 60); | 506 const int64 kSecondsbetweenYear1900and2010 = INT64_C(40176 * 24 * 60 * 60); |
| 510 const int64 kSecondsbetweenYear1900and2030 = INT64_C(47481 * 24 * 60 * 60); | 507 const int64 kSecondsbetweenYear1900and2030 = INT64_C(47481 * 24 * 60 * 60); |
| 511 | 508 |
| 512 uint32 ntp_seconds_1 = 0; | 509 uint32 ntp_seconds_1 = 0; |
| 513 uint32 ntp_fractions_1 = 0; | 510 uint32 ntp_fraction_1 = 0; |
| 514 base::TimeTicks input_time = base::TimeTicks::Now(); | 511 base::TimeTicks input_time = base::TimeTicks::Now(); |
| 515 ConvertTimeTicksToNtp(input_time, &ntp_seconds_1, &ntp_fractions_1); | 512 ConvertTimeTicksToNtp(input_time, &ntp_seconds_1, &ntp_fraction_1); |
| 516 | 513 |
| 517 // Verify absolute value. | 514 // Verify absolute value. |
| 518 EXPECT_GT(ntp_seconds_1, kSecondsbetweenYear1900and2010); | 515 EXPECT_GT(ntp_seconds_1, kSecondsbetweenYear1900and2010); |
| 519 EXPECT_LT(ntp_seconds_1, kSecondsbetweenYear1900and2030); | 516 EXPECT_LT(ntp_seconds_1, kSecondsbetweenYear1900and2030); |
| 520 | 517 |
| 521 base::TimeTicks out_1 = ConvertNtpToTimeTicks(ntp_seconds_1, ntp_fractions_1); | 518 base::TimeTicks out_1 = ConvertNtpToTimeTicks(ntp_seconds_1, ntp_fraction_1); |
| 522 EXPECT_EQ(input_time, out_1); // Verify inverse. | 519 EXPECT_EQ(input_time, out_1); // Verify inverse. |
| 523 | 520 |
| 524 base::TimeDelta time_delta = base::TimeDelta::FromMilliseconds(1000); | 521 base::TimeDelta time_delta = base::TimeDelta::FromMilliseconds(1000); |
| 525 input_time += time_delta; | 522 input_time += time_delta; |
| 526 | 523 |
| 527 uint32 ntp_seconds_2 = 0; | 524 uint32 ntp_seconds_2 = 0; |
| 528 uint32 ntp_fractions_2 = 0; | 525 uint32 ntp_fraction_2 = 0; |
| 529 | 526 |
| 530 ConvertTimeTicksToNtp(input_time, &ntp_seconds_2, &ntp_fractions_2); | 527 ConvertTimeTicksToNtp(input_time, &ntp_seconds_2, &ntp_fraction_2); |
| 531 base::TimeTicks out_2 = ConvertNtpToTimeTicks(ntp_seconds_2, ntp_fractions_2); | 528 base::TimeTicks out_2 = ConvertNtpToTimeTicks(ntp_seconds_2, ntp_fraction_2); |
| 532 EXPECT_EQ(input_time, out_2); // Verify inverse. | 529 EXPECT_EQ(input_time, out_2); // Verify inverse. |
| 533 | 530 |
| 534 // Verify delta. | 531 // Verify delta. |
| 535 EXPECT_EQ((out_2 - out_1), time_delta); | 532 EXPECT_EQ((out_2 - out_1), time_delta); |
| 536 EXPECT_EQ((ntp_seconds_2 - ntp_seconds_1), UINT32_C(1)); | 533 EXPECT_EQ((ntp_seconds_2 - ntp_seconds_1), UINT32_C(1)); |
| 537 EXPECT_NEAR(ntp_fractions_2, ntp_fractions_1, 1); | 534 EXPECT_NEAR(ntp_fraction_2, ntp_fraction_1, 1); |
| 538 | 535 |
| 539 time_delta = base::TimeDelta::FromMilliseconds(500); | 536 time_delta = base::TimeDelta::FromMilliseconds(500); |
| 540 input_time += time_delta; | 537 input_time += time_delta; |
| 541 | 538 |
| 542 uint32 ntp_seconds_3 = 0; | 539 uint32 ntp_seconds_3 = 0; |
| 543 uint32 ntp_fractions_3 = 0; | 540 uint32 ntp_fraction_3 = 0; |
| 544 | 541 |
| 545 ConvertTimeTicksToNtp(input_time, &ntp_seconds_3, &ntp_fractions_3); | 542 ConvertTimeTicksToNtp(input_time, &ntp_seconds_3, &ntp_fraction_3); |
| 546 base::TimeTicks out_3 = ConvertNtpToTimeTicks(ntp_seconds_3, ntp_fractions_3); | 543 base::TimeTicks out_3 = ConvertNtpToTimeTicks(ntp_seconds_3, ntp_fraction_3); |
| 547 EXPECT_EQ(input_time, out_3); // Verify inverse. | 544 EXPECT_EQ(input_time, out_3); // Verify inverse. |
| 548 | 545 |
| 549 // Verify delta. | 546 // Verify delta. |
| 550 EXPECT_EQ((out_3 - out_2), time_delta); | 547 EXPECT_EQ((out_3 - out_2), time_delta); |
| 551 EXPECT_NEAR((ntp_fractions_3 - ntp_fractions_2), 0xffffffff / 2, 1); | 548 EXPECT_NEAR((ntp_fraction_3 - ntp_fraction_2), 0xffffffff / 2, 1); |
| 552 } | 549 } |
| 553 | 550 |
| 554 TEST_F(RtcpTest, WrapAround) { | 551 TEST_F(RtcpTest, UsesReportsToConvertRemoteNtpTimeToLocalTimeTicks) { |
| 555 RtcpPeer rtcp_peer(cast_environment_, | 552 RtcpPeer rtcp(cast_environment_, |
| 556 &mock_sender_feedback_, | 553 &mock_sender_feedback_, |
| 557 transport_sender_.get(), | 554 transport_sender_.get(), |
| 558 NULL, | 555 &receiver_to_sender_, |
| 559 NULL, | 556 NULL, |
| 560 kRtcpReducedSize, | 557 kRtcpReducedSize, |
| 561 base::TimeDelta::FromMilliseconds(kRtcpIntervalMs), | 558 base::TimeDelta::FromMilliseconds(kRtcpIntervalMs), |
| 562 kReceiverSsrc, | 559 kReceiverSsrc, |
| 563 kSenderSsrc, | 560 kSenderSsrc, |
| 564 kCName); | 561 kCName); |
| 565 uint32 new_timestamp = 0; | 562 |
| 566 uint32 old_timestamp = 0; | 563 // Start out with a simulated "remote clock" that is perfectly synchronized to |
| 567 EXPECT_EQ(0, rtcp_peer.CheckForWrapAround(new_timestamp, old_timestamp)); | 564 // the local clock. |
| 568 new_timestamp = 1234567890; | 565 base::SimpleTestTickClock remote_clock; |
| 569 old_timestamp = 1234567000; | 566 remote_clock.Advance(testing_clock_->NowTicks() - base::TimeTicks()); |
| 570 EXPECT_EQ(0, rtcp_peer.CheckForWrapAround(new_timestamp, old_timestamp)); | 567 uint32 remote_ntp_seconds = 0; |
| 571 new_timestamp = 1234567000; | 568 uint32 remote_ntp_fraction = 0; |
| 572 old_timestamp = 1234567890; | 569 ConvertTimeTicksToNtp( |
| 573 EXPECT_EQ(0, rtcp_peer.CheckForWrapAround(new_timestamp, old_timestamp)); | 570 remote_clock.NowTicks(), &remote_ntp_seconds, &remote_ntp_fraction); |
| 574 new_timestamp = 123; | 571 |
| 575 old_timestamp = 4234567890u; | 572 // Expect the operation fails before the first call to OnReceivedNtp(). |
| 576 EXPECT_EQ(1, rtcp_peer.CheckForWrapAround(new_timestamp, old_timestamp)); | 573 EXPECT_TRUE(rtcp.ToApproximateLocalTime(remote_ntp_seconds, |
| 577 new_timestamp = 4234567890u; | 574 remote_ntp_fraction).is_null()); |
| 578 old_timestamp = 123; | 575 |
| 579 EXPECT_EQ(-1, rtcp_peer.CheckForWrapAround(new_timestamp, old_timestamp)); | 576 // Now receive the NTP timestamp and expect ToApproximateLocalTime() will |
| 577 // return current time according to both clocks. |
| 578 rtcp.OnReceivedNtp(remote_ntp_seconds, remote_ntp_fraction); |
| 579 uint32 ntp_seconds = remote_ntp_seconds; |
| 580 uint32 ntp_fraction = remote_ntp_fraction; |
| 581 EXPECT_EQ(testing_clock_->NowTicks(), |
| 582 rtcp.ToApproximateLocalTime(ntp_seconds, ntp_fraction)); |
| 583 EXPECT_EQ(remote_clock.NowTicks(), |
| 584 rtcp.ToApproximateLocalTime(ntp_seconds, ntp_fraction)); |
| 585 |
| 586 // Now advance the local clock and receive the same NTP timestamp again, and |
| 587 // expect ToApproximateLocalTime() will still return the current local time. |
| 588 const base::TimeDelta local_advance_by = |
| 589 base::TimeDelta::FromMicroseconds(1234567); |
| 590 testing_clock_->Advance(local_advance_by); |
| 591 EXPECT_EQ(testing_clock_->NowTicks() - local_advance_by, |
| 592 rtcp.ToApproximateLocalTime(ntp_seconds, ntp_fraction)); |
| 593 rtcp.OnReceivedNtp(remote_ntp_seconds, remote_ntp_fraction); |
| 594 EXPECT_EQ(testing_clock_->NowTicks(), |
| 595 rtcp.ToApproximateLocalTime(ntp_seconds, ntp_fraction)); |
| 596 |
| 597 // Advance sender clock and provide a new NTP timestamp. When |
| 598 // ToApproximateLocalTime() is called with the old NTP timestamp, expect to |
| 599 // get a result that is backwards in time by the same amount the sender clock |
| 600 // was advanced. |
| 601 const base::TimeDelta sender_ahead_by = |
| 602 base::TimeDelta::FromMicroseconds(987654); |
| 603 remote_clock.Advance(sender_ahead_by); |
| 604 ConvertTimeTicksToNtp( |
| 605 remote_clock.NowTicks(), &remote_ntp_seconds, &remote_ntp_fraction); |
| 606 rtcp.OnReceivedNtp(remote_ntp_seconds, remote_ntp_fraction); |
| 607 EXPECT_EQ(testing_clock_->NowTicks() - sender_ahead_by, |
| 608 rtcp.ToApproximateLocalTime(ntp_seconds, ntp_fraction)); |
| 580 } | 609 } |
| 581 | 610 |
| 582 TEST_F(RtcpTest, RtpTimestampInSenderTime) { | 611 TEST_F(RtcpTest, UsesLipSyncToExtrapolateCaptureTime) { |
| 583 RtcpPeer rtcp_peer(cast_environment_, | 612 RtcpPeer rtcp(cast_environment_, |
| 584 &mock_sender_feedback_, | 613 &mock_sender_feedback_, |
| 585 transport_sender_.get(), | 614 transport_sender_.get(), |
| 586 &receiver_to_sender_, | 615 &receiver_to_sender_, |
| 587 NULL, | 616 NULL, |
| 588 kRtcpReducedSize, | 617 kRtcpReducedSize, |
| 589 base::TimeDelta::FromMilliseconds(kRtcpIntervalMs), | 618 base::TimeDelta::FromMilliseconds(kRtcpIntervalMs), |
| 590 kReceiverSsrc, | 619 kReceiverSsrc, |
| 591 kSenderSsrc, | 620 kSenderSsrc, |
| 592 kCName); | 621 kCName); |
| 593 int frequency = 32000; | 622 const int frequency = 32000; |
| 594 uint32 rtp_timestamp = 64000; | 623 uint32 rtp_timestamp = 64000; |
| 595 base::TimeTicks rtp_timestamp_in_ticks; | |
| 596 | 624 |
| 597 // Test fail before we get a OnReceivedLipSyncInfo. | 625 // Expect the operation fails before we get the first OnReceivedLipSyncInfo. |
| 598 EXPECT_FALSE(rtcp_peer.RtpTimestampInSenderTime( | 626 EXPECT_TRUE( |
| 599 frequency, rtp_timestamp, &rtp_timestamp_in_ticks)); | 627 rtcp.ToApproximateCaptureTime(rtp_timestamp, frequency).is_null()); |
| 600 | 628 |
| 601 uint32 ntp_seconds = 0; | 629 uint32 ntp_seconds = 0; |
| 602 uint32 ntp_fractions = 0; | 630 uint32 ntp_fraction = 0; |
| 603 uint64 input_time_us = 12345678901000LL; | 631 const base::TimeTicks lip_sync_time = cast_environment_->Clock()->NowTicks(); |
| 604 base::TimeTicks input_time; | |
| 605 input_time += base::TimeDelta::FromMicroseconds(input_time_us); | |
| 606 | 632 |
| 607 // Test exact match. | 633 // Test exact match. |
| 608 ConvertTimeTicksToNtp(input_time, &ntp_seconds, &ntp_fractions); | 634 ConvertTimeTicksToNtp(lip_sync_time, &ntp_seconds, &ntp_fraction); |
| 609 rtcp_peer.OnReceivedLipSyncInfo(rtp_timestamp, ntp_seconds, ntp_fractions); | 635 rtcp.OnReceivedNtp(ntp_seconds, ntp_fraction); |
| 610 EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime( | 636 rtcp.OnReceivedLipSyncInfo(rtp_timestamp, ntp_seconds, ntp_fraction); |
| 611 frequency, rtp_timestamp, &rtp_timestamp_in_ticks)); | 637 EXPECT_FALSE( |
| 612 EXPECT_EQ(input_time, rtp_timestamp_in_ticks); | 638 rtcp.ToApproximateCaptureTime(rtp_timestamp, frequency).is_null()); |
| 639 EXPECT_EQ(lip_sync_time, |
| 640 rtcp.ToApproximateCaptureTime(rtp_timestamp, frequency)); |
| 613 | 641 |
| 614 // Test older rtp_timestamp. | 642 // Test older rtp_timestamp. |
| 615 rtp_timestamp = 32000; | 643 rtp_timestamp = 32000; |
| 616 EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime( | 644 EXPECT_FALSE( |
| 617 frequency, rtp_timestamp, &rtp_timestamp_in_ticks)); | 645 rtcp.ToApproximateCaptureTime(rtp_timestamp, frequency).is_null()); |
| 618 EXPECT_EQ(input_time - base::TimeDelta::FromMilliseconds(1000), | 646 EXPECT_EQ(lip_sync_time - base::TimeDelta::FromMilliseconds(1000), |
| 619 rtp_timestamp_in_ticks); | 647 rtcp.ToApproximateCaptureTime(rtp_timestamp, frequency)); |
| 620 | 648 |
| 621 // Test older rtp_timestamp with wrap. | 649 // Test older rtp_timestamp with wrap. |
| 622 rtp_timestamp = 4294903296u; | 650 rtp_timestamp = 4294903296u; |
| 623 EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime( | 651 EXPECT_FALSE( |
| 624 frequency, rtp_timestamp, &rtp_timestamp_in_ticks)); | 652 rtcp.ToApproximateCaptureTime(rtp_timestamp, frequency).is_null()); |
| 625 EXPECT_EQ(input_time - base::TimeDelta::FromMilliseconds(4000), | 653 EXPECT_EQ(lip_sync_time - base::TimeDelta::FromMilliseconds(4000), |
| 626 rtp_timestamp_in_ticks); | 654 rtcp.ToApproximateCaptureTime(rtp_timestamp, frequency)); |
| 627 | 655 |
| 628 // Test newer rtp_timestamp. | 656 // Test newer rtp_timestamp. |
| 629 rtp_timestamp = 128000; | 657 rtp_timestamp = 128000; |
| 630 EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime( | 658 EXPECT_FALSE( |
| 631 frequency, rtp_timestamp, &rtp_timestamp_in_ticks)); | 659 rtcp.ToApproximateCaptureTime(rtp_timestamp, frequency).is_null()); |
| 632 EXPECT_EQ(input_time + base::TimeDelta::FromMilliseconds(2000), | 660 EXPECT_EQ(lip_sync_time + base::TimeDelta::FromMilliseconds(2000), |
| 633 rtp_timestamp_in_ticks); | 661 rtcp.ToApproximateCaptureTime(rtp_timestamp, frequency)); |
| 634 | 662 |
| 635 // Test newer rtp_timestamp with wrap. | 663 // Test newer rtp_timestamp with wrap. |
| 636 rtp_timestamp = 4294903296u; | 664 rtp_timestamp = 4294903296u; |
| 637 rtcp_peer.OnReceivedLipSyncInfo(rtp_timestamp, ntp_seconds, ntp_fractions); | 665 rtcp.OnReceivedLipSyncInfo(rtp_timestamp, ntp_seconds, ntp_fraction); |
| 638 rtp_timestamp = 64000; | 666 rtp_timestamp = 64000; |
| 639 EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime( | 667 EXPECT_FALSE( |
| 640 frequency, rtp_timestamp, &rtp_timestamp_in_ticks)); | 668 rtcp.ToApproximateCaptureTime(rtp_timestamp, frequency).is_null()); |
| 641 EXPECT_EQ(input_time + base::TimeDelta::FromMilliseconds(4000), | 669 EXPECT_EQ(lip_sync_time + base::TimeDelta::FromMilliseconds(4000), |
| 642 rtp_timestamp_in_ticks); | 670 rtcp.ToApproximateCaptureTime(rtp_timestamp, frequency)); |
| 643 } | 671 } |
| 644 | 672 |
| 645 } // namespace cast | 673 } // namespace cast |
| 646 } // namespace media | 674 } // namespace media |
| OLD | NEW |