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/big_endian.h" | 7 #include "base/big_endian.h" |
8 #include "base/test/simple_test_tick_clock.h" | 8 #include "base/test/simple_test_tick_clock.h" |
| 9 #include "media/cast/logging/logging_impl.h" |
9 #include "media/cast/logging/simple_event_subscriber.h" | 10 #include "media/cast/logging/simple_event_subscriber.h" |
| 11 #include "media/cast/net/pacing/paced_sender.h" |
10 #include "media/cast/test/fake_single_thread_task_runner.h" | 12 #include "media/cast/test/fake_single_thread_task_runner.h" |
11 #include "media/cast/transport/pacing/paced_sender.h" | |
12 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
13 | 14 |
| 15 using testing::_; |
| 16 |
14 namespace media { | 17 namespace media { |
15 namespace cast { | 18 namespace cast { |
16 namespace transport { | 19 namespace { |
17 | |
18 using testing::_; | |
19 | 20 |
20 static const uint8 kValue = 123; | 21 static const uint8 kValue = 123; |
21 static const size_t kSize1 = 100; | 22 static const size_t kSize1 = 100; |
22 static const size_t kSize2 = 101; | 23 static const size_t kSize2 = 101; |
23 static const size_t kSize3 = 102; | 24 static const size_t kSize3 = 102; |
24 static const size_t kSize4 = 103; | 25 static const size_t kSize4 = 103; |
25 static const size_t kNackSize = 104; | 26 static const size_t kNackSize = 104; |
26 static const int64 kStartMillisecond = INT64_C(12345678900000); | 27 static const int64 kStartMillisecond = INT64_C(12345678900000); |
27 static const uint32 kVideoSsrc = 0x1234; | 28 static const uint32 kVideoSsrc = 0x1234; |
28 static const uint32 kAudioSsrc = 0x5678; | 29 static const uint32 kAudioSsrc = 0x5678; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 paced_sender_.reset(new PacedSender( | 62 paced_sender_.reset(new PacedSender( |
62 &testing_clock_, &logging_, &mock_transport_, task_runner_)); | 63 &testing_clock_, &logging_, &mock_transport_, task_runner_)); |
63 paced_sender_->RegisterAudioSsrc(kAudioSsrc); | 64 paced_sender_->RegisterAudioSsrc(kAudioSsrc); |
64 paced_sender_->RegisterVideoSsrc(kVideoSsrc); | 65 paced_sender_->RegisterVideoSsrc(kVideoSsrc); |
65 } | 66 } |
66 | 67 |
67 virtual ~PacedSenderTest() { | 68 virtual ~PacedSenderTest() { |
68 logging_.RemoveRawEventSubscriber(&subscriber_); | 69 logging_.RemoveRawEventSubscriber(&subscriber_); |
69 } | 70 } |
70 | 71 |
71 static void UpdateCastTransportStatus(transport::CastTransportStatus status) { | 72 static void UpdateCastTransportStatus(CastTransportStatus status) { |
72 NOTREACHED(); | 73 NOTREACHED(); |
73 } | 74 } |
74 | 75 |
75 SendPacketVector CreateSendPacketVector(size_t packet_size, | 76 SendPacketVector CreateSendPacketVector(size_t packet_size, |
76 int num_of_packets_in_frame, | 77 int num_of_packets_in_frame, |
77 bool audio) { | 78 bool audio) { |
78 DCHECK_GE(packet_size, 12u); | 79 DCHECK_GE(packet_size, 12u); |
79 SendPacketVector packets; | 80 SendPacketVector packets; |
80 base::TimeTicks frame_tick = testing_clock_.NowTicks(); | 81 base::TimeTicks frame_tick = testing_clock_.NowTicks(); |
81 // Advance the clock so that we don't get the same frame_tick | 82 // Advance the clock so that we don't get the same frame_tick |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 LoggingImpl logging_; | 118 LoggingImpl logging_; |
118 SimpleEventSubscriber subscriber_; | 119 SimpleEventSubscriber subscriber_; |
119 base::SimpleTestTickClock testing_clock_; | 120 base::SimpleTestTickClock testing_clock_; |
120 TestPacketSender mock_transport_; | 121 TestPacketSender mock_transport_; |
121 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; | 122 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; |
122 scoped_ptr<PacedSender> paced_sender_; | 123 scoped_ptr<PacedSender> paced_sender_; |
123 | 124 |
124 DISALLOW_COPY_AND_ASSIGN(PacedSenderTest); | 125 DISALLOW_COPY_AND_ASSIGN(PacedSenderTest); |
125 }; | 126 }; |
126 | 127 |
| 128 } // namespace |
| 129 |
127 TEST_F(PacedSenderTest, PassThroughRtcp) { | 130 TEST_F(PacedSenderTest, PassThroughRtcp) { |
128 mock_transport_.AddExpectedSize(kSize1, 2); | 131 mock_transport_.AddExpectedSize(kSize1, 2); |
129 SendPacketVector packets = CreateSendPacketVector(kSize1, 1, true); | 132 SendPacketVector packets = CreateSendPacketVector(kSize1, 1, true); |
130 | 133 |
131 EXPECT_TRUE(paced_sender_->SendPackets(packets)); | 134 EXPECT_TRUE(paced_sender_->SendPackets(packets)); |
132 EXPECT_TRUE(paced_sender_->ResendPackets(packets, base::TimeDelta())); | 135 EXPECT_TRUE(paced_sender_->ResendPackets(packets, base::TimeDelta())); |
133 | 136 |
134 mock_transport_.AddExpectedSize(kSize2, 1); | 137 mock_transport_.AddExpectedSize(kSize2, 1); |
135 Packet tmp(kSize2, kValue); | 138 Packet tmp(kSize2, kValue); |
136 EXPECT_TRUE(paced_sender_->SendRtcpPacket( | 139 EXPECT_TRUE(paced_sender_->SendRtcpPacket( |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 testing_clock_.Advance(timeout_10ms); | 342 testing_clock_.Advance(timeout_10ms); |
340 task_runner_->RunTasks(); | 343 task_runner_->RunTasks(); |
341 | 344 |
342 testing_clock_.Advance(timeout_10ms); | 345 testing_clock_.Advance(timeout_10ms); |
343 task_runner_->RunTasks(); | 346 task_runner_->RunTasks(); |
344 | 347 |
345 // No more packets. | 348 // No more packets. |
346 EXPECT_TRUE(RunUntilEmpty(5)); | 349 EXPECT_TRUE(RunUntilEmpty(5)); |
347 } | 350 } |
348 | 351 |
349 } // namespace transport | |
350 } // namespace cast | 352 } // namespace cast |
351 } // namespace media | 353 } // namespace media |
OLD | NEW |