OLD | NEW |
---|---|
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 Loading... | |
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 { | |
juberti1
2015/07/30 20:47:40
This should be TurnPortState, since it is at globa
honghaiz3
2015/07/31 00:17:06
I have moved this inside class TurnPort.
| |
35 STATE_DISCONNECTED, // No socket available, cannot send any packets. | |
36 STATE_CONNECTING, // Socket available, can send stun packets only. | |
37 STATE_CONNECTED // Socket available and allocation response received, | |
38 // can send any packets. | |
39 }; | |
40 | |
34 class TurnPort : public Port { | 41 class TurnPort : public Port { |
35 public: | 42 public: |
36 static TurnPort* Create(rtc::Thread* thread, | 43 static TurnPort* Create(rtc::Thread* thread, |
37 rtc::PacketSocketFactory* factory, | 44 rtc::PacketSocketFactory* factory, |
38 rtc::Network* network, | 45 rtc::Network* network, |
39 rtc::AsyncPacketSocket* socket, | 46 rtc::AsyncPacketSocket* socket, |
40 const std::string& username, // ice username. | 47 const std::string& username, // ice username. |
41 const std::string& password, // ice password. | 48 const std::string& password, // ice password. |
42 const ProtocolAddress& server_address, | 49 const ProtocolAddress& server_address, |
43 const RelayCredentials& credentials, | 50 const RelayCredentials& credentials, |
(...skipping 19 matching lines...) Expand all Loading... | |
63 username, password, server_address, credentials, | 70 username, password, server_address, credentials, |
64 server_priority, origin); | 71 server_priority, origin); |
65 } | 72 } |
66 | 73 |
67 virtual ~TurnPort(); | 74 virtual ~TurnPort(); |
68 | 75 |
69 const ProtocolAddress& server_address() const { return server_address_; } | 76 const ProtocolAddress& server_address() const { return server_address_; } |
70 // Returns an empty address if the local address has not been assigned. | 77 // Returns an empty address if the local address has not been assigned. |
71 rtc::SocketAddress GetLocalAddress() const; | 78 rtc::SocketAddress GetLocalAddress() const; |
72 | 79 |
73 bool connected() const { return connected_; } | 80 bool connected() const { return state_ == STATE_CONNECTED; } |
74 const RelayCredentials& credentials() const { return credentials_; } | 81 const RelayCredentials& credentials() const { return credentials_; } |
75 | 82 |
76 virtual void PrepareAddress(); | 83 virtual void PrepareAddress(); |
77 virtual Connection* CreateConnection( | 84 virtual Connection* CreateConnection( |
78 const Candidate& c, PortInterface::CandidateOrigin origin); | 85 const Candidate& c, PortInterface::CandidateOrigin origin); |
79 virtual int SendTo(const void* data, size_t size, | 86 virtual int SendTo(const void* data, size_t size, |
80 const rtc::SocketAddress& addr, | 87 const rtc::SocketAddress& addr, |
81 const rtc::PacketOptions& options, | 88 const rtc::PacketOptions& options, |
82 bool payload); | 89 bool payload); |
83 virtual int SetOption(rtc::Socket::Option opt, int value); | 90 virtual int SetOption(rtc::Socket::Option opt, int value); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 // Signal with resolved server address. | 123 // Signal with resolved server address. |
117 // Parameters are port, server address and resolved server address. | 124 // Parameters are port, server address and resolved server address. |
118 // This signal will be sent only if server address is resolved successfully. | 125 // This signal will be sent only if server address is resolved successfully. |
119 sigslot::signal3<TurnPort*, | 126 sigslot::signal3<TurnPort*, |
120 const rtc::SocketAddress&, | 127 const rtc::SocketAddress&, |
121 const rtc::SocketAddress&> SignalResolvedServerAddress; | 128 const rtc::SocketAddress&> SignalResolvedServerAddress; |
122 | 129 |
123 // This signal is only for testing purpose. | 130 // This signal is only for testing purpose. |
124 sigslot::signal3<TurnPort*, const rtc::SocketAddress&, int> | 131 sigslot::signal3<TurnPort*, const rtc::SocketAddress&, int> |
125 SignalCreatePermissionResult; | 132 SignalCreatePermissionResult; |
133 // For testing purpose. | |
134 void SendAllocateRequest(int delay); | |
126 | 135 |
127 protected: | 136 protected: |
128 TurnPort(rtc::Thread* thread, | 137 TurnPort(rtc::Thread* thread, |
129 rtc::PacketSocketFactory* factory, | 138 rtc::PacketSocketFactory* factory, |
130 rtc::Network* network, | 139 rtc::Network* network, |
131 rtc::AsyncPacketSocket* socket, | 140 rtc::AsyncPacketSocket* socket, |
132 const std::string& username, | 141 const std::string& username, |
133 const std::string& password, | 142 const std::string& password, |
134 const ProtocolAddress& server_address, | 143 const ProtocolAddress& server_address, |
135 const RelayCredentials& credentials, | 144 const RelayCredentials& credentials, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 int error_; | 227 int error_; |
219 | 228 |
220 StunRequestManager request_manager_; | 229 StunRequestManager request_manager_; |
221 std::string realm_; // From 401/438 response message. | 230 std::string realm_; // From 401/438 response message. |
222 std::string nonce_; // From 401/438 response message. | 231 std::string nonce_; // From 401/438 response message. |
223 std::string hash_; // Digest of username:realm:password | 232 std::string hash_; // Digest of username:realm:password |
224 | 233 |
225 int next_channel_number_; | 234 int next_channel_number_; |
226 EntryList entries_; | 235 EntryList entries_; |
227 | 236 |
228 bool connected_; | 237 PortState state_; |
229 // By default the value will be set to 0. This value will be used in | 238 // By default the value will be set to 0. This value will be used in |
230 // calculating the candidate priority. | 239 // calculating the candidate priority. |
231 int server_priority_; | 240 int server_priority_; |
232 | 241 |
233 // The number of retries made due to allocate mismatch error. | 242 // The number of retries made due to allocate mismatch error. |
234 size_t allocate_mismatch_retries_; | 243 size_t allocate_mismatch_retries_; |
235 | 244 |
236 friend class TurnEntry; | 245 friend class TurnEntry; |
237 friend class TurnAllocateRequest; | 246 friend class TurnAllocateRequest; |
238 friend class TurnRefreshRequest; | 247 friend class TurnRefreshRequest; |
239 friend class TurnCreatePermissionRequest; | 248 friend class TurnCreatePermissionRequest; |
240 friend class TurnChannelBindRequest; | 249 friend class TurnChannelBindRequest; |
241 }; | 250 }; |
242 | 251 |
243 } // namespace cricket | 252 } // namespace cricket |
244 | 253 |
245 #endif // WEBRTC_P2P_BASE_TURNPORT_H_ | 254 #endif // WEBRTC_P2P_BASE_TURNPORT_H_ |
OLD | NEW |