Use injected clock in rtp_replayer
Stops using the global clock methods from time_utils.
This CL was uploaded by an experimental version of git cl split
(https://crbug.com/389069356).
Bug: webrtc:42223992
Change-Id: I6bab555f1170b437eecff581d4c70252ee7de13d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/405524
Auto-Submit: Evan Shrubsole <eshr@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45421}
diff --git a/rtc_base/strings/json.h b/rtc_base/strings/json.h
index 383b6b5..23c0fbb 100644
--- a/rtc_base/strings/json.h
+++ b/rtc_base/strings/json.h
@@ -16,9 +16,14 @@
#include <vector>
#include "absl/strings/string_view.h"
-#include "json/json.h" // IWYU pragma: export
-#include "json/reader.h" // IWYU pragma: export
-#include "json/value.h" // IWYU pragma: export
+// IWYU pragma: begin_exports
+#include "json/config.h"
+#include "json/json.h"
+#include "json/json_features.h"
+#include "json/reader.h"
+#include "json/value.h"
+#include "json/writer.h"
+// IWYU pragma: end_exports
namespace webrtc {
@@ -83,5 +88,4 @@
} // namespace webrtc
-
#endif // RTC_BASE_STRINGS_JSON_H_
diff --git a/test/fuzzers/utils/BUILD.gn b/test/fuzzers/utils/BUILD.gn
index c59a91c..6d1c867 100644
--- a/test/fuzzers/utils/BUILD.gn
+++ b/test/fuzzers/utils/BUILD.gn
@@ -15,9 +15,12 @@
"rtp_replayer.h",
]
deps = [
+ "../../../api:rtp_parameters",
"../../../api:transport_api",
+ "../../../api/environment",
"../../../api/environment:environment_factory",
"../../../api/test/video:function_video_factory",
+ "../../../api/units:time_delta",
"../../../api/units:timestamp",
"../../../api/video:video_frame",
"../../../api/video_codecs:video_codecs_api",
@@ -28,6 +31,7 @@
"../../../media:rtc_internal_video_codecs",
"../../../modules/rtp_rtcp:rtp_rtcp_format",
"../../../rtc_base:checks",
+ "../../../rtc_base:logging",
"../../../rtc_base:rtc_base_tests_utils",
"../../../rtc_base:rtc_json",
"../../../rtc_base:timeutils",
diff --git a/test/fuzzers/utils/rtp_replayer.cc b/test/fuzzers/utils/rtp_replayer.cc
index d6d3b4a..90ebfb5 100644
--- a/test/fuzzers/utils/rtp_replayer.cc
+++ b/test/fuzzers/utils/rtp_replayer.cc
@@ -11,23 +11,37 @@
#include "test/fuzzers/utils/rtp_replayer.h"
#include <algorithm>
+#include <cstddef>
+#include <cstdint>
#include <memory>
#include <string>
#include <utility>
+#include <vector>
#include "absl/memory/memory.h"
+#include "api/call/transport.h"
+#include "api/environment/environment.h"
#include "api/environment/environment_factory.h"
+#include "api/media_types.h"
+#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
+#include "call/call.h"
+#include "call/call_config.h"
+#include "call/video_receive_stream.h"
#include "media/engine/internal_decoder_factory.h"
+#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
+#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/rtp_rtcp/source/rtp_packet.h"
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
+#include "rtc_base/fake_clock.h"
+#include "rtc_base/logging.h"
#include "rtc_base/strings/json.h"
#include "system_wrappers/include/clock.h"
#include "test/call_config_utils.h"
#include "test/encoder_settings.h"
-#include "test/fake_decoder.h"
#include "test/rtp_file_reader.h"
#include "test/run_loop.h"
+#include "test/video_renderer.h"
namespace webrtc {
namespace test {
@@ -73,7 +87,8 @@
}
// Setup the video streams based on the configuration.
- CallConfig call_config(CreateEnvironment());
+ Environment env = CreateEnvironment();
+ CallConfig call_config(env);
std::unique_ptr<Call> call(Call::Create(std::move(call_config)));
SetupVideoStreams(&receive_stream_configs, stream_state.get(), call.get());
@@ -82,7 +97,8 @@
receive_stream->Start();
}
- ReplayPackets(&fake_clock, call.get(), rtp_reader.get(), extensions);
+ ReplayPackets(&fake_clock, env.clock(), call.get(), rtp_reader.get(),
+ extensions);
for (const auto& receive_stream : stream_state->receive_streams) {
call->DestroyVideoReceiveStream(receive_stream);
@@ -150,14 +166,15 @@
}
void RtpReplayer::ReplayPackets(
- FakeClock* clock,
+ FakeClock* fake_clock,
+ Clock& clock,
Call* call,
test::RtpFileReader* rtp_reader,
const RtpPacketReceived::ExtensionManager& extensions) {
int64_t replay_start_ms = -1;
while (true) {
- int64_t now_ms = TimeMillis();
+ int64_t now_ms = clock.TimeInMilliseconds();
if (replay_start_ms == -1) {
replay_start_ms = now_ms;
}
@@ -171,12 +188,11 @@
if (deliver_in_ms > 0) {
// StatsCounter::ReportMetricToAggregatedCounter is O(elapsed time).
// Set an upper limit to prevent waste time.
- clock->AdvanceTime(TimeDelta::Millis(
+ fake_clock->AdvanceTime(TimeDelta::Millis(
std::min(deliver_in_ms, static_cast<int64_t>(100))));
}
- RtpPacketReceived received_packet(
- &extensions, Timestamp::Micros(clock->TimeNanos() / 1000));
+ RtpPacketReceived received_packet(&extensions, clock.CurrentTime());
if (!received_packet.Parse(packet.data, packet.length)) {
RTC_LOG(LS_ERROR) << "Packet error, corrupt packets or incorrect setup?";
break;
diff --git a/test/fuzzers/utils/rtp_replayer.h b/test/fuzzers/utils/rtp_replayer.h
index 6646245..fd9fbc2 100644
--- a/test/fuzzers/utils/rtp_replayer.h
+++ b/test/fuzzers/utils/rtp_replayer.h
@@ -24,6 +24,7 @@
#include "call/video_receive_stream.h"
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
#include "rtc_base/fake_clock.h"
+#include "system_wrappers/include/clock.h"
#include "test/null_transport.h"
#include "test/rtp_file_reader.h"
#include "test/video_renderer.h"
@@ -78,7 +79,8 @@
size_t rtp_dump_size);
// Replays each packet to from the RtpDump.
- static void ReplayPackets(FakeClock* clock,
+ static void ReplayPackets(FakeClock* fake_clock,
+ Clock& clock,
Call* call,
test::RtpFileReader* rtp_reader,
const RtpHeaderExtensionMap& extensions);