2018-08-15 22:02:15 -07:00
|
|
|
#pragma once
|
|
|
|
|
2018-09-25 00:47:59 -07:00
|
|
|
#include "../../decoder.h"
|
2018-08-15 22:02:15 -07:00
|
|
|
#include "../renderer.h"
|
|
|
|
|
|
|
|
#include <QQueue>
|
2019-01-22 20:31:31 -08:00
|
|
|
#include <QMutex>
|
|
|
|
#include <QWaitCondition>
|
2018-08-15 22:02:15 -07:00
|
|
|
|
|
|
|
class IVsyncSource {
|
|
|
|
public:
|
|
|
|
virtual ~IVsyncSource() {}
|
2018-08-20 17:53:35 -07:00
|
|
|
virtual bool initialize(SDL_Window* window, int displayFps) = 0;
|
2018-08-15 22:02:15 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class Pacer
|
|
|
|
{
|
|
|
|
public:
|
2018-09-25 00:47:59 -07:00
|
|
|
Pacer(IFFmpegRenderer* renderer, PVIDEO_STATS videoStats);
|
2018-08-15 22:02:15 -07:00
|
|
|
|
|
|
|
~Pacer();
|
|
|
|
|
|
|
|
void submitFrame(AVFrame* frame);
|
|
|
|
|
2018-12-25 12:57:00 -08:00
|
|
|
bool initialize(SDL_Window* window, int maxVideoFps, bool enablePacing);
|
2018-08-15 22:02:15 -07:00
|
|
|
|
2018-08-20 17:53:35 -07:00
|
|
|
void vsyncCallback(int timeUntilNextVsyncMillis);
|
2018-08-15 22:02:15 -07:00
|
|
|
|
2019-04-09 21:46:14 -07:00
|
|
|
void renderOnMainThread();
|
|
|
|
|
2018-08-15 22:02:15 -07:00
|
|
|
private:
|
2019-01-22 20:31:31 -08:00
|
|
|
static int renderThread(void* context);
|
|
|
|
|
2019-04-09 21:46:14 -07:00
|
|
|
void enqueueFrameForRenderingAndUnlock(AVFrame* frame);
|
|
|
|
|
2019-01-20 19:59:29 -08:00
|
|
|
void renderFrame(AVFrame* frame);
|
|
|
|
|
2019-02-18 12:13:45 -08:00
|
|
|
void dropFrameForEnqueue(QQueue<AVFrame*>& queue);
|
|
|
|
|
2019-02-15 22:09:50 -08:00
|
|
|
QQueue<AVFrame*> m_RenderQueue;
|
|
|
|
QQueue<AVFrame*> m_PacingQueue;
|
|
|
|
QQueue<int> m_PacingQueueHistory;
|
2019-02-15 23:51:20 -08:00
|
|
|
QQueue<int> m_RenderQueueHistory;
|
2019-01-22 20:31:31 -08:00
|
|
|
QMutex m_FrameQueueLock;
|
2019-02-15 22:09:50 -08:00
|
|
|
QWaitCondition m_RenderQueueNotEmpty;
|
|
|
|
QWaitCondition m_PacingQueueNotEmpty;
|
2019-01-22 20:31:31 -08:00
|
|
|
SDL_Thread* m_RenderThread;
|
|
|
|
bool m_Stopping;
|
2018-08-15 22:02:15 -07:00
|
|
|
|
|
|
|
IVsyncSource* m_VsyncSource;
|
2018-08-15 23:57:03 -07:00
|
|
|
IFFmpegRenderer* m_VsyncRenderer;
|
2018-08-15 22:02:15 -07:00
|
|
|
int m_MaxVideoFps;
|
|
|
|
int m_DisplayFps;
|
2018-09-25 00:47:59 -07:00
|
|
|
PVIDEO_STATS m_VideoStats;
|
2022-04-24 17:43:35 -05:00
|
|
|
int m_RendererAttributes;
|
2018-08-15 22:02:15 -07:00
|
|
|
};
|