Propagate multicodec support to other places of PC level framework

Bug: webrtc:10138
Change-Id: I9258db991053abfa40f2a5112eddfa7f3e0d41a1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167062
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30346}
diff --git a/test/pc/e2e/peer_connection_quality_test.cc b/test/pc/e2e/peer_connection_quality_test.cc
index 595060d..e5667e6 100644
--- a/test/pc/e2e/peer_connection_quality_test.cc
+++ b/test/pc/e2e/peer_connection_quality_test.cc
@@ -510,6 +510,7 @@
   std::set<std::string> audio_labels;
   int media_streams_count = 0;
 
+  bool has_simulcast = false;
   for (size_t i = 0; i < params.size(); ++i) {
     Params* p = params[i];
     if (p->audio_config) {
@@ -574,6 +575,7 @@
         }
       }
       if (video_config.simulcast_config) {
+        has_simulcast = true;
         // We support simulcast only from caller.
         RTC_CHECK_EQ(i, 0)
             << "Only simulcast stream from first peer is supported";
@@ -601,6 +603,11 @@
       }
     }
   }
+  if (has_simulcast) {
+    RTC_CHECK_EQ(run_params.video_codecs.size(), 1)
+        << "Only 1 video codec is supported when simulcast is enabled in at "
+        << "least 1 video config";
+  }
 
   RTC_CHECK_GT(media_streams_count, 0) << "No media in the call.";
 }
@@ -673,7 +680,8 @@
     RtpTransceiverInit transceiver_params;
     if (video_config.simulcast_config) {
       transceiver_params.direction = RtpTransceiverDirection::kSendOnly;
-      if (run_params.video_codec_name == cricket::kVp8CodecName) {
+      // Because simulcast enabled |run_params.video_codecs| has only 1 element.
+      if (run_params.video_codecs[0].name == cricket::kVp8CodecName) {
         // For Vp8 simulcast we need to add as many RtpEncodingParameters to the
         // track as many simulcast streams requested.
         for (int i = 0;
@@ -937,7 +945,7 @@
            video_config.simulcast_config->simulcast_streams_count});
     }
   }
-  PatchingParams patching_params(run_params.video_codec_name,
+  PatchingParams patching_params(run_params.video_codecs,
                                  run_params.use_conference_mode,
                                  stream_label_to_simulcast_streams_count);
   SignalingInterceptor signaling_interceptor(patching_params);
diff --git a/test/pc/e2e/sdp/sdp_changer.cc b/test/pc/e2e/sdp/sdp_changer.cc
index 5536c26..68f418e 100644
--- a/test/pc/e2e/sdp/sdp_changer.cc
+++ b/test/pc/e2e/sdp/sdp_changer.cc
@@ -165,12 +165,15 @@
     media_desc->set_conference_mode(params_.use_conference_mode);
   }
 
-  if (params_.video_codec_name == cricket::kVp8CodecName) {
-    return PatchVp8Offer(std::move(offer));
-  }
+  if (params_.stream_label_to_simulcast_streams_count.size() > 0) {
+    // Because simulcast enabled |params_.video_codecs| has only 1 element.
+    if (params_.video_codecs[0].name == cricket::kVp8CodecName) {
+      return PatchVp8Offer(std::move(offer));
+    }
 
-  if (params_.video_codec_name == cricket::kVp9CodecName) {
-    return PatchVp9Offer(std::move(offer));
+    if (params_.video_codecs[0].name == cricket::kVp9CodecName) {
+      return PatchVp9Offer(std::move(offer));
+    }
   }
 
   auto offer_for_remote = CloneSessionDescription(offer.get());
@@ -353,12 +356,15 @@
     media_desc->set_conference_mode(params_.use_conference_mode);
   }
 
-  if (params_.video_codec_name == cricket::kVp8CodecName) {
-    return PatchVp8Answer(std::move(answer));
-  }
+  if (params_.stream_label_to_simulcast_streams_count.size() > 0) {
+    // Because simulcast enabled |params_.video_codecs| has only 1 element.
+    if (params_.video_codecs[0].name == cricket::kVp8CodecName) {
+      return PatchVp8Answer(std::move(answer));
+    }
 
-  if (params_.video_codec_name == cricket::kVp9CodecName) {
-    return PatchVp9Answer(std::move(answer));
+    if (params_.video_codecs[0].name == cricket::kVp9CodecName) {
+      return PatchVp9Answer(std::move(answer));
+    }
   }
 
   auto answer_for_remote = CloneSessionDescription(answer.get());
diff --git a/test/pc/e2e/sdp/sdp_changer.h b/test/pc/e2e/sdp/sdp_changer.h
index ca3de7e..11e3d42 100644
--- a/test/pc/e2e/sdp/sdp_changer.h
+++ b/test/pc/e2e/sdp/sdp_changer.h
@@ -61,15 +61,17 @@
 
 struct PatchingParams {
   PatchingParams(
-      std::string video_codec_name,
+      std::vector<PeerConnectionE2EQualityTestFixture::VideoCodecConfig>
+          video_codecs,
       bool use_conference_mode,
       std::map<std::string, int> stream_label_to_simulcast_streams_count)
-      : video_codec_name(video_codec_name),
+      : video_codecs(std::move(video_codecs)),
         use_conference_mode(use_conference_mode),
         stream_label_to_simulcast_streams_count(
             stream_label_to_simulcast_streams_count) {}
 
-  std::string video_codec_name;
+  std::vector<PeerConnectionE2EQualityTestFixture::VideoCodecConfig>
+      video_codecs;
   bool use_conference_mode;
   std::map<std::string, int> stream_label_to_simulcast_streams_count;
 };