22#ifndef __VIDEORENDER_H
23#define __VIDEORENDER_H
29#include <xf86drmMode.h>
32#include <libavutil/hwcontext_drm.h>
38#include <EGL/eglext.h>
39#include <EGL/eglplatform.h>
68#define QUIRK_NO_HW_DEINT 1 << 0
69#define QUIRK_CODEC_FLUSH_WORKAROUND 1 << 1
70#define QUIRK_CODEC_NEEDS_EXT_INIT 1 << 2
71#define QUIRK_CODEC_SKIP_FIRST_FRAMES 1 << 3
72#define QUIRK_CODEC_SKIP_NUM_FRAMES 2
73#define QUIRK_CODEC_DISABLE_MPEG_HW 1 << 4
74#define QUIRK_CODEC_DISABLE_H264_HW 1 << 5
76#define AV_SYNC_THRESHOLD_AUDIO_BEHIND_VIDEO_MS 35
77#define AV_SYNC_THRESHOLD_AUDIO_AHEAD_VIDEO_MS 5
145 void OsdDrawARGB(
int,
int,
int,
int,
int,
const uint8_t *,
int,
int);
184 void DisableOglOsd(
void) { m_disableOglOsd =
true; };
185 void EnableOglOsd(
void) { m_disableOglOsd =
false; };
186 bool OglOsdDisabled(
void) {
return m_disableOglOsd; };
187 EGLSurface EglSurface(
void) {
return m_pDrmDevice->EglSurface(); };
188 EGLDisplay EglDisplay(
void) {
return m_pDrmDevice->EglDisplay(); };
189 EGLContext EglContext(
void) {
return m_pDrmDevice->EglContext(); };
190 int GlInitiated(
void) {
return m_pDrmDevice->GlInitiated(); };
258 bool m_disableOglOsd;
260 struct gbm_bo *m_pOldBo;
261 struct gbm_bo *m_pNextBo;
cDrmBuffer * GetBuffer(cDrmBufferPool *, AVDRMFrameDescriptor *) override
cDrmBuffer * GetBuffer(cDrmBufferPool *, AVDRMFrameDescriptor *) override
cDrmBuffer * GetBuffer(cDrmBufferPool *, AVDRMFrameDescriptor *) override
virtual cDrmBuffer * GetBuffer(cDrmBufferPool *, AVDRMFrameDescriptor *)=0
virtual ~cBufferStrategy()=default
AVFrame * PrepareDrmBuffer(cDrmBuffer *, int, AVFrame *) override
AVFrame * PrepareDrmBuffer(cDrmBuffer *, int, AVFrame *) override
virtual AVFrame * PrepareDrmBuffer(cDrmBuffer *, int, AVFrame *)=0
virtual ~cDecodingStrategy()=default
size_t Size(void)
Get the current size of the queue.
cSoftHdAudio - Audio class
cSoftHdGrab - Grabber class
cVideoRender - Video render class
void PushPipFrame(AVFrame *)
void SetFrameFlags(AVFrame *, int)
Set frame flags.
int m_numWrongProgressive
counter for progressive frames sent in an interlaced stream (only used for logging)
int DrmHandleEvent(void)
Wrapper for drmHandleEvent()
bool IsOutputBufferFull(void)
Check, if the main render output buffer is full.
int m_framesDuped
number of frames duplicated
void SetScreenSize(int, int, uint32_t)
Wrapper to set the screen size in the device.
bool m_osdShown
set, if osd is shown currently
cCondVar m_grabCond
condition gets signalled, if renederer finished to clone the grabbed buffers
cDrmBuffer * m_pCurrentlyDisplayed
pointer to currently displayed DRM buffer
int m_pipScalePercent
scale factor for pip
int GetFramesFilled(void)
void ConvertPipBufToRgb(void)
Convert the pip drm buffer to an rgb image.
std::atomic< bool > m_resumeAudioScheduled
set, if audio resume is scheduled after a pause
void ConvertVideoBufToRgb(void)
Convert the video drm buffer to an rgb image.
void ResetBufferReuseStrategy()
std::atomic< bool > m_displayOneFrameThenPause
set, if only one frame shall be displayed and then pause playback
std::vector< Event > m_eventQueue
event queue for incoming events
cDrmBufferPool m_pipDrmBufferPool
PIP pool of drm buffers.
void ProcessEvents(void)
Process queued events and forward to event receiver.
int m_framesDropped
number of frames dropped
void OsdClear(void)
Clear the OSD (draw an empty/ transparent OSD)
cDisplayThread * m_pDisplayThread
pointer to display thread
int64_t m_pts
current video PTS
cSoftHdGrab * GetGrab(int *, int *, int *, int *, int *, int)
Get the grabbed image.
int m_trickSpeed
current trick speed
std::atomic< bool > m_pipActive
true, if pip should be displayed
cSoftHdGrab m_grabVideo
keeps the current grabbed video
int SetOsdBuffer(drmModeAtomicReqPtr)
Modesetting for osd.
void ClearDecoderToDisplayQueue(void)
Clear (empty) the decoder to display queue.
void Init(void)
Initialize the renderer.
void ResetDecodingStrategy()
std::atomic< bool > m_videoPlaybackPaused
set, if playback is frozen (used for pause)
void PushFrame(AVFrame *, bool, std::atomic< cBufferStrategy * > &, std::atomic< cDecodingStrategy * > &, cQueue< cDrmBuffer > *, cDrmBufferPool *)
Push the frame into the render ringbuffer.
void Exit(void)
Exit and cleanup the renderer.
cMutex m_trickspeedMutex
mutex used while accessing trickspeed parameters
cQueue< cDrmBuffer > m_drmBufferQueue
queue for DRM buffers to be displayed (VIDEO_SURFACES_MAX is defined in thread.h)
cRect m_lastVideoGrab
crtc rect of the last shown video frame
virtual ~cVideoRender(void)
cVideoRender destructor
cRect m_videoRect
rect of the currently displayed video
bool m_startgrab
internal flag to trigger grabbing
void GetStats(int *, int *, int *)
Get some rendering statistics.
std::atomic< cDecodingStrategy * > m_pipDecodingStrategy
strategy for decoding setup
void SetTrickSpeed(int, int)
Set the trickspeed parameters.
std::atomic< cBufferStrategy * > m_bufferReuseStrategy
strategy to select drm buffers
void DisplayBlackFrame(void)
void SetVideoClock(int64_t)
Wrapper to set the video clock (m_pts)
cSoftHdAudio * m_pAudio
pointer to cSoftHdAudio
AVRational m_timebase
timebase used for pts, set by first RenderFrame()
void PushMainFrame(AVFrame *)
void SetVideoOutputPosition(const cRect &)
Set size and position of the video on the screen.
cVideoRender(cSoftHdDevice *)
cVideoRender constructor
int GetFrameFlags(AVFrame *)
Get frame flags.
int m_pipTopPercent
top margin for pip
cDrmBuffer * m_pBufOsd
pointer to osd drm buffer object
int64_t GetOutputPtsMs(void)
Get the output PTS in milliseconds.
cSoftHdDevice * m_pDevice
pointer to cSoftHdDevice
int m_framePresentationCounter
number of times the current frame has to be shown (for slow motion)
void SetPipActive(bool on)
std::atomic< cBufferStrategy * > m_pipBufferReuseStrategy
strategy to select drm buffers
cSoftHdConfig * m_pConfig
pointer to cSoftHdConfig
void DisplayThreadHalt(void)
void ClearPipDecoderToDisplayQueue(void)
Clear (empty) the decoder to display queue.
void ClearGrab(void)
Clear the grab drm buffers.
cSoftHdGrab m_grabOsd
keeps the current grabbed osd
int CommitBuffer(cDrmBuffer *, cDrmBuffer *)
Commit the frame to the hardware.
int TriggerGrab(void)
Trigger a screen grab.
IEventReceiver * m_pEventReceiver
pointer to event receiver
cQueue< cDrmBuffer > m_pipDrmBufferQueue
queue for PIP DRM buffers to be displayed (VIDEO_SURFACES_MAX is defined in thread....
cQueue< cDrmBuffer > * GetPipOutputBuffer(void)
cRect m_lastPipGrab
crtc rect of the last shown pip frame
void LogDroppedDuped(int64_t, int64_t, int)
Log A/V sync debug message.
void SetPipBuffer(cDrmBuffer *)
Modesetting for pip.
bool DisplayFrame()
Display the frame (video and/or osd)
void ConvertOsdBufToRgb(void)
Convert the osd drm buffer to an rgb image.
void SchedulePlaybackStartAtPtsMs(int64_t ptsMs)
void SetVideoBuffer(cDrmBuffer *)
Modesetting for video.
cDrmBuffer * m_pCurrentlyPipDisplayed
pointer to currently displayed DRM buffer
int64_t GetVideoClock(void)
Wrapper to get the video clock (m_pts)
int GetTrickForward(void)
Get the current trickspeed direction.
void OsdDrawARGB(int, int, int, int, int, const uint8_t *, int, int)
Draw an OSD ARGB image.
void SetScheduleAudioResume(bool resume)
cDrmDevice * m_pDrmDevice
pointer cDrmDevice object
void Grab(cDrmBuffer *, cDrmBuffer *)
Grab video and osd.
cMutex m_timebaseMutex
mutex used around m_timebase
cMutex m_videoClockMutex
mutex used around m_pts
std::atomic< cDecodingStrategy * > m_decodingStrategy
strategy for decoding setup
void SetDisplayOneFrameThenPause(bool pause)
int GetTrickSpeed(void)
Get the current trickspeed.
bool m_lastFrameWasDropped
true, if the last frame was dropped
bool PageFlip(cDrmBuffer *, cDrmBuffer *)
Do the pageflip.
int m_pipLeftPercent
left margin for pip
void SetPlaybackPaused(bool pause)
cDrmBufferPool m_drmBufferPool
pool of drm buffers
std::atomic< int64_t > m_schedulePlaybackStartAtPtsMs
if set, frames with PTS older than this will be dropped
void DisplayThreadResume(void)
void ResetFrameCounter(void)
Send start condition to video thread.
int m_startCounter
counter for displayed frames, indicates a video start
bool m_trickForward
true, if trickspeed plays forward
bool m_videoIsScaled
true, if the currently displayed video is scaled
void ExitDisplayThread(void)
Stop display thread.
cQueue< cDrmBuffer > * GetMainOutputBuffer(void)
cDrmBuffer m_bufBlack
black drm buffer object
cSoftHdGrab m_grabPip
keeps the current grabbed pip video
SoftHdDevice config header file.
State machine and event header file.
Some helper functions for GL.
Atomic wrapper macros function header file.
Logger class header file.
#define VIDEO_SURFACES_MAX
Thread-safe queue header file.
Device class header file.
Thread classes header file.
Videostream class header file.