diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn index d65f6412b4..0424b55805 100644 --- a/api/video/BUILD.gn +++ b/api/video/BUILD.gn @@ -185,6 +185,7 @@ rtc_library("rtp_video_frame_assembler") { "../../modules/video_coding:packet_buffer", "../../modules/video_coding:video_coding", "../../rtc_base:logging", + "../../rtc_base:rtc_numerics", ] absl_deps = [ diff --git a/api/video/rtp_video_frame_assembler.cc b/api/video/rtp_video_frame_assembler.cc index 81c08389bb..b748534f3f 100644 --- a/api/video/rtp_video_frame_assembler.cc +++ b/api/video/rtp_video_frame_assembler.cc @@ -32,6 +32,7 @@ #include "modules/video_coding/packet_buffer.h" #include "modules/video_coding/rtp_frame_reference_finder.h" #include "rtc_base/logging.h" +#include "rtc_base/numerics/sequence_number_unwrapper.h" namespace webrtc { namespace { diff --git a/logging/rtc_event_log/rtc_event_log_parser.cc b/logging/rtc_event_log/rtc_event_log_parser.cc index 7e471ddd0f..b37d29d7e3 100644 --- a/logging/rtc_event_log/rtc_event_log_parser.cc +++ b/logging/rtc_event_log/rtc_event_log_parser.cc @@ -42,7 +42,7 @@ #include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_conversions.h" -#include "rtc_base/numerics/sequence_number_util.h" +#include "rtc_base/numerics/sequence_number_unwrapper.h" #include "rtc_base/protobuf_utils.h" #include "rtc_base/system/file_wrapper.h" diff --git a/modules/remote_bitrate_estimator/remote_estimator_proxy.h b/modules/remote_bitrate_estimator/remote_estimator_proxy.h index 7b0a8a6c49..54257ea6f0 100644 --- a/modules/remote_bitrate_estimator/remote_estimator_proxy.h +++ b/modules/remote_bitrate_estimator/remote_estimator_proxy.h @@ -26,7 +26,7 @@ #include "modules/remote_bitrate_estimator/packet_arrival_map.h" #include "modules/rtp_rtcp/source/rtcp_packet.h" #include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" -#include "rtc_base/numerics/sequence_number_util.h" +#include "rtc_base/numerics/sequence_number_unwrapper.h" #include "rtc_base/synchronization/mutex.h" namespace webrtc { diff --git a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc index 4d8786c824..2713171616 100644 --- a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc +++ b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc @@ -33,7 +33,7 @@ #include "modules/video_coding/svc/scalable_video_controller_no_layering.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" -#include "rtc_base/numerics/sequence_number_util.h" +#include "rtc_base/numerics/sequence_number_unwrapper.h" #include "third_party/libaom/source/libaom/aom/aom_codec.h" #include "third_party/libaom/source/libaom/aom/aom_encoder.h" #include "third_party/libaom/source/libaom/aom/aomcx.h" diff --git a/modules/video_coding/h264_packet_buffer.h b/modules/video_coding/h264_packet_buffer.h index 1671fddb23..a72c240e82 100644 --- a/modules/video_coding/h264_packet_buffer.h +++ b/modules/video_coding/h264_packet_buffer.h @@ -18,7 +18,7 @@ #include "absl/base/attributes.h" #include "absl/types/optional.h" #include "modules/video_coding/packet_buffer.h" -#include "rtc_base/numerics/sequence_number_util.h" +#include "rtc_base/numerics/sequence_number_unwrapper.h" namespace webrtc { diff --git a/modules/video_coding/packet_buffer_unittest.cc b/modules/video_coding/packet_buffer_unittest.cc index 49afa148e9..b147977ab6 100644 --- a/modules/video_coding/packet_buffer_unittest.cc +++ b/modules/video_coding/packet_buffer_unittest.cc @@ -18,6 +18,7 @@ #include "api/array_view.h" #include "common_video/h264/h264_common.h" #include "modules/video_coding/frame_object.h" +#include "rtc_base/numerics/sequence_number_unwrapper.h" #include "rtc_base/random.h" #include "test/field_trial.h" #include "test/gmock.h" diff --git a/modules/video_coding/rtp_frame_id_only_ref_finder.h b/modules/video_coding/rtp_frame_id_only_ref_finder.h index 1df4870c5b..5c0bdc8b26 100644 --- a/modules/video_coding/rtp_frame_id_only_ref_finder.h +++ b/modules/video_coding/rtp_frame_id_only_ref_finder.h @@ -16,7 +16,7 @@ #include "absl/container/inlined_vector.h" #include "modules/video_coding/frame_object.h" #include "modules/video_coding/rtp_frame_reference_finder.h" -#include "rtc_base/numerics/sequence_number_util.h" +#include "rtc_base/numerics/sequence_number_unwrapper.h" namespace webrtc { diff --git a/modules/video_coding/rtp_seq_num_only_ref_finder.h b/modules/video_coding/rtp_seq_num_only_ref_finder.h index ef3c022111..c05655b579 100644 --- a/modules/video_coding/rtp_seq_num_only_ref_finder.h +++ b/modules/video_coding/rtp_seq_num_only_ref_finder.h @@ -20,7 +20,7 @@ #include "absl/container/inlined_vector.h" #include "modules/video_coding/frame_object.h" #include "modules/video_coding/rtp_frame_reference_finder.h" -#include "rtc_base/numerics/sequence_number_util.h" +#include "rtc_base/numerics/sequence_number_unwrapper.h" namespace webrtc { diff --git a/modules/video_coding/rtp_vp8_ref_finder.h b/modules/video_coding/rtp_vp8_ref_finder.h index 1ae45cdba3..26df658a3b 100644 --- a/modules/video_coding/rtp_vp8_ref_finder.h +++ b/modules/video_coding/rtp_vp8_ref_finder.h @@ -19,7 +19,7 @@ #include "absl/container/inlined_vector.h" #include "modules/video_coding/frame_object.h" #include "modules/video_coding/rtp_frame_reference_finder.h" -#include "rtc_base/numerics/sequence_number_util.h" +#include "rtc_base/numerics/sequence_number_unwrapper.h" namespace webrtc { diff --git a/modules/video_coding/rtp_vp9_ref_finder.h b/modules/video_coding/rtp_vp9_ref_finder.h index 2971f686b1..ea5e319fc8 100644 --- a/modules/video_coding/rtp_vp9_ref_finder.h +++ b/modules/video_coding/rtp_vp9_ref_finder.h @@ -19,7 +19,7 @@ #include "absl/container/inlined_vector.h" #include "modules/video_coding/frame_object.h" #include "modules/video_coding/rtp_frame_reference_finder.h" -#include "rtc_base/numerics/sequence_number_util.h" +#include "rtc_base/numerics/sequence_number_unwrapper.h" namespace webrtc { diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index 5d4cdb33d4..07dec5d5a7 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -775,6 +775,7 @@ rtc_library("rtc_numerics") { "numerics/moving_percentile_filter.h", "numerics/percentile_filter.h", "numerics/running_statistics.h", + "numerics/sequence_number_unwrapper.h", "numerics/sequence_number_util.h", ] deps = [ @@ -1696,6 +1697,7 @@ if (rtc_include_tests) { "numerics/moving_percentile_filter_unittest.cc", "numerics/percentile_filter_unittest.cc", "numerics/running_statistics_unittest.cc", + "numerics/sequence_number_unwrapper_unittest.cc", "numerics/sequence_number_util_unittest.cc", "numerics/sequence_numbers_conformance_test.cc", ] diff --git a/rtc_base/numerics/sequence_number_unwrapper.h b/rtc_base/numerics/sequence_number_unwrapper.h new file mode 100644 index 0000000000..d741b5c910 --- /dev/null +++ b/rtc_base/numerics/sequence_number_unwrapper.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef RTC_BASE_NUMERICS_SEQUENCE_NUMBER_UNWRAPPER_H_ +#define RTC_BASE_NUMERICS_SEQUENCE_NUMBER_UNWRAPPER_H_ + +#include + +#include + +#include "absl/types/optional.h" +#include "rtc_base/numerics/sequence_number_util.h" + +namespace webrtc { + +// A sequence number unwrapper where the first unwrapped value equals the +// first value being unwrapped. +template +class SeqNumUnwrapper { + static_assert( + std::is_unsigned::value && + std::numeric_limits::max() < std::numeric_limits::max(), + "Type unwrapped must be an unsigned integer smaller than int64_t."); + + public: + // Unwraps `value` and updates the internal state of the unwrapper. + int64_t Unwrap(T value) { + if (!last_value_) { + last_unwrapped_ = {value}; + } else { + last_unwrapped_ += Delta(*last_value_, value); + } + + last_value_ = value; + return last_unwrapped_; + } + + // Returns the `value` without updating the internal state of the unwrapper. + int64_t PeekUnwrap(T value) const { + if (!last_value_) { + return value; + } + return last_unwrapped_ + Delta(*last_value_, value); + } + + // Resets the unwrapper to its initial state. Unwrapped sequence numbers will + // being at 0 after resetting. + void Reset() { + last_unwrapped_ = 0; + last_value_.reset(); + } + + private: + static int64_t Delta(T last_value, T new_value) { + constexpr int64_t kBackwardAdjustment = + M == 0 ? int64_t{std::numeric_limits::max()} + 1 : M; + int64_t result = ForwardDiff(last_value, new_value); + if (!AheadOrAt(new_value, last_value)) { + result -= kBackwardAdjustment; + } + return result; + } + + int64_t last_unwrapped_ = 0; + absl::optional last_value_; +}; + +using RtpTimestampUnwrapper = SeqNumUnwrapper; +using RtpSequenceNumberUnwrapper = SeqNumUnwrapper; + +} // namespace webrtc + +#endif // RTC_BASE_NUMERICS_SEQUENCE_NUMBER_UNWRAPPER_H_ diff --git a/rtc_base/numerics/sequence_number_unwrapper_unittest.cc b/rtc_base/numerics/sequence_number_unwrapper_unittest.cc new file mode 100644 index 0000000000..fcd903bab4 --- /dev/null +++ b/rtc_base/numerics/sequence_number_unwrapper_unittest.cc @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "rtc_base/numerics/sequence_number_unwrapper.h" + +#include + +#include "test/gtest.h" + +namespace webrtc { + +TEST(SeqNumUnwrapper, PreserveStartValue) { + SeqNumUnwrapper unwrapper; + EXPECT_EQ(123, unwrapper.Unwrap(123)); +} + +TEST(SeqNumUnwrapper, ForwardWrap) { + SeqNumUnwrapper unwrapper; + EXPECT_EQ(255, unwrapper.Unwrap(255)); + EXPECT_EQ(256, unwrapper.Unwrap(0)); +} + +TEST(SeqNumUnwrapper, ForwardWrapWithDivisor) { + SeqNumUnwrapper unwrapper; + EXPECT_EQ(30, unwrapper.Unwrap(30)); + EXPECT_EQ(36, unwrapper.Unwrap(3)); +} + +TEST(SeqNumUnwrapper, BackWardWrap) { + SeqNumUnwrapper unwrapper; + EXPECT_EQ(0, unwrapper.Unwrap(0)); + EXPECT_EQ(-2, unwrapper.Unwrap(254)); +} + +TEST(SeqNumUnwrapper, BackWardWrapWithDivisor) { + SeqNumUnwrapper unwrapper; + EXPECT_EQ(0, unwrapper.Unwrap(0)); + EXPECT_EQ(-2, unwrapper.Unwrap(31)); +} + +TEST(SeqNumUnwrapper, Unwrap) { + SeqNumUnwrapper unwrapper; + const uint16_t kMax = std::numeric_limits::max(); + const uint16_t kMaxDist = kMax / 2 + 1; + + EXPECT_EQ(0, unwrapper.Unwrap(0)); + EXPECT_EQ(kMaxDist, unwrapper.Unwrap(kMaxDist)); + EXPECT_EQ(0, unwrapper.Unwrap(0)); + + EXPECT_EQ(kMaxDist, unwrapper.Unwrap(kMaxDist)); + EXPECT_EQ(kMax, unwrapper.Unwrap(kMax)); + EXPECT_EQ(kMax + 1, unwrapper.Unwrap(0)); + EXPECT_EQ(kMax, unwrapper.Unwrap(kMax)); + EXPECT_EQ(kMaxDist, unwrapper.Unwrap(kMaxDist)); + EXPECT_EQ(0, unwrapper.Unwrap(0)); +} + +TEST(SeqNumUnwrapper, UnwrapOddDivisor) { + SeqNumUnwrapper unwrapper; + + EXPECT_EQ(10, unwrapper.Unwrap(10)); + EXPECT_EQ(11, unwrapper.Unwrap(0)); + EXPECT_EQ(16, unwrapper.Unwrap(5)); + EXPECT_EQ(21, unwrapper.Unwrap(10)); + EXPECT_EQ(22, unwrapper.Unwrap(0)); + EXPECT_EQ(17, unwrapper.Unwrap(6)); + EXPECT_EQ(12, unwrapper.Unwrap(1)); + EXPECT_EQ(7, unwrapper.Unwrap(7)); + EXPECT_EQ(2, unwrapper.Unwrap(2)); + EXPECT_EQ(0, unwrapper.Unwrap(0)); +} + +TEST(SeqNumUnwrapper, ManyForwardWraps) { + const int kLargeNumber = 4711; + const int kMaxStep = kLargeNumber / 2; + const int kNumWraps = 100; + SeqNumUnwrapper unwrapper; + + uint16_t next_unwrap = 0; + int64_t expected = 0; + for (int i = 0; i < kNumWraps * 2 + 1; ++i) { + EXPECT_EQ(expected, unwrapper.Unwrap(next_unwrap)); + expected += kMaxStep; + next_unwrap = (next_unwrap + kMaxStep) % kLargeNumber; + } +} + +TEST(SeqNumUnwrapper, ManyBackwardWraps) { + const int kLargeNumber = 4711; + const int kMaxStep = kLargeNumber / 2; + const int kNumWraps = 100; + SeqNumUnwrapper unwrapper; + + uint16_t next_unwrap = 0; + int64_t expected = 0; + for (uint16_t i = 0; i < kNumWraps * 2 + 1; ++i) { + EXPECT_EQ(expected, unwrapper.Unwrap(next_unwrap)); + expected -= kMaxStep; + next_unwrap = (next_unwrap + kMaxStep + 1) % kLargeNumber; + } +} + +TEST(SeqNumUnwrapper, Reset) { + const uint16_t kMax = std::numeric_limits::max(); + const uint16_t kMaxStep = kMax / 2; + SeqNumUnwrapper unwrapper; + EXPECT_EQ(10, unwrapper.Unwrap(10)); + EXPECT_EQ(kMaxStep + 10, unwrapper.Unwrap(kMaxStep + 10)); + + EXPECT_EQ(kMax + 3, unwrapper.PeekUnwrap(2)); + unwrapper.Reset(); + // After Reset() the range is reset back to the start. + EXPECT_EQ(2, unwrapper.PeekUnwrap(2)); +} + +TEST(SeqNumUnwrapper, PeekUnwrap) { + const uint16_t kMax = std::numeric_limits::max(); + const uint16_t kMaxStep = kMax / 2; + const uint16_t kMaxDist = kMaxStep + 1; + SeqNumUnwrapper unwrapper; + // No previous unwraps, so PeekUnwrap(x) == x. + EXPECT_EQ(10, unwrapper.PeekUnwrap(10)); + EXPECT_EQ(kMaxDist + 10, unwrapper.PeekUnwrap(kMaxDist + 10)); + + EXPECT_EQ(10, unwrapper.Unwrap(10)); + EXPECT_EQ(12, unwrapper.PeekUnwrap(12)); + // State should not have updated, so kMaxDist + 12 should be negative. + EXPECT_EQ(-kMaxDist + 12, unwrapper.Unwrap(kMaxDist + 12)); + + // Test PeekUnwrap after around. + unwrapper.Reset(); + EXPECT_EQ(kMaxStep, unwrapper.Unwrap(kMaxStep)); + EXPECT_EQ(2 * kMaxStep, unwrapper.Unwrap(2 * kMaxStep)); + EXPECT_EQ(kMax + 1, unwrapper.PeekUnwrap(0)); + // Wrap back to last range. + EXPECT_EQ(kMax - 3, unwrapper.PeekUnwrap(kMax - 3)); +} + +} // namespace webrtc diff --git a/rtc_base/numerics/sequence_number_util.h b/rtc_base/numerics/sequence_number_util.h index d68c064b63..702b82fa2b 100644 --- a/rtc_base/numerics/sequence_number_util.h +++ b/rtc_base/numerics/sequence_number_util.h @@ -16,8 +16,6 @@ #include #include -#include "absl/types/optional.h" -#include "rtc_base/checks.h" #include "rtc_base/numerics/mod_ops.h" namespace webrtc { @@ -82,38 +80,6 @@ struct DescendingSeqNumComp { bool operator()(T a, T b) const { return AheadOf(b, a); } }; -// A sequence number unwrapper where the first unwrapped value equals the -// first value being unwrapped. -template -class SeqNumUnwrapper { - static_assert( - std::is_unsigned::value && - std::numeric_limits::max() < std::numeric_limits::max(), - "Type unwrapped must be an unsigned integer smaller than int64_t."); - - public: - int64_t Unwrap(T value) { - if (!last_value_) { - last_unwrapped_ = {value}; - } else { - last_unwrapped_ += ForwardDiff(*last_value_, value); - - if (!AheadOrAt(value, *last_value_)) { - constexpr int64_t kBackwardAdjustment = - M == 0 ? int64_t{std::numeric_limits::max()} + 1 : M; - last_unwrapped_ -= kBackwardAdjustment; - } - } - - last_value_ = value; - return last_unwrapped_; - } - - private: - int64_t last_unwrapped_ = 0; - absl::optional last_value_; -}; - } // namespace webrtc #endif // RTC_BASE_NUMERICS_SEQUENCE_NUMBER_UTIL_H_ diff --git a/rtc_base/numerics/sequence_number_util_unittest.cc b/rtc_base/numerics/sequence_number_util_unittest.cc index d7fa0b1467..d44127bfa5 100644 --- a/rtc_base/numerics/sequence_number_util_unittest.cc +++ b/rtc_base/numerics/sequence_number_util_unittest.cc @@ -212,95 +212,4 @@ TEST_F(TestSeqNumUtil, SeqNumComparatorWithDivisor) { } } -TEST(SeqNumUnwrapper, PreserveStartValue) { - SeqNumUnwrapper unwrapper; - EXPECT_EQ(123, unwrapper.Unwrap(123)); -} - -TEST(SeqNumUnwrapper, ForwardWrap) { - SeqNumUnwrapper unwrapper; - EXPECT_EQ(255, unwrapper.Unwrap(255)); - EXPECT_EQ(256, unwrapper.Unwrap(0)); -} - -TEST(SeqNumUnwrapper, ForwardWrapWithDivisor) { - SeqNumUnwrapper unwrapper; - EXPECT_EQ(30, unwrapper.Unwrap(30)); - EXPECT_EQ(36, unwrapper.Unwrap(3)); -} - -TEST(SeqNumUnwrapper, BackWardWrap) { - SeqNumUnwrapper unwrapper; - EXPECT_EQ(0, unwrapper.Unwrap(0)); - EXPECT_EQ(-2, unwrapper.Unwrap(254)); -} - -TEST(SeqNumUnwrapper, BackWardWrapWithDivisor) { - SeqNumUnwrapper unwrapper; - EXPECT_EQ(0, unwrapper.Unwrap(0)); - EXPECT_EQ(-2, unwrapper.Unwrap(31)); -} - -TEST(SeqNumUnwrapper, Unwrap) { - SeqNumUnwrapper unwrapper; - const uint16_t kMax = std::numeric_limits::max(); - const uint16_t kMaxDist = kMax / 2 + 1; - - EXPECT_EQ(0, unwrapper.Unwrap(0)); - EXPECT_EQ(kMaxDist, unwrapper.Unwrap(kMaxDist)); - EXPECT_EQ(0, unwrapper.Unwrap(0)); - - EXPECT_EQ(kMaxDist, unwrapper.Unwrap(kMaxDist)); - EXPECT_EQ(kMax, unwrapper.Unwrap(kMax)); - EXPECT_EQ(kMax + 1, unwrapper.Unwrap(0)); - EXPECT_EQ(kMax, unwrapper.Unwrap(kMax)); - EXPECT_EQ(kMaxDist, unwrapper.Unwrap(kMaxDist)); - EXPECT_EQ(0, unwrapper.Unwrap(0)); -} - -TEST(SeqNumUnwrapper, UnwrapOddDivisor) { - SeqNumUnwrapper unwrapper; - - EXPECT_EQ(10, unwrapper.Unwrap(10)); - EXPECT_EQ(11, unwrapper.Unwrap(0)); - EXPECT_EQ(16, unwrapper.Unwrap(5)); - EXPECT_EQ(21, unwrapper.Unwrap(10)); - EXPECT_EQ(22, unwrapper.Unwrap(0)); - EXPECT_EQ(17, unwrapper.Unwrap(6)); - EXPECT_EQ(12, unwrapper.Unwrap(1)); - EXPECT_EQ(7, unwrapper.Unwrap(7)); - EXPECT_EQ(2, unwrapper.Unwrap(2)); - EXPECT_EQ(0, unwrapper.Unwrap(0)); -} - -TEST(SeqNumUnwrapper, ManyForwardWraps) { - const int kLargeNumber = 4711; - const int kMaxStep = kLargeNumber / 2; - const int kNumWraps = 100; - SeqNumUnwrapper unwrapper; - - uint16_t next_unwrap = 0; - int64_t expected = 0; - for (int i = 0; i < kNumWraps * 2 + 1; ++i) { - EXPECT_EQ(expected, unwrapper.Unwrap(next_unwrap)); - expected += kMaxStep; - next_unwrap = (next_unwrap + kMaxStep) % kLargeNumber; - } -} - -TEST(SeqNumUnwrapper, ManyBackwardWraps) { - const int kLargeNumber = 4711; - const int kMaxStep = kLargeNumber / 2; - const int kNumWraps = 100; - SeqNumUnwrapper unwrapper; - - uint16_t next_unwrap = 0; - int64_t expected = 0; - for (uint16_t i = 0; i < kNumWraps * 2 + 1; ++i) { - EXPECT_EQ(expected, unwrapper.Unwrap(next_unwrap)); - expected -= kMaxStep; - next_unwrap = (next_unwrap + kMaxStep + 1) % kLargeNumber; - } -} - } // namespace webrtc diff --git a/rtc_base/numerics/sequence_numbers_conformance_test.cc b/rtc_base/numerics/sequence_numbers_conformance_test.cc index 8c5bc62e56..62f7eb7b1d 100644 --- a/rtc_base/numerics/sequence_numbers_conformance_test.cc +++ b/rtc_base/numerics/sequence_numbers_conformance_test.cc @@ -14,7 +14,7 @@ #include "modules/include/module_common_types_public.h" #include "net/dcsctp/common/sequence_numbers.h" -#include "rtc_base/numerics/sequence_number_util.h" +#include "rtc_base/numerics/sequence_number_unwrapper.h" #include "rtc_base/strong_alias.h" #include "rtc_base/time_utils.h" #include "test/gmock.h" @@ -26,7 +26,7 @@ namespace { using ::testing::Test; using dcsctp::UnwrappedSequenceNumber; -using Wrapped = webrtc::StrongAlias; +using Wrapped = StrongAlias; using TestSequence = UnwrappedSequenceNumber; template @@ -84,9 +84,9 @@ TYPED_TEST_P(UnwrapperConformanceFixture, PositiveWrapAround) { TYPED_TEST_P(UnwrapperConformanceFixture, NegativeUnwrap) { using UnwrapperT = decltype(this->ref_unwrapper_); - // webrtc::TimestampUnwrapper known to not handle negative numbers. + // TimestampUnwrapper known to not handle negative numbers. // rtc::TimestampWrapAroundHandler does not wrap around correctly. - if constexpr (std::is_same() || + if constexpr (std::is_same() || std::is_same()) { return; } @@ -134,10 +134,10 @@ TYPED_TEST_P(UnwrapperConformanceFixture, WrapBoundaries) { TYPED_TEST_P(UnwrapperConformanceFixture, MultipleNegativeWrapArounds) { using UnwrapperT = decltype(this->ref_unwrapper_); - // webrtc::TimestampUnwrapper known to not handle negative numbers. - // webrtc::SequenceNumberUnwrapper can only wrap negative once. + // TimestampUnwrapper known to not handle negative numbers. + // SequenceNumberUnwrapper can only wrap negative once. // rtc::TimestampWrapAroundHandler does not wrap around correctly. - if constexpr (std::is_same() || + if constexpr (std::is_same() || std::is_same>() || std::is_same()) { @@ -164,11 +164,11 @@ REGISTER_TYPED_TEST_SUITE_P(UnwrapperConformanceFixture, constexpr int64_t k15BitMax = (int64_t{1} << 15) - 1; using UnwrapperTypes = ::testing::Types< FixtureParams, - FixtureParams, - FixtureParams>, + FixtureParams, + FixtureParams, FixtureParams>, // SeqNumUnwrapper supports arbitrary limits. - FixtureParams, k15BitMax>>; + FixtureParams, k15BitMax>>; class TestNames { public: @@ -177,15 +177,13 @@ class TestNames { if constexpr (std::is_same()) return "TimestampWrapAroundHandler"; - if constexpr (std::is_same()) + if constexpr (std::is_same()) return "TimestampUnwrapper"; if constexpr (std::is_same>()) + SeqNumUnwrapper>()) return "SeqNumUnwrapper"; - if constexpr (std::is_same< - typename T::Unwrapper, - webrtc::SeqNumUnwrapper>()) + if constexpr (std::is_same>()) return "SeqNumUnwrapper15bit"; if constexpr (std::is_same>()) diff --git a/rtc_tools/rtc_event_log_visualizer/alerts.cc b/rtc_tools/rtc_event_log_visualizer/alerts.cc index 9ef5e9a77a..a9f50cdd5c 100644 --- a/rtc_tools/rtc_event_log_visualizer/alerts.cc +++ b/rtc_tools/rtc_event_log_visualizer/alerts.cc @@ -20,7 +20,7 @@ #include "logging/rtc_event_log/rtc_event_processor.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" -#include "rtc_base/numerics/sequence_number_util.h" +#include "rtc_base/numerics/sequence_number_unwrapper.h" #include "rtc_base/strings/string_builder.h" namespace webrtc { diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer.cc b/rtc_tools/rtc_event_log_visualizer/analyzer.cc index ddd65cb6c5..6b9449fbe5 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer.cc +++ b/rtc_tools/rtc_event_log_visualizer/analyzer.cc @@ -49,7 +49,7 @@ #include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" -#include "rtc_base/numerics/sequence_number_util.h" +#include "rtc_base/numerics/sequence_number_unwrapper.h" #include "rtc_base/rate_statistics.h" #include "rtc_base/strings/string_builder.h" #include "rtc_tools/rtc_event_log_visualizer/log_simulation.h" diff --git a/test/fuzzers/frame_buffer_fuzzer.cc b/test/fuzzers/frame_buffer_fuzzer.cc index ea009938d0..e58d5e9f98 100644 --- a/test/fuzzers/frame_buffer_fuzzer.cc +++ b/test/fuzzers/frame_buffer_fuzzer.cc @@ -11,7 +11,7 @@ #include "api/array_view.h" #include "api/video/encoded_frame.h" #include "api/video/frame_buffer.h" -#include "rtc_base/numerics/sequence_number_util.h" +#include "rtc_base/numerics/sequence_number_unwrapper.h" #include "test/fuzzers/fuzz_data_helper.h" #include "test/scoped_key_value_config.h" diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h index 782fa522f7..862db6c861 100644 --- a/video/rtp_video_stream_receiver2.h +++ b/video/rtp_video_stream_receiver2.h @@ -43,7 +43,7 @@ #include "modules/video_coding/packet_buffer.h" #include "modules/video_coding/rtp_frame_reference_finder.h" #include "rtc_base/experiments/field_trial_parser.h" -#include "rtc_base/numerics/sequence_number_util.h" +#include "rtc_base/numerics/sequence_number_unwrapper.h" #include "rtc_base/system/no_unique_address.h" #include "rtc_base/thread_annotations.h" #include "video/buffered_frame_decryptor.h"