OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 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 #ifndef WEBRTC_P2P_BASE_TRANSPORTCONTROLLER_H_ | 11 #ifndef WEBRTC_P2P_BASE_TRANSPORTCONTROLLER_H_ |
12 #define WEBRTC_P2P_BASE_TRANSPORTCONTROLLER_H_ | 12 #define WEBRTC_P2P_BASE_TRANSPORTCONTROLLER_H_ |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "webrtc/base/asyncinvoker.h" | |
19 #include "webrtc/base/sigslot.h" | 18 #include "webrtc/base/sigslot.h" |
20 #include "webrtc/base/sslstreamadapter.h" | 19 #include "webrtc/base/sslstreamadapter.h" |
21 #include "webrtc/p2p/base/candidate.h" | 20 #include "webrtc/p2p/base/candidate.h" |
22 #include "webrtc/p2p/base/transport.h" | 21 #include "webrtc/p2p/base/transport.h" |
23 | 22 |
24 namespace rtc { | 23 namespace rtc { |
25 class Thread; | 24 class Thread; |
26 } | 25 } |
27 | 26 |
28 namespace cricket { | 27 namespace cricket { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 bool SetRemoteTransportDescription(const std::string& transport_name, | 67 bool SetRemoteTransportDescription(const std::string& transport_name, |
69 const TransportDescription& tdesc, | 68 const TransportDescription& tdesc, |
70 ContentAction action, | 69 ContentAction action, |
71 std::string* err); | 70 std::string* err); |
72 // Start gathering candidates for any new transports, or transports doing an | 71 // Start gathering candidates for any new transports, or transports doing an |
73 // ICE restart. | 72 // ICE restart. |
74 void MaybeStartGathering(); | 73 void MaybeStartGathering(); |
75 bool AddRemoteCandidates(const std::string& transport_name, | 74 bool AddRemoteCandidates(const std::string& transport_name, |
76 const Candidates& candidates, | 75 const Candidates& candidates, |
77 std::string* err); | 76 std::string* err); |
78 bool RemoveRemoteCandidates(const Candidates& candidates, std::string* err); | |
79 bool ReadyForRemoteCandidates(const std::string& transport_name); | 77 bool ReadyForRemoteCandidates(const std::string& transport_name); |
80 bool GetStats(const std::string& transport_name, TransportStats* stats); | 78 bool GetStats(const std::string& transport_name, TransportStats* stats); |
81 | 79 |
82 // Creates a channel if it doesn't exist. Otherwise, increments a reference | 80 // Creates a channel if it doesn't exist. Otherwise, increments a reference |
83 // count and returns an existing channel. | 81 // count and returns an existing channel. |
84 virtual TransportChannel* CreateTransportChannel_w( | 82 virtual TransportChannel* CreateTransportChannel_w( |
85 const std::string& transport_name, | 83 const std::string& transport_name, |
86 int component); | 84 int component); |
87 | 85 |
88 // Decrements a channel's reference count, and destroys the channel if | 86 // Decrements a channel's reference count, and destroys the channel if |
(...skipping 14 matching lines...) Expand all Loading... |
103 | 101 |
104 // If all transports done gathering => complete, | 102 // If all transports done gathering => complete, |
105 // Else if any are gathering => gathering, | 103 // Else if any are gathering => gathering, |
106 // Else => new | 104 // Else => new |
107 sigslot::signal1<IceGatheringState> SignalGatheringState; | 105 sigslot::signal1<IceGatheringState> SignalGatheringState; |
108 | 106 |
109 // (transport_name, candidates) | 107 // (transport_name, candidates) |
110 sigslot::signal2<const std::string&, const Candidates&> | 108 sigslot::signal2<const std::string&, const Candidates&> |
111 SignalCandidatesGathered; | 109 SignalCandidatesGathered; |
112 | 110 |
113 sigslot::signal1<const Candidates&> SignalCandidatesRemoved; | |
114 | |
115 // for unit test | 111 // for unit test |
116 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate_for_testing(); | 112 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate_for_testing(); |
117 | 113 |
118 protected: | 114 protected: |
119 // Protected and virtual so we can override it in unit tests. | 115 // Protected and virtual so we can override it in unit tests. |
120 virtual Transport* CreateTransport_w(const std::string& transport_name); | 116 virtual Transport* CreateTransport_w(const std::string& transport_name); |
121 | 117 |
122 // For unit tests | 118 // For unit tests |
123 const std::map<std::string, Transport*>& transports() { return transports_; } | 119 const std::map<std::string, Transport*>& transports() { return transports_; } |
124 Transport* GetTransport_w(const std::string& transport_name); | 120 Transport* GetTransport_w(const std::string& transport_name); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 ContentAction action, | 169 ContentAction action, |
174 std::string* err); | 170 std::string* err); |
175 bool SetRemoteTransportDescription_w(const std::string& transport_name, | 171 bool SetRemoteTransportDescription_w(const std::string& transport_name, |
176 const TransportDescription& tdesc, | 172 const TransportDescription& tdesc, |
177 ContentAction action, | 173 ContentAction action, |
178 std::string* err); | 174 std::string* err); |
179 void MaybeStartGathering_w(); | 175 void MaybeStartGathering_w(); |
180 bool AddRemoteCandidates_w(const std::string& transport_name, | 176 bool AddRemoteCandidates_w(const std::string& transport_name, |
181 const Candidates& candidates, | 177 const Candidates& candidates, |
182 std::string* err); | 178 std::string* err); |
183 bool RemoveRemoteCandidates_w(const Candidates& candidates, std::string* err); | |
184 bool ReadyForRemoteCandidates_w(const std::string& transport_name); | 179 bool ReadyForRemoteCandidates_w(const std::string& transport_name); |
185 bool GetStats_w(const std::string& transport_name, TransportStats* stats); | 180 bool GetStats_w(const std::string& transport_name, TransportStats* stats); |
186 | 181 |
187 // Handlers for signals from Transport. | 182 // Handlers for signals from Transport. |
188 void OnChannelWritableState_w(TransportChannel* channel); | 183 void OnChannelWritableState_w(TransportChannel* channel); |
189 void OnChannelReceivingState_w(TransportChannel* channel); | 184 void OnChannelReceivingState_w(TransportChannel* channel); |
190 void OnChannelGatheringState_w(TransportChannelImpl* channel); | 185 void OnChannelGatheringState_w(TransportChannelImpl* channel); |
191 void OnChannelCandidateGathered_w(TransportChannelImpl* channel, | 186 void OnChannelCandidateGathered_w(TransportChannelImpl* channel, |
192 const Candidate& candidate); | 187 const Candidate& candidate); |
193 void OnChannelCandidatesRemoved(const Candidates& candidates); | |
194 void OnChannelCandidatesRemoved_w(TransportChannelImpl* channel, | |
195 const Candidates& candidates); | |
196 void OnChannelRoleConflict_w(TransportChannelImpl* channel); | 188 void OnChannelRoleConflict_w(TransportChannelImpl* channel); |
197 void OnChannelConnectionRemoved_w(TransportChannelImpl* channel); | 189 void OnChannelConnectionRemoved_w(TransportChannelImpl* channel); |
198 | 190 |
199 void UpdateAggregateStates_w(); | 191 void UpdateAggregateStates_w(); |
200 | 192 |
201 rtc::Thread* const signaling_thread_ = nullptr; | 193 rtc::Thread* const signaling_thread_ = nullptr; |
202 rtc::Thread* const worker_thread_ = nullptr; | 194 rtc::Thread* const worker_thread_ = nullptr; |
203 typedef std::map<std::string, Transport*> TransportMap; | 195 typedef std::map<std::string, Transport*> TransportMap; |
204 TransportMap transports_; | 196 TransportMap transports_; |
205 | 197 |
206 std::vector<RefCountedChannel> channels_; | 198 std::vector<RefCountedChannel> channels_; |
207 | 199 |
208 PortAllocator* const port_allocator_ = nullptr; | 200 PortAllocator* const port_allocator_ = nullptr; |
209 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12; | 201 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12; |
210 | 202 |
211 // Aggregate state for TransportChannelImpls. | 203 // Aggregate state for TransportChannelImpls. |
212 IceConnectionState connection_state_ = kIceConnectionConnecting; | 204 IceConnectionState connection_state_ = kIceConnectionConnecting; |
213 bool receiving_ = false; | 205 bool receiving_ = false; |
214 IceGatheringState gathering_state_ = kIceGatheringNew; | 206 IceGatheringState gathering_state_ = kIceGatheringNew; |
215 | 207 |
216 // TODO(deadbeef): Move the fields below down to the transports themselves | 208 // TODO(deadbeef): Move the fields below down to the transports themselves |
217 IceConfig ice_config_; | 209 IceConfig ice_config_; |
218 IceRole ice_role_ = ICEROLE_CONTROLLING; | 210 IceRole ice_role_ = ICEROLE_CONTROLLING; |
219 // Flag which will be set to true after the first role switch | 211 // Flag which will be set to true after the first role switch |
220 bool ice_role_switch_ = false; | 212 bool ice_role_switch_ = false; |
221 uint64_t ice_tiebreaker_ = rtc::CreateRandomId64(); | 213 uint64_t ice_tiebreaker_ = rtc::CreateRandomId64(); |
222 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; | 214 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; |
223 rtc::AsyncInvoker invoker_; | |
224 }; | 215 }; |
225 | 216 |
226 } // namespace cricket | 217 } // namespace cricket |
227 | 218 |
228 #endif // WEBRTC_P2P_BASE_TRANSPORTCONTROLLER_H_ | 219 #endif // WEBRTC_P2P_BASE_TRANSPORTCONTROLLER_H_ |
OLD | NEW |