Minor format to extrapolate local time

- Removing unnecessary else {} blocks for better readability.
- Consistent naming of: timestamp_diff with explicit typecast.

BUG=None

Change-Id: I35161ffed245737c789336316f0cfb6821b12349
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/361060
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42939}
This commit is contained in:
yazdan0a 2024-09-02 21:15:39 -05:00 committed by WebRTC LUCI CQ
parent 45065a749d
commit 55a59337c8

View File

@ -129,7 +129,8 @@ std::optional<Timestamp> TimestampExtrapolator::ExtrapolateLocalTime(
if (!first_unwrapped_timestamp_) {
return std::nullopt;
} else if (packet_count_ < kStartUpFilterDelayInPackets) {
}
if (packet_count_ < kStartUpFilterDelayInPackets) {
constexpr double kRtpTicksPerMs = 90;
TimeDelta diff = TimeDelta::Millis(
(unwrapped_ts90khz - *prev_unwrapped_timestamp_) / kRtpTicksPerMs);
@ -139,19 +140,20 @@ std::optional<Timestamp> TimestampExtrapolator::ExtrapolateLocalTime(
return std::nullopt;
}
return prev_ + diff;
} else if (w_[0] < 1e-3) {
return start_;
} else {
double timestampDiff = unwrapped_ts90khz - *first_unwrapped_timestamp_;
TimeDelta diff = TimeDelta::Millis(
static_cast<int64_t>((timestampDiff - w_[1]) / w_[0] + 0.5));
if (start_.us() + diff.us() < 0) {
// Prevent the construction of a negative Timestamp.
// This scenario can occur when the RTP timestamp wraps around.
return std::nullopt;
}
return start_ + diff;
}
if (w_[0] < 1e-3) {
return start_;
}
double timestamp_diff =
static_cast<double>(unwrapped_ts90khz - *first_unwrapped_timestamp_);
TimeDelta diff = TimeDelta::Millis(
static_cast<int64_t>((timestamp_diff - w_[1]) / w_[0] + 0.5));
if (start_.us() + diff.us() < 0) {
// Prevent the construction of a negative Timestamp.
// This scenario can occur when the RTP timestamp wraps around.
return std::nullopt;
}
return start_ + diff;
}
bool TimestampExtrapolator::DelayChangeDetection(double error) {