From 9b9adf38ff49a7baf0d21359cc60161046aa1054 Mon Sep 17 00:00:00 2001 From: Cosmin Stejerean Date: Thu, 8 Feb 2024 18:49:15 +0100 Subject: [PATCH] test: fix fake clock for muxer for integration tests (#1322) The fix in #1289 was not complete and left the fake clock as null which didn't have any effect. This was revealed by integration tests showing mismatches in the timestamps in MP4. --- packager/media/formats/mp4/mp4_muxer.cc | 5 +---- packager/packager.cc | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packager/media/formats/mp4/mp4_muxer.cc b/packager/media/formats/mp4/mp4_muxer.cc index 947e36f2c3..c31cba5c8e 100644 --- a/packager/media/formats/mp4/mp4_muxer.cc +++ b/packager/media/formats/mp4/mp4_muxer.cc @@ -692,10 +692,7 @@ uint64_t MP4Muxer::IsoTimeNow() { const uint64_t kIsomTimeOffset = 2082844800l; // Get the current system time since January 1, 1970, in seconds. - std::chrono::system_clock::duration duration = - std::chrono::system_clock::now().time_since_epoch(); - std::int64_t secondsSince1970 = - std::chrono::duration_cast(duration).count(); + std::int64_t secondsSince1970 = Now(); // Add the offset of seconds between January 1, 1970, and January 1, 1904. return secondsSince1970 + kIsomTimeOffset; diff --git a/packager/packager.cc b/packager/packager.cc index 5068d7f3b4..8f0196322d 100644 --- a/packager/packager.cc +++ b/packager/packager.cc @@ -942,6 +942,7 @@ Status Packager::Initialize( media::MuxerFactory muxer_factory(packaging_params); if (packaging_params.test_params.inject_fake_clock) { + internal->fake_clock.reset(new media::FakeClock()); muxer_factory.OverrideClock(internal->fake_clock); }