Reland "Reland "Move rtp-specific config out of EncoderSettings.""

This reverts commit 6c2c13af06b32778b86950681758a7970d1c5d9e.

Reason for revert: Intend to investigate and fix perf problems.

Original change's description:
> Revert "Reland "Move rtp-specific config out of EncoderSettings.""
> 
> This reverts commit 04dd1768625eb2241d1fb97fd0137897e703e266.
> 
> Reason for revert: Regression in ramp up perf tests.
> 
> Original change's description:
> > Reland "Move rtp-specific config out of EncoderSettings."
> >
> > This is a reland of bc900cb1d1810fcf678fe41cf1e3966daa39c88c
> >
> > Original change's description:
> > > Move rtp-specific config out of EncoderSettings.
> > >
> > > In VideoSendStream::Config, move payload_name and payload_type from
> > > EncoderSettings to Rtp.
> > >
> > > EncoderSettings now contains configuration for VideoStreamEncoder only,
> > > and should perhaps be renamed in a follow up cl. It's no longer
> > > passed as an argument to VideoCodecInitializer::SetupCodec.
> > >
> > > The latter then needs a different way to know the codec type,
> > > which is provided by a new codec_type member in VideoEncoderConfig.
> > >
> > > Bug: webrtc:8830
> > > Change-Id: Ifcc691aef1ee6a95e43c0452c5e630d92a511cd6
> > > Reviewed-on: https://webrtc-review.googlesource.com/62062
> > > Commit-Queue: Niels Moller <nisse@webrtc.org>
> > > Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
> > > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#22532}
> >
> > Bug: webrtc:8830
> > Change-Id: If88ef7d57cdaa4fae3c7b2a97ea5a6e1b833e019
> > Reviewed-on: https://webrtc-review.googlesource.com/63721
> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
> > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > Commit-Queue: Niels Moller <nisse@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#22595}
> 
> TBR=brandtr@webrtc.org,magjed@webrtc.org,nisse@webrtc.org,stefan@webrtc.org
> 
> Bug: webrtc:8830,chromium:827080
> Change-Id: Iaaf146de91ec5c0d741b8efdf143f7e173084fef
> Reviewed-on: https://webrtc-review.googlesource.com/65520
> Commit-Queue: Niels Moller <nisse@webrtc.org>
> Reviewed-by: Niels Moller <nisse@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#22677}

TBR=brandtr@webrtc.org,magjed@webrtc.org,nisse@webrtc.org,stefan@webrtc.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: webrtc:8830, chromium:827080
Change-Id: I9b62987bf5daced90dfeb3ebb6739c80117c487f
Reviewed-on: https://webrtc-review.googlesource.com/66862
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22751}
diff --git a/call/bitrate_estimator_tests.cc b/call/bitrate_estimator_tests.cc
index b833034..b4f808f 100644
--- a/call/bitrate_estimator_tests.cc
+++ b/call/bitrate_estimator_tests.cc
@@ -118,10 +118,9 @@
       video_send_config_.rtp.ssrcs.push_back(kVideoSendSsrcs[0]);
       // Encoders will be set separately per stream.
       video_send_config_.encoder_settings.encoder = nullptr;
-      video_send_config_.encoder_settings.payload_name = "FAKE";
-      video_send_config_.encoder_settings.payload_type =
-          kFakeVideoSendPayloadType;
-      test::FillEncoderConfiguration(1, &video_encoder_config_);
+      video_send_config_.rtp.payload_name = "FAKE";
+      video_send_config_.rtp.payload_type = kFakeVideoSendPayloadType;
+      test::FillEncoderConfiguration(kVideoCodecVP8, 1, &video_encoder_config_);
 
       receive_config_ = VideoReceiveStream::Config(receive_transport_.get());
       // receive_config_.decoders will be set by every stream separately.
@@ -182,10 +181,8 @@
 
       VideoReceiveStream::Decoder decoder;
       decoder.decoder = &fake_decoder_;
-      decoder.payload_type =
-          test_->video_send_config_.encoder_settings.payload_type;
-      decoder.payload_name =
-          test_->video_send_config_.encoder_settings.payload_name;
+      decoder.payload_type = test_->video_send_config_.rtp.payload_type;
+      decoder.payload_name = test_->video_send_config_.rtp.payload_name;
       test_->receive_config_.decoders.clear();
       test_->receive_config_.decoders.push_back(decoder);
       test_->receive_config_.rtp.remote_ssrc =
diff --git a/call/call.cc b/call/call.cc
index aee43aa..4f18330 100644
--- a/call/call.cc
+++ b/call/call.cc
@@ -135,8 +135,8 @@
   rtclog_config->rtcp_mode = config.rtp.rtcp_mode;
   rtclog_config->rtp_extensions = config.rtp.extensions;
 
-  rtclog_config->codecs.emplace_back(config.encoder_settings.payload_name,
-                                     config.encoder_settings.payload_type,
+  rtclog_config->codecs.emplace_back(config.rtp.payload_name,
+                                     config.rtp.payload_type,
                                      config.rtp.rtx.payload_type);
   return rtclog_config;
 }
diff --git a/call/rampup_tests.cc b/call/rampup_tests.cc
index c5920e2..6f4227d 100644
--- a/call/rampup_tests.cc
+++ b/call/rampup_tests.cc
@@ -220,7 +220,7 @@
       recv_config.rtp.rtx_ssrc = video_rtx_ssrcs_[i];
       recv_config.rtp
           .rtx_associated_payload_types[send_config->rtp.rtx.payload_type] =
-          send_config->encoder_settings.payload_type;
+          send_config->rtp.payload_type;
     }
     ++i;
   }
diff --git a/call/video_config.h b/call/video_config.h
index 041b779..162d833 100644
--- a/call/video_config.h
+++ b/call/video_config.h
@@ -126,10 +126,6 @@
   ~VideoEncoderConfig();
   std::string ToString() const;
 
-  // TODO(nisse): This codec_type member is intended to be the new way
-  // to say which codec to use, when
-  // VideoSendStream::Config::EncoderSettings::payload_name is
-  // deleted. For the transition, both need to coexist.
   VideoCodecType codec_type;
   rtc::scoped_refptr<VideoStreamFactoryInterface> video_stream_factory;
   std::vector<SpatialLayer> spatial_layers;
