#include "OpenGLVideoIOBridge.h"

#include "RenderEngine.h"

OpenGLVideoIOBridge::OpenGLVideoIOBridge(RenderEngine& renderEngine) :
	mRenderEngine(renderEngine)
{
}

void OpenGLVideoIOBridge::UploadInputFrame(const VideoIOFrame& inputFrame, const VideoIOState& state)
{
	if (inputFrame.hasNoInputSource || inputFrame.bytes == nullptr)
		return;							// don't transfer texture when there's no input

	mRenderEngine.QueueInputFrame(inputFrame, state);
}

bool OpenGLVideoIOBridge::RenderScheduledFrame(const VideoIOState& state, const VideoIOCompletion& completion, VideoIOOutputFrame& outputFrame)
{
	RenderPipelineFrameContext frameContext;
	frameContext.videoState = state;
	frameContext.completion = completion;

	return mRenderEngine.RequestOutputFrame(frameContext, outputFrame);
}
