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 "base/test/simple_test_tick_clock.h" | 5 #include "base/test/simple_test_tick_clock.h" |
6 #include "media/cast/cast_defines.h" | 6 #include "media/cast/cast_defines.h" |
| 7 #include "media/cast/cast_ntp_tick_clock.h" |
7 #include "media/cast/pacing/paced_sender.h" | 8 #include "media/cast/pacing/paced_sender.h" |
8 #include "media/cast/rtcp/mock_rtcp_receiver_feedback.h" | 9 #include "media/cast/rtcp/mock_rtcp_receiver_feedback.h" |
9 #include "media/cast/rtcp/mock_rtcp_sender_feedback.h" | 10 #include "media/cast/rtcp/mock_rtcp_sender_feedback.h" |
10 #include "media/cast/rtcp/rtcp.h" | 11 #include "media/cast/rtcp/rtcp.h" |
11 #include "media/cast/rtcp/test_rtcp_packet_builder.h" | 12 #include "media/cast/rtcp/test_rtcp_packet_builder.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
13 | 14 |
14 namespace media { | 15 namespace media { |
15 namespace cast { | 16 namespace cast { |
16 | 17 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 292 |
292 EXPECT_NEAR(2 * kAddedShortDelay, rtt.InMilliseconds(), 1); | 293 EXPECT_NEAR(2 * kAddedShortDelay, rtt.InMilliseconds(), 1); |
293 EXPECT_NEAR((2 * kAddedShortDelay + 2 * kAddedDelay) / 2, | 294 EXPECT_NEAR((2 * kAddedShortDelay + 2 * kAddedDelay) / 2, |
294 avg_rtt.InMilliseconds(), | 295 avg_rtt.InMilliseconds(), |
295 1); | 296 1); |
296 EXPECT_NEAR(2 * kAddedShortDelay, min_rtt.InMilliseconds(), 1); | 297 EXPECT_NEAR(2 * kAddedShortDelay, min_rtt.InMilliseconds(), 1); |
297 EXPECT_NEAR(2 * kAddedDelay, max_rtt.InMilliseconds(), 1); | 298 EXPECT_NEAR(2 * kAddedDelay, max_rtt.InMilliseconds(), 1); |
298 } | 299 } |
299 | 300 |
300 TEST_F(RtcpTest, NtpAndTime) { | 301 TEST_F(RtcpTest, NtpAndTime) { |
301 RtcpPeer rtcp_peer(&testing_clock_, | |
302 &mock_sender_feedback_, | |
303 NULL, | |
304 NULL, | |
305 NULL, | |
306 kRtcpReducedSize, | |
307 base::TimeDelta::FromMilliseconds(kRtcpIntervalMs), | |
308 false, | |
309 kReceiverSsrc, | |
310 kCName); | |
311 uint32 ntp_seconds = 0; | 302 uint32 ntp_seconds = 0; |
312 uint32 ntp_fractions = 0; | 303 uint32 ntp_fractions = 0; |
313 base::TimeTicks input_time = base::TimeTicks::FromInternalValue( | 304 base::TimeTicks input_time = base::TimeTicks::FromInternalValue( |
314 12345678901000LL + kNtpEpochDeltaMicroseconds); | 305 12345678901000LL); |
315 ConvertTimeToNtp(input_time, &ntp_seconds, &ntp_fractions); | 306 ConvertTimeToNtp(input_time, &ntp_seconds, &ntp_fractions); |
316 EXPECT_EQ(12345678u, ntp_seconds); | 307 EXPECT_EQ(12345678u, ntp_seconds); |
317 EXPECT_EQ(input_time, | 308 EXPECT_EQ(input_time, |
318 ConvertNtpToTime(ntp_seconds, ntp_fractions)); | 309 ConvertNtpToTime(ntp_seconds, ntp_fractions)); |
319 } | 310 } |
320 | 311 |
321 TEST_F(RtcpTest, WrapAround) { | 312 TEST_F(RtcpTest, WrapAround) { |
322 RtcpPeer rtcp_peer(&testing_clock_, | 313 RtcpPeer rtcp_peer(&testing_clock_, |
323 &mock_sender_feedback_, | 314 &mock_sender_feedback_, |
324 NULL, | 315 NULL, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 uint32 rtp_timestamp = 64000; | 352 uint32 rtp_timestamp = 64000; |
362 base::TimeTicks rtp_timestamp_in_ticks; | 353 base::TimeTicks rtp_timestamp_in_ticks; |
363 | 354 |
364 // Test fail before we get a OnReceivedLipSyncInfo. | 355 // Test fail before we get a OnReceivedLipSyncInfo. |
365 EXPECT_FALSE(rtcp_peer.RtpTimestampInSenderTime(frequency, rtp_timestamp, | 356 EXPECT_FALSE(rtcp_peer.RtpTimestampInSenderTime(frequency, rtp_timestamp, |
366 &rtp_timestamp_in_ticks)); | 357 &rtp_timestamp_in_ticks)); |
367 | 358 |
368 uint32 ntp_seconds = 0; | 359 uint32 ntp_seconds = 0; |
369 uint32 ntp_fractions = 0; | 360 uint32 ntp_fractions = 0; |
370 base::TimeTicks input_time = base::TimeTicks::FromInternalValue( | 361 base::TimeTicks input_time = base::TimeTicks::FromInternalValue( |
371 12345678901000LL + kNtpEpochDeltaMicroseconds); | 362 12345678901000LL); |
372 | 363 |
373 // Test exact match. | 364 // Test exact match. |
374 ConvertTimeToNtp(input_time, &ntp_seconds, &ntp_fractions); | 365 ConvertTimeToNtp(input_time, &ntp_seconds, &ntp_fractions); |
375 rtcp_peer.OnReceivedLipSyncInfo(rtp_timestamp, ntp_seconds, ntp_fractions); | 366 rtcp_peer.OnReceivedLipSyncInfo(rtp_timestamp, ntp_seconds, ntp_fractions); |
376 EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime(frequency, rtp_timestamp, | 367 EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime(frequency, rtp_timestamp, |
377 &rtp_timestamp_in_ticks)); | 368 &rtp_timestamp_in_ticks)); |
378 EXPECT_EQ(input_time, rtp_timestamp_in_ticks); | 369 EXPECT_EQ(input_time, rtp_timestamp_in_ticks); |
379 | 370 |
380 // Test older rtp_timestamp. | 371 // Test older rtp_timestamp. |
381 rtp_timestamp = 32000; | 372 rtp_timestamp = 32000; |
(...skipping 21 matching lines...) Expand all Loading... |
403 rtcp_peer.OnReceivedLipSyncInfo(rtp_timestamp, ntp_seconds, ntp_fractions); | 394 rtcp_peer.OnReceivedLipSyncInfo(rtp_timestamp, ntp_seconds, ntp_fractions); |
404 rtp_timestamp = 64000; | 395 rtp_timestamp = 64000; |
405 EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime(frequency, rtp_timestamp, | 396 EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime(frequency, rtp_timestamp, |
406 &rtp_timestamp_in_ticks)); | 397 &rtp_timestamp_in_ticks)); |
407 EXPECT_EQ(input_time + base::TimeDelta::FromMilliseconds(4000), | 398 EXPECT_EQ(input_time + base::TimeDelta::FromMilliseconds(4000), |
408 rtp_timestamp_in_ticks); | 399 rtp_timestamp_in_ticks); |
409 } | 400 } |
410 | 401 |
411 } // namespace cast | 402 } // namespace cast |
412 } // namespace media | 403 } // namespace media |
OLD | NEW |