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>
|
|
|
|
|
|
|
|
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
|
|
|
|
2018-08-16 17:59:33 -07:00
|
|
|
bool isUsingFrameQueue();
|
|
|
|
|
2018-08-15 22:02:15 -07:00
|
|
|
private:
|
2019-01-20 19:59:29 -08:00
|
|
|
void renderFrame(AVFrame* frame);
|
|
|
|
|
2018-08-15 22:02:15 -07:00
|
|
|
QQueue<AVFrame*> m_FrameQueue;
|
|
|
|
QQueue<int> m_FrameQueueHistory;
|
|
|
|
SDL_SpinLock m_FrameQueueLock;
|
2019-01-20 19:59:29 -08:00
|
|
|
bool m_DropNextFrame;
|
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;
|
2018-08-15 22:02:15 -07:00
|
|
|
};
|