Bug 1276368: use b=TIAS for maxBitrate encoding constraints. r=jesup
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Wed, 18 May 2016 18:16:59 -0700
changeset 341517 403728f309ce77168d47d67e69e41aad284aabbd
parent 341516 a9575284041e2bd8b8822c469012ce4df5739ef8
child 341518 f4e2ff34312b8104fe96e07af43b23cbce3c3f73
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1276368
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1276368: use b=TIAS for maxBitrate encoding constraints. r=jesup MozReview-Commit-ID: C6kGt9pfhko
media/webrtc/signaling/src/jsep/JsepTrack.cpp
media/webrtc/signaling/src/jsep/JsepTrackEncoding.h
media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
--- a/media/webrtc/signaling/src/jsep/JsepTrack.cpp
+++ b/media/webrtc/signaling/src/jsep/JsepTrack.cpp
@@ -289,16 +289,18 @@ JsepTrack::CreateEncodings(
     // If we end up supporting params for rid, we would handle that here.
 
     // Incorporate the corresponding JS encoding constraints, if they exist
     for (const JsConstraints& jsConstraints : mJsEncodeConstraints) {
       if (jsConstraints.rid == rids[i].id) {
         encoding->mConstraints = jsConstraints.constraints;
       }
     }
+
+    encoding->UpdateMaxBitrate(remote);
   }
 }
 
 std::vector<JsepCodecDescription*>
 JsepTrack::GetCodecClones() const
 {
   std::vector<JsepCodecDescription*> clones;
   for (const JsepCodecDescription* codec : mPrototypeCodecs.values) {
--- a/media/webrtc/signaling/src/jsep/JsepTrackEncoding.h
+++ b/media/webrtc/signaling/src/jsep/JsepTrackEncoding.h
@@ -34,16 +34,26 @@ public:
     for (const JsepCodecDescription* codec : mCodecs.values) {
       if (codec->mDefaultPt == format) {
         return true;
       }
     }
     return false;
   }
 
+  void UpdateMaxBitrate(const SdpMediaSection& remote)
+  {
+    uint32_t tias = remote.GetBandwidth("TIAS");
+    // select minimum of the two which is not zero
+    mConstraints.maxBr = std::min(tias ? tias : mConstraints.maxBr,
+                                  mConstraints.maxBr ? mConstraints.maxBr :
+                                                       tias);
+    // TODO add support for b=AS if TIAS is not set (bug 976521)
+  }
+
   EncodingConstraints mConstraints;
   std::string mRid;
 
 private:
   PtrVector<JsepCodecDescription> mCodecs;
 };
 }
 
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
@@ -1044,23 +1044,23 @@ WebrtcVideoConduit::SelectBitrates(unsig
 
   // mLastFramerateTenths is an atomic, and scaled by *10
   double framerate = std::min((aLastFramerateTenths/10.),60.0);
   MOZ_ASSERT(framerate > 0);
   // Now linear reduction/increase based on fps (max 60fps i.e. doubling)
   if (framerate >= 10) {
     out_min = out_min * (framerate/30);
     out_start = out_start * (framerate/30);
-    out_max = out_max * (framerate/30);
+    out_max = std::max((unsigned int)(out_max * (framerate/30)), cap);
   } else {
     // At low framerates, don't reduce bandwidth as much - cut slope to 1/2.
     // Mostly this would be ultra-low-light situations/mobile or screensharing.
     out_min = out_min * ((10-(framerate/2))/30);
     out_start = out_start * ((10-(framerate/2))/30);
-    out_max = out_max * ((10-(framerate/2))/30);
+    out_max = std::max((unsigned int)(out_max * ((10-(framerate/2))/30)), cap);
   }
 
   if (mMinBitrate && mMinBitrate > out_min) {
     out_min = mMinBitrate;
   }
   // If we try to set a minimum bitrate that is too low, ViE will reject it.
   out_min = std::max((unsigned int) webrtc::kViEMinCodecBitrate,
                                   out_min);