From: Andreas Pehrson Date: Tue, 2 Nov 2021 14:35:00 +0000 Subject: Bug 1729455 - Inject RTCStatsTimestampMakerRealtimeClock into Call instances. r=bwc This patch makes libwebrtc use our clock for timestamps. It also makes sure there's no use of the libwebrtc realtime clock, other than for relative time tracking (like timeouts), and that future libwebrtc updates don't introduce unaudited use of it. Differential Revision: https://phabricator.services.mozilla.com/D127714 Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0744d68b8c944e69945de4ac5c4ca71332e78ad8 --- audio/channel_send.cc | 2 +- call/degraded_call.cc | 2 ++ modules/audio_coding/acm2/acm_receiver.cc | 2 +- modules/rtp_rtcp/include/flexfec_receiver.h | 2 ++ modules/rtp_rtcp/source/flexfec_receiver.cc | 2 ++ rtc_base/task_utils/repeating_task.h | 4 ++-- system_wrappers/include/clock.h | 2 +- system_wrappers/source/clock.cc | 2 +- 8 files changed, 12 insertions(+), 6 deletions(-) diff --git a/audio/channel_send.cc b/audio/channel_send.cc index db632b3aa8..c8251b4b52 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc @@ -443,7 +443,7 @@ ChannelSend::ChannelSend( transport_controller->GetRtcpObserver(); configuration.transport_feedback_callback = transport_controller->transport_feedback_observer(); - configuration.clock = (clock ? clock : Clock::GetRealTimeClock()); + configuration.clock = clock; configuration.audio = true; configuration.outgoing_transport = rtp_transport; diff --git a/call/degraded_call.cc b/call/degraded_call.cc index a511eda7bd..75a4a1cac0 100644 --- a/call/degraded_call.cc +++ b/call/degraded_call.cc @@ -126,6 +126,7 @@ bool DegradedCall::FakeNetworkPipeTransportAdapter::SendRtcp( return true; } +/* Mozilla: Avoid this since it could use GetRealTimeClock(). DegradedCall::DegradedCall( std::unique_ptr call, const std::vector& send_configs, @@ -162,6 +163,7 @@ DegradedCall::DegradedCall( } } } +*/ DegradedCall::~DegradedCall() { RTC_DCHECK_RUN_ON(call_->worker_thread()); diff --git a/modules/audio_coding/acm2/acm_receiver.cc b/modules/audio_coding/acm2/acm_receiver.cc index 24a49024c8..4deabdf7ff 100644 --- a/modules/audio_coding/acm2/acm_receiver.cc +++ b/modules/audio_coding/acm2/acm_receiver.cc @@ -50,7 +50,7 @@ std::unique_ptr CreateNetEq( AcmReceiver::Config::Config( rtc::scoped_refptr decoder_factory) - : clock(*Clock::GetRealTimeClock()), decoder_factory(decoder_factory) {} + : clock(*Clock::GetRealTimeClockRaw()), decoder_factory(decoder_factory) {} AcmReceiver::Config::Config(const Config&) = default; AcmReceiver::Config::~Config() = default; diff --git a/modules/rtp_rtcp/include/flexfec_receiver.h b/modules/rtp_rtcp/include/flexfec_receiver.h index a869c8ad41..b6a33882d1 100644 --- a/modules/rtp_rtcp/include/flexfec_receiver.h +++ b/modules/rtp_rtcp/include/flexfec_receiver.h @@ -30,9 +30,11 @@ class Clock; class FlexfecReceiver { public: + /* Mozilla: Avoid this since it could use GetRealTimeClock(). FlexfecReceiver(uint32_t ssrc, uint32_t protected_media_ssrc, RecoveredPacketReceiver* recovered_packet_receiver); + */ FlexfecReceiver(Clock* clock, uint32_t ssrc, uint32_t protected_media_ssrc, diff --git a/modules/rtp_rtcp/source/flexfec_receiver.cc b/modules/rtp_rtcp/source/flexfec_receiver.cc index 7f2cc0cb3c..2ba85a2157 100644 --- a/modules/rtp_rtcp/source/flexfec_receiver.cc +++ b/modules/rtp_rtcp/source/flexfec_receiver.cc @@ -31,6 +31,7 @@ constexpr TimeDelta kPacketLogInterval = TimeDelta::Seconds(10); } // namespace +/* Mozilla: Avoid this since it could use GetRealTimeClock(). FlexfecReceiver::FlexfecReceiver( uint32_t ssrc, uint32_t protected_media_ssrc, @@ -39,6 +40,7 @@ FlexfecReceiver::FlexfecReceiver( ssrc, protected_media_ssrc, recovered_packet_receiver) {} + */ FlexfecReceiver::FlexfecReceiver( Clock* clock, diff --git a/rtc_base/task_utils/repeating_task.h b/rtc_base/task_utils/repeating_task.h index c45de95ecc..28c691c3de 100644 --- a/rtc_base/task_utils/repeating_task.h +++ b/rtc_base/task_utils/repeating_task.h @@ -57,7 +57,7 @@ class RepeatingTaskHandle { absl::AnyInvocable closure, TaskQueueBase::DelayPrecision precision = TaskQueueBase::DelayPrecision::kLow, - Clock* clock = Clock::GetRealTimeClock(), + Clock* clock = Clock::GetRealTimeClockRaw(), const Location& location = Location::Current()); // DelayedStart is equivalent to Start except that the first invocation of the @@ -68,7 +68,7 @@ class RepeatingTaskHandle { absl::AnyInvocable closure, TaskQueueBase::DelayPrecision precision = TaskQueueBase::DelayPrecision::kLow, - Clock* clock = Clock::GetRealTimeClock(), + Clock* clock = Clock::GetRealTimeClockRaw(), const Location& location = Location::Current()); // Stops future invocations of the repeating task closure. Can only be called diff --git a/system_wrappers/include/clock.h b/system_wrappers/include/clock.h index 60296070cc..214b34c970 100644 --- a/system_wrappers/include/clock.h +++ b/system_wrappers/include/clock.h @@ -49,7 +49,7 @@ class RTC_EXPORT Clock { } // Returns an instance of the real-time system clock implementation. - static Clock* GetRealTimeClock(); + static Clock* GetRealTimeClockRaw(); }; class SimulatedClock : public Clock { diff --git a/system_wrappers/source/clock.cc b/system_wrappers/source/clock.cc index 88c99d6a68..f7460b831c 100644 --- a/system_wrappers/source/clock.cc +++ b/system_wrappers/source/clock.cc @@ -57,7 +57,7 @@ class RealTimeClock : public Clock { } }; -Clock* Clock::GetRealTimeClock() { +Clock* Clock::GetRealTimeClockRaw() { static Clock* const clock = new RealTimeClock(); return clock; }