Inject TickTimeInterface into VCM and tests
The purpose of this change is to introduce dependency injection of the timer into the video coding module. Review URL: http://webrtc-codereview.appspot.com/332003 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1220 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -12,11 +12,14 @@
|
||||
#include "content_metrics_processing.h"
|
||||
#include "frame_dropper.h"
|
||||
#include "qm_select.h"
|
||||
#include "modules/video_coding/main/source/tick_time_interface.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
VCMMediaOptimization::VCMMediaOptimization(WebRtc_Word32 id):
|
||||
VCMMediaOptimization::VCMMediaOptimization(WebRtc_Word32 id,
|
||||
TickTimeInterface* clock):
|
||||
_id(id),
|
||||
_clock(clock),
|
||||
_maxBitRate(0),
|
||||
_sendCodecType(kVideoCodecUnknown),
|
||||
_codecWidth(0),
|
||||
@@ -42,7 +45,7 @@ _lastChangeTime(0)
|
||||
memset(_incomingFrameTimes, -1, sizeof(_incomingFrameTimes));
|
||||
|
||||
_frameDropper = new VCMFrameDropper(_id);
|
||||
_lossProtLogic = new VCMLossProtectionLogic();
|
||||
_lossProtLogic = new VCMLossProtectionLogic(_clock->MillisecondTimestamp());
|
||||
_content = new VCMContentMetricsProcessing();
|
||||
_qmResolution = new VCMQmResolution();
|
||||
}
|
||||
@@ -62,12 +65,12 @@ VCMMediaOptimization::Reset()
|
||||
memset(_incomingFrameTimes, -1, sizeof(_incomingFrameTimes));
|
||||
InputFrameRate(); // Resets _incomingFrameRate
|
||||
_frameDropper->Reset();
|
||||
_lossProtLogic->Reset();
|
||||
_lossProtLogic->Reset(_clock->MillisecondTimestamp());
|
||||
_frameDropper->SetRates(0, 0);
|
||||
_content->Reset();
|
||||
_qmResolution->Reset();
|
||||
_lossProtLogic->UpdateFrameRate(_incomingFrameRate);
|
||||
_lossProtLogic->Reset();
|
||||
_lossProtLogic->Reset(_clock->MillisecondTimestamp());
|
||||
_sendStatisticsZeroEncode = 0;
|
||||
_targetBitRate = 0;
|
||||
_codecWidth = 0;
|
||||
@@ -93,7 +96,7 @@ VCMMediaOptimization::SetTargetRates(WebRtc_UWord32 bitRate,
|
||||
{
|
||||
VCMProtectionMethod *selectedMethod = _lossProtLogic->SelectedMethod();
|
||||
_lossProtLogic->UpdateBitRate(static_cast<float>(bitRate));
|
||||
_lossProtLogic->UpdateLossPr(fractionLost);
|
||||
_lossProtLogic->UpdateLossPr(fractionLost, _clock->MillisecondTimestamp());
|
||||
_lossProtLogic->UpdateRtt(roundTripTimeMs);
|
||||
_lossProtLogic->UpdateResidualPacketLoss(static_cast<float>(fractionLost));
|
||||
|
||||
@@ -116,7 +119,8 @@ VCMMediaOptimization::SetTargetRates(WebRtc_UWord32 bitRate,
|
||||
// average or max filter may be used.
|
||||
// We should think about which filter is appropriate for low/high bit rates,
|
||||
// low/high loss rates, etc.
|
||||
WebRtc_UWord8 packetLossEnc = _lossProtLogic->FilteredLoss();
|
||||
WebRtc_UWord8 packetLossEnc = _lossProtLogic->FilteredLoss(
|
||||
_clock->MillisecondTimestamp());
|
||||
|
||||
// For now use the filtered loss for computing the robustness settings
|
||||
_lossProtLogic->UpdateFilteredLossPr(packetLossEnc);
|
||||
@@ -253,7 +257,7 @@ VCMMediaOptimization::SetEncodingData(VideoCodecType sendCodecType, WebRtc_Word3
|
||||
// has changed. If native dimension values have changed, then either user
|
||||
// initiated change, or QM initiated change. Will be able to determine only
|
||||
// after the processing of the first frame.
|
||||
_lastChangeTime = VCMTickTime::MillisecondTimestamp();
|
||||
_lastChangeTime = _clock->MillisecondTimestamp();
|
||||
_content->Reset();
|
||||
_content->UpdateFrameRate(frameRate);
|
||||
|
||||
@@ -336,7 +340,7 @@ VCMMediaOptimization::SentFrameRate()
|
||||
float
|
||||
VCMMediaOptimization::SentBitRate()
|
||||
{
|
||||
UpdateBitRateEstimate(-1, VCMTickTime::MillisecondTimestamp());
|
||||
UpdateBitRateEstimate(-1, _clock->MillisecondTimestamp());
|
||||
return _avgSentBitRateBps / 1000.0f;
|
||||
}
|
||||
|
||||
@@ -351,7 +355,7 @@ VCMMediaOptimization::UpdateWithEncodedData(WebRtc_Word32 encodedLength,
|
||||
FrameType encodedFrameType)
|
||||
{
|
||||
// look into the ViE version - debug mode - needs also number of layers.
|
||||
UpdateBitRateEstimate(encodedLength, VCMTickTime::MillisecondTimestamp());
|
||||
UpdateBitRateEstimate(encodedLength, _clock->MillisecondTimestamp());
|
||||
if(encodedLength > 0)
|
||||
{
|
||||
const bool deltaFrame = (encodedFrameType != kVideoFrameKey &&
|
||||
@@ -364,11 +368,13 @@ VCMMediaOptimization::UpdateWithEncodedData(WebRtc_Word32 encodedLength,
|
||||
static_cast<float>(_maxPayloadSize);
|
||||
if (deltaFrame)
|
||||
{
|
||||
_lossProtLogic->UpdatePacketsPerFrame(minPacketsPerFrame);
|
||||
_lossProtLogic->UpdatePacketsPerFrame(
|
||||
minPacketsPerFrame, _clock->MillisecondTimestamp());
|
||||
}
|
||||
else
|
||||
{
|
||||
_lossProtLogic->UpdatePacketsPerFrameKey(minPacketsPerFrame);
|
||||
_lossProtLogic->UpdatePacketsPerFrameKey(
|
||||
minPacketsPerFrame, _clock->MillisecondTimestamp());
|
||||
}
|
||||
|
||||
if (_enableQm)
|
||||
@@ -519,7 +525,7 @@ VCMMediaOptimization::SelectQuality()
|
||||
_qmResolution->ResetRates();
|
||||
|
||||
// Reset counters
|
||||
_lastQMUpdateTime = VCMTickTime::MillisecondTimestamp();
|
||||
_lastQMUpdateTime = _clock->MillisecondTimestamp();
|
||||
|
||||
// Reset content metrics
|
||||
_content->Reset();
|
||||
@@ -542,7 +548,7 @@ VCMMediaOptimization::checkStatusForQMchange()
|
||||
// (to sample the metrics) from the event lastChangeTime
|
||||
// lastChangeTime is the time where user changed the size/rate/frame rate
|
||||
// (via SetEncodingData)
|
||||
WebRtc_Word64 now = VCMTickTime::MillisecondTimestamp();
|
||||
WebRtc_Word64 now = _clock->MillisecondTimestamp();
|
||||
if ((now - _lastQMUpdateTime) < kQmMinIntervalMs ||
|
||||
(now - _lastChangeTime) < kQmMinIntervalMs)
|
||||
{
|
||||
@@ -612,7 +618,7 @@ VCMMediaOptimization::QMUpdate(VCMResolutionScale* qm)
|
||||
void
|
||||
VCMMediaOptimization::UpdateIncomingFrameRate()
|
||||
{
|
||||
WebRtc_Word64 now = VCMTickTime::MillisecondTimestamp();
|
||||
WebRtc_Word64 now = _clock->MillisecondTimestamp();
|
||||
if (_incomingFrameTimes[0] == 0)
|
||||
{
|
||||
// first no shift
|
||||
@@ -664,7 +670,7 @@ VCMMediaOptimization::ProcessIncomingFrameRate(WebRtc_Word64 now)
|
||||
WebRtc_UWord32
|
||||
VCMMediaOptimization::InputFrameRate()
|
||||
{
|
||||
ProcessIncomingFrameRate(VCMTickTime::MillisecondTimestamp());
|
||||
ProcessIncomingFrameRate(_clock->MillisecondTimestamp());
|
||||
return WebRtc_UWord32 (_incomingFrameRate + 0.5f);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user