This was actually working as intended, but as r3970 changed when render timestamps were extrapolated to when a frame was taken out for decoding, the wraparound could have happened in the Update() step before it had happened in the ExtrapolateLocalTime() step. This causes render timestamps to be generated 13 hours into the future. TEST=trybots BUG=1787 R=mflodman@webrtc.org Review URL: https://webrtc-codereview.appspot.com/1497004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4055 4adac7df-926f-26a2-2b94-8c16560cd09d
111 lines
4.0 KiB
C++
111 lines
4.0 KiB
C++
/*
|
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef WEBRTC_MODULES_VIDEO_CODING_TIMING_H_
|
|
#define WEBRTC_MODULES_VIDEO_CODING_TIMING_H_
|
|
|
|
#include "typedefs.h"
|
|
#include "critical_section_wrapper.h"
|
|
#include "codec_timer.h"
|
|
|
|
namespace webrtc
|
|
{
|
|
|
|
class Clock;
|
|
class VCMTimestampExtrapolator;
|
|
|
|
class VCMTiming
|
|
{
|
|
public:
|
|
// The primary timing component should be passed
|
|
// if this is the dual timing component.
|
|
VCMTiming(Clock* clock,
|
|
int32_t vcmId = 0,
|
|
int32_t timingId = 0,
|
|
VCMTiming* masterTiming = NULL);
|
|
~VCMTiming();
|
|
|
|
// Resets the timing to the initial state.
|
|
void Reset();
|
|
void ResetDecodeTime();
|
|
|
|
// The amount of time needed to render an image. Defaults to 10 ms.
|
|
void SetRenderDelay(uint32_t renderDelayMs);
|
|
|
|
// The minimum time the video must be delayed on the receiver to
|
|
// get the desired jitter buffer level.
|
|
void SetRequiredDelay(uint32_t requiredDelayMs);
|
|
|
|
// Minimum total delay required to sync video with audio.
|
|
void SetMinimumTotalDelay(uint32_t minTotalDelayMs);
|
|
|
|
// Increases or decreases the current delay to get closer to the target delay.
|
|
// Calculates how long it has been since the previous call to this function,
|
|
// and increases/decreases the delay in proportion to the time difference.
|
|
void UpdateCurrentDelay(uint32_t frameTimestamp);
|
|
|
|
// Increases or decreases the current delay to get closer to the target delay.
|
|
// Given the actual decode time in ms and the render time in ms for a frame, this
|
|
// function calculates how late the frame is and increases the delay accordingly.
|
|
void UpdateCurrentDelay(int64_t renderTimeMs, int64_t actualDecodeTimeMs);
|
|
|
|
// Stops the decoder timer, should be called when the decoder returns a frame
|
|
// or when the decoded frame callback is called.
|
|
int32_t StopDecodeTimer(uint32_t timeStamp,
|
|
int64_t startTimeMs,
|
|
int64_t nowMs);
|
|
|
|
// Used to report that a frame is passed to decoding. Updates the timestamp
|
|
// filter which is used to map between timestamps and receiver system time.
|
|
void IncomingTimestamp(uint32_t timeStamp, int64_t lastPacketTimeMs);
|
|
|
|
// Returns the receiver system time when the frame with timestamp frameTimestamp
|
|
// should be rendered, assuming that the system time currently is nowMs.
|
|
int64_t RenderTimeMs(uint32_t frameTimestamp, int64_t nowMs) const;
|
|
|
|
// Returns the maximum time in ms that we can wait for a frame to become complete
|
|
// before we must pass it to the decoder.
|
|
uint32_t MaxWaitingTime(int64_t renderTimeMs, int64_t nowMs) const;
|
|
|
|
// Returns the current target delay which is required delay + decode time + render
|
|
// delay.
|
|
uint32_t TargetVideoDelay() const;
|
|
|
|
// Calculates whether or not there is enough time to decode a frame given a
|
|
// certain amount of processing time.
|
|
bool EnoughTimeToDecode(uint32_t availableProcessingTimeMs) const;
|
|
|
|
enum { kDefaultRenderDelayMs = 10 };
|
|
enum { kDelayMaxChangeMsPerS = 100 };
|
|
|
|
protected:
|
|
int32_t MaxDecodeTimeMs(FrameType frameType = kVideoFrameDelta) const;
|
|
int64_t RenderTimeMsInternal(uint32_t frameTimestamp, int64_t nowMs) const;
|
|
uint32_t TargetDelayInternal() const;
|
|
|
|
private:
|
|
CriticalSectionWrapper* _critSect;
|
|
int32_t _vcmId;
|
|
Clock* _clock;
|
|
int32_t _timingId;
|
|
bool _master;
|
|
VCMTimestampExtrapolator* _tsExtrapolator;
|
|
VCMCodecTimer _codecTimer;
|
|
uint32_t _renderDelayMs;
|
|
uint32_t _minTotalDelayMs;
|
|
uint32_t _requiredDelayMs;
|
|
uint32_t _currentDelayMs;
|
|
uint32_t _prevFrameTimestamp;
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // WEBRTC_MODULES_VIDEO_CODING_TIMING_H_
|