| 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 |
| 11 #ifndef WEBRTC_P2P_BASE_CANDIDATE_H_ | 11 #ifndef WEBRTC_P2P_BASE_CANDIDATE_H_ |
| 12 #define WEBRTC_P2P_BASE_CANDIDATE_H_ | 12 #define WEBRTC_P2P_BASE_CANDIDATE_H_ |
| 13 | 13 |
| 14 #include <limits.h> | 14 #include <limits.h> |
| 15 #include <math.h> | 15 #include <math.h> |
| 16 | 16 |
| 17 #include <algorithm> | 17 #include <algorithm> |
| 18 #include <iomanip> | 18 #include <iomanip> |
| 19 #include <sstream> | 19 #include <sstream> |
| 20 #include <string> | 20 #include <string> |
| 21 | 21 |
| 22 #include "webrtc/p2p/base/p2pconstants.h" | 22 #include "webrtc/p2p/base/p2pconstants.h" |
| 23 #include "webrtc/base/basictypes.h" | 23 #include "webrtc/base/basictypes.h" |
| 24 #include "webrtc/base/helpers.h" | 24 #include "webrtc/base/helpers.h" |
| 25 #include "webrtc/base/network.h" | 25 #include "webrtc/base/network.h" |
| 26 #include "webrtc/base/socketaddress.h" | 26 #include "webrtc/base/socketaddress.h" |
| 27 | 27 |
| 28 namespace cricket { | 28 namespace cricket { |
| 29 | 29 |
| 30 const uint16_t kMaxNetworkCost = 999; | |
| 31 | |
| 32 // Candidate for ICE based connection discovery. | 30 // Candidate for ICE based connection discovery. |
| 33 | 31 |
| 34 class Candidate { | 32 class Candidate { |
| 35 public: | 33 public: |
| 36 // TODO: Match the ordering and param list as per RFC 5245 | 34 // TODO: Match the ordering and param list as per RFC 5245 |
| 37 // candidate-attribute syntax. http://tools.ietf.org/html/rfc5245#section-15.1 | 35 // candidate-attribute syntax. http://tools.ietf.org/html/rfc5245#section-15.1 |
| 38 Candidate() | 36 Candidate() |
| 39 : id_(rtc::CreateRandomString(8)), | 37 : id_(rtc::CreateRandomString(8)), |
| 40 component_(0), | 38 component_(0), |
| 41 priority_(0), | 39 priority_(0), |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 ost << generation_; | 139 ost << generation_; |
| 142 return ost.str(); | 140 return ost.str(); |
| 143 } | 141 } |
| 144 void set_generation_str(const std::string& str) { | 142 void set_generation_str(const std::string& str) { |
| 145 std::istringstream ist(str); | 143 std::istringstream ist(str); |
| 146 ist >> generation_; | 144 ist >> generation_; |
| 147 } | 145 } |
| 148 | 146 |
| 149 // |network_cost| measures the cost/penalty of using this candidate. A network | 147 // |network_cost| measures the cost/penalty of using this candidate. A network |
| 150 // cost of 0 indicates this candidate can be used freely. A value of | 148 // cost of 0 indicates this candidate can be used freely. A value of |
| 151 // |kMaxNetworkCost| indicates it should be used only as the last resort. | 149 // rtc::kNetworkCostMax indicates it should be used only as the last resort. |
| 152 void set_network_cost(uint16_t network_cost) { | 150 void set_network_cost(uint16_t network_cost) { |
| 153 ASSERT(network_cost <= kMaxNetworkCost); | 151 ASSERT(network_cost <= rtc::kNetworkCostMax); |
| 154 network_cost_ = network_cost; | 152 network_cost_ = network_cost; |
| 155 } | 153 } |
| 156 uint16_t network_cost() const { return network_cost_; } | 154 uint16_t network_cost() const { return network_cost_; } |
| 157 | 155 |
| 158 // An ID assigned to the network hosting the candidate. | 156 // An ID assigned to the network hosting the candidate. |
| 159 uint16_t network_id() const { return network_id_; } | 157 uint16_t network_id() const { return network_id_; } |
| 160 void set_network_id(uint16_t network_id) { network_id_ = network_id; } | 158 void set_network_id(uint16_t network_id) { network_id_ = network_id; } |
| 161 | 159 |
| 162 const std::string& foundation() const { | 160 const std::string& foundation() const { |
| 163 return foundation_; | 161 return foundation_; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 virtual ~CandidateTranslator() {} | 293 virtual ~CandidateTranslator() {} |
| 296 virtual bool GetChannelNameFromComponent( | 294 virtual bool GetChannelNameFromComponent( |
| 297 int component, std::string* channel_name) const = 0; | 295 int component, std::string* channel_name) const = 0; |
| 298 virtual bool GetComponentFromChannelName( | 296 virtual bool GetComponentFromChannelName( |
| 299 const std::string& channel_name, int* component) const = 0; | 297 const std::string& channel_name, int* component) const = 0; |
| 300 }; | 298 }; |
| 301 | 299 |
| 302 } // namespace cricket | 300 } // namespace cricket |
| 303 | 301 |
| 304 #endif // WEBRTC_P2P_BASE_CANDIDATE_H_ | 302 #endif // WEBRTC_P2P_BASE_CANDIDATE_H_ |
| OLD | NEW |