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 24 matching lines...) Expand all Loading... |
35 class TurnPort : public Port { | 35 class TurnPort : public Port { |
36 public: | 36 public: |
37 enum PortState { | 37 enum PortState { |
38 STATE_CONNECTING, // Initial state, cannot send any packets. | 38 STATE_CONNECTING, // Initial state, cannot send any packets. |
39 STATE_CONNECTED, // Socket connected, ready to send stun requests. | 39 STATE_CONNECTED, // Socket connected, ready to send stun requests. |
40 STATE_READY, // Received allocate success, can send any packets. | 40 STATE_READY, // Received allocate success, can send any packets. |
41 STATE_RECEIVEONLY, // Had REFRESH_REQUEST error, cannot send any packets. | 41 STATE_RECEIVEONLY, // Had REFRESH_REQUEST error, cannot send any packets. |
42 STATE_DISCONNECTED, // TCP connection died, cannot send/receive any | 42 STATE_DISCONNECTED, // TCP connection died, cannot send/receive any |
43 // packets. | 43 // packets. |
44 }; | 44 }; |
| 45 // Create a TURN port using the shared UDP socket, |socket|. |
45 static TurnPort* Create(rtc::Thread* thread, | 46 static TurnPort* Create(rtc::Thread* thread, |
46 rtc::PacketSocketFactory* factory, | 47 rtc::PacketSocketFactory* factory, |
47 rtc::Network* network, | 48 rtc::Network* network, |
48 rtc::AsyncPacketSocket* socket, | 49 rtc::AsyncPacketSocket* socket, |
49 const std::string& username, // ice username. | 50 const std::string& username, // ice username. |
50 const std::string& password, // ice password. | 51 const std::string& password, // ice password. |
51 const ProtocolAddress& server_address, | 52 const ProtocolAddress& server_address, |
52 const RelayCredentials& credentials, | 53 const RelayCredentials& credentials, |
53 int server_priority, | 54 int server_priority, |
54 const std::string& origin) { | 55 const std::string& origin) { |
55 return new TurnPort(thread, factory, network, socket, username, password, | 56 return new TurnPort(thread, factory, network, socket, username, password, |
56 server_address, credentials, server_priority, origin); | 57 server_address, credentials, server_priority, origin); |
57 } | 58 } |
58 | 59 |
| 60 // Create a TURN port that will use a new socket, bound to |network| and |
| 61 // using a port in the range between |min_port| and |max_port|. |
59 static TurnPort* Create(rtc::Thread* thread, | 62 static TurnPort* Create(rtc::Thread* thread, |
60 rtc::PacketSocketFactory* factory, | 63 rtc::PacketSocketFactory* factory, |
61 rtc::Network* network, | 64 rtc::Network* network, |
62 const rtc::IPAddress& ip, | |
63 uint16_t min_port, | 65 uint16_t min_port, |
64 uint16_t max_port, | 66 uint16_t max_port, |
65 const std::string& username, // ice username. | 67 const std::string& username, // ice username. |
66 const std::string& password, // ice password. | 68 const std::string& password, // ice password. |
67 const ProtocolAddress& server_address, | 69 const ProtocolAddress& server_address, |
68 const RelayCredentials& credentials, | 70 const RelayCredentials& credentials, |
69 int server_priority, | 71 int server_priority, |
70 const std::string& origin) { | 72 const std::string& origin) { |
71 return new TurnPort(thread, factory, network, ip, min_port, max_port, | 73 return new TurnPort(thread, factory, network, min_port, max_port, username, |
72 username, password, server_address, credentials, | 74 password, server_address, credentials, server_priority, |
73 server_priority, origin); | 75 origin); |
74 } | 76 } |
75 | 77 |
76 virtual ~TurnPort(); | 78 virtual ~TurnPort(); |
77 | 79 |
78 const ProtocolAddress& server_address() const { return server_address_; } | 80 const ProtocolAddress& server_address() const { return server_address_; } |
79 // 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. |
80 rtc::SocketAddress GetLocalAddress() const; | 82 rtc::SocketAddress GetLocalAddress() const; |
81 | 83 |
82 bool ready() const { return state_ == STATE_READY; } | 84 bool ready() const { return state_ == STATE_READY; } |
83 bool connected() const { | 85 bool connected() const { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 const std::string& username, | 172 const std::string& username, |
171 const std::string& password, | 173 const std::string& password, |
172 const ProtocolAddress& server_address, | 174 const ProtocolAddress& server_address, |
173 const RelayCredentials& credentials, | 175 const RelayCredentials& credentials, |
174 int server_priority, | 176 int server_priority, |
175 const std::string& origin); | 177 const std::string& origin); |
176 | 178 |
177 TurnPort(rtc::Thread* thread, | 179 TurnPort(rtc::Thread* thread, |
178 rtc::PacketSocketFactory* factory, | 180 rtc::PacketSocketFactory* factory, |
179 rtc::Network* network, | 181 rtc::Network* network, |
180 const rtc::IPAddress& ip, | |
181 uint16_t min_port, | 182 uint16_t min_port, |
182 uint16_t max_port, | 183 uint16_t max_port, |
183 const std::string& username, | 184 const std::string& username, |
184 const std::string& password, | 185 const std::string& password, |
185 const ProtocolAddress& server_address, | 186 const ProtocolAddress& server_address, |
186 const RelayCredentials& credentials, | 187 const RelayCredentials& credentials, |
187 int server_priority, | 188 int server_priority, |
188 const std::string& origin); | 189 const std::string& origin); |
189 | 190 |
190 private: | 191 private: |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 friend class TurnEntry; | 295 friend class TurnEntry; |
295 friend class TurnAllocateRequest; | 296 friend class TurnAllocateRequest; |
296 friend class TurnRefreshRequest; | 297 friend class TurnRefreshRequest; |
297 friend class TurnCreatePermissionRequest; | 298 friend class TurnCreatePermissionRequest; |
298 friend class TurnChannelBindRequest; | 299 friend class TurnChannelBindRequest; |
299 }; | 300 }; |
300 | 301 |
301 } // namespace cricket | 302 } // namespace cricket |
302 | 303 |
303 #endif // WEBRTC_P2P_BASE_TURNPORT_H_ | 304 #endif // WEBRTC_P2P_BASE_TURNPORT_H_ |
OLD | NEW |