Phase 7
This commit is contained in:
@@ -16,6 +16,9 @@ void VideoPlayoutScheduler::Configure(int64_t frameDuration, int64_t timeScale,
|
||||
void VideoPlayoutScheduler::Reset()
|
||||
{
|
||||
mScheduledFrameIndex = 0;
|
||||
mCompletedFrameIndex = 0;
|
||||
mLateStreak = 0;
|
||||
mDropStreak = 0;
|
||||
}
|
||||
|
||||
VideoIOScheduleTime VideoPlayoutScheduler::NextScheduleTime()
|
||||
@@ -29,10 +32,38 @@ VideoIOScheduleTime VideoPlayoutScheduler::NextScheduleTime()
|
||||
return time;
|
||||
}
|
||||
|
||||
void VideoPlayoutScheduler::AccountForCompletionResult(VideoIOCompletionResult result)
|
||||
VideoPlayoutRecoveryDecision VideoPlayoutScheduler::AccountForCompletionResult(VideoIOCompletionResult result, uint64_t readyQueueDepth)
|
||||
{
|
||||
if (result == VideoIOCompletionResult::DisplayedLate || result == VideoIOCompletionResult::Dropped)
|
||||
mScheduledFrameIndex += mPolicy.lateOrDropCatchUpFrames;
|
||||
++mCompletedFrameIndex;
|
||||
if (result == VideoIOCompletionResult::DisplayedLate)
|
||||
++mLateStreak;
|
||||
else
|
||||
mLateStreak = 0;
|
||||
if (result == VideoIOCompletionResult::Dropped)
|
||||
++mDropStreak;
|
||||
else
|
||||
mDropStreak = 0;
|
||||
|
||||
const uint64_t measuredLagFrames = MeasureLag(result, readyQueueDepth);
|
||||
const uint64_t catchUpFrames = measuredLagFrames < mPolicy.lateOrDropCatchUpFrames
|
||||
? measuredLagFrames
|
||||
: mPolicy.lateOrDropCatchUpFrames;
|
||||
if (catchUpFrames > 0)
|
||||
mScheduledFrameIndex += catchUpFrames;
|
||||
|
||||
VideoPlayoutRecoveryDecision decision;
|
||||
decision.result = result;
|
||||
decision.completedFrameIndex = mCompletedFrameIndex;
|
||||
decision.scheduledFrameIndex = mScheduledFrameIndex;
|
||||
decision.readyQueueDepth = readyQueueDepth;
|
||||
decision.scheduledLeadFrames = mScheduledFrameIndex > mCompletedFrameIndex
|
||||
? mScheduledFrameIndex - mCompletedFrameIndex
|
||||
: 0;
|
||||
decision.measuredLagFrames = measuredLagFrames;
|
||||
decision.catchUpFrames = catchUpFrames;
|
||||
decision.lateStreak = mLateStreak;
|
||||
decision.dropStreak = mDropStreak;
|
||||
return decision;
|
||||
}
|
||||
|
||||
double VideoPlayoutScheduler::FrameBudgetMilliseconds() const
|
||||
@@ -41,3 +72,26 @@ double VideoPlayoutScheduler::FrameBudgetMilliseconds() const
|
||||
? (static_cast<double>(mFrameDuration) * 1000.0) / static_cast<double>(mTimeScale)
|
||||
: 0.0;
|
||||
}
|
||||
|
||||
uint64_t VideoPlayoutScheduler::MeasureLag(VideoIOCompletionResult result, uint64_t readyQueueDepth) const
|
||||
{
|
||||
if (result != VideoIOCompletionResult::DisplayedLate && result != VideoIOCompletionResult::Dropped)
|
||||
return 0;
|
||||
|
||||
uint64_t lagFrames = 1;
|
||||
if (result == VideoIOCompletionResult::DisplayedLate && mLateStreak > lagFrames)
|
||||
lagFrames = mLateStreak;
|
||||
if (result == VideoIOCompletionResult::Dropped && mDropStreak * 2 > lagFrames)
|
||||
lagFrames = mDropStreak * 2;
|
||||
|
||||
if (mCompletedFrameIndex >= mScheduledFrameIndex)
|
||||
{
|
||||
const uint64_t scheduleLagFrames = mCompletedFrameIndex - mScheduledFrameIndex + 1;
|
||||
if (scheduleLagFrames > lagFrames)
|
||||
lagFrames = scheduleLagFrames;
|
||||
}
|
||||
if (readyQueueDepth < mPolicy.targetReadyFrames && mPolicy.targetReadyFrames - readyQueueDepth > lagFrames)
|
||||
lagFrames = mPolicy.targetReadyFrames - readyQueueDepth;
|
||||
|
||||
return lagFrames;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user