44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
#include "VideoPlayoutScheduler.h"
|
|
|
|
void VideoPlayoutScheduler::Configure(int64_t frameDuration, int64_t timeScale)
|
|
{
|
|
Configure(frameDuration, timeScale, VideoPlayoutPolicy());
|
|
}
|
|
|
|
void VideoPlayoutScheduler::Configure(int64_t frameDuration, int64_t timeScale, const VideoPlayoutPolicy& policy)
|
|
{
|
|
mFrameDuration = frameDuration;
|
|
mTimeScale = timeScale;
|
|
mPolicy = NormalizeVideoPlayoutPolicy(policy);
|
|
Reset();
|
|
}
|
|
|
|
void VideoPlayoutScheduler::Reset()
|
|
{
|
|
mScheduledFrameIndex = 0;
|
|
}
|
|
|
|
VideoIOScheduleTime VideoPlayoutScheduler::NextScheduleTime()
|
|
{
|
|
VideoIOScheduleTime time;
|
|
time.streamTime = static_cast<int64_t>(mScheduledFrameIndex) * mFrameDuration;
|
|
time.duration = mFrameDuration;
|
|
time.timeScale = mTimeScale;
|
|
time.frameIndex = mScheduledFrameIndex;
|
|
++mScheduledFrameIndex;
|
|
return time;
|
|
}
|
|
|
|
void VideoPlayoutScheduler::AccountForCompletionResult(VideoIOCompletionResult result)
|
|
{
|
|
if (result == VideoIOCompletionResult::DisplayedLate || result == VideoIOCompletionResult::Dropped)
|
|
mScheduledFrameIndex += mPolicy.lateOrDropCatchUpFrames;
|
|
}
|
|
|
|
double VideoPlayoutScheduler::FrameBudgetMilliseconds() const
|
|
{
|
|
return mTimeScale != 0
|
|
? (static_cast<double>(mFrameDuration) * 1000.0) / static_cast<double>(mTimeScale)
|
|
: 0.0;
|
|
}
|