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 #ifndef MEDIA_CAST_TEST_LOOPBACK_TRANSPORT_H_ | 5 #ifndef MEDIA_CAST_TEST_LOOPBACK_TRANSPORT_H_ |
6 #define MEDIA_CAST_TEST_LOOPBACK_TRANSPORT_H_ | 6 #define MEDIA_CAST_TEST_LOOPBACK_TRANSPORT_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "media/cast/cast_environment.h" | 10 #include "media/cast/cast_environment.h" |
11 #include "media/cast/transport/cast_transport_config.h" | 11 #include "media/cast/net/cast_transport_config.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class SingleThreadTaskRunner; | 14 class SingleThreadTaskRunner; |
15 class TickClock; | 15 class TickClock; |
16 } // namespace base | 16 } // namespace base |
17 | 17 |
18 namespace media { | 18 namespace media { |
19 namespace cast { | 19 namespace cast { |
20 | 20 |
21 namespace test { | 21 namespace test { |
22 class PacketPipe; | 22 class PacketPipe; |
23 } // namespace test | 23 } // namespace test |
24 | 24 |
25 // Class that sends the packet to a receiver through a stack of PacketPipes. | 25 // Class that sends the packet to a receiver through a stack of PacketPipes. |
26 class LoopBackTransport : public transport::PacketSender { | 26 class LoopBackTransport : public PacketSender { |
27 public: | 27 public: |
28 explicit LoopBackTransport( | 28 explicit LoopBackTransport( |
29 scoped_refptr<CastEnvironment> cast_environment); | 29 scoped_refptr<CastEnvironment> cast_environment); |
30 virtual ~LoopBackTransport(); | 30 virtual ~LoopBackTransport(); |
31 | 31 |
32 virtual bool SendPacket(transport::PacketRef packet, | 32 virtual bool SendPacket(PacketRef packet, |
33 const base::Closure& cb) OVERRIDE; | 33 const base::Closure& cb) OVERRIDE; |
34 | 34 |
35 // Initiailize this loopback transport. | 35 // Initiailize this loopback transport. |
36 // Establish a flow of packets from |pipe| to |packet_receiver|. | 36 // Establish a flow of packets from |pipe| to |packet_receiver|. |
37 // The data flow looks like: | 37 // The data flow looks like: |
38 // SendPacket() -> |pipe| -> Fake loopback pipe -> |packet_receiver|. | 38 // SendPacket() -> |pipe| -> Fake loopback pipe -> |packet_receiver|. |
39 void Initialize( | 39 void Initialize( |
40 scoped_ptr<test::PacketPipe> pipe, | 40 scoped_ptr<test::PacketPipe> pipe, |
41 const transport::PacketReceiverCallback& packet_receiver, | 41 const PacketReceiverCallback& packet_receiver, |
42 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 42 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
43 base::TickClock* clock); | 43 base::TickClock* clock); |
44 | 44 |
45 private: | 45 private: |
46 const scoped_refptr<CastEnvironment> cast_environment_; | 46 const scoped_refptr<CastEnvironment> cast_environment_; |
47 scoped_ptr<test::PacketPipe> packet_pipe_; | 47 scoped_ptr<test::PacketPipe> packet_pipe_; |
48 | 48 |
49 DISALLOW_COPY_AND_ASSIGN(LoopBackTransport); | 49 DISALLOW_COPY_AND_ASSIGN(LoopBackTransport); |
50 }; | 50 }; |
51 | 51 |
52 } // namespace cast | 52 } // namespace cast |
53 } // namespace media | 53 } // namespace media |
54 | 54 |
55 #endif // MEDIA_CAST_TEST_LOOPBACK_TRANSPORT_H_ | 55 #endif // MEDIA_CAST_TEST_LOOPBACK_TRANSPORT_H_ |
OLD | NEW |