2018-07-13 09:28:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <SDL.h>
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
}
|
|
|
|
|
2018-07-18 03:00:16 +00:00
|
|
|
class IFFmpegRenderer {
|
2018-07-13 09:28:10 +00:00
|
|
|
public:
|
2018-12-25 20:57:00 +00:00
|
|
|
enum FramePacingConstraint {
|
|
|
|
PACING_FORCE_OFF,
|
|
|
|
PACING_FORCE_ON,
|
|
|
|
PACING_ANY
|
2018-09-04 00:57:09 +00:00
|
|
|
};
|
|
|
|
|
2018-07-18 03:00:16 +00:00
|
|
|
virtual ~IFFmpegRenderer() {}
|
2018-07-13 09:28:10 +00:00
|
|
|
virtual bool initialize(SDL_Window* window,
|
|
|
|
int videoFormat,
|
|
|
|
int width,
|
2018-08-16 03:41:19 +00:00
|
|
|
int height,
|
2018-08-21 01:19:42 +00:00
|
|
|
int maxFps,
|
|
|
|
bool enableVsync) = 0;
|
2018-07-13 09:28:10 +00:00
|
|
|
virtual bool prepareDecoderContext(AVCodecContext* context) = 0;
|
2018-08-16 06:57:03 +00:00
|
|
|
virtual void renderFrameAtVsync(AVFrame* frame) = 0;
|
2018-08-19 07:59:04 +00:00
|
|
|
virtual bool needsTestFrame() = 0;
|
2018-08-25 19:38:04 +00:00
|
|
|
virtual int getDecoderCapabilities() = 0;
|
2018-12-25 20:57:00 +00:00
|
|
|
virtual FramePacingConstraint getFramePacingConstraint() = 0;
|
2018-07-13 09:28:10 +00:00
|
|
|
};
|
|
|
|
|
2018-07-18 03:00:16 +00:00
|
|
|
class SdlRenderer : public IFFmpegRenderer {
|
2018-07-13 09:28:10 +00:00
|
|
|
public:
|
|
|
|
SdlRenderer();
|
|
|
|
virtual ~SdlRenderer();
|
|
|
|
virtual bool initialize(SDL_Window* window,
|
|
|
|
int videoFormat,
|
|
|
|
int width,
|
2018-08-16 03:41:19 +00:00
|
|
|
int height,
|
2018-08-21 01:19:42 +00:00
|
|
|
int maxFps,
|
|
|
|
bool enableVsync);
|
2018-07-13 09:28:10 +00:00
|
|
|
virtual bool prepareDecoderContext(AVCodecContext* context);
|
2018-08-16 06:57:03 +00:00
|
|
|
virtual void renderFrameAtVsync(AVFrame* frame);
|
2018-08-19 07:59:04 +00:00
|
|
|
virtual bool needsTestFrame();
|
2018-08-25 19:38:04 +00:00
|
|
|
virtual int getDecoderCapabilities();
|
2018-12-25 20:57:00 +00:00
|
|
|
virtual FramePacingConstraint getFramePacingConstraint();
|
2018-07-13 09:28:10 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SDL_Renderer* m_Renderer;
|
|
|
|
SDL_Texture* m_Texture;
|
|
|
|
};
|