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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 77 } |
78 | 78 |
79 const rtc::SocketAddress & address() const { return address_; } | 79 const rtc::SocketAddress & address() const { return address_; } |
80 void set_address(const rtc::SocketAddress & address) { | 80 void set_address(const rtc::SocketAddress & address) { |
81 address_ = address; | 81 address_ = address; |
82 } | 82 } |
83 | 83 |
84 uint32 priority() const { return priority_; } | 84 uint32 priority() const { return priority_; } |
85 void set_priority(const uint32 priority) { priority_ = priority; } | 85 void set_priority(const uint32 priority) { priority_ = priority; } |
86 | 86 |
87 // TODO(pthatcher): Remove once Chromium's jingle/glue/utils.cc | 87 // void set_type_preference(uint32 type_preference) { |
88 // doesn't use it. | 88 // priority_ = GetPriority(type_preference); |
| 89 // } |
| 90 |
89 // Maps old preference (which was 0.0-1.0) to match priority (which | 91 // Maps old preference (which was 0.0-1.0) to match priority (which |
90 // is 0-2^32-1) to to match RFC 5245, section 4.1.2.1. Also see | 92 // is 0-2^32-1) to to match RFC 5245, section 4.1.2.1. Also see |
91 // https://docs.google.com/a/google.com/document/d/ | 93 // https://docs.google.com/a/google.com/document/d/ |
92 // 1iNQDiwDKMh0NQOrCqbj3DKKRT0Dn5_5UJYhmZO-t7Uc/edit | 94 // 1iNQDiwDKMh0NQOrCqbj3DKKRT0Dn5_5UJYhmZO-t7Uc/edit |
93 float preference() const { | 95 float preference() const { |
94 // The preference value is clamped to two decimal precision. | 96 // The preference value is clamped to two decimal precision. |
95 return static_cast<float>(((priority_ >> 24) * 100 / 127) / 100.0); | 97 return static_cast<float>(((priority_ >> 24) * 100 / 127) / 100.0); |
96 } | 98 } |
97 | 99 |
98 // TODO(pthatcher): Remove once Chromium's jingle/glue/utils.cc | |
99 // doesn't use it. | |
100 void set_preference(float preference) { | 100 void set_preference(float preference) { |
101 // Limiting priority to UINT_MAX when value exceeds uint32 max. | 101 // Limiting priority to UINT_MAX when value exceeds uint32 max. |
102 // This can happen for e.g. when preference = 3. | 102 // This can happen for e.g. when preference = 3. |
103 uint64 prio_val = static_cast<uint64>(preference * 127) << 24; | 103 uint64 prio_val = static_cast<uint64>(preference * 127) << 24; |
104 priority_ = | 104 priority_ = |
105 static_cast<uint32>(std::min(prio_val, static_cast<uint64>(UINT_MAX))); | 105 static_cast<uint32>(std::min(prio_val, static_cast<uint64>(UINT_MAX))); |
106 } | 106 } |
107 | 107 |
108 const std::string & username() const { return username_; } | 108 const std::string & username() const { return username_; } |
109 void set_username(const std::string & username) { username_ = username; } | 109 void set_username(const std::string & username) { username_ = username; } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 virtual ~CandidateTranslator() {} | 242 virtual ~CandidateTranslator() {} |
243 virtual bool GetChannelNameFromComponent( | 243 virtual bool GetChannelNameFromComponent( |
244 int component, std::string* channel_name) const = 0; | 244 int component, std::string* channel_name) const = 0; |
245 virtual bool GetComponentFromChannelName( | 245 virtual bool GetComponentFromChannelName( |
246 const std::string& channel_name, int* component) const = 0; | 246 const std::string& channel_name, int* component) const = 0; |
247 }; | 247 }; |
248 | 248 |
249 } // namespace cricket | 249 } // namespace cricket |
250 | 250 |
251 #endif // WEBRTC_P2P_BASE_CANDIDATE_H_ | 251 #endif // WEBRTC_P2P_BASE_CANDIDATE_H_ |
OLD | NEW |