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

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

Issue 1998813002: Fixing the behavior of the candidate filter with pooled candidates. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Undoing unintentional "git cl format" of unrelated files. Created 4 years, 7 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.cc ('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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 const std::string& content_name, 81 const std::string& content_name,
82 int component, 82 int component,
83 const std::string& ice_ufrag, 83 const std::string& ice_ufrag,
84 const std::string& ice_pwd); 84 const std::string& ice_pwd);
85 ~BasicPortAllocatorSession(); 85 ~BasicPortAllocatorSession();
86 86
87 virtual BasicPortAllocator* allocator() { return allocator_; } 87 virtual BasicPortAllocator* allocator() { return allocator_; }
88 rtc::Thread* network_thread() { return network_thread_; } 88 rtc::Thread* network_thread() { return network_thread_; }
89 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; } 89 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; }
90 90
91 void SetCandidateFilter(uint32_t filter) override;
91 void StartGettingPorts() override; 92 void StartGettingPorts() override;
92 void StopGettingPorts() override; 93 void StopGettingPorts() override;
93 void ClearGettingPorts() override; 94 void ClearGettingPorts() override;
94 bool IsGettingPorts() override { return running_; } 95 bool IsGettingPorts() override { return running_; }
95 // These will all be cricket::Ports. 96 // These will all be cricket::Ports.
96 std::vector<PortInterface*> ReadyPorts() const override; 97 std::vector<PortInterface*> ReadyPorts() const override;
97 std::vector<Candidate> ReadyCandidates() const override; 98 std::vector<Candidate> ReadyCandidates() const override;
98 bool CandidatesAllocationDone() const override; 99 bool CandidatesAllocationDone() const override;
99 100
100 protected: 101 protected:
101 void UpdateIceParametersInternal() override; 102 void UpdateIceParametersInternal() override;
102 103
103 // Starts the process of getting the port configurations. 104 // Starts the process of getting the port configurations.
104 virtual void GetPortConfigurations(); 105 virtual void GetPortConfigurations();
105 106
106 // Adds a port configuration that is now ready. Once we have one for each 107 // Adds a port configuration that is now ready. Once we have one for each
107 // network (or a timeout occurs), we will start allocating ports. 108 // network (or a timeout occurs), we will start allocating ports.
108 virtual void ConfigReady(PortConfiguration* config); 109 virtual void ConfigReady(PortConfiguration* config);
109 110
110 // MessageHandler. Can be overriden if message IDs do not conflict. 111 // MessageHandler. Can be overriden if message IDs do not conflict.
111 void OnMessage(rtc::Message* message) override; 112 void OnMessage(rtc::Message* message) override;
112 113
113 private: 114 private:
114 class PortData { 115 class PortData {
115 public: 116 public:
116 PortData() : port_(NULL), sequence_(NULL), state_(STATE_INIT) {} 117 PortData() {}
117 PortData(Port* port, AllocationSequence* seq) 118 PortData(Port* port, AllocationSequence* seq)
118 : port_(port), sequence_(seq), state_(STATE_INIT) { 119 : port_(port), sequence_(seq) {}
119 }
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 ready() const { return state_ == STATE_READY; } 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 126
127 void set_ready() { ASSERT(state_ == STATE_INIT); state_ = STATE_READY; } 127 void set_has_pairable_candidate(bool has_pairable_candidate) {
128 if (has_pairable_candidate) {
129 ASSERT(state_ == STATE_INPROGRESS);
130 }
131 has_pairable_candidate_ = has_pairable_candidate;
132 }
128 void set_complete() { 133 void set_complete() {
129 state_ = STATE_COMPLETE; 134 state_ = STATE_COMPLETE;
130 } 135 }
131 void set_error() { 136 void set_error() {
132 ASSERT(state_ == STATE_INIT || state_ == STATE_READY); 137 ASSERT(state_ == STATE_INPROGRESS);
133 state_ = STATE_ERROR; 138 state_ = STATE_ERROR;
134 } 139 }
135 140
136 private: 141 private:
137 enum State { 142 enum State {
138 STATE_INIT, // No candidates allocated yet. 143 STATE_INPROGRESS, // Still gathering candidates.
139 STATE_READY, // At least one candidate is ready for process. 144 STATE_COMPLETE, // All candidates allocated and ready for process.
140 STATE_COMPLETE, // All candidates allocated and ready for process. 145 STATE_ERROR // Error in gathering candidates.
141 STATE_ERROR // Error in gathering candidates.
142 }; 146 };
143 Port* port_; 147 Port* port_ = nullptr;
144 AllocationSequence* sequence_; 148 AllocationSequence* sequence_ = nullptr;
145 State state_; 149 State state_ = STATE_INPROGRESS;
150 bool has_pairable_candidate_ = false;
146 }; 151 };
147 152
148 void OnConfigReady(PortConfiguration* config); 153 void OnConfigReady(PortConfiguration* config);
149 void OnConfigStop(); 154 void OnConfigStop();
150 void AllocatePorts(); 155 void AllocatePorts();
151 void OnAllocate(); 156 void OnAllocate();
152 void DoAllocate(); 157 void DoAllocate();
153 void OnNetworksChanged(); 158 void OnNetworksChanged();
154 void OnAllocationSequenceObjectsCreated(); 159 void OnAllocationSequenceObjectsCreated();
155 void DisableEquivalentPhases(rtc::Network* network, 160 void DisableEquivalentPhases(rtc::Network* network,
156 PortConfiguration* config, 161 PortConfiguration* config,
157 uint32_t* flags); 162 uint32_t* flags);
158 void AddAllocatedPort(Port* port, AllocationSequence* seq, 163 void AddAllocatedPort(Port* port, AllocationSequence* seq,
159 bool prepare_address); 164 bool prepare_address);
160 void OnCandidateReady(Port* port, const Candidate& c); 165 void OnCandidateReady(Port* port, const Candidate& c);
161 void OnPortComplete(Port* port); 166 void OnPortComplete(Port* port);
162 void OnPortError(Port* port); 167 void OnPortError(Port* port);
163 void OnProtocolEnabled(AllocationSequence* seq, ProtocolType proto); 168 void OnProtocolEnabled(AllocationSequence* seq, ProtocolType proto);
164 void OnPortDestroyed(PortInterface* port); 169 void OnPortDestroyed(PortInterface* port);
165 void MaybeSignalCandidatesAllocationDone(); 170 void MaybeSignalCandidatesAllocationDone();
166 void OnPortAllocationComplete(AllocationSequence* seq); 171 void OnPortAllocationComplete(AllocationSequence* seq);
167 PortData* FindPort(Port* port); 172 PortData* FindPort(Port* port);
168 void GetNetworks(std::vector<rtc::Network*>* networks); 173 void GetNetworks(std::vector<rtc::Network*>* networks);
169 174
170 bool CheckCandidateFilter(const Candidate& c) const; 175 bool CheckCandidateFilter(const Candidate& c) const;
176 bool CandidatePairable(const Candidate& c, const Port* port) const;
177 // Clear the related address according to the flags and candidate filter
178 // in order to avoid leaking any information.
179 Candidate SanitizeRelatedAddress(const Candidate& c) const;
171 180
172 BasicPortAllocator* allocator_; 181 BasicPortAllocator* allocator_;
173 rtc::Thread* network_thread_; 182 rtc::Thread* network_thread_;
174 std::unique_ptr<rtc::PacketSocketFactory> owned_socket_factory_; 183 std::unique_ptr<rtc::PacketSocketFactory> owned_socket_factory_;
175 rtc::PacketSocketFactory* socket_factory_; 184 rtc::PacketSocketFactory* socket_factory_;
176 bool allocation_started_; 185 bool allocation_started_;
177 bool network_manager_started_; 186 bool network_manager_started_;
178 bool running_; // set when StartGetAllPorts is called 187 bool running_; // set when StartGetAllPorts is called
179 bool allocation_sequences_created_; 188 bool allocation_sequences_created_;
180 std::vector<PortConfiguration*> configs_; 189 std::vector<PortConfiguration*> configs_;
181 std::vector<AllocationSequence*> sequences_; 190 std::vector<AllocationSequence*> sequences_;
182 std::vector<PortData> ports_; 191 std::vector<PortData> ports_;
192 uint32_t candidate_filter_ = CF_ALL;
183 193
184 friend class AllocationSequence; 194 friend class AllocationSequence;
185 }; 195 };
186 196
187 // Records configuration information useful in creating ports. 197 // Records configuration information useful in creating ports.
188 // TODO(deadbeef): Rename "relay" to "turn_server" in this struct. 198 // TODO(deadbeef): Rename "relay" to "turn_server" in this struct.
189 struct PortConfiguration : public rtc::MessageData { 199 struct PortConfiguration : public rtc::MessageData {
190 // TODO(jiayl): remove |stun_address| when Chrome is updated. 200 // TODO(jiayl): remove |stun_address| when Chrome is updated.
191 rtc::SocketAddress stun_address; 201 rtc::SocketAddress stun_address;
192 ServerAddresses stun_servers; 202 ServerAddresses stun_servers;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 std::unique_ptr<rtc::AsyncPacketSocket> udp_socket_; 319 std::unique_ptr<rtc::AsyncPacketSocket> udp_socket_;
310 // There will be only one udp port per AllocationSequence. 320 // There will be only one udp port per AllocationSequence.
311 UDPPort* udp_port_; 321 UDPPort* udp_port_;
312 std::vector<TurnPort*> turn_ports_; 322 std::vector<TurnPort*> turn_ports_;
313 int phase_; 323 int phase_;
314 }; 324 };
315 325
316 } // namespace cricket 326 } // namespace cricket
317 327
318 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_ 328 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/turnport.cc ('k') | webrtc/p2p/client/basicportallocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698