webrtc/src/modules/rtp_rtcp/source/bandwidth_management.h
pwestin@webrtc.org 1da1ce0da5 First implementation of simulcast, adds VP8 simulcast to video engine.
Changed API to RTP module
Expanded Auto test with a test for simulcast
Made the video codec tests compile
Added the vp8_simulcast files to this cl
Added missing auto test file
Review URL: http://webrtc-codereview.appspot.com/188001

git-svn-id: http://webrtc.googlecode.com/svn/trunk@736 4adac7df-926f-26a2-2b94-8c16560cd09d
2011-10-13 15:19:55 +00:00

85 lines
2.9 KiB
C++

/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_BANDWIDTH_MANAGEMENT_H_
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_BANDWIDTH_MANAGEMENT_H_
#include "typedefs.h"
#include "rtp_rtcp_config.h"
#include "critical_section_wrapper.h"
/*
* FEC and NACK added bitrate is handled outside class
*/
namespace webrtc {
class BandwidthManagement
{
public:
BandwidthManagement(const WebRtc_Word32 id);
~BandwidthManagement();
// Call when we receive a RTCP message with TMMBR or REMB
WebRtc_Word32 UpdateBandwidthEstimate(const WebRtc_UWord16 bandWidthKbit,
WebRtc_UWord32* newBitrate,
WebRtc_UWord8* fractionLost,
WebRtc_UWord16* roundTripTime);
// Call when we receive a RTCP message with a ReceiveBlock
WebRtc_Word32 UpdatePacketLoss(
const WebRtc_UWord32 lastReceivedExtendedHighSeqNum,
const WebRtc_UWord16 rtt,
WebRtc_UWord8* loss,
WebRtc_UWord32* newBitrate);
WebRtc_Word32 AvailableBandwidth(WebRtc_UWord16* bandwidthKbit) const;
WebRtc_Word32 SetSendBitrate(const WebRtc_UWord32 startBitrate,
const WebRtc_UWord16 minBitrateKbit,
const WebRtc_UWord16 maxBitrateKbit);
WebRtc_Word32 MaxConfiguredBitrate(WebRtc_UWord16* maxBitrateKbit);
protected:
WebRtc_UWord32 ShapeSimple(WebRtc_Word32 packetLoss, WebRtc_Word32 rtt);
WebRtc_Word32 CalcTFRCbps(WebRtc_Word16 avgPackSizeBytes,
WebRtc_Word32 rttMs,
WebRtc_Word32 packetLoss);
private:
WebRtc_Word32 _id;
CriticalSectionWrapper& _critsect;
// incoming filters
WebRtc_UWord32 _lastPacketLossExtendedHighSeqNum;
bool _lastReportAllLost;
WebRtc_UWord8 _lastLoss;
int _accumulateLostPacketsQ8;
int _accumulateExpectedPackets;
// bitrate
WebRtc_UWord32 _bitRate;
WebRtc_UWord32 _minBitRateConfigured;
WebRtc_UWord32 _maxBitRateConfigured;
WebRtc_UWord8 _last_fraction_loss;
WebRtc_UWord16 _last_round_trip_time;
// bandwidth estimate
WebRtc_UWord32 _bwEstimateIncoming;
WebRtc_Word16 _smoothedFractionLostQ4;
WebRtc_Word16 _sFLFactorQ4; // forgetting factor for _smoothedFractionLostQ4
};
} // namespace webrtc
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_BANDWIDTH_MANAGEMENT_H_