Reland of BWE allocation strategy

TBR=stefan@webrtc.org,alexnarest@webrtc.org

Bug: webrtc:8243
Change-Id: Ie68e4f414b2ac32ba4e64877cb250fabcb089a07
Reviewed-on: https://webrtc-review.googlesource.com/13940
Commit-Queue: Alex Narest <alexnarest@webrtc.org>
Reviewed-by: Alex Narest <alexnarest@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20369}
diff --git a/pc/peerconnection.cc b/pc/peerconnection.cc
index bec13a5..7cad0e1 100644
--- a/pc/peerconnection.cc
+++ b/pc/peerconnection.cc
@@ -1331,6 +1331,24 @@
   return RTCError::OK();
 }
 
+void PeerConnection::SetBitrateAllocationStrategy(
+    std::unique_ptr<rtc::BitrateAllocationStrategy>
+        bitrate_allocation_strategy) {
+  rtc::Thread* worker_thread = factory_->worker_thread();
+  if (!worker_thread->IsCurrent()) {
+    rtc::BitrateAllocationStrategy* strategy_raw =
+        bitrate_allocation_strategy.release();
+    auto functor = [this, strategy_raw]() {
+      call_->SetBitrateAllocationStrategy(
+          rtc::WrapUnique<rtc::BitrateAllocationStrategy>(strategy_raw));
+    };
+    worker_thread->Invoke<void>(RTC_FROM_HERE, functor);
+    return;
+  }
+  RTC_DCHECK(call_.get());
+  call_->SetBitrateAllocationStrategy(std::move(bitrate_allocation_strategy));
+}
+
 std::unique_ptr<rtc::SSLCertificate>
 PeerConnection::GetRemoteAudioSSLCertificate() {
   if (!session_) {