Implement encoder overshoot detector and rate adjuster.

The overshoot detector uses a simple pacer model to determine an
estimate of how much the encoder is overusing the target bitrate.
This utilization factor can then be adjuster for when configuring the
actual target bitrate.

Spatial layers (simulcast streams) are adjusted separately.
Temporal layers are measured separately, but are combined into a single
utilization factor per spatial layer.

Bug: webrtc:10155
Change-Id: I8ea58dc6c4871e880553d7c22202f11cb2feb216
Reviewed-on: https://webrtc-review.googlesource.com/c/114886
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26573}
diff --git a/video/BUILD.gn b/video/BUILD.gn
index 9874742..610a2fd 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -169,6 +169,10 @@
 
   # visibility = [ "../api/video:video_stream_encoder_create" ]
   sources = [
+    "encoder_bitrate_adjuster.cc",
+    "encoder_bitrate_adjuster.h",
+    "encoder_overshoot_detector.cc",
+    "encoder_overshoot_detector.h",
     "overuse_frame_detector.cc",
     "overuse_frame_detector.h",
     "partial_frame_assembler.cc",
@@ -183,7 +187,9 @@
   }
 
   deps = [
+    "../api/units:data_rate",
     "../api/video:encoded_image",
+    "../api/video:video_bitrate_allocation",
     "../api/video:video_bitrate_allocator",
     "../api/video:video_bitrate_allocator_factory",
     "../api/video:video_frame",
@@ -205,6 +211,7 @@
     "../rtc_base:sequenced_task_checker",
     "../rtc_base:timeutils",
     "../rtc_base/experiments:quality_scaling_experiment",
+    "../rtc_base/experiments:rate_control_settings",
     "../rtc_base/system:fallthrough",
     "../rtc_base/task_utils:repeating_task",
     "../system_wrappers:field_trial",
@@ -456,7 +463,9 @@
       "buffered_frame_decryptor_unittest.cc",
       "call_stats_unittest.cc",
       "cpu_scaling_tests.cc",
+      "encoder_bitrate_adjuster_unittest.cc",
       "encoder_key_frame_callback_unittest.cc",
+      "encoder_overshoot_detector_unittest.cc",
       "end_to_end_tests/bandwidth_tests.cc",
       "end_to_end_tests/call_operation_tests.cc",
       "end_to_end_tests/codec_tests.cc",
@@ -505,6 +514,7 @@
       "../api:scoped_refptr",
       "../api:simulated_network_api",
       "../api/test/video:function_video_factory",
+      "../api/units:data_rate",
       "../api/video:builtin_video_bitrate_allocator_factory",
       "../api/video:encoded_image",
       "../api/video:video_bitrate_allocation",