OLD | NEW |
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 #include <algorithm> | 10 #include <algorithm> |
11 | 11 |
12 #include "webrtc/p2p/base/relayport.h" | 12 #include "webrtc/p2p/base/relayport.h" |
13 #include "webrtc/base/asyncpacketsocket.h" | 13 #include "webrtc/base/asyncpacketsocket.h" |
14 #include "webrtc/base/helpers.h" | 14 #include "webrtc/base/helpers.h" |
15 #include "webrtc/base/logging.h" | 15 #include "webrtc/base/logging.h" |
16 | 16 |
17 namespace cricket { | 17 namespace cricket { |
18 | 18 |
19 static const uint32 kMessageConnectTimeout = 1; | 19 static const uint32_t kMessageConnectTimeout = 1; |
20 static const int kKeepAliveDelay = 10 * 60 * 1000; | 20 static const int kKeepAliveDelay = 10 * 60 * 1000; |
21 static const int kRetryTimeout = 50 * 1000; // ICE says 50 secs | 21 static const int kRetryTimeout = 50 * 1000; // ICE says 50 secs |
22 // How long to wait for a socket to connect to remote host in milliseconds | 22 // How long to wait for a socket to connect to remote host in milliseconds |
23 // before trying another connection. | 23 // before trying another connection. |
24 static const int kSoftConnectTimeoutMs = 3 * 1000; | 24 static const int kSoftConnectTimeoutMs = 3 * 1000; |
25 | 25 |
26 // Handles a connection to one address/port/protocol combination for a | 26 // Handles a connection to one address/port/protocol combination for a |
27 // particular RelayEntry. | 27 // particular RelayEntry. |
28 class RelayConnection : public sigslot::has_slots<> { | 28 class RelayConnection : public sigslot::has_slots<> { |
29 public: | 29 public: |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 void OnSent() override; | 164 void OnSent() override; |
165 int resend_delay() override; | 165 int resend_delay() override; |
166 | 166 |
167 void OnResponse(StunMessage* response) override; | 167 void OnResponse(StunMessage* response) override; |
168 void OnErrorResponse(StunMessage* response) override; | 168 void OnErrorResponse(StunMessage* response) override; |
169 void OnTimeout() override; | 169 void OnTimeout() override; |
170 | 170 |
171 private: | 171 private: |
172 RelayEntry* entry_; | 172 RelayEntry* entry_; |
173 RelayConnection* connection_; | 173 RelayConnection* connection_; |
174 uint32 start_time_; | 174 uint32_t start_time_; |
175 }; | 175 }; |
176 | 176 |
177 RelayPort::RelayPort(rtc::Thread* thread, | 177 RelayPort::RelayPort(rtc::Thread* thread, |
178 rtc::PacketSocketFactory* factory, | 178 rtc::PacketSocketFactory* factory, |
179 rtc::Network* network, | 179 rtc::Network* network, |
180 const rtc::IPAddress& ip, | 180 const rtc::IPAddress& ip, |
181 uint16 min_port, | 181 uint16_t min_port, |
182 uint16 max_port, | 182 uint16_t max_port, |
183 const std::string& username, | 183 const std::string& username, |
184 const std::string& password) | 184 const std::string& password) |
185 : Port(thread, RELAY_PORT_TYPE, factory, network, ip, min_port, max_port, | 185 : Port(thread, |
186 username, password), | 186 RELAY_PORT_TYPE, |
| 187 factory, |
| 188 network, |
| 189 ip, |
| 190 min_port, |
| 191 max_port, |
| 192 username, |
| 193 password), |
187 ready_(false), | 194 ready_(false), |
188 error_(0) { | 195 error_(0) { |
189 entries_.push_back( | 196 entries_.push_back( |
190 new RelayEntry(this, rtc::SocketAddress())); | 197 new RelayEntry(this, rtc::SocketAddress())); |
191 // TODO: set local preference value for TCP based candidates. | 198 // TODO: set local preference value for TCP based candidates. |
192 } | 199 } |
193 | 200 |
194 RelayPort::~RelayPort() { | 201 RelayPort::~RelayPort() { |
195 for (size_t i = 0; i < entries_.size(); ++i) | 202 for (size_t i = 0; i < entries_.size(); ++i) |
196 delete entries_[i]; | 203 delete entries_[i]; |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 if (rtc::TimeSince(start_time_) <= kRetryTimeout) | 827 if (rtc::TimeSince(start_time_) <= kRetryTimeout) |
821 entry_->ScheduleKeepAlive(); | 828 entry_->ScheduleKeepAlive(); |
822 } | 829 } |
823 | 830 |
824 void AllocateRequest::OnTimeout() { | 831 void AllocateRequest::OnTimeout() { |
825 LOG(INFO) << "Allocate request timed out"; | 832 LOG(INFO) << "Allocate request timed out"; |
826 entry_->HandleConnectFailure(connection_->socket()); | 833 entry_->HandleConnectFailure(connection_->socket()); |
827 } | 834 } |
828 | 835 |
829 } // namespace cricket | 836 } // namespace cricket |
OLD | NEW |