From 25fe54f71c8008fe6e86f0d664e96ee9cbd7ddce Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Wed, 7 Dec 2016 08:38:13 -1000 Subject: [PATCH] Bug 1320101 - Differentiate between b=TIAS and simulcast stream max-br. r=bwc,jesup MozReview-Commit-ID: HPnOvwtawwV --HG-- extra : rebase_source : 9133afc61b48d25f466c0e4a65a743f26eba48c5 --- media/webrtc/signaling/src/jsep/JsepTrack.cpp | 5 +++-- media/webrtc/signaling/src/jsep/JsepTrack.h | 10 ++++++++++ media/webrtc/signaling/src/jsep/JsepTrackEncoding.h | 10 ---------- media/webrtc/signaling/src/media-conduit/CodecConfig.h | 2 ++ .../signaling/src/media-conduit/VideoConduit.cpp | 6 ++++-- .../src/peerconnection/MediaPipelineFactory.cpp | 3 +++ 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/media/webrtc/signaling/src/jsep/JsepTrack.cpp b/media/webrtc/signaling/src/jsep/JsepTrack.cpp index 1b045d8ec7e6..8f3fbebf28c2 100644 --- a/media/webrtc/signaling/src/jsep/JsepTrack.cpp +++ b/media/webrtc/signaling/src/jsep/JsepTrack.cpp @@ -261,6 +261,9 @@ JsepTrack::CreateEncodings( const std::vector& negotiatedCodecs, JsepTrackNegotiatedDetails* negotiatedDetails) { + negotiatedDetails->mTias = remote.GetBandwidth("TIAS"); + // TODO add support for b=AS if TIAS is not set (bug 976521) + std::vector rids; GetRids(remote, sdp::kRecv, &rids); // Get rids we will send NegotiateRids(rids, &mJsEncodeConstraints); @@ -294,8 +297,6 @@ JsepTrack::CreateEncodings( encoding->mConstraints = jsConstraints.constraints; } } - - encoding->UpdateMaxBitrate(remote); } } diff --git a/media/webrtc/signaling/src/jsep/JsepTrack.h b/media/webrtc/signaling/src/jsep/JsepTrack.h index 5aa37404fff3..692f313a005d 100644 --- a/media/webrtc/signaling/src/jsep/JsepTrack.h +++ b/media/webrtc/signaling/src/jsep/JsepTrack.h @@ -28,6 +28,10 @@ namespace mozilla { class JsepTrackNegotiatedDetails { public: + JsepTrackNegotiatedDetails() : + mTias(0) + {} + size_t GetEncodingCount() const { @@ -56,12 +60,18 @@ public: return mUniquePayloadTypes; } + uint32_t GetTias() const + { + return mTias; + } + private: friend class JsepTrack; std::map mExtmap; std::vector mUniquePayloadTypes; PtrVector mEncodings; + uint32_t mTias; // bits per second }; class JsepTrack diff --git a/media/webrtc/signaling/src/jsep/JsepTrackEncoding.h b/media/webrtc/signaling/src/jsep/JsepTrackEncoding.h index b59b672e4293..078bd796f3fc 100644 --- a/media/webrtc/signaling/src/jsep/JsepTrackEncoding.h +++ b/media/webrtc/signaling/src/jsep/JsepTrackEncoding.h @@ -39,16 +39,6 @@ public: 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; diff --git a/media/webrtc/signaling/src/media-conduit/CodecConfig.h b/media/webrtc/signaling/src/media-conduit/CodecConfig.h index 308c97948166..153229fa4dd0 100755 --- a/media/webrtc/signaling/src/media-conduit/CodecConfig.h +++ b/media/webrtc/signaling/src/media-conduit/CodecConfig.h @@ -90,6 +90,7 @@ public: bool mRembFbSet; bool mFECFbSet; + uint32_t mTias; EncodingConstraints mEncodingConstraints; struct SimulcastEncoding { std::string rid; @@ -110,6 +111,7 @@ public: mType(type), mName(name), mFECFbSet(false), + mTias(0), mEncodingConstraints(constraints), mProfile(0x42), mConstraints(0xE0), diff --git a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp index 5d774281dc25..3d2e0d919d6c 100755 --- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp +++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp @@ -732,6 +732,10 @@ WebrtcVideoConduit::ConfigureSendMediaCodec(const VideoCodecConfig* codecConfig) CSFLogError(logTag, "%s Codec Mismatch ", __FUNCTION__); return kMediaConduitInvalidSendCodec; } + + // So we can comply with b=TIAS/b=AS/maxbr=X when input resolution changes + mNegotiatedMaxBitrate = codecConfig->mTias / 1000; + // Note: only for overriding parameters from GetCodec()! CodecConfigToWebRTCCodec(codecConfig, video_codec); if (mSendingWidth != 0) { @@ -751,8 +755,6 @@ WebrtcVideoConduit::ConfigureSendMediaCodec(const VideoCodecConfig* codecConfig) mSendingHeight = 0; mSendingFramerate = video_codec.maxFramerate; } - // So we can comply with b=TIAS/b=AS/maxbr=X when input resolution changes - mNegotiatedMaxBitrate = MinIgnoreZero(mPrefMaxBitrate, video_codec.maxBitrate); video_codec.mode = mCodecMode; diff --git a/media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp b/media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp index f4bdbefbaaa8..c651e2a2f77d 100644 --- a/media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp +++ b/media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp @@ -167,6 +167,8 @@ NegotiatedDetailsToVideoCodecConfigs(const JsepTrackNegotiatedDetails& aDetails, return NS_ERROR_INVALID_ARG; } + config->mTias = aDetails.GetTias(); + for (size_t i = 0; i < aDetails.GetEncodingCount(); ++i) { const JsepTrackEncoding& jsepEncoding(aDetails.GetEncoding(i)); if (jsepEncoding.HasFormat(codec->mDefaultPt)) { @@ -176,6 +178,7 @@ NegotiatedDetailsToVideoCodecConfigs(const JsepTrackNegotiatedDetails& aDetails, config->mSimulcastEncodings.push_back(encoding); } } + aConfigs->values.push_back(config); }