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 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "webrtc/base/rtccertificate.h" | 36 #include "webrtc/base/rtccertificate.h" |
37 #include "webrtc/base/sigslot.h" | 37 #include "webrtc/base/sigslot.h" |
38 #include "webrtc/base/sslstreamadapter.h" | 38 #include "webrtc/base/sslstreamadapter.h" |
39 | 39 |
40 namespace cricket { | 40 namespace cricket { |
41 | 41 |
42 class PortAllocator; | 42 class PortAllocator; |
43 class TransportChannel; | 43 class TransportChannel; |
44 class TransportChannelImpl; | 44 class TransportChannelImpl; |
45 | 45 |
46 typedef std::vector<Candidate> Candidates; | |
47 | |
48 // TODO(deadbeef): Unify with PeerConnectionInterface::IceConnectionState | 46 // TODO(deadbeef): Unify with PeerConnectionInterface::IceConnectionState |
49 // once /talk/ and /webrtc/ are combined, and also switch to ENUM_NAME naming | 47 // once /talk/ and /webrtc/ are combined, and also switch to ENUM_NAME naming |
50 // style. | 48 // style. |
51 enum IceConnectionState { | 49 enum IceConnectionState { |
52 kIceConnectionConnecting = 0, | 50 kIceConnectionConnecting = 0, |
53 kIceConnectionFailed, | 51 kIceConnectionFailed, |
54 kIceConnectionConnected, // Writable, but still checking one or more | 52 kIceConnectionConnected, // Writable, but still checking one or more |
55 // connections | 53 // connections |
56 kIceConnectionCompleted, | 54 kIceConnectionCompleted, |
57 }; | 55 }; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 void ResetChannels(); | 250 void ResetChannels(); |
253 | 251 |
254 // Destroys every channel created so far. | 252 // Destroys every channel created so far. |
255 void DestroyAllChannels(); | 253 void DestroyAllChannels(); |
256 | 254 |
257 bool GetStats(TransportStats* stats); | 255 bool GetStats(TransportStats* stats); |
258 | 256 |
259 // Called when one or more candidates are ready from the remote peer. | 257 // Called when one or more candidates are ready from the remote peer. |
260 bool AddRemoteCandidates(const std::vector<Candidate>& candidates, | 258 bool AddRemoteCandidates(const std::vector<Candidate>& candidates, |
261 std::string* error); | 259 std::string* error); |
262 | 260 bool RemoveRemoteCandidates(const std::vector<Candidate>& candidates, |
263 // If candidate is not acceptable, returns false and sets error. | 261 std::string* error); |
264 // Call this before calling OnRemoteCandidates. | |
265 virtual bool VerifyCandidate(const Candidate& candidate, | |
266 std::string* error); | |
267 | 262 |
268 virtual bool GetSslRole(rtc::SSLRole* ssl_role) const { return false; } | 263 virtual bool GetSslRole(rtc::SSLRole* ssl_role) const { return false; } |
269 | 264 |
270 // Must be called before channel is starting to connect. | 265 // Must be called before channel is starting to connect. |
271 virtual bool SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version) { | 266 virtual bool SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version) { |
272 return false; | 267 return false; |
273 } | 268 } |
274 | 269 |
275 protected: | 270 protected: |
276 // These are called by Create/DestroyChannel above in order to create or | 271 // These are called by Create/DestroyChannel above in order to create or |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 std::string* error_desc); | 305 std::string* error_desc); |
311 | 306 |
312 // Pushes down the transport parameters obtained via negotiation. | 307 // Pushes down the transport parameters obtained via negotiation. |
313 // Derived classes can set their specific parameters here, but must call the | 308 // Derived classes can set their specific parameters here, but must call the |
314 // base as well. | 309 // base as well. |
315 virtual bool ApplyNegotiatedTransportDescription( | 310 virtual bool ApplyNegotiatedTransportDescription( |
316 TransportChannelImpl* channel, | 311 TransportChannelImpl* channel, |
317 std::string* error_desc); | 312 std::string* error_desc); |
318 | 313 |
319 private: | 314 private: |
| 315 // If a candidate is not acceptable, returns false and sets error. |
| 316 // Call this before calling OnRemoteCandidates. |
| 317 bool VerifyCandidate(const Candidate& candidate, std::string* error); |
| 318 bool VerifyCandidates(const Candidates& candidates, std::string* error); |
| 319 |
320 // Candidate component => TransportChannelImpl* | 320 // Candidate component => TransportChannelImpl* |
321 typedef std::map<int, TransportChannelImpl*> ChannelMap; | 321 typedef std::map<int, TransportChannelImpl*> ChannelMap; |
322 | 322 |
323 // Helper function that invokes the given function on every channel. | 323 // Helper function that invokes the given function on every channel. |
324 typedef void (TransportChannelImpl::* TransportChannelFunc)(); | 324 typedef void (TransportChannelImpl::* TransportChannelFunc)(); |
325 void CallChannels(TransportChannelFunc func); | 325 void CallChannels(TransportChannelFunc func); |
326 | 326 |
327 const std::string name_; | 327 const std::string name_; |
328 PortAllocator* const allocator_; | 328 PortAllocator* const allocator_; |
329 bool channels_destroyed_ = false; | 329 bool channels_destroyed_ = false; |
330 bool connect_requested_ = false; | 330 bool connect_requested_ = false; |
331 IceRole ice_role_ = ICEROLE_UNKNOWN; | 331 IceRole ice_role_ = ICEROLE_UNKNOWN; |
332 uint64_t tiebreaker_ = 0; | 332 uint64_t tiebreaker_ = 0; |
333 IceMode remote_ice_mode_ = ICEMODE_FULL; | 333 IceMode remote_ice_mode_ = ICEMODE_FULL; |
334 IceConfig ice_config_; | 334 IceConfig ice_config_; |
335 rtc::scoped_ptr<TransportDescription> local_description_; | 335 rtc::scoped_ptr<TransportDescription> local_description_; |
336 rtc::scoped_ptr<TransportDescription> remote_description_; | 336 rtc::scoped_ptr<TransportDescription> remote_description_; |
337 bool local_description_set_ = false; | 337 bool local_description_set_ = false; |
338 bool remote_description_set_ = false; | 338 bool remote_description_set_ = false; |
339 | 339 |
340 ChannelMap channels_; | 340 ChannelMap channels_; |
341 | 341 |
342 RTC_DISALLOW_COPY_AND_ASSIGN(Transport); | 342 RTC_DISALLOW_COPY_AND_ASSIGN(Transport); |
343 }; | 343 }; |
344 | 344 |
345 | 345 |
346 } // namespace cricket | 346 } // namespace cricket |
347 | 347 |
348 #endif // WEBRTC_P2P_BASE_TRANSPORT_H_ | 348 #endif // WEBRTC_P2P_BASE_TRANSPORT_H_ |
OLD | NEW |