Bug 1474661: Fixed bug where we were overwriting the high quality simulcast config with the next one down, and add another entry to the resolutions/bitrates table. draft
authorByron Campen [:bwc] <docfaraday@gmail.com>
Fri, 27 Jul 2018 14:31:00 -0500
changeset 823658 966c3385ddee185f1b16ec8ce807cfc0ac7c785e
parent 823465 87bcafe428a4ad6017e59b915581ae00aa863407
push id117754
push userbcampen@mozilla.com
push dateFri, 27 Jul 2018 19:31:50 +0000
bugs1474661
milestone63.0a1
Bug 1474661: Fixed bug where we were overwriting the high quality simulcast config with the next one down, and add another entry to the resolutions/bitrates table. MozReview-Commit-ID: DhPYvioLqAe
media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
@@ -597,17 +597,16 @@ WebrtcVideoConduit::VideoStreamFactory::
 
   // XXX webrtc.org code has a restriction on simulcast layers that each
   // layer must be 1/2 the dimension of the previous layer - not sure why.
   // This means we can't use scaleResolutionBy/scaleDownBy (yet), even if
   // the user specified it.  The one exception is that we can apply it on
   // the full-resolution stream (which also happens to handle the
   // non-simulcast usage case). NOTE: we make an assumption here, not in the
   // spec, that the first stream is the full-resolution stream.
-  auto& simulcastEncoding = mConduit->mCurSendCodecConfig->mSimulcastEncodings[0];
 #if 0
   // XXX What we'd like to do for each simulcast stream...
   if (simulcastEncoding.constraints.scaleDownBy > 1.0) {
     uint32_t new_width = width / simulcastEncoding.constraints.scaleDownBy;
     uint32_t new_height = height / simulcastEncoding.constraints.scaleDownBy;
 
     if (new_width != width || new_height != height) {
       if (streamCount == 1) {
@@ -634,17 +633,17 @@ WebrtcVideoConduit::VideoStreamFactory::
 
     // width/height will be overridden on the first frame; they must be 'sane' for
     // SetSendCodec()
     video_stream.width = width >> idx;
     video_stream.height = height >> idx;
     // We want to ensure this picks up the current framerate, so indirect
     video_stream.max_framerate = mConduit->mSendingFramerate;
 
-    simulcastEncoding = mConduit->mCurSendCodecConfig->mSimulcastEncodings[idx];
+    auto& simulcastEncoding = mConduit->mCurSendCodecConfig->mSimulcastEncodings[idx];
     MOZ_ASSERT(simulcastEncoding.constraints.scaleDownBy >= 1.0);
 
     // Calculate these first
     video_stream.max_bitrate_bps = MinIgnoreZero(simulcastEncoding.constraints.maxBr,
                                                  kDefaultMaxBitrate_bps);
     video_stream.max_bitrate_bps = MinIgnoreZero((int) mConduit->mPrefMaxBitrate*1000,
                                                  video_stream.max_bitrate_bps);
     video_stream.min_bitrate_bps = (mConduit->mMinBitrate ?
@@ -1626,16 +1625,17 @@ struct ResolutionAndBitrateLimits
 // 30fps.
 
 // XXX Populate this based on a pref (which we should consider sorting because
 // people won't assume they need to).
 static ResolutionAndBitrateLimits kResolutionAndBitrateLimits[] = {
   {MB_OF(1920, 1200), KBPS(1500), KBPS(2000), KBPS(10000)}, // >HD (3K, 4K, etc)
   {MB_OF(1280, 720), KBPS(1200), KBPS(1500), KBPS(5000)}, // HD ~1080-1200
   {MB_OF(800, 480), KBPS(600), KBPS(800), KBPS(2500)}, // HD ~720
+  {MB_OF(480, 270), KBPS(300), KBPS(500), KBPS(2000)},
   {tl::Max<MB_OF(400, 240), MB_OF(352, 288)>::value, KBPS(200), KBPS(300), KBPS(1300)}, // VGA, WVGA
   {MB_OF(176, 144), KBPS(100), KBPS(150), KBPS(500)}, // WQVGA, CIF
   {0 , KBPS(40), KBPS(80), KBPS(250)} // QCIF and below
 };
 
 void
 WebrtcVideoConduit::SelectBitrates(
   unsigned short width, unsigned short height, int cap,