diff --git a/call/video_send_stream.cc b/call/video_send_stream.cc
index 5bf965c..8fccd32 100644
--- a/call/video_send_stream.cc
+++ b/call/video_send_stream.cc
@@ -91,9 +91,7 @@
 std::string VideoSendStream::Config::EncoderSettings::ToString() const {
   char buf[1024];
   rtc::SimpleStringBuilder ss(buf);
-  ss << "{payload_name: " << payload_name;
-  ss << ", payload_type: " << payload_type;
-  ss << ", encoder_factory: "
+  ss << "{encoder_factory: "
      << (encoder_factory ? "(VideoEncoderFactory)" : "(nullptr)");
   ss << ", encoder: " << (encoder ? "(VideoEncoder)" : "nullptr");
   ss << '}';
@@ -132,6 +130,8 @@
 
   ss << ", nack: {rtp_history_ms: " << nack.rtp_history_ms << '}';
   ss << ", ulpfec: " << ulpfec.ToString();
+  ss << ", payload_name: " << payload_name;
+  ss << ", payload_type: " << payload_type;
 
   ss << ", flexfec: {payload_type: " << flexfec.payload_type;
   ss << ", ssrc: " << flexfec.ssrc;
diff --git a/call/video_send_stream.h b/call/video_send_stream.h
index 59e8690..0019a95 100644
--- a/call/video_send_stream.h
+++ b/call/video_send_stream.h
@@ -113,19 +113,9 @@
 
     struct EncoderSettings {
       EncoderSettings() = default;
-      EncoderSettings(std::string payload_name,
-                      int payload_type,
-                      VideoEncoder* encoder)
-          : payload_name(std::move(payload_name)),
-            payload_type(payload_type),
-            encoder(encoder) {}
+      explicit EncoderSettings(VideoEncoder* encoder) : encoder(encoder) {}
       std::string ToString() const;
 
-      // TODO(nisse): About to be deleted. Unused if the corresponding
-      // fields in the below Rtp struct are set.
-      std::string payload_name;
-      int payload_type = -1;
-
       // TODO(sophiechang): Delete this field when no one is using internal
       // sources anymore.
       bool internal_source = false;
diff --git a/media/engine/fakewebrtccall.cc b/media/engine/fakewebrtccall.cc
index 4bc01f0..0aa9cb0 100644
--- a/media/engine/fakewebrtccall.cc
+++ b/media/engine/fakewebrtccall.cc
@@ -229,19 +229,19 @@
   if (config.encoder_specific_settings != NULL) {
     const unsigned char num_temporal_layers = static_cast<unsigned char>(
         video_streams_.back().num_temporal_layers.value_or(1));
-    if (config_.encoder_settings.payload_name == "VP8") {
+    if (config_.rtp.payload_name == "VP8") {
       config.encoder_specific_settings->FillVideoCodecVp8(&vpx_settings_.vp8);
       if (!video_streams_.empty()) {
         vpx_settings_.vp8.numberOfTemporalLayers = num_temporal_layers;
       }
-    } else if (config_.encoder_settings.payload_name == "VP9") {
+    } else if (config_.rtp.payload_name == "VP9") {
       config.encoder_specific_settings->FillVideoCodecVp9(&vpx_settings_.vp9);
       if (!video_streams_.empty()) {
         vpx_settings_.vp9.numberOfTemporalLayers = num_temporal_layers;
       }
     } else {
       ADD_FAILURE() << "Unsupported encoder payload: "
-                    << config_.encoder_settings.payload_name;
+                    << config_.rtp.payload_name;
     }
   }
   codec_settings_set_ = config.encoder_specific_settings != NULL;
diff --git a/media/engine/webrtcvideoengine.cc b/media/engine/webrtcvideoengine.cc
index 8de05da..3cf72cf 100644
--- a/media/engine/webrtcvideoengine.cc
+++ b/media/engine/webrtcvideoengine.cc
@@ -1757,8 +1757,8 @@
   parameters_.config.encoder_settings.internal_source =
       info.has_internal_source;
 
-  parameters_.config.encoder_settings.payload_name = codec_settings.codec.name;
-  parameters_.config.encoder_settings.payload_type = codec_settings.codec.id;
+  parameters_.config.rtp.payload_name = codec_settings.codec.name;
+  parameters_.config.rtp.payload_type = codec_settings.codec.id;
   parameters_.config.rtp.ulpfec = codec_settings.ulpfec;
   parameters_.config.rtp.flexfec.payload_type =
       codec_settings.flexfec_payload_type;
@@ -1914,6 +1914,8 @@
     const VideoCodec& codec) const {
   RTC_DCHECK_RUN_ON(&thread_checker_);
   webrtc::VideoEncoderConfig encoder_config;
+  encoder_config.codec_type = webrtc::PayloadStringToCodecType(codec.name);
+
   bool is_screencast = parameters_.options.is_screencast.value_or(false);
   if (is_screencast) {
     encoder_config.min_transmit_bitrate_bps =
diff --git a/media/engine/webrtcvideoengine_unittest.cc b/media/engine/webrtcvideoengine_unittest.cc
index ae85fc0..ed46e3d 100644
--- a/media/engine/webrtcvideoengine_unittest.cc
+++ b/media/engine/webrtcvideoengine_unittest.cc
@@ -133,7 +133,7 @@
 void VerifySendStreamHasRtxTypes(const webrtc::VideoSendStream::Config& config,
                                  const std::map<int, int>& rtx_types) {
   std::map<int, int>::const_iterator it;
-  it = rtx_types.find(config.encoder_settings.payload_type);
+  it = rtx_types.find(config.rtp.payload_type);
   EXPECT_TRUE(it != rtx_types.end() &&
               it->second == config.rtp.rtx.payload_type);
 
diff --git a/modules/video_coding/include/video_codec_initializer.h b/modules/video_coding/include/video_codec_initializer.h
index 9b91aa9..498cb3d 100644
--- a/modules/video_coding/include/video_codec_initializer.h
+++ b/modules/video_coding/include/video_codec_initializer.h
@@ -13,8 +13,10 @@
 
 #include <memory>
 #include <string>
+#include <utility>
 #include <vector>
 
+#include "call/video_config.h"
 #include "call/video_send_stream.h"
 
 namespace webrtc {
@@ -33,12 +35,25 @@
   // GetBitrateAllocator is called implicitly from here, no need to call again.
   static bool SetupCodec(
       const VideoEncoderConfig& config,
-      const VideoSendStream::Config::EncoderSettings settings,
       const std::vector<VideoStream>& streams,
       bool nack_enabled,
       VideoCodec* codec,
       std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator);
 
+  // TODO(nisse): Deprecated version, with an additional ignored argument.
+  // Delete as soon as downstream users are updated, together with above
+  // includes of "call/video_send_stream.h" and <utility>.
+  static bool SetupCodec(
+      const VideoEncoderConfig& config,
+      const VideoSendStream::Config::EncoderSettings /* settings */,
+      const std::vector<VideoStream>& streams,
+      bool nack_enabled,
+      VideoCodec* codec,
+      std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator) {
+    return SetupCodec(config, streams, nack_enabled, codec,
+                      std::move(bitrate_allocator));
+}
+
   // Create a bitrate allocator for the specified codec. |tl_factory| is
   // optional, if it is populated, ownership of that instance will be
   // transferred to the VideoBitrateAllocator instance.
@@ -49,8 +64,6 @@
   static VideoCodec VideoEncoderConfigToVideoCodec(
       const VideoEncoderConfig& config,
       const std::vector<VideoStream>& streams,
-      // TODO(nisse): Delete when we can rely on config.codec_type.
-      VideoCodecType codec_type,
       bool nack_enabled);
 };
 
diff --git a/modules/video_coding/video_codec_initializer.cc b/modules/video_coding/video_codec_initializer.cc
index e0c40c1..5ba659d 100644
--- a/modules/video_coding/video_codec_initializer.cc
+++ b/modules/video_coding/video_codec_initializer.cc
@@ -28,23 +28,15 @@
 
 bool VideoCodecInitializer::SetupCodec(
     const VideoEncoderConfig& config,
-    const VideoSendStream::Config::EncoderSettings settings,
     const std::vector<VideoStream>& streams,
     bool nack_enabled,
     VideoCodec* codec,
     std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator) {
-  VideoCodecType codec_type = config.codec_type;
-  // TODO(nisse): Transition hack, the intention is to delete the
-  // |settings| argument and require configuration via
-  // config.codec_type.
-  if (codec_type == kVideoCodecUnknown) {
-    codec_type = PayloadStringToCodecType(settings.payload_name);
-  }
-  if (codec_type == kVideoCodecMultiplex) {
+  if (config.codec_type == kVideoCodecMultiplex) {
     VideoEncoderConfig associated_config = config.Copy();
     associated_config.codec_type = kVideoCodecVP9;
-    if (!SetupCodec(associated_config, settings /* ignored */, streams,
-                    nack_enabled, codec, bitrate_allocator)) {
+    if (!SetupCodec(associated_config, streams, nack_enabled, codec,
+                    bitrate_allocator)) {
       RTC_LOG(LS_ERROR) << "Failed to create stereo encoder configuration.";
       return false;
     }
@@ -53,7 +45,7 @@
   }
 
   *codec =
-      VideoEncoderConfigToVideoCodec(config, streams, codec_type, nack_enabled);
+      VideoEncoderConfigToVideoCodec(config, streams, nack_enabled);
   *bitrate_allocator = CreateBitrateAllocator(*codec);
 
   return true;
@@ -82,7 +74,6 @@
 VideoCodec VideoCodecInitializer::VideoEncoderConfigToVideoCodec(
     const VideoEncoderConfig& config,
     const std::vector<VideoStream>& streams,
-    VideoCodecType codec_type,
     bool nack_enabled) {
   static const int kEncoderMinBitrateKbps = 30;
   RTC_DCHECK(!streams.empty());
@@ -90,7 +81,7 @@
 
   VideoCodec video_codec;
   memset(&video_codec, 0, sizeof(video_codec));
-  video_codec.codecType = codec_type;
+  video_codec.codecType = config.codec_type;
 
   switch (config.content_type) {
     case VideoEncoderConfig::ContentType::kRealtimeVideo:
diff --git a/modules/video_coding/video_codec_initializer_unittest.cc b/modules/video_coding/video_codec_initializer_unittest.cc
index 2b3103d..4a39399 100644
--- a/modules/video_coding/video_codec_initializer_unittest.cc
+++ b/modules/video_coding/video_codec_initializer_unittest.cc
@@ -20,10 +20,6 @@
 namespace webrtc {
 
 namespace {
-static const char* kVp8PayloadName = "VP8";
-static const int kVp8PayloadType = 100;
-static const char* kVp9PayloadName = "VP9";
-static const int kVp9PayloadType = 120;
 static const int kDefaultWidth = 1280;
 static const int kDefaultHeight = 720;
 static const int kDefaultFrameRate = 30;
@@ -52,6 +48,8 @@
                 int num_temporal_streams,
                 bool screenshare) {
     config_ = VideoEncoderConfig();
+    config_.codec_type = type;
+
     if (screenshare) {
       config_.min_transmit_bitrate_bps = kDefaultMinTransmitBitrateBps;
       config_.content_type = VideoEncoderConfig::ContentType::kScreen;
@@ -63,16 +61,12 @@
       vp8_settings.numberOfTemporalLayers = num_temporal_streams;
       config_.encoder_specific_settings = new rtc::RefCountedObject<
           webrtc::VideoEncoderConfig::Vp8EncoderSpecificSettings>(vp8_settings);
-      settings_.payload_name = kVp8PayloadName;
-      settings_.payload_type = kVp8PayloadType;
     } else if (type == VideoCodecType::kVideoCodecVP9) {
       VideoCodecVP9 vp9_settings = VideoEncoder::GetDefaultVp9Settings();
       vp9_settings.numberOfSpatialLayers = num_spatial_streams;
       vp9_settings.numberOfTemporalLayers = num_temporal_streams;
       config_.encoder_specific_settings = new rtc::RefCountedObject<
           webrtc::VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings);
-      settings_.payload_name = kVp9PayloadName;
-      settings_.payload_type = kVp9PayloadType;
     } else if (type != VideoCodecType::kVideoCodecMultiplex) {
       ADD_FAILURE() << "Unexpected codec type: " << type;
     }
@@ -82,8 +76,8 @@
     codec_out_ = VideoCodec();
     bitrate_allocator_out_.reset();
     temporal_layers_.clear();
-    if (!VideoCodecInitializer::SetupCodec(config_, settings_, streams_,
-                                           nack_enabled_, &codec_out_,
+    if (!VideoCodecInitializer::SetupCodec(config_, streams_, nack_enabled_,
+                                           &codec_out_,
                                            &bitrate_allocator_out_)) {
       return false;
     }
@@ -127,7 +121,6 @@
 
   // Input settings.
   VideoEncoderConfig config_;
-  VideoSendStream::Config::EncoderSettings settings_;
   std::vector<VideoStream> streams_;
   bool nack_enabled_;
 
diff --git a/test/call_test.cc b/test/call_test.cc
index ff65ad0..4e62865 100644
--- a/test/call_test.cc
+++ b/test/call_test.cc
@@ -194,14 +194,15 @@
   RTC_DCHECK_LE(num_video_streams + num_used_ssrcs, kNumSsrcs);
   *video_config = VideoSendStream::Config(send_transport);
   video_config->encoder_settings.encoder = &fake_encoder_;
-  video_config->encoder_settings.payload_name = "FAKE";
-  video_config->encoder_settings.payload_type = kFakeVideoSendPayloadType;
+  video_config->rtp.payload_name = "FAKE";
+  video_config->rtp.payload_type = kFakeVideoSendPayloadType;
   video_config->rtp.extensions.push_back(
       RtpExtension(RtpExtension::kTransportSequenceNumberUri,
                    kTransportSequenceNumberExtensionId));
   video_config->rtp.extensions.push_back(RtpExtension(
       RtpExtension::kVideoContentTypeUri, kVideoContentTypeExtensionId));
-  FillEncoderConfiguration(num_video_streams, &video_encoder_config_);
+  FillEncoderConfiguration(kVideoCodecGeneric, num_video_streams,
+                           &video_encoder_config_);
 
   for (size_t i = 0; i < num_video_streams; ++i)
     video_config->rtp.ssrcs.push_back(kVideoSendSsrcs[num_used_ssrcs + i]);
@@ -257,7 +258,7 @@
   video_config.renderer = &fake_renderer_;
   for (size_t i = 0; i < video_send_config.rtp.ssrcs.size(); ++i) {
     VideoReceiveStream::Decoder decoder =
-        test::CreateMatchingDecoder(video_send_config.encoder_settings);
+        test::CreateMatchingDecoder(video_send_config);
     allocated_decoders_.push_back(
         std::unique_ptr<VideoDecoder>(decoder.decoder));
     video_config.decoders.clear();
diff --git a/test/encoder_settings.cc b/test/encoder_settings.cc
index 83dea9c..665c82b 100644
--- a/test/encoder_settings.cc
+++ b/test/encoder_settings.cc
@@ -78,10 +78,12 @@
   return CreateVideoStreams(width, height, encoder_config);
 }
 
-void FillEncoderConfiguration(size_t num_streams,
+void FillEncoderConfiguration(VideoCodecType codec_type,
+                              size_t num_streams,
                               VideoEncoderConfig* configuration) {
   RTC_DCHECK_LE(num_streams, DefaultVideoStreamFactory::kMaxNumberOfStreams);
 
+  configuration->codec_type = codec_type;
   configuration->number_of_streams = num_streams;
   configuration->video_stream_factory =
       new rtc::RefCountedObject<DefaultVideoStreamFactory>();
@@ -94,17 +96,17 @@
 }
 
 VideoReceiveStream::Decoder CreateMatchingDecoder(
-    const VideoSendStream::Config::EncoderSettings& encoder_settings) {
+    int payload_type, const std::string& payload_name) {
   VideoReceiveStream::Decoder decoder;
-  decoder.payload_type = encoder_settings.payload_type;
-  decoder.payload_name = encoder_settings.payload_name;
-  if (encoder_settings.payload_name == "H264") {
+  decoder.payload_type = payload_type;
+  decoder.payload_name = payload_name;
+  if (payload_name == "H264") {
     decoder.decoder = H264Decoder::Create().release();
-  } else if (encoder_settings.payload_name == "VP8") {
+  } else if (payload_name == "VP8") {
     decoder.decoder = VP8Decoder::Create().release();
-  } else if (encoder_settings.payload_name == "VP9") {
+  } else if (payload_name == "VP9") {
     decoder.decoder = VP9Decoder::Create().release();
-  } else if (encoder_settings.payload_name == "multiplex") {
+  } else if (payload_name == "multiplex") {
     decoder.decoder = new MultiplexDecoderAdapter(
         new InternalDecoderFactory(), SdpVideoFormat(cricket::kVp9CodecName));
   } else {
@@ -112,5 +114,12 @@
   }
   return decoder;
 }
+
+VideoReceiveStream::Decoder CreateMatchingDecoder(
+    const VideoSendStream::Config& config) {
+  return CreateMatchingDecoder(config.rtp.payload_type,
+                               config.rtp.payload_name);
+}
+
 }  // namespace test
 }  // namespace webrtc
diff --git a/test/encoder_settings.h b/test/encoder_settings.h
index 25cfa29..787387b 100644
--- a/test/encoder_settings.h
+++ b/test/encoder_settings.h
@@ -45,11 +45,14 @@
     int height,
     const webrtc::VideoEncoderConfig& encoder_config);
 
-void FillEncoderConfiguration(size_t num_streams,
+void FillEncoderConfiguration(VideoCodecType codec_type, size_t num_streams,
                               VideoEncoderConfig* configuration);
 
 VideoReceiveStream::Decoder CreateMatchingDecoder(
-    const VideoSendStream::Config::EncoderSettings& encoder_settings);
+    int payload_type, const std::string& payload_name);
+
+VideoReceiveStream::Decoder CreateMatchingDecoder(
+    const VideoSendStream::Config& config);
 }  // namespace test
 }  // namespace webrtc
 
diff --git a/video/encoder_rtcp_feedback_unittest.cc b/video/encoder_rtcp_feedback_unittest.cc
index 07e8978..398e3fd 100644
--- a/video/encoder_rtcp_feedback_unittest.cc
+++ b/video/encoder_rtcp_feedback_unittest.cc
@@ -24,13 +24,13 @@
 class MockVideoStreamEncoder : public VideoStreamEncoder {
  public:
   explicit MockVideoStreamEncoder(SendStatisticsProxy* send_stats_proxy)
-      : VideoStreamEncoder(1,
-                           send_stats_proxy,
-                           VideoSendStream::Config::EncoderSettings("fake", 0,
-                                                                    nullptr),
-                           nullptr,
-                           rtc::MakeUnique<OveruseFrameDetector>(
-                               CpuOveruseOptions(), nullptr)) {}
+      : VideoStreamEncoder(
+            1,
+            send_stats_proxy,
+            VideoSendStream::Config::EncoderSettings(nullptr),
+            nullptr,
+            rtc::MakeUnique<OveruseFrameDetector>(CpuOveruseOptions(),
+                                                  nullptr)) {}
   ~MockVideoStreamEncoder() { Stop(); }
 
   MOCK_METHOD0(SendKeyFrame, void());
diff --git a/video/end_to_end_tests/codec_tests.cc b/video/end_to_end_tests/codec_tests.cc
index 01c238a..1607382 100644
--- a/video/end_to_end_tests/codec_tests.cc
+++ b/video/end_to_end_tests/codec_tests.cc
@@ -68,17 +68,17 @@
       VideoSendStream::Config* send_config,
       std::vector<VideoReceiveStream::Config>* receive_configs,
       VideoEncoderConfig* encoder_config) override {
+    encoder_config->codec_type = PayloadStringToCodecType(payload_name_);
     send_config->encoder_settings.encoder = encoder_.get();
-    send_config->encoder_settings.payload_name = payload_name_;
-    send_config->encoder_settings.payload_type =
-        test::CallTest::kVideoSendPayloadType;
+    send_config->rtp.payload_name = payload_name_;
+    send_config->rtp.payload_type = test::CallTest::kVideoSendPayloadType;
 
     (*receive_configs)[0].renderer = this;
     (*receive_configs)[0].decoders.resize(1);
     (*receive_configs)[0].decoders[0].payload_type =
-        send_config->encoder_settings.payload_type;
+        send_config->rtp.payload_type;
     (*receive_configs)[0].decoders[0].payload_name =
-        send_config->encoder_settings.payload_name;
+        send_config->rtp.payload_name;
     (*receive_configs)[0].decoders[0].decoder = decoder_.get();
   }
 
diff --git a/video/end_to_end_tests/extended_reports_tests.cc b/video/end_to_end_tests/extended_reports_tests.cc
index 3ce47ad..322a9c3 100644
--- a/video/end_to_end_tests/extended_reports_tests.cc
+++ b/video/end_to_end_tests/extended_reports_tests.cc
@@ -132,12 +132,13 @@
           new rtc::RefCountedObject<ZeroTargetVideoStreamFactory>();
 
       // Configure VP8 to be able to use simulcast.
-      send_config->encoder_settings.payload_name = "VP8";
+      send_config->rtp.payload_name = "VP8";
+      encoder_config->codec_type = kVideoCodecVP8;
       (*receive_configs)[0].decoders.resize(1);
       (*receive_configs)[0].decoders[0].payload_type =
-          send_config->encoder_settings.payload_type;
+          send_config->rtp.payload_type;
       (*receive_configs)[0].decoders[0].payload_name =
-          send_config->encoder_settings.payload_name;
+          send_config->rtp.payload_name;
     }
     if (enable_target_bitrate_) {
       // TargetBitrate only signaled for screensharing.
diff --git a/video/end_to_end_tests/fec_tests.cc b/video/end_to_end_tests/fec_tests.cc
index 36171ff..80a97cd 100644
--- a/video/end_to_end_tests/fec_tests.cc
+++ b/video/end_to_end_tests/fec_tests.cc
@@ -103,10 +103,11 @@
       // Use VP8 instead of FAKE, since the latter does not have PictureID
       // in the packetization headers.
       send_config->encoder_settings.encoder = encoder_.get();
-      send_config->encoder_settings.payload_name = "VP8";
-      send_config->encoder_settings.payload_type = kVideoSendPayloadType;
+      send_config->rtp.payload_name = "VP8";
+      send_config->rtp.payload_type = kVideoSendPayloadType;
+      encoder_config->codec_type = kVideoCodecVP8;
       VideoReceiveStream::Decoder decoder =
-          test::CreateMatchingDecoder(send_config->encoder_settings);
+          test::CreateMatchingDecoder(*send_config);
       decoder_.reset(decoder.decoder);
       (*receive_configs)[0].decoders.clear();
       (*receive_configs)[0].decoders.push_back(decoder);
@@ -452,8 +453,9 @@
       send_config->rtp.ulpfec.ulpfec_payload_type = kUlpfecPayloadType;
       // Set codec to VP8, otherwise NACK/FEC hybrid will be disabled.
       send_config->encoder_settings.encoder = encoder_.get();
-      send_config->encoder_settings.payload_name = "VP8";
-      send_config->encoder_settings.payload_type = kFakeVideoSendPayloadType;
+      send_config->rtp.payload_name = "VP8";
+      send_config->rtp.payload_type = kFakeVideoSendPayloadType;
+      encoder_config->codec_type = kVideoCodecVP8;
 
       (*receive_configs)[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
       (*receive_configs)[0].rtp.red_payload_type = kRedPayloadType;
@@ -461,9 +463,9 @@
 
       (*receive_configs)[0].decoders.resize(1);
       (*receive_configs)[0].decoders[0].payload_type =
-          send_config->encoder_settings.payload_type;
+          send_config->rtp.payload_type;
       (*receive_configs)[0].decoders[0].payload_name =
-          send_config->encoder_settings.payload_name;
+          send_config->rtp.payload_name;
       (*receive_configs)[0].decoders[0].decoder = decoder_.get();
     }
 
diff --git a/video/end_to_end_tests/histogram_tests.cc b/video/end_to_end_tests/histogram_tests.cc
index 2204e5e..decbb77 100644
--- a/video/end_to_end_tests/histogram_tests.cc
+++ b/video/end_to_end_tests/histogram_tests.cc
@@ -89,7 +89,8 @@
         send_config->rtp.ulpfec.ulpfec_payload_type = kUlpfecPayloadType;
         send_config->rtp.ulpfec.red_payload_type = kRedPayloadType;
         send_config->encoder_settings.encoder = vp8_encoder_.get();
-        send_config->encoder_settings.payload_name = "VP8";
+        send_config->rtp.payload_name = "VP8";
+        encoder_config->codec_type = kVideoCodecVP8;
         (*receive_configs)[0].decoders[0].payload_name = "VP8";
         (*receive_configs)[0].rtp.red_payload_type = kRedPayloadType;
         (*receive_configs)[0].rtp.ulpfec_payload_type = kUlpfecPayloadType;
diff --git a/video/end_to_end_tests/log_tests.cc b/video/end_to_end_tests/log_tests.cc
index c04a401..2695667 100644
--- a/video/end_to_end_tests/log_tests.cc
+++ b/video/end_to_end_tests/log_tests.cc
@@ -77,14 +77,15 @@
       decoder_ = VP8Decoder::Create();
 
       send_config->post_encode_callback = this;
-      send_config->encoder_settings.payload_name = "VP8";
+      send_config->rtp.payload_name = "VP8";
       send_config->encoder_settings.encoder = encoder_.get();
+      encoder_config->codec_type = kVideoCodecVP8;
 
       (*receive_configs)[0].decoders.resize(1);
       (*receive_configs)[0].decoders[0].payload_type =
-          send_config->encoder_settings.payload_type;
+          send_config->rtp.payload_type;
       (*receive_configs)[0].decoders[0].payload_name =
-          send_config->encoder_settings.payload_name;
+          send_config->rtp.payload_name;
       (*receive_configs)[0].decoders[0].decoder = decoder_.get();
     }
 
diff --git a/video/end_to_end_tests/multi_stream_tester.cc b/video/end_to_end_tests/multi_stream_tester.cc
index 87f0ea2..2d501c1 100644
--- a/video/end_to_end_tests/multi_stream_tester.cc
+++ b/video/end_to_end_tests/multi_stream_tester.cc
@@ -72,10 +72,10 @@
       VideoSendStream::Config send_config(sender_transport.get());
       send_config.rtp.ssrcs.push_back(ssrc);
       send_config.encoder_settings.encoder = encoders[i].get();
-      send_config.encoder_settings.payload_name = "VP8";
-      send_config.encoder_settings.payload_type = kVideoPayloadType;
+      send_config.rtp.payload_name = "VP8";
+      send_config.rtp.payload_type = kVideoPayloadType;
       VideoEncoderConfig encoder_config;
-      test::FillEncoderConfiguration(1, &encoder_config);
+      test::FillEncoderConfiguration(kVideoCodecVP8, 1, &encoder_config);
       encoder_config.max_bitrate_bps = 100000;
 
       UpdateSendConfig(i, &send_config, &encoder_config, &frame_generators[i]);
@@ -88,7 +88,7 @@
       receive_config.rtp.remote_ssrc = ssrc;
       receive_config.rtp.local_ssrc = test::CallTest::kReceiverLocalVideoSsrc;
       VideoReceiveStream::Decoder decoder =
-          test::CreateMatchingDecoder(send_config.encoder_settings);
+          test::CreateMatchingDecoder(send_config);
       allocated_decoders.push_back(
           std::unique_ptr<VideoDecoder>(decoder.decoder));
       receive_config.decoders.push_back(decoder);
diff --git a/video/end_to_end_tests/retransmission_tests.cc b/video/end_to_end_tests/retransmission_tests.cc
index 0d42cda..aefb02c 100644
--- a/video/end_to_end_tests/retransmission_tests.cc
+++ b/video/end_to_end_tests/retransmission_tests.cc
@@ -438,7 +438,8 @@
       // doesn't support FEC with NACK.
       RTC_DCHECK_EQ(1, (*receive_configs)[0].decoders.size());
       send_config->encoder_settings.encoder = encoder_.get();
-      send_config->encoder_settings.payload_name = "VP8";
+      send_config->rtp.payload_name = "VP8";
+      encoder_config->codec_type = kVideoCodecVP8;
       (*receive_configs)[0].decoders[0].payload_name = "VP8";
     }
 
diff --git a/video/end_to_end_tests/rtp_rtcp_tests.cc b/video/end_to_end_tests/rtp_rtcp_tests.cc
index 8fd861e..c12b988 100644
--- a/video/end_to_end_tests/rtp_rtcp_tests.cc
+++ b/video/end_to_end_tests/rtp_rtcp_tests.cc
@@ -496,11 +496,12 @@
                      send_transport.get());
     encoder = VP8Encoder::Create();
     video_send_config_.encoder_settings.encoder = encoder.get();
-    video_send_config_.encoder_settings.payload_name = "VP8";
-    video_send_config_.encoder_settings.payload_type = kVideoSendPayloadType;
+    video_send_config_.rtp.payload_name = "VP8";
+    video_send_config_.rtp.payload_type = kVideoSendPayloadType;
     video_send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
     video_send_config_.rtp.rtx.ssrcs.push_back(kSendRtxSsrcs[0]);
     video_send_config_.rtp.rtx.payload_type = kSendRtxPayloadType;
+    video_encoder_config_.codec_type = kVideoCodecVP8;
 
     CreateMatchingReceiveConfigs(receive_transport.get());
     video_receive_configs_[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
diff --git a/video/picture_id_tests.cc b/video/picture_id_tests.cc
index 9a43efe..ff62ddc 100644
--- a/video/picture_id_tests.cc
+++ b/video/picture_id_tests.cc
@@ -308,7 +308,8 @@
 
     CreateSendConfig(kNumSimulcastStreams, 0, 0, send_transport_.get());
     video_send_config_.encoder_settings.encoder = encoder;
-    video_send_config_.encoder_settings.payload_name = payload_name;
+    video_send_config_.rtp.payload_name = payload_name;
+    video_encoder_config_.codec_type = PayloadStringToCodecType(payload_name);
     video_encoder_config_.video_stream_factory =
         new rtc::RefCountedObject<VideoStreamFactory>(num_temporal_layers_);
     video_encoder_config_.number_of_streams = 1;
diff --git a/video/replay.cc b/video/replay.cc
index a79c3f9..88a5c58 100644
--- a/video/replay.cc
+++ b/video/replay.cc
@@ -247,9 +247,6 @@
   }
   receive_config.renderer = &file_passthrough;
 
-  VideoSendStream::Config::EncoderSettings encoder_settings;
-  encoder_settings.payload_name = flags::Codec();
-  encoder_settings.payload_type = flags::MediaPayloadType();
   VideoReceiveStream::Decoder decoder;
   std::unique_ptr<DecoderBitstreamFileWriter> bitstream_writer;
   if (!flags::DecoderBitstreamFilename().empty()) {
@@ -257,7 +254,8 @@
         flags::DecoderBitstreamFilename().c_str()));
     receive_config.pre_decode_callback = bitstream_writer.get();
   }
-  decoder = test::CreateMatchingDecoder(encoder_settings);
+  decoder = test::CreateMatchingDecoder(flags::MediaPayloadType(),
+                                        flags::Codec());
   if (!flags::DecoderBitstreamFilename().empty()) {
     // Replace with a null decoder if we're writing the bitstream to a file
     // instead.
diff --git a/video/send_statistics_proxy.cc b/video/send_statistics_proxy.cc
index 097ae60..6edbe54 100644
--- a/video/send_statistics_proxy.cc
+++ b/video/send_statistics_proxy.cc
@@ -126,11 +126,7 @@
     const VideoSendStream::Config& config,
     VideoEncoderConfig::ContentType content_type)
     : clock_(clock),
-      // TODO(nisse): This is a transition hack; encoder_settings.payload_name
-      // is soon to be deleted.
-      payload_name_(!config.rtp.payload_name.empty()
-                        ? config.rtp.payload_name
-                        : config.encoder_settings.payload_name),
+      payload_name_(config.rtp.payload_name),
       rtp_config_(config.rtp),
       fallback_max_pixels_(GetFallbackMaxPixelsIfFieldTrialEnabled()),
       fallback_max_pixels_disabled_(GetFallbackMaxPixelsIfFieldTrialDisabled()),
diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc
index b638175..6107266 100644
--- a/video/video_quality_test.cc
+++ b/video/video_quality_test.cc
@@ -1264,6 +1264,8 @@
   if (params->ss[video_idx].streams.empty() &&
       params->ss[video_idx].infer_streams) {
     webrtc::VideoEncoderConfig encoder_config;
+    encoder_config.codec_type =
+        PayloadStringToCodecType(params->video[video_idx].codec);
     encoder_config.content_type =
         params->screenshare[video_idx].enabled
             ? webrtc::VideoEncoderConfig::ContentType::kScreen
@@ -1397,9 +1399,9 @@
     }
     video_send_configs_[video_idx].encoder_settings.encoder =
         video_encoders_[video_idx].get();
-    video_send_configs_[video_idx].encoder_settings.payload_name =
+    video_send_configs_[video_idx].rtp.payload_name =
         params_.video[video_idx].codec;
-    video_send_configs_[video_idx].encoder_settings.payload_type = payload_type;
+    video_send_configs_[video_idx].rtp.payload_type = payload_type;
     video_send_configs_[video_idx].rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
     video_send_configs_[video_idx].rtp.rtx.payload_type = kSendRtxPayloadType;
     for (size_t i = 0; i < num_video_substreams; ++i) {
@@ -1421,6 +1423,9 @@
     video_send_configs_[video_idx].rtp.extensions.push_back(RtpExtension(
         RtpExtension::kVideoTimingUri, test::kVideoTimingExtensionId));
 
+    video_encoder_configs_[video_idx].codec_type =
+        PayloadStringToCodecType(params_.video[video_idx].codec);
+
     video_encoder_configs_[video_idx].min_transmit_bitrate_bps =
         params_.video[video_idx].min_transmit_bps;
 
@@ -1474,10 +1479,8 @@
           i != params_.ss[video_idx].selected_stream) {
         VideoReceiveStream::Decoder decoder;
         decoder.decoder = new test::FakeDecoder();
-        decoder.payload_type =
-            video_send_configs_[video_idx].encoder_settings.payload_type;
-        decoder.payload_name =
-            video_send_configs_[video_idx].encoder_settings.payload_name;
+        decoder.payload_type = video_send_configs_[video_idx].rtp.payload_type;
+        decoder.payload_name = video_send_configs_[video_idx].rtp.payload_name;
         new_receive_configs[i].decoders.clear();
         allocated_decoders_.emplace_back(decoder.decoder);
         new_receive_configs[i].decoders.push_back(decoder);
@@ -1612,9 +1615,8 @@
     thumbnail_send_config.rtp.ssrcs.push_back(kThumbnailSendSsrcStart + i);
     thumbnail_send_config.encoder_settings.encoder =
         thumbnail_encoders_.back().get();
-    thumbnail_send_config.encoder_settings.payload_name =
-        params_.video[0].codec;
-    thumbnail_send_config.encoder_settings.payload_type = kPayloadTypeVP8;
+    thumbnail_send_config.rtp.payload_name = params_.video[0].codec;
+    thumbnail_send_config.rtp.payload_type = kPayloadTypeVP8;
     thumbnail_send_config.rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
     thumbnail_send_config.rtp.rtx.payload_type = kSendRtxPayloadType;
     thumbnail_send_config.rtp.rtx.ssrcs.push_back(kThumbnailRtxSsrcStart + i);
@@ -1629,6 +1631,7 @@
     }
 
     VideoEncoderConfig thumbnail_encoder_config;
+    thumbnail_encoder_config.codec_type = kVideoCodecVP8;
     thumbnail_encoder_config.min_transmit_bitrate_bps = 7500;
     thumbnail_send_config.suspend_below_min_bitrate =
         params_.video[0].suspend_below_min_bitrate;
@@ -1655,7 +1658,7 @@
     thumbnail_receive_config.renderer = &fake_renderer_;
 
     VideoReceiveStream::Decoder decoder =
-        test::CreateMatchingDecoder(thumbnail_send_config.encoder_settings);
+        test::CreateMatchingDecoder(thumbnail_send_config);
     allocated_decoders_.push_back(
         std::unique_ptr<VideoDecoder>(decoder.decoder));
     thumbnail_receive_config.decoders.clear();
diff --git a/video/video_send_stream.cc b/video/video_send_stream.cc
index 9ef1942..cf36683b 100644
--- a/video/video_send_stream.cc
+++ b/video/video_send_stream.cc
@@ -401,11 +401,6 @@
 
   SendStatisticsProxy* const stats_proxy_;
   const VideoSendStream::Config* const config_;
-  // TODO(nisse): Transition hack, to support either
-  // config.rtp.payload_* or config_.encoder_settings.payload_*.
-  std::string payload_name_;
-  int payload_type_;
-
   std::map<uint32_t, RtpState> suspended_ssrcs_;
 
   std::unique_ptr<FecController> fec_controller_;
@@ -704,12 +699,6 @@
           webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")),
       stats_proxy_(stats_proxy),
       config_(config),
-      payload_name_(!config_->rtp.payload_name.empty()
-                        ? config_->rtp.payload_name.c_str()
-                        : config_->encoder_settings.payload_name.c_str()),
-      payload_type_(config_->rtp.payload_type != -1
-                        ? config_->rtp.payload_type
-                        : config_->encoder_settings.payload_type),
       suspended_ssrcs_(std::move(suspended_ssrcs)),
       fec_controller_(std::move(fec_controller)),
       module_process_thread_(nullptr),
@@ -743,9 +732,7 @@
                                              transport->keepalive_config())),
       payload_router_(rtp_rtcp_modules_,
                       config_->rtp.ssrcs,
-                      config_->rtp.payload_type != -1
-                          ? config_->rtp.payload_type
-                          : config_->encoder_settings.payload_type,
+                      config_->rtp.payload_type,
                       suspended_payload_states),
       weak_ptr_factory_(this),
       overhead_bytes_per_packet_(0),
@@ -847,7 +834,8 @@
     rtp_rtcp->RegisterRtcpStatisticsCallback(stats_proxy_);
     rtp_rtcp->RegisterSendChannelRtpStatisticsCallback(stats_proxy_);
     rtp_rtcp->SetMaxRtpPacketSize(config_->rtp.max_packet_size);
-    rtp_rtcp->RegisterVideoSendPayload(payload_type_, payload_name_.c_str());
+    rtp_rtcp->RegisterVideoSendPayload(config_->rtp.payload_type,
+                                       config_->rtp.payload_name.c_str());
   }
 
   fec_controller_->SetProtectionCallback(this);
@@ -857,8 +845,8 @@
   }
 
   RTC_DCHECK(config_->encoder_settings.encoder);
-  RTC_DCHECK_GE(payload_type_, 0);
-  RTC_DCHECK_LE(payload_type_, 127);
+  RTC_DCHECK_GE(config_->rtp.payload_type, 0);
+  RTC_DCHECK_LE(config_->rtp.payload_type, 127);
 
   video_stream_encoder_->SetStartBitrate(
       bitrate_allocator_->GetStartBitrate(this));
@@ -1151,7 +1139,7 @@
   // is a waste of bandwidth since FEC packets still have to be transmitted.
   // Note that this is not the case with FlexFEC.
   if (nack_enabled && IsUlpfecEnabled() &&
-      !PayloadTypeSupportsSkippingFecPackets(payload_name_)) {
+      !PayloadTypeSupportsSkippingFecPackets(config_->rtp.payload_name)) {
     RTC_LOG(LS_WARNING)
         << "Transmitting payload type without picture ID using "
            "NACK+ULPFEC is a waste of bandwidth since ULPFEC packets "
@@ -1229,7 +1217,7 @@
   RTC_DCHECK_GE(config_->rtp.rtx.payload_type, 0);
   for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
     rtp_rtcp->SetRtxSendPayloadType(config_->rtp.rtx.payload_type,
-                                    payload_type_);
+                                    config_->rtp.payload_type);
     rtp_rtcp->SetRtxSendStatus(kRtxRetransmitted | kRtxRedundantPayloads);
   }
   if (config_->rtp.ulpfec.red_payload_type != -1 &&
diff --git a/video/video_send_stream_tests.cc b/video/video_send_stream_tests.cc
index 1fe4bec..9985b85 100644
--- a/video/video_send_stream_tests.cc
+++ b/video/video_send_stream_tests.cc
@@ -532,7 +532,7 @@
               VideoSendStreamTest::kNackRtpHistoryMs;
     }
     send_config->encoder_settings.encoder = encoder_;
