mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
[Unwrap] Migrate TimestampExtrapolator to use RtpTimestampUnwrapper
Bug: webrtc:13982 Change-Id: I570f2b053e7c77295e9d6a60f005e51022c3759f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/288942 Auto-Submit: Evan Shrubsole <eshr@webrtc.org> Commit-Queue: Evan Shrubsole <eshr@webrtc.org> Reviewed-by: Philip Eliasson <philipel@webrtc.org> Cr-Commit-Position: refs/heads/main@{#39042}
This commit is contained in:
parent
372cf8b824
commit
11dfb42fe9
4 changed files with 19 additions and 5 deletions
|
@ -94,6 +94,7 @@ rtc_library("timestamp_extrapolator") {
|
|||
deps = [
|
||||
"../../../api/units:timestamp",
|
||||
"../../../modules:module_api_public",
|
||||
"../../../rtc_base:rtc_numerics",
|
||||
]
|
||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <algorithm>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "modules/include/module_common_types_public.h"
|
||||
#include "rtc_base/numerics/sequence_number_unwrapper.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
@ -47,7 +47,7 @@ void TimestampExtrapolator::Reset(Timestamp start) {
|
|||
p_[0][0] = 1;
|
||||
p_[1][1] = kP11;
|
||||
p_[0][1] = p_[1][0] = 0;
|
||||
unwrapper_ = TimestampUnwrapper();
|
||||
unwrapper_ = RtpTimestampUnwrapper();
|
||||
packet_count_ = 0;
|
||||
detector_accumulator_pos_ = 0;
|
||||
detector_accumulator_neg_ = 0;
|
||||
|
@ -124,7 +124,7 @@ void TimestampExtrapolator::Update(Timestamp now, uint32_t ts90khz) {
|
|||
|
||||
absl::optional<Timestamp> TimestampExtrapolator::ExtrapolateLocalTime(
|
||||
uint32_t timestamp90khz) const {
|
||||
int64_t unwrapped_ts90khz = unwrapper_.UnwrapWithoutUpdate(timestamp90khz);
|
||||
int64_t unwrapped_ts90khz = unwrapper_.PeekUnwrap(timestamp90khz);
|
||||
|
||||
if (!first_unwrapped_timestamp_) {
|
||||
return absl::nullopt;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/units/timestamp.h"
|
||||
#include "modules/include/module_common_types_public.h"
|
||||
#include "rtc_base/numerics/sequence_number_unwrapper.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
@ -36,7 +36,7 @@ class TimestampExtrapolator {
|
|||
Timestamp start_;
|
||||
Timestamp prev_;
|
||||
absl::optional<int64_t> first_unwrapped_timestamp_;
|
||||
TimestampUnwrapper unwrapper_;
|
||||
RtpTimestampUnwrapper unwrapper_;
|
||||
absl::optional<int64_t> prev_unwrapped_timestamp_;
|
||||
uint32_t packet_count_;
|
||||
double detector_accumulator_pos_;
|
||||
|
|
|
@ -120,6 +120,19 @@ TEST(TimestampExtrapolatorTest, TimestampExtrapolatesMultipleRtpWrapArounds) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST(TimestampExtrapolatorTest, NegativeRtpTimestampWrapAround) {
|
||||
SimulatedClock clock(Timestamp::Millis(1337));
|
||||
TimestampExtrapolator ts_extrapolator(clock.CurrentTime());
|
||||
uint32_t rtp = 0;
|
||||
ts_extrapolator.Update(clock.CurrentTime(), rtp);
|
||||
EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp),
|
||||
Optional(clock.CurrentTime()));
|
||||
// Go backwards!
|
||||
rtp -= kRtpHz.hertz();
|
||||
EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp),
|
||||
Optional(clock.CurrentTime() - TimeDelta::Seconds(1)));
|
||||
}
|
||||
|
||||
TEST(TimestampExtrapolatorTest, Slow90KHzClock) {
|
||||
// This simulates a slow camera, which produces frames at 24Hz instead of
|
||||
// 25Hz. The extrapolator should be able to resolve this with enough data.
|
||||
|
|
Loading…
Reference in a new issue