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

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

Issue 1247573002: Fix a Turn TCP port issue. (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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2012 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 13 matching lines...) Expand all
24 class AsyncResolver; 24 class AsyncResolver;
25 class SignalThread; 25 class SignalThread;
26 } 26 }
27 27
28 namespace cricket { 28 namespace cricket {
29 29
30 extern const char TURN_PORT_TYPE[]; 30 extern const char TURN_PORT_TYPE[];
31 class TurnAllocateRequest; 31 class TurnAllocateRequest;
32 class TurnEntry; 32 class TurnEntry;
33 33
34 enum PortState {
35 STATE_INITIAL, // Not ready for sending anything yet.
36 STATE_SOCKET_READY, // Socket is ready for sending stun request.
37 STATE_CONNECTED // Stun response is received.
pthatcher1 2015/07/28 18:23:04 Can you call these DISCONNECTED, CONNECTING, and C
honghaiz3 2015/07/29 21:44:13 Done.
38 };
39
34 class TurnPort : public Port { 40 class TurnPort : public Port {
35 public: 41 public:
36 static TurnPort* Create(rtc::Thread* thread, 42 static TurnPort* Create(rtc::Thread* thread,
37 rtc::PacketSocketFactory* factory, 43 rtc::PacketSocketFactory* factory,
38 rtc::Network* network, 44 rtc::Network* network,
39 rtc::AsyncPacketSocket* socket, 45 rtc::AsyncPacketSocket* socket,
40 const std::string& username, // ice username. 46 const std::string& username, // ice username.
41 const std::string& password, // ice password. 47 const std::string& password, // ice password.
42 const ProtocolAddress& server_address, 48 const ProtocolAddress& server_address,
43 const RelayCredentials& credentials, 49 const RelayCredentials& credentials,
(...skipping 19 matching lines...) Expand all
63 username, password, server_address, credentials, 69 username, password, server_address, credentials,
64 server_priority, origin); 70 server_priority, origin);
65 } 71 }
66 72
67 virtual ~TurnPort(); 73 virtual ~TurnPort();
68 74
69 const ProtocolAddress& server_address() const { return server_address_; } 75 const ProtocolAddress& server_address() const { return server_address_; }
70 // Returns an empty address if the local address has not been assigned. 76 // Returns an empty address if the local address has not been assigned.
71 rtc::SocketAddress GetLocalAddress() const; 77 rtc::SocketAddress GetLocalAddress() const;
72 78
73 bool connected() const { return connected_; } 79 bool connected() const { return port_state_ == STATE_CONNECTED; }
74 const RelayCredentials& credentials() const { return credentials_; } 80 const RelayCredentials& credentials() const { return credentials_; }
75 81
76 virtual void PrepareAddress(); 82 virtual void PrepareAddress();
77 virtual Connection* CreateConnection( 83 virtual Connection* CreateConnection(
78 const Candidate& c, PortInterface::CandidateOrigin origin); 84 const Candidate& c, PortInterface::CandidateOrigin origin);
79 virtual int SendTo(const void* data, size_t size, 85 virtual int SendTo(const void* data, size_t size,
80 const rtc::SocketAddress& addr, 86 const rtc::SocketAddress& addr,
81 const rtc::PacketOptions& options, 87 const rtc::PacketOptions& options,
82 bool payload); 88 bool payload);
83 virtual int SetOption(rtc::Socket::Option opt, int value); 89 virtual int SetOption(rtc::Socket::Option opt, int value);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // Signal with resolved server address. 122 // Signal with resolved server address.
117 // Parameters are port, server address and resolved server address. 123 // Parameters are port, server address and resolved server address.
118 // This signal will be sent only if server address is resolved successfully. 124 // This signal will be sent only if server address is resolved successfully.
119 sigslot::signal3<TurnPort*, 125 sigslot::signal3<TurnPort*,
120 const rtc::SocketAddress&, 126 const rtc::SocketAddress&,
121 const rtc::SocketAddress&> SignalResolvedServerAddress; 127 const rtc::SocketAddress&> SignalResolvedServerAddress;
122 128
123 // This signal is only for testing purpose. 129 // This signal is only for testing purpose.
124 sigslot::signal3<TurnPort*, const rtc::SocketAddress&, int> 130 sigslot::signal3<TurnPort*, const rtc::SocketAddress&, int>
125 SignalCreatePermissionResult; 131 SignalCreatePermissionResult;
132 // For testing purpose.
133 void SendAllocateRequest(int delay);
126 134
127 protected: 135 protected:
128 TurnPort(rtc::Thread* thread, 136 TurnPort(rtc::Thread* thread,
129 rtc::PacketSocketFactory* factory, 137 rtc::PacketSocketFactory* factory,
130 rtc::Network* network, 138 rtc::Network* network,
131 rtc::AsyncPacketSocket* socket, 139 rtc::AsyncPacketSocket* socket,
132 const std::string& username, 140 const std::string& username,
133 const std::string& password, 141 const std::string& password,
134 const ProtocolAddress& server_address, 142 const ProtocolAddress& server_address,
135 const RelayCredentials& credentials, 143 const RelayCredentials& credentials,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 int error_; 226 int error_;
219 227
220 StunRequestManager request_manager_; 228 StunRequestManager request_manager_;
221 std::string realm_; // From 401/438 response message. 229 std::string realm_; // From 401/438 response message.
222 std::string nonce_; // From 401/438 response message. 230 std::string nonce_; // From 401/438 response message.
223 std::string hash_; // Digest of username:realm:password 231 std::string hash_; // Digest of username:realm:password
224 232
225 int next_channel_number_; 233 int next_channel_number_;
226 EntryList entries_; 234 EntryList entries_;
227 235
228 bool connected_; 236 PortState port_state_;
229 // By default the value will be set to 0. This value will be used in 237 // By default the value will be set to 0. This value will be used in
230 // calculating the candidate priority. 238 // calculating the candidate priority.
231 int server_priority_; 239 int server_priority_;
232 240
233 // The number of retries made due to allocate mismatch error. 241 // The number of retries made due to allocate mismatch error.
234 size_t allocate_mismatch_retries_; 242 size_t allocate_mismatch_retries_;
235 243
236 friend class TurnEntry; 244 friend class TurnEntry;
237 friend class TurnAllocateRequest; 245 friend class TurnAllocateRequest;
238 friend class TurnRefreshRequest; 246 friend class TurnRefreshRequest;
239 friend class TurnCreatePermissionRequest; 247 friend class TurnCreatePermissionRequest;
240 friend class TurnChannelBindRequest; 248 friend class TurnChannelBindRequest;
241 }; 249 };
242 250
243 } // namespace cricket 251 } // namespace cricket
244 252
245 #endif // WEBRTC_P2P_BASE_TURNPORT_H_ 253 #endif // WEBRTC_P2P_BASE_TURNPORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698