Move BitrateAllocator reference from ViEEncoder to VideoSendStream.

This CL will be followed up with a CL adding AudioSendStream to
BitrateAllocator, so this is a small CL to have the video connection to
BitrateAllocator "at the same level" as for audio.

BUG=webrtc:5079
R=stefan@webrtc.org

Review URL: https://codereview.webrtc.org/1785283002 .

Cr-Original-Commit-Position: refs/heads/master@{#11955}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 86aabb288d61d56955e7fa4890f46f3388f28263
diff --git a/call/bitrate_allocator.cc b/call/bitrate_allocator.cc
index 07f8306..097378f 100644
--- a/call/bitrate_allocator.cc
+++ b/call/bitrate_allocator.cc
@@ -41,7 +41,7 @@
   uint32_t allocated_bitrate_bps = 0;
   ObserverBitrateMap allocation = AllocateBitrates();
   for (const auto& kv : allocation) {
-    kv.first->OnNetworkChanged(kv.second, last_fraction_loss_, last_rtt_);
+    kv.first->OnBitrateUpdated(kv.second, last_fraction_loss_, last_rtt_);
     allocated_bitrate_bps += kv.second;
   }
   return allocated_bitrate_bps;
@@ -60,9 +60,9 @@
     return NormalRateAllocation(last_bitrate_bps_, sum_min_bitrates);
 }
 
