Releand of Let ViEEncoder handle resolution changes.

The original landed cl is in patchset 1.
The following patchset fix VideoQualityTest as well as fix the case where max_bitrate is set in the SendParams. A unit test is added for that as well.

Original cl description:
Let ViEEncoder handle resolution changes.

This cl move codec reconfiguration due to video frame size changes from WebRtcVideoSendStream to ViEEncoder.

With this change, many variables in WebRtcVideoSendStream no longer need to be locked.

BUG=webrtc:5687, webrtc:6371, webrtc:5332

Review-Url: https://codereview.webrtc.org/2386573002
Cr-Commit-Position: refs/heads/master@{#14467}
diff --git a/webrtc/test/encoder_settings.h b/webrtc/test/encoder_settings.h
index a44d366..82d8c5f 100644
--- a/webrtc/test/encoder_settings.h
+++ b/webrtc/test/encoder_settings.h
@@ -10,12 +10,43 @@
 #ifndef WEBRTC_TEST_ENCODER_SETTINGS_H_
 #define WEBRTC_TEST_ENCODER_SETTINGS_H_
 
+#include <vector>
+
 #include "webrtc/video_receive_stream.h"
 #include "webrtc/video_send_stream.h"
 
 namespace webrtc {
 namespace test {
-std::vector<VideoStream> CreateVideoStreams(size_t num_streams);
+
+class DefaultVideoStreamFactory
+    : public VideoEncoderConfig::VideoStreamFactoryInterface {
+ public:
+  DefaultVideoStreamFactory();
+
+  static const size_t kMaxNumberOfStreams = 3;
+  // Defined as {150000, 450000, 1500000};
+  static const int kMaxBitratePerStream[];
+  // Defined as {50000, 200000, 700000};
+  static const int kDefaultMinBitratePerStream[];
+
+ private:
+  std::vector<VideoStream> CreateEncoderStreams(
+      int width,
+      int height,
+      const VideoEncoderConfig& encoder_config) override;
+};
+
+// Creates |encoder_config.number_of_streams| VideoStreams where index
+// |encoder_config.number_of_streams -1| have width = |width|, height =
+// |height|. The total max bitrate of all VideoStreams is
+// |encoder_config.max_bitrate_bps|.
+std::vector<VideoStream> CreateVideoStreams(
+    int width,
+    int height,
+    const webrtc::VideoEncoderConfig& encoder_config);
+
+void FillEncoderConfiguration(size_t num_streams,
+                              VideoEncoderConfig* configuration);
 
 VideoReceiveStream::Decoder CreateMatchingDecoder(
     const VideoSendStream::Config::EncoderSettings& encoder_settings);