Bug 1365090 - Use target bitrate instead of max for simulcast. r=bwc, a=gchang
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Tue, 16 May 2017 16:15:04 -0700
changeset 396366 dbb2acc72839c7bda047fd2be29182d3ced0b86b
parent 396365 1099d84ea9bd94c452b4bbba7b6cbcab6daf23c6
child 396367 93e66a0ce8102ee500389ab819869b3ddfbaf1d6
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc, gchang
bugs1365090
milestone54.0
Bug 1365090 - Use target bitrate instead of max for simulcast. r=bwc, a=gchang MozReview-Commit-ID: GThcXHHnoCV
media/webrtc/trunk/webrtc/video/video_send_stream.cc
--- a/media/webrtc/trunk/webrtc/video/video_send_stream.cc
+++ b/media/webrtc/trunk/webrtc/video/video_send_stream.cc
@@ -421,17 +421,26 @@ bool VideoSendStream::ReconfigureVideoEn
 
     video_codec.width = std::max(video_codec.width,
                                  static_cast<uint16_t>(streams[i].width));
     video_codec.height = std::max(
         video_codec.height, static_cast<uint16_t>(streams[i].height));
     video_codec.minBitrate =
         std::min(static_cast<uint16_t>(video_codec.minBitrate),
                  static_cast<uint16_t>(streams[i].min_bitrate_bps / 1000));
-    video_codec.maxBitrate += streams[i].max_bitrate_bps / 1000;
+    // SimulcastEncoderAdapter::GetStreamBitrate() expects to give the target
+    // rate to each of the lower layers and the remainder to the last layer.
+    // Giving max to everything results in lower layer to consume too much
+    // bandwidth and the top layer potentially not having enough bitrate left
+    // for its minimum.
+    if (i + 1 == streams.size()) {
+      video_codec.maxBitrate += streams[i].max_bitrate_bps / 1000;
+    } else {
+      video_codec.maxBitrate += streams[i].target_bitrate_bps / 1000;
+    }
     video_codec.qpMax = std::max(video_codec.qpMax,
                                  static_cast<unsigned int>(streams[i].max_qp));
   }
 
   // Set to zero to not update the bitrate controller from ViEEncoder, as
   // the bitrate controller is already set from Call.
   video_codec.startBitrate = 0;