-    send_config->encoder_settings.payload_name = payload_name_;
+    send_config->rtp.payload_name = payload_name_;
     send_config->rtp.ulpfec.red_payload_type =
         VideoSendStreamTest::kRedPayloadType;
     send_config->rtp.ulpfec.ulpfec_payload_type =
@@ -544,6 +544,7 @@
       send_config->rtp.extensions.push_back(RtpExtension(
           RtpExtension::kAbsSendTimeUri, test::kAbsSendTimeExtensionId));
     }
+    encoder_config->codec_type = PayloadStringToCodecType(payload_name_);
     (*receive_configs)[0].rtp.red_payload_type =
         send_config->rtp.ulpfec.red_payload_type;
     (*receive_configs)[0].rtp.ulpfec_payload_type =
@@ -709,7 +710,7 @@
               VideoSendStreamTest::kNackRtpHistoryMs;
     }
     send_config->encoder_settings.encoder = encoder_;
-    send_config->encoder_settings.payload_name = payload_name_;
+    send_config->rtp.payload_name = payload_name_;
     if (header_extensions_enabled_) {
       send_config->rtp.extensions.push_back(RtpExtension(
           RtpExtension::kAbsSendTimeUri, test::kAbsSendTimeExtensionId));
@@ -718,6 +719,7 @@
     } else {
       send_config->rtp.extensions.clear();
     }
