Fixes bug in AudioPriorityBitrateAllocationStrategy field trial.

Previously the rate limits weren't properly applied. This is fixed by
working on mutable copies of the TrackConfig.

Bug: webrtc:9718
Change-Id: I7438c59efa5d7e70fa3ce5e466e2c53a5a7ea9e2
Reviewed-on: https://webrtc-review.googlesource.com/c/107636
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25367}
diff --git a/call/bitrate_allocator.cc b/call/bitrate_allocator.cc
index 64d1a486..c13b7dc 100644
--- a/call/bitrate_allocator.cc
+++ b/call/bitrate_allocator.cc
@@ -301,14 +301,14 @@
     return ObserverAllocation();
 
   if (bitrate_allocation_strategy_ != nullptr) {
-    std::vector<const rtc::BitrateAllocationStrategy::TrackConfig*>
-        track_configs(bitrate_observer_configs_.size());
-    int i = 0;
-    for (const auto& c : bitrate_observer_configs_) {
-      track_configs[i++] = &c;
-    }
+    // Note: This intentionally causes slicing, we only copy the fields in
+    // ObserverConfig that are inherited from TrackConfig.
+    std::vector<rtc::BitrateAllocationStrategy::TrackConfig> track_configs(
+        bitrate_observer_configs_.begin(), bitrate_observer_configs_.end());
+
     std::vector<uint32_t> track_allocations =
-        bitrate_allocation_strategy_->AllocateBitrates(bitrate, track_configs);
+        bitrate_allocation_strategy_->AllocateBitrates(
+            bitrate, std::move(track_configs));
     // The strategy should return allocation for all tracks.
     RTC_CHECK(track_allocations.size() == bitrate_observer_configs_.size());
     ObserverAllocation allocation;