Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(548)

Side by Side Diff: webrtc/p2p/client/basicportallocator.h

Issue 2093623004: Add config to prune TURN ports (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add all tests and fix a bug to set port type Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 void OnAllocate(); 156 void OnAllocate();
157 void DoAllocate(); 157 void DoAllocate();
158 void OnNetworksChanged(); 158 void OnNetworksChanged();
159 void OnAllocationSequenceObjectsCreated(); 159 void OnAllocationSequenceObjectsCreated();
160 void DisableEquivalentPhases(rtc::Network* network, 160 void DisableEquivalentPhases(rtc::Network* network,
161 PortConfiguration* config, 161 PortConfiguration* config,
162 uint32_t* flags); 162 uint32_t* flags);
163 void AddAllocatedPort(Port* port, AllocationSequence* seq, 163 void AddAllocatedPort(Port* port, AllocationSequence* seq,
164 bool prepare_address); 164 bool prepare_address);
165 void OnCandidateReady(Port* port, const Candidate& c); 165 void OnCandidateReady(Port* port, const Candidate& c);
166 void MaybeSignalPortReady(Port* port);
167 void MaybeSignalCandidatesReady(Port* port,
168 const std::vector<Candidate>& candidates);
169 bool IsPortInUse(Port* port) const;
166 void OnPortComplete(Port* port); 170 void OnPortComplete(Port* port);
167 void OnPortError(Port* port); 171 void OnPortError(Port* port);
168 void OnProtocolEnabled(AllocationSequence* seq, ProtocolType proto); 172 void OnProtocolEnabled(AllocationSequence* seq, ProtocolType proto);
169 void OnPortDestroyed(PortInterface* port); 173 void OnPortDestroyed(PortInterface* port);
170 void MaybeSignalCandidatesAllocationDone(); 174 void MaybeSignalCandidatesAllocationDone();
171 void OnPortAllocationComplete(AllocationSequence* seq); 175 void OnPortAllocationComplete(AllocationSequence* seq);
172 PortData* FindPort(Port* port); 176 PortData* FindPort(Port* port);
173 void GetNetworks(std::vector<rtc::Network*>* networks); 177 void GetNetworks(std::vector<rtc::Network*>* networks);
174 178
175 bool CheckCandidateFilter(const Candidate& c) const; 179 bool CheckCandidateFilter(const Candidate& c) const;
176 bool CandidatePairable(const Candidate& c, const Port* port) const; 180 bool CandidatePairable(const Candidate& c, const Port* port) const;
177 // Clear the related address according to the flags and candidate filter 181 // Clear the related address according to the flags and candidate filter
178 // in order to avoid leaking any information. 182 // in order to avoid leaking any information.
179 Candidate SanitizeRelatedAddress(const Candidate& c) const; 183 Candidate SanitizeRelatedAddress(const Candidate& c) const;
180 184
181 BasicPortAllocator* allocator_; 185 BasicPortAllocator* allocator_;
182 rtc::Thread* network_thread_; 186 rtc::Thread* network_thread_;
183 std::unique_ptr<rtc::PacketSocketFactory> owned_socket_factory_; 187 std::unique_ptr<rtc::PacketSocketFactory> owned_socket_factory_;
184 rtc::PacketSocketFactory* socket_factory_; 188 rtc::PacketSocketFactory* socket_factory_;
185 bool allocation_started_; 189 bool allocation_started_;
186 bool network_manager_started_; 190 bool network_manager_started_;
187 bool running_; // set when StartGetAllPorts is called 191 bool running_; // set when StartGetAllPorts is called
188 bool allocation_sequences_created_; 192 bool allocation_sequences_created_;
189 std::vector<PortConfiguration*> configs_; 193 std::vector<PortConfiguration*> configs_;
190 std::vector<AllocationSequence*> sequences_; 194 std::vector<AllocationSequence*> sequences_;
191 std::vector<PortData> ports_; 195 std::vector<PortData> ports_;
192 uint32_t candidate_filter_ = CF_ALL; 196 uint32_t candidate_filter_ = CF_ALL;
193 197
198 typedef std::vector<Port*> PortArray;
pthatcher1 2016/06/27 20:35:55 I'd prefer not to have a typedef and just have s
honghaiz3 2016/06/28 01:49:26 Done.
199 // The currently used turn ports keyed by the network names.
200 std::map<std::string, PortArray> turn_ports_in_use_by_network_names_;
pthatcher1 2016/06/27 20:35:55 Why not just turn_ports_by_network_name?
honghaiz3 2016/06/28 01:49:26 Removed this.
201
pthatcher1 2016/06/27 20:35:55 Actually, instead of having a separate map for tur
honghaiz3 2016/06/28 01:49:26 Done.
194 friend class AllocationSequence; 202 friend class AllocationSequence;
195 }; 203 };
196 204
197 // Records configuration information useful in creating ports. 205 // Records configuration information useful in creating ports.
198 // TODO(deadbeef): Rename "relay" to "turn_server" in this struct. 206 // TODO(deadbeef): Rename "relay" to "turn_server" in this struct.
199 struct PortConfiguration : public rtc::MessageData { 207 struct PortConfiguration : public rtc::MessageData {
200 // TODO(jiayl): remove |stun_address| when Chrome is updated. 208 // TODO(jiayl): remove |stun_address| when Chrome is updated.
201 rtc::SocketAddress stun_address; 209 rtc::SocketAddress stun_address;
202 ServerAddresses stun_servers; 210 ServerAddresses stun_servers;
203 std::string username; 211 std::string username;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 std::unique_ptr<rtc::AsyncPacketSocket> udp_socket_; 327 std::unique_ptr<rtc::AsyncPacketSocket> udp_socket_;
320 // There will be only one udp port per AllocationSequence. 328 // There will be only one udp port per AllocationSequence.
321 UDPPort* udp_port_; 329 UDPPort* udp_port_;
322 std::vector<TurnPort*> turn_ports_; 330 std::vector<TurnPort*> turn_ports_;
323 int phase_; 331 int phase_;
324 }; 332 };
325 333
326 } // namespace cricket 334 } // namespace cricket
327 335
328 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_ 336 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698