video_coding: Updating protection logic in media optimization utility:

1. Changing protection logic structure: Accepts only one method (not a list)
2. Removed unused code (unreferenced protection methods)
3. Removed inline constructors/destructors.  
Review URL: http://webrtc-codereview.appspot.com/120005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@467 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mikhal@webrtc.org 2011-08-26 21:17:34 +00:00
parent 552f173979
commit a057a9561c
5 changed files with 206 additions and 349 deletions

View File

@ -21,6 +21,27 @@
namespace webrtc {
VCMProtectionMethod::VCMProtectionMethod():
_effectivePacketLoss(0),
_protectionFactorK(0),
_protectionFactorD(0),
_residualPacketLossFec(0.0f),
_scaleProtKey(2.0f),
_maxPayloadSize(1460),
_qmRobustness(new VCMQmRobustness()),
_useUepProtectionK(false),
_useUepProtectionD(true),
_corrFecCost(1.0),
_type(kNone),
_efficiency(0)
{
//
}
VCMProtectionMethod::~VCMProtectionMethod()
{
delete _qmRobustness;
}
void
VCMProtectionMethod::UpdateContentMetrics(const
VideoContentMetrics* contentMetrics)
@ -28,15 +49,15 @@ VCMProtectionMethod::UpdateContentMetrics(const
_qmRobustness->UpdateContent(contentMetrics);
}
VCMNackFecMethod::VCMNackFecMethod() : VCMProtectionMethod(kNackFec)
VCMNackFecMethod::VCMNackFecMethod():
VCMFecMethod()
{
_fecMethod = new VCMFecMethod();
_type = kNackFec;
}
VCMNackFecMethod::~VCMNackFecMethod()
{
delete _fecMethod;
//
}
bool
VCMNackFecMethod::ProtectionFactor(const
@ -54,13 +75,7 @@ VCMNackFecMethod::ProtectionFactor(const
// nack the residual, based on a decision made in the JB.
// Compute the protection factors
_fecMethod->ProtectionFactor(parameters);
_protectionFactorK = _fecMethod->_protectionFactorK;
_protectionFactorD = _fecMethod->_protectionFactorD;
_useUepProtectionD = _fecMethod->_useUepProtectionD;
_useUepProtectionK = _fecMethod->_useUepProtectionK;
VCMFecMethod::ProtectionFactor(parameters);
// When in Hybrid mode (RTT range), adjust FEC rates based on the
// RTT (NACK effectiveness) - adjustment factor is in the range [0,1].
@ -75,7 +90,7 @@ VCMNackFecMethod::ProtectionFactor(const
(adjustRtt *
static_cast<float>(_protectionFactorD));
// update FEC rates after applyingadjustment softness parameter
_fecMethod->UpdateProtectionFactorD(_protectionFactorD);
VCMFecMethod::UpdateProtectionFactorD(_protectionFactorD);
}
return true;
@ -87,10 +102,7 @@ VCMNackFecMethod::EffectivePacketLoss(const
{
// Set the effective packet loss for encoder (based on FEC code).
// Compute the effective packet loss and residual packet loss due to FEC.
_fecMethod->EffectivePacketLoss(parameters);
_effectivePacketLoss = _fecMethod->_effectivePacketLoss;
_residualPacketLossFec = _fecMethod->_residualPacketLossFec;
VCMFecMethod::EffectivePacketLoss(parameters);
return true;
}
@ -119,18 +131,28 @@ VCMNackFecMethod::UpdateParameters(const VCMProtectionParameters* parameters)
// protection factor is defined relative to source number of packets so we
// should convert the factor to reduce mismatch between mediaOpt's rate and
// the actual one
_protectionFactorK = _fecMethod->ConvertFECRate(_protectionFactorK);
_protectionFactorD = _fecMethod->ConvertFECRate(_protectionFactorD);
_protectionFactorK = VCMFecMethod::ConvertFECRate(_protectionFactorK);
_protectionFactorD = VCMFecMethod::ConvertFECRate(_protectionFactorD);
return true;
}
VCMNackMethod::VCMNackMethod():
VCMProtectionMethod()
{
_type = kNack;
}
VCMNackMethod::~VCMNackMethod()
{
//
}
bool
VCMNackMethod::EffectivePacketLoss(const VCMProtectionParameters* parameter)
{
// Effective Packet Loss, NA in current version.
_effectivePacketLoss = 0;
return true;
}
@ -146,6 +168,16 @@ VCMNackMethod::UpdateParameters(const VCMProtectionParameters* parameters)
return true;
}
VCMFecMethod::VCMFecMethod():
VCMProtectionMethod()
{
_type = kFec;
}
VCMFecMethod::~VCMFecMethod()
{
//
}
WebRtc_UWord8
VCMFecMethod::BoostCodeRateKey(WebRtc_UWord8 packetFrameDelta,
WebRtc_UWord8 packetFrameKey) const
@ -175,7 +207,6 @@ void
VCMFecMethod::UpdateProtectionFactorD(WebRtc_UWord8 protectionFactorD)
{
_protectionFactorD = protectionFactorD;
}
// AvgRecoveryFEC: computes the residual packet loss function.
@ -241,8 +272,10 @@ VCMFecMethod::AvgRecoveryFEC(const VCMProtectionParameters* parameters) const
}
}
const WebRtc_UWord8 lossRate = static_cast<WebRtc_UWord8> (255.0 *
WebRtc_UWord8 lossRate = static_cast<WebRtc_UWord8> (255.0 *
parameters->lossPr + 0.5f);
// Constrain lossRate to 129 (50% protection)
// TODO (marpan): Verify table values
const WebRtc_UWord16 codeIndex = (fecPacketsPerFrame - 1) * codeSize +
(sourcePacketsPerFrame - 1);
@ -527,151 +560,100 @@ VCMFecMethod::UpdateParameters(const VCMProtectionParameters* parameters)
return true;
}
bool
VCMIntraReqMethod::UpdateParameters(const VCMProtectionParameters* parameters)
VCMLossProtectionLogic::VCMLossProtectionLogic():
_selectedMethod(NULL),
_currentParameters(),
_rtt(0),
_lossPr(0.0f),
_bitRate(0.0f),
_frameRate(0.0f),
_keyFrameSize(0.0f),
_fecRateKey(0),
_fecRateDelta(0),
_lastPrUpdateT(0),
_lossPr255(0.9999f),
_lossPrHistory(),
_shortMaxLossPr255(0),
_packetsPerFrame(0.9999f),
_packetsPerFrameKey(0.9999f),
_residualPacketLossFec(0),
_boostRateKey(2),
_codecWidth(0),
_codecHeight(0)
{
float packetRate = parameters->packetsPerFrame * parameters->frameRate;
// Assume that all lost packets cohere to different frames
float lossRate = parameters->lossPr * packetRate;
if (parameters->keyFrameSize <= 1e-3)
{
return false;
}
_efficiency = lossRate * parameters->keyFrameSize;
if (parameters->lossPr >= 1.0f / parameters->keyFrameSize ||
parameters->rtt > _IREQ_MAX_RTT)
{
return false;
}
return true;
}
bool
VCMPeriodicIntraMethod::UpdateParameters(const
VCMProtectionParameters* /*parameters*/)
{
// Periodic I-frames. The last thing we want to use.
_efficiency = 0.0f;
return true;
}
bool
VCMMbIntraRefreshMethod::UpdateParameters(const
VCMProtectionParameters* parameters)
{
// Assume optimal for now.
_efficiency = parameters->bitRate * parameters->lossPr /
(1.0f + parameters->lossPr);
if (parameters->bitRate < _MBREF_MIN_BITRATE)
{
return false;
}
return true;
Reset();
}
VCMLossProtectionLogic::~VCMLossProtectionLogic()
{
ClearLossProtections();
}
void
VCMLossProtectionLogic::ClearLossProtections()
{
ListItem *item;
while ((item = _availableMethods.First()) != 0)
{
VCMProtectionMethod *method = static_cast<VCMProtectionMethod*>
(item->GetItem());
if (method != NULL)
{
delete method;
}
_availableMethods.PopFront();
}
_selectedMethod = NULL;
Release();
}
bool
VCMLossProtectionLogic::AddMethod(VCMProtectionMethod *newMethod)
VCMLossProtectionLogic::SetMethod(enum VCMProtectionMethodEnum newMethodType)
{
VCMProtectionMethod *method;
ListItem *item;
if (newMethod == NULL)
if (_selectedMethod != NULL)
{
if (_selectedMethod->Type() == newMethodType)
{
// Nothing to update
return false;
}
for (item = _availableMethods.First(); item != NULL;
item = _availableMethods.Next(item))
// New method - delete existing one
delete _selectedMethod;
}
VCMProtectionMethod *newMethod = NULL;
switch (newMethodType)
{
method = static_cast<VCMProtectionMethod *> (item->GetItem());
if (method != NULL && method->Type() == newMethod->Type())
case kNack:
{
newMethod = new VCMNackMethod();
break;
}
case kFec:
{
newMethod = new VCMFecMethod();
break;
}
case kNackFec:
{
newMethod = new VCMNackFecMethod();
break;
}
default:
{
return false;
break;
}
}
_availableMethods.PushBack(newMethod);
_selectedMethod = newMethod;
return true;
}
bool
VCMLossProtectionLogic::RemoveMethod(VCMProtectionMethodEnum methodType)
VCMLossProtectionLogic::RemoveMethod(enum VCMProtectionMethodEnum method)
{
VCMProtectionMethod *method;
ListItem *item;
bool foundAndRemoved = false;
for (item = _availableMethods.First(); item != NULL;
item = _availableMethods.Next(item))
if (_selectedMethod == NULL)
{
method = static_cast<VCMProtectionMethod *> (item->GetItem());
if (method != NULL && method->Type() == methodType)
{
if (_selectedMethod != NULL &&
_selectedMethod->Type() == method->Type())
return false;
}
else if (_selectedMethod->Type() == method)
{
delete _selectedMethod;
_selectedMethod = NULL;
}
_availableMethods.Erase(item);
item = NULL;
delete method;
foundAndRemoved = true;
}
}
return foundAndRemoved;
}
VCMProtectionMethod*
VCMLossProtectionLogic::FindMethod(VCMProtectionMethodEnum methodType) const
{
VCMProtectionMethod *method;
ListItem *item;
for (item = _availableMethods.First(); item != NULL;
item = _availableMethods.Next(item))
{
method = static_cast<VCMProtectionMethod *> (item->GetItem());
if (method != NULL && method->Type() == methodType)
{
return method;
}
}
return NULL;
return true;
}
float
VCMLossProtectionLogic::HighestOverhead() const
VCMLossProtectionLogic::RequiredBitRate() const
{
VCMProtectionMethod *method;
ListItem *item;
float highestOverhead = 0.0f;
for (item = _availableMethods.First(); item != NULL;
item = _availableMethods.Next(item))
float RequiredBitRate = 0.0f;
if (_selectedMethod != NULL)
{
method = static_cast<VCMProtectionMethod *> (item->GetItem());
if (method != NULL && method->RequiredBitRate() > highestOverhead)
{
highestOverhead = method->RequiredBitRate();
RequiredBitRate = _selectedMethod->RequiredBitRate();
}
}
return highestOverhead;
return RequiredBitRate;
}
void
@ -774,7 +756,7 @@ VCMLossProtectionLogic::FilteredLoss() const
//TODO: Update for hybrid
//take the windowed max of the received loss
if (_selectedMethod != NULL && _selectedMethod->Type() == kFEC)
if (_selectedMethod != NULL && _selectedMethod->Type() == kFec)
{
return MaxFilteredLossPr(VCMTickTime::MillisecondTimestamp());
}
@ -829,8 +811,12 @@ VCMLossProtectionLogic::UpdateFrameSize(WebRtc_UWord16 width,
}
bool
VCMLossProtectionLogic::UpdateMethod(VCMProtectionMethod *newMethod /*=NULL */)
VCMLossProtectionLogic::UpdateMethod()
{
if (_selectedMethod == NULL)
{
return false;
}
_currentParameters.rtt = _rtt;
_currentParameters.lossPr = _lossPr;
_currentParameters.bitRate = _bitRate;
@ -843,15 +829,7 @@ VCMLossProtectionLogic::UpdateMethod(VCMProtectionMethod *newMethod /*=NULL */)
_currentParameters.residualPacketLossFec = _residualPacketLossFec;
_currentParameters.codecWidth = _codecWidth;
_currentParameters.codecHeight = _codecHeight;
// Update to new method, if not NULL
if (newMethod != NULL)
{
_selectedMethod = newMethod;
_selectedMethod->UpdateParameters(&_currentParameters);
return true;
}
return false;
return _selectedMethod->UpdateParameters(&_currentParameters);
}
VCMProtectionMethod*
@ -860,6 +838,12 @@ VCMLossProtectionLogic::SelectedMethod() const
return _selectedMethod;
}
VCMProtectionMethodEnum
VCMLossProtectionLogic::SelectedType() const
{
return _selectedMethod->Type();
}
void
VCMLossProtectionLogic::Reset()
{
@ -876,7 +860,14 @@ VCMLossProtectionLogic::Reset()
_lossPrHistory[i].timeMs = -1;
}
_shortMaxLossPr255 = 0;
ClearLossProtections();
Release();
}
void
VCMLossProtectionLogic::Release()
{
delete _selectedMethod;
_selectedMethod = NULL;
}
}

