summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/api/test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /third_party/libwebrtc/api/test
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/api/test')
-rw-r--r--third_party/libwebrtc/api/test/compile_all_headers.cc1
-rw-r--r--third_party/libwebrtc/api/test/create_time_controller.cc43
-rw-r--r--third_party/libwebrtc/api/test/create_time_controller.h12
-rw-r--r--third_party/libwebrtc/api/test/create_video_codec_tester.cc27
-rw-r--r--third_party/libwebrtc/api/test/create_video_codec_tester.h26
-rw-r--r--third_party/libwebrtc/api/test/mock_transformable_audio_frame.h3
-rw-r--r--third_party/libwebrtc/api/test/mock_transformable_frame.h45
-rw-r--r--third_party/libwebrtc/api/test/pclf/media_configuration.h1
-rw-r--r--third_party/libwebrtc/api/test/pclf/media_quality_test_params.h2
-rw-r--r--third_party/libwebrtc/api/test/peerconnection_quality_test_fixture.h1
-rw-r--r--third_party/libwebrtc/api/test/video_codec_stats.cc97
-rw-r--r--third_party/libwebrtc/api/test/video_codec_stats.h120
-rw-r--r--third_party/libwebrtc/api/test/video_codec_tester.h148
13 files changed, 88 insertions, 438 deletions
diff --git a/third_party/libwebrtc/api/test/compile_all_headers.cc b/third_party/libwebrtc/api/test/compile_all_headers.cc
index 1fcf63e97b..9d375a19f2 100644
--- a/third_party/libwebrtc/api/test/compile_all_headers.cc
+++ b/third_party/libwebrtc/api/test/compile_all_headers.cc
@@ -43,6 +43,7 @@
#include "api/test/mock_rtpreceiver.h"
#include "api/test/mock_rtpsender.h"
#include "api/test/mock_session_description_interface.h"
+#include "api/test/mock_transformable_frame.h"
#include "api/test/mock_transformable_video_frame.h"
#include "api/test/mock_video_bitrate_allocator.h"
#include "api/test/mock_video_bitrate_allocator_factory.h"
diff --git a/third_party/libwebrtc/api/test/create_time_controller.cc b/third_party/libwebrtc/api/test/create_time_controller.cc
index 2c356cb887..7523e05208 100644
--- a/third_party/libwebrtc/api/test/create_time_controller.cc
+++ b/third_party/libwebrtc/api/test/create_time_controller.cc
@@ -11,10 +11,18 @@
#include "api/test/create_time_controller.h"
#include <memory>
+#include <utility>
+#include "absl/base/nullability.h"
+#include "api/enable_media_with_defaults.h"
+#include "api/environment/environment.h"
+#include "api/peer_connection_interface.h"
#include "call/call.h"
#include "call/rtp_transport_config.h"
#include "call/rtp_transport_controller_send_factory_interface.h"
+#include "pc/media_factory.h"
+#include "rtc_base/checks.h"
+#include "system_wrappers/include/clock.h"
#include "test/time_controller/external_time_controller.h"
#include "test/time_controller/simulated_time_controller.h"
@@ -30,24 +38,37 @@ std::unique_ptr<TimeController> CreateSimulatedTimeController() {
Timestamp::Seconds(10000));
}
-std::unique_ptr<CallFactoryInterface> CreateTimeControllerBasedCallFactory(
- TimeController* time_controller) {
- class TimeControllerBasedCallFactory : public CallFactoryInterface {
+void EnableMediaWithDefaultsAndTimeController(
+ TimeController& time_controller,
+ PeerConnectionFactoryDependencies& deps) {
+ class TimeControllerBasedFactory : public MediaFactory {
public:
- explicit TimeControllerBasedCallFactory(TimeController* time_controller)
- : time_controller_(time_controller) {}
- std::unique_ptr<Call> CreateCall(const CallConfig& config) override {
- RtpTransportConfig transportConfig = config.ExtractTransportConfig();
+ TimeControllerBasedFactory(
+ absl::Nonnull<Clock*> clock,
+ absl::Nonnull<std::unique_ptr<MediaFactory>> media_factory)
+ : clock_(clock), media_factory_(std::move(media_factory)) {}
- return Call::Create(config, time_controller_->GetClock(),
+ std::unique_ptr<Call> CreateCall(const CallConfig& config) override {
+ return Call::Create(config, clock_,
config.rtp_transport_controller_send_factory->Create(
- transportConfig, time_controller_->GetClock()));
+ config.ExtractTransportConfig(), clock_));
+ }
+
+ std::unique_ptr<cricket::MediaEngineInterface> CreateMediaEngine(
+ const Environment& env,
+ PeerConnectionFactoryDependencies& dependencies) override {
+ return media_factory_->CreateMediaEngine(env, dependencies);
}
private:
- TimeController* time_controller_;
+ absl::Nonnull<Clock*> clock_;
+ absl::Nonnull<std::unique_ptr<MediaFactory>> media_factory_;
};
- return std::make_unique<TimeControllerBasedCallFactory>(time_controller);
+
+ EnableMediaWithDefaults(deps);
+ RTC_CHECK(deps.media_factory);
+ deps.media_factory = std::make_unique<TimeControllerBasedFactory>(
+ time_controller.GetClock(), std::move(deps.media_factory));
}
} // namespace webrtc
diff --git a/third_party/libwebrtc/api/test/create_time_controller.h b/third_party/libwebrtc/api/test/create_time_controller.h
index e7bc9cb465..c8257da650 100644
--- a/third_party/libwebrtc/api/test/create_time_controller.h
+++ b/third_party/libwebrtc/api/test/create_time_controller.h
@@ -12,7 +12,7 @@
#include <memory>
-#include "api/call/call_factory_interface.h"
+#include "api/peer_connection_interface.h"
#include "api/test/time_controller.h"
namespace webrtc {
@@ -24,10 +24,12 @@ std::unique_ptr<TimeController> CreateTimeController(
// Creates a time controller that runs in simulated time.
std::unique_ptr<TimeController> CreateSimulatedTimeController();
-// This is creates a call factory that creates Call instances that are backed by
-// a time controller.
-std::unique_ptr<CallFactoryInterface> CreateTimeControllerBasedCallFactory(
- TimeController* time_controller);
+// Adjusts media `deps` to use clock `time_controller` provides, fills media
+// related dependencies, and enables media support for a PeerConnectionFactory
+// created from `deps`.
+void EnableMediaWithDefaultsAndTimeController(
+ TimeController& time_controller,
+ PeerConnectionFactoryDependencies& deps);
} // namespace webrtc
diff --git a/third_party/libwebrtc/api/test/create_video_codec_tester.cc b/third_party/libwebrtc/api/test/create_video_codec_tester.cc
deleted file mode 100644
index a1efefdb48..0000000000
--- a/third_party/libwebrtc/api/test/create_video_codec_tester.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "api/test/create_video_codec_tester.h"
-
-#include <memory>
-#include <utility>
-
-#include "api/test/video_codec_tester.h"
-#include "modules/video_coding/codecs/test/video_codec_tester_impl.h"
-
-namespace webrtc {
-namespace test {
-
-std::unique_ptr<VideoCodecTester> CreateVideoCodecTester() {
- return std::make_unique<VideoCodecTesterImpl>();
-}
-
-} // namespace test
-} // namespace webrtc
diff --git a/third_party/libwebrtc/api/test/create_video_codec_tester.h b/third_party/libwebrtc/api/test/create_video_codec_tester.h
deleted file mode 100644
index c68864ce85..0000000000
--- a/third_party/libwebrtc/api/test/create_video_codec_tester.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef API_TEST_CREATE_VIDEO_CODEC_TESTER_H_
-#define API_TEST_CREATE_VIDEO_CODEC_TESTER_H_
-
-#include <memory>
-
-#include "api/test/video_codec_tester.h"
-
-namespace webrtc {
-namespace test {
-
-std::unique_ptr<VideoCodecTester> CreateVideoCodecTester();
-
-} // namespace test
-} // namespace webrtc
-
-#endif // API_TEST_CREATE_VIDEO_CODEC_TESTER_H_
diff --git a/third_party/libwebrtc/api/test/mock_transformable_audio_frame.h b/third_party/libwebrtc/api/test/mock_transformable_audio_frame.h
index be703006ea..584c77fa54 100644
--- a/third_party/libwebrtc/api/test/mock_transformable_audio_frame.h
+++ b/third_party/libwebrtc/api/test/mock_transformable_audio_frame.h
@@ -11,6 +11,8 @@
#ifndef API_TEST_MOCK_TRANSFORMABLE_AUDIO_FRAME_H_
#define API_TEST_MOCK_TRANSFORMABLE_AUDIO_FRAME_H_
+#include <string>
+
#include "api/frame_transformer_interface.h"
#include "test/gmock.h"
@@ -24,6 +26,7 @@ class MockTransformableAudioFrame : public TransformableAudioFrameInterface {
MOCK_METHOD(uint8_t, GetPayloadType, (), (const, override));
MOCK_METHOD(uint32_t, GetSsrc, (), (const, override));
MOCK_METHOD(uint32_t, GetTimestamp, (), (const, override));
+ MOCK_METHOD(std::string, GetMimeType, (), (const, override));
MOCK_METHOD(rtc::ArrayView<const uint32_t>,
GetContributingSources,
(),
diff --git a/third_party/libwebrtc/api/test/mock_transformable_frame.h b/third_party/libwebrtc/api/test/mock_transformable_frame.h
new file mode 100644
index 0000000000..df20b62295
--- /dev/null
+++ b/third_party/libwebrtc/api/test/mock_transformable_frame.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2023 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef API_TEST_MOCK_TRANSFORMABLE_FRAME_H_
+#define API_TEST_MOCK_TRANSFORMABLE_FRAME_H_
+
+#include <stdint.h>
+
+#include <optional>
+#include <string>
+
+#include "api/array_view.h"
+#include "api/frame_transformer_interface.h"
+#include "api/units/timestamp.h"
+#include "test/gmock.h"
+
+namespace webrtc {
+
+class MockTransformableFrame : public webrtc::TransformableFrameInterface {
+ public:
+ MOCK_METHOD(rtc::ArrayView<const uint8_t>, GetData, (), (const, override));
+ MOCK_METHOD(void, SetData, (rtc::ArrayView<const uint8_t>), (override));
+ MOCK_METHOD(uint8_t, GetPayloadType, (), (const, override));
+ MOCK_METHOD(uint32_t, GetSsrc, (), (const, override));
+ MOCK_METHOD(uint32_t, GetTimestamp, (), (const, override));
+ MOCK_METHOD(void, SetRTPTimestamp, (uint32_t), (override));
+ MOCK_METHOD(std::optional<webrtc::Timestamp>,
+ GetCaptureTimeIdentifier,
+ (),
+ (const, override));
+ MOCK_METHOD(std::string, GetMimeType, (), (const, override));
+};
+
+static_assert(!std::is_abstract_v<MockTransformableFrame>, "");
+
+} // namespace webrtc
+
+#endif // API_TEST_MOCK_TRANSFORMABLE_FRAME_H_
diff --git a/third_party/libwebrtc/api/test/pclf/media_configuration.h b/third_party/libwebrtc/api/test/pclf/media_configuration.h
index 5bcb308c83..5c3440c293 100644
--- a/third_party/libwebrtc/api/test/pclf/media_configuration.h
+++ b/third_party/libwebrtc/api/test/pclf/media_configuration.h
@@ -24,7 +24,6 @@
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "api/array_view.h"
-#include "api/async_resolver_factory.h"
#include "api/audio/audio_mixer.h"
#include "api/audio_options.h"
#include "api/call/call_factory_interface.h"
diff --git a/third_party/libwebrtc/api/test/pclf/media_quality_test_params.h b/third_party/libwebrtc/api/test/pclf/media_quality_test_params.h
index b2ccdf18c5..aad04c3eb6 100644
--- a/third_party/libwebrtc/api/test/pclf/media_quality_test_params.h
+++ b/third_party/libwebrtc/api/test/pclf/media_quality_test_params.h
@@ -49,8 +49,6 @@ struct PeerConnectionFactoryComponents {
std::unique_ptr<NetworkControllerFactoryInterface> network_controller_factory;
std::unique_ptr<NetEqFactory> neteq_factory;
- // Will be passed to MediaEngineInterface, that will be used in
- // PeerConnectionFactory.
std::unique_ptr<VideoEncoderFactory> video_encoder_factory;
std::unique_ptr<VideoDecoderFactory> video_decoder_factory;
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory;
diff --git a/third_party/libwebrtc/api/test/peerconnection_quality_test_fixture.h b/third_party/libwebrtc/api/test/peerconnection_quality_test_fixture.h
index 74470cdf86..034e13ff3b 100644
--- a/third_party/libwebrtc/api/test/peerconnection_quality_test_fixture.h
+++ b/third_party/libwebrtc/api/test/peerconnection_quality_test_fixture.h
@@ -25,7 +25,6 @@
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "api/array_view.h"
-#include "api/async_resolver_factory.h"
#include "api/audio/audio_mixer.h"
#include "api/call/call_factory_interface.h"
#include "api/fec_controller.h"
diff --git a/third_party/libwebrtc/api/test/video_codec_stats.cc b/third_party/libwebrtc/api/test/video_codec_stats.cc
deleted file mode 100644
index fb7226701e..0000000000
--- a/third_party/libwebrtc/api/test/video_codec_stats.cc
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2023 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "api/test/video_codec_stats.h"
-
-namespace webrtc {
-namespace test {
-
-void VideoCodecStats::Stream::LogMetrics(
- MetricsLogger* logger,
- std::string test_case_name,
- std::map<std::string, std::string> metadata) const {
- logger->LogMetric("width", test_case_name, width, Unit::kCount,
- webrtc::test::ImprovementDirection::kBiggerIsBetter,
- metadata);
-
- logger->LogMetric("height", test_case_name, height, Unit::kCount,
- webrtc::test::ImprovementDirection::kBiggerIsBetter,
- metadata);
-
- logger->LogMetric(
- "frame_size_bytes", test_case_name, frame_size_bytes, Unit::kBytes,
- webrtc::test::ImprovementDirection::kNeitherIsBetter, metadata);
-
- logger->LogMetric("keyframe", test_case_name, keyframe, Unit::kCount,
- webrtc::test::ImprovementDirection::kSmallerIsBetter,
- metadata);
-
- logger->LogMetric("qp", test_case_name, qp, Unit::kUnitless,
- webrtc::test::ImprovementDirection::kSmallerIsBetter,
- metadata);
-
- logger->LogMetric(
- "encode_time_ms", test_case_name, encode_time_ms, Unit::kMilliseconds,
- webrtc::test::ImprovementDirection::kSmallerIsBetter, metadata);
-
- logger->LogMetric(
- "decode_time_ms", test_case_name, decode_time_ms, Unit::kMilliseconds,
- webrtc::test::ImprovementDirection::kSmallerIsBetter, metadata);
-
- logger->LogMetric("target_bitrate_kbps", test_case_name, target_bitrate_kbps,
- Unit::kKilobitsPerSecond,
- webrtc::test::ImprovementDirection::kBiggerIsBetter,
- metadata);
-
- logger->LogMetric("target_framerate_fps", test_case_name,
- target_framerate_fps, Unit::kHertz,
- webrtc::test::ImprovementDirection::kBiggerIsBetter,
- metadata);
-
- logger->LogMetric("encoded_bitrate_kbps", test_case_name,
- encoded_bitrate_kbps, Unit::kKilobitsPerSecond,
- webrtc::test::ImprovementDirection::kBiggerIsBetter,
- metadata);
-
- logger->LogMetric("encoded_framerate_fps", test_case_name,
- encoded_framerate_fps, Unit::kHertz,
- webrtc::test::ImprovementDirection::kBiggerIsBetter,
- metadata);
-
- logger->LogMetric("bitrate_mismatch_pct", test_case_name,
- bitrate_mismatch_pct, Unit::kPercent,
- webrtc::test::ImprovementDirection::kSmallerIsBetter,
- metadata);
-
- logger->LogMetric("framerate_mismatch_pct", test_case_name,
- framerate_mismatch_pct, Unit::kPercent,
- webrtc::test::ImprovementDirection::kSmallerIsBetter,
- metadata);
-
- logger->LogMetric("transmission_time_ms", test_case_name,
- transmission_time_ms, Unit::kMilliseconds,
- webrtc::test::ImprovementDirection::kSmallerIsBetter,
- metadata);
-
- logger->LogMetric("psnr_y_db", test_case_name, psnr.y, Unit::kUnitless,
- webrtc::test::ImprovementDirection::kBiggerIsBetter,
- metadata);
-
- logger->LogMetric("psnr_u_db", test_case_name, psnr.u, Unit::kUnitless,
- webrtc::test::ImprovementDirection::kBiggerIsBetter,
- metadata);
-
- logger->LogMetric("psnr_v_db", test_case_name, psnr.v, Unit::kUnitless,
- webrtc::test::ImprovementDirection::kBiggerIsBetter,
- metadata);
-}
-
-} // namespace test
-} // namespace webrtc
diff --git a/third_party/libwebrtc/api/test/video_codec_stats.h b/third_party/libwebrtc/api/test/video_codec_stats.h
deleted file mode 100644
index 80f8287848..0000000000
--- a/third_party/libwebrtc/api/test/video_codec_stats.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2023 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef API_TEST_VIDEO_CODEC_STATS_H_
-#define API_TEST_VIDEO_CODEC_STATS_H_
-
-#include <map>
-#include <string>
-#include <vector>
-
-#include "absl/types/optional.h"
-#include "api/numerics/samples_stats_counter.h"
-#include "api/test/metrics/metric.h"
-#include "api/test/metrics/metrics_logger.h"
-#include "api/units/data_rate.h"
-#include "api/units/data_size.h"
-#include "api/units/frequency.h"
-
-namespace webrtc {
-namespace test {
-
-// Interface for encoded and/or decoded video frame and stream statistics.
-class VideoCodecStats {
- public:
- // Filter for slicing frames.
- struct Filter {
- absl::optional<int> first_frame;
- absl::optional<int> last_frame;
- absl::optional<int> spatial_idx;
- absl::optional<int> temporal_idx;
- };
-
- struct Frame {
- int frame_num = 0;
- uint32_t timestamp_rtp = 0;
-
- int spatial_idx = 0;
- int temporal_idx = 0;
-
- int width = 0;
- int height = 0;
- DataSize frame_size = DataSize::Zero();
- bool keyframe = false;
- absl::optional<int> qp;
- absl::optional<int> base_spatial_idx;
-
- Timestamp encode_start = Timestamp::Zero();
- TimeDelta encode_time = TimeDelta::Zero();
- Timestamp decode_start = Timestamp::Zero();
- TimeDelta decode_time = TimeDelta::Zero();
-
- struct Psnr {
- double y = 0.0;
- double u = 0.0;
- double v = 0.0;
- };
- absl::optional<Psnr> psnr;
-
- absl::optional<DataRate> target_bitrate;
- absl::optional<Frequency> target_framerate;
-
- bool encoded = false;
- bool decoded = false;
- };
-
- struct Stream {
- SamplesStatsCounter width;
- SamplesStatsCounter height;
- SamplesStatsCounter frame_size_bytes;
- SamplesStatsCounter keyframe;
- SamplesStatsCounter qp;
-
- SamplesStatsCounter encode_time_ms;
- SamplesStatsCounter decode_time_ms;
-
- SamplesStatsCounter target_bitrate_kbps;
- SamplesStatsCounter target_framerate_fps;
-
- SamplesStatsCounter encoded_bitrate_kbps;
- SamplesStatsCounter encoded_framerate_fps;
-
- SamplesStatsCounter bitrate_mismatch_pct;
- SamplesStatsCounter framerate_mismatch_pct;
-
- SamplesStatsCounter transmission_time_ms;
-
- struct Psnr {
- SamplesStatsCounter y;
- SamplesStatsCounter u;
- SamplesStatsCounter v;
- } psnr;
-
- // Logs `Stream` metrics to provided `MetricsLogger`.
- void LogMetrics(MetricsLogger* logger,
- std::string test_case_name,
- std::map<std::string, std::string> metadata = {}) const;
- };
-
- virtual ~VideoCodecStats() = default;
-
- // Returns frames from interval, spatial and temporal layer specified by given
- // `filter`.
- virtual std::vector<Frame> Slice(
- absl::optional<Filter> filter = absl::nullopt) const = 0;
-
- // Returns video statistics aggregated for given `frames`.
- virtual Stream Aggregate(const std::vector<Frame>& frames) const = 0;
-};
-
-} // namespace test
-} // namespace webrtc
-
-#endif // API_TEST_VIDEO_CODEC_STATS_H_
diff --git a/third_party/libwebrtc/api/test/video_codec_tester.h b/third_party/libwebrtc/api/test/video_codec_tester.h
deleted file mode 100644
index c2fb89e2cb..0000000000
--- a/third_party/libwebrtc/api/test/video_codec_tester.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef API_TEST_VIDEO_CODEC_TESTER_H_
-#define API_TEST_VIDEO_CODEC_TESTER_H_
-
-#include <memory>
-#include <string>
-
-#include "absl/functional/any_invocable.h"
-#include "absl/types/optional.h"
-#include "api/test/video_codec_stats.h"
-#include "api/video/encoded_image.h"
-#include "api/video/resolution.h"
-#include "api/video/video_frame.h"
-
-namespace webrtc {
-namespace test {
-
-// Interface for a video codec tester. The interface provides minimalistic set
-// of data structures that enables implementation of decode-only, encode-only
-// and encode-decode tests.
-class VideoCodecTester {
- public:
- // Pacing settings for codec input.
- struct PacingSettings {
- enum PacingMode {
- // Pacing is not used. Frames are sent to codec back-to-back.
- kNoPacing,
- // Pace with the rate equal to the target video frame rate. Pacing time is
- // derived from RTP timestamp.
- kRealTime,
- // Pace with the explicitly provided rate.
- kConstantRate,
- };
- PacingMode mode = PacingMode::kNoPacing;
- // Pacing rate for `kConstantRate` mode.
- Frequency constant_rate = Frequency::Zero();
- };
-
- struct DecoderSettings {
- PacingSettings pacing;
- absl::optional<std::string> decoder_input_base_path;
- absl::optional<std::string> decoder_output_base_path;
- };
-
- struct EncoderSettings {
- PacingSettings pacing;
- absl::optional<std::string> encoder_input_base_path;
- absl::optional<std::string> encoder_output_base_path;
- };
-
- virtual ~VideoCodecTester() = default;
-
- // Interface for a raw video frames source.
- class RawVideoSource {
- public:
- virtual ~RawVideoSource() = default;
-
- // Returns next frame. If no more frames to pull, returns `absl::nullopt`.
- // For analysis and pacing purposes, frame must have RTP timestamp set. The
- // timestamp must represent the target video frame rate and be unique.
- virtual absl::optional<VideoFrame> PullFrame() = 0;
-
- // Returns early pulled frame with RTP timestamp equal to `timestamp_rtp`.
- virtual VideoFrame GetFrame(uint32_t timestamp_rtp,
- Resolution resolution) = 0;
- };
-
- // Interface for a coded video frames source.
- class CodedVideoSource {
- public:
- virtual ~CodedVideoSource() = default;
-
- // Returns next frame. If no more frames to pull, returns `absl::nullopt`.
- // For analysis and pacing purposes, frame must have RTP timestamp set. The
- // timestamp must represent the target video frame rate and be unique.
- virtual absl::optional<EncodedImage> PullFrame() = 0;
- };
-
- // Interface for a video encoder.
- class Encoder {
- public:
- using EncodeCallback =
- absl::AnyInvocable<void(const EncodedImage& encoded_frame)>;
-
- virtual ~Encoder() = default;
-
- virtual void Initialize() = 0;
-
- virtual void Encode(const VideoFrame& frame, EncodeCallback callback) = 0;
-
- virtual void Flush() = 0;
- };
-
- // Interface for a video decoder.
- class Decoder {
- public:
- using DecodeCallback =
- absl::AnyInvocable<void(const VideoFrame& decoded_frame)>;
-
- virtual ~Decoder() = default;
-
- virtual void Initialize() = 0;
-
- virtual void Decode(const EncodedImage& frame, DecodeCallback callback) = 0;
-
- virtual void Flush() = 0;
- };
-
- // Pulls coded video frames from `video_source` and passes them to `decoder`.
- // Returns `VideoCodecTestStats` object that contains collected per-frame
- // metrics.
- virtual std::unique_ptr<VideoCodecStats> RunDecodeTest(
- CodedVideoSource* video_source,
- Decoder* decoder,
- const DecoderSettings& decoder_settings) = 0;
-
- // Pulls raw video frames from `video_source` and passes them to `encoder`.
- // Returns `VideoCodecTestStats` object that contains collected per-frame
- // metrics.
- virtual std::unique_ptr<VideoCodecStats> RunEncodeTest(
- RawVideoSource* video_source,
- Encoder* encoder,
- const EncoderSettings& encoder_settings) = 0;
-
- // Pulls raw video frames from `video_source`, passes them to `encoder` and
- // then passes encoded frames to `decoder`. Returns `VideoCodecTestStats`
- // object that contains collected per-frame metrics.
- virtual std::unique_ptr<VideoCodecStats> RunEncodeDecodeTest(
- RawVideoSource* video_source,
- Encoder* encoder,
- Decoder* decoder,
- const EncoderSettings& encoder_settings,
- const DecoderSettings& decoder_settings) = 0;
-};
-
-} // namespace test
-} // namespace webrtc
-
-#endif // API_TEST_VIDEO_CODEC_TESTER_H_