+    encoder_config->codec_type = PayloadStringToCodecType(payload_name_);
   }
 
   void PerformTest() override {
@@ -1073,7 +1075,7 @@
       }
 
       if (!test_generic_packetization_)
-        send_config->encoder_settings.payload_name = "VP8";
+        send_config->rtp.payload_name = "VP8";
 
       send_config->encoder_settings.encoder = &encoder_;
       send_config->rtp.max_packet_size = kMaxPacketSize;
@@ -2117,7 +2119,7 @@
 
     video_send_config_.encoder_settings.encoder = &encoder;
     video_send_config_.encoder_settings.internal_source = true;
-    video_send_config_.encoder_settings.payload_name = "VP8";
+    video_send_config_.rtp.payload_name = "VP8";
 
     CreateVideoStreams();
   });
@@ -2491,8 +2493,9 @@
       std::vector<VideoReceiveStream::Config>* receive_configs,
       VideoEncoderConfig* encoder_config) override {
     send_config->encoder_settings.encoder = this;
-    send_config->encoder_settings.payload_name = codec_name_;
+    send_config->rtp.payload_name = codec_name_;
 
+    encoder_config->codec_type = video_codec_type_;
     encoder_config->encoder_specific_settings = GetEncoderSpecificSettings();
     encoder_config->video_stream_factory =
         new rtc::RefCountedObject<VideoStreamFactory>();
@@ -3082,8 +3085,8 @@
       std::vector<VideoReceiveStream::Config>* receive_configs,
       VideoEncoderConfig* encoder_config) override {
     send_config->encoder_settings.encoder = vp9_encoder_.get();
-    send_config->encoder_settings.payload_name = "VP9";
-    send_config->encoder_settings.payload_type = kVp9PayloadType;
+    send_config->rtp.payload_name = "VP9";
+    send_config->rtp.payload_type = kVp9PayloadType;
     ModifyVideoConfigsHook(send_config, receive_configs, encoder_config);
     encoder_config->encoder_specific_settings = new rtc::RefCountedObject<
       VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings_);
