| 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 "remoting/protocol/chromium_socket_factory.h" | 5 #include "remoting/protocol/chromium_socket_factory.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/time/time.h" |
| 13 #include "jingle/glue/utils.h" | 14 #include "jingle/glue/utils.h" |
| 14 #include "net/base/io_buffer.h" | 15 #include "net/base/io_buffer.h" |
| 15 #include "net/base/ip_endpoint.h" | 16 #include "net/base/ip_endpoint.h" |
| 16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 17 #include "net/udp/udp_server_socket.h" | 18 #include "net/udp/udp_server_socket.h" |
| 18 #include "remoting/protocol/socket_util.h" | 19 #include "remoting/protocol/socket_util.h" |
| 20 #include "third_party/libjingle/source/talk/media/base/rtputils.h" |
| 19 #include "third_party/webrtc/base/asyncpacketsocket.h" | 21 #include "third_party/webrtc/base/asyncpacketsocket.h" |
| 20 #include "third_party/webrtc/base/nethelpers.h" | 22 #include "third_party/webrtc/base/nethelpers.h" |
| 21 | 23 |
| 22 namespace remoting { | 24 namespace remoting { |
| 23 namespace protocol { | 25 namespace protocol { |
| 24 | 26 |
| 25 namespace { | 27 namespace { |
| 26 | 28 |
| 27 // Size of the buffer to allocate for RecvFrom(). | 29 // Size of the buffer to allocate for RecvFrom(). |
| 28 const int kReceiveBufferSize = 65536; | 30 const int kReceiveBufferSize = 65536; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 189 |
| 188 net::IPEndPoint endpoint; | 190 net::IPEndPoint endpoint; |
| 189 if (!jingle_glue::SocketAddressToIPEndPoint(address, &endpoint)) { | 191 if (!jingle_glue::SocketAddressToIPEndPoint(address, &endpoint)) { |
| 190 return EINVAL; | 192 return EINVAL; |
| 191 } | 193 } |
| 192 | 194 |
| 193 if (send_queue_size_ >= kMaxSendBufferSize) { | 195 if (send_queue_size_ >= kMaxSendBufferSize) { |
| 194 return EWOULDBLOCK; | 196 return EWOULDBLOCK; |
| 195 } | 197 } |
| 196 | 198 |
| 197 send_queue_.push_back(PendingPacket(data, data_size, endpoint)); | 199 PendingPacket packet(data, data_size, endpoint); |
| 200 cricket::ApplyPacketOptions( |
| 201 reinterpret_cast<uint8_t*>(packet.data->data()), data_size, |
| 202 options.packet_time_params, |
| 203 (base::TimeTicks::Now() - base::TimeTicks()).InMilliseconds()); |
| 204 send_queue_.push_back(packet); |
| 198 send_queue_size_ += data_size; | 205 send_queue_size_ += data_size; |
| 199 | 206 |
| 200 DoSend(); | 207 DoSend(); |
| 201 return data_size; | 208 return data_size; |
| 202 } | 209 } |
| 203 | 210 |
| 204 int UdpPacketSocket::Close() { | 211 int UdpPacketSocket::Close() { |
| 205 state_ = STATE_CLOSED; | 212 state_ = STATE_CLOSED; |
| 206 socket_.reset(); | 213 socket_.reset(); |
| 207 return 0; | 214 return 0; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 return nullptr; | 403 return nullptr; |
| 397 } | 404 } |
| 398 | 405 |
| 399 rtc::AsyncResolverInterface* | 406 rtc::AsyncResolverInterface* |
| 400 ChromiumPacketSocketFactory::CreateAsyncResolver() { | 407 ChromiumPacketSocketFactory::CreateAsyncResolver() { |
| 401 return new rtc::AsyncResolver(); | 408 return new rtc::AsyncResolver(); |
| 402 } | 409 } |
| 403 | 410 |
| 404 } // namespace protocol | 411 } // namespace protocol |
| 405 } // namespace remoting | 412 } // namespace remoting |
| OLD | NEW |