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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // Create a TURN port using the shared UDP socket, |socket|. | 45 // Create a TURN port using the shared UDP socket, |socket|. |
46 static TurnPort* Create(rtc::Thread* thread, | 46 static TurnPort* Create(rtc::Thread* thread, |
47 rtc::PacketSocketFactory* factory, | 47 rtc::PacketSocketFactory* factory, |
48 rtc::Network* network, | 48 rtc::Network* network, |
49 rtc::AsyncPacketSocket* socket, | 49 rtc::AsyncPacketSocket* socket, |
50 const std::string& username, // ice username. | 50 const std::string& username, // ice username. |
51 const std::string& password, // ice password. | 51 const std::string& password, // ice password. |
52 const ProtocolAddress& server_address, | 52 const ProtocolAddress& server_address, |
53 const RelayCredentials& credentials, | 53 const RelayCredentials& credentials, |
54 int server_priority, | 54 int server_priority, |
55 const std::string& origin, | 55 const std::string& origin) { |
56 webrtc::RtcEventLog* event_log) { | |
57 return new TurnPort(thread, factory, network, socket, username, password, | 56 return new TurnPort(thread, factory, network, socket, username, password, |
58 server_address, credentials, server_priority, origin, | 57 server_address, credentials, server_priority, origin); |
59 event_log); | |
60 } | 58 } |
61 | 59 |
62 // Create a TURN port that will use a new socket, bound to |network| and | 60 // Create a TURN port that will use a new socket, bound to |network| and |
63 // using a port in the range between |min_port| and |max_port|. | 61 // using a port in the range between |min_port| and |max_port|. |
64 static TurnPort* Create(rtc::Thread* thread, | 62 static TurnPort* Create(rtc::Thread* thread, |
65 rtc::PacketSocketFactory* factory, | 63 rtc::PacketSocketFactory* factory, |
66 rtc::Network* network, | 64 rtc::Network* network, |
67 uint16_t min_port, | 65 uint16_t min_port, |
68 uint16_t max_port, | 66 uint16_t max_port, |
69 const std::string& username, // ice username. | 67 const std::string& username, // ice username. |
70 const std::string& password, // ice password. | 68 const std::string& password, // ice password. |
71 const ProtocolAddress& server_address, | 69 const ProtocolAddress& server_address, |
72 const RelayCredentials& credentials, | 70 const RelayCredentials& credentials, |
73 int server_priority, | 71 int server_priority, |
74 const std::string& origin, | 72 const std::string& origin) { |
75 webrtc::RtcEventLog* event_log) { | |
76 return new TurnPort(thread, factory, network, min_port, max_port, username, | 73 return new TurnPort(thread, factory, network, min_port, max_port, username, |
77 password, server_address, credentials, server_priority, | 74 password, server_address, credentials, server_priority, |
78 origin, event_log); | 75 origin); |
79 } | 76 } |
80 | 77 |
81 virtual ~TurnPort(); | 78 virtual ~TurnPort(); |
82 | 79 |
83 const ProtocolAddress& server_address() const { return server_address_; } | 80 const ProtocolAddress& server_address() const { return server_address_; } |
84 // Returns an empty address if the local address has not been assigned. | 81 // Returns an empty address if the local address has not been assigned. |
85 rtc::SocketAddress GetLocalAddress() const; | 82 rtc::SocketAddress GetLocalAddress() const; |
86 | 83 |
87 bool ready() const { return state_ == STATE_READY; } | 84 bool ready() const { return state_ == STATE_READY; } |
88 bool connected() const { | 85 bool connected() const { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 protected: | 167 protected: |
171 TurnPort(rtc::Thread* thread, | 168 TurnPort(rtc::Thread* thread, |
172 rtc::PacketSocketFactory* factory, | 169 rtc::PacketSocketFactory* factory, |
173 rtc::Network* network, | 170 rtc::Network* network, |
174 rtc::AsyncPacketSocket* socket, | 171 rtc::AsyncPacketSocket* socket, |
175 const std::string& username, | 172 const std::string& username, |
176 const std::string& password, | 173 const std::string& password, |
177 const ProtocolAddress& server_address, | 174 const ProtocolAddress& server_address, |
178 const RelayCredentials& credentials, | 175 const RelayCredentials& credentials, |
179 int server_priority, | 176 int server_priority, |
180 const std::string& origin, | 177 const std::string& origin); |
181 webrtc::RtcEventLog* event_log); | |
182 | 178 |
183 TurnPort(rtc::Thread* thread, | 179 TurnPort(rtc::Thread* thread, |
184 rtc::PacketSocketFactory* factory, | 180 rtc::PacketSocketFactory* factory, |
185 rtc::Network* network, | 181 rtc::Network* network, |
186 uint16_t min_port, | 182 uint16_t min_port, |
187 uint16_t max_port, | 183 uint16_t max_port, |
188 const std::string& username, | 184 const std::string& username, |
189 const std::string& password, | 185 const std::string& password, |
190 const ProtocolAddress& server_address, | 186 const ProtocolAddress& server_address, |
191 const RelayCredentials& credentials, | 187 const RelayCredentials& credentials, |
192 int server_priority, | 188 int server_priority, |
193 const std::string& origin, | 189 const std::string& origin); |
194 webrtc::RtcEventLog* event_log); | |
195 | 190 |
196 private: | 191 private: |
197 enum { | 192 enum { |
198 MSG_ALLOCATE_ERROR = MSG_FIRST_AVAILABLE, | 193 MSG_ALLOCATE_ERROR = MSG_FIRST_AVAILABLE, |
199 MSG_ALLOCATE_MISMATCH, | 194 MSG_ALLOCATE_MISMATCH, |
200 MSG_TRY_ALTERNATE_SERVER, | 195 MSG_TRY_ALTERNATE_SERVER, |
201 MSG_REFRESH_ERROR | 196 MSG_REFRESH_ERROR |
202 }; | 197 }; |
203 | 198 |
204 typedef std::list<TurnEntry*> EntryList; | 199 typedef std::list<TurnEntry*> EntryList; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 EntryList entries_; | 283 EntryList entries_; |
289 | 284 |
290 PortState state_; | 285 PortState state_; |
291 // By default the value will be set to 0. This value will be used in | 286 // By default the value will be set to 0. This value will be used in |
292 // calculating the candidate priority. | 287 // calculating the candidate priority. |
293 int server_priority_; | 288 int server_priority_; |
294 | 289 |
295 // The number of retries made due to allocate mismatch error. | 290 // The number of retries made due to allocate mismatch error. |
296 size_t allocate_mismatch_retries_; | 291 size_t allocate_mismatch_retries_; |
297 | 292 |
298 webrtc::RtcEventLog* event_log_; | |
299 | |
300 rtc::AsyncInvoker invoker_; | 293 rtc::AsyncInvoker invoker_; |
301 | 294 |
302 friend class TurnEntry; | 295 friend class TurnEntry; |
303 friend class TurnAllocateRequest; | 296 friend class TurnAllocateRequest; |
304 friend class TurnRefreshRequest; | 297 friend class TurnRefreshRequest; |
305 friend class TurnCreatePermissionRequest; | 298 friend class TurnCreatePermissionRequest; |
306 friend class TurnChannelBindRequest; | 299 friend class TurnChannelBindRequest; |
307 }; | 300 }; |
308 | 301 |
309 } // namespace cricket | 302 } // namespace cricket |
310 | 303 |
311 #endif // WEBRTC_P2P_BASE_TURNPORT_H_ | 304 #endif // WEBRTC_P2P_BASE_TURNPORT_H_ |
OLD | NEW |