@@ -3484,6 +3487,7 @@
         VideoSendStream::Config* send_config,
         std::vector<VideoReceiveStream::Config>* receive_configs,
         VideoEncoderConfig* encoder_config) override {
+      encoder_config->codec_type = kVideoCodecVP9;
       vp9_settings_.flexibleMode = false;
       vp9_settings_.numberOfTemporalLayers = 1;
       vp9_settings_.numberOfSpatialLayers = 1;
@@ -3521,6 +3525,7 @@
         VideoSendStream::Config* send_config,
         std::vector<VideoReceiveStream::Config>* receive_configs,
         VideoEncoderConfig* encoder_config) override {
+      encoder_config->codec_type = kVideoCodecVP9;
       encoder_config->content_type = VideoEncoderConfig::ContentType::kScreen;
       vp9_settings_.flexibleMode = true;
       vp9_settings_.numberOfTemporalLayers = 1;
diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc
index f5f0ca5..b598713b 100644
--- a/video/video_stream_encoder.cc
+++ b/video/video_stream_encoder.cc
@@ -552,9 +552,8 @@
   crop_height_ = last_frame_info_->height - highest_stream_height;
 
   VideoCodec codec;
-  if (!VideoCodecInitializer::SetupCodec(encoder_config_, settings_, streams,
-                                         nack_enabled_, &codec,
-                                         &rate_allocator_)) {
+  if (!VideoCodecInitializer::SetupCodec(
+          encoder_config_, streams, nack_enabled_, &codec, &rate_allocator_)) {
     RTC_LOG(LS_ERROR) << "Failed to create encoder configuration.";
   }
 
diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc
index 8ef06a3..b42d8e7 100644
--- a/video/video_stream_encoder_unittest.cc
+++ b/video/video_stream_encoder_unittest.cc
@@ -285,11 +285,11 @@
     metrics::Reset();
     video_send_config_ = VideoSendStream::Config(nullptr);
     video_send_config_.encoder_settings.encoder = &fake_encoder_;
-    video_send_config_.encoder_settings.payload_name = "FAKE";
-    video_send_config_.encoder_settings.payload_type = 125;
+    video_send_config_.rtp.payload_name = "FAKE";
+    video_send_config_.rtp.payload_type = 125;
 
     VideoEncoderConfig video_encoder_config;
-    test::FillEncoderConfiguration(1, &video_encoder_config);
+    test::FillEncoderConfiguration(kVideoCodecVP8, 1, &video_encoder_config);
     video_encoder_config.video_stream_factory =
         new rtc::RefCountedObject<VideoStreamFactory>(1, max_framerate_);
     video_encoder_config_ = video_encoder_config.Copy();
@@ -326,9 +326,10 @@
                     unsigned char num_spatial_layers,
                     bool nack_enabled,
                     bool screenshare) {
-    video_send_config_.encoder_settings.payload_name = payload_name;
+    video_send_config_.rtp.payload_name = payload_name;
 
     VideoEncoderConfig video_encoder_config;
+    video_encoder_config.codec_type = PayloadStringToCodecType(payload_name);
     video_encoder_config.number_of_streams = num_streams;
     video_encoder_config.max_bitrate_bps = kTargetBitrateBps;
     video_encoder_config.video_stream_factory =
@@ -784,7 +785,7 @@
   EXPECT_EQ(1, sink_.number_of_reconfigurations());
 
   VideoEncoderConfig video_encoder_config;
-  test::FillEncoderConfiguration(1, &video_encoder_config);
+  test::FillEncoderConfiguration(kVideoCodecVP8, 1, &video_encoder_config);
   video_encoder_config.min_transmit_bitrate_bps = 9999;
   video_stream_encoder_->ConfigureEncoder(std::move(video_encoder_config),
                                           kMaxPayloadLength,
@@ -2283,6 +2284,7 @@
 
   // Trigger reconfigure encoder (without resetting the entire instance).
   VideoEncoderConfig video_encoder_config;
+  video_encoder_config.codec_type = kVideoCodecVP8;
   video_encoder_config.max_bitrate_bps = kTargetBitrateBps;
   video_encoder_config.number_of_streams = 1;
   video_encoder_config.video_stream_factory =
@@ -2334,6 +2336,7 @@
 
   // Trigger initial configuration.
   VideoEncoderConfig video_encoder_config;
+  video_encoder_config.codec_type = kVideoCodecVP8;
   video_encoder_config.max_bitrate_bps = kTargetBitrateBps;
   video_encoder_config.number_of_streams = 1;
   video_encoder_config.video_stream_factory =
@@ -2396,6 +2399,7 @@
 
   // Trigger initial configuration.
   VideoEncoderConfig video_encoder_config;
+  video_encoder_config.codec_type = kVideoCodecVP8;
   video_encoder_config.max_bitrate_bps = kTargetBitrateBps;
   video_encoder_config.number_of_streams = 1;
   video_encoder_config.video_stream_factory =
@@ -3189,6 +3193,7 @@
   video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
   // Trigger reconfigure encoder (without resetting the entire instance).
   VideoEncoderConfig video_encoder_config;
+  video_encoder_config.codec_type = kVideoCodecVP8;
   video_encoder_config.max_bitrate_bps = kTargetBitrateBps;
   video_encoder_config.number_of_streams = 1;
   video_encoder_config.video_stream_factory =