| 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 public: | 28 public: |
| 29 // Construct a UDP transport. | 29 // Construct a UDP transport. |
| 30 // All methods must be called on |io_thread_proxy|. | 30 // All methods must be called on |io_thread_proxy|. |
| 31 // |local_end_point| specifies the address and port to bind and listen | 31 // |local_end_point| specifies the address and port to bind and listen |
| 32 // to incoming packets. If the value is 0.0.0.0:0 then a bind is not | 32 // to incoming packets. If the value is 0.0.0.0:0 then a bind is not |
| 33 // performed. | 33 // performed. |
| 34 // |remote_end_point| specifies the address and port to send packets | 34 // |remote_end_point| specifies the address and port to send packets |
| 35 // to. If the value is 0.0.0.0:0 the the end point is set to the source | 35 // to. If the value is 0.0.0.0:0 the the end point is set to the source |
| 36 // address of the first packet received. | 36 // address of the first packet received. |
| 37 // |send_buffer_size| specifies the size of the socket send buffer. | 37 // |send_buffer_size| specifies the size of the socket send buffer. |
| 38 UdpTransport( | 38 UdpTransport(const CastTransportSender::CreateParams& params, |
| 39 net::NetLog* net_log, | 39 int32 send_buffer_size); |
| 40 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_proxy, | |
| 41 const net::IPEndPoint& local_end_point, | |
| 42 const net::IPEndPoint& remote_end_point, | |
| 43 int32 send_buffer_size, | |
| 44 const CastTransportStatusCallback& status_callback); | |
| 45 ~UdpTransport() final; | 40 ~UdpTransport() final; |
| 46 | 41 |
| 47 // Start receiving packets. Packets are submitted to |packet_receiver|. | 42 // Start receiving packets. Packets are submitted to |packet_receiver|. |
| 48 void StartReceiving(const PacketReceiverCallbackWithStatus& packet_receiver); | 43 void StartReceiving(const PacketReceiverCallbackWithStatus& packet_receiver); |
| 49 void StopReceiving(); | 44 void StopReceiving(); |
| 50 | 45 |
| 51 // Set a new DSCP value to the socket. The value will be set right before | 46 // Set a new DSCP value to the socket. The value will be set right before |
| 52 // the next send. | 47 // the next send. |
| 53 void SetDscp(net::DiffServCodePoint dscp); | 48 void SetDscp(net::DiffServCodePoint dscp); |
| 54 | 49 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 69 void ReceiveNextPacket(int length_or_status); | 64 void ReceiveNextPacket(int length_or_status); |
| 70 | 65 |
| 71 // Schedule packet receiving, if needed. | 66 // Schedule packet receiving, if needed. |
| 72 void ScheduleReceiveNextPacket(); | 67 void ScheduleReceiveNextPacket(); |
| 73 | 68 |
| 74 void OnSent(const scoped_refptr<net::IOBuffer>& buf, | 69 void OnSent(const scoped_refptr<net::IOBuffer>& buf, |
| 75 PacketRef packet, | 70 PacketRef packet, |
| 76 const base::Closure& cb, | 71 const base::Closure& cb, |
| 77 int result); | 72 int result); |
| 78 | 73 |
| 74 CastTransportSender::Client* transport_client_; |
| 79 const scoped_refptr<base::SingleThreadTaskRunner> io_thread_proxy_; | 75 const scoped_refptr<base::SingleThreadTaskRunner> io_thread_proxy_; |
| 80 const net::IPEndPoint local_addr_; | 76 const net::IPEndPoint local_addr_; |
| 81 net::IPEndPoint remote_addr_; | 77 net::IPEndPoint remote_addr_; |
| 82 scoped_ptr<net::UDPSocket> udp_socket_; | 78 scoped_ptr<net::UDPSocket> udp_socket_; |
| 83 bool send_pending_; | 79 bool send_pending_; |
| 84 bool receive_pending_; | 80 bool receive_pending_; |
| 85 bool client_connected_; | 81 bool client_connected_; |
| 86 net::DiffServCodePoint next_dscp_value_; | 82 net::DiffServCodePoint next_dscp_value_; |
| 87 scoped_ptr<Packet> next_packet_; | 83 scoped_ptr<Packet> next_packet_; |
| 88 scoped_refptr<net::WrappedIOBuffer> recv_buf_; | 84 scoped_refptr<net::WrappedIOBuffer> recv_buf_; |
| 89 net::IPEndPoint recv_addr_; | 85 net::IPEndPoint recv_addr_; |
| 90 PacketReceiverCallbackWithStatus packet_receiver_; | 86 PacketReceiverCallbackWithStatus packet_receiver_; |
| 91 int32 send_buffer_size_; | 87 int32 send_buffer_size_; |
| 92 const CastTransportStatusCallback status_callback_; | |
| 93 int bytes_sent_; | 88 int bytes_sent_; |
| 94 | 89 |
| 95 // NOTE: Weak pointers must be invalidated before all other member variables. | 90 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 96 base::WeakPtrFactory<UdpTransport> weak_factory_; | 91 base::WeakPtrFactory<UdpTransport> weak_factory_; |
| 97 | 92 |
| 98 DISALLOW_COPY_AND_ASSIGN(UdpTransport); | 93 DISALLOW_COPY_AND_ASSIGN(UdpTransport); |
| 99 }; | 94 }; |
| 100 | 95 |
| 101 } // namespace cast | 96 } // namespace cast |
| 102 } // namespace media | 97 } // namespace media |
| 103 | 98 |
| 104 #endif // MEDIA_CAST_NET_UDP_TRANSPORT_H_ | 99 #endif // MEDIA_CAST_NET_UDP_TRANSPORT_H_ |
| OLD | NEW |