View File

@ -12,7 +12,6 @@
#define WEBRTC_MODULES_VIDEO_CODING_MEDIA_OPT_UTIL_H_
#include "typedefs.h"
#include "list_wrapper.h"
#include "trace.h"
#include "exp_filter.h"
#include "internal_defines.h"
@ -40,9 +39,10 @@ enum HybridNackTH {
struct VCMProtectionParameters
{
VCMProtectionParameters() : rtt(0), lossPr(0), bitRate(0),
packetsPerFrame(0), frameRate(0), keyFrameSize(0), fecRateDelta(0),
fecRateKey(0), residualPacketLossFec(0.0), codecWidth(0), codecHeight(0)
VCMProtectionParameters() : rtt(0), lossPr(0.0f), bitRate(0.0f),
packetsPerFrame(0.0f), packetsPerFrameKey(0.0f), frameRate(0.0f),
keyFrameSize(0.0f), fecRateDelta(0), fecRateKey(0),
residualPacketLossFec(0.0f), codecWidth(0), codecHeight(0)
{}
WebRtc_UWord32 rtt;
@ -57,7 +57,6 @@ struct VCMProtectionParameters
float residualPacketLossFec;
WebRtc_UWord16 codecWidth;
WebRtc_UWord16 codecHeight;
};
@ -67,12 +66,9 @@ struct VCMProtectionParameters
enum VCMProtectionMethodEnum
{
kNACK,
kFEC,
kNack,
kFec,
kNackFec,
kIntraRequest, // I-frame request
kPeriodicIntra, // I-frame refresh
kMBIntraRefresh, // Macro block refresh
kNone
};
@ -89,19 +85,13 @@ public:
class VCMProtectionMethod
{
public:
VCMProtectionMethod(VCMProtectionMethodEnum type) : _effectivePacketLoss(0),
_protectionFactorK(0), _protectionFactorD(0),
_residualPacketLossFec(0.0), _scaleProtKey(2.0), _maxPayloadSize(1460),
_useUepProtectionK(false), _useUepProtectionD(true), _corrFecCost(1.0),
_efficiency(0), _type(type)
{_qmRobustness = new VCMQmRobustness();}
virtual ~VCMProtectionMethod() { delete _qmRobustness;}
VCMProtectionMethod();
virtual ~VCMProtectionMethod();
// Updates the efficiency of the method using the parameters provided
//
// Input:
// - parameters : Parameters used to calculate the efficiency
// - parameters : Parameters used to calculate efficiency
//
// Return value : True if this method is recommended in
// the given conditions.
@ -146,6 +136,8 @@ public:
// Updates content metrics
void UpdateContentMetrics(const VideoContentMetrics* contentMetrics);
protected:
WebRtc_UWord8 _effectivePacketLoss;
WebRtc_UWord8 _protectionFactorK;
WebRtc_UWord8 _protectionFactorD;
@ -158,20 +150,15 @@ public:
bool _useUepProtectionK;
bool _useUepProtectionD;
float _corrFecCost;
protected:
enum VCMProtectionMethodEnum _type;
float _efficiency;
private:
const enum VCMProtectionMethodEnum _type;
};
class VCMNackMethod : public VCMProtectionMethod
{
public:
VCMNackMethod() : VCMProtectionMethod(kNACK) {}
virtual ~VCMNackMethod() {}
VCMNackMethod();
virtual ~VCMNackMethod();
virtual bool UpdateParameters(const VCMProtectionParameters* parameters);
// Get the effective packet loss
bool EffectivePacketLoss(const VCMProtectionParameters* parameter);
@ -180,8 +167,8 @@ public:
class VCMFecMethod : public VCMProtectionMethod
{
public:
VCMFecMethod() : VCMProtectionMethod(kFEC) {}
virtual ~VCMFecMethod() {}
VCMFecMethod();
virtual ~VCMFecMethod();
virtual bool UpdateParameters(const VCMProtectionParameters* parameters);
// Get the effective packet loss for ER
bool EffectivePacketLoss(const VCMProtectionParameters* parameters);
@ -199,69 +186,41 @@ public:
};
class VCMNackFecMethod : public VCMProtectionMethod
class VCMNackFecMethod : public VCMFecMethod
{
public:
VCMNackFecMethod();
~VCMNackFecMethod();
virtual ~VCMNackFecMethod();
virtual bool UpdateParameters(const VCMProtectionParameters* parameters);
// Get the effective packet loss for ER
bool EffectivePacketLoss(const VCMProtectionParameters* parameters);
// Get the FEC protection factors
// Get the protection factors
bool ProtectionFactor(const VCMProtectionParameters* parameters);
private:
VCMFecMethod* _fecMethod;
};
class VCMIntraReqMethod : public VCMProtectionMethod
{
public:
VCMIntraReqMethod() : VCMProtectionMethod(kIntraRequest), _IREQ_MAX_RTT(150)
{}
virtual bool UpdateParameters(const VCMProtectionParameters* parameters);
private:
const WebRtc_UWord32 _IREQ_MAX_RTT;
};
class VCMPeriodicIntraMethod : public VCMProtectionMethod
{
public:
VCMPeriodicIntraMethod() : VCMProtectionMethod(kPeriodicIntra) {}
virtual bool UpdateParameters(const VCMProtectionParameters* parameters);
};
class VCMMbIntraRefreshMethod : public VCMProtectionMethod
{
public:
VCMMbIntraRefreshMethod() :
VCMProtectionMethod(kMBIntraRefresh), _MBREF_MIN_BITRATE(150) {}
virtual bool UpdateParameters(const VCMProtectionParameters* parameters);
virtual float RequiredBitRate() { return 0.0; }
private:
const WebRtc_UWord32 _MBREF_MIN_BITRATE;
};
class VCMLossProtectionLogic
{
public:
VCMLossProtectionLogic() : _availableMethods(), _selectedMethod(NULL),
_bestNotOkMethod(NULL), _currentParameters(), _rtt(0), _lossPr(0.0f),
_bitRate(0.0f), _frameRate(0.0f), _keyFrameSize(0.0f), _fecRateKey(0),
_fecRateDelta(0), _lastPrUpdateT(0), _lossPr255(0.9999f),
_lossPrHistory(), _shortMaxLossPr255(0), _packetsPerFrame(0.9999f),
_packetsPerFrameKey(0.9999f), _residualPacketLossFec(0),
_boostRateKey(2), _codecWidth(0), _codecHeight(0)
{ Reset(); }
VCMLossProtectionLogic();
~VCMLossProtectionLogic();
void ClearLossProtections();
bool AddMethod(VCMProtectionMethod *newMethod);
bool RemoveMethod(VCMProtectionMethodEnum methodType);
VCMProtectionMethod* FindMethod(VCMProtectionMethodEnum methodType) const;
float HighestOverhead() const;
// Set the protection method to be used
//
// Input:
// - newMethodType : New requested protection method type. If one
// is already set, it will be deleted and replaced
// Return value: Returns true on update
bool SetMethod(enum VCMProtectionMethodEnum newMethodType);
// Remove requested protection method
// Input:
// - method : method to be removed (if currently selected)
//
// Return value: Returns true on update
bool RemoveMethod(enum VCMProtectionMethodEnum method);
// Return required bit rate per selected protectin method
float RequiredBitRate() const;
// Update the round-trip time
//
@ -340,18 +299,17 @@ public:
// Update the protection methods with the current VCMProtectionParameters
// and set the requested protection settings.
//
// Input:
// - newMethod : If not NULL, this method will be selected.
//
// Return value : Returns true on update
bool UpdateMethod(VCMProtectionMethod *newMethod = NULL);
bool UpdateMethod();
// Returns the method currently selected.
//
// Return value : The protection method currently selected.
VCMProtectionMethod* SelectedMethod() const;
// Return the protection type of the currently selected method
VCMProtectionMethodEnum SelectedType() const;
// Returns the filtered loss probability in the interval [0, 255].
//
// Return value : The filtered loss probability
@ -359,13 +317,13 @@ public:
void Reset();
void Release();
private:
// Sets the available loss protection methods.
void UpdateMaxLossHistory(WebRtc_UWord8 lossPr255, WebRtc_Word64 now);
WebRtc_UWord8 MaxFilteredLossPr(WebRtc_Word64 nowMs) const;
ListWrapper _availableMethods;
VCMProtectionMethod* _selectedMethod;
VCMProtectionMethod* _bestNotOkMethod;
VCMProtectionParameters _currentParameters;
WebRtc_UWord32 _rtt;
float _lossPr;

View File

@ -27,7 +27,6 @@ _packetLossEnc(0),
_fractionLost(0),
_sendStatisticsZeroEncode(0),
_maxPayloadSize(1460),
_lastBitRate(0),
_targetBitRate(0),
_incomingFrameRate(0),
_enableQm(false),
@ -51,7 +50,7 @@ _lastChangeTime(0)
VCMMediaOptimization::~VCMMediaOptimization(void)
{
_lossProtLogic->ClearLossProtections();
_lossProtLogic->Release();
delete _lossProtLogic;
delete _frameDropper;
delete _content;
@ -71,7 +70,6 @@ VCMMediaOptimization::Reset()
_lossProtLogic->UpdateFrameRate(_incomingFrameRate);
_lossProtLogic->Reset();
_sendStatisticsZeroEncode = 0;
_lastBitRate = 0;
_targetBitRate = 0;
_lossProtOverhead = 0;
_codecWidth = 0;
@ -144,7 +142,7 @@ VCMMediaOptimization::SetTargetRates(WebRtc_UWord32 bitRate,
// Get the bit cost of protection method
_lossProtOverhead = static_cast<WebRtc_UWord32>
(_lossProtLogic->HighestOverhead() + 0.5f);
(_lossProtLogic->RequiredBitRate() + 0.5f);
// Get the effective packet loss for encoder ER
// when applicable, should be passed to encoder via fractionLost
@ -154,9 +152,6 @@ VCMMediaOptimization::SetTargetRates(WebRtc_UWord32 bitRate,
// Update encoding rates following protection settings
_frameDropper->SetRates(static_cast<float>(bitRate -
_lossProtOverhead), 0);
// This may be used for UpdateEncoderBitRate: lastBitRate is total rate,
// before compensation
_lastBitRate = _targetBitRate;
// Source coding rate: total rate - protection overhead
_targetBitRate = bitRate - _lossProtOverhead;
@ -205,7 +200,7 @@ VCMMediaOptimization::UpdateProtectionCallback(VCMProtectionMethod
// NACK is on for NACK and NackFec protection method: off for FEC method
bool nackStatus = (selectedMethod->Type() == kNackFec ||
selectedMethod->Type() == kNACK);
selectedMethod->Type() == kNack);
return _videoProtectionCallback->ProtectionRequest(codeRateDeltaRTP,
codeRateKeyRTP,
@ -270,31 +265,24 @@ VCMMediaOptimization::RegisterProtectionCallback(VCMProtectionCallback*
}
void
VCMMediaOptimization::EnableFrameDropper(bool enable)
{
_frameDropper->Enable(enable);
}
void
VCMMediaOptimization::EnableNack(bool enable)
VCMMediaOptimization::EnableProtectionMethod(bool enable,
VCMProtectionMethodEnum method)
{
// Add NACK to the list of loss protection methods
bool updated = false;
if (enable)
{
VCMProtectionMethod *nackMethod = new VCMNackMethod();
updated = _lossProtLogic->AddMethod(nackMethod);
if (!updated)
{
delete nackMethod;
}
updated = _lossProtLogic->SetMethod(method);
}
else
{
updated = _lossProtLogic->RemoveMethod(kNACK);
_lossProtLogic->RemoveMethod(method);
}
if (updated)
{
@ -303,68 +291,9 @@ VCMMediaOptimization::EnableNack(bool enable)
}
bool
VCMMediaOptimization::IsNackEnabled()
VCMMediaOptimization::IsProtectionMethodEnabled(VCMProtectionMethodEnum method)
{
return (_lossProtLogic->FindMethod(kNACK) != NULL);
}
void
VCMMediaOptimization::EnableFEC(bool enable)
{
// Add FEC to the list of loss protection methods
bool updated = false;
if (enable)
{
VCMProtectionMethod *fecMethod = new VCMFecMethod();
updated = _lossProtLogic->AddMethod(fecMethod);
if (!updated)
{
delete fecMethod;
}
}
else
{
updated = _lossProtLogic->RemoveMethod(kFEC);
}
if (updated)
{
_lossProtLogic->UpdateMethod();
}
}
void
VCMMediaOptimization::EnableNackFEC(bool enable)
{
// Add NackFec to the list of loss protection methods
bool updated = false;
if (enable)
{
VCMProtectionMethod *nackfecMethod = new VCMNackFecMethod();
updated = _lossProtLogic->AddMethod(nackfecMethod);
if (!updated)
{
delete nackfecMethod;
}
}
else
{
updated = _lossProtLogic->RemoveMethod(kNackFec);
}
if (updated)
{
_lossProtLogic->UpdateMethod();
}
}
bool
VCMMediaOptimization::IsFecEnabled()
{
return (_lossProtLogic->FindMethod(kFEC) != NULL);
}
bool
VCMMediaOptimization::IsNackFecEnabled()
{
return (_lossProtLogic->FindMethod(kNackFec) != NULL);
return (_lossProtLogic->SelectedType() == method);
}
void

View File

@ -67,35 +67,17 @@ public:
WebRtc_UWord16 width,
WebRtc_UWord16 height);
/**
* Enable NACK and update error resilience parameters
* Enable protection method
*/
void EnableNack(bool enable);
void EnableProtectionMethod(bool enable, VCMProtectionMethodEnum method);
/**
* Returns weather or not NACK is enabled
* Returns weather or not protection method is enabled
*/
bool IsNackEnabled();
/**
* Enable FEC and update error resilience parameters
*/
void EnableFEC(bool enable);
/**
* Returns weather or not FEC is enabled
*/
bool IsFecEnabled();
/**
* Returns weather or not NackFec is enabled
*/
bool IsNackFecEnabled();
bool IsProtectionMethodEnabled(VCMProtectionMethodEnum method);
/**
* Updates the max pay load size
*/
/**
* Enable NackFec and update error resilience parameters
*/
void EnableNackFEC(bool enable);
void SetMtu(WebRtc_Word32 mtu);
/*
* Get actual input frame rate
*/
@ -122,10 +104,10 @@ public:
* Register a protection callback to be used to inform the user about the
* protection methods used
*/
WebRtc_Word32 RegisterProtectionCallback(VCMProtectionCallback* protectionCallback);
WebRtc_Word32 RegisterProtectionCallback(VCMProtectionCallback*
protectionCallback);
/*
* Register a quality settings callback to be used to inform VPM/user about the optimal
* quality settings (frame rate/dimension) required
* Register a quality settings callback to be used to inform VPM/user about
*/
WebRtc_Word32 RegisterVideoQMCallback(VCMQMSettingsCallback* videoQMSettings);
void EnableFrameDropper(bool enable);
@ -194,7 +176,6 @@ private:
WebRtc_UWord32 _sendStatistics[4];
WebRtc_UWord32 _sendStatisticsZeroEncode;
WebRtc_Word32 _maxPayloadSize;
WebRtc_UWord32 _lastBitRate;
WebRtc_UWord32 _targetBitRate;
float _incomingFrameRate;
@ -215,7 +196,7 @@ private:
VCMQmResolution* _qmResolution;
WebRtc_Word64 _lastQMUpdateTime;
WebRtc_Word64 _lastChangeTime; // content or user triggered
WebRtc_Word64 _lastChangeTime; // content/user triggered
}; // end of VCMMediaOptimization class definition

View File

@ -590,15 +590,13 @@ VideoCodingModuleImpl::SetVideoProtection(VCMVideoProtection videoProtection, bo
case kProtectionNackSender:
{
// Send-side only
CriticalSectionScoped cs(_sendCritSect);
_mediaOpt.EnableNack(enable);
_mediaOpt.EnableProtectionMethod(enable, kNack);
break;
}
case kProtectionNackReceiver:
{
// Receive-side only
CriticalSectionScoped cs(_receiveCritSect);
if (enable)
{
@ -679,7 +677,7 @@ VideoCodingModuleImpl::SetVideoProtection(VCMVideoProtection videoProtection, bo
// Send Side
{
CriticalSectionScoped cs(_sendCritSect);
_mediaOpt.EnableNackFEC(enable);
_mediaOpt.EnableProtectionMethod(enable, kNackFec);
}
break;
}
@ -687,7 +685,7 @@ VideoCodingModuleImpl::SetVideoProtection(VCMVideoProtection videoProtection, bo
case kProtectionFEC:
{
CriticalSectionScoped cs(_sendCritSect);
_mediaOpt.EnableFEC(enable);
_mediaOpt.EnableProtectionMethod(enable, kFec);
break;
}