Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-22 14:04:28 +01:00
parent 81b91f4139
commit f8c34fa5ee
22732 changed files with 4815320 additions and 2 deletions

View file

@ -0,0 +1,52 @@
# Copyright (c) 2018 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.
import("../../../webrtc.gni")
rtc_library("function_video_factory") {
visibility = [ "*" ]
testonly = true
sources = [
"function_video_decoder_factory.h",
"function_video_encoder_factory.h",
]
deps = [
"../../../rtc_base:checks",
"../../environment",
"../../video_codecs:video_codecs_api",
]
}
rtc_library("video_frame_writer") {
visibility = [ "*" ]
testonly = true
sources = [ "video_frame_writer.h" ]
deps = [ "../../video:video_frame" ]
}
rtc_library("test_video_track_source") {
visibility = [ "*" ]
testonly = true
sources = [
"test_video_track_source.cc",
"test_video_track_source.h",
]
deps = [
"../..:media_stream_interface",
"../..:sequence_checker",
"../../../rtc_base:checks",
"../../../rtc_base:macromagic",
"../../../rtc_base/system:no_unique_address",
"../../video:recordable_encoded_frame",
"../../video:video_frame",
]
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
}

View file

@ -0,0 +1,6 @@
specific_include_rules = {
"test_video_track_source\.h": [
"+rtc_base/thread_annotations.h",
"+rtc_base/system/no_unique_address.h",
],
}

View file

