Index: webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc |
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc b/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc |
index 3e8e47fbd377372cac9bae6b2f6389464eb10e7c..8c3c5cf7f2d4d59a7a7de1a77ff7e78daac73bec 100644 |
--- a/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc |
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc |
@@ -44,8 +44,7 @@ RTCPReceiver::RTCPReceiver( |
RtcpIntraFrameObserver* rtcp_intra_frame_observer, |
TransportFeedbackObserver* transport_feedback_observer, |
ModuleRtpRtcpImpl* owner) |
- : TMMBRHelp(), |
- _clock(clock), |
+ : _clock(clock), |
receiver_only_(receiver_only), |
_lastReceived(0), |
_rtpRtcp(*owner), |
@@ -695,7 +694,7 @@ bool RTCPReceiver::UpdateRTCPReceiveInformationTimers() { |
if ((timeNow - receiveInfo->lastTimeReceived) > |
5 * RTCP_INTERVAL_AUDIO_MS) { |
// no rtcp packet for the last five regular intervals, reset limitations |
- receiveInfo->TmmbrSet.clearSet(); |
+ receiveInfo->TmmbrSet.clear(); |
// prevent that we call this over and over again |
receiveInfo->lastTimeReceived = 0; |
// send new TMMBN to all channels using the default codec |
@@ -716,7 +715,8 @@ bool RTCPReceiver::UpdateRTCPReceiveInformationTimers() { |
return updateBoundingSet; |
} |
-int32_t RTCPReceiver::BoundingSet(bool* tmmbrOwner, TMMBRSet* boundingSetRec) { |
+int32_t RTCPReceiver::BoundingSet(bool* tmmbrOwner, |
+ std::vector<rtcp::TmmbItem>* boundingSetRec) { |
rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
std::map<uint32_t, RTCPReceiveInformation*>::iterator receiveInfoIt = |
@@ -729,22 +729,18 @@ int32_t RTCPReceiver::BoundingSet(bool* tmmbrOwner, TMMBRSet* boundingSetRec) { |
if (receiveInfo == NULL) { |
return -1; |
} |
- if (receiveInfo->TmmbnBoundingSet.lengthOfSet() > 0) { |
- boundingSetRec->VerifyAndAllocateSet( |
- receiveInfo->TmmbnBoundingSet.lengthOfSet() + 1); |
- for(uint32_t i=0; i< receiveInfo->TmmbnBoundingSet.lengthOfSet(); |
- i++) { |
- if(receiveInfo->TmmbnBoundingSet.Ssrc(i) == main_ssrc_) { |
+ if (receiveInfo->TmmbnBoundingSet.size() > 0) { |
+ boundingSetRec->clear(); |
+ boundingSetRec->reserve(receiveInfo->TmmbnBoundingSet.size() + 1); |
+ for (uint32_t i = 0; i < receiveInfo->TmmbnBoundingSet.size(); i++) { |
+ if (receiveInfo->TmmbnBoundingSet[i].ssrc() == main_ssrc_) { |
// owner of bounding set |
*tmmbrOwner = true; |
} |
- boundingSetRec->SetEntry(i, |
- receiveInfo->TmmbnBoundingSet.Tmmbr(i), |
- receiveInfo->TmmbnBoundingSet.PacketOH(i), |
- receiveInfo->TmmbnBoundingSet.Ssrc(i)); |
+ boundingSetRec->push_back(receiveInfo->TmmbnBoundingSet[i]); |
} |
} |
- return receiveInfo->TmmbnBoundingSet.lengthOfSet(); |
+ return receiveInfo->TmmbnBoundingSet.size(); |
} |
void RTCPReceiver::HandleSDES(RTCPUtility::RTCPParserV2& rtcpParser, |
@@ -1065,10 +1061,10 @@ void RTCPReceiver::HandleSR_REQ(RTCPUtility::RTCPParserV2& rtcpParser, |
void RTCPReceiver::HandleTMMBNItem(RTCPReceiveInformation& receiveInfo, |
const RTCPUtility::RTCPPacket& rtcpPacket) { |
- receiveInfo.TmmbnBoundingSet.AddEntry( |
- rtcpPacket.TMMBNItem.MaxTotalMediaBitRate, |
- rtcpPacket.TMMBNItem.MeasuredOverhead, |
- rtcpPacket.TMMBNItem.SSRC); |
+ receiveInfo.TmmbnBoundingSet.push_back( |
+ rtcp::TmmbItem(rtcpPacket.TMMBNItem.SSRC, |
+ rtcpPacket.TMMBNItem.MaxTotalMediaBitRate * 1000, |
+ rtcpPacket.TMMBNItem.MeasuredOverhead)); |
} |
void RTCPReceiver::HandleSLI(RTCPUtility::RTCPParserV2& rtcpParser, |
@@ -1232,44 +1228,35 @@ void RTCPReceiver::HandleTransportFeedback( |
rtcp_parser->Iterate(); |
} |
+ |
int32_t RTCPReceiver::UpdateTMMBR() { |
- int32_t numBoundingSet = 0; |
- uint32_t bitrate = 0; |
- uint32_t accNumCandidates = 0; |
- |
- int32_t size = TMMBRReceived(0, 0, NULL); |
- if (size > 0) { |
- TMMBRSet* candidateSet = VerifyAndAllocateCandidateSet(size); |
- // Get candidate set from receiver. |
- accNumCandidates = TMMBRReceived(size, accNumCandidates, candidateSet); |
- } else { |
- // Candidate set empty. |
- VerifyAndAllocateCandidateSet(0); // resets candidate set |
- } |
+ std::vector<rtcp::TmmbItem> candidates = TMMBRReceived(); |
// Find bounding set |
- TMMBRSet* boundingSet = NULL; |
- numBoundingSet = FindTMMBRBoundingSet(boundingSet); |
- if (numBoundingSet == -1) { |
- LOG(LS_WARNING) << "Failed to find TMMBR bounding set."; |
- return -1; |
- } |
+ FindTMMBRBoundingSet(&candidates); |
+ |
// Set bounding set |
// Inform remote clients about the new bandwidth |
// inform the remote client |
- _rtpRtcp.SetTMMBN(boundingSet); |
+ _rtpRtcp.SetTMMBN(&candidates); |
// might trigger a TMMBN |
- if (numBoundingSet == 0) { |
+ if (candidates.empty()) { |
// owner of max bitrate request has timed out |
// empty bounding set has been sent |
return 0; |
} |
- // Get net bitrate from bounding set depending on sent packet rate |
- if (CalcMinBitRate(&bitrate)) { |
- // we have a new bandwidth estimate on this channel |
- if (_cbRtcpBandwidthObserver) { |
- _cbRtcpBandwidthObserver->OnReceivedEstimatedBitrate(bitrate * 1000); |
+ if (_cbRtcpBandwidthObserver) { |
+ // Get net bitrate from bounding set depending on sent packet rate |
+ uint32_t min_bitrate_bps = std::numeric_limits<uint32_t>::max(); |
+ for (const rtcp::TmmbItem& entry : candidates) { |
+ if (min_bitrate_bps > entry.bitrate_bps()) { |
+ min_bitrate_bps = entry.bitrate_bps(); |
+ } |
} |
+ if (min_bitrate_bps < MIN_VIDEO_BW_MANAGEMENT_BITRATE * 1000) |
+ min_bitrate_bps = MIN_VIDEO_BW_MANAGEMENT_BITRATE * 1000; |
+ // we have a new bandwidth estimate on this channel |
+ _cbRtcpBandwidthObserver->OnReceivedEstimatedBitrate(min_bitrate_bps); |
} |
return 0; |
} |
@@ -1404,43 +1391,16 @@ int32_t RTCPReceiver::CNAME(uint32_t remoteSSRC, |
} |
// no callbacks allowed inside this function |
-int32_t RTCPReceiver::TMMBRReceived(uint32_t size, |
- uint32_t accNumCandidates, |
- TMMBRSet* candidateSet) const { |
+std::vector<rtcp::TmmbItem> RTCPReceiver::TMMBRReceived() const { |
rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
+ std::vector<rtcp::TmmbItem> candidates; |
- std::map<uint32_t, RTCPReceiveInformation*>::const_iterator |
- receiveInfoIt = _receivedInfoMap.begin(); |
- if (receiveInfoIt == _receivedInfoMap.end()) { |
- return -1; |
- } |
- uint32_t num = accNumCandidates; |
- if (candidateSet) { |
- while( num < size && receiveInfoIt != _receivedInfoMap.end()) { |
- RTCPReceiveInformation* receiveInfo = receiveInfoIt->second; |
- if (receiveInfo == NULL) { |
- return 0; |
- } |
- for (uint32_t i = 0; |
- (num < size) && (i < receiveInfo->TmmbrSet.lengthOfSet()); i++) { |
- if (receiveInfo->GetTMMBRSet(i, num, candidateSet, |
- _clock->TimeInMilliseconds()) == 0) { |
- num++; |
- } |
- } |
- receiveInfoIt++; |
- } |
- } else { |
- while (receiveInfoIt != _receivedInfoMap.end()) { |
- RTCPReceiveInformation* receiveInfo = receiveInfoIt->second; |
- if(receiveInfo == NULL) { |
- return -1; |
- } |
- num += receiveInfo->TmmbrSet.lengthOfSet(); |
- receiveInfoIt++; |
- } |
+ for (auto receive_info_it : _receivedInfoMap) { |
+ RTCPReceiveInformation* receive_info = receive_info_it.second; |
+ RTC_DCHECK(receive_info); |
+ receive_info->GetTMMBRSet(_clock->TimeInMilliseconds(), &candidates); |
} |
- return num; |
+ return candidates; |
} |
} // namespace webrtc |