Use default values for video and audio streams generation in PC E2E framework

Bug: webrtc:10138
Change-Id: I91591690f4f2202c32f211a492e96f1aa7844473
Reviewed-on: https://webrtc-review.googlesource.com/c/124986
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26908}
diff --git a/test/pc/e2e/api/peerconnection_quality_test_fixture.h b/test/pc/e2e/api/peerconnection_quality_test_fixture.h
index 705c940..0075562 100644
--- a/test/pc/e2e/api/peerconnection_quality_test_fixture.h
+++ b/test/pc/e2e/api/peerconnection_quality_test_fixture.h
@@ -121,8 +121,10 @@
     // Have to be unique among all specified configs for all peers in the call.
     // Will be auto generated if omitted.
     absl::optional<std::string> stream_label;
-    // Only single from 3 next fields can be specified.
-    // If specified generator with this name will be used as input.
+    // Only 1 from |generator|, |input_file_name| and |screen_share_config| can
+    // be specified. If none of them are specified, then |generator| will be set
+    // to VideoGeneratorType::kDefault.
+    // If specified generator of this type will be used to produce input video.
     absl::optional<VideoGeneratorType> generator;
     // If specified this file will be used as input. Input video will be played
     // in a circle.
@@ -163,7 +165,7 @@
     // Have to be unique among all specified configs for all peers in the call.
     // Will be auto generated if omitted.
     absl::optional<std::string> stream_label;
-    Mode mode;
+    Mode mode = kGenerated;
     // Have to be specified only if mode = kFile
     absl::optional<std::string> input_file_name;
     // If specified the input stream will be also copied to specified file.
diff --git a/test/pc/e2e/peer_connection_e2e_smoke_test.cc b/test/pc/e2e/peer_connection_e2e_smoke_test.cc
index 129f0c34..b38ea53 100644
--- a/test/pc/e2e/peer_connection_e2e_smoke_test.cc
+++ b/test/pc/e2e/peer_connection_e2e_smoke_test.cc
@@ -53,8 +53,6 @@
 TEST(PeerConnectionE2EQualityTestSmokeTest, RunWithEmulatedNetwork) {
   using Params = PeerConnectionE2EQualityTestFixture::Params;
   using RunParams = PeerConnectionE2EQualityTestFixture::RunParams;
-  using VideoGeneratorType =
-      PeerConnectionE2EQualityTestFixture::VideoGeneratorType;
   using VideoConfig = PeerConnectionE2EQualityTestFixture::VideoConfig;
   using AudioConfig = PeerConnectionE2EQualityTestFixture::AudioConfig;
   using InjectableComponents =
@@ -63,22 +61,16 @@
   auto alice_params = absl::make_unique<Params>();
   VideoConfig alice_video_config(1280, 720, 30);
   alice_video_config.stream_label = "alice-video";
-  alice_video_config.generator = VideoGeneratorType::kDefault;
 
   alice_params->video_configs.push_back(alice_video_config);
   alice_params->audio_config = AudioConfig();
-  alice_params->audio_config->mode = AudioConfig::Mode::kGenerated,
-  alice_params->audio_config->audio_options = cricket::AudioOptions();
 
   auto bob_params = absl::make_unique<Params>();
   VideoConfig bob_video_config(1280, 720, 30);
   bob_video_config.stream_label = "bob-video";
-  bob_video_config.generator = VideoGeneratorType::kDefault;
 
   bob_params->video_configs.push_back(bob_video_config);
   bob_params->audio_config = AudioConfig();
-  bob_params->audio_config->mode = AudioConfig::Mode::kGenerated,
-  bob_params->audio_config->audio_options = cricket::AudioOptions();
 
   // Setup emulated network
   NetworkEmulationManager network_emulation_manager;
diff --git a/test/pc/e2e/peer_connection_quality_test.cc b/test/pc/e2e/peer_connection_quality_test.cc
index 5382ac6..c9862d7 100644
--- a/test/pc/e2e/peer_connection_quality_test.cc
+++ b/test/pc/e2e/peer_connection_quality_test.cc
@@ -133,7 +133,7 @@
   RTC_CHECK(bob_components);
   RTC_CHECK(bob_params);
 
-  SetMissedVideoStreamLabels({alice_params.get(), bob_params.get()});
+  SetDefaultValuesForMissingParams({alice_params.get(), bob_params.get()});
   ValidateParams({alice_params.get(), bob_params.get()});
 
   // Print test summary
@@ -264,7 +264,7 @@
   RTC_CHECK(video_writers_.empty());
 }
 
-void PeerConnectionE2EQualityTest::SetMissedVideoStreamLabels(
+void PeerConnectionE2EQualityTest::SetDefaultValuesForMissingParams(
     std::vector<Params*> params) {
   int video_counter = 0;
   int audio_counter = 0;
@@ -272,6 +272,10 @@
   std::set<std::string> audio_labels;
   for (auto* p : params) {
     for (auto& video_config : p->video_configs) {
+      if (!video_config.generator && !video_config.input_file_name &&
+          !video_config.screen_share_config) {
+        video_config.generator = VideoGeneratorType::kDefault;
+      }
       if (!video_config.stream_label) {
         std::string label;
         do {
diff --git a/test/pc/e2e/peer_connection_quality_test.h b/test/pc/e2e/peer_connection_quality_test.h
index 1f635f2..16d4019 100644
--- a/test/pc/e2e/peer_connection_quality_test.h
+++ b/test/pc/e2e/peer_connection_quality_test.h
@@ -55,9 +55,11 @@
            RunParams run_params) override;
 
  private:
-  // Sets video stream labels that are not specified in VideoConfigs to unique
-  // generated values.
-  void SetMissedVideoStreamLabels(std::vector<Params*> params);
+  // Set missing params to default values if it is required:
+  //  * Generate video stream labels if some of them missed
+  //  * Generate audio stream labels if some of them missed
+  //  * Set video source generation mode if it is not specified
+  void SetDefaultValuesForMissingParams(std::vector<Params*> params);
   // Validate peer's parameters, also ensure uniqueness of all video stream
   // labels.
   void ValidateParams(std::vector<Params*> params);