| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 // covered by the sequence numbers may not be larger than floor(M/2). | 77 // covered by the sequence numbers may not be larger than floor(M/2). |
| 78 template <typename T, T M = 0> | 78 template <typename T, T M = 0> |
| 79 struct DescendingSeqNumComp { | 79 struct DescendingSeqNumComp { |
| 80 bool operator()(T a, T b) const { return AheadOf<T, M>(b, a); } | 80 bool operator()(T a, T b) const { return AheadOf<T, M>(b, a); } |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 // A sequencer number unwrapper where the start value of the unwrapped sequence | 83 // A sequencer number unwrapper where the start value of the unwrapped sequence |
| 84 // can be set. The unwrapped value is not allowed to wrap. | 84 // can be set. The unwrapped value is not allowed to wrap. |
| 85 template <typename T, T M = 0> | 85 template <typename T, T M = 0> |
| 86 class SeqNumUnwrapper { | 86 class SeqNumUnwrapper { |
| 87 // Use '<' instead of rtc::SafeLt to avoid crbug.com/753488 |
| 87 static_assert( | 88 static_assert( |
| 88 std::is_unsigned<T>::value && | 89 std::is_unsigned<T>::value && |
| 89 rtc::SafeLt(std::numeric_limits<T>::max(), | 90 std::numeric_limits<T>::max() < std::numeric_limits<uint64_t>::max(), |
| 90 std::numeric_limits<uint64_t>::max()), | |
| 91 "Type unwrapped must be an unsigned integer smaller than uint64_t."); | 91 "Type unwrapped must be an unsigned integer smaller than uint64_t."); |
| 92 | 92 |
| 93 public: | 93 public: |
| 94 SeqNumUnwrapper() : last_unwrapped_(0) {} | 94 SeqNumUnwrapper() : last_unwrapped_(0) {} |
| 95 explicit SeqNumUnwrapper(uint64_t start_at) : last_unwrapped_(start_at) {} | 95 explicit SeqNumUnwrapper(uint64_t start_at) : last_unwrapped_(start_at) {} |
| 96 | 96 |
| 97 uint64_t Unwrap(T value) { | 97 uint64_t Unwrap(T value) { |
| 98 if (!last_value_) | 98 if (!last_value_) |
| 99 last_value_.emplace(value); | 99 last_value_.emplace(value); |
| 100 | 100 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 113 } | 113 } |
| 114 | 114 |
| 115 private: | 115 private: |
| 116 uint64_t last_unwrapped_; | 116 uint64_t last_unwrapped_; |
| 117 rtc::Optional<T> last_value_; | 117 rtc::Optional<T> last_value_; |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 } // namespace webrtc | 120 } // namespace webrtc |
| 121 | 121 |
| 122 #endif // WEBRTC_MODULES_VIDEO_CODING_SEQUENCE_NUMBER_UTIL_H_ | 122 #endif // WEBRTC_MODULES_VIDEO_CODING_SEQUENCE_NUMBER_UTIL_H_ |
| OLD | NEW |