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/pacing/paced_sender.h" | 7 #include "media/cast/pacing/paced_sender.h" |
8 #include "media/cast/rtcp/mock_rtcp_receiver_feedback.h" | 8 #include "media/cast/rtcp/mock_rtcp_receiver_feedback.h" |
9 #include "media/cast/rtcp/mock_rtcp_sender_feedback.h" | 9 #include "media/cast/rtcp/mock_rtcp_sender_feedback.h" |
10 #include "media/cast/rtcp/rtcp.h" | 10 #include "media/cast/rtcp/rtcp.h" |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 291 |
292 EXPECT_NEAR(2 * kAddedShortDelay, rtt.InMilliseconds(), 1); | 292 EXPECT_NEAR(2 * kAddedShortDelay, rtt.InMilliseconds(), 1); |
293 EXPECT_NEAR((2 * kAddedShortDelay + 2 * kAddedDelay) / 2, | 293 EXPECT_NEAR((2 * kAddedShortDelay + 2 * kAddedDelay) / 2, |
294 avg_rtt.InMilliseconds(), | 294 avg_rtt.InMilliseconds(), |
295 1); | 295 1); |
296 EXPECT_NEAR(2 * kAddedShortDelay, min_rtt.InMilliseconds(), 1); | 296 EXPECT_NEAR(2 * kAddedShortDelay, min_rtt.InMilliseconds(), 1); |
297 EXPECT_NEAR(2 * kAddedDelay, max_rtt.InMilliseconds(), 1); | 297 EXPECT_NEAR(2 * kAddedDelay, max_rtt.InMilliseconds(), 1); |
298 } | 298 } |
299 | 299 |
300 TEST_F(RtcpTest, NtpAndTime) { | 300 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; | 301 uint32 ntp_seconds = 0; |
312 uint32 ntp_fractions = 0; | 302 uint32 ntp_fractions = 0; |
| 303 uint64 input_time_us = 12345678901000LL; |
| 304 ConvertTimeToFractions(input_time_us, &ntp_seconds, &ntp_fractions); |
| 305 EXPECT_EQ(12345678u, ntp_seconds); |
313 base::TimeTicks input_time = base::TimeTicks::FromInternalValue( | 306 base::TimeTicks input_time = base::TimeTicks::FromInternalValue( |
314 12345678901000LL + kNtpEpochDeltaMicroseconds); | 307 input_time_us); |
315 ConvertTimeToNtp(input_time, &ntp_seconds, &ntp_fractions); | |
316 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, |
325 NULL, | 316 NULL, |
326 NULL, | 317 NULL, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 int frequency = 32000; | 351 int frequency = 32000; |
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; |
| 361 uint64 input_time_us = 12345678901000LL; |
370 base::TimeTicks input_time = base::TimeTicks::FromInternalValue( | 362 base::TimeTicks input_time = base::TimeTicks::FromInternalValue( |
371 12345678901000LL + kNtpEpochDeltaMicroseconds); | 363 input_time_us); |
372 | 364 |
373 // Test exact match. | 365 // Test exact match. |
374 ConvertTimeToNtp(input_time, &ntp_seconds, &ntp_fractions); | 366 ConvertTimeToFractions(input_time_us, &ntp_seconds, &ntp_fractions); |
375 rtcp_peer.OnReceivedLipSyncInfo(rtp_timestamp, ntp_seconds, ntp_fractions); | 367 rtcp_peer.OnReceivedLipSyncInfo(rtp_timestamp, ntp_seconds, ntp_fractions); |
376 EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime(frequency, rtp_timestamp, | 368 EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime(frequency, rtp_timestamp, |
377 &rtp_timestamp_in_ticks)); | 369 &rtp_timestamp_in_ticks)); |
378 EXPECT_EQ(input_time, rtp_timestamp_in_ticks); | 370 EXPECT_EQ(input_time, rtp_timestamp_in_ticks); |
379 | 371 |
380 // Test older rtp_timestamp. | 372 // Test older rtp_timestamp. |
381 rtp_timestamp = 32000; | 373 rtp_timestamp = 32000; |
382 EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime(frequency, rtp_timestamp, | 374 EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime(frequency, rtp_timestamp, |
383 &rtp_timestamp_in_ticks)); | 375 &rtp_timestamp_in_ticks)); |
384 EXPECT_EQ(input_time - base::TimeDelta::FromMilliseconds(1000), | 376 EXPECT_EQ(input_time - base::TimeDelta::FromMilliseconds(1000), |
(...skipping 18 matching lines...) Expand all Loading... |
403 rtcp_peer.OnReceivedLipSyncInfo(rtp_timestamp, ntp_seconds, ntp_fractions); | 395 rtcp_peer.OnReceivedLipSyncInfo(rtp_timestamp, ntp_seconds, ntp_fractions); |
404 rtp_timestamp = 64000; | 396 rtp_timestamp = 64000; |
405 EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime(frequency, rtp_timestamp, | 397 EXPECT_TRUE(rtcp_peer.RtpTimestampInSenderTime(frequency, rtp_timestamp, |
406 &rtp_timestamp_in_ticks)); | 398 &rtp_timestamp_in_ticks)); |
407 EXPECT_EQ(input_time + base::TimeDelta::FromMilliseconds(4000), | 399 EXPECT_EQ(input_time + base::TimeDelta::FromMilliseconds(4000), |
408 rtp_timestamp_in_ticks); | 400 rtp_timestamp_in_ticks); |
409 } | 401 } |
410 | 402 |
411 } // namespace cast | 403 } // namespace cast |
412 } // namespace media | 404 } // namespace media |
OLD | NEW |