Delete master_timing argument to VCMTiming.
Makes construction simpler, and allows the ts_extrapolator_ pointer
to be marked const.
Followup to https://webrtc-review.googlesource.com/c/src/+/190721
Bug: webrtc:12102
Change-Id: I2abeb960935b5470509f654a4a9d5121c8001900
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/190981
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32535}
diff --git a/modules/video_coding/timing.cc b/modules/video_coding/timing.cc
index f1c66b8..eddac4f 100644
--- a/modules/video_coding/timing.cc
+++ b/modules/video_coding/timing.cc
@@ -21,11 +21,11 @@
namespace webrtc {
-VCMTiming::VCMTiming(Clock* clock, VCMTiming* master_timing)
+VCMTiming::VCMTiming(Clock* clock)
: clock_(clock),
- master_(false),
- ts_extrapolator_(),
- codec_timer_(new VCMCodecTimer()),
+ ts_extrapolator_(std::make_unique<TimestampExtrapolator>(
+ clock_->TimeInMilliseconds())),
+ codec_timer_(std::make_unique<VCMCodecTimer>()),
render_delay_ms_(kDefaultRenderDelayMs),
min_playout_delay_ms_(0),
max_playout_delay_ms_(10000),
@@ -37,24 +37,12 @@
low_latency_renderer_enabled_("enabled", true) {
ParseFieldTrial({&low_latency_renderer_enabled_},
field_trial::FindFullName("WebRTC-LowLatencyRenderer"));
- if (master_timing == NULL) {
- master_ = true;
- ts_extrapolator_ = new TimestampExtrapolator(clock_->TimeInMilliseconds());
- } else {
- ts_extrapolator_ = master_timing->ts_extrapolator_;
- }
-}
-
-VCMTiming::~VCMTiming() {
- if (master_) {
- delete ts_extrapolator_;
- }
}
void VCMTiming::Reset() {
MutexLock lock(&mutex_);
ts_extrapolator_->Reset(clock_->TimeInMilliseconds());
- codec_timer_.reset(new VCMCodecTimer());
+ codec_timer_ = std::make_unique<VCMCodecTimer>();
render_delay_ms_ = kDefaultRenderDelayMs;
min_playout_delay_ms_ = 0;
jitter_delay_ms_ = 0;
@@ -190,6 +178,8 @@
// Render as soon as possible or with low-latency renderer algorithm.
return 0;
}
+ // Note that TimestampExtrapolator::ExtrapolateLocalTime is not a const
+ // method; it mutates the object's wraparound state.
int64_t estimated_complete_time_ms =
ts_extrapolator_->ExtrapolateLocalTime(frame_timestamp);
if (estimated_complete_time_ms == -1) {