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}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 5bf7396..c7bbff0 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -398,6 +398,7 @@
     "../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",
diff --git a/api/test/video_quality_test_fixture.h b/api/test/video_quality_test_fixture.h
index 08ae12b..0aa23b1 100644
--- a/api/test/video_quality_test_fixture.h
+++ b/api/test/video_quality_test_fixture.h
@@ -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 {
 
diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn
index ee62abd..db9078d 100644
--- a/api/video/BUILD.gn
+++ b/api/video/BUILD.gn
@@ -304,11 +304,7 @@
 
 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",
diff --git a/api/video_codecs/BUILD.gn b/api/video_codecs/BUILD.gn
index d6b7392..386c46b 100644
--- a/api/video_codecs/BUILD.gn
+++ b/api/video_codecs/BUILD.gn
@@ -58,8 +58,6 @@
     "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",
diff --git a/api/video_codecs/video_encoder_config.h b/api/video_codecs/video_encoder_config.h
deleted file mode 100644
index 500ef6f..0000000
--- a/api/video_codecs/video_encoder_config.h
+++ /dev/null
@@ -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_
diff --git a/call/BUILD.gn b/call/BUILD.gn
index c56c557..47d44c3 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -334,6 +334,7 @@
     "../system_wrappers:metrics",
     "../video",
     "../video:decode_synchronizer",
+    "../video/config:encoder_config",
     "adaptation:resource_adaptation",
   ]
   absl_deps = [
@@ -384,6 +385,7 @@
     "../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 @@
         "../test:test_support",
         "../test:video_test_common",
         "../video",
+        "../video/config:encoder_config",
         "//testing/gtest",
       ]
       absl_deps = [
diff --git a/call/adaptation/BUILD.gn b/call/adaptation/BUILD.gn
index c195232..58fadc4 100644
--- a/call/adaptation/BUILD.gn
+++ b/call/adaptation/BUILD.gn
@@ -54,6 +54,8 @@
     "../../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 @@
       "../../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 @@
       "../../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",
diff --git a/call/adaptation/encoder_settings.h b/call/adaptation/encoder_settings.h
index ddb198a..30ce0a0 100644
--- a/call/adaptation/encoder_settings.h
+++ b/call/adaptation/encoder_settings.h
@@ -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 {
 
diff --git a/call/adaptation/resource_adaptation_processor.h b/call/adaptation/resource_adaptation_processor.h
index 6ad0ef8..db3b4c2 100644
--- a/call/adaptation/resource_adaptation_processor.h
+++ b/call/adaptation/resource_adaptation_processor.h
@@ -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 {
 
diff --git a/call/adaptation/test/fake_frame_rate_provider.h b/call/adaptation/test/fake_frame_rate_provider.h
index 3638f47..61cbd19 100644
--- a/call/adaptation/test/fake_frame_rate_provider.h
+++ b/call/adaptation/test/fake_frame_rate_provider.h
@@ -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 {
 
diff --git a/call/adaptation/video_stream_adapter.h b/call/adaptation/video_stream_adapter.h
index 92a5aec..5c17417 100644
--- a/call/adaptation/video_stream_adapter.h
+++ b/call/adaptation/video_stream_adapter.h
@@ -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 {
 
diff --git a/call/adaptation/video_stream_adapter_unittest.cc b/call/adaptation/video_stream_adapter_unittest.cc
index 8f29194..d4bc650 100644
--- a/call/adaptation/video_stream_adapter_unittest.cc
+++ b/call/adaptation/video_stream_adapter_unittest.cc
@@ -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 {
 
diff --git a/call/adaptation/video_stream_input_state_provider.h b/call/adaptation/video_stream_input_state_provider.h
index f4a3e0b..81996e6 100644
--- a/call/adaptation/video_stream_input_state_provider.h
+++ b/call/adaptation/video_stream_input_state_provider.h
@@ -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 {
 
diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc
index 3d8041e..402d69d 100644
--- a/call/call_perf_tests.cc
+++ b/call/call_perf_tests.cc
@@ -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;
diff --git a/call/degraded_call.h b/call/degraded_call.h
index 5223022..dcdd480 100644
--- a/call/degraded_call.h
+++ b/call/degraded_call.h
@@ -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 {
diff --git a/call/video_send_stream.h b/call/video_send_stream.h
index 1202a23..01dc584 100644
--- a/call/video_send_stream.h
+++ b/call/video_send_stream.h
@@ -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 {
 
diff --git a/media/BUILD.gn b/media/BUILD.gn
index 69f18c2..2f02f59 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -98,6 +98,7 @@
     "../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",
diff --git a/media/DEPS b/media/DEPS
index 7ae46d0..7fbbc0f 100644
--- a/media/DEPS
+++ b/media/DEPS
@@ -25,6 +25,9 @@
   ".*webrtc_video_engine\.h": [
     "+video/config",
   ],
+  ".*media_channel\.h": [
+    "+video/config",
+  ],
   ".*webrtc_video_engine_unittest\.cc": [
     "+video/config",
   ],
diff --git a/media/base/media_channel.h b/media/base/media_channel.h
index 986cb26..9677410 100644
--- a/media/base/media_channel.h
+++ b/media/base/media_channel.h
@@ -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;
diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn
index b54b8bd..bae0213 100644
--- a/modules/video_coding/BUILD.gn
+++ b/modules/video_coding/BUILD.gn
@@ -295,6 +295,7 @@
     "../../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 @@
       "../../test:test_support",
       "../../test:video_test_common",
       "../../test:video_test_support",
+      "../../video/config:encoder_config",
       "../../video/config:streams_config",
     ]
     absl_deps = [
diff --git a/modules/video_coding/DEPS b/modules/video_coding/DEPS
index 2aac37a..d62707c 100644
--- a/modules/video_coding/DEPS
+++ b/modules/video_coding/DEPS
@@ -7,6 +7,7 @@
   "+rtc_tools",
   "+third_party/libyuv",
   "+rtc_base/system/rtc_export.h",
+  "+video/config",
 ]
 
 specific_include_rules = {
diff --git a/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc b/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc
index e30fe96..e7028f6 100644
--- a/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc
+++ b/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc
@@ -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 {
diff --git a/modules/video_coding/include/video_codec_initializer.h b/modules/video_coding/include/video_codec_initializer.h
index e979f9c..270c4db 100644
--- a/modules/video_coding/include/video_codec_initializer.h
+++ b/modules/video_coding/include/video_codec_initializer.h
@@ -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 {
 
diff --git a/rtc_base/experiments/BUILD.gn b/rtc_base/experiments/BUILD.gn
index 2293540..ac542cc 100644
--- a/rtc_base/experiments/BUILD.gn
+++ b/rtc_base/experiments/BUILD.gn
@@ -192,6 +192,7 @@
     "../../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 @@
       "../../test:scoped_key_value_config",
       "../../test:test_main",
       "../../test:test_support",
+      "../../video/config:encoder_config",
     ]
     absl_deps = [
       "//third_party/abseil-cpp/absl/strings",
diff --git a/rtc_base/experiments/DEPS b/rtc_base/experiments/DEPS
index 8a9adf1..7c8ddde 100644
--- a/rtc_base/experiments/DEPS
+++ b/rtc_base/experiments/DEPS
@@ -1,3 +1,8 @@
 include_rules = [
   "+system_wrappers",
 ]
+specific_include_rules = {
+  ".*rate_control_settings.*": [
+    "+video/config",
+  ],
+}
diff --git a/rtc_base/experiments/rate_control_settings.h b/rtc_base/experiments/rate_control_settings.h
index 656eeb6..6aff70a 100644
--- a/rtc_base/experiments/rate_control_settings.h
+++ b/rtc_base/experiments/rate_control_settings.h
@@ -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 {
 
diff --git a/rtc_base/experiments/rate_control_settings_unittest.cc b/rtc_base/experiments/rate_control_settings_unittest.cc
index 1946f38..79f19e1 100644
--- a/rtc_base/experiments/rate_control_settings_unittest.cc
+++ b/rtc_base/experiments/rate_control_settings_unittest.cc
@@ -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 {
 
diff --git a/rtc_tools/BUILD.gn b/rtc_tools/BUILD.gn
index 9cf7790..9e6dd0f 100644
--- a/rtc_tools/BUILD.gn
+++ b/rtc_tools/BUILD.gn
@@ -218,6 +218,7 @@
       "../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",
diff --git a/rtc_tools/rtp_generator/rtp_generator.cc b/rtc_tools/rtp_generator/rtp_generator.cc
index d93655a..51f3c35 100644
--- a/rtc_tools/rtp_generator/rtp_generator.cc
+++ b/rtc_tools/rtp_generator/rtp_generator.cc
@@ -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 {
diff --git a/rtc_tools/rtp_generator/rtp_generator.h b/rtc_tools/rtp_generator/rtp_generator.h
index a317bf7..9a56522 100644
--- a/rtc_tools/rtp_generator/rtp_generator.h
+++ b/rtc_tools/rtp_generator/rtp_generator.h
@@ -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 {
 
diff --git a/test/BUILD.gn b/test/BUILD.gn
index df84de8..5a891a7 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -927,6 +927,7 @@
     "../call:video_stream_api",
     "../rtc_base:checks",
     "../rtc_base:refcount",
+    "../video/config:encoder_config",
   ]
 }
 
@@ -1012,6 +1013,7 @@
     "../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) {
diff --git a/test/call_test.cc b/test/call_test.cc
index b0dca88..7e7c9bb 100644
--- a/test/call_test.cc
+++ b/test/call_test.cc
@@ -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 {
diff --git a/test/encoder_settings.h b/test/encoder_settings.h
index 01586cf..01eb4fa 100644
--- a/test/encoder_settings.h
+++ b/test/encoder_settings.h
@@ -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 {
diff --git a/video/BUILD.gn b/video/BUILD.gn
index ac603f5..0f168d7 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -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 @@
     ":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 @@
     "../system_wrappers",
     "../system_wrappers:field_trial",
     "../system_wrappers:metrics",
+    "../video/config:encoder_config",
     "adaptation:video_adaptation",
   ]
   absl_deps = [
@@ -377,6 +402,7 @@
 
   deps = [
     ":frame_cadence_adapter",
+    ":video_stream_encoder_interface",
     "../api:field_trials_view",
     "../api:rtp_parameters",
     "../api:sequence_checker",
@@ -434,6 +460,7 @@
     "../system_wrappers:field_trial",
     "../system_wrappers:metrics",
     "adaptation:video_adaptation",
+    "config:encoder_config",
     "config:streams_config",
   ]
   absl_deps = [
@@ -456,6 +483,7 @@
     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 @@
         "../test:fileutils",
         "../test:test_common",
         "../test:test_support",
+        "../video/config:encoder_config",
         "//testing/gtest",
       ]
       absl_deps = [
@@ -906,6 +935,7 @@
       "../test:video_test_common",
       "../test/time_controller",
       "adaptation:video_adaptation",
+      "config:encoder_config",
       "config:streams_config",
     ]
     absl_deps = [
diff --git a/video/adaptation/BUILD.gn b/video/adaptation/BUILD.gn
index aadf615..d206909 100644
--- a/video/adaptation/BUILD.gn
+++ b/video/adaptation/BUILD.gn
@@ -67,6 +67,8 @@
     "../../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",
diff --git a/video/adaptation/overuse_frame_detector.h b/video/adaptation/overuse_frame_detector.h
index a7393fc..4e1f6a8 100644
--- a/video/adaptation/overuse_frame_detector.h
+++ b/video/adaptation/overuse_frame_detector.h
@@ -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 {
 
diff --git a/video/adaptation/video_stream_encoder_resource_manager.h b/video/adaptation/video_stream_encoder_resource_manager.h
index 61660dd..e0de3f7 100644
--- a/video/adaptation/video_stream_encoder_resource_manager.h
+++ b/video/adaptation/video_stream_encoder_resource_manager.h
@@ -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 {
 
diff --git a/video/alignment_adjuster.h b/video/alignment_adjuster.h
index ea2a9a0..36ac062 100644
--- a/video/alignment_adjuster.h
+++ b/video/alignment_adjuster.h
@@ -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 {
 
diff --git a/video/config/BUILD.gn b/video/config/BUILD.gn
index be76be9..11871b8 100644
--- a/video/config/BUILD.gn
+++ b/video/config/BUILD.gn
@@ -17,6 +17,7 @@
   ]
 
   deps = [
+    ":encoder_config",
     "../../api:field_trials_view",
     "../../api/transport:field_trial_based_config",
     "../../api/units:data_rate",
@@ -40,6 +41,29 @@
   ]
 }
 
+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 @@
     }
   }
 }
-
-rtc_library("encoder_config") {
-  sources = [ "video_encoder_config.h" ]
-  deps = [ "../../api/video_codecs:video_codecs_api" ]
-}
diff --git a/video/config/encoder_stream_factory.h b/video/config/encoder_stream_factory.h
index 971eed4..7da4050 100644
--- a/video/config/encoder_stream_factory.h
+++ b/video/config/encoder_stream_factory.h
@@ -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 {
 
diff --git a/video/config/simulcast.h b/video/config/simulcast.h
index aa48058..32af168 100644
--- a/video/config/simulcast.h
+++ b/video/config/simulcast.h
@@ -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 {
 
diff --git a/api/video_codecs/video_encoder_config.cc b/video/config/video_encoder_config.cc
similarity index 98%
rename from api/video_codecs/video_encoder_config.cc
rename to video/config/video_encoder_config.cc
index fd4a68f..6ea2052 100644
--- a/api/video_codecs/video_encoder_config.cc
+++ b/video/config/video_encoder_config.cc
@@ -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>
 
diff --git a/video/config/video_encoder_config.h b/video/config/video_encoder_config.h
index d33dec1..41bdefa 100644
--- a/video/config/video_encoder_config.h
+++ b/video/config/video_encoder_config.h
@@ -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_
diff --git a/video/cpu_scaling_tests.cc b/video/cpu_scaling_tests.cc
index 33e0e12..b9f3a45 100644
--- a/video/cpu_scaling_tests.cc
+++ b/video/cpu_scaling_tests.cc
@@ -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 {
diff --git a/video/encoder_rtcp_feedback.h b/video/encoder_rtcp_feedback.h
index 2aadcc3..c66a945 100644
--- a/video/encoder_rtcp_feedback.h
+++ b/video/encoder_rtcp_feedback.h
@@ -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 {
 
diff --git a/video/end_to_end_tests/extended_reports_tests.cc b/video/end_to_end_tests/extended_reports_tests.cc
index 1b631ae..ee37bf9 100644
--- a/video/end_to_end_tests/extended_reports_tests.cc
+++ b/video/end_to_end_tests/extended_reports_tests.cc
@@ -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 {
diff --git a/video/end_to_end_tests/multi_stream_tests.cc b/video/end_to_end_tests/multi_stream_tests.cc
index ff17fc1..b997538 100644
--- a/video/end_to_end_tests/multi_stream_tests.cc
+++ b/video/end_to_end_tests/multi_stream_tests.cc
@@ -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 {
diff --git a/video/full_stack_tests.cc b/video/full_stack_tests.cc
index 3831fdf..cddf983 100644
--- a/video/full_stack_tests.cc
+++ b/video/full_stack_tests.cc
@@ -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,
diff --git a/video/send_statistics_proxy.h b/video/send_statistics_proxy.h
index a1319d8..e1c653d 100644
--- a/video/send_statistics_proxy.h
+++ b/video/send_statistics_proxy.h
@@ -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 {
 
diff --git a/video/send_statistics_proxy_unittest.cc b/video/send_statistics_proxy_unittest.cc
index 8264065..5a7c356 100644
--- a/video/send_statistics_proxy_unittest.cc
+++ b/video/send_statistics_proxy_unittest.cc
@@ -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 {
diff --git a/video/test/mock_video_stream_encoder.h b/video/test/mock_video_stream_encoder.h
index 8ea87ac..ff246df 100644
--- a/video/test/mock_video_stream_encoder.h
+++ b/video/test/mock_video_stream_encoder.h
@@ -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 {
 
diff --git a/video/video_send_stream.h b/video/video_send_stream.h
index d495133..3fa8463 100644
--- a/video/video_send_stream.h
+++ b/video/video_send_stream.h
@@ -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 {
diff --git a/video/video_send_stream_impl.h b/video/video_send_stream_impl.h
index d6ce47f..b738cd8 100644
--- a/video/video_send_stream_impl.h
+++ b/video/video_send_stream_impl.h
@@ -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 {
diff --git a/video/video_stream_encoder.h b/video/video_stream_encoder.h
index c4c461f..7a4fc32 100644
--- a/video/video_stream_encoder.h
+++ b/video/video_stream_encoder.h
@@ -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 {
 
diff --git a/api/video/video_stream_encoder_interface.h b/video/video_stream_encoder_interface.h
similarity index 96%
rename from api/video/video_stream_encoder_interface.h
rename to video/video_stream_encoder_interface.h
index 44affa4..38f180d 100644
--- a/api/video/video_stream_encoder_interface.h
+++ b/video/video_stream_encoder_interface.h
@@ -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 @@
 
 }  // namespace webrtc
 
-#endif  // API_VIDEO_VIDEO_STREAM_ENCODER_INTERFACE_H_
+#endif  // VIDEO_VIDEO_STREAM_ENCODER_INTERFACE_H_
diff --git a/api/video/video_stream_encoder_observer.h b/video/video_stream_encoder_observer.h
similarity index 94%
rename from api/video/video_stream_encoder_observer.h
rename to video/video_stream_encoder_observer.h
index 01e1f66..32d8408 100644
--- a/api/video/video_stream_encoder_observer.h
+++ b/video/video_stream_encoder_observer.h
@@ -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 @@
 };
 
 }  // namespace webrtc
-#endif  // API_VIDEO_VIDEO_STREAM_ENCODER_OBSERVER_H_
+
+#endif  // VIDEO_VIDEO_STREAM_ENCODER_OBSERVER_H_