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:
@@ -13,7 +13,7 @@
|
||||
#include "encoded_frame.h"
|
||||
#include "internal_defines.h"
|
||||
#include "media_opt_util.h"
|
||||
#include "tick_time.h"
|
||||
#include "tick_time_interface.h"
|
||||
#include "trace.h"
|
||||
#include "video_coding.h"
|
||||
|
||||
@@ -22,15 +22,17 @@
|
||||
namespace webrtc {
|
||||
|
||||
VCMReceiver::VCMReceiver(VCMTiming& timing,
|
||||
TickTimeInterface* clock,
|
||||
WebRtc_Word32 vcmId,
|
||||
WebRtc_Word32 receiverId,
|
||||
bool master)
|
||||
:
|
||||
_critSect(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_vcmId(vcmId),
|
||||
_clock(clock),
|
||||
_receiverId(receiverId),
|
||||
_master(master),
|
||||
_jitterBuffer(vcmId, receiverId, master),
|
||||
_jitterBuffer(_clock, vcmId, receiverId, master),
|
||||
_timing(timing),
|
||||
_renderWaitEvent(*new VCMEvent()),
|
||||
_state(kPassive)
|
||||
@@ -118,10 +120,10 @@ VCMReceiver::InsertPacket(const VCMPacket& packet,
|
||||
VCMId(_vcmId, _receiverId),
|
||||
"Packet seqNo %u of frame %u at %u",
|
||||
packet.seqNum, packet.timestamp,
|
||||
MaskWord64ToUWord32(VCMTickTime::MillisecondTimestamp()));
|
||||
MaskWord64ToUWord32(_clock->MillisecondTimestamp()));
|
||||
}
|
||||
|
||||
const WebRtc_Word64 nowMs = VCMTickTime::MillisecondTimestamp();
|
||||
const WebRtc_Word64 nowMs = _clock->MillisecondTimestamp();
|
||||
|
||||
WebRtc_Word64 renderTimeMs = _timing.RenderTimeMs(packet.timestamp, nowMs);
|
||||
|
||||
@@ -130,7 +132,7 @@ VCMReceiver::InsertPacket(const VCMPacket& packet,
|
||||
// Render time error. Assume that this is due to some change in
|
||||
// the incoming video stream and reset the JB and the timing.
|
||||
_jitterBuffer.Flush();
|
||||
_timing.Reset();
|
||||
_timing.Reset(_clock->MillisecondTimestamp());
|
||||
return VCM_FLUSH_INDICATOR;
|
||||
}
|
||||
else if (renderTimeMs < nowMs - kMaxVideoDelayMs)
|
||||
@@ -139,7 +141,7 @@ VCMReceiver::InsertPacket(const VCMPacket& packet,
|
||||
"This frame should have been rendered more than %u ms ago."
|
||||
"Flushing jitter buffer and resetting timing.", kMaxVideoDelayMs);
|
||||
_jitterBuffer.Flush();
|
||||
_timing.Reset();
|
||||
_timing.Reset(_clock->MillisecondTimestamp());
|
||||
return VCM_FLUSH_INDICATOR;
|
||||
}
|
||||
else if (_timing.TargetVideoDelay() > kMaxVideoDelayMs)
|
||||
@@ -148,14 +150,14 @@ VCMReceiver::InsertPacket(const VCMPacket& packet,
|
||||
"More than %u ms target delay. Flushing jitter buffer and resetting timing.",
|
||||
kMaxVideoDelayMs);
|
||||
_jitterBuffer.Flush();
|
||||
_timing.Reset();
|
||||
_timing.Reset(_clock->MillisecondTimestamp());
|
||||
return VCM_FLUSH_INDICATOR;
|
||||
}
|
||||
|
||||
// First packet received belonging to this frame.
|
||||
if (buffer->Length() == 0)
|
||||
{
|
||||
const WebRtc_Word64 nowMs = VCMTickTime::MillisecondTimestamp();
|
||||
const WebRtc_Word64 nowMs = _clock->MillisecondTimestamp();
|
||||
if (_master)
|
||||
{
|
||||
// Only trace the primary receiver to make it possible to parse and plot the trace file.
|
||||
@@ -199,7 +201,7 @@ VCMReceiver::FrameForDecoding(WebRtc_UWord16 maxWaitTimeMs, WebRtc_Word64& nextR
|
||||
// is thread-safe.
|
||||
FrameType incomingFrameType = kVideoFrameDelta;
|
||||
nextRenderTimeMs = -1;
|
||||
const WebRtc_Word64 startTimeMs = VCMTickTime::MillisecondTimestamp();
|
||||
const WebRtc_Word64 startTimeMs = _clock->MillisecondTimestamp();
|
||||
WebRtc_Word64 ret = _jitterBuffer.GetNextTimeStamp(maxWaitTimeMs,
|
||||
incomingFrameType,
|
||||
nextRenderTimeMs);
|
||||
@@ -215,7 +217,7 @@ VCMReceiver::FrameForDecoding(WebRtc_UWord16 maxWaitTimeMs, WebRtc_Word64& nextR
|
||||
_timing.UpdateCurrentDelay(timeStamp);
|
||||
|
||||
const WebRtc_Word32 tempWaitTime = maxWaitTimeMs -
|
||||
static_cast<WebRtc_Word32>(VCMTickTime::MillisecondTimestamp() - startTimeMs);
|
||||
static_cast<WebRtc_Word32>(_clock->MillisecondTimestamp() - startTimeMs);
|
||||
WebRtc_UWord16 newMaxWaitTime = static_cast<WebRtc_UWord16>(VCM_MAX(tempWaitTime, 0));
|
||||
|
||||
VCMEncodedFrame* frame = NULL;
|
||||
@@ -256,7 +258,7 @@ VCMReceiver::FrameForDecoding(WebRtc_UWord16 maxWaitTimeMs,
|
||||
{
|
||||
// How long can we wait until we must decode the next frame
|
||||
WebRtc_UWord32 waitTimeMs = _timing.MaxWaitingTime(nextRenderTimeMs,
|
||||
VCMTickTime::MillisecondTimestamp());
|
||||
_clock->MillisecondTimestamp());
|
||||
|
||||
// Try to get a complete frame from the jitter buffer
|
||||
VCMEncodedFrame* frame = _jitterBuffer.GetCompleteFrameForDecoding(0);
|
||||
@@ -284,7 +286,7 @@ VCMReceiver::FrameForDecoding(WebRtc_UWord16 maxWaitTimeMs,
|
||||
{
|
||||
// Get an incomplete frame
|
||||
if (_timing.MaxWaitingTime(nextRenderTimeMs,
|
||||
VCMTickTime::MillisecondTimestamp()) > 0)
|
||||
_clock->MillisecondTimestamp()) > 0)
|
||||
{
|
||||
// Still time to wait for a complete frame
|
||||
return NULL;
|
||||
@@ -316,7 +318,7 @@ VCMReceiver::FrameForRendering(WebRtc_UWord16 maxWaitTimeMs,
|
||||
// as possible before giving the frame to the decoder, which will render the frame as soon
|
||||
// as it has been decoded.
|
||||
WebRtc_UWord32 waitTimeMs = _timing.MaxWaitingTime(nextRenderTimeMs,
|
||||
VCMTickTime::MillisecondTimestamp());
|
||||
_clock->MillisecondTimestamp());
|
||||
if (maxWaitTimeMs < waitTimeMs)
|
||||
{
|
||||
// If we're not allowed to wait until the frame is supposed to be rendered
|
||||
|
||||
Reference in New Issue
Block a user