| 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 25 matching lines...) Expand all Loading... |
| 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 // |send_buffer_size| specifies the size of the socket send buffer. |
| 39 UdpTransport( | 39 UdpTransport( |
| 40 net::NetLog* net_log, | 40 net::NetLog* net_log, |
| 41 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_proxy, | 41 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_proxy, |
| 42 const net::IPEndPoint& local_end_point, | 42 const net::IPEndPoint& local_end_point, |
| 43 const net::IPEndPoint& remote_end_point, | 43 const net::IPEndPoint& remote_end_point, |
| 44 int32 send_buffer_size, | 44 int32 send_buffer_size, |
| 45 const CastTransportStatusCallback& status_callback); | 45 const CastTransportStatusCallback& status_callback); |
| 46 virtual ~UdpTransport(); | 46 ~UdpTransport() override; |
| 47 | 47 |
| 48 // Start receiving packets. Packets are submitted to |packet_receiver|. | 48 // Start receiving packets. Packets are submitted to |packet_receiver|. |
| 49 void StartReceiving(const PacketReceiverCallback& packet_receiver); | 49 void StartReceiving(const PacketReceiverCallback& packet_receiver); |
| 50 | 50 |
| 51 // 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 |
| 52 // the next send. | 52 // the next send. |
| 53 void SetDscp(net::DiffServCodePoint dscp); | 53 void SetDscp(net::DiffServCodePoint dscp); |
| 54 | 54 |
| 55 // PacketSender implementations. | 55 // PacketSender implementations. |
| 56 virtual bool SendPacket(PacketRef packet, | 56 bool SendPacket(PacketRef packet, const base::Closure& cb) override; |
| 57 const base::Closure& cb) override; | 57 int64 GetBytesSent() override; |
| 58 virtual int64 GetBytesSent() override; | |
| 59 | 58 |
| 60 private: | 59 private: |
| 61 // Requests and processes packets from |udp_socket_|. This method is called | 60 // Requests and processes packets from |udp_socket_|. This method is called |
| 62 // once with |length_or_status| set to net::ERR_IO_PENDING to start receiving | 61 // once with |length_or_status| set to net::ERR_IO_PENDING to start receiving |
| 63 // packets. Thereafter, it is called with some other value as the callback | 62 // packets. Thereafter, it is called with some other value as the callback |
| 64 // response from UdpSocket::RecvFrom(). | 63 // response from UdpSocket::RecvFrom(). |
| 65 void ReceiveNextPacket(int length_or_status); | 64 void ReceiveNextPacket(int length_or_status); |
| 66 | 65 |
| 67 // Schedule packet receiving, if needed. | 66 // Schedule packet receiving, if needed. |
| 68 void ScheduleReceiveNextPacket(); | 67 void ScheduleReceiveNextPacket(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 91 // NOTE: Weak pointers must be invalidated before all other member variables. | 90 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 92 base::WeakPtrFactory<UdpTransport> weak_factory_; | 91 base::WeakPtrFactory<UdpTransport> weak_factory_; |
| 93 | 92 |
| 94 DISALLOW_COPY_AND_ASSIGN(UdpTransport); | 93 DISALLOW_COPY_AND_ASSIGN(UdpTransport); |
| 95 }; | 94 }; |
| 96 | 95 |
| 97 } // namespace cast | 96 } // namespace cast |
| 98 } // namespace media | 97 } // namespace media |
| 99 | 98 |
| 100 #endif // MEDIA_CAST_NET_UDP_TRANSPORT_H_ | 99 #endif // MEDIA_CAST_NET_UDP_TRANSPORT_H_ |
| OLD | NEW |