Move VideoEncoderConfig from api/ into video/config

This cl move VideoEncoderConfig from api/ to video/config.

VideoStreamEncoderInterface and VideoStreamEncoderObserver
are moved as collateral.

brandt@ think that the reason these were in api/ in the
first place had to downstream project.

Functionality wise, this is a NOP, but it makes it easier
to modify the encoder (config).

Bug: webrtc:14451
Change-Id: I2610d815aeb186298498e7102cac773ecac8cd36
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/277002
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38242}
This commit is contained in:
Jonas Oreland 2022-09-29 10:28:24 +02:00 committed by WebRTC LUCI CQ
parent 5ed1752843
commit 6c2dae21e9
56 changed files with 326 additions and 270 deletions

View file

@ -398,6 +398,7 @@ rtc_source_set("video_quality_test_fixture_api") {
"../call:rtp_interfaces",
"../test:test_common",
"../test:video_test_common",
"../video/config:encoder_config",
"transport:bitrate_settings",
"transport:network_control",
"video_codecs:video_codecs_api",

View file

@ -24,8 +24,8 @@
#include "api/transport/network_control.h"
#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_decoder_factory.h"
#include "api/video_codecs/video_encoder_config.h"
#include "api/video_codecs/video_encoder_factory.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {

View file

@ -304,11 +304,7 @@ rtc_library("video_adaptation") {
rtc_source_set("video_stream_encoder") {
visibility = [ "*" ]
sources = [
"video_stream_encoder_interface.h",
"video_stream_encoder_observer.h",
"video_stream_encoder_settings.h",
]
sources = [ "video_stream_encoder_settings.h" ]
deps = [
":video_adaptation",

View file

@ -58,8 +58,6 @@ rtc_library("video_codecs_api") {
"video_decoder_factory.h",
"video_encoder.cc",
"video_encoder.h",
"video_encoder_config.cc",
"video_encoder_config.h",
"video_encoder_factory.h",
"vp8_frame_buffer_controller.h",
"vp8_frame_config.cc",

View file

@ -1,208 +0,0 @@
/*
* Copyright (c) 2013 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_VIDEO_CODECS_VIDEO_ENCODER_CONFIG_H_
#define API_VIDEO_CODECS_VIDEO_ENCODER_CONFIG_H_
#include <stddef.h>
#include <string>
#include <vector>
#include "absl/types/optional.h"
#include "api/scoped_refptr.h"
#include "api/video/resolution.h"
#include "api/video_codecs/scalability_mode.h"
#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_codec.h"
#include "rtc_base/ref_count.h"
namespace webrtc {
// The `VideoStream` struct describes a simulcast layer, or "stream".
struct VideoStream {
VideoStream();
~VideoStream();
VideoStream(const VideoStream& other);
std::string ToString() const;
// Width/Height in pixels.
// This is the actual width and height used to configure encoder,
// which might be less than `requested_resolution` due to adaptation
// or due to the source providing smaller frames than requested.
size_t width;
size_t height;
// Frame rate in fps.
int max_framerate;
// Bitrate, in bps, for the stream.
int min_bitrate_bps;
int target_bitrate_bps;
int max_bitrate_bps;
// Scaling factor applied to the stream size.
// `width` and `height` values are already scaled down.
double scale_resolution_down_by;
// Maximum Quantization Parameter to use when encoding the stream.
int max_qp;
// Determines the number of temporal layers that the stream should be
// encoded with. This value should be greater than zero.
// TODO(brandtr): This class is used both for configuring the encoder
// (meaning that this field _must_ be set), and for signaling the app-level
// encoder settings (meaning that the field _may_ be set). We should separate
// this and remove this optional instead.
absl::optional<size_t> num_temporal_layers;
// The priority of this stream, to be used when allocating resources
// between multiple streams.
absl::optional<double> bitrate_priority;
absl::optional<ScalabilityMode> scalability_mode;
// If this stream is enabled by the user, or not.
bool active;
// An optional user supplied max_frame_resolution
// than can be set independently of (adapted) VideoSource.
// This value is set from RtpEncodingParameters::requested_resolution
// (i.e. used for signaling app-level settings).
//
// The actual encode resolution is in `width` and `height`,
// which can be lower than requested_resolution,
// e.g. if source only provides lower resolution or
// if resource adaptation is active.
absl::optional<Resolution> requested_resolution;
};
class VideoEncoderConfig {
public:
// These are reference counted to permit copying VideoEncoderConfig and be
// kept alive until all encoder_specific_settings go out of scope.
// TODO(kthelgason): Consider removing the need for copying VideoEncoderConfig
// and use absl::optional for encoder_specific_settings instead.
class EncoderSpecificSettings : public rtc::RefCountInterface {
public:
// TODO(pbos): Remove FillEncoderSpecificSettings as soon as VideoCodec is
// not in use and encoder implementations ask for codec-specific structs
// directly.
void FillEncoderSpecificSettings(VideoCodec* codec_struct) const;
virtual void FillVideoCodecVp8(VideoCodecVP8* vp8_settings) const;
virtual void FillVideoCodecVp9(VideoCodecVP9* vp9_settings) const;
private:
~EncoderSpecificSettings() override {}
friend class VideoEncoderConfig;
};
class Vp8EncoderSpecificSettings : public EncoderSpecificSettings {
public:
explicit Vp8EncoderSpecificSettings(const VideoCodecVP8& specifics);
void FillVideoCodecVp8(VideoCodecVP8* vp8_settings) const override;
private:
VideoCodecVP8 specifics_;
};
class Vp9EncoderSpecificSettings : public EncoderSpecificSettings {
public:
explicit Vp9EncoderSpecificSettings(const VideoCodecVP9& specifics);
void FillVideoCodecVp9(VideoCodecVP9* vp9_settings) const override;
private:
VideoCodecVP9 specifics_;
};
enum class ContentType {
kRealtimeVideo,
kScreen,
};
class VideoStreamFactoryInterface : public rtc::RefCountInterface {
public:
// An implementation should return a std::vector<VideoStream> with the
// wanted VideoStream settings for the given video resolution.
// The size of the vector may not be larger than
// `encoder_config.number_of_streams`.
virtual std::vector<VideoStream> CreateEncoderStreams(
int width,
int height,
const VideoEncoderConfig& encoder_config) = 0;
protected:
~VideoStreamFactoryInterface() override {}
};
VideoEncoderConfig& operator=(VideoEncoderConfig&&) = default;
VideoEncoderConfig& operator=(const VideoEncoderConfig&) = delete;
// Mostly used by tests. Avoid creating copies if you can.
VideoEncoderConfig Copy() const { return VideoEncoderConfig(*this); }
VideoEncoderConfig();
VideoEncoderConfig(VideoEncoderConfig&&);
~VideoEncoderConfig();
std::string ToString() const;
// TODO(bugs.webrtc.org/6883): Consolidate on one of these.
VideoCodecType codec_type;
SdpVideoFormat video_format;
// Note: This factory can be unset, and VideoStreamEncoder will
// then use the EncoderStreamFactory. The factory is only set by
// tests.
rtc::scoped_refptr<VideoStreamFactoryInterface> video_stream_factory;
std::vector<SpatialLayer> spatial_layers;
ContentType content_type;
bool frame_drop_enabled;
rtc::scoped_refptr<const EncoderSpecificSettings> encoder_specific_settings;
// Padding will be used up to this bitrate regardless of the bitrate produced
// by the encoder. Padding above what's actually produced by the encoder helps
// maintaining a higher bitrate estimate. Padding will however not be sent
// unless the estimated bandwidth indicates that the link can handle it.
int min_transmit_bitrate_bps;
int max_bitrate_bps;
// The bitrate priority used for all VideoStreams.
double bitrate_priority;
// The simulcast layer's configurations set by the application for this video
// sender. These are modified by the video_stream_factory before being passed
// down to lower layers for the video encoding.
// `simulcast_layers` is also used for configuring non-simulcast (when there
// is a single VideoStream).
std::vector<VideoStream> simulcast_layers;
// Max number of encoded VideoStreams to produce.
size_t number_of_streams;
// Legacy Google conference mode flag for simulcast screenshare
bool legacy_conference_mode;
// Indicates whether quality scaling can be used or not.
bool is_quality_scaling_allowed;
// Maximum Quantization Parameter.
// This value is fed into EncoderStreamFactory that
// apply it to all simulcast layers/spatial layers.
int max_qp;
private:
// Access to the copy constructor is private to force use of the Copy()
// method for those exceptional cases where we do use it.
VideoEncoderConfig(const VideoEncoderConfig&);
};
} // namespace webrtc
#endif // API_VIDEO_CODECS_VIDEO_ENCODER_CONFIG_H_

View file

@ -334,6 +334,7 @@ rtc_library("call") {
"../system_wrappers:metrics",
"../video",
"../video:decode_synchronizer",
"../video/config:encoder_config",
"adaptation:resource_adaptation",
]
absl_deps = [
@ -384,6 +385,7 @@ rtc_library("video_stream_api") {
"../modules/rtp_rtcp:rtp_rtcp_format",
"../rtc_base:checks",
"../rtc_base:stringutils",
"../video/config:encoder_config",
]
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
}
@ -592,6 +594,7 @@ if (rtc_include_tests) {
"../test:test_support",
"../test:video_test_common",
"../video",
"../video/config:encoder_config",
"//testing/gtest",
]
absl_deps = [

View file

@ -54,6 +54,8 @@ rtc_library("resource_adaptation") {
"../../rtc_base/experiments:balanced_degradation_settings",
"../../rtc_base/synchronization:mutex",
"../../rtc_base/system:no_unique_address",
"../../video:video_stream_encoder_interface",
"../../video/config:encoder_config",
]
absl_deps = [
"//third_party/abseil-cpp/absl/algorithm:container",
@ -95,6 +97,7 @@ if (rtc_include_tests) {
"../../test:rtc_expect_death",
"../../test:scoped_key_value_config",
"../../test:test_support",
"../../video/config:encoder_config",
]
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
}
@ -122,6 +125,8 @@ if (rtc_include_tests) {
"../../api/task_queue:task_queue",
"../../api/video:video_stream_encoder",
"../../test:test_support",
"../../video:video_stream_encoder_interface",
"../../video/config:encoder_config",
]
absl_deps = [
"//third_party/abseil-cpp/absl/strings",

View file

@ -14,7 +14,7 @@
#include "absl/types/optional.h"
#include "api/video_codecs/video_codec.h"
#include "api/video_codecs/video_encoder.h"
#include "api/video_codecs/video_encoder_config.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {

View file

@ -25,12 +25,12 @@
#include "api/task_queue/task_queue_base.h"
#include "api/video/video_adaptation_counters.h"
#include "api/video/video_frame.h"
#include "api/video/video_stream_encoder_observer.h"
#include "call/adaptation/resource_adaptation_processor_interface.h"
#include "call/adaptation/video_source_restrictions.h"
#include "call/adaptation/video_stream_adapter.h"
#include "call/adaptation/video_stream_input_state.h"
#include "call/adaptation/video_stream_input_state_provider.h"
#include "video/video_stream_encoder_observer.h"
namespace webrtc {

View file

@ -14,8 +14,8 @@
#include <string>
#include <vector>
#include "api/video/video_stream_encoder_observer.h"
#include "test/gmock.h"
#include "video/video_stream_encoder_observer.h"
namespace webrtc {

View file

@ -21,7 +21,6 @@
#include "api/field_trials_view.h"
#include "api/rtp_parameters.h"
#include "api/video/video_adaptation_counters.h"
#include "api/video/video_stream_encoder_observer.h"
#include "call/adaptation/adaptation_constraint.h"
#include "call/adaptation/degradation_preference_provider.h"
#include "call/adaptation/video_source_restrictions.h"
@ -31,6 +30,7 @@
#include "rtc_base/experiments/balanced_degradation_settings.h"
#include "rtc_base/system/no_unique_address.h"
#include "rtc_base/thread_annotations.h"
#include "video/video_stream_encoder_observer.h"
namespace webrtc {

View file

@ -18,7 +18,6 @@
#include "api/video/video_adaptation_reason.h"
#include "api/video_codecs/video_codec.h"
#include "api/video_codecs/video_encoder.h"
#include "api/video_codecs/video_encoder_config.h"
#include "call/adaptation/adaptation_constraint.h"
#include "call/adaptation/encoder_settings.h"
#include "call/adaptation/test/fake_frame_rate_provider.h"
@ -31,6 +30,7 @@
#include "test/gtest.h"
#include "test/scoped_key_value_config.h"
#include "test/testsupport/rtc_expect_death.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {

View file

@ -11,10 +11,10 @@
#ifndef CALL_ADAPTATION_VIDEO_STREAM_INPUT_STATE_PROVIDER_H_
#define CALL_ADAPTATION_VIDEO_STREAM_INPUT_STATE_PROVIDER_H_
#include "api/video/video_stream_encoder_observer.h"
#include "call/adaptation/encoder_settings.h"
#include "call/adaptation/video_stream_input_state.h"
#include "rtc_base/synchronization/mutex.h"
#include "video/video_stream_encoder_observer.h"
namespace webrtc {

View file

@ -25,7 +25,6 @@
#include "api/video/builtin_video_bitrate_allocator_factory.h"
#include "api/video/video_bitrate_allocation.h"
#include "api/video_codecs/video_encoder.h"
#include "api/video_codecs/video_encoder_config.h"
#include "call/call.h"
#include "call/fake_network_pipe.h"
#include "call/simulated_network.h"
@ -53,6 +52,7 @@
#include "test/rtp_rtcp_observer.h"
#include "test/testsupport/file_utils.h"
#include "test/video_encoder_proxy_factory.h"
#include "video/config/video_encoder_config.h"
#include "video/transport_adapter.h"
using webrtc::test::DriftingClock;

View file

@ -27,7 +27,6 @@
#include "api/rtp_headers.h"
#include "api/task_queue/pending_task_safety_flag.h"
#include "api/test/simulated_network.h"
#include "api/video_codecs/video_encoder_config.h"
#include "call/audio_receive_stream.h"
#include "call/audio_send_stream.h"
#include "call/call.h"
@ -42,6 +41,7 @@
#include "rtc_base/network/sent_packet.h"
#include "rtc_base/task_queue.h"
#include "system_wrappers/include/clock.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {
class DegradedCall : public Call, private PacketReceiver {

View file

@ -29,13 +29,13 @@
#include "api/video/video_sink_interface.h"
#include "api/video/video_source_interface.h"
#include "api/video/video_stream_encoder_settings.h"
#include "api/video_codecs/video_encoder_config.h"
#include "call/rtp_config.h"
#include "common_video/frame_counts.h"
#include "common_video/include/quality_limitation_reason.h"
#include "modules/rtp_rtcp/include/report_block_data.h"
#include "modules/rtp_rtcp/include/rtcp_statistics.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {

View file

@ -98,6 +98,7 @@ rtc_library("rtc_media_base") {
"../rtc_base/system:rtc_export",
"../rtc_base/third_party/sigslot",
"../system_wrappers:field_trial",
"../video/config:encoder_config",
]
absl_deps = [
"//third_party/abseil-cpp/absl/algorithm:container",

View file

@ -25,6 +25,9 @@ specific_include_rules = {
".*webrtc_video_engine\.h": [
"+video/config",
],
".*media_channel\.h": [
"+video/config",
],
".*webrtc_video_engine_unittest\.cc": [
"+video/config",
],

View file

@ -34,7 +34,6 @@
#include "api/video/video_sink_interface.h"
#include "api/video/video_source_interface.h"
#include "api/video/video_timing.h"
#include "api/video_codecs/video_encoder_config.h"
#include "api/video_codecs/video_encoder_factory.h"
#include "call/video_receive_stream.h"
#include "common_video/include/quality_limitation_reason.h"
@ -53,6 +52,7 @@
#include "rtc_base/socket.h"
#include "rtc_base/string_encode.h"
#include "rtc_base/strings/string_builder.h"
#include "video/config/video_encoder_config.h"
namespace rtc {
class Timing;

View file

@ -295,6 +295,7 @@ rtc_library("video_coding") {
"../../system_wrappers",
"../../system_wrappers:field_trial",
"../../system_wrappers:metrics",
"../../video/config:encoder_config",
"../rtp_rtcp",
"../rtp_rtcp:rtp_rtcp_format",
"../rtp_rtcp:rtp_video_header",
@ -989,6 +990,7 @@ if (rtc_include_tests) {
"../../test:test_support",
"../../test:video_test_common",
"../../test:video_test_support",
"../../video/config:encoder_config",
"../../video/config:streams_config",
]
absl_deps = [

View file

@ -7,6 +7,7 @@ include_rules = [
"+rtc_tools",
"+third_party/libyuv",
"+rtc_base/system/rtc_export.h",
"+video/config",
]
specific_include_rules = {

View file

@ -37,7 +37,6 @@
#include "api/video_codecs/video_decoder_factory_template_libvpx_vp8_adapter.h"
#include "api/video_codecs/video_decoder_factory_template_libvpx_vp9_adapter.h"
#include "api/video_codecs/video_decoder_factory_template_open_h264_adapter.h"
#include "api/video_codecs/video_encoder_config.h"
#include "api/video_codecs/video_encoder_factory.h"
#include "api/video_codecs/video_encoder_factory_template.h"
#include "api/video_codecs/video_encoder_factory_template_libaom_av1_adapter.h"
@ -61,6 +60,7 @@
#include "test/testsupport/frame_writer.h"
#include "test/video_codec_settings.h"
#include "video/config/simulcast.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {
namespace test {

View file

@ -15,7 +15,7 @@
#include <string>
#include <vector>
#include "api/video_codecs/video_encoder_config.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {

View file

@ -192,6 +192,7 @@ rtc_library("rate_control_settings") {
"../../api/units:data_size",
"../../api/video_codecs:video_codecs_api",
"../../system_wrappers:field_trial",
"../../video/config:encoder_config",
]
absl_deps = [
"//third_party/abseil-cpp/absl/strings",
@ -289,6 +290,7 @@ if (rtc_include_tests && !build_with_chromium) {
"../../test:scoped_key_value_config",
"../../test:test_main",
"../../test:test_support",
"../../video/config:encoder_config",
]
absl_deps = [
"//third_party/abseil-cpp/absl/strings",

View file

@ -1,3 +1,8 @@
include_rules = [
"+system_wrappers",
]
specific_include_rules = {
".*rate_control_settings.*": [
"+video/config",
],
}

View file

@ -15,8 +15,8 @@
#include "api/field_trials_view.h"
#include "api/units/data_size.h"
#include "api/video_codecs/video_codec.h"
#include "api/video_codecs/video_encoder_config.h"
#include "rtc_base/experiments/struct_parameters_parser.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {

View file

@ -11,9 +11,9 @@
#include "rtc_base/experiments/rate_control_settings.h"
#include "api/video_codecs/video_codec.h"
#include "api/video_codecs/video_encoder_config.h"
#include "test/field_trial.h"
#include "test/gtest.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {

View file

@ -218,6 +218,7 @@ if (!is_component_build) {
"../test:fileutils",
"../test:rtp_test_utils",
"../test:video_test_common",
"../video/config:encoder_config",
"../video/config:streams_config",
"//third_party/abseil-cpp/absl/flags:flag",
"//third_party/abseil-cpp/absl/flags:parse",

View file

@ -19,13 +19,13 @@
#include "api/video_codecs/builtin_video_decoder_factory.h"
#include "api/video_codecs/builtin_video_encoder_factory.h"
#include "api/video_codecs/video_encoder.h"
#include "api/video_codecs/video_encoder_config.h"
#include "media/base/media_constants.h"
#include "rtc_base/strings/json.h"
#include "rtc_base/system/file_wrapper.h"
#include "rtc_base/thread.h"
#include "test/testsupport/file_utils.h"
#include "video/config/encoder_stream_factory.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {
namespace {

View file

@ -21,7 +21,6 @@
#include "api/task_queue/task_queue_factory.h"
#include "api/video/builtin_video_bitrate_allocator_factory.h"
#include "api/video_codecs/video_decoder_factory.h"
#include "api/video_codecs/video_encoder_config.h"
#include "api/video_codecs/video_encoder_factory.h"
#include "call/call.h"
#include "call/rtp_config.h"
@ -30,6 +29,7 @@
#include "test/frame_generator_capturer.h"
#include "test/rtp_file_reader.h"
#include "test/rtp_file_writer.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {

View file

@ -927,6 +927,7 @@ rtc_library("encoder_settings") {
"../call:video_stream_api",
"../rtc_base:checks",
"../rtc_base:refcount",
"../video/config:encoder_config",
]
}
@ -1012,6 +1013,7 @@ rtc_library("test_common") {
"../rtc_base:timeutils",
"../system_wrappers",
"../system_wrappers:field_trial",
"../video/config:encoder_config",
]
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
if (!is_android && !build_with_chromium) {

View file

@ -19,7 +19,6 @@
#include "api/task_queue/task_queue_base.h"
#include "api/test/create_frame_generator.h"
#include "api/video/builtin_video_bitrate_allocator_factory.h"
#include "api/video_codecs/video_encoder_config.h"
#include "call/fake_network_pipe.h"
#include "call/simulated_network.h"
#include "modules/audio_mixer/audio_mixer_impl.h"
@ -28,6 +27,7 @@
#include "rtc_base/task_queue_for_test.h"
#include "test/fake_encoder.h"
#include "test/testsupport/file_utils.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {
namespace test {

View file

@ -15,9 +15,9 @@
#include <string>
#include <vector>
#include "api/video_codecs/video_encoder_config.h"
#include "call/video_receive_stream.h"
#include "call/video_send_stream.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {
namespace test {

View file

@ -8,6 +8,29 @@
import("../webrtc.gni")
rtc_library("video_stream_encoder_interface") {
sources = [
"video_stream_encoder_interface.h",
"video_stream_encoder_observer.h",
]
deps = [
"../api:fec_controller_api",
"../api:rtp_parameters",
"../api:scoped_refptr",
"../api/adaptation:resource_adaptation_api",
"../api/units:data_rate",
"../api/video:video_adaptation",
"../api/video:video_bitrate_allocation",
"../api/video:video_bitrate_allocator",
"../api/video:video_codec_constants",
"../api/video:video_frame",
"../api/video:video_layers_allocation",
"../api/video_codecs:video_codecs_api",
"../video/config:encoder_config",
]
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
}
rtc_library("video") {
sources = [
"buffered_frame_decryptor.cc",
@ -59,6 +82,7 @@ rtc_library("video") {
":unique_timestamp_counter",
":video_stream_buffer_controller",
":video_stream_encoder_impl",
":video_stream_encoder_interface",
"../api:array_view",
"../api:fec_controller_api",
"../api:field_trials_view",
@ -136,6 +160,7 @@ rtc_library("video") {
"../system_wrappers",
"../system_wrappers:field_trial",
"../system_wrappers:metrics",
"../video/config:encoder_config",
"adaptation:video_adaptation",
]
absl_deps = [
@ -377,6 +402,7 @@ rtc_library("video_stream_encoder_impl") {
deps = [
":frame_cadence_adapter",
":video_stream_encoder_interface",
"../api:field_trials_view",
"../api:rtp_parameters",
"../api:sequence_checker",
@ -434,6 +460,7 @@ rtc_library("video_stream_encoder_impl") {
"../system_wrappers:field_trial",
"../system_wrappers:metrics",
"adaptation:video_adaptation",
"config:encoder_config",
"config:streams_config",
]
absl_deps = [
@ -456,6 +483,7 @@ if (rtc_include_tests) {
testonly = true
sources = [ "test/mock_video_stream_encoder.h" ]
deps = [
":video_stream_encoder_interface",
"../api/video:video_stream_encoder",
"../test:test_support",
]
@ -570,6 +598,7 @@ if (rtc_include_tests) {
"../test:fileutils",
"../test:test_common",
"../test:test_support",
"../video/config:encoder_config",
"//testing/gtest",
]
absl_deps = [
@ -906,6 +935,7 @@ if (rtc_include_tests) {
"../test:video_test_common",
"../test/time_controller",
"adaptation:video_adaptation",
"config:encoder_config",
"config:streams_config",
]
absl_deps = [

View file

@ -67,6 +67,8 @@ rtc_library("video_adaptation") {
"../../rtc_base/task_utils:repeating_task",
"../../system_wrappers:field_trial",
"../../system_wrappers:system_wrappers",
"../../video:video_stream_encoder_interface",
"../../video/config:encoder_config",
]
absl_deps = [
"//third_party/abseil-cpp/absl/algorithm:container",

View file

@ -18,12 +18,12 @@
#include "api/field_trials_view.h"
#include "api/sequence_checker.h"
#include "api/task_queue/task_queue_base.h"
#include "api/video/video_stream_encoder_observer.h"
#include "rtc_base/experiments/field_trial_parser.h"
#include "rtc_base/numerics/exp_filter.h"
#include "rtc_base/system/no_unique_address.h"
#include "rtc_base/task_utils/repeating_task.h"
#include "rtc_base/thread_annotations.h"
#include "video/video_stream_encoder_observer.h"
namespace webrtc {

View file

@ -29,10 +29,8 @@
#include "api/video/video_adaptation_reason.h"
#include "api/video/video_frame.h"
#include "api/video/video_source_interface.h"
#include "api/video/video_stream_encoder_observer.h"
#include "api/video_codecs/video_codec.h"
#include "api/video_codecs/video_encoder.h"
#include "api/video_codecs/video_encoder_config.h"
#include "call/adaptation/resource_adaptation_processor_interface.h"
#include "call/adaptation/video_stream_adapter.h"
#include "call/adaptation/video_stream_input_state_provider.h"
@ -51,6 +49,8 @@
#include "video/adaptation/quality_rampup_experiment_helper.h"
#include "video/adaptation/quality_scaler_resource.h"
#include "video/adaptation/video_stream_encoder_resource.h"
#include "video/config/video_encoder_config.h"
#include "video/video_stream_encoder_observer.h"
namespace webrtc {

View file

@ -12,7 +12,7 @@
#define VIDEO_ALIGNMENT_ADJUSTER_H_
#include "api/video_codecs/video_encoder.h"
#include "api/video_codecs/video_encoder_config.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {

View file

@ -17,6 +17,7 @@ rtc_library("streams_config") {
]
deps = [
":encoder_config",
"../../api:field_trials_view",
"../../api/transport:field_trial_based_config",
"../../api/units:data_rate",
@ -40,6 +41,29 @@ rtc_library("streams_config") {
]
}
rtc_library("encoder_config") {
sources = [
"video_encoder_config.cc",
"video_encoder_config.h",
]
deps = [
"../../api:scoped_refptr",
"../../api/video:resolution",
"../../api/video_codecs:scalability_mode",
"../../api/video_codecs:video_codecs_api",
"../../rtc_base:checks",
"../../rtc_base:refcount",
"../../rtc_base:stringutils",
]
absl_deps = [
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional",
]
}
if (rtc_include_tests) {
rtc_library("video_config_tests") {
testonly = true
@ -66,8 +90,3 @@ if (rtc_include_tests) {
}
}
}
rtc_library("encoder_config") {
sources = [ "video_encoder_config.h" ]
deps = [ "../../api/video_codecs:video_codecs_api" ]
}

View file

@ -15,7 +15,7 @@
#include "api/transport/field_trial_based_config.h"
#include "api/units/data_rate.h"
#include "api/video_codecs/video_encoder_config.h"
#include "video/config/video_encoder_config.h"
namespace cricket {

View file

@ -17,7 +17,7 @@
#include "api/field_trials_view.h"
#include "api/units/data_rate.h"
#include "api/video_codecs/video_encoder_config.h"
#include "video/config/video_encoder_config.h"
namespace cricket {

View file

@ -7,7 +7,7 @@
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "api/video_codecs/video_encoder_config.h"
#include "video/config/video_encoder_config.h"
#include <string>

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2013 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
@ -11,6 +11,198 @@
#ifndef VIDEO_CONFIG_VIDEO_ENCODER_CONFIG_H_
#define VIDEO_CONFIG_VIDEO_ENCODER_CONFIG_H_
#include "api/video_codecs/video_encoder_config.h"
#include <stddef.h>
#include <string>
#include <vector>
#include "absl/types/optional.h"
#include "api/scoped_refptr.h"
#include "api/video/resolution.h"
#include "api/video_codecs/scalability_mode.h"
#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_codec.h"
#include "rtc_base/ref_count.h"
namespace webrtc {
// The `VideoStream` struct describes a simulcast layer, or "stream".
struct VideoStream {
VideoStream();
~VideoStream();
VideoStream(const VideoStream& other);
std::string ToString() const;
// Width/Height in pixels.
// This is the actual width and height used to configure encoder,
// which might be less than `requested_resolution` due to adaptation
// or due to the source providing smaller frames than requested.
size_t width;
size_t height;
// Frame rate in fps.
int max_framerate;
// Bitrate, in bps, for the stream.
int min_bitrate_bps;
int target_bitrate_bps;
int max_bitrate_bps;
// Scaling factor applied to the stream size.
// `width` and `height` values are already scaled down.
double scale_resolution_down_by;
// Maximum Quantization Parameter to use when encoding the stream.
int max_qp;
// Determines the number of temporal layers that the stream should be
// encoded with. This value should be greater than zero.
// TODO(brandtr): This class is used both for configuring the encoder
// (meaning that this field _must_ be set), and for signaling the app-level
// encoder settings (meaning that the field _may_ be set). We should separate
// this and remove this optional instead.
absl::optional<size_t> num_temporal_layers;
// The priority of this stream, to be used when allocating resources
// between multiple streams.
absl::optional<double> bitrate_priority;
absl::optional<ScalabilityMode> scalability_mode;
// If this stream is enabled by the user, or not.
bool active;
// An optional user supplied max_frame_resolution
// than can be set independently of (adapted) VideoSource.
// This value is set from RtpEncodingParameters::requested_resolution
// (i.e. used for signaling app-level settings).
//
// The actual encode resolution is in `width` and `height`,
// which can be lower than requested_resolution,
// e.g. if source only provides lower resolution or
// if resource adaptation is active.
absl::optional<Resolution> requested_resolution;
};
class VideoEncoderConfig {
public:
// These are reference counted to permit copying VideoEncoderConfig and be
// kept alive until all encoder_specific_settings go out of scope.
// TODO(kthelgason): Consider removing the need for copying VideoEncoderConfig
// and use absl::optional for encoder_specific_settings instead.
class EncoderSpecificSettings : public rtc::RefCountInterface {
public:
// TODO(pbos): Remove FillEncoderSpecificSettings as soon as VideoCodec is
// not in use and encoder implementations ask for codec-specific structs
// directly.
void FillEncoderSpecificSettings(VideoCodec* codec_struct) const;
virtual void FillVideoCodecVp8(VideoCodecVP8* vp8_settings) const;
virtual void FillVideoCodecVp9(VideoCodecVP9* vp9_settings) const;
private:
~EncoderSpecificSettings() override {}
friend class VideoEncoderConfig;
};
class Vp8EncoderSpecificSettings : public EncoderSpecificSettings {
public:
explicit Vp8EncoderSpecificSettings(const VideoCodecVP8& specifics);
void FillVideoCodecVp8(VideoCodecVP8* vp8_settings) const override;
private:
VideoCodecVP8 specifics_;
};
class Vp9EncoderSpecificSettings : public EncoderSpecificSettings {
public:
explicit Vp9EncoderSpecificSettings(const VideoCodecVP9& specifics);
void FillVideoCodecVp9(VideoCodecVP9* vp9_settings) const override;
private:
VideoCodecVP9 specifics_;
};
enum class ContentType {
kRealtimeVideo,
kScreen,
};
class VideoStreamFactoryInterface : public rtc::RefCountInterface {
public:
// An implementation should return a std::vector<VideoStream> with the
// wanted VideoStream settings for the given video resolution.
// The size of the vector may not be larger than
// `encoder_config.number_of_streams`.
virtual std::vector<VideoStream> CreateEncoderStreams(
int width,
int height,
const VideoEncoderConfig& encoder_config) = 0;
protected:
~VideoStreamFactoryInterface() override {}
};
VideoEncoderConfig& operator=(VideoEncoderConfig&&) = default;
VideoEncoderConfig& operator=(const VideoEncoderConfig&) = delete;
// Mostly used by tests. Avoid creating copies if you can.
VideoEncoderConfig Copy() const { return VideoEncoderConfig(*this); }
VideoEncoderConfig();
VideoEncoderConfig(VideoEncoderConfig&&);
~VideoEncoderConfig();
std::string ToString() const;
// TODO(bugs.webrtc.org/6883): Consolidate on one of these.
VideoCodecType codec_type;
SdpVideoFormat video_format;
// Note: This factory can be unset, and VideoStreamEncoder will
// then use the EncoderStreamFactory. The factory is only set by
// tests.
rtc::scoped_refptr<VideoStreamFactoryInterface> video_stream_factory;
std::vector<SpatialLayer> spatial_layers;
ContentType content_type;
bool frame_drop_enabled;
rtc::scoped_refptr<const EncoderSpecificSettings> encoder_specific_settings;
// Padding will be used up to this bitrate regardless of the bitrate produced
// by the encoder. Padding above what's actually produced by the encoder helps
// maintaining a higher bitrate estimate. Padding will however not be sent
// unless the estimated bandwidth indicates that the link can handle it.
int min_transmit_bitrate_bps;
int max_bitrate_bps;
// The bitrate priority used for all VideoStreams.
double bitrate_priority;
// The simulcast layer's configurations set by the application for this video
// sender. These are modified by the video_stream_factory before being passed
// down to lower layers for the video encoding.
// `simulcast_layers` is also used for configuring non-simulcast (when there
// is a single VideoStream).
std::vector<VideoStream> simulcast_layers;
// Max number of encoded VideoStreams to produce.
size_t number_of_streams;
// Legacy Google conference mode flag for simulcast screenshare
bool legacy_conference_mode;
// Indicates whether quality scaling can be used or not.
bool is_quality_scaling_allowed;
// Maximum Quantization Parameter.
// This value is fed into EncoderStreamFactory that
// apply it to all simulcast layers/spatial layers.
int max_qp;
private:
// Access to the copy constructor is private to force use of the Copy()
// method for those exceptional cases where we do use it.
VideoEncoderConfig(const VideoEncoderConfig&);
};
} // namespace webrtc
#endif // VIDEO_CONFIG_VIDEO_ENCODER_CONFIG_H_

View file

@ -15,7 +15,6 @@
#include "api/video/video_frame.h"
#include "api/video/video_sink_interface.h"
#include "api/video/video_source_interface.h"
#include "api/video_codecs/video_encoder_config.h"
#include "call/video_receive_stream.h"
#include "call/video_send_stream.h"
#include "rtc_base/checks.h"
@ -24,6 +23,7 @@
#include "test/field_trial.h"
#include "test/frame_generator_capturer.h"
#include "test/gtest.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {
namespace {

View file

@ -16,11 +16,11 @@
#include "api/sequence_checker.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "api/video/video_stream_encoder_interface.h"
#include "call/rtp_video_sender_interface.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "rtc_base/system/no_unique_address.h"
#include "system_wrappers/include/clock.h"
#include "video/video_stream_encoder_interface.h"
namespace webrtc {

View file

@ -21,7 +21,6 @@
#include "api/task_queue/task_queue_base.h"
#include "api/test/simulated_network.h"
#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_encoder_config.h"
#include "call/call.h"
#include "call/fake_network_pipe.h"
#include "call/rtp_config.h"
@ -40,6 +39,7 @@
#include "test/gtest.h"
#include "test/rtcp_packet_parser.h"
#include "test/rtp_rtcp_observer.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {
namespace {

View file

@ -16,13 +16,13 @@
#include "api/video/video_frame.h"
#include "api/video/video_sink_interface.h"
#include "api/video_codecs/video_encoder_config.h"
#include "call/rtp_config.h"
#include "call/video_receive_stream.h"
#include "call/video_send_stream.h"
#include "rtc_base/event.h"
#include "test/frame_generator_capturer.h"
#include "test/gtest.h"
#include "video/config/video_encoder_config.h"
#include "video/end_to_end_tests/multi_stream_tester.h"
namespace webrtc {

View file

@ -20,13 +20,13 @@
#include "api/test/video_quality_test_fixture.h"
#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_codec.h"
#include "api/video_codecs/video_encoder_config.h"
#include "api/video_codecs/vp9_profile.h"
#include "modules/video_coding/codecs/vp9/include/vp9.h"
#include "system_wrappers/include/field_trial.h"
#include "test/field_trial.h"
#include "test/gtest.h"
#include "test/testsupport/file_utils.h"
#include "video/config/video_encoder_config.h"
#include "video/video_quality_test.h"
ABSL_FLAG(std::string,

View file

@ -19,8 +19,6 @@
#include "api/field_trials_view.h"
#include "api/video/video_codec_constants.h"
#include "api/video/video_stream_encoder_observer.h"
#include "api/video_codecs/video_encoder_config.h"
#include "call/video_send_stream.h"
#include "modules/include/module_common_types_public.h"
#include "modules/rtp_rtcp/include/report_block_data.h"
@ -31,9 +29,11 @@
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
#include "system_wrappers/include/clock.h"
#include "video/config/video_encoder_config.h"
#include "video/quality_limitation_reason_tracker.h"
#include "video/report_block_stats.h"
#include "video/stats_counter.h"
#include "video/video_stream_encoder_observer.h"
namespace webrtc {

View file

@ -22,11 +22,11 @@
#include "api/video/video_bitrate_allocation.h"
#include "api/video/video_codec_type.h"
#include "api/video_codecs/video_codec.h"
#include "api/video_codecs/video_encoder_config.h"
#include "rtc_base/fake_clock.h"
#include "system_wrappers/include/metrics.h"
#include "test/gtest.h"
#include "test/scoped_key_value_config.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {
namespace {

View file

@ -12,8 +12,8 @@
#include <vector>
#include "api/video/video_stream_encoder_interface.h"
#include "test/gmock.h"
#include "video/video_stream_encoder_interface.h"
namespace webrtc {

View file

@ -19,7 +19,6 @@
#include "api/field_trials_view.h"
#include "api/sequence_checker.h"
#include "api/task_queue/pending_task_safety_flag.h"
#include "api/video/video_stream_encoder_interface.h"
#include "call/bitrate_allocator.h"
#include "call/video_receive_stream.h"
#include "call/video_send_stream.h"
@ -29,6 +28,7 @@
#include "video/send_delay_stats.h"
#include "video/send_statistics_proxy.h"
#include "video/video_send_stream_impl.h"
#include "video/video_stream_encoder_interface.h"
namespace webrtc {
namespace test {

View file

@ -25,9 +25,7 @@
#include "api/video/encoded_image.h"
#include "api/video/video_bitrate_allocation.h"
#include "api/video/video_bitrate_allocator.h"
#include "api/video/video_stream_encoder_interface.h"
#include "api/video_codecs/video_encoder.h"
#include "api/video_codecs/video_encoder_config.h"
#include "call/bitrate_allocator.h"
#include "call/rtp_config.h"
#include "call/rtp_transport_controller_send_interface.h"
@ -39,7 +37,9 @@
#include "rtc_base/system/no_unique_address.h"
#include "rtc_base/task_utils/repeating_task.h"
#include "rtc_base/thread_annotations.h"
#include "video/config/video_encoder_config.h"
#include "video/send_statistics_proxy.h"
#include "video/video_stream_encoder_interface.h"
namespace webrtc {
namespace internal {

View file

@ -26,8 +26,6 @@
#include "api/video/video_bitrate_allocator.h"
#include "api/video/video_rotation.h"
#include "api/video/video_sink_interface.h"
#include "api/video/video_stream_encoder_interface.h"
#include "api/video/video_stream_encoder_observer.h"
#include "api/video/video_stream_encoder_settings.h"
#include "api/video_codecs/video_codec.h"
#include "api/video_codecs/video_encoder.h"
@ -50,6 +48,8 @@
#include "video/frame_cadence_adapter.h"
#include "video/frame_encode_metadata_writer.h"
#include "video/video_source_sink_controller.h"
#include "video/video_stream_encoder_interface.h"
#include "video/video_stream_encoder_observer.h"
namespace webrtc {

View file

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef API_VIDEO_VIDEO_STREAM_ENCODER_INTERFACE_H_
#define API_VIDEO_VIDEO_STREAM_ENCODER_INTERFACE_H_
#ifndef VIDEO_VIDEO_STREAM_ENCODER_INTERFACE_H_
#define VIDEO_VIDEO_STREAM_ENCODER_INTERFACE_H_
#include <vector>
@ -23,7 +23,7 @@
#include "api/video/video_sink_interface.h"
#include "api/video/video_source_interface.h"
#include "api/video_codecs/video_encoder.h"
#include "api/video_codecs/video_encoder_config.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {
@ -137,4 +137,4 @@ class VideoStreamEncoderInterface {
} // namespace webrtc
#endif // API_VIDEO_VIDEO_STREAM_ENCODER_INTERFACE_H_
#endif // VIDEO_VIDEO_STREAM_ENCODER_INTERFACE_H_

View file

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef API_VIDEO_VIDEO_STREAM_ENCODER_OBSERVER_H_
#define API_VIDEO_VIDEO_STREAM_ENCODER_OBSERVER_H_
#ifndef VIDEO_VIDEO_STREAM_ENCODER_OBSERVER_H_
#define VIDEO_VIDEO_STREAM_ENCODER_OBSERVER_H_
#include <string>
#include <vector>
@ -20,7 +20,7 @@
#include "api/video/video_bitrate_allocation.h"
#include "api/video/video_codec_constants.h"
#include "api/video_codecs/video_encoder.h"
#include "api/video_codecs/video_encoder_config.h"
#include "video/config/video_encoder_config.h"
namespace webrtc {
@ -112,4 +112,5 @@ class VideoStreamEncoderObserver : public CpuOveruseMetricsObserver {
};
} // namespace webrtc
#endif // API_VIDEO_VIDEO_STREAM_ENCODER_OBSERVER_H_
#endif // VIDEO_VIDEO_STREAM_ENCODER_OBSERVER_H_