OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/test/simple_test_tick_clock.h" | 10 #include "base/test/simple_test_tick_clock.h" |
11 #include "media/base/media.h" | 11 #include "media/base/media.h" |
12 #include "media/cast/cast_config.h" | 12 #include "media/cast/cast_config.h" |
13 #include "media/cast/cast_environment.h" | 13 #include "media/cast/cast_environment.h" |
14 #include "media/cast/net/cast_transport_config.h" | 14 #include "media/cast/net/cast_transport_config.h" |
15 #include "media/cast/net/cast_transport_sender_impl.h" | 15 #include "media/cast/net/cast_transport_sender_impl.h" |
16 #include "media/cast/sender/audio_sender.h" | 16 #include "media/cast/sender/audio_sender.h" |
17 #include "media/cast/test/fake_single_thread_task_runner.h" | 17 #include "media/cast/test/fake_single_thread_task_runner.h" |
18 #include "media/cast/test/utility/audio_utility.h" | 18 #include "media/cast/test/utility/audio_utility.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 namespace media { | 21 namespace media { |
22 namespace cast { | 22 namespace cast { |
23 | 23 |
| 24 namespace { |
| 25 |
| 26 void SaveOperationalStatus(OperationalStatus* out_status, |
| 27 OperationalStatus in_status) { |
| 28 DVLOG(1) << "OperationalStatus transitioning from " << *out_status << " to " |
| 29 << in_status; |
| 30 *out_status = in_status; |
| 31 } |
| 32 |
| 33 } // namespace |
| 34 |
24 class TestPacketSender : public PacketSender { | 35 class TestPacketSender : public PacketSender { |
25 public: | 36 public: |
26 TestPacketSender() : number_of_rtp_packets_(0), number_of_rtcp_packets_(0) {} | 37 TestPacketSender() : number_of_rtp_packets_(0), number_of_rtcp_packets_(0) {} |
27 | 38 |
28 bool SendPacket(PacketRef packet, const base::Closure& cb) override { | 39 bool SendPacket(PacketRef packet, const base::Closure& cb) override { |
29 if (Rtcp::IsRtcpPacket(&packet->data[0], packet->data.size())) { | 40 if (Rtcp::IsRtcpPacket(&packet->data[0], packet->data.size())) { |
30 ++number_of_rtcp_packets_; | 41 ++number_of_rtcp_packets_; |
31 } else { | 42 } else { |
32 // Check that at least one RTCP packet was sent before the first RTP | 43 // Check that at least one RTCP packet was sent before the first RTP |
33 // packet. This confirms that the receiver will have the necessary lip | 44 // packet. This confirms that the receiver will have the necessary lip |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 testing_clock_, | 90 testing_clock_, |
80 net::IPEndPoint(), | 91 net::IPEndPoint(), |
81 dummy_endpoint, | 92 dummy_endpoint, |
82 make_scoped_ptr(new base::DictionaryValue), | 93 make_scoped_ptr(new base::DictionaryValue), |
83 base::Bind(&UpdateCastTransportStatus), | 94 base::Bind(&UpdateCastTransportStatus), |
84 BulkRawEventsCallback(), | 95 BulkRawEventsCallback(), |
85 base::TimeDelta(), | 96 base::TimeDelta(), |
86 task_runner_, | 97 task_runner_, |
87 PacketReceiverCallback(), | 98 PacketReceiverCallback(), |
88 &transport_)); | 99 &transport_)); |
| 100 OperationalStatus operational_status = STATUS_UNINITIALIZED; |
89 audio_sender_.reset(new AudioSender( | 101 audio_sender_.reset(new AudioSender( |
90 cast_environment_, audio_config_, transport_sender_.get())); | 102 cast_environment_, |
| 103 audio_config_, |
| 104 base::Bind(&SaveOperationalStatus, &operational_status), |
| 105 transport_sender_.get())); |
91 task_runner_->RunTasks(); | 106 task_runner_->RunTasks(); |
| 107 CHECK_EQ(STATUS_INITIALIZED, operational_status); |
92 } | 108 } |
93 | 109 |
94 ~AudioSenderTest() override {} | 110 ~AudioSenderTest() override {} |
95 | 111 |
96 static void UpdateCastTransportStatus(CastTransportStatus status) { | 112 static void UpdateCastTransportStatus(CastTransportStatus status) { |
97 EXPECT_EQ(TRANSPORT_AUDIO_INITIALIZED, status); | 113 EXPECT_EQ(TRANSPORT_AUDIO_INITIALIZED, status); |
98 } | 114 } |
99 | 115 |
100 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. | 116 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. |
101 TestPacketSender transport_; | 117 TestPacketSender transport_; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 base::TimeDelta max_rtcp_timeout = | 151 base::TimeDelta max_rtcp_timeout = |
136 base::TimeDelta::FromMilliseconds(1 + kDefaultRtcpIntervalMs * 3 / 2); | 152 base::TimeDelta::FromMilliseconds(1 + kDefaultRtcpIntervalMs * 3 / 2); |
137 testing_clock_->Advance(max_rtcp_timeout); | 153 testing_clock_->Advance(max_rtcp_timeout); |
138 task_runner_->RunTasks(); | 154 task_runner_->RunTasks(); |
139 EXPECT_LE(1, transport_.number_of_rtp_packets()); | 155 EXPECT_LE(1, transport_.number_of_rtp_packets()); |
140 EXPECT_LE(1, transport_.number_of_rtcp_packets()); | 156 EXPECT_LE(1, transport_.number_of_rtcp_packets()); |
141 } | 157 } |
142 | 158 |
143 } // namespace cast | 159 } // namespace cast |
144 } // namespace media | 160 } // namespace media |
OLD | NEW |