OLD | NEW |
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 Loading... |
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 | |
178 // Determines whether this candidate is equivalent to the given one. | 172 // Determines whether this candidate is equivalent to the given one. |
179 bool IsEquivalent(const Candidate& c) const { | 173 bool IsEquivalent(const Candidate& c) const { |
180 // We ignore the network name, since that is just debug information, and | 174 // We ignore the network name, since that is just debug information, and |
181 // the priority, since that should be the same if the rest is (and it's | 175 // the priority, since that should be the same if the rest is (and it's |
182 // a float so equality checking is always worrisome). | 176 // a float so equality checking is always worrisome). |
183 return (component_ == c.component_) && (protocol_ == c.protocol_) && | 177 return (component_ == c.component_) && (protocol_ == c.protocol_) && |
184 (address_ == c.address_) && (username_ == c.username_) && | 178 (address_ == c.address_) && (username_ == c.username_) && |
185 (password_ == c.password_) && (type_ == c.type_) && | 179 (password_ == c.password_) && (type_ == c.type_) && |
186 (generation_ == c.generation_) && (foundation_ == c.foundation_) && | 180 (generation_ == c.generation_) && (foundation_ == c.foundation_) && |
187 (related_address_ == c.related_address_); | 181 (related_address_ == c.related_address_); |
188 } | 182 } |
189 | 183 |
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 | |
197 std::string ToString() const { | 184 std::string ToString() const { |
198 return ToStringInternal(false); | 185 return ToStringInternal(false); |
199 } | 186 } |
200 | 187 |
201 std::string ToSensitiveString() const { | 188 std::string ToSensitiveString() const { |
202 return ToStringInternal(true); | 189 return ToStringInternal(true); |
203 } | 190 } |
204 | 191 |
205 uint32_t GetPriority(uint32_t type_preference, | 192 uint32_t GetPriority(uint32_t type_preference, |
206 int network_adapter_preference, | 193 int network_adapter_preference, |
(...skipping 21 matching lines...) Expand all Loading... |
228 return (type_preference << 24) | | 215 return (type_preference << 24) | |
229 (local_preference << 8) | | 216 (local_preference << 8) | |
230 (256 - component_); | 217 (256 - component_); |
231 } | 218 } |
232 | 219 |
233 private: | 220 private: |
234 std::string ToStringInternal(bool sensitive) const { | 221 std::string ToStringInternal(bool sensitive) const { |
235 std::ostringstream ost; | 222 std::ostringstream ost; |
236 std::string address = sensitive ? address_.ToSensitiveString() : | 223 std::string address = sensitive ? address_.ToSensitiveString() : |
237 address_.ToString(); | 224 address_.ToString(); |
238 ost << "Cand[" << transport_name_ << ":" << foundation_ << ":" << component_ | 225 ost << "Cand[" << foundation_ << ":" << component_ << ":" << protocol_ |
239 << ":" << protocol_ << ":" << priority_ << ":" << address << ":" | 226 << ":" << priority_ << ":" << address << ":" << type_ << ":" |
240 << type_ << ":" << related_address_ << ":" << username_ << ":" | 227 << related_address_ << ":" << username_ << ":" << password_ << ":" |
241 << password_ << ":" << network_cost_ << "]"; | 228 << network_cost_ << "]"; |
242 return ost.str(); | 229 return ost.str(); |
243 } | 230 } |
244 | 231 |
245 std::string id_; | 232 std::string id_; |
246 int component_; | 233 int component_; |
247 std::string protocol_; | 234 std::string protocol_; |
248 std::string relay_protocol_; | 235 std::string relay_protocol_; |
249 rtc::SocketAddress address_; | 236 rtc::SocketAddress address_; |
250 uint32_t priority_; | 237 uint32_t priority_; |
251 std::string username_; | 238 std::string username_; |
252 std::string password_; | 239 std::string password_; |
253 std::string type_; | 240 std::string type_; |
254 std::string network_name_; | 241 std::string network_name_; |
255 rtc::AdapterType network_type_; | 242 rtc::AdapterType network_type_; |
256 uint32_t generation_; | 243 uint32_t generation_; |
257 std::string foundation_; | 244 std::string foundation_; |
258 rtc::SocketAddress related_address_; | 245 rtc::SocketAddress related_address_; |
259 std::string tcptype_; | 246 std::string tcptype_; |
260 uint32_t network_cost_ = 0; | 247 uint32_t network_cost_ = 0; |
261 std::string transport_name_; | |
262 }; | 248 }; |
263 | 249 |
264 // Used during parsing and writing to map component to channel name | 250 // Used during parsing and writing to map component to channel name |
265 // and back. This is primarily for converting old G-ICE candidate | 251 // and back. This is primarily for converting old G-ICE candidate |
266 // signalling to new ICE candidate classes. | 252 // signalling to new ICE candidate classes. |
267 class CandidateTranslator { | 253 class CandidateTranslator { |
268 public: | 254 public: |
269 virtual ~CandidateTranslator() {} | 255 virtual ~CandidateTranslator() {} |
270 virtual bool GetChannelNameFromComponent( | 256 virtual bool GetChannelNameFromComponent( |
271 int component, std::string* channel_name) const = 0; | 257 int component, std::string* channel_name) const = 0; |
272 virtual bool GetComponentFromChannelName( | 258 virtual bool GetComponentFromChannelName( |
273 const std::string& channel_name, int* component) const = 0; | 259 const std::string& channel_name, int* component) const = 0; |
274 }; | 260 }; |
275 | 261 |
276 } // namespace cricket | 262 } // namespace cricket |
277 | 263 |
278 #endif // WEBRTC_P2P_BASE_CANDIDATE_H_ | 264 #endif // WEBRTC_P2P_BASE_CANDIDATE_H_ |
OLD | NEW |