summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/test/pc/e2e/media
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /third_party/libwebrtc/test/pc/e2e/media
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/test/pc/e2e/media')
-rw-r--r--third_party/libwebrtc/test/pc/e2e/media/media_helper.cc128
-rw-r--r--third_party/libwebrtc/test/pc/e2e/media/media_helper.h58
-rw-r--r--third_party/libwebrtc/test/pc/e2e/media/test_video_capturer_video_track_source.h55
3 files changed, 241 insertions, 0 deletions
diff --git a/third_party/libwebrtc/test/pc/e2e/media/media_helper.cc b/third_party/libwebrtc/test/pc/e2e/media/media_helper.cc
new file mode 100644
index 0000000000..e945bd4dae
--- /dev/null
+++ b/third_party/libwebrtc/test/pc/e2e/media/media_helper.cc
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2020 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 "test/pc/e2e/media/media_helper.h"
+
+#include <string>
+#include <utility>
+
+#include "absl/types/variant.h"
+#include "api/media_stream_interface.h"
+#include "api/test/create_frame_generator.h"
+#include "api/test/pclf/media_configuration.h"
+#include "api/test/pclf/peer_configurer.h"
+#include "test/frame_generator_capturer.h"
+#include "test/platform_video_capturer.h"
+#include "test/testsupport/file_utils.h"
+
+namespace webrtc {
+namespace webrtc_pc_e2e {
+
+void MediaHelper::MaybeAddAudio(TestPeer* peer) {
+ if (!peer->params().audio_config) {
+ return;
+ }
+ const AudioConfig& audio_config = peer->params().audio_config.value();
+ rtc::scoped_refptr<webrtc::AudioSourceInterface> source =
+ peer->pc_factory()->CreateAudioSource(audio_config.audio_options);
+ rtc::scoped_refptr<AudioTrackInterface> track =
+ peer->pc_factory()->CreateAudioTrack(*audio_config.stream_label,
+ source.get());
+ std::string sync_group = audio_config.sync_group
+ ? audio_config.sync_group.value()
+ : audio_config.stream_label.value() + "-sync";
+ peer->AddTrack(track, {sync_group, *audio_config.stream_label});
+}
+
+std::vector<rtc::scoped_refptr<TestVideoCapturerVideoTrackSource>>
+MediaHelper::MaybeAddVideo(TestPeer* peer) {
+ // Params here valid because of pre-run validation.
+ const Params& params = peer->params();
+ const ConfigurableParams& configurable_params = peer->configurable_params();
+ std::vector<rtc::scoped_refptr<TestVideoCapturerVideoTrackSource>> out;
+ for (size_t i = 0; i < configurable_params.video_configs.size(); ++i) {
+ const VideoConfig& video_config = configurable_params.video_configs[i];
+ // Setup input video source into peer connection.
+ std::unique_ptr<test::TestVideoCapturer> capturer = CreateVideoCapturer(
+ video_config, peer->ReleaseVideoSource(i),
+ video_quality_analyzer_injection_helper_->CreateFramePreprocessor(
+ params.name.value(), video_config));
+ bool is_screencast =
+ video_config.content_hint == VideoTrackInterface::ContentHint::kText ||
+ video_config.content_hint ==
+ VideoTrackInterface::ContentHint::kDetailed;
+ rtc::scoped_refptr<TestVideoCapturerVideoTrackSource> source =
+ rtc::make_ref_counted<TestVideoCapturerVideoTrackSource>(
+ std::move(capturer), is_screencast);
+ out.push_back(source);
+ RTC_LOG(LS_INFO) << "Adding video with video_config.stream_label="
+ << video_config.stream_label.value();
+ rtc::scoped_refptr<VideoTrackInterface> track =
+ peer->pc_factory()->CreateVideoTrack(video_config.stream_label.value(),
+ source.get());
+ if (video_config.content_hint.has_value()) {
+ track->set_content_hint(video_config.content_hint.value());
+ }
+ std::string sync_group = video_config.sync_group
+ ? video_config.sync_group.value()
+ : video_config.stream_label.value() + "-sync";
+ RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> sender =
+ peer->AddTrack(track, {sync_group, *video_config.stream_label});
+ RTC_CHECK(sender.ok());
+ if (video_config.temporal_layers_count ||
+ video_config.degradation_preference) {
+ RtpParameters rtp_parameters = sender.value()->GetParameters();
+ if (video_config.temporal_layers_count) {
+ for (auto& encoding_parameters : rtp_parameters.encodings) {
+ encoding_parameters.num_temporal_layers =
+ video_config.temporal_layers_count;
+ }
+ }
+ if (video_config.degradation_preference) {
+ rtp_parameters.degradation_preference =
+ video_config.degradation_preference;
+ }
+ RTCError res = sender.value()->SetParameters(rtp_parameters);
+ RTC_CHECK(res.ok()) << "Failed to set RTP parameters";
+ }
+ }
+ return out;
+}
+
+std::unique_ptr<test::TestVideoCapturer> MediaHelper::CreateVideoCapturer(
+ const VideoConfig& video_config,
+ PeerConfigurer::VideoSource source,
+ std::unique_ptr<test::TestVideoCapturer::FramePreprocessor>
+ frame_preprocessor) {
+ CapturingDeviceIndex* capturing_device_index =
+ absl::get_if<CapturingDeviceIndex>(&source);
+ if (capturing_device_index != nullptr) {
+ std::unique_ptr<test::TestVideoCapturer> capturer =
+ test::CreateVideoCapturer(video_config.width, video_config.height,
+ video_config.fps,
+ static_cast<size_t>(*capturing_device_index));
+ RTC_CHECK(capturer)
+ << "Failed to obtain input stream from capturing device #"
+ << *capturing_device_index;
+ capturer->SetFramePreprocessor(std::move(frame_preprocessor));
+ return capturer;
+ }
+
+ auto capturer = std::make_unique<test::FrameGeneratorCapturer>(
+ clock_,
+ absl::get<std::unique_ptr<test::FrameGeneratorInterface>>(
+ std::move(source)),
+ video_config.fps, *task_queue_factory_);
+ capturer->SetFramePreprocessor(std::move(frame_preprocessor));
+ capturer->Init();
+ return capturer;
+}
+
+} // namespace webrtc_pc_e2e
+} // namespace webrtc
diff --git a/third_party/libwebrtc/test/pc/e2e/media/media_helper.h b/third_party/libwebrtc/test/pc/e2e/media/media_helper.h
new file mode 100644
index 0000000000..2d163d009e
--- /dev/null
+++ b/third_party/libwebrtc/test/pc/e2e/media/media_helper.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2020 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 TEST_PC_E2E_MEDIA_MEDIA_HELPER_H_
+#define TEST_PC_E2E_MEDIA_MEDIA_HELPER_H_
+
+#include <memory>
+#include <vector>
+
+#include "api/test/frame_generator_interface.h"
+#include "api/test/pclf/media_configuration.h"
+#include "api/test/pclf/peer_configurer.h"
+#include "test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.h"
+#include "test/pc/e2e/media/test_video_capturer_video_track_source.h"
+#include "test/pc/e2e/test_peer.h"
+
+namespace webrtc {
+namespace webrtc_pc_e2e {
+
+class MediaHelper {
+ public:
+ MediaHelper(VideoQualityAnalyzerInjectionHelper*
+ video_quality_analyzer_injection_helper,
+ TaskQueueFactory* task_queue_factory,
+ Clock* clock)
+ : clock_(clock),
+ task_queue_factory_(task_queue_factory),
+ video_quality_analyzer_injection_helper_(
+ video_quality_analyzer_injection_helper) {}
+
+ void MaybeAddAudio(TestPeer* peer);
+
+ std::vector<rtc::scoped_refptr<TestVideoCapturerVideoTrackSource>>
+ MaybeAddVideo(TestPeer* peer);
+
+ private:
+ std::unique_ptr<test::TestVideoCapturer> CreateVideoCapturer(
+ const VideoConfig& video_config,
+ PeerConfigurer::VideoSource source,
+ std::unique_ptr<test::TestVideoCapturer::FramePreprocessor>
+ frame_preprocessor);
+
+ Clock* const clock_;
+ TaskQueueFactory* const task_queue_factory_;
+ VideoQualityAnalyzerInjectionHelper* video_quality_analyzer_injection_helper_;
+};
+
+} // namespace webrtc_pc_e2e
+} // namespace webrtc
+
+#endif // TEST_PC_E2E_MEDIA_MEDIA_HELPER_H_
diff --git a/third_party/libwebrtc/test/pc/e2e/media/test_video_capturer_video_track_source.h b/third_party/libwebrtc/test/pc/e2e/media/test_video_capturer_video_track_source.h
new file mode 100644
index 0000000000..c883a2e8e9
--- /dev/null
+++ b/third_party/libwebrtc/test/pc/e2e/media/test_video_capturer_video_track_source.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2020 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 TEST_PC_E2E_MEDIA_TEST_VIDEO_CAPTURER_VIDEO_TRACK_SOURCE_H_
+#define TEST_PC_E2E_MEDIA_TEST_VIDEO_CAPTURER_VIDEO_TRACK_SOURCE_H_
+
+#include <memory>
+#include <utility>
+
+#include "api/video/video_frame.h"
+#include "api/video/video_source_interface.h"
+#include "pc/video_track_source.h"
+#include "test/test_video_capturer.h"
+
+namespace webrtc {
+namespace webrtc_pc_e2e {
+
+class TestVideoCapturerVideoTrackSource : public VideoTrackSource {
+ public:
+ TestVideoCapturerVideoTrackSource(
+ std::unique_ptr<test::TestVideoCapturer> video_capturer,
+ bool is_screencast)
+ : VideoTrackSource(/*remote=*/false),
+ video_capturer_(std::move(video_capturer)),
+ is_screencast_(is_screencast) {}
+
+ ~TestVideoCapturerVideoTrackSource() = default;
+
+ void Start() { SetState(kLive); }
+
+ void Stop() { SetState(kMuted); }
+
+ bool is_screencast() const override { return is_screencast_; }
+
+ protected:
+ rtc::VideoSourceInterface<VideoFrame>* source() override {
+ return video_capturer_.get();
+ }
+
+ private:
+ std::unique_ptr<test::TestVideoCapturer> video_capturer_;
+ const bool is_screencast_;
+};
+
+} // namespace webrtc_pc_e2e
+} // namespace webrtc
+
+#endif // TEST_PC_E2E_MEDIA_TEST_VIDEO_CAPTURER_VIDEO_TRACK_SOURCE_H_