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_NET_UDP_TRANSPORT_H_ | 5 #ifndef MEDIA_CAST_NET_UDP_TRANSPORT_H_ |
6 #define MEDIA_CAST_NET_UDP_TRANSPORT_H_ | 6 #define MEDIA_CAST_NET_UDP_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 "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 class UdpTransport : public PacketSender { | 28 class UdpTransport : public PacketSender { |
29 public: | 29 public: |
30 // Construct a UDP transport. | 30 // Construct a UDP transport. |
31 // All methods must be called on |io_thread_proxy|. | 31 // All methods must be called on |io_thread_proxy|. |
32 // |local_end_point| specifies the address and port to bind and listen | 32 // |local_end_point| specifies the address and port to bind and listen |
33 // to incoming packets. If the value is 0.0.0.0:0 then a bind is not | 33 // to incoming packets. If the value is 0.0.0.0:0 then a bind is not |
34 // performed. | 34 // performed. |
35 // |remote_end_point| specifies the address and port to send packets | 35 // |remote_end_point| specifies the address and port to send packets |
36 // to. If the value is 0.0.0.0:0 the the end point is set to the source | 36 // to. If the value is 0.0.0.0:0 the the end point is set to the source |
37 // address of the first packet received. | 37 // address of the first packet received. |
| 38 // |send_buffer_size| specifies the size of the socket send buffer. |
38 UdpTransport( | 39 UdpTransport( |
39 net::NetLog* net_log, | 40 net::NetLog* net_log, |
40 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_proxy, | 41 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_proxy, |
41 const net::IPEndPoint& local_end_point, | 42 const net::IPEndPoint& local_end_point, |
42 const net::IPEndPoint& remote_end_point, | 43 const net::IPEndPoint& remote_end_point, |
| 44 int32 send_buffer_size, |
43 const CastTransportStatusCallback& status_callback); | 45 const CastTransportStatusCallback& status_callback); |
44 virtual ~UdpTransport(); | 46 virtual ~UdpTransport(); |
45 | 47 |
46 // Start receiving packets. Packets are submitted to |packet_receiver|. | 48 // Start receiving packets. Packets are submitted to |packet_receiver|. |
47 void StartReceiving(const PacketReceiverCallback& packet_receiver); | 49 void StartReceiving(const PacketReceiverCallback& packet_receiver); |
48 | 50 |
49 // Set a new DSCP value to the socket. The value will be set right before | 51 // Set a new DSCP value to the socket. The value will be set right before |
50 // the next send. | 52 // the next send. |
51 void SetDscp(net::DiffServCodePoint dscp); | 53 void SetDscp(net::DiffServCodePoint dscp); |
52 | 54 |
(...skipping 22 matching lines...) Expand all Loading... |
75 net::IPEndPoint remote_addr_; | 77 net::IPEndPoint remote_addr_; |
76 const scoped_ptr<net::UDPSocket> udp_socket_; | 78 const scoped_ptr<net::UDPSocket> udp_socket_; |
77 bool send_pending_; | 79 bool send_pending_; |
78 bool receive_pending_; | 80 bool receive_pending_; |
79 bool client_connected_; | 81 bool client_connected_; |
80 net::DiffServCodePoint next_dscp_value_; | 82 net::DiffServCodePoint next_dscp_value_; |
81 scoped_ptr<Packet> next_packet_; | 83 scoped_ptr<Packet> next_packet_; |
82 scoped_refptr<net::WrappedIOBuffer> recv_buf_; | 84 scoped_refptr<net::WrappedIOBuffer> recv_buf_; |
83 net::IPEndPoint recv_addr_; | 85 net::IPEndPoint recv_addr_; |
84 PacketReceiverCallback packet_receiver_; | 86 PacketReceiverCallback packet_receiver_; |
| 87 int32 send_buffer_size_; |
85 const CastTransportStatusCallback status_callback_; | 88 const CastTransportStatusCallback status_callback_; |
86 int bytes_sent_; | 89 int bytes_sent_; |
87 | 90 |
88 // NOTE: Weak pointers must be invalidated before all other member variables. | 91 // NOTE: Weak pointers must be invalidated before all other member variables. |
89 base::WeakPtrFactory<UdpTransport> weak_factory_; | 92 base::WeakPtrFactory<UdpTransport> weak_factory_; |
90 | 93 |
91 DISALLOW_COPY_AND_ASSIGN(UdpTransport); | 94 DISALLOW_COPY_AND_ASSIGN(UdpTransport); |
92 }; | 95 }; |
93 | 96 |
94 } // namespace cast | 97 } // namespace cast |
95 } // namespace media | 98 } // namespace media |
96 | 99 |
97 #endif // MEDIA_CAST_NET_UDP_TRANSPORT_H_ | 100 #endif // MEDIA_CAST_NET_UDP_TRANSPORT_H_ |
OLD | NEW |