Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Side by Side Diff: content/browser/renderer_host/p2p/socket_host_udp.cc

Issue 159353002: This CL adds methods to manipulate RTP header extension, particularly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/p2p/socket_host_udp.h" 5 #include "content/browser/renderer_host/p2p/socket_host_udp.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "content/browser/renderer_host/p2p/socket_host_throttler.h" 11 #include "content/browser/renderer_host/p2p/socket_host_throttler.h"
12 #include "content/common/p2p_messages.h" 12 #include "content/common/p2p_messages.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "ipc/ipc_sender.h" 14 #include "ipc/ipc_sender.h"
15 #include "net/base/io_buffer.h" 15 #include "net/base/io_buffer.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/base/net_util.h" 17 #include "net/base/net_util.h"
18 #include "third_party/libjingle/source/talk/base/asyncpacketsocket.h"
18 19
19 namespace { 20 namespace {
20 21
21 // UDP packets cannot be bigger than 64k. 22 // UDP packets cannot be bigger than 64k.
22 const int kReadBufferSize = 65536; 23 const int kReadBufferSize = 65536;
23 // Socket receive buffer size. 24 // Socket receive buffer size.
24 const int kRecvSocketBufferSize = 65536; // 64K 25 const int kRecvSocketBufferSize = 65536; // 64K
25 26
26 // Defines set of transient errors. These errors are ignored when we get them 27 // Defines set of transient errors. These errors are ignored when we get them
27 // from sendto() or recvfrom() calls. 28 // from sendto() or recvfrom() calls.
(...skipping 28 matching lines...) Expand all
56 const net::IPEndPoint& to, 57 const net::IPEndPoint& to,
57 const std::vector<char>& content, 58 const std::vector<char>& content,
58 const talk_base::PacketOptions& options, 59 const talk_base::PacketOptions& options,
59 uint64 id) 60 uint64 id)
60 : to(to), 61 : to(to),
61 data(new net::IOBuffer(content.size())), 62 data(new net::IOBuffer(content.size())),
62 size(content.size()), 63 size(content.size()),
63 packet_options(options), 64 packet_options(options),
64 id(id) { 65 id(id) {
65 memcpy(data->data(), &content[0], size); 66 memcpy(data->data(), &content[0], size);
66 if (!options.packet_time_params.srtp_auth_key.empty()) {
67 memcpy(&packet_options.packet_time_params.srtp_auth_key[0],
68 &options.packet_time_params.srtp_auth_key[0],
69 options.packet_time_params.srtp_auth_key.size());
70 }
71 } 67 }
72 68
73 P2PSocketHostUdp::PendingPacket::~PendingPacket() { 69 P2PSocketHostUdp::PendingPacket::~PendingPacket() {
74 } 70 }
75 71
76 P2PSocketHostUdp::P2PSocketHostUdp(IPC::Sender* message_sender, 72 P2PSocketHostUdp::P2PSocketHostUdp(IPC::Sender* message_sender,
77 int id, 73 int id,
78 P2PMessageThrottler* throttler) 74 P2PMessageThrottler* throttler)
79 : P2PSocketHost(message_sender, id), 75 : P2PSocketHost(message_sender, id),
80 socket_(new net::UDPServerSocket(NULL, net::NetLog::Source())), 76 socket_(new net::UDPServerSocket(NULL, net::NetLog::Source())),
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 int result = socket_->SetDiffServCodePoint(dscp); 231 int result = socket_->SetDiffServCodePoint(dscp);
236 if (result == net::OK) { 232 if (result == net::OK) {
237 last_dscp_ = dscp; 233 last_dscp_ = dscp;
238 } else if (!IsTransientError(result) && last_dscp_ != net::DSCP_CS0) { 234 } else if (!IsTransientError(result) && last_dscp_ != net::DSCP_CS0) {
239 // We receieved a non-transient error, and it seems we have 235 // We receieved a non-transient error, and it seems we have
240 // not changed the DSCP in the past, disable DSCP as it unlikely 236 // not changed the DSCP in the past, disable DSCP as it unlikely
241 // to work in the future. 237 // to work in the future.
242 last_dscp_ = net::DSCP_NO_CHANGE; 238 last_dscp_ = net::DSCP_NO_CHANGE;
243 } 239 }
244 } 240 }
241 talk_base::PacketOptions options;
242 MaybeUpdatePacketAbsSendTimeExtn(packet.data->data(), packet.size, options);
245 int result = socket_->SendTo( 243 int result = socket_->SendTo(
246 packet.data.get(), 244 packet.data.get(),
247 packet.size, 245 packet.size,
248 packet.to, 246 packet.to,
249 base::Bind(&P2PSocketHostUdp::OnSend, base::Unretained(this), packet.id)); 247 base::Bind(&P2PSocketHostUdp::OnSend, base::Unretained(this), packet.id));
250 248
251 // sendto() may return an error, e.g. if we've received an ICMP Destination 249 // sendto() may return an error, e.g. if we've received an ICMP Destination
252 // Unreachable message. When this happens try sending the same packet again, 250 // Unreachable message. When this happens try sending the same packet again,
253 // and just drop it if it fails again. 251 // and just drop it if it fails again.
254 if (IsTransientError(result)) { 252 if (IsTransientError(result)) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 case P2P_SOCKET_OPT_DSCP: 311 case P2P_SOCKET_OPT_DSCP:
314 return (net::OK == socket_->SetDiffServCodePoint( 312 return (net::OK == socket_->SetDiffServCodePoint(
315 static_cast<net::DiffServCodePoint>(value))) ? true : false; 313 static_cast<net::DiffServCodePoint>(value))) ? true : false;
316 default: 314 default:
317 NOTREACHED(); 315 NOTREACHED();
318 return false; 316 return false;
319 } 317 }
320 } 318 }
321 319
322 } // namespace content 320 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698