proactive realignment
This commit is contained in:
@@ -12,6 +12,9 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
constexpr int64_t kMinimumHealthyScheduleLeadFrames = 3;
|
||||||
|
constexpr int64_t kProactiveScheduleLeadFloorFrames = 2;
|
||||||
|
|
||||||
class SystemMemoryDeckLinkVideoBuffer : public IDeckLinkVideoBuffer
|
class SystemMemoryDeckLinkVideoBuffer : public IDeckLinkVideoBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -539,6 +542,7 @@ bool DeckLinkSession::ScheduleFrame(IDeckLinkMutableVideoFrame* outputVideoFrame
|
|||||||
}
|
}
|
||||||
|
|
||||||
UpdateScheduleLeadTelemetry();
|
UpdateScheduleLeadTelemetry();
|
||||||
|
MaybeRealignScheduleCursorForLowLead();
|
||||||
const VideoIOScheduleTime scheduleTime = mScheduler.NextScheduleTime();
|
const VideoIOScheduleTime scheduleTime = mScheduler.NextScheduleTime();
|
||||||
const auto scheduleStart = std::chrono::steady_clock::now();
|
const auto scheduleStart = std::chrono::steady_clock::now();
|
||||||
const HRESULT result = output->ScheduleVideoFrame(outputVideoFrame, scheduleTime.streamTime, scheduleTime.duration, scheduleTime.timeScale);
|
const HRESULT result = output->ScheduleVideoFrame(outputVideoFrame, scheduleTime.streamTime, scheduleTime.duration, scheduleTime.timeScale);
|
||||||
@@ -577,6 +581,24 @@ void DeckLinkSession::UpdateScheduleLeadTelemetry()
|
|||||||
mState.deckLinkScheduleLeadFrames = static_cast<int64_t>(nextScheduleFrameIndex) - static_cast<int64_t>(playbackFrameIndex);
|
mState.deckLinkScheduleLeadFrames = static_cast<int64_t>(nextScheduleFrameIndex) - static_cast<int64_t>(playbackFrameIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeckLinkSession::MaybeRealignScheduleCursorForLowLead()
|
||||||
|
{
|
||||||
|
if (!mState.deckLinkScheduleLeadAvailable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (mState.deckLinkScheduleLeadFrames >= kMinimumHealthyScheduleLeadFrames)
|
||||||
|
{
|
||||||
|
mProactiveScheduleRealignmentArmed = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mProactiveScheduleRealignmentArmed || mState.deckLinkScheduleLeadFrames > kProactiveScheduleLeadFloorFrames)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RealignScheduleCursorToPlayback();
|
||||||
|
mProactiveScheduleRealignmentArmed = false;
|
||||||
|
}
|
||||||
|
|
||||||
void DeckLinkSession::RealignScheduleCursorToPlayback()
|
void DeckLinkSession::RealignScheduleCursorToPlayback()
|
||||||
{
|
{
|
||||||
if (output == nullptr)
|
if (output == nullptr)
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ private:
|
|||||||
bool PopulateOutputFrame(IDeckLinkMutableVideoFrame* outputVideoFrame, VideoIOOutputFrame& frame);
|
bool PopulateOutputFrame(IDeckLinkMutableVideoFrame* outputVideoFrame, VideoIOOutputFrame& frame);
|
||||||
bool ScheduleFrame(IDeckLinkMutableVideoFrame* outputVideoFrame);
|
bool ScheduleFrame(IDeckLinkMutableVideoFrame* outputVideoFrame);
|
||||||
void UpdateScheduleLeadTelemetry();
|
void UpdateScheduleLeadTelemetry();
|
||||||
|
void MaybeRealignScheduleCursorForLowLead();
|
||||||
void RealignScheduleCursorToPlayback();
|
void RealignScheduleCursorToPlayback();
|
||||||
bool ScheduleSystemMemoryFrame(const VideoIOOutputFrame& frame);
|
bool ScheduleSystemMemoryFrame(const VideoIOOutputFrame& frame);
|
||||||
bool ScheduleBlackFrame(IDeckLinkMutableVideoFrame* outputVideoFrame);
|
bool ScheduleBlackFrame(IDeckLinkMutableVideoFrame* outputVideoFrame);
|
||||||
@@ -95,6 +96,7 @@ private:
|
|||||||
VideoPlayoutScheduler mScheduler;
|
VideoPlayoutScheduler mScheduler;
|
||||||
bool mScheduleRealignmentPending = false;
|
bool mScheduleRealignmentPending = false;
|
||||||
bool mScheduleRealignmentArmed = true;
|
bool mScheduleRealignmentArmed = true;
|
||||||
|
bool mProactiveScheduleRealignmentArmed = true;
|
||||||
InputFrameCallback mInputFrameCallback;
|
InputFrameCallback mInputFrameCallback;
|
||||||
OutputFrameCallback mOutputFrameCallback;
|
OutputFrameCallback mOutputFrameCallback;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user