Re-implement dependency injection of TickTime into VCM and tests

This change basicly re-enables the change of r1220, which was
reverted in r1235 due to Clang issues.

The difference from r1220 is that the TickTimeInterface was
renamed to TickTimeClass, and no longer inherits from TickTime.

Review URL: http://webrtc-codereview.appspot.com/335006

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1267 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrik.lundin@webrtc.org
2011-12-21 15:24:01 +00:00
parent 5490c71a1b
commit 7d8c72e2db
47 changed files with 357 additions and 317 deletions

View File

@@ -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_base.h"
namespace webrtc {
VCMMediaOptimization::VCMMediaOptimization(WebRtc_Word32 id):
VCMMediaOptimization::VCMMediaOptimization(WebRtc_Word32 id,
TickTimeBase* clock):
_id(id),
_clock(clock),
_maxBitRate(0),
_sendCodecType(kVideoCodecUnknown),
_codecWidth(0),
@@ -43,7 +46,7 @@ _numLayers(0)
memset(_incomingFrameTimes, -1, sizeof(_incomingFrameTimes));
_frameDropper = new VCMFrameDropper(_id);
_lossProtLogic = new VCMLossProtectionLogic();
_lossProtLogic = new VCMLossProtectionLogic(_clock->MillisecondTimestamp());
_content = new VCMContentMetricsProcessing();
_qmResolution = new VCMQmResolution();
}
@@ -63,12 +66,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;
@@ -95,7 +98,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));
@@ -118,7 +121,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);
@@ -261,7 +265,7 @@ VCMMediaOptimization::SetEncodingData(VideoCodecType sendCodecType,
// 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);
@@ -346,7 +350,7 @@ VCMMediaOptimization::SentFrameRate()
float
VCMMediaOptimization::SentBitRate()
{
UpdateBitRateEstimate(-1, VCMTickTime::MillisecondTimestamp());
UpdateBitRateEstimate(-1, _clock->MillisecondTimestamp());
return _avgSentBitRateBps / 1000.0f;
}
@@ -361,7 +365,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 &&
@@ -374,11 +378,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)
@@ -529,7 +535,7 @@ VCMMediaOptimization::SelectQuality()
_qmResolution->ResetRates();
// Reset counters
_lastQMUpdateTime = VCMTickTime::MillisecondTimestamp();
_lastQMUpdateTime = _clock->MillisecondTimestamp();
// Reset content metrics
_content->Reset();
@@ -552,7 +558,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)
{
@@ -622,7 +628,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
@@ -674,7 +680,7 @@ VCMMediaOptimization::ProcessIncomingFrameRate(WebRtc_Word64 now)
WebRtc_UWord32
VCMMediaOptimization::InputFrameRate()
{
ProcessIncomingFrameRate(VCMTickTime::MillisecondTimestamp());
ProcessIncomingFrameRate(_clock->MillisecondTimestamp());
return WebRtc_UWord32 (_incomingFrameRate + 0.5f);
}