Chromium Code Reviews| 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 "media/cast/net/udp_transport.h" | 5 #include "media/cast/net/udp_transport.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 addr1.address().end(), | 35 addr1.address().end(), |
| 36 addr2.address().begin()); | 36 addr2.address().begin()); |
| 37 } | 37 } |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 UdpTransport::UdpTransport( | 40 UdpTransport::UdpTransport( |
| 41 net::NetLog* net_log, | 41 net::NetLog* net_log, |
| 42 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_proxy, | 42 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_proxy, |
| 43 const net::IPEndPoint& local_end_point, | 43 const net::IPEndPoint& local_end_point, |
| 44 const net::IPEndPoint& remote_end_point, | 44 const net::IPEndPoint& remote_end_point, |
| 45 int32 send_buffer_size, | |
|
miu
2014/10/16 18:31:57
s/int32/int/
| |
| 45 const CastTransportStatusCallback& status_callback) | 46 const CastTransportStatusCallback& status_callback) |
| 46 : io_thread_proxy_(io_thread_proxy), | 47 : io_thread_proxy_(io_thread_proxy), |
| 47 local_addr_(local_end_point), | 48 local_addr_(local_end_point), |
| 48 remote_addr_(remote_end_point), | 49 remote_addr_(remote_end_point), |
| 49 udp_socket_(new net::UDPSocket(net::DatagramSocket::DEFAULT_BIND, | 50 udp_socket_(new net::UDPSocket(net::DatagramSocket::DEFAULT_BIND, |
| 50 net::RandIntCallback(), | 51 net::RandIntCallback(), |
| 51 net_log, | 52 net_log, |
| 52 net::NetLog::Source())), | 53 net::NetLog::Source())), |
| 53 send_pending_(false), | 54 send_pending_(false), |
| 54 receive_pending_(false), | 55 receive_pending_(false), |
| 55 client_connected_(false), | 56 client_connected_(false), |
| 56 next_dscp_value_(net::DSCP_NO_CHANGE), | 57 next_dscp_value_(net::DSCP_NO_CHANGE), |
| 58 send_buffer_size_(send_buffer_size), | |
| 57 status_callback_(status_callback), | 59 status_callback_(status_callback), |
| 58 bytes_sent_(0), | 60 bytes_sent_(0), |
| 59 weak_factory_(this) { | 61 weak_factory_(this) { |
| 60 DCHECK(!IsEmpty(local_end_point) || !IsEmpty(remote_end_point)); | 62 DCHECK(!IsEmpty(local_end_point) || !IsEmpty(remote_end_point)); |
| 61 } | 63 } |
| 62 | 64 |
| 63 UdpTransport::~UdpTransport() {} | 65 UdpTransport::~UdpTransport() {} |
| 64 | 66 |
| 65 void UdpTransport::StartReceiving( | 67 void UdpTransport::StartReceiving( |
| 66 const PacketReceiverCallback& packet_receiver) { | 68 const PacketReceiverCallback& packet_receiver) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 78 } else if (!IsEmpty(remote_addr_)) { | 80 } else if (!IsEmpty(remote_addr_)) { |
| 79 if (udp_socket_->Connect(remote_addr_) < 0) { | 81 if (udp_socket_->Connect(remote_addr_) < 0) { |
| 80 status_callback_.Run(TRANSPORT_SOCKET_ERROR); | 82 status_callback_.Run(TRANSPORT_SOCKET_ERROR); |
| 81 LOG(ERROR) << "Failed to connect to remote address."; | 83 LOG(ERROR) << "Failed to connect to remote address."; |
| 82 return; | 84 return; |
| 83 } | 85 } |
| 84 client_connected_ = true; | 86 client_connected_ = true; |
| 85 } else { | 87 } else { |
| 86 NOTREACHED() << "Either local or remote address has to be defined."; | 88 NOTREACHED() << "Either local or remote address has to be defined."; |
| 87 } | 89 } |
| 90 if (udp_socket_->SetSendBufferSize(send_buffer_size_) != net::OK) { | |
| 91 VLOG(1) << "Failed to set socket send buffer size."; | |
|
miu
2014/10/16 18:31:57
Perhaps this should be LOG(WARNING) or, if we beli
Alpha Left Google
2014/10/16 18:41:27
Done.
| |
| 92 } | |
| 88 | 93 |
| 89 ScheduleReceiveNextPacket(); | 94 ScheduleReceiveNextPacket(); |
| 90 } | 95 } |
| 91 | 96 |
| 92 void UdpTransport::SetDscp(net::DiffServCodePoint dscp) { | 97 void UdpTransport::SetDscp(net::DiffServCodePoint dscp) { |
| 93 DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread()); | 98 DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread()); |
| 94 next_dscp_value_ = dscp; | 99 next_dscp_value_ = dscp; |
| 95 } | 100 } |
| 96 | 101 |
| 97 void UdpTransport::ScheduleReceiveNextPacket() { | 102 void UdpTransport::ScheduleReceiveNextPacket() { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 } | 238 } |
| 234 ScheduleReceiveNextPacket(); | 239 ScheduleReceiveNextPacket(); |
| 235 | 240 |
| 236 if (!cb.is_null()) { | 241 if (!cb.is_null()) { |
| 237 cb.Run(); | 242 cb.Run(); |
| 238 } | 243 } |
| 239 } | 244 } |
| 240 | 245 |
| 241 } // namespace cast | 246 } // namespace cast |
| 242 } // namespace media | 247 } // namespace media |
| OLD | NEW |