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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 void set_protocol(const std::string & protocol) { protocol_ = protocol; } | 71 void set_protocol(const std::string & protocol) { protocol_ = protocol; } |
72 | 72 |
73 const rtc::SocketAddress & address() const { return address_; } | 73 const rtc::SocketAddress & address() const { return address_; } |
74 void set_address(const rtc::SocketAddress & address) { | 74 void set_address(const rtc::SocketAddress & address) { |
75 address_ = address; | 75 address_ = address; |
76 } | 76 } |
77 | 77 |
78 uint32 priority() const { return priority_; } | 78 uint32 priority() const { return priority_; } |
79 void set_priority(const uint32 priority) { priority_ = priority; } | 79 void set_priority(const uint32 priority) { priority_ = priority; } |
80 | 80 |
81 // void set_type_preference(uint32 type_preference) { | |
82 // priority_ = GetPriority(type_preference); | |
83 // } | |
84 | |
85 // Maps old preference (which was 0.0-1.0) to match priority (which | |
86 // is 0-2^32-1) to to match RFC 5245, section 4.1.2.1. Also see | |
87 // https://docs.google.com/a/google.com/document/d/ | |
88 // 1iNQDiwDKMh0NQOrCqbj3DKKRT0Dn5_5UJYhmZO-t7Uc/edit | |
89 float preference() const { | |
90 // The preference value is clamped to two decimal precision. | |
91 return static_cast<float>(((priority_ >> 24) * 100 / 127) / 100.0); | |
92 } | |
93 | |
94 void set_preference(float preference) { | |
95 // Limiting priority to UINT_MAX when value exceeds uint32 max. | |
96 // This can happen for e.g. when preference = 3. | |
97 uint64 prio_val = static_cast<uint64>(preference * 127) << 24; | |
98 priority_ = | |
99 static_cast<uint32>(std::min(prio_val, static_cast<uint64>(UINT_MAX))); | |
100 } | |
101 | |
102 const std::string & username() const { return username_; } | 81 const std::string & username() const { return username_; } |
103 void set_username(const std::string & username) { username_ = username; } | 82 void set_username(const std::string & username) { username_ = username; } |
104 | 83 |
105 const std::string & password() const { return password_; } | 84 const std::string & password() const { return password_; } |
106 void set_password(const std::string & password) { password_ = password; } | 85 void set_password(const std::string & password) { password_ = password; } |
107 | 86 |
108 const std::string & type() const { return type_; } | 87 const std::string & type() const { return type_; } |
109 void set_type(const std::string & type) { type_ = type; } | 88 void set_type(const std::string & type) { type_ = type; } |
110 | 89 |
111 const std::string & network_name() const { return network_name_; } | 90 const std::string & network_name() const { return network_name_; } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 virtual ~CandidateTranslator() {} | 214 virtual ~CandidateTranslator() {} |
236 virtual bool GetChannelNameFromComponent( | 215 virtual bool GetChannelNameFromComponent( |
237 int component, std::string* channel_name) const = 0; | 216 int component, std::string* channel_name) const = 0; |
238 virtual bool GetComponentFromChannelName( | 217 virtual bool GetComponentFromChannelName( |
239 const std::string& channel_name, int* component) const = 0; | 218 const std::string& channel_name, int* component) const = 0; |
240 }; | 219 }; |
241 | 220 |
242 } // namespace cricket | 221 } // namespace cricket |
243 | 222 |
244 #endif // WEBRTC_P2P_BASE_CANDIDATE_H_ | 223 #endif // WEBRTC_P2P_BASE_CANDIDATE_H_ |
OLD | NEW |