Chromium Code Reviews

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

Issue 264793017: Implements RTP header dumping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "content/browser/renderer_host/p2p/socket_host_throttler.h" 10 #include "content/browser/renderer_host/p2p/socket_host_throttler.h"
(...skipping 48 matching lines...)
59 size(content.size()), 59 size(content.size()),
60 packet_options(options), 60 packet_options(options),
61 id(id) { 61 id(id) {
62 memcpy(data->data(), &content[0], size); 62 memcpy(data->data(), &content[0], size);
63 } 63 }
64 64
65 P2PSocketHostUdp::PendingPacket::~PendingPacket() { 65 P2PSocketHostUdp::PendingPacket::~PendingPacket() {
66 } 66 }
67 67
68 P2PSocketHostUdp::P2PSocketHostUdp(IPC::Sender* message_sender, 68 P2PSocketHostUdp::P2PSocketHostUdp(IPC::Sender* message_sender,
69 int id, 69 int socket_id,
70 int render_process_host_id,
70 P2PMessageThrottler* throttler) 71 P2PMessageThrottler* throttler)
71 : P2PSocketHost(message_sender, id), 72 : P2PSocketHost(message_sender, socket_id, render_process_host_id),
72 socket_(new net::UDPServerSocket( 73 socket_(
73 GetContentClient()->browser()->GetNetLog(), 74 new net::UDPServerSocket(GetContentClient()->browser()->GetNetLog(),
74 net::NetLog::Source())), 75 net::NetLog::Source())),
75 send_pending_(false), 76 send_pending_(false),
76 last_dscp_(net::DSCP_CS0), 77 last_dscp_(net::DSCP_CS0),
77 throttler_(throttler) { 78 throttler_(throttler) {
78 } 79 }
79 80
80 P2PSocketHostUdp::~P2PSocketHostUdp() { 81 P2PSocketHostUdp::~P2PSocketHostUdp() {
81 if (state_ == STATE_OPEN) { 82 if (state_ == STATE_OPEN) {
82 DCHECK(socket_.get()); 83 DCHECK(socket_.get());
83 socket_.reset(); 84 socket_.reset();
84 } 85 }
(...skipping 81 matching lines...)
166 } else if (!stun || type == STUN_DATA_INDICATION) { 167 } else if (!stun || type == STUN_DATA_INDICATION) {
167 LOG(ERROR) << "Received unexpected data packet from " 168 LOG(ERROR) << "Received unexpected data packet from "
168 << recv_address_.ToString() 169 << recv_address_.ToString()
169 << " before STUN binding is finished."; 170 << " before STUN binding is finished.";
170 return; 171 return;
171 } 172 }
172 } 173 }
173 174
174 message_sender_->Send(new P2PMsg_OnDataReceived( 175 message_sender_->Send(new P2PMsg_OnDataReceived(
175 id_, recv_address_, data, base::TimeTicks::Now())); 176 id_, recv_address_, data, base::TimeTicks::Now()));
177
178 if (dump_incoming_rtp_packet_)
179 DumpRtpPacket(data.data(), data.size(), true);
176 } else if (result < 0 && !IsTransientError(result)) { 180 } else if (result < 0 && !IsTransientError(result)) {
177 LOG(ERROR) << "Error when reading from UDP socket: " << result; 181 LOG(ERROR) << "Error when reading from UDP socket: " << result;
178 OnError(); 182 OnError();
179 } 183 }
180 } 184 }
181 185
182 void P2PSocketHostUdp::Send(const net::IPEndPoint& to, 186 void P2PSocketHostUdp::Send(const net::IPEndPoint& to,
183 const std::vector<char>& data, 187 const std::vector<char>& data,
184 const talk_base::PacketOptions& options, 188 const talk_base::PacketOptions& options,
185 uint64 packet_id) { 189 uint64 packet_id) {
(...skipping 68 matching lines...)
254 packet.to, 258 packet.to,
255 base::Bind(&P2PSocketHostUdp::OnSend, base::Unretained(this), 259 base::Bind(&P2PSocketHostUdp::OnSend, base::Unretained(this),
256 packet.id)); 260 packet.id));
257 } 261 }
258 262
259 if (result == net::ERR_IO_PENDING) { 263 if (result == net::ERR_IO_PENDING) {
260 send_pending_ = true; 264 send_pending_ = true;
261 } else { 265 } else {
262 HandleSendResult(packet.id, result); 266 HandleSendResult(packet.id, result);
263 } 267 }
268
269 if (dump_outgoing_rtp_packet_)
270 DumpRtpPacket(packet.data->data(), packet.size, false);
264 } 271 }
265 272
266 void P2PSocketHostUdp::OnSend(uint64 packet_id, int result) { 273 void P2PSocketHostUdp::OnSend(uint64 packet_id, int result) {
267 DCHECK(send_pending_); 274 DCHECK(send_pending_);
268 DCHECK_NE(result, net::ERR_IO_PENDING); 275 DCHECK_NE(result, net::ERR_IO_PENDING);
269 276
270 send_pending_ = false; 277 send_pending_ = false;
271 278
272 HandleSendResult(packet_id, result); 279 HandleSendResult(packet_id, result);
273 280
(...skipping 36 matching lines...)
310 case P2P_SOCKET_OPT_DSCP: 317 case P2P_SOCKET_OPT_DSCP:
311 return (net::OK == socket_->SetDiffServCodePoint( 318 return (net::OK == socket_->SetDiffServCodePoint(
312 static_cast<net::DiffServCodePoint>(value))) ? true : false; 319 static_cast<net::DiffServCodePoint>(value))) ? true : false;
313 default: 320 default:
314 NOTREACHED(); 321 NOTREACHED();
315 return false; 322 return false;
316 } 323 }
317 } 324 }
318 325
319 } // namespace content 326 } // namespace content
OLDNEW

Powered by Google App Engine