VCM: Updating Media Opt:
1. Removed protection method specific code from SetTargetRates 2. Updated encoding rate following protection settings 3. Removing RTT max threshold from NACK, as it is not used in the receiver side. 4. Two bug fixes: FEC conversion function fix (line #133) and residual loss calculation (line #94) 5. Removing compiler warnings 6.. Removed unused code and general clean-up. Review URL: http://webrtc-codereview.appspot.com/96002 git-svn-id: http://webrtc.googlecode.com/svn/trunk@281 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
02f8bbdbb7
commit
b29d940db7
@ -91,7 +91,7 @@ VCMNackFecMethod::EffectivePacketLoss(const
|
|||||||
// Effective Packet Loss, NA in current version.
|
// Effective Packet Loss, NA in current version.
|
||||||
_effectivePacketLoss = 0;
|
_effectivePacketLoss = 0;
|
||||||
// No FEC applied.
|
// No FEC applied.
|
||||||
_residualPacketLossFec = 255 * parameters->lossPr;
|
_residualPacketLossFec = parameters->lossPr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,27 +130,16 @@ VCMNackFecMethod::UpdateParameters(const VCMProtectionParameters* parameters)
|
|||||||
// should convert the factor to reduce mismatch between mediaOpt's rate and
|
// should convert the factor to reduce mismatch between mediaOpt's rate and
|
||||||
// the actual one
|
// the actual one
|
||||||
_protectionFactorK = _fecMethod->ConvertFECRate(_protectionFactorK);
|
_protectionFactorK = _fecMethod->ConvertFECRate(_protectionFactorK);
|
||||||
_protectionFactorD = _fecMethod->ConvertFECRate(_protectionFactorK);
|
_protectionFactorD = _fecMethod->ConvertFECRate(_protectionFactorD);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
VCMNackMethod::EffectivePacketLoss(WebRtc_UWord8 packetLoss,
|
VCMNackMethod::EffectivePacketLoss(const VCMProtectionParameters* parameter)
|
||||||
WebRtc_UWord16 rttTime)
|
|
||||||
{
|
{
|
||||||
WebRtc_UWord16 rttMax = MaxRttNack();
|
// Effective Packet Loss, NA in current version.
|
||||||
|
_effectivePacketLoss = 0;
|
||||||
// For large RTT, we should rely on some Error Resilience, so we set
|
|
||||||
// packetLossEnc = 0 for RTT less than the NACK threshold
|
|
||||||
if (rttTime < rttMax)
|
|
||||||
{
|
|
||||||
_effectivePacketLoss = 0; // may want a softer transition here
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_effectivePacketLoss = packetLoss;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -158,18 +147,10 @@ VCMNackMethod::EffectivePacketLoss(WebRtc_UWord8 packetLoss,
|
|||||||
bool
|
bool
|
||||||
VCMNackMethod::UpdateParameters(const VCMProtectionParameters* parameters)
|
VCMNackMethod::UpdateParameters(const VCMProtectionParameters* parameters)
|
||||||
{
|
{
|
||||||
// Compute the effective packet loss for ER
|
// Compute the effective packet loss
|
||||||
WebRtc_UWord8 effPacketLoss = (WebRtc_UWord8) (255 * parameters->lossPr);
|
EffectivePacketLoss(parameters);
|
||||||
WebRtc_UWord16 rttTime = (WebRtc_UWord16) parameters->rtt;
|
|
||||||
EffectivePacketLoss(effPacketLoss, rttTime);
|
|
||||||
|
|
||||||
// Compute the NACK bit cost
|
|
||||||
if (rttTime > _NACK_MAX_RTT)
|
|
||||||
{
|
|
||||||
_efficiency = 0.0f;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// nackCost = (bitRate - nackCost) * (lossPr)
|
||||||
_efficiency = parameters->bitRate * parameters->lossPr /
|
_efficiency = parameters->bitRate * parameters->lossPr /
|
||||||
(1.0f + parameters->lossPr);
|
(1.0f + parameters->lossPr);
|
||||||
return true;
|
return true;
|
||||||
@ -564,12 +545,6 @@ VCMMbIntraRefreshMethod::UpdateParameters(const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_UWord16
|
|
||||||
VCMNackMethod::MaxRttNack() const
|
|
||||||
{
|
|
||||||
return _NACK_MAX_RTT;
|
|
||||||
}
|
|
||||||
|
|
||||||
VCMLossProtectionLogic::~VCMLossProtectionLogic()
|
VCMLossProtectionLogic::~VCMLossProtectionLogic()
|
||||||
{
|
{
|
||||||
ClearLossProtections();
|
ClearLossProtections();
|
||||||
@ -579,7 +554,8 @@ void
|
|||||||
VCMLossProtectionLogic::ClearLossProtections()
|
VCMLossProtectionLogic::ClearLossProtections()
|
||||||
{
|
{
|
||||||
ListItem *item;
|
ListItem *item;
|
||||||
while ((item = _availableMethods.First()) != 0) {
|
while ((item = _availableMethods.First()) != 0)
|
||||||
|
{
|
||||||
VCMProtectionMethod *method = static_cast<VCMProtectionMethod*>
|
VCMProtectionMethod *method = static_cast<VCMProtectionMethod*>
|
||||||
(item->GetItem());
|
(item->GetItem());
|
||||||
if (method != NULL)
|
if (method != NULL)
|
||||||
@ -685,12 +661,6 @@ VCMLossProtectionLogic::UpdateResidualPacketLoss(float residualPacketLoss)
|
|||||||
_residualPacketLossFec = residualPacketLoss;
|
_residualPacketLossFec = residualPacketLoss;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
VCMLossProtectionLogic::UpdateFecType(VCMFecTypes fecType)
|
|
||||||
{
|
|
||||||
_fecType = fecType;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
VCMLossProtectionLogic::UpdateLossPr(WebRtc_UWord8 lossPr255)
|
VCMLossProtectionLogic::UpdateLossPr(WebRtc_UWord8 lossPr255)
|
||||||
{
|
{
|
||||||
@ -846,13 +816,11 @@ VCMLossProtectionLogic::UpdateMethod(VCMProtectionMethod *newMethod /*=NULL */)
|
|||||||
_currentParameters.packetsPerFrame = _packetsPerFrame.Value();
|
_currentParameters.packetsPerFrame = _packetsPerFrame.Value();
|
||||||
_currentParameters.packetsPerFrameKey = _packetsPerFrameKey.Value();
|
_currentParameters.packetsPerFrameKey = _packetsPerFrameKey.Value();
|
||||||
_currentParameters.residualPacketLossFec = _residualPacketLossFec;
|
_currentParameters.residualPacketLossFec = _residualPacketLossFec;
|
||||||
_currentParameters.fecType = _fecType;
|
|
||||||
_currentParameters.codecWidth = _codecWidth;
|
_currentParameters.codecWidth = _codecWidth;
|
||||||
_currentParameters.codecHeight = _codecHeight;
|
_currentParameters.codecHeight = _codecHeight;
|
||||||
|
|
||||||
if (newMethod == NULL)
|
if (newMethod == NULL)
|
||||||
{
|
{
|
||||||
//_selectedMethod = _bestNotOkMethod = NULL;
|
|
||||||
VCMProtectionMethod *method;
|
VCMProtectionMethod *method;
|
||||||
ListItem *item;
|
ListItem *item;
|
||||||
for (item = _availableMethods.First(); item != NULL;
|
for (item = _availableMethods.First(); item != NULL;
|
||||||
|
@ -28,12 +28,8 @@ namespace webrtc
|
|||||||
class ListWrapper;
|
class ListWrapper;
|
||||||
|
|
||||||
enum { kLossPrHistorySize = 30 }; // 30 time periods
|
enum { kLossPrHistorySize = 30 }; // 30 time periods
|
||||||
enum { kLossPrShortFilterWinMs = 1000 }; // 1000 ms, total filter length is 30 000 ms
|
// 1000 ms, total filter length is 30 000 ms
|
||||||
|
enum { kLossPrShortFilterWinMs = 1000 };
|
||||||
enum VCMFecTypes
|
|
||||||
{
|
|
||||||
kXORFec
|
|
||||||
};
|
|
||||||
|
|
||||||
// Thresholds for hybrid NACK/FEC
|
// Thresholds for hybrid NACK/FEC
|
||||||
// common to media optimization and the jitter buffer.
|
// common to media optimization and the jitter buffer.
|
||||||
@ -46,8 +42,8 @@ struct VCMProtectionParameters
|
|||||||
{
|
{
|
||||||
VCMProtectionParameters() : rtt(0), lossPr(0), bitRate(0),
|
VCMProtectionParameters() : rtt(0), lossPr(0), bitRate(0),
|
||||||
packetsPerFrame(0), frameRate(0), keyFrameSize(0), fecRateDelta(0),
|
packetsPerFrame(0), frameRate(0), keyFrameSize(0), fecRateDelta(0),
|
||||||
fecRateKey(0), residualPacketLossFec(0.0), fecType(kXORFec),
|
fecRateKey(0), residualPacketLossFec(0.0), codecWidth(0), codecHeight(0)
|
||||||
codecWidth(0), codecHeight(0) {}
|
{}
|
||||||
|
|
||||||
WebRtc_UWord32 rtt;
|
WebRtc_UWord32 rtt;
|
||||||
float lossPr;
|
float lossPr;
|
||||||
@ -59,7 +55,6 @@ struct VCMProtectionParameters
|
|||||||
WebRtc_UWord8 fecRateDelta;
|
WebRtc_UWord8 fecRateDelta;
|
||||||
WebRtc_UWord8 fecRateKey;
|
WebRtc_UWord8 fecRateKey;
|
||||||
float residualPacketLossFec;
|
float residualPacketLossFec;
|
||||||
VCMFecTypes fecType;
|
|
||||||
WebRtc_UWord16 codecWidth;
|
WebRtc_UWord16 codecWidth;
|
||||||
WebRtc_UWord16 codecHeight;
|
WebRtc_UWord16 codecHeight;
|
||||||
|
|
||||||
@ -91,16 +86,16 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class VCMProtectionMethod
|
class VCMProtectionMethod
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//friend VCMProtectionMethod;
|
VCMProtectionMethod(VCMProtectionMethodEnum type) : _effectivePacketLoss(0),
|
||||||
VCMProtectionMethod(VCMProtectionMethodEnum type) : _protectionFactorK(0),
|
_protectionFactorK(0), _protectionFactorD(0),
|
||||||
_protectionFactorD(0), _residualPacketLossFec(0.0), _scaleProtKey(2.0),
|
_residualPacketLossFec(0.0), _scaleProtKey(2.0), _maxPayloadSize(1460),
|
||||||
_maxPayloadSize(1460), _efficiency(0), _type(type),
|
_useUepProtectionK(false), _useUepProtectionD(true), _efficiency(0),
|
||||||
_useUepProtectionK(false), _useUepProtectionD(true)
|
_type(type)
|
||||||
{_qmRobustness = new VCMQmRobustness();}
|
{_qmRobustness = new VCMQmRobustness();}
|
||||||
|
|
||||||
virtual ~VCMProtectionMethod() { delete _qmRobustness;}
|
virtual ~VCMProtectionMethod() { delete _qmRobustness;}
|
||||||
|
|
||||||
// Updates the efficiency of the method using the parameters provided
|
// Updates the efficiency of the method using the parameters provided
|
||||||
@ -174,15 +169,11 @@ private:
|
|||||||
class VCMNackMethod : public VCMProtectionMethod
|
class VCMNackMethod : public VCMProtectionMethod
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VCMNackMethod() : VCMProtectionMethod(kNACK), _NACK_MAX_RTT(200) {}
|
VCMNackMethod() : VCMProtectionMethod(kNACK) {}
|
||||||
virtual ~VCMNackMethod() {}
|
virtual ~VCMNackMethod() {}
|
||||||
virtual bool UpdateParameters(const VCMProtectionParameters* parameters);
|
virtual bool UpdateParameters(const VCMProtectionParameters* parameters);
|
||||||
// Get the effective packet loss for ER
|
// Get the effective packet loss
|
||||||
bool EffectivePacketLoss(WebRtc_UWord8 packetLoss, WebRtc_UWord16 rttTime);
|
bool EffectivePacketLoss(const VCMProtectionParameters* parameter);
|
||||||
// Get the threshold for NACK
|
|
||||||
WebRtc_UWord16 MaxRttNack() const;
|
|
||||||
private:
|
|
||||||
const WebRtc_UWord16 _NACK_MAX_RTT;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class VCMFecMethod : public VCMProtectionMethod
|
class VCMFecMethod : public VCMProtectionMethod
|
||||||
@ -253,10 +244,10 @@ class VCMLossProtectionLogic
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VCMLossProtectionLogic() : _availableMethods(), _selectedMethod(NULL),
|
VCMLossProtectionLogic() : _availableMethods(), _selectedMethod(NULL),
|
||||||
_bestNotOkMethod(NULL), _rtt(0), _lossPr(0.0f), _bitRate(0.0f),
|
_bestNotOkMethod(NULL), _currentParameters(), _rtt(0), _lossPr(0.0f),
|
||||||
_frameRate(0.0f), _keyFrameSize(0.0f), _fecRateKey(0), _fecRateDelta(0),
|
_bitRate(0.0f), _frameRate(0.0f), _keyFrameSize(0.0f), _fecRateKey(0),
|
||||||
_lastPrUpdateT(0), _lossPr255(0.9999f), _lossPrHistory(),
|
_fecRateDelta(0), _lastPrUpdateT(0), _lossPr255(0.9999f),
|
||||||
_shortMaxLossPr255(0), _packetsPerFrame(0.9999f),
|
_lossPrHistory(), _shortMaxLossPr255(0), _packetsPerFrame(0.9999f),
|
||||||
_packetsPerFrameKey(0.9999f), _residualPacketLossFec(0),
|
_packetsPerFrameKey(0.9999f), _residualPacketLossFec(0),
|
||||||
_boostRateKey(2), _codecWidth(0), _codecHeight(0)
|
_boostRateKey(2), _codecWidth(0), _codecHeight(0)
|
||||||
{ Reset(); }
|
{ Reset(); }
|
||||||
@ -282,12 +273,6 @@ public:
|
|||||||
// effective loss after FEC recovery
|
// effective loss after FEC recovery
|
||||||
void UpdateResidualPacketLoss(float _residualPacketLoss);
|
void UpdateResidualPacketLoss(float _residualPacketLoss);
|
||||||
|
|
||||||
// Update fecType
|
|
||||||
//
|
|
||||||
// Input:
|
|
||||||
// - fecType : kXORFec for generic XOR FEC
|
|
||||||
void UpdateFecType(VCMFecTypes fecType);
|
|
||||||
|
|
||||||
// Update the loss probability.
|
// Update the loss probability.
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
@ -342,22 +327,22 @@ public:
|
|||||||
// The amount of packet loss to cover for with FEC.
|
// The amount of packet loss to cover for with FEC.
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
// - fecRateKey : Packet loss to cover for with FEC when sending key frames.
|
// - fecRateKey : Packet loss to cover for with FEC when
|
||||||
// - fecRateDelta : Packet loss to cover for with FEC when sending delta frames.
|
// sending key frames.
|
||||||
|
// - fecRateDelta : Packet loss to cover for with FEC when
|
||||||
|
// sending delta frames.
|
||||||
void UpdateFECRates(WebRtc_UWord8 fecRateKey, WebRtc_UWord8 fecRateDelta)
|
void UpdateFECRates(WebRtc_UWord8 fecRateKey, WebRtc_UWord8 fecRateDelta)
|
||||||
{ _fecRateKey = fecRateKey; _fecRateDelta = fecRateDelta; }
|
{ _fecRateKey = fecRateKey;
|
||||||
|
_fecRateDelta = fecRateDelta; }
|
||||||
|
|
||||||
// Update the protection methods with the current VCMProtectionParameters and
|
// Update the protection methods with the current VCMProtectionParameters
|
||||||
// choose the best method available. The update involves computing the robustness settings
|
// and choose the best method available. The update involves computing the
|
||||||
// for the protection method.
|
// robustness settings for the protection method.
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
// - newMethod : If not NULL, this is method will be selected by force.
|
// - newMethod : If not NULL, this method will be selected.
|
||||||
//
|
//
|
||||||
// Return value : True if the selected method is recommended using these settings,
|
// Return value : Returns true on update
|
||||||
// false if it's the best method, but still not recommended to be used.
|
|
||||||
// E.g. if NACK is the best available, but the RTT is too large, false
|
|
||||||
// will be returned.
|
|
||||||
bool UpdateMethod(VCMProtectionMethod *newMethod = NULL);
|
bool UpdateMethod(VCMProtectionMethod *newMethod = NULL);
|
||||||
|
|
||||||
// Returns the method currently selected.
|
// Returns the method currently selected.
|
||||||
@ -370,11 +355,6 @@ public:
|
|||||||
// Return value : The filtered loss probability
|
// Return value : The filtered loss probability
|
||||||
WebRtc_UWord8 FilteredLoss() const;
|
WebRtc_UWord8 FilteredLoss() const;
|
||||||
|
|
||||||
// Get constraint on NACK
|
|
||||||
//
|
|
||||||
// return value : RTT threshold for using NACK
|
|
||||||
WebRtc_UWord8 GetNackThreshold() const;
|
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -402,7 +382,6 @@ private:
|
|||||||
VCMExpFilter _packetsPerFrameKey;
|
VCMExpFilter _packetsPerFrameKey;
|
||||||
float _residualPacketLossFec;
|
float _residualPacketLossFec;
|
||||||
WebRtc_UWord8 _boostRateKey;
|
WebRtc_UWord8 _boostRateKey;
|
||||||
VCMFecTypes _fecType;
|
|
||||||
WebRtc_UWord16 _codecWidth;
|
WebRtc_UWord16 _codecWidth;
|
||||||
WebRtc_UWord16 _codecHeight;
|
WebRtc_UWord16 _codecHeight;
|
||||||
};
|
};
|
||||||
|
@ -101,9 +101,6 @@ VCMMediaOptimization::SetTargetRates(WebRtc_UWord32 bitRate,
|
|||||||
_lossProtLogic->UpdateRtt(roundTripTimeMs);
|
_lossProtLogic->UpdateRtt(roundTripTimeMs);
|
||||||
_lossProtLogic->UpdateResidualPacketLoss(static_cast<float>(fractionLost));
|
_lossProtLogic->UpdateResidualPacketLoss(static_cast<float>(fractionLost));
|
||||||
|
|
||||||
VCMFecTypes fecType = kXORFec; // generic FEC
|
|
||||||
_lossProtLogic->UpdateFecType(fecType);
|
|
||||||
|
|
||||||
// Get frame rate for encoder: this is the actual/sent frame rate
|
// Get frame rate for encoder: this is the actual/sent frame rate
|
||||||
float actualFrameRate = SentFrameRate();
|
float actualFrameRate = SentFrameRate();
|
||||||
|
|
||||||
@ -131,73 +128,32 @@ VCMMediaOptimization::SetTargetRates(WebRtc_UWord32 bitRate,
|
|||||||
// Rate cost of the protection methods
|
// Rate cost of the protection methods
|
||||||
_lossProtOverhead = 0;
|
_lossProtOverhead = 0;
|
||||||
|
|
||||||
if (selectedMethod && (selectedMethod->Type() == kFEC ||
|
// Update protection settings, when applicable
|
||||||
selectedMethod->Type() == kNackFec ))
|
if (selectedMethod)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Update protection method with content metrics
|
// Update protection method with content metrics
|
||||||
selectedMethod->UpdateContentMetrics(_content->ShortTermAvgData());
|
selectedMethod->UpdateContentMetrics(_content->ShortTermAvgData());
|
||||||
|
|
||||||
// Update method will compute the robustness settings for the given
|
// Update method will compute the robustness settings for the given
|
||||||
// protection method and the overhead cost
|
// protection method and the overhead cost
|
||||||
// the protection method is set by the user via SetVideoProtection.
|
// the protection method is set by the user via SetVideoProtection.
|
||||||
// The robustness settings are: the effective packet loss for ER and the
|
|
||||||
// FEC protection settings
|
|
||||||
_lossProtLogic->UpdateMethod();
|
_lossProtLogic->UpdateMethod();
|
||||||
|
|
||||||
// Get the FEC code rate for Key frames
|
// Update protection callback with protection settings
|
||||||
const WebRtc_UWord8 codeRateKeyRTP = selectedMethod->RequiredProtectionFactorK();
|
UpdateProtectionCallback(selectedMethod);
|
||||||
|
|
||||||
// Get the FEC code rate for Delta frames
|
|
||||||
const WebRtc_UWord8 codeRateDeltaRTP = selectedMethod->RequiredProtectionFactorD();
|
|
||||||
|
|
||||||
// Get the FEC-UEP protection status for Key frames: UEP on/off
|
|
||||||
const bool useUepProtectionKeyRTP = selectedMethod->RequiredUepProtectionK();
|
|
||||||
|
|
||||||
// Get the FEC-UEP protection status for Delta frames: UEP on/off
|
|
||||||
const bool useUepProtectionDeltaRTP = selectedMethod->RequiredUepProtectionD();
|
|
||||||
|
|
||||||
// Get the effective packet loss for ER
|
|
||||||
packetLossEnc = selectedMethod->RequiredPacketLossER();
|
|
||||||
|
|
||||||
// NACK is on for NACK and NackFec protection method: off for FEC method
|
|
||||||
bool nackStatus = (selectedMethod->Type() == kNackFec ||
|
|
||||||
selectedMethod->Type() == kNACK);
|
|
||||||
|
|
||||||
if(_videoProtectionCallback)
|
|
||||||
{
|
|
||||||
_videoProtectionCallback->ProtectionRequest(codeRateDeltaRTP,
|
|
||||||
codeRateKeyRTP,
|
|
||||||
useUepProtectionDeltaRTP,
|
|
||||||
useUepProtectionKeyRTP,
|
|
||||||
nackStatus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the bit cost of protection method
|
// Get the bit cost of protection method
|
||||||
_lossProtOverhead = static_cast<WebRtc_UWord32>(_lossProtLogic->HighestOverhead() + 0.5f);
|
_lossProtOverhead = static_cast<WebRtc_UWord32>
|
||||||
|
(_lossProtLogic->HighestOverhead() + 0.5f);
|
||||||
|
|
||||||
// Update effective packet loss for encoder: note: fractionLost was passed as reference
|
// Get the effective packet loss for encoder ER
|
||||||
fractionLost = packetLossEnc;
|
// when applicable, should be passed to encoder via fractionLost
|
||||||
|
packetLossEnc = selectedMethod->RequiredPacketLossER();
|
||||||
WebRtc_UWord32 nackBitRate=0;
|
|
||||||
if(selectedMethod && _lossProtLogic->FindMethod(kNACK) != NULL)
|
|
||||||
{
|
|
||||||
// TODO(mikhal): update frame dropper with bit rate including both nack and fec
|
|
||||||
// Make sure we don't over-use the channel momentarily. This is
|
|
||||||
// necessary for NACK since it can be very bursty.
|
|
||||||
nackBitRate = (_lastBitRate * fractionLost) / 255;
|
|
||||||
if (nackBitRate > _targetBitRate)
|
|
||||||
{
|
|
||||||
nackBitRate = _targetBitRate;
|
|
||||||
}
|
|
||||||
_frameDropper->SetRates(static_cast<float>(bitRate - nackBitRate), 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_frameDropper->SetRates(static_cast<float>(bitRate - _lossProtOverhead), 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update encoding rates following protection settings
|
||||||
|
_frameDropper->SetRates(static_cast<float>(bitRate -
|
||||||
|
_lossProtOverhead), 0);
|
||||||
// This may be used for UpdateEncoderBitRate: lastBitRate is total rate,
|
// This may be used for UpdateEncoderBitRate: lastBitRate is total rate,
|
||||||
// before compensation
|
// before compensation
|
||||||
_lastBitRate = _targetBitRate;
|
_lastBitRate = _targetBitRate;
|
||||||
@ -223,6 +179,40 @@ VCMMediaOptimization::SetTargetRates(WebRtc_UWord32 bitRate,
|
|||||||
return _targetBitRate;
|
return _targetBitRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_UWord32
|
||||||
|
VCMMediaOptimization::UpdateProtectionCallback(VCMProtectionMethod
|
||||||
|
*selectedMethod)
|
||||||
|
{
|
||||||
|
if (!_videoProtectionCallback)
|
||||||
|
{
|
||||||
|
return VCM_OK;
|
||||||
|
}
|
||||||
|
// Get the FEC code rate for Key frames (set to 0 when NA)
|
||||||
|
const WebRtc_UWord8
|
||||||
|
codeRateKeyRTP = selectedMethod->RequiredProtectionFactorK();
|
||||||
|
|
||||||
|
// Get the FEC code rate for Delta frames (set to 0 when NA)
|
||||||
|
const WebRtc_UWord8
|
||||||
|
codeRateDeltaRTP = selectedMethod->RequiredProtectionFactorD();
|
||||||
|
|
||||||
|
// Get the FEC-UEP protection status for Key frames: UEP on/off
|
||||||
|
const bool
|
||||||
|
useUepProtectionKeyRTP = selectedMethod->RequiredUepProtectionK();
|
||||||
|
|
||||||
|
// Get the FEC-UEP protection status for Delta frames: UEP on/off
|
||||||
|
const bool
|
||||||
|
useUepProtectionDeltaRTP = selectedMethod->RequiredUepProtectionD();
|
||||||
|
|
||||||
|
// NACK is on for NACK and NackFec protection method: off for FEC method
|
||||||
|
bool nackStatus = (selectedMethod->Type() == kNackFec ||
|
||||||
|
selectedMethod->Type() == kNACK);
|
||||||
|
|
||||||
|
return _videoProtectionCallback->ProtectionRequest(codeRateDeltaRTP,
|
||||||
|
codeRateKeyRTP,
|
||||||
|
useUepProtectionDeltaRTP,
|
||||||
|
useUepProtectionKeyRTP,
|
||||||
|
nackStatus);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
VCMMediaOptimization::DropFrame()
|
VCMMediaOptimization::DropFrame()
|
||||||
@ -245,9 +235,10 @@ VCMMediaOptimization::SetEncodingData(VideoCodecType sendCodecType, WebRtc_Word3
|
|||||||
WebRtc_UWord32 frameRate, WebRtc_UWord32 bitRate,
|
WebRtc_UWord32 frameRate, WebRtc_UWord32 bitRate,
|
||||||
WebRtc_UWord16 width, WebRtc_UWord16 height)
|
WebRtc_UWord16 width, WebRtc_UWord16 height)
|
||||||
{
|
{
|
||||||
// Everything codec specific should be reset here since this means the codec has changed.
|
// Everything codec specific should be reset here since this means the codec
|
||||||
// If native dimension values have changed, then either user initiated change, or QM
|
// has changed. If native dimension values have changed, then either user
|
||||||
// initiated change. Will be able to determine only after the processing of the first frame
|
// initiated change, or QM initiated change. Will be able to determine only
|
||||||
|
// after the processing of the first frame.
|
||||||
_lastChangeTime = VCMTickTime::MillisecondTimestamp();
|
_lastChangeTime = VCMTickTime::MillisecondTimestamp();
|
||||||
_content->Reset();
|
_content->Reset();
|
||||||
_content->UpdateFrameRate(frameRate);
|
_content->UpdateFrameRate(frameRate);
|
||||||
@ -259,7 +250,8 @@ VCMMediaOptimization::SetEncodingData(VideoCodecType sendCodecType, WebRtc_Word3
|
|||||||
_lossProtLogic->UpdateFrameRate(static_cast<float>(frameRate));
|
_lossProtLogic->UpdateFrameRate(static_cast<float>(frameRate));
|
||||||
_lossProtLogic->UpdateFrameSize(width, height);
|
_lossProtLogic->UpdateFrameSize(width, height);
|
||||||
_frameDropper->Reset();
|
_frameDropper->Reset();
|
||||||
_frameDropper->SetRates(static_cast<float>(bitRate), static_cast<float>(frameRate));
|
_frameDropper->SetRates(static_cast<float>(bitRate),
|
||||||
|
static_cast<float>(frameRate));
|
||||||
_userFrameRate = static_cast<float>(frameRate);
|
_userFrameRate = static_cast<float>(frameRate);
|
||||||
_codecWidth = width;
|
_codecWidth = width;
|
||||||
_codecHeight = height;
|
_codecHeight = height;
|
||||||
@ -270,7 +262,8 @@ VCMMediaOptimization::SetEncodingData(VideoCodecType sendCodecType, WebRtc_Word3
|
|||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32
|
WebRtc_Word32
|
||||||
VCMMediaOptimization::RegisterProtectionCallback(VCMProtectionCallback* protectionCallback)
|
VCMMediaOptimization::RegisterProtectionCallback(VCMProtectionCallback*
|
||||||
|
protectionCallback)
|
||||||
{
|
{
|
||||||
_videoProtectionCallback = protectionCallback;
|
_videoProtectionCallback = protectionCallback;
|
||||||
return VCM_OK;
|
return VCM_OK;
|
||||||
@ -385,7 +378,8 @@ VCMMediaOptimization::SentFrameRate()
|
|||||||
{
|
{
|
||||||
if (_frameDropper)
|
if (_frameDropper)
|
||||||
{
|
{
|
||||||
return _frameDropper->ActualFrameRate((WebRtc_UWord32)(InputFrameRate() + 0.5f));
|
return _frameDropper->ActualFrameRate((WebRtc_UWord32)(InputFrameRate()
|
||||||
|
+ 0.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
return VCM_CODEC_ERROR;
|
return VCM_CODEC_ERROR;
|
||||||
@ -442,9 +436,12 @@ VCMMediaOptimization::UpdateWithEncodedData(WebRtc_Word32 encodedLength,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// updating counters
|
// updating counters
|
||||||
if (deltaFrame){
|
if (deltaFrame)
|
||||||
|
{
|
||||||
_deltaFrameCnt++;
|
_deltaFrameCnt++;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_keyFrameCnt++;
|
_keyFrameCnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,9 +466,11 @@ void VCMMediaOptimization::UpdateBitRateEstimate(WebRtc_Word64 encodedLength,
|
|||||||
// Found empty slot
|
// Found empty slot
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (nowMs - _encodedFrameSamples[i]._timeCompleteMs < kBitrateAverageWinMs)
|
if (nowMs - _encodedFrameSamples[i]._timeCompleteMs <
|
||||||
|
kBitrateAverageWinMs)
|
||||||
{
|
{
|
||||||
frameSizeSum += static_cast<WebRtc_UWord32>(_encodedFrameSamples[i]._sizeBytes);
|
frameSizeSum += static_cast<WebRtc_UWord32>
|
||||||
|
(_encodedFrameSamples[i]._sizeBytes);
|
||||||
if (timeOldest == -1)
|
if (timeOldest == -1)
|
||||||
{
|
{
|
||||||
timeOldest = _encodedFrameSamples[i]._timeCompleteMs;
|
timeOldest = _encodedFrameSamples[i]._timeCompleteMs;
|
||||||
@ -515,7 +514,8 @@ void VCMMediaOptimization::UpdateBitRateEstimate(WebRtc_Word64 encodedLength,
|
|||||||
|
|
||||||
|
|
||||||
WebRtc_Word32
|
WebRtc_Word32
|
||||||
VCMMediaOptimization::RegisterVideoQMCallback(VCMQMSettingsCallback *videoQMSettings)
|
VCMMediaOptimization::RegisterVideoQMCallback(VCMQMSettingsCallback*
|
||||||
|
videoQMSettings)
|
||||||
{
|
{
|
||||||
_videoQMSettingsCallback = videoQMSettings;
|
_videoQMSettingsCallback = videoQMSettings;
|
||||||
// Callback setting controls QM
|
// Callback setting controls QM
|
||||||
@ -531,12 +531,13 @@ VCMMediaOptimization::RegisterVideoQMCallback(VCMQMSettingsCallback *videoQMSett
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VCMMediaOptimization::updateContentData(const VideoContentMetrics *contentMetrics)
|
VCMMediaOptimization::updateContentData(const VideoContentMetrics*
|
||||||
|
contentMetrics)
|
||||||
{
|
{
|
||||||
// Updating content metrics
|
// Updating content metrics
|
||||||
if (contentMetrics == NULL)
|
if (contentMetrics == NULL)
|
||||||
{
|
{
|
||||||
//No QM if metrics are NULL
|
// Disable QM if metrics are NULL
|
||||||
_enableQm = false;
|
_enableQm = false;
|
||||||
_qmResolution->Reset();
|
_qmResolution->Reset();
|
||||||
}
|
}
|
||||||
|
@ -154,6 +154,11 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update protection callback with protection settings
|
||||||
|
*/
|
||||||
|
WebRtc_UWord32 UpdateProtectionCallback(VCMProtectionMethod *selectedMethod);
|
||||||
|
|
||||||
void UpdateBitRateEstimate(WebRtc_Word64 encodedLength, WebRtc_Word64 nowMs);
|
void UpdateBitRateEstimate(WebRtc_Word64 encodedLength, WebRtc_Word64 nowMs);
|
||||||
/*
|
/*
|
||||||
* verify if QM settings differ from default, i.e. if an update is required
|
* verify if QM settings differ from default, i.e. if an update is required
|
||||||
|
Loading…
x
Reference in New Issue
Block a user