OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/renderer/media/cast_udp_transport.h" | 5 #include "chrome/renderer/media/cast_udp_transport.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/renderer/media/cast_session.h" | 8 #include "chrome/renderer/media/cast_session.h" |
9 #include "content/public/renderer/p2p_socket_client.h" | |
10 #include "net/base/host_port_pair.h" | |
11 #include "net/base/net_util.h" | |
12 | |
13 class CastUDPSocketFactory : public CastSession::SocketFactory { | |
Alpha Left Google
2013/11/09 00:30:18
nit: CastUdpSocketFactory to be consistent with Ca
hubbe
2013/11/26 20:24:29
Done.
| |
14 public: | |
15 virtual content::P2PSocketClient* create() OVERRIDE { | |
16 content::P2PSocketClient *socket = content::CreateP2PSocket(); | |
Alpha Left Google
2013/11/09 00:30:18
This should be scoped_ptr<content::P2PSocketClient
hubbe
2013/11/26 20:24:29
scoped_refptr actually
| |
17 net::IPEndPoint unspecified_end_point; | |
18 socket->Init(content::P2P_SOCKET_UDP, | |
19 unspecified_end_point, | |
20 unspecified_end_point, | |
21 NULL); | |
22 return socket; | |
Alpha Left Google
2013/11/09 00:30:18
return socket.Pass() if socket is a scoped_ptr.
hubbe
2013/11/26 20:24:29
using scoped_refptr, no need for Pass
| |
23 } | |
24 }; | |
9 | 25 |
10 CastUdpTransport::CastUdpTransport() | 26 CastUdpTransport::CastUdpTransport() |
11 : cast_session_(new CastSession()) { | 27 : cast_session_(new CastSession()) { |
12 } | 28 } |
13 | 29 |
14 CastUdpTransport::~CastUdpTransport() { | 30 CastUdpTransport::~CastUdpTransport() { |
15 } | 31 } |
16 | 32 |
17 void CastUdpTransport::Start(const net::HostPortPair& remote_address) { | 33 void CastUdpTransport::Start(const net::HostPortPair& remote_address) { |
Alpha Left Google
2013/11/09 00:30:18
Might as well just change the type to net::IPAddre
hubbe
2013/11/26 20:24:29
Done.
| |
18 NOTIMPLEMENTED(); | 34 net::IPAddressNumber ip; |
35 if (!net::ParseIPLiteralToNumber(remote_address.host(), &ip)) { | |
36 // TODO(Hubbe): Report back to caller | |
37 return; | |
38 } | |
39 net::IPEndPoint endpoint(ip, remote_address.port()); | |
40 cast_session_->SetSocketFactory( | |
41 new CastUDPSocketFactory(), | |
42 endpoint); | |
19 } | 43 } |
20 | 44 |
21 void CastUdpTransport::Stop() { | 45 void CastUdpTransport::Stop() { |
22 NOTIMPLEMENTED(); | 46 NOTIMPLEMENTED(); |
23 } | 47 } |
OLD | NEW |