Remove TMMBRSet class
by cleaning RTCPReceiveInfo class and following cleaning of RTCPReceiver::BoundingSet function. BUG=webrtc:5565 Review-Url: https://codereview.webrtc.org/2254703003 Cr-Commit-Position: refs/heads/master@{#13817}
This commit is contained in:
@ -107,8 +107,8 @@ int64_t RTCPReceiver::LastReceivedReceiverReport() const {
|
|||||||
int64_t last_received_rr = -1;
|
int64_t last_received_rr = -1;
|
||||||
for (ReceivedInfoMap::const_iterator it = _receivedInfoMap.begin();
|
for (ReceivedInfoMap::const_iterator it = _receivedInfoMap.begin();
|
||||||
it != _receivedInfoMap.end(); ++it) {
|
it != _receivedInfoMap.end(); ++it) {
|
||||||
if (it->second->lastTimeReceived > last_received_rr) {
|
if (it->second->last_time_received_ms > last_received_rr) {
|
||||||
last_received_rr = it->second->lastTimeReceived;
|
last_received_rr = it->second->last_time_received_ms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return last_received_rr;
|
return last_received_rr;
|
||||||
@ -445,7 +445,8 @@ RTCPReceiver::HandleSenderReceiverReport(RTCPUtility::RTCPParserV2& rtcpParser,
|
|||||||
|
|
||||||
rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRr;
|
rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRr;
|
||||||
}
|
}
|
||||||
UpdateReceiveInformation(*ptrReceiveInfo);
|
// Update that this remote is alive.
|
||||||
|
ptrReceiveInfo->last_time_received_ms = _clock->TimeInMilliseconds();
|
||||||
|
|
||||||
rtcpPacketType = rtcpParser.Iterate();
|
rtcpPacketType = rtcpParser.Iterate();
|
||||||
|
|
||||||
@ -639,12 +640,6 @@ RTCPReceiver::GetReceiveInformation(uint32_t remoteSSRC) {
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTCPReceiver::UpdateReceiveInformation(
|
|
||||||
RTCPReceiveInformation& receiveInformation) {
|
|
||||||
// Update that this remote is alive
|
|
||||||
receiveInformation.lastTimeReceived = _clock->TimeInMilliseconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RTCPReceiver::RtcpRrTimeout(int64_t rtcp_interval_ms) {
|
bool RTCPReceiver::RtcpRrTimeout(int64_t rtcp_interval_ms) {
|
||||||
rtc::CritScope lock(&_criticalSectionRTCPReceiver);
|
rtc::CritScope lock(&_criticalSectionRTCPReceiver);
|
||||||
if (_lastReceivedRrMs == 0)
|
if (_lastReceivedRrMs == 0)
|
||||||
@ -691,20 +686,20 @@ bool RTCPReceiver::UpdateRTCPReceiveInformationTimers() {
|
|||||||
// time since last received rtcp packet
|
// time since last received rtcp packet
|
||||||
// when we dont have a lastTimeReceived and the object is marked
|
// when we dont have a lastTimeReceived and the object is marked
|
||||||
// readyForDelete it's removed from the map
|
// readyForDelete it's removed from the map
|
||||||
if (receiveInfo->lastTimeReceived) {
|
if (receiveInfo->last_time_received_ms > 0) {
|
||||||
/// use audio define since we don't know what interval the remote peer is
|
/// use audio define since we don't know what interval the remote peer is
|
||||||
// using
|
// using
|
||||||
if ((timeNow - receiveInfo->lastTimeReceived) >
|
if ((timeNow - receiveInfo->last_time_received_ms) >
|
||||||
5 * RTCP_INTERVAL_AUDIO_MS) {
|
5 * RTCP_INTERVAL_AUDIO_MS) {
|
||||||
// no rtcp packet for the last five regular intervals, reset limitations
|
// no rtcp packet for the last five regular intervals, reset limitations
|
||||||
receiveInfo->TmmbrSet.clearSet();
|
receiveInfo->ClearTmmbr();
|
||||||
// prevent that we call this over and over again
|
// prevent that we call this over and over again
|
||||||
receiveInfo->lastTimeReceived = 0;
|
receiveInfo->last_time_received_ms = 0;
|
||||||
// send new TMMBN to all channels using the default codec
|
// send new TMMBN to all channels using the default codec
|
||||||
updateBoundingSet = true;
|
updateBoundingSet = true;
|
||||||
}
|
}
|
||||||
receiveInfoIt++;
|
receiveInfoIt++;
|
||||||
} else if (receiveInfo->readyForDelete) {
|
} else if (receiveInfo->ready_for_delete) {
|
||||||
// store our current receiveInfoItem
|
// store our current receiveInfoItem
|
||||||
std::map<uint32_t, RTCPReceiveInformation*>::iterator
|
std::map<uint32_t, RTCPReceiveInformation*>::iterator
|
||||||
receiveInfoItemToBeErased = receiveInfoIt;
|
receiveInfoItemToBeErased = receiveInfoIt;
|
||||||
@ -718,35 +713,20 @@ bool RTCPReceiver::UpdateRTCPReceiveInformationTimers() {
|
|||||||
return updateBoundingSet;
|
return updateBoundingSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t RTCPReceiver::BoundingSet(bool* tmmbrOwner, TMMBRSet* boundingSetRec) {
|
std::vector<rtcp::TmmbItem> RTCPReceiver::BoundingSet(bool* tmmbr_owner) {
|
||||||
rtc::CritScope lock(&_criticalSectionRTCPReceiver);
|
rtc::CritScope lock(&_criticalSectionRTCPReceiver);
|
||||||
|
|
||||||
std::map<uint32_t, RTCPReceiveInformation*>::iterator receiveInfoIt =
|
std::map<uint32_t, RTCPReceiveInformation*>::iterator receiveInfoIt =
|
||||||
_receivedInfoMap.find(_remoteSSRC);
|
_receivedInfoMap.find(_remoteSSRC);
|
||||||
|
|
||||||
if (receiveInfoIt == _receivedInfoMap.end()) {
|
if (receiveInfoIt == _receivedInfoMap.end()) {
|
||||||
return -1;
|
return std::vector<rtcp::TmmbItem>();
|
||||||
}
|
}
|
||||||
RTCPReceiveInformation* receiveInfo = receiveInfoIt->second;
|
RTCPReceiveInformation* receiveInfo = receiveInfoIt->second;
|
||||||
if (receiveInfo == NULL) {
|
RTC_DCHECK(receiveInfo);
|
||||||
return -1;
|
|
||||||
}
|
*tmmbr_owner = TMMBRHelp::IsOwner(receiveInfo->tmmbn, main_ssrc_);
|
||||||
if (receiveInfo->TmmbnBoundingSet.lengthOfSet() > 0) {
|
return receiveInfo->tmmbn;
|
||||||
boundingSetRec->VerifyAndAllocateSet(
|
|
||||||
receiveInfo->TmmbnBoundingSet.lengthOfSet() + 1);
|
|
||||||
for(uint32_t i=0; i< receiveInfo->TmmbnBoundingSet.lengthOfSet();
|
|
||||||
i++) {
|
|
||||||
if(receiveInfo->TmmbnBoundingSet.Ssrc(i) == main_ssrc_) {
|
|
||||||
// owner of bounding set
|
|
||||||
*tmmbrOwner = true;
|
|
||||||
}
|
|
||||||
boundingSetRec->SetEntry(i,
|
|
||||||
receiveInfo->TmmbnBoundingSet.Tmmbr(i),
|
|
||||||
receiveInfo->TmmbnBoundingSet.PacketOH(i),
|
|
||||||
receiveInfo->TmmbnBoundingSet.Ssrc(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return receiveInfo->TmmbnBoundingSet.lengthOfSet();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTCPReceiver::HandleSDES(RTCPUtility::RTCPParserV2& rtcpParser,
|
void RTCPReceiver::HandleSDES(RTCPUtility::RTCPParserV2& rtcpParser,
|
||||||
@ -838,7 +818,7 @@ void RTCPReceiver::HandleBYE(RTCPUtility::RTCPParserV2& rtcpParser) {
|
|||||||
_receivedInfoMap.find(rtcpPacket.BYE.SenderSSRC);
|
_receivedInfoMap.find(rtcpPacket.BYE.SenderSSRC);
|
||||||
|
|
||||||
if (receiveInfoIt != _receivedInfoMap.end()) {
|
if (receiveInfoIt != _receivedInfoMap.end()) {
|
||||||
receiveInfoIt->second->readyForDelete = true;
|
receiveInfoIt->second->ready_for_delete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<uint32_t, RTCPCnameInformation*>::iterator cnameInfoIt =
|
std::map<uint32_t, RTCPCnameInformation*>::iterator cnameInfoIt =
|
||||||
@ -1007,7 +987,6 @@ void RTCPReceiver::HandleTMMBR(RTCPUtility::RTCPParserV2& rtcpParser,
|
|||||||
rtcpParser.Iterate();
|
rtcpParser.Iterate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ptrReceiveInfo->VerifyAndAllocateTMMBRSet((uint32_t)maxNumOfTMMBRBlocks);
|
|
||||||
|
|
||||||
RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
|
RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
|
||||||
while (pktType == RTCPPacketTypes::kRtpfbTmmbrItem) {
|
while (pktType == RTCPPacketTypes::kRtpfbTmmbrItem) {
|
||||||
@ -1022,7 +1001,11 @@ void RTCPReceiver::HandleTMMBRItem(RTCPReceiveInformation& receiveInfo,
|
|||||||
uint32_t senderSSRC) {
|
uint32_t senderSSRC) {
|
||||||
if (main_ssrc_ == rtcpPacket.TMMBRItem.SSRC &&
|
if (main_ssrc_ == rtcpPacket.TMMBRItem.SSRC &&
|
||||||
rtcpPacket.TMMBRItem.MaxTotalMediaBitRate > 0) {
|
rtcpPacket.TMMBRItem.MaxTotalMediaBitRate > 0) {
|
||||||
receiveInfo.InsertTMMBRItem(senderSSRC, rtcpPacket.TMMBRItem,
|
receiveInfo.InsertTmmbrItem(
|
||||||
|
senderSSRC,
|
||||||
|
rtcp::TmmbItem(rtcpPacket.TMMBRItem.SSRC,
|
||||||
|
rtcpPacket.TMMBRItem.MaxTotalMediaBitRate * 1000,
|
||||||
|
rtcpPacket.TMMBRItem.MeasuredOverhead),
|
||||||
_clock->TimeInMilliseconds());
|
_clock->TimeInMilliseconds());
|
||||||
rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpTmmbr;
|
rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpTmmbr;
|
||||||
}
|
}
|
||||||
@ -1050,8 +1033,6 @@ void RTCPReceiver::HandleTMMBN(RTCPUtility::RTCPParserV2& rtcpParser,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptrReceiveInfo->VerifyAndAllocateBoundingSet((uint32_t)maxNumOfTMMBNBlocks);
|
|
||||||
|
|
||||||
RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
|
RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
|
||||||
while (pktType == RTCPPacketTypes::kRtpfbTmmbnItem) {
|
while (pktType == RTCPPacketTypes::kRtpfbTmmbnItem) {
|
||||||
HandleTMMBNItem(*ptrReceiveInfo, rtcpPacket);
|
HandleTMMBNItem(*ptrReceiveInfo, rtcpPacket);
|
||||||
@ -1067,10 +1048,10 @@ void RTCPReceiver::HandleSR_REQ(RTCPUtility::RTCPParserV2& rtcpParser,
|
|||||||
|
|
||||||
void RTCPReceiver::HandleTMMBNItem(RTCPReceiveInformation& receiveInfo,
|
void RTCPReceiver::HandleTMMBNItem(RTCPReceiveInformation& receiveInfo,
|
||||||
const RTCPUtility::RTCPPacket& rtcpPacket) {
|
const RTCPUtility::RTCPPacket& rtcpPacket) {
|
||||||
receiveInfo.TmmbnBoundingSet.AddEntry(
|
receiveInfo.tmmbn.emplace_back(
|
||||||
rtcpPacket.TMMBNItem.MaxTotalMediaBitRate,
|
rtcpPacket.TMMBNItem.SSRC,
|
||||||
rtcpPacket.TMMBNItem.MeasuredOverhead,
|
rtcpPacket.TMMBNItem.MaxTotalMediaBitRate * 1000,
|
||||||
rtcpPacket.TMMBNItem.SSRC);
|
rtcpPacket.TMMBNItem.MeasuredOverhead);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTCPReceiver::HandleSLI(RTCPUtility::RTCPParserV2& rtcpParser,
|
void RTCPReceiver::HandleSLI(RTCPUtility::RTCPParserV2& rtcpParser,
|
||||||
@ -1186,12 +1167,12 @@ void RTCPReceiver::HandleFIRItem(RTCPReceiveInformation* receiveInfo,
|
|||||||
if (receiveInfo) {
|
if (receiveInfo) {
|
||||||
// check if we have reported this FIRSequenceNumber before
|
// check if we have reported this FIRSequenceNumber before
|
||||||
if (rtcpPacket.FIRItem.CommandSequenceNumber !=
|
if (rtcpPacket.FIRItem.CommandSequenceNumber !=
|
||||||
receiveInfo->lastFIRSequenceNumber) {
|
receiveInfo->last_fir_sequence_number) {
|
||||||
int64_t now = _clock->TimeInMilliseconds();
|
int64_t now = _clock->TimeInMilliseconds();
|
||||||
// sanity; don't go crazy with the callbacks
|
// sanity; don't go crazy with the callbacks
|
||||||
if ((now - receiveInfo->lastFIRRequest) > RTCP_MIN_FRAME_LENGTH_MS) {
|
if ((now - receiveInfo->last_fir_request_ms) > RTCP_MIN_FRAME_LENGTH_MS) {
|
||||||
receiveInfo->lastFIRRequest = now;
|
receiveInfo->last_fir_request_ms = now;
|
||||||
receiveInfo->lastFIRSequenceNumber =
|
receiveInfo->last_fir_sequence_number =
|
||||||
rtcpPacket.FIRItem.CommandSequenceNumber;
|
rtcpPacket.FIRItem.CommandSequenceNumber;
|
||||||
// received signal that we need to send a new key frame
|
// received signal that we need to send a new key frame
|
||||||
rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpFir;
|
rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpFir;
|
||||||
@ -1402,7 +1383,7 @@ std::vector<rtcp::TmmbItem> RTCPReceiver::TMMBRReceived() const {
|
|||||||
for (const auto& kv : _receivedInfoMap) {
|
for (const auto& kv : _receivedInfoMap) {
|
||||||
RTCPReceiveInformation* receive_info = kv.second;
|
RTCPReceiveInformation* receive_info = kv.second;
|
||||||
RTC_DCHECK(receive_info);
|
RTC_DCHECK(receive_info);
|
||||||
receive_info->GetTMMBRSet(now_ms, &candidates);
|
receive_info->GetTmmbrSet(now_ms, &candidates);
|
||||||
}
|
}
|
||||||
return candidates;
|
return candidates;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -96,7 +96,7 @@ public:
|
|||||||
|
|
||||||
bool UpdateRTCPReceiveInformationTimers();
|
bool UpdateRTCPReceiveInformationTimers();
|
||||||
|
|
||||||
int32_t BoundingSet(bool* tmmbrOwner, TMMBRSet* boundingSetRec);
|
std::vector<rtcp::TmmbItem> BoundingSet(bool* tmmbr_owner);
|
||||||
|
|
||||||
int32_t UpdateTMMBR();
|
int32_t UpdateTMMBR();
|
||||||
|
|
||||||
@ -112,9 +112,6 @@ protected:
|
|||||||
uint32_t remoteSSRC);
|
uint32_t remoteSSRC);
|
||||||
RTCPHelp::RTCPReceiveInformation* GetReceiveInformation(uint32_t remoteSSRC);
|
RTCPHelp::RTCPReceiveInformation* GetReceiveInformation(uint32_t remoteSSRC);
|
||||||
|
|
||||||
void UpdateReceiveInformation(
|
|
||||||
RTCPHelp::RTCPReceiveInformation& receiveInformation);
|
|
||||||
|
|
||||||
void HandleSenderReceiverReport(
|
void HandleSenderReceiverReport(
|
||||||
RTCPUtility::RTCPParserV2& rtcpParser,
|
RTCPUtility::RTCPParserV2& rtcpParser,
|
||||||
RTCPHelp::RTCPPacketInformation& rtcpPacketInformation)
|
RTCPHelp::RTCPPacketInformation& rtcpPacketInformation)
|
||||||
|
|||||||
@ -115,72 +115,38 @@ RTCPReportBlockInformation::~RTCPReportBlockInformation()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
RTCPReceiveInformation::RTCPReceiveInformation()
|
RTCPReceiveInformation::RTCPReceiveInformation() = default;
|
||||||
: lastTimeReceived(0),
|
RTCPReceiveInformation::~RTCPReceiveInformation() = default;
|
||||||
lastFIRSequenceNumber(-1),
|
|
||||||
lastFIRRequest(0),
|
void RTCPReceiveInformation::InsertTmmbrItem(uint32_t sender_ssrc,
|
||||||
readyForDelete(false) {
|
const rtcp::TmmbItem& tmmbr_item,
|
||||||
|
int64_t current_time_ms) {
|
||||||
|
TimedTmmbrItem* entry = &tmmbr_[sender_ssrc];
|
||||||
|
entry->tmmbr_item = rtcp::TmmbItem(sender_ssrc,
|
||||||
|
tmmbr_item.bitrate_bps(),
|
||||||
|
tmmbr_item.packet_overhead());
|
||||||
|
entry->last_updated_ms = current_time_ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
RTCPReceiveInformation::~RTCPReceiveInformation() {
|
void RTCPReceiveInformation::GetTmmbrSet(
|
||||||
}
|
|
||||||
|
|
||||||
// Increase size of TMMBRSet if needed, and also take care of
|
|
||||||
// the _tmmbrSetTimeouts vector.
|
|
||||||
void RTCPReceiveInformation::VerifyAndAllocateTMMBRSet(
|
|
||||||
const uint32_t minimumSize) {
|
|
||||||
if (minimumSize > TmmbrSet.sizeOfSet()) {
|
|
||||||
TmmbrSet.VerifyAndAllocateSetKeepingData(minimumSize);
|
|
||||||
// make sure that our buffers are big enough
|
|
||||||
_tmmbrSetTimeouts.reserve(minimumSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RTCPReceiveInformation::InsertTMMBRItem(
|
|
||||||
const uint32_t senderSSRC,
|
|
||||||
const RTCPUtility::RTCPPacketRTPFBTMMBRItem& TMMBRItem,
|
|
||||||
const int64_t currentTimeMS) {
|
|
||||||
// serach to see if we have it in our list
|
|
||||||
for (uint32_t i = 0; i < TmmbrSet.lengthOfSet(); i++) {
|
|
||||||
if (TmmbrSet.Ssrc(i) == senderSSRC) {
|
|
||||||
// we already have this SSRC in our list update it
|
|
||||||
TmmbrSet.SetEntry(i,
|
|
||||||
TMMBRItem.MaxTotalMediaBitRate,
|
|
||||||
TMMBRItem.MeasuredOverhead,
|
|
||||||
senderSSRC);
|
|
||||||
_tmmbrSetTimeouts[i] = currentTimeMS;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
VerifyAndAllocateTMMBRSet(TmmbrSet.lengthOfSet() + 1);
|
|
||||||
TmmbrSet.AddEntry(TMMBRItem.MaxTotalMediaBitRate,
|
|
||||||
TMMBRItem.MeasuredOverhead,
|
|
||||||
senderSSRC);
|
|
||||||
_tmmbrSetTimeouts.push_back(currentTimeMS);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RTCPReceiveInformation::GetTMMBRSet(
|
|
||||||
int64_t current_time_ms,
|
int64_t current_time_ms,
|
||||||
std::vector<rtcp::TmmbItem>* candidates) {
|
std::vector<rtcp::TmmbItem>* candidates) {
|
||||||
|
// Use audio define since we don't know what interval the remote peer use.
|
||||||
|
int64_t timeouted_ms = current_time_ms - 5 * RTCP_INTERVAL_AUDIO_MS;
|
||||||
|
for (auto it = tmmbr_.begin(); it != tmmbr_.end();) {
|
||||||
|
if (it->second.last_updated_ms < timeouted_ms) {
|
||||||
// Erase timeout entries.
|
// Erase timeout entries.
|
||||||
for (size_t source_idx = 0; source_idx < TmmbrSet.size();) {
|
it = tmmbr_.erase(it);
|
||||||
// Use audio define since we don't know what interval the remote peer is
|
} else {
|
||||||
// using.
|
candidates->push_back(it->second.tmmbr_item);
|
||||||
if (current_time_ms - _tmmbrSetTimeouts[source_idx] >
|
++it;
|
||||||
5 * RTCP_INTERVAL_AUDIO_MS) {
|
|
||||||
// Value timed out.
|
|
||||||
TmmbrSet.erase(TmmbrSet.begin() + source_idx);
|
|
||||||
_tmmbrSetTimeouts.erase(_tmmbrSetTimeouts.begin() + source_idx);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
candidates->push_back(TmmbrSet[source_idx]);
|
|
||||||
++source_idx;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTCPReceiveInformation::VerifyAndAllocateBoundingSet(
|
void RTCPReceiveInformation::ClearTmmbr() {
|
||||||
const uint32_t minimumSize) {
|
tmmbr_.clear();
|
||||||
TmmbnBoundingSet.VerifyAndAllocateSet(minimumSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace RTCPHelp
|
} // namespace RTCPHelp
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@ -12,12 +12,12 @@
|
|||||||
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_HELP_H_
|
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_HELP_H_
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "webrtc/base/constructormagic.h"
|
#include "webrtc/base/constructormagic.h"
|
||||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" // RTCPReportBlock
|
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
|
|
||||||
#include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h"
|
#include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h"
|
||||||
#include "webrtc/typedefs.h"
|
#include "webrtc/typedefs.h"
|
||||||
|
|
||||||
@ -95,38 +95,36 @@ private:
|
|||||||
RTC_DISALLOW_COPY_AND_ASSIGN(RTCPPacketInformation);
|
RTC_DISALLOW_COPY_AND_ASSIGN(RTCPPacketInformation);
|
||||||
};
|
};
|
||||||
|
|
||||||
class RTCPReceiveInformation
|
class RTCPReceiveInformation {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
RTCPReceiveInformation();
|
RTCPReceiveInformation();
|
||||||
~RTCPReceiveInformation();
|
~RTCPReceiveInformation();
|
||||||
|
|
||||||
void VerifyAndAllocateBoundingSet(const uint32_t minimumSize);
|
void InsertTmmbrItem(uint32_t sender_ssrc,
|
||||||
void VerifyAndAllocateTMMBRSet(const uint32_t minimumSize);
|
const rtcp::TmmbItem& tmmbr_item,
|
||||||
|
int64_t current_time_ms);
|
||||||
|
|
||||||
void InsertTMMBRItem(const uint32_t senderSSRC,
|
void GetTmmbrSet(int64_t current_time_ms,
|
||||||
const RTCPUtility::RTCPPacketRTPFBTMMBRItem& TMMBRItem,
|
|
||||||
const int64_t currentTimeMS);
|
|
||||||
|
|
||||||
// get
|
|
||||||
void GetTMMBRSet(int64_t current_time_ms,
|
|
||||||
std::vector<rtcp::TmmbItem>* candidates);
|
std::vector<rtcp::TmmbItem>* candidates);
|
||||||
|
|
||||||
int64_t lastTimeReceived;
|
void ClearTmmbr();
|
||||||
|
|
||||||
// FIR
|
int64_t last_time_received_ms = 0;
|
||||||
int32_t lastFIRSequenceNumber;
|
|
||||||
int64_t lastFIRRequest;
|
|
||||||
|
|
||||||
// TMMBN
|
int32_t last_fir_sequence_number = -1;
|
||||||
TMMBRSet TmmbnBoundingSet;
|
int64_t last_fir_request_ms = 0;
|
||||||
|
|
||||||
// TMMBR
|
bool ready_for_delete = false;
|
||||||
TMMBRSet TmmbrSet;
|
|
||||||
|
|
||||||
bool readyForDelete;
|
std::vector<rtcp::TmmbItem> tmmbn;
|
||||||
private:
|
|
||||||
std::vector<int64_t> _tmmbrSetTimeouts;
|
private:
|
||||||
|
struct TimedTmmbrItem {
|
||||||
|
rtcp::TmmbItem tmmbr_item;
|
||||||
|
int64_t last_updated_ms;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::map<uint32_t, TimedTmmbrItem> tmmbr_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace RTCPHelp
|
} // end namespace RTCPHelp
|
||||||
|
|||||||
@ -172,7 +172,7 @@ RTCPSender::RTCPSender(
|
|||||||
|
|
||||||
remb_bitrate_(0),
|
remb_bitrate_(0),
|
||||||
|
|
||||||
tmmbr_send_(0),
|
tmmbr_send_bps_(0),
|
||||||
packet_oh_send_(0),
|
packet_oh_send_(0),
|
||||||
max_payload_length_(IP_PACKET_SIZE - 28), // IPv4 + UDP by default.
|
max_payload_length_(IP_PACKET_SIZE - 28), // IPv4 + UDP by default.
|
||||||
|
|
||||||
@ -577,7 +577,7 @@ std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildREMB(
|
|||||||
|
|
||||||
void RTCPSender::SetTargetBitrate(unsigned int target_bitrate) {
|
void RTCPSender::SetTargetBitrate(unsigned int target_bitrate) {
|
||||||
rtc::CritScope lock(&critical_section_rtcp_sender_);
|
rtc::CritScope lock(&critical_section_rtcp_sender_);
|
||||||
tmmbr_send_ = target_bitrate / 1000;
|
tmmbr_send_bps_ = target_bitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBR(
|
std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBR(
|
||||||
@ -590,48 +590,46 @@ std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBR(
|
|||||||
// * If not an owner but the TMMBR would enter the TMMBN -> send TMMBR
|
// * If not an owner but the TMMBR would enter the TMMBN -> send TMMBR
|
||||||
|
|
||||||
// get current bounding set from RTCP receiver
|
// get current bounding set from RTCP receiver
|
||||||
bool tmmbrOwner = false;
|
bool tmmbr_owner = false;
|
||||||
TMMBRSet candidates;
|
|
||||||
|
|
||||||
// holding critical_section_rtcp_sender_ while calling RTCPreceiver which
|
// holding critical_section_rtcp_sender_ while calling RTCPreceiver which
|
||||||
// will accuire criticalSectionRTCPReceiver_ is a potental deadlock but
|
// will accuire criticalSectionRTCPReceiver_ is a potental deadlock but
|
||||||
// since RTCPreceiver is not doing the reverse we should be fine
|
// since RTCPreceiver is not doing the reverse we should be fine
|
||||||
int32_t lengthOfBoundingSet =
|
std::vector<rtcp::TmmbItem> candidates =
|
||||||
ctx.feedback_state_.module->BoundingSet(&tmmbrOwner, &candidates);
|
ctx.feedback_state_.module->BoundingSet(&tmmbr_owner);
|
||||||
|
|
||||||
if (lengthOfBoundingSet > 0) {
|
if (!candidates.empty()) {
|
||||||
for (int32_t i = 0; i < lengthOfBoundingSet; i++) {
|
for (const auto& candidate : candidates) {
|
||||||
if (candidates.Tmmbr(i) == tmmbr_send_ &&
|
if (candidate.bitrate_bps() == tmmbr_send_bps_ &&
|
||||||
candidates.PacketOH(i) == packet_oh_send_) {
|
candidate.packet_overhead() == packet_oh_send_) {
|
||||||
// Do not send the same tuple.
|
// Do not send the same tuple.
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!tmmbrOwner) {
|
if (!tmmbr_owner) {
|
||||||
// use received bounding set as candidate set
|
// Use received bounding set as candidate set.
|
||||||
// add current tuple
|
// Add current tuple.
|
||||||
candidates.SetEntry(lengthOfBoundingSet, tmmbr_send_, packet_oh_send_,
|
candidates.emplace_back(ssrc_, tmmbr_send_bps_, packet_oh_send_);
|
||||||
ssrc_);
|
|
||||||
|
|
||||||
// find bounding set
|
// Find bounding set.
|
||||||
std::vector<rtcp::TmmbItem> bounding =
|
std::vector<rtcp::TmmbItem> bounding =
|
||||||
TMMBRHelp::FindBoundingSet(std::move(candidates));
|
TMMBRHelp::FindBoundingSet(std::move(candidates));
|
||||||
tmmbrOwner = TMMBRHelp::IsOwner(bounding, ssrc_);
|
tmmbr_owner = TMMBRHelp::IsOwner(bounding, ssrc_);
|
||||||
if (!tmmbrOwner) {
|
if (!tmmbr_owner) {
|
||||||
// Did not enter bounding set, no meaning to send this request.
|
// Did not enter bounding set, no meaning to send this request.
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tmmbr_send_)
|
if (!tmmbr_send_bps_)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
rtcp::Tmmbr* tmmbr = new rtcp::Tmmbr();
|
rtcp::Tmmbr* tmmbr = new rtcp::Tmmbr();
|
||||||
tmmbr->From(ssrc_);
|
tmmbr->From(ssrc_);
|
||||||
rtcp::TmmbItem request;
|
rtcp::TmmbItem request;
|
||||||
request.set_ssrc(remote_ssrc_);
|
request.set_ssrc(remote_ssrc_);
|
||||||
request.set_bitrate_bps(tmmbr_send_ * 1000);
|
request.set_bitrate_bps(tmmbr_send_bps_);
|
||||||
request.set_packet_overhead(packet_oh_send_);
|
request.set_packet_overhead(packet_oh_send_);
|
||||||
tmmbr->WithTmmbr(request);
|
tmmbr->WithTmmbr(request);
|
||||||
|
|
||||||
|
|||||||
@ -241,7 +241,7 @@ class RTCPSender {
|
|||||||
|
|
||||||
std::vector<rtcp::TmmbItem> tmmbn_to_send_
|
std::vector<rtcp::TmmbItem> tmmbn_to_send_
|
||||||
GUARDED_BY(critical_section_rtcp_sender_);
|
GUARDED_BY(critical_section_rtcp_sender_);
|
||||||
uint32_t tmmbr_send_ GUARDED_BY(critical_section_rtcp_sender_);
|
uint32_t tmmbr_send_bps_ GUARDED_BY(critical_section_rtcp_sender_);
|
||||||
uint32_t packet_oh_send_ GUARDED_BY(critical_section_rtcp_sender_);
|
uint32_t packet_oh_send_ GUARDED_BY(critical_section_rtcp_sender_);
|
||||||
size_t max_payload_length_;
|
size_t max_payload_length_;
|
||||||
|
|
||||||
|
|||||||
@ -925,9 +925,8 @@ bool ModuleRtpRtcpImpl::UpdateRTCPReceiveInformationTimers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Called from RTCPsender.
|
// Called from RTCPsender.
|
||||||
int32_t ModuleRtpRtcpImpl::BoundingSet(bool* tmmbr_owner,
|
std::vector<rtcp::TmmbItem> ModuleRtpRtcpImpl::BoundingSet(bool* tmmbr_owner) {
|
||||||
TMMBRSet* bounding_set) {
|
return rtcp_receiver_.BoundingSet(tmmbr_owner);
|
||||||
return rtcp_receiver_.BoundingSet(tmmbr_owner, bounding_set);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t ModuleRtpRtcpImpl::RtcpReportInterval() {
|
int64_t ModuleRtpRtcpImpl::RtcpReportInterval() {
|
||||||
|
|||||||
@ -297,7 +297,7 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
|
|||||||
|
|
||||||
bool LastReceivedXrReferenceTimeInfo(RtcpReceiveTimeInfo* info) const;
|
bool LastReceivedXrReferenceTimeInfo(RtcpReceiveTimeInfo* info) const;
|
||||||
|
|
||||||
int32_t BoundingSet(bool* tmmbr_owner, TMMBRSet* bounding_set_rec);
|
std::vector<rtcp::TmmbItem> BoundingSet(bool* tmmbr_owner);
|
||||||
|
|
||||||
void BitrateSent(uint32_t* total_rate,
|
void BitrateSent(uint32_t* total_rate,
|
||||||
uint32_t* video_rate,
|
uint32_t* video_rate,
|
||||||
|
|||||||
@ -16,40 +16,6 @@
|
|||||||
#include "webrtc/base/checks.h"
|
#include "webrtc/base/checks.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
void TMMBRSet::VerifyAndAllocateSet(uint32_t minimumSize) {
|
|
||||||
clear();
|
|
||||||
reserve(minimumSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TMMBRSet::VerifyAndAllocateSetKeepingData(uint32_t minimumSize) {
|
|
||||||
reserve(minimumSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TMMBRSet::SetEntry(unsigned int i,
|
|
||||||
uint32_t tmmbrSet,
|
|
||||||
uint32_t packetOHSet,
|
|
||||||
uint32_t ssrcSet) {
|
|
||||||
RTC_DCHECK_LT(i, capacity());
|
|
||||||
if (i >= size()) {
|
|
||||||
resize(i + 1);
|
|
||||||
}
|
|
||||||
(*this)[i].set_bitrate_bps(tmmbrSet * 1000);
|
|
||||||
(*this)[i].set_packet_overhead(packetOHSet);
|
|
||||||
(*this)[i].set_ssrc(ssrcSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TMMBRSet::AddEntry(uint32_t tmmbrSet,
|
|
||||||
uint32_t packetOHSet,
|
|
||||||
uint32_t ssrcSet) {
|
|
||||||
RTC_DCHECK_LT(size(), capacity());
|
|
||||||
SetEntry(size(), tmmbrSet, packetOHSet, ssrcSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TMMBRSet::RemoveEntry(uint32_t sourceIdx) {
|
|
||||||
RTC_DCHECK_LT(sourceIdx, size());
|
|
||||||
erase(begin() + sourceIdx);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<rtcp::TmmbItem> TMMBRHelp::FindBoundingSet(
|
std::vector<rtcp::TmmbItem> TMMBRHelp::FindBoundingSet(
|
||||||
std::vector<rtcp::TmmbItem> candidates) {
|
std::vector<rtcp::TmmbItem> candidates) {
|
||||||
// Filter out candidates with 0 bitrate.
|
// Filter out candidates with 0 bitrate.
|
||||||
|
|||||||
@ -16,28 +16,6 @@
|
|||||||
#include "webrtc/typedefs.h"
|
#include "webrtc/typedefs.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
class TMMBRSet : public std::vector<rtcp::TmmbItem> {
|
|
||||||
public:
|
|
||||||
void VerifyAndAllocateSet(uint32_t minimumSize);
|
|
||||||
void VerifyAndAllocateSetKeepingData(uint32_t minimumSize);
|
|
||||||
// Number of valid data items in set.
|
|
||||||
uint32_t lengthOfSet() const { return size(); }
|
|
||||||
// Presently allocated max size of set.
|
|
||||||
uint32_t sizeOfSet() const { return capacity(); }
|
|
||||||
void clearSet() { clear(); }
|
|
||||||
uint32_t Tmmbr(int i) const { return (*this)[i].bitrate_bps() / 1000; }
|
|
||||||
uint32_t PacketOH(int i) const { return (*this)[i].packet_overhead(); }
|
|
||||||
uint32_t Ssrc(int i) const { return (*this)[i].ssrc(); }
|
|
||||||
void SetEntry(unsigned int i,
|
|
||||||
uint32_t tmmbrSet,
|
|
||||||
uint32_t packetOHSet,
|
|
||||||
uint32_t ssrcSet);
|
|
||||||
|
|
||||||
void AddEntry(uint32_t tmmbrSet, uint32_t packetOHSet, uint32_t ssrcSet);
|
|
||||||
|
|
||||||
// Remove one entry from table, and move all others down.
|
|
||||||
void RemoveEntry(uint32_t sourceIdx);
|
|
||||||
};
|
|
||||||
|
|
||||||
class TMMBRHelp {
|
class TMMBRHelp {
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user