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

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

Issue 2111663003: Revert of Add config to prune TURN ports (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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
« no previous file with comments | « webrtc/p2p/base/turnport.h ('k') | webrtc/p2p/client/basicportallocator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 public: 116 public:
117 PortData() {} 117 PortData() {}
118 PortData(Port* port, AllocationSequence* seq) 118 PortData(Port* port, AllocationSequence* seq)
119 : port_(port), sequence_(seq) {} 119 : port_(port), sequence_(seq) {}
120 120
121 Port* port() const { return port_; } 121 Port* port() const { return port_; }
122 AllocationSequence* sequence() const { return sequence_; } 122 AllocationSequence* sequence() const { return sequence_; }
123 bool has_pairable_candidate() const { return has_pairable_candidate_; } 123 bool has_pairable_candidate() const { return has_pairable_candidate_; }
124 bool complete() const { return state_ == STATE_COMPLETE; } 124 bool complete() const { return state_ == STATE_COMPLETE; }
125 bool error() const { return state_ == STATE_ERROR; } 125 bool error() const { return state_ == STATE_ERROR; }
126 bool pruned() const { return state_ == STATE_PRUNED; }
127 bool inprogress() const { return state_ == STATE_INPROGRESS; }
128 // Returns true if this port is ready to be used.
129 bool ready() const {
130 return has_pairable_candidate_ && state_ != STATE_ERROR &&
131 state_ != STATE_PRUNED;
132 }
133 126
134 void set_pruned() { state_ = STATE_PRUNED; }
135 void set_has_pairable_candidate(bool has_pairable_candidate) { 127 void set_has_pairable_candidate(bool has_pairable_candidate) {
136 if (has_pairable_candidate) { 128 if (has_pairable_candidate) {
137 ASSERT(state_ == STATE_INPROGRESS); 129 ASSERT(state_ == STATE_INPROGRESS);
138 } 130 }
139 has_pairable_candidate_ = has_pairable_candidate; 131 has_pairable_candidate_ = has_pairable_candidate;
140 } 132 }
141 void set_complete() { 133 void set_complete() {
142 state_ = STATE_COMPLETE; 134 state_ = STATE_COMPLETE;
143 } 135 }
144 void set_error() { 136 void set_error() {
145 ASSERT(state_ == STATE_INPROGRESS); 137 ASSERT(state_ == STATE_INPROGRESS);
146 state_ = STATE_ERROR; 138 state_ = STATE_ERROR;
147 } 139 }
148 140
149 private: 141 private:
150 enum State { 142 enum State {
151 STATE_INPROGRESS, // Still gathering candidates. 143 STATE_INPROGRESS, // Still gathering candidates.
152 STATE_COMPLETE, // All candidates allocated and ready for process. 144 STATE_COMPLETE, // All candidates allocated and ready for process.
153 STATE_ERROR, // Error in gathering candidates. 145 STATE_ERROR // Error in gathering candidates.
154 STATE_PRUNED // Pruned by higher priority ports on the same network
155 // interface. Only TURN ports may be pruned.
156 }; 146 };
157 Port* port_ = nullptr; 147 Port* port_ = nullptr;
158 AllocationSequence* sequence_ = nullptr; 148 AllocationSequence* sequence_ = nullptr;
159 State state_ = STATE_INPROGRESS; 149 State state_ = STATE_INPROGRESS;
160 bool has_pairable_candidate_ = false; 150 bool has_pairable_candidate_ = false;
161 }; 151 };
162 152
163 void OnConfigReady(PortConfiguration* config); 153 void OnConfigReady(PortConfiguration* config);
164 void OnConfigStop(); 154 void OnConfigStop();
165 void AllocatePorts(); 155 void AllocatePorts();
(...skipping 15 matching lines...) Expand all
181 void OnPortAllocationComplete(AllocationSequence* seq); 171 void OnPortAllocationComplete(AllocationSequence* seq);
182 PortData* FindPort(Port* port); 172 PortData* FindPort(Port* port);
183 void GetNetworks(std::vector<rtc::Network*>* networks); 173 void GetNetworks(std::vector<rtc::Network*>* networks);
184 174
185 bool CheckCandidateFilter(const Candidate& c) const; 175 bool CheckCandidateFilter(const Candidate& c) const;
186 bool CandidatePairable(const Candidate& c, const Port* port) const; 176 bool CandidatePairable(const Candidate& c, const Port* port) const;
187 // Clear the related address according to the flags and candidate filter 177 // Clear the related address according to the flags and candidate filter
188 // in order to avoid leaking any information. 178 // in order to avoid leaking any information.
189 Candidate SanitizeRelatedAddress(const Candidate& c) const; 179 Candidate SanitizeRelatedAddress(const Candidate& c) const;
190 180
191 Port* GetBestTurnPortForNetwork(const std::string& network_name) const;
192 // Returns true if at least one TURN port is pruned.
193 bool PruneTurnPorts(Port* newly_pairable_turn_port);
194
195 BasicPortAllocator* allocator_; 181 BasicPortAllocator* allocator_;
196 rtc::Thread* network_thread_; 182 rtc::Thread* network_thread_;
197 std::unique_ptr<rtc::PacketSocketFactory> owned_socket_factory_; 183 std::unique_ptr<rtc::PacketSocketFactory> owned_socket_factory_;
198 rtc::PacketSocketFactory* socket_factory_; 184 rtc::PacketSocketFactory* socket_factory_;
199 bool allocation_started_; 185 bool allocation_started_;
200 bool network_manager_started_; 186 bool network_manager_started_;
201 bool running_; // set when StartGetAllPorts is called 187 bool running_; // set when StartGetAllPorts is called
202 bool allocation_sequences_created_; 188 bool allocation_sequences_created_;
203 std::vector<PortConfiguration*> configs_; 189 std::vector<PortConfiguration*> configs_;
204 std::vector<AllocationSequence*> sequences_; 190 std::vector<AllocationSequence*> sequences_;
205 std::vector<PortData> ports_; 191 std::vector<PortData> ports_;
206 uint32_t candidate_filter_ = CF_ALL; 192 uint32_t candidate_filter_ = CF_ALL;
207 // Whether to prune low-priority ports, taken from the port allocator.
208 bool prune_turn_ports_;
209 193
210 friend class AllocationSequence; 194 friend class AllocationSequence;
211 }; 195 };
212 196
213 // Records configuration information useful in creating ports. 197 // Records configuration information useful in creating ports.
214 // TODO(deadbeef): Rename "relay" to "turn_server" in this struct. 198 // TODO(deadbeef): Rename "relay" to "turn_server" in this struct.
215 struct PortConfiguration : public rtc::MessageData { 199 struct PortConfiguration : public rtc::MessageData {
216 // TODO(jiayl): remove |stun_address| when Chrome is updated. 200 // TODO(jiayl): remove |stun_address| when Chrome is updated.
217 rtc::SocketAddress stun_address; 201 rtc::SocketAddress stun_address;
218 ServerAddresses stun_servers; 202 ServerAddresses stun_servers;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 std::unique_ptr<rtc::AsyncPacketSocket> udp_socket_; 319 std::unique_ptr<rtc::AsyncPacketSocket> udp_socket_;
336 // There will be only one udp port per AllocationSequence. 320 // There will be only one udp port per AllocationSequence.
337 UDPPort* udp_port_; 321 UDPPort* udp_port_;
338 std::vector<TurnPort*> turn_ports_; 322 std::vector<TurnPort*> turn_ports_;
339 int phase_; 323 int phase_;
340 }; 324 };
341 325
342 } // namespace cricket 326 } // namespace cricket
343 327
344 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_ 328 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/turnport.h ('k') | webrtc/p2p/client/basicportallocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698