| 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 |
| 11 // P2PTransportChannel wraps up the state management of the connection between | 11 // P2PTransportChannel wraps up the state management of the connection between |
| 12 // two P2P clients. Clients have candidate ports for connecting, and | 12 // two P2P clients. Clients have candidate ports for connecting, and |
| 13 // connections which are combinations of candidates from each end (Alice and | 13 // connections which are combinations of candidates from each end (Alice and |
| 14 // Bob each have candidates, one candidate from Alice and one candidate from | 14 // Bob each have candidates, one candidate from Alice and one candidate from |
| 15 // Bob are used to make a connection, repeat to make many connections). | 15 // Bob are used to make a connection, repeat to make many connections). |
| 16 // | 16 // |
| 17 // When all of the available connections become invalid (non-writable), we | 17 // When all of the available connections become invalid (non-writable), we |
| 18 // kick off a process of determining more candidates and more connections. | 18 // kick off a process of determining more candidates and more connections. |
| 19 // | 19 // |
| 20 #ifndef WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ | 20 #ifndef WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ |
| 21 #define WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ | 21 #define WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ |
| 22 | 22 |
| 23 #include <map> | 23 #include <map> |
| 24 #include <string> | 24 #include <string> |
| 25 #include <vector> | 25 #include <vector> |
| 26 #include "webrtc/p2p/base/candidate.h" | 26 #include "webrtc/p2p/base/candidate.h" |
| 27 #include "webrtc/p2p/base/p2ptransport.h" | 27 #include "webrtc/p2p/base/p2ptransport.h" |
| 28 #include "webrtc/p2p/base/portallocator.h" | 28 #include "webrtc/p2p/base/portallocator.h" |
| 29 #include "webrtc/p2p/base/portinterface.h" | 29 #include "webrtc/p2p/base/portinterface.h" |
| 30 #include "webrtc/p2p/base/transport.h" | |
| 31 #include "webrtc/p2p/base/transportchannelimpl.h" | 30 #include "webrtc/p2p/base/transportchannelimpl.h" |
| 32 #include "webrtc/base/asyncpacketsocket.h" | 31 #include "webrtc/base/asyncpacketsocket.h" |
| 33 #include "webrtc/base/sigslot.h" | 32 #include "webrtc/base/sigslot.h" |
| 34 | 33 |
| 35 namespace cricket { | 34 namespace cricket { |
| 36 | 35 |
| 37 extern const uint32_t WEAK_PING_DELAY; | 36 extern const uint32_t WEAK_PING_DELAY; |
| 38 | 37 |
| 39 struct IceParameters { | 38 struct IceParameters { |
| 40 std::string ufrag; | 39 std::string ufrag; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 60 PortInterface* origin_port_; | 59 PortInterface* origin_port_; |
| 61 }; | 60 }; |
| 62 | 61 |
| 63 // P2PTransportChannel manages the candidates and connection process to keep | 62 // P2PTransportChannel manages the candidates and connection process to keep |
| 64 // two P2P clients connected to each other. | 63 // two P2P clients connected to each other. |
| 65 class P2PTransportChannel : public TransportChannelImpl, | 64 class P2PTransportChannel : public TransportChannelImpl, |
| 66 public rtc::MessageHandler { | 65 public rtc::MessageHandler { |
| 67 public: | 66 public: |
| 68 P2PTransportChannel(const std::string& transport_name, | 67 P2PTransportChannel(const std::string& transport_name, |
| 69 int component, | 68 int component, |
| 69 PortAllocator* allocator); |
| 70 // TODO(mikescarlett): Deprecated. Remove when Chromium's |
| 71 // IceTransportChannel does not depend on this. |
| 72 P2PTransportChannel(const std::string& transport_name, |
| 73 int component, |
| 70 P2PTransport* transport, | 74 P2PTransport* transport, |
| 71 PortAllocator* allocator); | 75 PortAllocator* allocator); |
| 72 virtual ~P2PTransportChannel(); | 76 virtual ~P2PTransportChannel(); |
| 73 | 77 |
| 74 // From TransportChannelImpl: | 78 // From TransportChannelImpl: |
| 75 Transport* GetTransport() override { return transport_; } | |
| 76 TransportChannelState GetState() const override; | 79 TransportChannelState GetState() const override; |
| 77 void SetIceRole(IceRole role) override; | 80 void SetIceRole(IceRole role) override; |
| 78 IceRole GetIceRole() const override { return ice_role_; } | 81 IceRole GetIceRole() const override { return ice_role_; } |
| 79 void SetIceTiebreaker(uint64_t tiebreaker) override; | 82 void SetIceTiebreaker(uint64_t tiebreaker) override; |
| 80 void SetIceCredentials(const std::string& ice_ufrag, | 83 void SetIceCredentials(const std::string& ice_ufrag, |
| 81 const std::string& ice_pwd) override; | 84 const std::string& ice_pwd) override; |
| 82 void SetRemoteIceCredentials(const std::string& ice_ufrag, | 85 void SetRemoteIceCredentials(const std::string& ice_ufrag, |
| 83 const std::string& ice_pwd) override; | 86 const std::string& ice_pwd) override; |
| 84 void SetRemoteIceMode(IceMode mode) override; | 87 void SetRemoteIceMode(IceMode mode) override; |
| 85 void Connect() override; | 88 void Connect() override; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 const IceParameters* FindRemoteIceFromUfrag(const std::string& ufrag, | 261 const IceParameters* FindRemoteIceFromUfrag(const std::string& ufrag, |
| 259 uint32_t* generation); | 262 uint32_t* generation); |
| 260 // Returns the index of the latest remote ICE parameters, or 0 if no remote | 263 // Returns the index of the latest remote ICE parameters, or 0 if no remote |
| 261 // ICE parameters have been received. | 264 // ICE parameters have been received. |
| 262 uint32_t remote_ice_generation() { | 265 uint32_t remote_ice_generation() { |
| 263 return remote_ice_parameters_.empty() | 266 return remote_ice_parameters_.empty() |
| 264 ? 0 | 267 ? 0 |
| 265 : static_cast<uint32_t>(remote_ice_parameters_.size() - 1); | 268 : static_cast<uint32_t>(remote_ice_parameters_.size() - 1); |
| 266 } | 269 } |
| 267 | 270 |
| 268 P2PTransport* transport_; | |
| 269 PortAllocator* allocator_; | 271 PortAllocator* allocator_; |
| 270 rtc::Thread* worker_thread_; | 272 rtc::Thread* worker_thread_; |
| 271 bool incoming_only_; | 273 bool incoming_only_; |
| 272 int error_; | 274 int error_; |
| 273 std::vector<PortAllocatorSession*> allocator_sessions_; | 275 std::vector<PortAllocatorSession*> allocator_sessions_; |
| 274 std::vector<PortInterface *> ports_; | 276 std::vector<PortInterface *> ports_; |
| 275 std::vector<Connection *> connections_; | 277 std::vector<Connection *> connections_; |
| 276 Connection* best_connection_; | 278 Connection* best_connection_; |
| 277 // Connection selected by the controlling agent. This should be used only | 279 // Connection selected by the controlling agent. This should be used only |
| 278 // at controlled side when protocol type is RFC5245. | 280 // at controlled side when protocol type is RFC5245. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 297 bool gather_continually_ = false; | 299 bool gather_continually_ = false; |
| 298 int weak_ping_delay_ = WEAK_PING_DELAY; | 300 int weak_ping_delay_ = WEAK_PING_DELAY; |
| 299 TransportChannelState state_ = TransportChannelState::STATE_INIT; | 301 TransportChannelState state_ = TransportChannelState::STATE_INIT; |
| 300 | 302 |
| 301 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); | 303 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); |
| 302 }; | 304 }; |
| 303 | 305 |
| 304 } // namespace cricket | 306 } // namespace cricket |
| 305 | 307 |
| 306 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ | 308 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ |
| OLD | NEW |