Index: media/cast/rtcp/rtcp_unittest.cc |
diff --git a/media/cast/rtcp/rtcp_unittest.cc b/media/cast/rtcp/rtcp_unittest.cc |
index b8f538857fb67ea744bd234a0a0b5ef97fdbeaef..f864a0034fa9d4de2d87f2ec0973b4f3c348764d 100644 |
--- a/media/cast/rtcp/rtcp_unittest.cc |
+++ b/media/cast/rtcp/rtcp_unittest.cc |
@@ -142,7 +142,7 @@ class RtcpPeer : public Rtcp { |
c_name, |
true) {} |
- using Rtcp::CheckForWrapAround; |
+ using Rtcp::OnReceivedNtp; |
using Rtcp::OnReceivedLipSyncInfo; |
}; |
@@ -204,7 +204,7 @@ class RtcpTest : public ::testing::Test { |
}; |
TEST_F(RtcpTest, TimeToSend) { |
- base::TimeTicks start_time = testing_clock_->NowTicks(); |
+ const base::TimeTicks start_time = testing_clock_->NowTicks(); |
Rtcp rtcp(cast_environment_, |
&mock_sender_feedback_, |
transport_sender_.get(), |
@@ -498,136 +498,45 @@ TEST_F(RtcpTest, NtpAndTime) { |
const int64 kSecondsbetweenYear1900and2030 = INT64_C(47481 * 24 * 60 * 60); |
uint32 ntp_seconds_1 = 0; |
- uint32 ntp_fractions_1 = 0; |
+ uint32 ntp_fraction_1 = 0; |
base::TimeTicks input_time = base::TimeTicks::Now(); |
- ConvertTimeTicksToNtp(input_time, &ntp_seconds_1, &ntp_fractions_1); |
+ ConvertTimeTicksToNtp(input_time, &ntp_seconds_1, &ntp_fraction_1); |
// Verify absolute value. |
EXPECT_GT(ntp_seconds_1, kSecondsbetweenYear1900and2010); |
EXPECT_LT(ntp_seconds_1, kSecondsbetweenYear1900and2030); |
- base::TimeTicks out_1 = ConvertNtpToTimeTicks(ntp_seconds_1, ntp_fractions_1); |
+ base::TimeTicks out_1 = ConvertNtpToTimeTicks(ntp_seconds_1, ntp_fraction_1); |
EXPECT_EQ(input_time, out_1); // Verify inverse. |
base::TimeDelta time_delta = base::TimeDelta::FromMilliseconds(1000); |
input_time += time_delta; |
uint32 ntp_seconds_2 = 0; |
- uint32 ntp_fractions_2 = 0; |
+ uint32 ntp_fraction_2 = 0; |
- ConvertTimeTicksToNtp(input_time, &ntp_seconds_2, &ntp_fractions_2); |
- base::TimeTicks out_2 = ConvertNtpToTimeTicks(ntp_seconds_2, ntp_fractions_2); |
+ ConvertTimeTicksToNtp(input_time, &ntp_seconds_2, &ntp_fraction_2); |
+ base::TimeTicks out_2 = ConvertNtpToTimeTicks(ntp_seconds_2, ntp_fraction_2); |
EXPECT_EQ(input_time, out_2); // Verify inverse. |
// Verify delta. |
EXPECT_EQ((out_2 - out_1), time_delta); |
EXPECT_EQ((ntp_seconds_2 - ntp_seconds_1), UINT32_C(1)); |
- EXPECT_NEAR(ntp_fractions_2, ntp_fractions_1, 1); |
+ EXPECT_NEAR(ntp_fraction_2, ntp_fraction_1, 1); |
time_delta = base::TimeDelta::FromMilliseconds(500); |
input_time += time_delta; |
uint32 ntp_seconds_3 = 0; |
- uint32 ntp_fractions_3 = 0; |
+ uint32 ntp_fraction_3 = 0; |
- ConvertTimeTicksToNtp(input_time, &ntp_seconds_3, &ntp_fractions_3); |
- base::TimeTicks out_3 = ConvertNtpToTimeTicks(ntp_seconds_3, ntp_fractions_3); |
+ ConvertTimeTicksToNtp(input_time, &ntp_seconds_3, &ntp_fraction_3); |
+ base::TimeTicks out_3 = ConvertNtpToTimeTicks(ntp_seconds_3, ntp_fraction_3); |
EXPECT_EQ(input_time, out_3); // Verify inverse. |
// Verify delta. |
EXPECT_EQ((out_3 - out_2), time_delta); |
- EXPECT_NEAR((ntp_fractions_3 - ntp_fractions_2), 0xffffffff / 2, 1); |
-} |
- |
-TEST_F(RtcpTest, WrapAround) { |
- RtcpPeer rtcp_peer(cast_environment_, |
- &mock_sender_feedback_, |
- transport_sender_.get(), |
- NULL, |
- NULL, |
- kRtcpReducedSize, |
- base::TimeDelta::FromMilliseconds(kRtcpIntervalMs), |
- kReceiverSsrc, |
- kSenderSsrc, |
- kCName); |
- uint32 new_timestamp = 0; |
- uint32 old_timestamp = 0; |
- EXPECT_EQ(0, rtcp_peer.CheckForWrapAround(new_timestamp, old_timestamp)); |
- new_timestamp = 1234567890; |
- old_timestamp = 1234567000; |
- EXPECT_EQ(0, rtcp_peer.CheckForWrapAround(new_timestamp, old_timestamp)); |
- new_timestamp = 1234567000; |
- old_timestamp = 1234567890; |
- EXPECT_EQ(0, rtcp_peer.CheckForWrapAround(new_timestamp, old_timestamp)); |
- new_timestamp = 123; |
- old_timestamp = 4234567890u; |
- EXPECT_EQ(1, rtcp_peer.CheckForWrapAround(new_timestamp, old_timestamp)); |
- new_timestamp = 4234567890u; |
- old_timestamp = 123; |
- EXPECT_EQ(-1, rtcp_peer.CheckForWrapAround(new_timestamp, old_timestamp)); |
-} |
- |
-TEST_F(RtcpTest, RtpTimestampInSenderTime) { |
- RtcpPeer rtcp_peer(cast_environment_, |
- &mock_sender_feedback_, |
- transport_sender_.get(), |
- &receiver_to_sender_, |
- NULL, |
- kRtcpReducedSize, |
- base::TimeDelta::FromMilliseconds(kRtcpIntervalMs), |
- kReceiverSsrc, |
- kSenderSsrc, |
- kCName); |
- int frequency = 32000; |
- uint32 rtp_timestamp = 64000; |
- base::TimeTicks rtp_timestamp_in_ticks; |
- |
- // Test fail before we get a OnReceivedLipSyncInfo. |
- EXPECT_FALSE(rtcp_peer.RtpTimestampInSenderTime( |
- frequency, rtp_timestamp, &rtp_timestamp_in_ticks)); |
- |
- uint32 ntp_seconds = 0; |
- uint32 ntp_fractions = 0; |
- uint64 input_time_us = 12345678901000LL; |
- base::TimeTicks input_time; |
- input_time += base::TimeDelta::FromMicroseconds(input_time_us); |
- |
- // Test exact match. |
- ConvertTimeTicksToNtp(input_time, &ntp_seconds, &ntp_fractions); |
- rtcp_peer.OnReceivedLipSyncInfo(rtp_timestamp, ntp_seconds, ntp_fractions); |
- EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime( |
- frequency, rtp_timestamp, &rtp_timestamp_in_ticks)); |
- EXPECT_EQ(input_time, rtp_timestamp_in_ticks); |
- |
- // Test older rtp_timestamp. |
- rtp_timestamp = 32000; |
- EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime( |
- frequency, rtp_timestamp, &rtp_timestamp_in_ticks)); |
- EXPECT_EQ(input_time - base::TimeDelta::FromMilliseconds(1000), |
- rtp_timestamp_in_ticks); |
- |
- // Test older rtp_timestamp with wrap. |
- rtp_timestamp = 4294903296u; |
- EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime( |
- frequency, rtp_timestamp, &rtp_timestamp_in_ticks)); |
- EXPECT_EQ(input_time - base::TimeDelta::FromMilliseconds(4000), |
- rtp_timestamp_in_ticks); |
- |
- // Test newer rtp_timestamp. |
- rtp_timestamp = 128000; |
- EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime( |
- frequency, rtp_timestamp, &rtp_timestamp_in_ticks)); |
- EXPECT_EQ(input_time + base::TimeDelta::FromMilliseconds(2000), |
- rtp_timestamp_in_ticks); |
- |
- // Test newer rtp_timestamp with wrap. |
- rtp_timestamp = 4294903296u; |
- rtcp_peer.OnReceivedLipSyncInfo(rtp_timestamp, ntp_seconds, ntp_fractions); |
- rtp_timestamp = 64000; |
- EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime( |
- frequency, rtp_timestamp, &rtp_timestamp_in_ticks)); |
- EXPECT_EQ(input_time + base::TimeDelta::FromMilliseconds(4000), |
- rtp_timestamp_in_ticks); |
+ EXPECT_NEAR((ntp_fraction_3 - ntp_fraction_2), 0xffffffff / 2, 1); |
} |
} // namespace cast |