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) { | 81 // TODO(pthatcher): Remove once Chromium's jingle/glue/utils.cc doesn't use it
. |
82 // priority_ = GetPriority(type_preference); | |
83 // } | |
84 | |
85 // Maps old preference (which was 0.0-1.0) to match priority (which | 82 // 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 | 83 // 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/ | 84 // https://docs.google.com/a/google.com/document/d/ |
88 // 1iNQDiwDKMh0NQOrCqbj3DKKRT0Dn5_5UJYhmZO-t7Uc/edit | 85 // 1iNQDiwDKMh0NQOrCqbj3DKKRT0Dn5_5UJYhmZO-t7Uc/edit |
89 float preference() const { | 86 float preference() const { |
90 // The preference value is clamped to two decimal precision. | 87 // The preference value is clamped to two decimal precision. |
91 return static_cast<float>(((priority_ >> 24) * 100 / 127) / 100.0); | 88 return static_cast<float>(((priority_ >> 24) * 100 / 127) / 100.0); |
92 } | 89 } |
93 | 90 |
| 91 // TODO(pthatcher): Remove once Chromium's jingle/glue/utils.cc doesn't use it
. |
94 void set_preference(float preference) { | 92 void set_preference(float preference) { |
95 // Limiting priority to UINT_MAX when value exceeds uint32 max. | 93 // Limiting priority to UINT_MAX when value exceeds uint32 max. |
96 // This can happen for e.g. when preference = 3. | 94 // This can happen for e.g. when preference = 3. |
97 uint64 prio_val = static_cast<uint64>(preference * 127) << 24; | 95 uint64 prio_val = static_cast<uint64>(preference * 127) << 24; |
98 priority_ = | 96 priority_ = |
99 static_cast<uint32>(std::min(prio_val, static_cast<uint64>(UINT_MAX))); | 97 static_cast<uint32>(std::min(prio_val, static_cast<uint64>(UINT_MAX))); |
100 } | 98 } |
101 | 99 |
102 const std::string & username() const { return username_; } | 100 const std::string & username() const { return username_; } |
103 void set_username(const std::string & username) { username_ = username; } | 101 void set_username(const std::string & username) { username_ = username; } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 virtual ~CandidateTranslator() {} | 233 virtual ~CandidateTranslator() {} |
236 virtual bool GetChannelNameFromComponent( | 234 virtual bool GetChannelNameFromComponent( |
237 int component, std::string* channel_name) const = 0; | 235 int component, std::string* channel_name) const = 0; |
238 virtual bool GetComponentFromChannelName( | 236 virtual bool GetComponentFromChannelName( |
239 const std::string& channel_name, int* component) const = 0; | 237 const std::string& channel_name, int* component) const = 0; |
240 }; | 238 }; |
241 | 239 |
242 } // namespace cricket | 240 } // namespace cricket |
243 | 241 |
244 #endif // WEBRTC_P2P_BASE_CANDIDATE_H_ | 242 #endif // WEBRTC_P2P_BASE_CANDIDATE_H_ |
OLD | NEW |