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/base/candidate.h

Issue 1648813004: Remove candidates when doing continual gathering (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Address Alex's comments Created 4 years, 9 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 162 }
163 void set_related_address( 163 void set_related_address(
164 const rtc::SocketAddress & related_address) { 164 const rtc::SocketAddress & related_address) {
165 related_address_ = related_address; 165 related_address_ = related_address;
166 } 166 }
167 const std::string& tcptype() const { return tcptype_; } 167 const std::string& tcptype() const { return tcptype_; }
168 void set_tcptype(const std::string& tcptype){ 168 void set_tcptype(const std::string& tcptype){
169 tcptype_ = tcptype; 169 tcptype_ = tcptype;
170 } 170 }
171 171
172 // The name of the transport channel of this candidate.
173 const std::string& transport_name() const { return transport_name_; }
174 void set_transport_name(const std::string& transport_name) {
175 transport_name_ = transport_name;
176 }
177
172 // Determines whether this candidate is equivalent to the given one. 178 // Determines whether this candidate is equivalent to the given one.
173 bool IsEquivalent(const Candidate& c) const { 179 bool IsEquivalent(const Candidate& c) const {
174 // We ignore the network name, since that is just debug information, and 180 // We ignore the network name, since that is just debug information, and
175 // the priority, since that should be the same if the rest is (and it's 181 // the priority, since that should be the same if the rest is (and it's
176 // a float so equality checking is always worrisome). 182 // a float so equality checking is always worrisome).
177 return (component_ == c.component_) && (protocol_ == c.protocol_) && 183 return (component_ == c.component_) && (protocol_ == c.protocol_) &&
178 (address_ == c.address_) && (username_ == c.username_) && 184 (address_ == c.address_) && (username_ == c.username_) &&
179 (password_ == c.password_) && (type_ == c.type_) && 185 (password_ == c.password_) && (type_ == c.type_) &&
180 (generation_ == c.generation_) && (foundation_ == c.foundation_) && 186 (generation_ == c.generation_) && (foundation_ == c.foundation_) &&
181 (related_address_ == c.related_address_); 187 (related_address_ == c.related_address_);
182 } 188 }
183 189
190 // Determines whether this candidate can be considered equivalent to the
191 // given one when looking for a matching candidate to remove.
192 bool MatchesForRemoval(const Candidate& c) const {
193 return component_ == c.component_ && protocol_ == c.protocol_ &&
194 address_ == c.address_;
195 }
196
184 std::string ToString() const { 197 std::string ToString() const {
185 return ToStringInternal(false); 198 return ToStringInternal(false);
186 } 199 }
187 200
188 std::string ToSensitiveString() const { 201 std::string ToSensitiveString() const {
189 return ToStringInternal(true); 202 return ToStringInternal(true);
190 } 203 }
191 204
192 uint32_t GetPriority(uint32_t type_preference, 205 uint32_t GetPriority(uint32_t type_preference,
193 int network_adapter_preference, 206 int network_adapter_preference,
(...skipping 21 matching lines...) Expand all
215 return (type_preference << 24) | 228 return (type_preference << 24) |
216 (local_preference << 8) | 229 (local_preference << 8) |
217 (256 - component_); 230 (256 - component_);
218 } 231 }
219 232
220 private: 233 private:
221 std::string ToStringInternal(bool sensitive) const { 234 std::string ToStringInternal(bool sensitive) const {
222 std::ostringstream ost; 235 std::ostringstream ost;
223 std::string address = sensitive ? address_.ToSensitiveString() : 236 std::string address = sensitive ? address_.ToSensitiveString() :
224 address_.ToString(); 237 address_.ToString();
225 ost << "Cand[" << foundation_ << ":" << component_ << ":" << protocol_ 238 ost << "Cand[" << transport_name_ << ":" << foundation_ << ":" << component_
226 << ":" << priority_ << ":" << address << ":" << type_ << ":" 239 << ":" << protocol_ << ":" << priority_ << ":" << address << ":"
227 << related_address_ << ":" << username_ << ":" << password_ << ":" 240 << type_ << ":" << related_address_ << ":" << username_ << ":"
228 << network_cost_ << "]"; 241 << password_ << ":" << network_cost_ << "]";
229 return ost.str(); 242 return ost.str();
230 } 243 }
231 244
232 std::string id_; 245 std::string id_;
233 int component_; 246 int component_;
234 std::string protocol_; 247 std::string protocol_;
235 std::string relay_protocol_; 248 std::string relay_protocol_;
236 rtc::SocketAddress address_; 249 rtc::SocketAddress address_;
237 uint32_t priority_; 250 uint32_t priority_;
238 std::string username_; 251 std::string username_;
239 std::string password_; 252 std::string password_;
240 std::string type_; 253 std::string type_;
241 std::string network_name_; 254 std::string network_name_;
242 rtc::AdapterType network_type_; 255 rtc::AdapterType network_type_;
243 uint32_t generation_; 256 uint32_t generation_;
244 std::string foundation_; 257 std::string foundation_;
245 rtc::SocketAddress related_address_; 258 rtc::SocketAddress related_address_;
246 std::string tcptype_; 259 std::string tcptype_;
247 uint32_t network_cost_ = 0; 260 uint32_t network_cost_ = 0;
261 std::string transport_name_;
248 }; 262 };
249 263
250 // Used during parsing and writing to map component to channel name 264 // Used during parsing and writing to map component to channel name
251 // and back. This is primarily for converting old G-ICE candidate 265 // and back. This is primarily for converting old G-ICE candidate
252 // signalling to new ICE candidate classes. 266 // signalling to new ICE candidate classes.
253 class CandidateTranslator { 267 class CandidateTranslator {
254 public: 268 public:
255 virtual ~CandidateTranslator() {} 269 virtual ~CandidateTranslator() {}
256 virtual bool GetChannelNameFromComponent( 270 virtual bool GetChannelNameFromComponent(
257 int component, std::string* channel_name) const = 0; 271 int component, std::string* channel_name) const = 0;
258 virtual bool GetComponentFromChannelName( 272 virtual bool GetComponentFromChannelName(
259 const std::string& channel_name, int* component) const = 0; 273 const std::string& channel_name, int* component) const = 0;
260 }; 274 };
261 275
262 } // namespace cricket 276 } // namespace cricket
263 277
264 #endif // WEBRTC_P2P_BASE_CANDIDATE_H_ 278 #endif // WEBRTC_P2P_BASE_CANDIDATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698