-int BitrateAllocator::AddBitrateObserver(BitrateObserver* observer,
-                                         uint32_t min_bitrate_bps,
-                                         uint32_t max_bitrate_bps) {
+int BitrateAllocator::AddObserver(BitrateAllocatorObserver* observer,
+                                  uint32_t min_bitrate_bps,
+                                  uint32_t max_bitrate_bps) {
   rtc::CritScope lock(&crit_sect_);
 
   BitrateObserverConfList::iterator it =
@@ -87,14 +87,14 @@
   ObserverBitrateMap allocation = AllocateBitrates();
   int new_observer_bitrate_bps = 0;
   for (auto& kv : allocation) {
-    kv.first->OnNetworkChanged(kv.second, last_fraction_loss_, last_rtt_);
+    kv.first->OnBitrateUpdated(kv.second, last_fraction_loss_, last_rtt_);
     if (kv.first == observer)
       new_observer_bitrate_bps = kv.second;
   }
   return new_observer_bitrate_bps;
 }
 
-void BitrateAllocator::RemoveBitrateObserver(BitrateObserver* observer) {
+void BitrateAllocator::RemoveObserver(BitrateAllocatorObserver* observer) {
   rtc::CritScope lock(&crit_sect_);
   BitrateObserverConfList::iterator it =
       FindObserverConfigurationPair(observer);
@@ -118,7 +118,7 @@
 
 BitrateAllocator::BitrateObserverConfList::iterator
 BitrateAllocator::FindObserverConfigurationPair(
-    const BitrateObserver* observer) {
+    const BitrateAllocatorObserver* observer) {
   for (auto it = bitrate_observers_.begin(); it != bitrate_observers_.end();
        ++it) {
     if (it->first == observer)
diff --git a/call/bitrate_allocator.h b/call/bitrate_allocator.h
index 5028e12..25ca735 100644
--- a/call/bitrate_allocator.h
+++ b/call/bitrate_allocator.h
@@ -6,10 +6,6 @@
  *  tree. An additional intellectual property rights grant can be found
  *  in the file PATENTS.  All contributing project authors may
  *  be found in the AUTHORS file in the root of the source tree.
- *
- *  Usage: this class will register multiple RtcpBitrateObserver's one at each
- *  RTCP module. It will aggregate the results and run one bandwidth estimation
- *  and push the result to the encoders via BitrateObserver(s).
  */
 
 #ifndef WEBRTC_CALL_BITRATE_ALLOCATOR_H_
@@ -25,13 +21,26 @@
 
 namespace webrtc {
 
-class BitrateObserver;
+// Used by all send streams with adaptive bitrate, to get the currently
+// allocated bitrate for the send stream. The current network properties are
+// given at the same time, to let the send stream decide about possible loss
+// protection.
+class BitrateAllocatorObserver {
+ public:
+  virtual void OnBitrateUpdated(uint32_t bitrate_bps,
+                                uint8_t fraction_loss,
+                                int64_t rtt) = 0;
+  virtual ~BitrateAllocatorObserver() {}
+};
 
+// Usage: this class will register multiple RtcpBitrateObserver's one at each
+// RTCP module. It will aggregate the results and run one bandwidth estimation
+// and push the result to the encoders via BitrateAllocatorObserver(s).
 class BitrateAllocator {
  public:
   BitrateAllocator();
 
-  // Allocate target_bitrate across the registered BitrateObservers.
+  // Allocate target_bitrate across the registered BitrateAllocatorObservers.
   // Returns actual bitrate allocated (might be higher than target_bitrate if
   // for instance EnforceMinBitrate() is enabled.
   uint32_t OnNetworkChanged(uint32_t target_bitrate,
@@ -44,11 +53,11 @@
   // |min_bitrate_bps| = 0 equals no min bitrate.
   // |max_bitrate_bps| = 0 equals no max bitrate.
   // Returns bitrate allocated for the bitrate observer.
-  int AddBitrateObserver(BitrateObserver* observer,
-                         uint32_t min_bitrate_bps,
-                         uint32_t max_bitrate_bps);
+  int AddObserver(BitrateAllocatorObserver* observer,
+                  uint32_t min_bitrate_bps,
+                  uint32_t max_bitrate_bps);
 
-  void RemoveBitrateObserver(BitrateObserver* observer);
+  void RemoveObserver(BitrateAllocatorObserver* observer);
 
   void GetMinMaxBitrateSumBps(int* min_bitrate_sum_bps,
                               int* max_bitrate_sum_bps) const;
@@ -68,19 +77,20 @@
     uint32_t max_bitrate;
   };
   struct ObserverConfiguration {
-    ObserverConfiguration(BitrateObserver* observer, uint32_t bitrate)
+    ObserverConfiguration(BitrateAllocatorObserver* observer, uint32_t bitrate)
         : observer(observer), min_bitrate(bitrate) {}
-    BitrateObserver* const observer;
+    BitrateAllocatorObserver* const observer;
     uint32_t min_bitrate;
   };
-  typedef std::pair<BitrateObserver*, BitrateConfiguration>
+  typedef std::pair<BitrateAllocatorObserver*, BitrateConfiguration>
       BitrateObserverConfiguration;
   typedef std::list<BitrateObserverConfiguration> BitrateObserverConfList;
   typedef std::multimap<uint32_t, ObserverConfiguration> ObserverSortingMap;
-  typedef std::map<BitrateObserver*, int> ObserverBitrateMap;
+  typedef std::map<BitrateAllocatorObserver*, int> ObserverBitrateMap;
 
   BitrateObserverConfList::iterator FindObserverConfigurationPair(
-      const BitrateObserver* observer) EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
+      const BitrateAllocatorObserver* observer)
+      EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
   ObserverBitrateMap AllocateBitrates() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
   ObserverBitrateMap NormalRateAllocation(uint32_t bitrate,
                                           uint32_t sum_min_bitrates)
diff --git a/call/bitrate_allocator_unittest.cc b/call/bitrate_allocator_unittest.cc
index 86f75a4..fc4f170 100644
--- a/call/bitrate_allocator_unittest.cc
+++ b/call/bitrate_allocator_unittest.cc
@@ -17,12 +17,12 @@
 
 namespace webrtc {
 
-class TestBitrateObserver : public BitrateObserver {
+class TestBitrateObserver : public BitrateAllocatorObserver {
  public:
   TestBitrateObserver()
       : last_bitrate_(0), last_fraction_loss_(0), last_rtt_(0) {}
 
-  virtual void OnNetworkChanged(uint32_t bitrate,
+  virtual void OnBitrateUpdated(uint32_t bitrate,
                                 uint8_t fraction_loss,
                                 int64_t rtt) {
     last_bitrate_ = bitrate;
@@ -47,7 +47,7 @@
 TEST_F(BitrateAllocatorTest, UpdatingBitrateObserver) {
   TestBitrateObserver bitrate_observer;
   int start_bitrate =
-      allocator_->AddBitrateObserver(&bitrate_observer, 100000, 1500000);
+      allocator_->AddObserver(&bitrate_observer, 100000, 1500000);
   EXPECT_EQ(300000, start_bitrate);
   allocator_->OnNetworkChanged(200000, 0, 0);
   EXPECT_EQ(200000u, bitrate_observer.last_bitrate_);
@@ -56,12 +56,10 @@
   // bitrate for FEC/retransmissions (see todo in BitrateAllocator).
   allocator_->OnNetworkChanged(4000000, 0, 0);
   EXPECT_EQ(3000000u, bitrate_observer.last_bitrate_);
-  start_bitrate =
-      allocator_->AddBitrateObserver(&bitrate_observer, 100000, 4000000);
+  start_bitrate = allocator_->AddObserver(&bitrate_observer, 100000, 4000000);
   EXPECT_EQ(4000000, start_bitrate);
 
-  start_bitrate =
-      allocator_->AddBitrateObserver(&bitrate_observer, 100000, 1500000);
+  start_bitrate = allocator_->AddObserver(&bitrate_observer, 100000, 1500000);
   EXPECT_EQ(3000000, start_bitrate);
   EXPECT_EQ(3000000u, bitrate_observer.last_bitrate_);
   allocator_->OnNetworkChanged(1500000, 0, 0);
@@ -72,10 +70,9 @@
   TestBitrateObserver bitrate_observer_1;
   TestBitrateObserver bitrate_observer_2;
   int start_bitrate =
-      allocator_->AddBitrateObserver(&bitrate_observer_1, 100000, 300000);
+      allocator_->AddObserver(&bitrate_observer_1, 100000, 300000);
   EXPECT_EQ(300000, start_bitrate);
-  start_bitrate =
-      allocator_->AddBitrateObserver(&bitrate_observer_2, 200000, 300000);
+  start_bitrate = allocator_->AddObserver(&bitrate_observer_2, 200000, 300000);
   EXPECT_EQ(200000, start_bitrate);
 
   // Test too low start bitrate, hence lower than sum of min. Min bitrates will
@@ -116,7 +113,7 @@
 TEST_F(BitrateAllocatorTestNoEnforceMin, OneBitrateObserver) {
   TestBitrateObserver bitrate_observer_1;
   int start_bitrate =
-      allocator_->AddBitrateObserver(&bitrate_observer_1, 100000, 400000);
+      allocator_->AddObserver(&bitrate_observer_1, 100000, 400000);
   EXPECT_EQ(300000, start_bitrate);
 
   // High REMB.
@@ -127,7 +124,7 @@
   allocator_->OnNetworkChanged(10000, 0, 0);
   EXPECT_EQ(10000u, bitrate_observer_1.last_bitrate_);
 
-  allocator_->RemoveBitrateObserver(&bitrate_observer_1);
+  allocator_->RemoveObserver(&bitrate_observer_1);
 }
 
 TEST_F(BitrateAllocatorTestNoEnforceMin, ThreeBitrateObservers) {
@@ -136,16 +133,14 @@
   TestBitrateObserver bitrate_observer_3;
   // Set up the observers with min bitrates at 100000, 200000, and 300000.
   int start_bitrate =
-      allocator_->AddBitrateObserver(&bitrate_observer_1, 100000, 400000);
+      allocator_->AddObserver(&bitrate_observer_1, 100000, 400000);
   EXPECT_EQ(300000, start_bitrate);
 
-  start_bitrate =
-      allocator_->AddBitrateObserver(&bitrate_observer_2, 200000, 400000);
+  start_bitrate = allocator_->AddObserver(&bitrate_observer_2, 200000, 400000);
   EXPECT_EQ(200000, start_bitrate);
   EXPECT_EQ(100000u, bitrate_observer_1.last_bitrate_);
 
-  start_bitrate =
-      allocator_->AddBitrateObserver(&bitrate_observer_3, 300000, 400000);
+  start_bitrate = allocator_->AddObserver(&bitrate_observer_3, 300000, 400000);
   EXPECT_EQ(0, start_bitrate);
   EXPECT_EQ(100000u, bitrate_observer_1.last_bitrate_);
   EXPECT_EQ(200000u, bitrate_observer_2.last_bitrate_);
@@ -175,9 +170,9 @@
   EXPECT_EQ(0u, bitrate_observer_2.last_bitrate_);
   EXPECT_EQ(0u, bitrate_observer_3.last_bitrate_);
 
-  allocator_->RemoveBitrateObserver(&bitrate_observer_1);
-  allocator_->RemoveBitrateObserver(&bitrate_observer_2);
-  allocator_->RemoveBitrateObserver(&bitrate_observer_3);
+  allocator_->RemoveObserver(&bitrate_observer_1);
+  allocator_->RemoveObserver(&bitrate_observer_2);
+  allocator_->RemoveObserver(&bitrate_observer_3);
 }
 
 TEST_F(BitrateAllocatorTest, ThreeBitrateObserversLowRembEnforceMin) {
@@ -185,16 +180,14 @@
   TestBitrateObserver bitrate_observer_2;
   TestBitrateObserver bitrate_observer_3;
   int start_bitrate =
-      allocator_->AddBitrateObserver(&bitrate_observer_1, 100000, 400000);
+      allocator_->AddObserver(&bitrate_observer_1, 100000, 400000);
   EXPECT_EQ(300000, start_bitrate);
 
-  start_bitrate =
-      allocator_->AddBitrateObserver(&bitrate_observer_2, 200000, 400000);
+  start_bitrate = allocator_->AddObserver(&bitrate_observer_2, 200000, 400000);
   EXPECT_EQ(200000, start_bitrate);
   EXPECT_EQ(100000u, bitrate_observer_1.last_bitrate_);
 
-  start_bitrate =
-      allocator_->AddBitrateObserver(&bitrate_observer_3, 300000, 400000);
+  start_bitrate = allocator_->AddObserver(&bitrate_observer_3, 300000, 400000);
   EXPECT_EQ(300000, start_bitrate);
   EXPECT_EQ(100000, static_cast<int>(bitrate_observer_1.last_bitrate_));
   EXPECT_EQ(200000, static_cast<int>(bitrate_observer_2.last_bitrate_));
@@ -205,8 +198,8 @@
   EXPECT_EQ(200000u, bitrate_observer_2.last_bitrate_);  // Min cap.
   EXPECT_EQ(300000u, bitrate_observer_3.last_bitrate_);  // Min cap.
 
-  allocator_->RemoveBitrateObserver(&bitrate_observer_1);
-  allocator_->RemoveBitrateObserver(&bitrate_observer_2);
-  allocator_->RemoveBitrateObserver(&bitrate_observer_3);
+  allocator_->RemoveObserver(&bitrate_observer_1);
+  allocator_->RemoveObserver(&bitrate_observer_2);
+  allocator_->RemoveObserver(&bitrate_observer_3);
 }
 }  // namespace webrtc
diff --git a/call/call.cc b/call/call.cc
index 41ac328..2dfb13a 100644
--- a/call/call.cc
+++ b/call/call.cc
@@ -394,7 +394,7 @@
   // the call has already started.
   VideoSendStream* send_stream = new VideoSendStream(
       num_cpu_cores_, module_process_thread_.get(), call_stats_.get(),
-      congestion_controller_.get(), &remb_, bitrate_allocator_.get(), config,
+      congestion_controller_.get(), bitrate_allocator_.get(), &remb_, config,
       encoder_config, suspended_video_send_ssrcs_);
 
   if (!network_enabled_)
diff --git a/video/encoder_state_feedback_unittest.cc b/video/encoder_state_feedback_unittest.cc
index be81bda..3341cf0 100644
--- a/video/encoder_state_feedback_unittest.cc
+++ b/video/encoder_state_feedback_unittest.cc
@@ -35,7 +35,6 @@
                    nullptr,
                    nullptr,
                    pacer,
-                   nullptr,
                    nullptr) {}
   ~MockVieEncoder() {}
 
diff --git a/video/video_send_stream.cc b/video/video_send_stream.cc
index c98e518..658cd49 100644
--- a/video/video_send_stream.cc
+++ b/video/video_send_stream.cc
@@ -156,8 +156,8 @@
     ProcessThread* module_process_thread,
     CallStats* call_stats,
     CongestionController* congestion_controller,
-    VieRemb* remb,
     BitrateAllocator* bitrate_allocator,
+    VieRemb* remb,
     const VideoSendStream::Config& config,
     const VideoEncoderConfig& encoder_config,
     const std::map<uint32_t, RtpState>& suspended_ssrcs)
@@ -170,6 +170,7 @@
       module_process_thread_(module_process_thread),
       call_stats_(call_stats),
       congestion_controller_(congestion_controller),
+      bitrate_allocator_(bitrate_allocator),
       remb_(remb),
       encoder_thread_(EncoderThreadFunction, this, "EncoderThread"),
       encoder_wakeup_event_(false, false),
@@ -202,8 +203,7 @@
                    config.pre_encode_callback,
                    &overuse_detector_,
                    congestion_controller_->pacer(),
-                   &payload_router_,
-                   bitrate_allocator),
+                   &payload_router_),
       vcm_(vie_encoder_.vcm()),
       rtp_rtcp_modules_(vie_channel_.rtp_rtcp()),
       input_(&encoder_wakeup_event_,
@@ -298,8 +298,10 @@
   if (config_.post_encode_callback)
     vie_encoder_.RegisterPostEncodeImageCallback(&encoded_frame_proxy_);
 
-  if (config_.suspend_below_min_bitrate)
-    vie_encoder_.SuspendBelowMinBitrate();
+  if (config_.suspend_below_min_bitrate) {
+    vcm_->SuspendBelowMinBitrate();
+    bitrate_allocator_->EnforceMinBitrate(false);
+  }
 
   vie_channel_.RegisterRtcpPacketTypeCounterObserver(&stats_proxy_);
   vie_channel_.RegisterSendBitrateObserver(&stats_proxy_);
@@ -313,6 +315,8 @@
 
 VideoSendStream::~VideoSendStream() {
   LOG(LS_INFO) << "~VideoSendStream: " << config_.ToString();
+
+  bitrate_allocator_->RemoveObserver(this);
   Stop();
 
   // Stop the encoder thread permanently.
@@ -516,6 +520,10 @@
   RTC_DCHECK_GT(streams[0].max_framerate, 0);
   video_codec.maxFramerate = streams[0].max_framerate;
 
+  video_codec.startBitrate =
+      bitrate_allocator_->AddObserver(this,
+                                      video_codec.minBitrate * 1000,
+                                      video_codec.maxBitrate * 1000) / 1000;
   vie_encoder_.SetEncoder(video_codec, config.min_transmit_bitrate_bps);
 }
 
@@ -614,5 +622,12 @@
 int VideoSendStream::GetPaddingNeededBps() const {
   return vie_encoder_.GetPaddingNeededBps();
 }
+
+void VideoSendStream::OnBitrateUpdated(uint32_t bitrate_bps,
+                                       uint8_t fraction_loss,
+                                       int64_t rtt) {
+  vie_encoder_.OnBitrateUpdated(bitrate_bps, fraction_loss, rtt);
+}
+
 }  // namespace internal
 }  // namespace webrtc
diff --git a/video/video_send_stream.h b/video/video_send_stream.h
index 88d8abc..8b3d064 100644
--- a/video/video_send_stream.h
+++ b/video/video_send_stream.h
@@ -14,6 +14,7 @@
 #include <map>
 #include <vector>
 
+#include "webrtc/call/bitrate_allocator.h"
 #include "webrtc/call.h"
 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
 #include "webrtc/video/encoded_frame_callback_adapter.h"
@@ -40,14 +41,15 @@
 namespace internal {
 
 class VideoSendStream : public webrtc::VideoSendStream,
-                        public webrtc::CpuOveruseObserver {
+                        public webrtc::CpuOveruseObserver,
+                        public webrtc::BitrateAllocatorObserver {
  public:
   VideoSendStream(int num_cpu_cores,
                   ProcessThread* module_process_thread,
                   CallStats* call_stats,
                   CongestionController* congestion_controller,
-                  VieRemb* remb,
                   BitrateAllocator* bitrate_allocator,
+                  VieRemb* remb,
                   const VideoSendStream::Config& config,
                   const VideoEncoderConfig& encoder_config,
                   const std::map<uint32_t, RtpState>& suspended_ssrcs);
@@ -74,6 +76,11 @@
 
   int GetPaddingNeededBps() const;
 
+  // Implements BitrateAllocatorObserver.
+  void OnBitrateUpdated(uint32_t bitrate_bps,
+                        uint8_t fraction_loss,
+                        int64_t rtt) override;
+
  private:
   static bool EncoderThreadFunction(void* obj);
   void EncoderProcess();
@@ -88,6 +95,7 @@
   ProcessThread* const module_process_thread_;
   CallStats* const call_stats_;
   CongestionController* const congestion_controller_;
+  BitrateAllocator* const bitrate_allocator_;
   VieRemb* const remb_;
 
   rtc::PlatformThread encoder_thread_;
diff --git a/video/vie_encoder.cc b/video/vie_encoder.cc
index bd0729c..e6f6776 100644
--- a/video/vie_encoder.cc
+++ b/video/vie_encoder.cc
@@ -17,11 +17,9 @@
 #include "webrtc/base/checks.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/trace_event.h"
-#include "webrtc/call/bitrate_allocator.h"
 #include "webrtc/common_video/include/video_image.h"
 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
 #include "webrtc/frame_callback.h"
-#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
 #include "webrtc/modules/pacing/paced_sender.h"
 #include "webrtc/modules/utility/include/process_thread.h"
 #include "webrtc/modules/video_coding/include/video_codec_interface.h"
@@ -80,22 +78,6 @@
   VideoProcessing* vp_;
 };
 
-class ViEBitrateObserver : public BitrateObserver {
- public:
-  explicit ViEBitrateObserver(ViEEncoder* owner)
-      : owner_(owner) {
-  }
-  virtual ~ViEBitrateObserver() {}
-  // Implements BitrateObserver.
-  virtual void OnNetworkChanged(uint32_t bitrate_bps,
-                                uint8_t fraction_lost,
-                                int64_t rtt) {
-    owner_->OnNetworkChanged(bitrate_bps, fraction_lost, rtt);
-  }
- private:
-  ViEEncoder* owner_;
-};
-
 ViEEncoder::ViEEncoder(uint32_t number_of_cores,
                        const std::vector<uint32_t>& ssrcs,
                        ProcessThread* module_process_thread,
@@ -103,8 +85,7 @@
                        I420FrameCallback* pre_encode_callback,
                        OveruseFrameDetector* overuse_detector,
                        PacedSender* pacer,
-                       PayloadRouter* payload_router,
-                       BitrateAllocator* bitrate_allocator)
+                       PayloadRouter* payload_router)
     : number_of_cores_(number_of_cores),
       ssrcs_(ssrcs),
       vp_(VideoProcessing::Create()),
@@ -117,7 +98,6 @@
       overuse_detector_(overuse_detector),
       pacer_(pacer),
       send_payload_router_(payload_router),
-      bitrate_allocator_(bitrate_allocator),
       time_of_last_frame_activity_ms_(0),
       encoder_config_(),
       min_transmit_bitrate_bps_(0),
@@ -132,7 +112,6 @@
       has_received_rpsi_(false),
       picture_id_rpsi_(0),
       video_suspended_(false) {
-  bitrate_observer_.reset(new ViEBitrateObserver(this));
   module_process_thread_->RegisterModule(vcm_.get());
 }
 
@@ -157,8 +136,6 @@
 
 ViEEncoder::~ViEEncoder() {
   module_process_thread_->DeRegisterModule(vcm_.get());
-  if (bitrate_allocator_)
-    bitrate_allocator_->RemoveBitrateObserver(bitrate_observer_.get());
 }
 
 void ViEEncoder::SetNetworkTransmissionState(bool is_transmitting) {
@@ -202,7 +179,7 @@
                vp_->SetTargetResolution(video_codec.width, video_codec.height,
                                         video_codec.maxFramerate));
 
-  // Cache codec before calling AddBitrateObserver (which calls OnNetworkChanged
+  // Cache codec before calling AddBitrateObserver (which calls OnBitrateUpdated
   // that makes use of the number of simulcast streams configured).
   {
     rtc::CritScope lock(&data_cs_);
@@ -211,18 +188,9 @@
     min_transmit_bitrate_bps_ = min_transmit_bitrate_bps;
   }
 
-  // Add a bitrate observer to the allocator and update the start, max and
-  // min bitrates of the bitrate controller as needed.
-  int allocated_bitrate_bps = bitrate_allocator_->AddBitrateObserver(
-      bitrate_observer_.get(), video_codec.minBitrate * 1000,
-      video_codec.maxBitrate * 1000);
-
-  webrtc::VideoCodec modified_video_codec = video_codec;
-  modified_video_codec.startBitrate = allocated_bitrate_bps / 1000;
-
   size_t max_data_payload_length = send_payload_router_->MaxPayloadLength();
   bool success = vcm_->RegisterSendCodec(
-                     &modified_video_codec, number_of_cores_,
+                     &video_codec, number_of_cores_,
                      static_cast<uint32_t>(max_data_payload_length)) == VCM_OK;
   if (!success) {
     LOG(LS_ERROR) << "Failed to configure encoder.";
@@ -511,11 +479,10 @@
   RTC_NOTREACHED() << "Should not receive keyframe requests on unknown SSRCs.";
 }
 
-// Called from ViEBitrateObserver.
-void ViEEncoder::OnNetworkChanged(uint32_t bitrate_bps,
+void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps,
                                   uint8_t fraction_lost,
                                   int64_t round_trip_time_ms) {
-  LOG(LS_VERBOSE) << "OnNetworkChanged, bitrate" << bitrate_bps
+  LOG(LS_VERBOSE) << "OnBitrateUpdated, bitrate" << bitrate_bps
                   << " packet loss " << static_cast<int>(fraction_lost)
                   << " rtt " << round_trip_time_ms;
   RTC_DCHECK(send_payload_router_ != NULL);
@@ -546,11 +513,6 @@
     stats_proxy_->OnSuspendChange(video_is_suspended);
 }
 
-void ViEEncoder::SuspendBelowMinBitrate() {
-  vcm_->SuspendBelowMinBitrate();
-  bitrate_allocator_->EnforceMinBitrate(false);
-}
-
 void ViEEncoder::RegisterPostEncodeImageCallback(
       EncodedImageCallback* post_encode_callback) {
   vcm_->RegisterPostEncodeImageCallback(post_encode_callback);
diff --git a/video/vie_encoder.h b/video/vie_encoder.h
index 3703ccd..ce1e508 100644
--- a/video/vie_encoder.h
+++ b/video/vie_encoder.h
@@ -17,7 +17,6 @@
 #include "webrtc/base/criticalsection.h"
 #include "webrtc/base/scoped_ref_ptr.h"
 #include "webrtc/base/thread_annotations.h"
-#include "webrtc/call/bitrate_allocator.h"
 #include "webrtc/common_types.h"
 #include "webrtc/frame_callback.h"
 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
@@ -27,8 +26,6 @@
 
 namespace webrtc {
 
-class BitrateAllocator;
-class BitrateObserver;
 class Config;
 class EncodedImageCallback;
 class OveruseFrameDetector;
@@ -55,8 +52,7 @@
              I420FrameCallback* pre_encode_callback,
              OveruseFrameDetector* overuse_detector,
              PacedSender* pacer,
-             PayloadRouter* payload_router,
-             BitrateAllocator* bitrate_allocator);
+             PayloadRouter* payload_router);
   ~ViEEncoder();
 
   bool Init();
@@ -109,20 +105,13 @@
   virtual void OnReceivedSLI(uint32_t ssrc, uint8_t picture_id);
   virtual void OnReceivedRPSI(uint32_t ssrc, uint64_t picture_id);
 
-  // Lets the sender suspend video when the rate drops below
-  // |threshold_bps|, and turns back on when the rate goes back up above
-  // |threshold_bps| + |window_bps|.
-  void SuspendBelowMinBitrate();
-
   // New-style callbacks, used by VideoSendStream.
   void RegisterPostEncodeImageCallback(
         EncodedImageCallback* post_encode_callback);
 
   int GetPaddingNeededBps() const;
 
- protected:
-  // Called by BitrateObserver.
-  void OnNetworkChanged(uint32_t bitrate_bps,
+  void OnBitrateUpdated(uint32_t bitrate_bps,
                         uint8_t fraction_lost,
                         int64_t round_trip_time_ms);
 
@@ -139,14 +128,12 @@
   const std::unique_ptr<VideoCodingModule> vcm_;
 
   rtc::CriticalSection data_cs_;
-  std::unique_ptr<BitrateObserver> bitrate_observer_;
 
   SendStatisticsProxy* const stats_proxy_;
   I420FrameCallback* const pre_encode_callback_;
   OveruseFrameDetector* const overuse_detector_;
   PacedSender* const pacer_;
   PayloadRouter* const send_payload_router_;
-  BitrateAllocator* const bitrate_allocator_;
 
   // The time we last received an input frame or encoded frame. This is used to
   // track when video is stopped long enough that we also want to stop sending