mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-12-15 22:02:29 +00:00
26d04b5f9c
We can't always assume they are NV12. Even if they _are_ NV12, they may have DRM format modifiers that are incompatible with simply assuming linear Y and UV buffers (such as tiling).
45 lines
1.5 KiB
C++
45 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include "renderer.h"
|
|
|
|
#include <xf86drm.h>
|
|
#include <xf86drmMode.h>
|
|
|
|
class DrmRenderer : public IFFmpegRenderer {
|
|
public:
|
|
DrmRenderer();
|
|
virtual ~DrmRenderer() override;
|
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
|
|
virtual void renderFrame(AVFrame* frame) override;
|
|
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override;
|
|
virtual int getRendererAttributes() override;
|
|
virtual bool needsTestFrame() override;
|
|
virtual bool isDirectRenderingSupported() override;
|
|
#ifdef HAVE_EGL
|
|
virtual bool canExportEGL() override;
|
|
virtual AVPixelFormat getEGLImagePixelFormat() override;
|
|
virtual bool initializeEGL(EGLDisplay dpy, const EGLExtensions &ext) override;
|
|
virtual ssize_t exportEGLImages(AVFrame *frame, EGLDisplay dpy, EGLImage images[EGL_MAX_PLANES]) override;
|
|
virtual void freeEGLImages(EGLDisplay dpy, EGLImage[EGL_MAX_PLANES]) override;
|
|
#endif
|
|
|
|
private:
|
|
AVBufferRef* m_HwContext;
|
|
int m_DrmFd;
|
|
bool m_SdlOwnsDrmFd;
|
|
bool m_SupportsDirectRendering;
|
|
uint32_t m_CrtcId;
|
|
uint32_t m_PlaneId;
|
|
uint32_t m_CurrentFbId;
|
|
SDL_Rect m_OutputRect;
|
|
|
|
#ifdef HAVE_EGL
|
|
bool m_EGLExtDmaBuf;
|
|
PFNEGLCREATEIMAGEPROC m_eglCreateImage;
|
|
PFNEGLDESTROYIMAGEPROC m_eglDestroyImage;
|
|
PFNEGLCREATEIMAGEKHRPROC m_eglCreateImageKHR;
|
|
PFNEGLDESTROYIMAGEKHRPROC m_eglDestroyImageKHR;
|
|
#endif
|
|
};
|
|
|