Bug 1880804 [wpt PR 44645] - Implement constructor in RTCEncodedVideoFrame, a=testonly
[gecko.git] / third_party / libwebrtc / moz-patch-stack / 0052.patch
blob616b4fdcc73dd93cf5c53fd8ec9c0b9a6b3b3131
1 From: Andreas Pehrson <apehrson@mozilla.com>
2 Date: Tue, 2 Nov 2021 14:35:00 +0000
3 Subject: Bug 1729455 - Inject RTCStatsTimestampMakerRealtimeClock into Call
4 instances. r=bwc
6 This patch makes libwebrtc use our clock for timestamps.
7 It also makes sure there's no use of the libwebrtc realtime clock, other than
8 for relative time tracking (like timeouts), and that future libwebrtc updates
9 don't introduce unaudited use of it.
11 Differential Revision: https://phabricator.services.mozilla.com/D127714
12 Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0744d68b8c944e69945de4ac5c4ca71332e78ad8
13 ---
14 audio/channel_send.cc | 2 +-
15 call/call.cc | 2 ++
16 call/call_factory.cc | 4 ++++
17 call/degraded_call.cc | 2 ++
18 modules/audio_coding/acm2/acm_receiver.cc | 2 +-
19 modules/rtp_rtcp/include/flexfec_receiver.h | 2 ++
20 modules/rtp_rtcp/source/flexfec_receiver.cc | 2 ++
21 rtc_base/task_utils/repeating_task.h | 4 ++--
22 system_wrappers/include/clock.h | 2 +-
23 system_wrappers/source/clock.cc | 2 +-
24 10 files changed, 18 insertions(+), 6 deletions(-)
26 diff --git a/audio/channel_send.cc b/audio/channel_send.cc
27 index 549e65a59c..8080f4a3b8 100644
28 --- a/audio/channel_send.cc
29 +++ b/audio/channel_send.cc
30 @@ -443,7 +443,7 @@ ChannelSend::ChannelSend(
31 transport_controller->GetRtcpObserver();
32 configuration.transport_feedback_callback =
33 transport_controller->transport_feedback_observer();
34 - configuration.clock = (clock ? clock : Clock::GetRealTimeClock());
35 + configuration.clock = clock;
36 configuration.audio = true;
37 configuration.outgoing_transport = rtp_transport;
39 diff --git a/call/call.cc b/call/call.cc
40 index 42b3b988ea..d2ac705274 100644
41 --- a/call/call.cc
42 +++ b/call/call.cc
43 @@ -473,6 +473,7 @@ std::string Call::Stats::ToString(int64_t time_ms) const {
44 return ss.str();
47 +/* Mozilla: Avoid this since it could use GetRealTimeClock().
48 std::unique_ptr<Call> Call::Create(const CallConfig& config) {
49 Clock* clock =
50 config.env.has_value() ? &config.env->clock() : Clock::GetRealTimeClock();
51 @@ -480,6 +481,7 @@ std::unique_ptr<Call> Call::Create(const CallConfig& config) {
52 RtpTransportControllerSendFactory().Create(
53 config.ExtractTransportConfig(), clock));
55 + */
57 std::unique_ptr<Call> Call::Create(
58 const CallConfig& config,
59 diff --git a/call/call_factory.cc b/call/call_factory.cc
60 index 043b11da37..78a4f1635f 100644
61 --- a/call/call_factory.cc
62 +++ b/call/call_factory.cc
63 @@ -94,6 +94,9 @@ std::unique_ptr<Call> CallFactory::CreateCall(const CallConfig& config) {
65 RtpTransportConfig transportConfig = config.ExtractTransportConfig();
67 + RTC_CHECK(false);
68 + return nullptr;
69 + /* Mozilla: Avoid this since it could use GetRealTimeClock().
70 std::unique_ptr<Call> call =
71 Call::Create(config, Clock::GetRealTimeClock(),
72 config.rtp_transport_controller_send_factory->Create(
73 @@ -106,6 +109,7 @@ std::unique_ptr<Call> CallFactory::CreateCall(const CallConfig& config) {
76 return call;
77 + */
80 std::unique_ptr<CallFactoryInterface> CreateCallFactory() {
81 diff --git a/call/degraded_call.cc b/call/degraded_call.cc
82 index a511eda7bd..75a4a1cac0 100644
83 --- a/call/degraded_call.cc
84 +++ b/call/degraded_call.cc
85 @@ -126,6 +126,7 @@ bool DegradedCall::FakeNetworkPipeTransportAdapter::SendRtcp(
86 return true;
89 +/* Mozilla: Avoid this since it could use GetRealTimeClock().
90 DegradedCall::DegradedCall(
91 std::unique_ptr<Call> call,
92 const std::vector<TimeScopedNetworkConfig>& send_configs,
93 @@ -162,6 +163,7 @@ DegradedCall::DegradedCall(
97 +*/
99 DegradedCall::~DegradedCall() {
100 RTC_DCHECK_RUN_ON(call_->worker_thread());
101 diff --git a/modules/audio_coding/acm2/acm_receiver.cc b/modules/audio_coding/acm2/acm_receiver.cc
102 index a77e472ec1..a5bf88e547 100644
103 --- a/modules/audio_coding/acm2/acm_receiver.cc
104 +++ b/modules/audio_coding/acm2/acm_receiver.cc
105 @@ -50,7 +50,7 @@ std::unique_ptr<NetEq> CreateNetEq(
107 AcmReceiver::Config::Config(
108 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory)
109 - : clock(*Clock::GetRealTimeClock()), decoder_factory(decoder_factory) {
110 + : clock(*Clock::GetRealTimeClockRaw()), decoder_factory(decoder_factory) {
111 // Post-decode VAD is disabled by default in NetEq, however, Audio
112 // Conference Mixer relies on VAD decisions and fails without them.
113 neteq_config.enable_post_decode_vad = true;
114 diff --git a/modules/rtp_rtcp/include/flexfec_receiver.h b/modules/rtp_rtcp/include/flexfec_receiver.h
115 index a869c8ad41..b6a33882d1 100644
116 --- a/modules/rtp_rtcp/include/flexfec_receiver.h
117 +++ b/modules/rtp_rtcp/include/flexfec_receiver.h
118 @@ -30,9 +30,11 @@ class Clock;
120 class FlexfecReceiver {
121 public:
122 + /* Mozilla: Avoid this since it could use GetRealTimeClock().
123 FlexfecReceiver(uint32_t ssrc,
124 uint32_t protected_media_ssrc,
125 RecoveredPacketReceiver* recovered_packet_receiver);
126 + */
127 FlexfecReceiver(Clock* clock,
128 uint32_t ssrc,
129 uint32_t protected_media_ssrc,
130 diff --git a/modules/rtp_rtcp/source/flexfec_receiver.cc b/modules/rtp_rtcp/source/flexfec_receiver.cc
131 index 7f2cc0cb3c..2ba85a2157 100644
132 --- a/modules/rtp_rtcp/source/flexfec_receiver.cc
133 +++ b/modules/rtp_rtcp/source/flexfec_receiver.cc
134 @@ -31,6 +31,7 @@ constexpr TimeDelta kPacketLogInterval = TimeDelta::Seconds(10);
136 } // namespace
138 +/* Mozilla: Avoid this since it could use GetRealTimeClock().
139 FlexfecReceiver::FlexfecReceiver(
140 uint32_t ssrc,
141 uint32_t protected_media_ssrc,
142 @@ -39,6 +40,7 @@ FlexfecReceiver::FlexfecReceiver(
143 ssrc,
144 protected_media_ssrc,
145 recovered_packet_receiver) {}
146 + */
148 FlexfecReceiver::FlexfecReceiver(
149 Clock* clock,
150 diff --git a/rtc_base/task_utils/repeating_task.h b/rtc_base/task_utils/repeating_task.h
151 index c45de95ecc..28c691c3de 100644
152 --- a/rtc_base/task_utils/repeating_task.h
153 +++ b/rtc_base/task_utils/repeating_task.h
154 @@ -57,7 +57,7 @@ class RepeatingTaskHandle {
155 absl::AnyInvocable<TimeDelta()> closure,
156 TaskQueueBase::DelayPrecision precision =
157 TaskQueueBase::DelayPrecision::kLow,
158 - Clock* clock = Clock::GetRealTimeClock(),
159 + Clock* clock = Clock::GetRealTimeClockRaw(),
160 const Location& location = Location::Current());
162 // DelayedStart is equivalent to Start except that the first invocation of the
163 @@ -68,7 +68,7 @@ class RepeatingTaskHandle {
164 absl::AnyInvocable<TimeDelta()> closure,
165 TaskQueueBase::DelayPrecision precision =
166 TaskQueueBase::DelayPrecision::kLow,
167 - Clock* clock = Clock::GetRealTimeClock(),
168 + Clock* clock = Clock::GetRealTimeClockRaw(),
169 const Location& location = Location::Current());
171 // Stops future invocations of the repeating task closure. Can only be called
172 diff --git a/system_wrappers/include/clock.h b/system_wrappers/include/clock.h
173 index 60296070cc..214b34c970 100644
174 --- a/system_wrappers/include/clock.h
175 +++ b/system_wrappers/include/clock.h
176 @@ -49,7 +49,7 @@ class RTC_EXPORT Clock {
179 // Returns an instance of the real-time system clock implementation.
180 - static Clock* GetRealTimeClock();
181 + static Clock* GetRealTimeClockRaw();
184 class SimulatedClock : public Clock {
185 diff --git a/system_wrappers/source/clock.cc b/system_wrappers/source/clock.cc
186 index 88c99d6a68..f7460b831c 100644
187 --- a/system_wrappers/source/clock.cc
188 +++ b/system_wrappers/source/clock.cc
189 @@ -57,7 +57,7 @@ class RealTimeClock : public Clock {
193 -Clock* Clock::GetRealTimeClock() {
194 +Clock* Clock::GetRealTimeClockRaw() {
195 static Clock* const clock = new RealTimeClock();
196 return clock;