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 class TestPacketSender : public PacketSender { | 24 class TestPacketSender : public PacketSender { |
25 public: | 25 public: |
26 TestPacketSender() : number_of_rtp_packets_(0), number_of_rtcp_packets_(0) {} | 26 TestPacketSender() : number_of_rtp_packets_(0), number_of_rtcp_packets_(0) {} |
27 | 27 |
28 virtual bool SendPacket(PacketRef packet, | 28 virtual bool SendPacket(PacketRef packet, |
29 const base::Closure& cb) OVERRIDE { | 29 const base::Closure& cb) override { |
30 if (Rtcp::IsRtcpPacket(&packet->data[0], packet->data.size())) { | 30 if (Rtcp::IsRtcpPacket(&packet->data[0], packet->data.size())) { |
31 ++number_of_rtcp_packets_; | 31 ++number_of_rtcp_packets_; |
32 } else { | 32 } else { |
33 // Check that at least one RTCP packet was sent before the first RTP | 33 // Check that at least one RTCP packet was sent before the first RTP |
34 // packet. This confirms that the receiver will have the necessary lip | 34 // packet. This confirms that the receiver will have the necessary lip |
35 // sync info before it has to calculate the playout time of the first | 35 // sync info before it has to calculate the playout time of the first |
36 // frame. | 36 // frame. |
37 if (number_of_rtp_packets_ == 0) | 37 if (number_of_rtp_packets_ == 0) |
38 EXPECT_LE(1, number_of_rtcp_packets_); | 38 EXPECT_LE(1, number_of_rtcp_packets_); |
39 ++number_of_rtp_packets_; | 39 ++number_of_rtp_packets_; |
40 } | 40 } |
41 return true; | 41 return true; |
42 } | 42 } |
43 | 43 |
44 virtual int64 GetBytesSent() OVERRIDE { | 44 virtual int64 GetBytesSent() override { |
45 return 0; | 45 return 0; |
46 } | 46 } |
47 | 47 |
48 int number_of_rtp_packets() const { return number_of_rtp_packets_; } | 48 int number_of_rtp_packets() const { return number_of_rtp_packets_; } |
49 | 49 |
50 int number_of_rtcp_packets() const { return number_of_rtcp_packets_; } | 50 int number_of_rtcp_packets() const { return number_of_rtcp_packets_; } |
51 | 51 |
52 private: | 52 private: |
53 int number_of_rtp_packets_; | 53 int number_of_rtp_packets_; |
54 int number_of_rtcp_packets_; | 54 int number_of_rtcp_packets_; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 base::TimeDelta max_rtcp_timeout = | 136 base::TimeDelta max_rtcp_timeout = |
137 base::TimeDelta::FromMilliseconds(1 + kDefaultRtcpIntervalMs * 3 / 2); | 137 base::TimeDelta::FromMilliseconds(1 + kDefaultRtcpIntervalMs * 3 / 2); |
138 testing_clock_->Advance(max_rtcp_timeout); | 138 testing_clock_->Advance(max_rtcp_timeout); |
139 task_runner_->RunTasks(); | 139 task_runner_->RunTasks(); |
140 EXPECT_LE(1, transport_.number_of_rtp_packets()); | 140 EXPECT_LE(1, transport_.number_of_rtp_packets()); |
141 EXPECT_LE(1, transport_.number_of_rtcp_packets()); | 141 EXPECT_LE(1, transport_.number_of_rtcp_packets()); |
142 } | 142 } |
143 | 143 |
144 } // namespace cast | 144 } // namespace cast |
145 } // namespace media | 145 } // namespace media |
OLD | NEW |