@ -0,0 +1,70 @@
/*
* Copyright (c) 2018 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_FUNCTION_VIDEO_DECODER_FACTORY_H_
#define API_TEST_VIDEO_FUNCTION_VIDEO_DECODER_FACTORY_H_
#include <functional>
#include <memory>
#include <utility>
#include <vector>
#include "api/environment/environment.h"
#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_decoder.h"
#include "api/video_codecs/video_decoder_factory.h"
#include "rtc_base/checks.h"
namespace webrtc {
namespace test {
// A decoder factory producing decoders by calling a supplied create function.
class FunctionVideoDecoderFactory final : public VideoDecoderFactory {
public:
explicit FunctionVideoDecoderFactory(
std::function<std::unique_ptr<VideoDecoder>()> create)
: create_([create = std::move(create)](const Environment&,
const SdpVideoFormat&) {
return create();
}) {}
explicit FunctionVideoDecoderFactory(
std::function<std::unique_ptr<VideoDecoder>(const Environment&,
const SdpVideoFormat&)>
create)
: create_(std::move(create)) {}
FunctionVideoDecoderFactory(
std::function<std::unique_ptr<VideoDecoder>()> create,
std::vector<SdpVideoFormat> sdp_video_formats)
: create_([create = std::move(create)](const Environment&,
const SdpVideoFormat&) {
return create();
}),
sdp_video_formats_(std::move(sdp_video_formats)) {}
std::vector<SdpVideoFormat> GetSupportedFormats() const override {
return sdp_video_formats_;
}
std::unique_ptr<VideoDecoder> Create(const Environment& env,
const SdpVideoFormat& format) override {
return create_(env, format);
}
private:
const std::function<std::unique_ptr<VideoDecoder>(const Environment& env,
const SdpVideoFormat&)>
create_;
const std::vector<SdpVideoFormat> sdp_video_formats_;
};
} // namespace test
} // namespace webrtc
#endif // API_TEST_VIDEO_FUNCTION_VIDEO_DECODER_FACTORY_H_

View file

@ -0,0 +1,60 @@
/*
* Copyright (c) 2018 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_FUNCTION_VIDEO_ENCODER_FACTORY_H_
#define API_TEST_VIDEO_FUNCTION_VIDEO_ENCODER_FACTORY_H_
#include <functional>
#include <memory>
#include <utility>
#include <vector>
#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_encoder.h"
#include "api/video_codecs/video_encoder_factory.h"
#include "rtc_base/checks.h"
namespace webrtc {
namespace test {
// An encoder factory producing encoders by calling a supplied create
// function.
class FunctionVideoEncoderFactory final : public VideoEncoderFactory {
public:
explicit FunctionVideoEncoderFactory(
std::function<std::unique_ptr<VideoEncoder>()> create)
: create_([create = std::move(create)](const SdpVideoFormat&) {
return create();
}) {}
explicit FunctionVideoEncoderFactory(
std::function<std::unique_ptr<VideoEncoder>(const SdpVideoFormat&)>
create)
: create_(std::move(create)) {}
// Unused by tests.
std::vector<SdpVideoFormat> GetSupportedFormats() const override {
RTC_DCHECK_NOTREACHED();
return {};
}
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
const SdpVideoFormat& format) override {
return create_(format);
}
private:
const std::function<std::unique_ptr<VideoEncoder>(const SdpVideoFormat&)>
create_;
};
} // namespace test
} // namespace webrtc
#endif // API_TEST_VIDEO_FUNCTION_VIDEO_ENCODER_FACTORY_H_

View file

@ -0,0 +1,62 @@
/*
* 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/test_video_track_source.h"
#include <utility>
#include "absl/types/optional.h"
#include "api/media_stream_interface.h"
#include "api/sequence_checker.h"
#include "api/video/video_frame.h"
#include "api/video/video_sink_interface.h"
#include "api/video/video_source_interface.h"
#include "rtc_base/checks.h"
namespace webrtc {
namespace test {
TestVideoTrackSource::TestVideoTrackSource(
bool remote,
absl::optional<std::string> stream_label)
: stream_label_(std::move(stream_label)),
state_(kInitializing),
remote_(remote) {
worker_thread_checker_.Detach();
signaling_thread_checker_.Detach();
}
VideoTrackSourceInterface::SourceState TestVideoTrackSource::state() const {
RTC_DCHECK_RUN_ON(&signaling_thread_checker_);
return state_;
}
void TestVideoTrackSource::SetState(SourceState new_state) {
RTC_DCHECK_RUN_ON(&signaling_thread_checker_);
if (state_ != new_state) {
state_ = new_state;
FireOnChanged();
}
}
void TestVideoTrackSource::AddOrUpdateSink(
rtc::VideoSinkInterface<VideoFrame>* sink,
const rtc::VideoSinkWants& wants) {
RTC_DCHECK(worker_thread_checker_.IsCurrent());
source()->AddOrUpdateSink(sink, wants);
}
void TestVideoTrackSource::RemoveSink(
rtc::VideoSinkInterface<VideoFrame>* sink) {
RTC_DCHECK(worker_thread_checker_.IsCurrent());
source()->RemoveSink(sink);
}
} // namespace test
} // namespace webrtc

View file

@ -0,0 +1,97 @@
/*
* 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_TEST_VIDEO_TRACK_SOURCE_H_
#define API_TEST_VIDEO_TEST_VIDEO_TRACK_SOURCE_H_
#include <string>
#include "absl/types/optional.h"
#include "api/media_stream_interface.h"
#include "api/notifier.h"
#include "api/sequence_checker.h"
#include "api/video/recordable_encoded_frame.h"
#include "api/video/video_frame.h"
#include "api/video/video_sink_interface.h"
#include "api/video/video_source_interface.h"
#include "rtc_base/system/no_unique_address.h"
#include "rtc_base/thread_annotations.h"
namespace webrtc {
namespace test {
// Video source that can be used as input for tests.
class TestVideoTrackSource : public Notifier<VideoTrackSourceInterface> {
public:
explicit TestVideoTrackSource(
bool remote,
absl::optional<std::string> stream_label = absl::nullopt);
~TestVideoTrackSource() override = default;
void SetState(SourceState new_state);
SourceState state() const override;
bool remote() const override { return remote_; }
bool is_screencast() const override { return false; }
absl::optional<bool> needs_denoising() const override {
return absl::nullopt;
}
bool GetStats(Stats* stats) override { return false; }
void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
const rtc::VideoSinkWants& wants) override;
void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override;
bool SupportsEncodedOutput() const override { return false; }
void GenerateKeyFrame() override {}
void AddEncodedSink(
rtc::VideoSinkInterface<RecordableEncodedFrame>* sink) override {}
void RemoveEncodedSink(
rtc::VideoSinkInterface<RecordableEncodedFrame>* sink) override {}
// Starts producing video.
virtual void Start() = 0;
// Stops producing video.
virtual void Stop() = 0;
virtual void SetScreencast(bool is_screencast) = 0;
// TODO(titovartem): make next 4 methods pure virtual.
virtual void SetEnableAdaptation(bool enable_adaptation) {}
virtual int GetFrameWidth() const { return 0; }
virtual int GetFrameHeight() const { return 0; }
virtual void OnOutputFormatRequest(int width,
int height,
const absl::optional<int>& max_fps) {}
// Returns stream label for this video source if present. Implementations
// may override this method to increase debugability and testability.
virtual absl::optional<std::string> GetStreamLabel() { return stream_label_; }
protected:
virtual rtc::VideoSourceInterface<VideoFrame>* source() = 0;
private:
const absl::optional<std::string> stream_label_;
RTC_NO_UNIQUE_ADDRESS SequenceChecker worker_thread_checker_;
RTC_NO_UNIQUE_ADDRESS SequenceChecker signaling_thread_checker_;
SourceState state_ RTC_GUARDED_BY(&signaling_thread_checker_);
const bool remote_;
};
} // namespace test
} // namespace webrtc
#endif // API_TEST_VIDEO_TEST_VIDEO_TRACK_SOURCE_H_

View file

@ -0,0 +1,37 @@
/*
* 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_VIDEO_FRAME_WRITER_H_
#define API_TEST_VIDEO_VIDEO_FRAME_WRITER_H_
#include "api/video/video_frame.h"
namespace webrtc {
namespace test {
class VideoFrameWriter {
public:
virtual ~VideoFrameWriter() = default;
// Writes `VideoFrame` and returns true if operation was successful, false
// otherwise.
//
// Calling `WriteFrame` after `Close` is not allowed.
virtual bool WriteFrame(const VideoFrame& frame) = 0;
// Closes writer and cleans up all resources. No invocations to `WriteFrame`
// are allowed after `Close` was invoked.
virtual void Close() = 0;
};
} // namespace test
} // namespace webrtc
#endif // API_TEST_VIDEO_VIDEO_FRAME_WRITER_H_