Fix integer-overflow in TimestampExtrapolator

The Frequency implementation does not allow for nominators as large as
those that can occur in consecutive RTP timestamps, so use double math
instead.

Bug: chromium:1310611
Change-Id: I3b239e1b84043470ca29da06728b42cd4552300f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256978
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Evan Shrubsole <eshr@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36368}
This commit is contained in:
Evan Shrubsole 2022-03-29 12:15:01 +02:00 committed by WebRTC LUCI CQ
parent 81635f33ef
commit b7c15706de
2 changed files with 3 additions and 4 deletions

View File

@ -18,7 +18,6 @@ rtc_library("timestamp_extrapolator") {
"timestamp_extrapolator.h", "timestamp_extrapolator.h",
] ]
deps = [ deps = [
"../../api/units:frequency",
"../../api/units:timestamp", "../../api/units:timestamp",
"../../modules:module_api_public", "../../modules:module_api_public",
] ]

View File

@ -13,7 +13,6 @@
#include <algorithm> #include <algorithm>
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "api/units/frequency.h"
#include "modules/include/module_common_types_public.h" #include "modules/include/module_common_types_public.h"
namespace webrtc { namespace webrtc {
@ -130,8 +129,9 @@ absl::optional<Timestamp> TimestampExtrapolator::ExtrapolateLocalTime(
if (!first_unwrapped_timestamp_) { if (!first_unwrapped_timestamp_) {
return absl::nullopt; return absl::nullopt;
} else if (packet_count_ < kStartUpFilterDelayInPackets) { } else if (packet_count_ < kStartUpFilterDelayInPackets) {
constexpr Frequency k90KHz = Frequency::KiloHertz(90); constexpr double kRtpTicksPerMs = 90;
TimeDelta diff = (unwrapped_ts90khz - *prev_unwrapped_timestamp_) / k90KHz; TimeDelta diff = TimeDelta::Millis(
(unwrapped_ts90khz - *prev_unwrapped_timestamp_) / kRtpTicksPerMs);
return prev_ + diff; return prev_ + diff;
} else if (w_[0] < 1e-3) { } else if (w_[0] < 1e-3) {
return start_; return start_;