TMMBRHelp moved from member object/base class to stack object,
indicating the usage of this helper is local. With local usage critical section become obvisously useless and removed. BUG=webrtc:5565 R=åsapersson Review-Url: https://codereview.webrtc.org/1959013003 Cr-Commit-Position: refs/heads/master@{#12881}
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/time_util.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h"
|
||||
#include "webrtc/system_wrappers/include/ntp_time.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -44,8 +45,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),
|
||||
@ -1233,22 +1233,20 @@ void RTCPReceiver::HandleTransportFeedback(
|
||||
rtcp_parser->Iterate();
|
||||
}
|
||||
int32_t RTCPReceiver::UpdateTMMBR() {
|
||||
TMMBRHelp tmmbr_help;
|
||||
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);
|
||||
TMMBRSet* candidateSet = tmmbr_help.VerifyAndAllocateCandidateSet(size);
|
||||
// Get candidate set from receiver.
|
||||
accNumCandidates = TMMBRReceived(size, accNumCandidates, candidateSet);
|
||||
} else {
|
||||
// Candidate set empty.
|
||||
VerifyAndAllocateCandidateSet(0); // resets candidate set
|
||||
}
|
||||
// Find bounding set
|
||||
TMMBRSet* boundingSet = NULL;
|
||||
numBoundingSet = FindTMMBRBoundingSet(boundingSet);
|
||||
numBoundingSet = tmmbr_help.FindTMMBRBoundingSet(boundingSet);
|
||||
if (numBoundingSet == -1) {
|
||||
LOG(LS_WARNING) << "Failed to find TMMBR bounding set.";
|
||||
return -1;
|
||||
@ -1265,7 +1263,7 @@ int32_t RTCPReceiver::UpdateTMMBR() {
|
||||
return 0;
|
||||
}
|
||||
// Get net bitrate from bounding set depending on sent packet rate
|
||||
if (CalcMinBitRate(&bitrate)) {
|
||||
if (tmmbr_help.CalcMinBitRate(&bitrate)) {
|
||||
// we have a new bandwidth estimate on this channel
|
||||
if (_cbRtcpBandwidthObserver) {
|
||||
_cbRtcpBandwidthObserver->OnReceivedEstimatedBitrate(bitrate * 1000);
|
||||
|
||||
@ -21,13 +21,12 @@
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
class ModuleRtpRtcpImpl;
|
||||
|
||||
class RTCPReceiver : public TMMBRHelp
|
||||
class RTCPReceiver
|
||||
{
|
||||
public:
|
||||
RTCPReceiver(Clock* clock,
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbr.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -169,7 +170,6 @@ RTCPSender::RTCPSender(
|
||||
|
||||
remb_bitrate_(0),
|
||||
|
||||
tmmbr_help_(),
|
||||
tmmbr_send_(0),
|
||||
packet_oh_send_(0),
|
||||
max_payload_length_(IP_PACKET_SIZE - 28), // IPv4 + UDP by default.
|
||||
@ -585,10 +585,11 @@ std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBR(
|
||||
// * If the sender is an owner of the TMMBN -> send TMMBR
|
||||
// * If not an owner but the TMMBR would enter the TMMBN -> send TMMBR
|
||||
|
||||
TMMBRHelp tmmbr_help;
|
||||
// get current bounding set from RTCP receiver
|
||||
bool tmmbrOwner = false;
|
||||
// store in candidateSet, allocates one extra slot
|
||||
TMMBRSet* candidateSet = tmmbr_help_.CandidateSet();
|
||||
TMMBRSet* candidateSet = tmmbr_help.CandidateSet();
|
||||
|
||||
// holding critical_section_rtcp_sender_ while calling RTCPreceiver which
|
||||
// will accuire criticalSectionRTCPReceiver_ is a potental deadlock but
|
||||
@ -613,9 +614,9 @@ std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBR(
|
||||
|
||||
// find bounding set
|
||||
TMMBRSet* boundingSet = nullptr;
|
||||
int numBoundingSet = tmmbr_help_.FindTMMBRBoundingSet(boundingSet);
|
||||
int numBoundingSet = tmmbr_help.FindTMMBRBoundingSet(boundingSet);
|
||||
if (numBoundingSet > 0 || numBoundingSet <= numCandidates)
|
||||
tmmbrOwner = tmmbr_help_.IsOwner(ssrc_, numBoundingSet);
|
||||
tmmbrOwner = tmmbr_help.IsOwner(ssrc_, numBoundingSet);
|
||||
if (!tmmbrOwner) {
|
||||
// Did not enter bounding set, no meaning to send this request.
|
||||
return nullptr;
|
||||
|
||||
@ -28,8 +28,8 @@
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h"
|
||||
#include "webrtc/transport.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
@ -240,7 +240,6 @@ class RTCPSender {
|
||||
uint32_t remb_bitrate_ GUARDED_BY(critical_section_rtcp_sender_);
|
||||
std::vector<uint32_t> remb_ssrcs_ GUARDED_BY(critical_section_rtcp_sender_);
|
||||
|
||||
TMMBRHelp tmmbr_help_ GUARDED_BY(critical_section_rtcp_sender_);
|
||||
std::vector<rtcp::TmmbItem> tmmbn_to_send_
|
||||
GUARDED_BY(critical_section_rtcp_sender_);
|
||||
uint32_t tmmbr_send_ GUARDED_BY(critical_section_rtcp_sender_);
|
||||
|
||||
@ -83,8 +83,6 @@ TMMBRHelp::~TMMBRHelp() {
|
||||
TMMBRSet*
|
||||
TMMBRHelp::VerifyAndAllocateBoundingSet(uint32_t minimumSize)
|
||||
{
|
||||
rtc::CritScope lock(&_criticalSection);
|
||||
|
||||
if(minimumSize > _boundingSet.capacity())
|
||||
{
|
||||
// make sure that our buffers are big enough
|
||||
@ -107,8 +105,6 @@ TMMBRSet* TMMBRHelp::BoundingSet() {
|
||||
TMMBRSet*
|
||||
TMMBRHelp::VerifyAndAllocateCandidateSet(uint32_t minimumSize)
|
||||
{
|
||||
rtc::CritScope lock(&_criticalSection);
|
||||
|
||||
_candidateSet.VerifyAndAllocateSet(minimumSize);
|
||||
return &_candidateSet;
|
||||
}
|
||||
@ -122,8 +118,6 @@ TMMBRHelp::CandidateSet()
|
||||
int32_t
|
||||
TMMBRHelp::FindTMMBRBoundingSet(TMMBRSet*& boundingSet)
|
||||
{
|
||||
rtc::CritScope lock(&_criticalSection);
|
||||
|
||||
// Work on local variable, will be modified
|
||||
TMMBRSet candidateSet;
|
||||
candidateSet.VerifyAndAllocateSet(_candidateSet.capacity());
|
||||
@ -165,8 +159,6 @@ TMMBRHelp::FindTMMBRBoundingSet(TMMBRSet*& boundingSet)
|
||||
int32_t
|
||||
TMMBRHelp::FindTMMBRBoundingSet(int32_t numCandidates, TMMBRSet& candidateSet)
|
||||
{
|
||||
rtc::CritScope lock(&_criticalSection);
|
||||
|
||||
uint32_t numBoundingSet = 0;
|
||||
VerifyAndAllocateBoundingSet(candidateSet.capacity());
|
||||
|
||||
@ -370,8 +362,6 @@ TMMBRHelp::FindTMMBRBoundingSet(int32_t numCandidates, TMMBRSet& candidateSet)
|
||||
|
||||
bool TMMBRHelp::IsOwner(const uint32_t ssrc,
|
||||
const uint32_t length) const {
|
||||
rtc::CritScope lock(&_criticalSection);
|
||||
|
||||
if (length == 0) {
|
||||
// Empty bounding set.
|
||||
return false;
|
||||
@ -386,8 +376,6 @@ bool TMMBRHelp::IsOwner(const uint32_t ssrc,
|
||||
}
|
||||
|
||||
bool TMMBRHelp::CalcMinBitRate( uint32_t* minBitrateKbit) const {
|
||||
rtc::CritScope lock(&_criticalSection);
|
||||
|
||||
if (_candidateSet.size() == 0) {
|
||||
// Empty bounding set.
|
||||
return false;
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_TMMBR_HELP_H_
|
||||
|
||||
#include <vector>
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
@ -76,7 +75,6 @@ protected:
|
||||
int32_t FindTMMBRBoundingSet(int32_t numCandidates, TMMBRSet& candidateSet);
|
||||
|
||||
private:
|
||||
rtc::CriticalSection _criticalSection;
|
||||
TMMBRSet _candidateSet;
|
||||
TMMBRSet _boundingSet;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user