moonlight-qt/app/streaming/video/ffmpeg-renderers/renderer.h

72 lines
1.9 KiB
C
Raw Normal View History

2018-07-13 09:28:10 +00:00
#pragma once
#include <SDL.h>
#include "streaming/video/decoder.h"
#include "streaming/video/overlaymanager.h"
2018-07-13 09:28:10 +00:00
extern "C" {
#include <libavcodec/avcodec.h>
}
#define RENDERER_ATTRIBUTE_FULLSCREEN_ONLY 0x01
#define RENDERER_ATTRIBUTE_1080P_MAX 0x02
class IFFmpegRenderer : public Overlay::IOverlayRenderer {
2018-07-13 09:28:10 +00:00
public:
virtual bool initialize(PDECODER_PARAMETERS params) = 0;
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) = 0;
virtual void renderFrame(AVFrame* frame) = 0;
2019-04-13 05:12:53 +00:00
virtual bool needsTestFrame() {
// No test frame required by default
return false;
}
virtual int getDecoderCapabilities() {
// No special capabilities by default
return 0;
}
virtual int getRendererAttributes() {
// No special attributes by default
return 0;
}
virtual int getDecoderColorspace() {
// Rec 601 is default
return COLORSPACE_REC_601;
}
2019-04-13 05:12:53 +00:00
virtual bool isRenderThreadSupported() {
// Render thread is supported by default
return true;
}
2019-04-13 05:54:21 +00:00
virtual bool isDirectRenderingSupported() {
// The renderer can render directly to the display
return true;
}
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) {
if (videoFormat == VIDEO_FORMAT_H265_MAIN10) {
// 10-bit YUV 4:2:0
return AV_PIX_FMT_P010;
}
else {
// Planar YUV 4:2:0
return AV_PIX_FMT_YUV420P;
}
}
virtual bool isPixelFormatSupported(int videoFormat, enum AVPixelFormat pixelFormat) {
// By default, we only support the preferred pixel format
return getPreferredPixelFormat(videoFormat) == pixelFormat;
}
// IOverlayRenderer
virtual void notifyOverlayUpdated(Overlay::OverlayType) override {
// Nothing
}
2018-07-13 09:28:10 +00:00
};