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

Side by Side Diff: webrtc/p2p/base/stunport.h

Issue 1275703006: Bug 4517: Enable connectivity for demo page when no STUN/TURN specifiefd. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « webrtc/p2p/base/portallocator.h ('k') | webrtc/p2p/base/stunport.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 16 matching lines...) Expand all
27 27
28 // Communicates using the address on the outside of a NAT. 28 // Communicates using the address on the outside of a NAT.
29 class UDPPort : public Port { 29 class UDPPort : public Port {
30 public: 30 public:
31 static UDPPort* Create(rtc::Thread* thread, 31 static UDPPort* Create(rtc::Thread* thread,
32 rtc::PacketSocketFactory* factory, 32 rtc::PacketSocketFactory* factory,
33 rtc::Network* network, 33 rtc::Network* network,
34 rtc::AsyncPacketSocket* socket, 34 rtc::AsyncPacketSocket* socket,
35 const std::string& username, 35 const std::string& username,
36 const std::string& password, 36 const std::string& password,
37 const std::string& origin) { 37 const std::string& origin,
38 bool emit_localhost_for_anyaddress) {
38 UDPPort* port = new UDPPort(thread, factory, network, socket, 39 UDPPort* port = new UDPPort(thread, factory, network, socket,
39 username, password, origin); 40 username, password, origin,
41 emit_localhost_for_anyaddress);
40 if (!port->Init()) { 42 if (!port->Init()) {
41 delete port; 43 delete port;
42 port = NULL; 44 port = NULL;
43 } 45 }
44 return port; 46 return port;
45 } 47 }
46 48
47 static UDPPort* Create(rtc::Thread* thread, 49 static UDPPort* Create(rtc::Thread* thread,
48 rtc::PacketSocketFactory* factory, 50 rtc::PacketSocketFactory* factory,
49 rtc::Network* network, 51 rtc::Network* network,
50 const rtc::IPAddress& ip, 52 const rtc::IPAddress& ip,
51 uint16 min_port, 53 uint16 min_port,
52 uint16 max_port, 54 uint16 max_port,
53 const std::string& username, 55 const std::string& username,
54 const std::string& password, 56 const std::string& password,
55 const std::string& origin) { 57 const std::string& origin,
58 bool emit_localhost_for_anyaddress) {
56 UDPPort* port = new UDPPort(thread, factory, network, 59 UDPPort* port = new UDPPort(thread, factory, network,
57 ip, min_port, max_port, 60 ip, min_port, max_port,
58 username, password, origin); 61 username, password, origin,
62 emit_localhost_for_anyaddress);
59 if (!port->Init()) { 63 if (!port->Init()) {
60 delete port; 64 delete port;
61 port = NULL; 65 port = NULL;
62 } 66 }
63 return port; 67 return port;
64 } 68 }
65 69
66 virtual ~UDPPort(); 70 virtual ~UDPPort();
67 71
68 rtc::SocketAddress GetLocalAddress() const { 72 rtc::SocketAddress GetLocalAddress() const {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 107
104 protected: 108 protected:
105 UDPPort(rtc::Thread* thread, 109 UDPPort(rtc::Thread* thread,
106 rtc::PacketSocketFactory* factory, 110 rtc::PacketSocketFactory* factory,
107 rtc::Network* network, 111 rtc::Network* network,
108 const rtc::IPAddress& ip, 112 const rtc::IPAddress& ip,
109 uint16 min_port, 113 uint16 min_port,
110 uint16 max_port, 114 uint16 max_port,
111 const std::string& username, 115 const std::string& username,
112 const std::string& password, 116 const std::string& password,
113 const std::string& origin); 117 const std::string& origin,
118 bool emit_localhost_for_anyaddress);
114 119
115 UDPPort(rtc::Thread* thread, 120 UDPPort(rtc::Thread* thread,
116 rtc::PacketSocketFactory* factory, 121 rtc::PacketSocketFactory* factory,
117 rtc::Network* network, 122 rtc::Network* network,
118 rtc::AsyncPacketSocket* socket, 123 rtc::AsyncPacketSocket* socket,
119 const std::string& username, 124 const std::string& username,
120 const std::string& password, 125 const std::string& password,
121 const std::string& origin); 126 const std::string& origin,
127 bool emit_localhost_for_anyaddress);
122 128
123 bool Init(); 129 bool Init();
124 130
125 virtual int SendTo(const void* data, size_t size, 131 virtual int SendTo(const void* data, size_t size,
126 const rtc::SocketAddress& addr, 132 const rtc::SocketAddress& addr,
127 const rtc::PacketOptions& options, 133 const rtc::PacketOptions& options,
128 bool payload); 134 bool payload);
129 135
130 void OnLocalAddressReady(rtc::AsyncPacketSocket* socket, 136 void OnLocalAddressReady(rtc::AsyncPacketSocket* socket,
131 const rtc::SocketAddress& address); 137 const rtc::SocketAddress& address);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 ServerAddresses server_addresses_; 201 ServerAddresses server_addresses_;
196 ServerAddresses bind_request_succeeded_servers_; 202 ServerAddresses bind_request_succeeded_servers_;
197 ServerAddresses bind_request_failed_servers_; 203 ServerAddresses bind_request_failed_servers_;
198 StunRequestManager requests_; 204 StunRequestManager requests_;
199 rtc::AsyncPacketSocket* socket_; 205 rtc::AsyncPacketSocket* socket_;
200 int error_; 206 int error_;
201 rtc::scoped_ptr<AddressResolver> resolver_; 207 rtc::scoped_ptr<AddressResolver> resolver_;
202 bool ready_; 208 bool ready_;
203 int stun_keepalive_delay_; 209 int stun_keepalive_delay_;
204 210
211 // This is true when no STUN or TURN is specified in AllocationSequence and
212 // PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE is specified.
213 bool emit_localhost_for_anyaddress_;
214
205 friend class StunBindingRequest; 215 friend class StunBindingRequest;
206 }; 216 };
207 217
208 class StunPort : public UDPPort { 218 class StunPort : public UDPPort {
209 public: 219 public:
210 static StunPort* Create(rtc::Thread* thread, 220 static StunPort* Create(rtc::Thread* thread,
211 rtc::PacketSocketFactory* factory, 221 rtc::PacketSocketFactory* factory,
212 rtc::Network* network, 222 rtc::Network* network,
213 const rtc::IPAddress& ip, 223 const rtc::IPAddress& ip,
214 uint16 min_port, uint16 max_port, 224 uint16 min_port, uint16 max_port,
(...skipping 23 matching lines...) Expand all
238 rtc::PacketSocketFactory* factory, 248 rtc::PacketSocketFactory* factory,
239 rtc::Network* network, 249 rtc::Network* network,
240 const rtc::IPAddress& ip, 250 const rtc::IPAddress& ip,
241 uint16 min_port, 251 uint16 min_port,
242 uint16 max_port, 252 uint16 max_port,
243 const std::string& username, 253 const std::string& username,
244 const std::string& password, 254 const std::string& password,
245 const ServerAddresses& servers, 255 const ServerAddresses& servers,
246 const std::string& origin) 256 const std::string& origin)
247 : UDPPort(thread, factory, network, ip, min_port, max_port, username, 257 : UDPPort(thread, factory, network, ip, min_port, max_port, username,
248 password, origin) { 258 password, origin, false) {
249 // UDPPort will set these to local udp, updating these to STUN. 259 // UDPPort will set these to local udp, updating these to STUN.
250 set_type(STUN_PORT_TYPE); 260 set_type(STUN_PORT_TYPE);
251 set_server_addresses(servers); 261 set_server_addresses(servers);
252 } 262 }
253 }; 263 };
254 264
255 } // namespace cricket 265 } // namespace cricket
256 266
257 #endif // WEBRTC_P2P_BASE_STUNPORT_H_ 267 #endif // WEBRTC_P2P_BASE_STUNPORT_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/portallocator.h ('k') | webrtc/p2p/base/stunport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698