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