61 lines
1.4 KiB
C++
61 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "VideoIOTypes.h"
|
|
|
|
#include <windows.h>
|
|
|
|
#include <chrono>
|
|
#include <functional>
|
|
#include <cstdint>
|
|
|
|
class OpenGLRenderer;
|
|
class RuntimeHost;
|
|
|
|
struct RenderPipelineFrameContext
|
|
{
|
|
VideoIOState videoState;
|
|
VideoIOCompletion completion;
|
|
};
|
|
|
|
class OpenGLVideoIOBridge
|
|
{
|
|
public:
|
|
using RenderEffectCallback = std::function<void()>;
|
|
using OutputReadyCallback = std::function<void()>;
|
|
using PaintCallback = std::function<void()>;
|
|
|
|
OpenGLVideoIOBridge(
|
|
VideoIODevice& videoIO,
|
|
OpenGLRenderer& renderer,
|
|
RuntimeHost& runtimeHost,
|
|
CRITICAL_SECTION& mutex,
|
|
HDC hdc,
|
|
HGLRC hglrc,
|
|
RenderEffectCallback renderEffect,
|
|
OutputReadyCallback outputReady,
|
|
PaintCallback paint);
|
|
|
|
void VideoFrameArrived(const VideoIOFrame& inputFrame);
|
|
void PlayoutFrameCompleted(const VideoIOCompletion& completion);
|
|
|
|
private:
|
|
void RecordFramePacing(VideoIOCompletionResult completionResult);
|
|
|
|
VideoIODevice& mVideoIO;
|
|
OpenGLRenderer& mRenderer;
|
|
RuntimeHost& mRuntimeHost;
|
|
CRITICAL_SECTION& mMutex;
|
|
HDC mHdc;
|
|
HGLRC mHglrc;
|
|
RenderEffectCallback mRenderEffect;
|
|
OutputReadyCallback mOutputReady;
|
|
PaintCallback mPaint;
|
|
std::chrono::steady_clock::time_point mLastPlayoutCompletionTime;
|
|
double mCompletionIntervalMilliseconds = 0.0;
|
|
double mSmoothedCompletionIntervalMilliseconds = 0.0;
|
|
double mMaxCompletionIntervalMilliseconds = 0.0;
|
|
uint64_t mLateFrameCount = 0;
|
|
uint64_t mDroppedFrameCount = 0;
|
|
uint64_t mFlushedFrameCount = 0;
|
|
};
|