MythTV  master
mythvideoout.h
Go to the documentation of this file.
1 #ifndef MYTH_VIDEOOUT_H_
2 #define MYTH_VIDEOOUT_H_
3 
4 // Std
5 #include <memory>
6 
7 // Qt
8 #include <QSize>
9 #include <QRect>
10 #include <QString>
11 #include <QPoint>
12 #include <QMap>
13 #include <qwindowdefs.h>
14 
15 // MythTV
16 #include "libmythtv/mythavutil.h"
17 #include "libmythtv/mythcodecid.h"
19 #include "libmythtv/mythframe.h"
23 #include "libmythtv/videobuffers.h"
25 #include "libmythui/mythdisplay.h"
26 
27 class MythPlayer;
28 class OSD;
29 class AudioPlayer;
30 class MythRender;
31 class MythPainter;
32 
33 using MythVideoProfilePtr = std::shared_ptr<MythVideoProfile>;
34 
36 {
37  Q_OBJECT
38 
39  public:
40  static void GetRenderOptions(RenderOptions& Options, MythRender* Render);
41 
42  ~MythVideoOutput() override = default;
43 
44  virtual bool Init(QSize VideoDim, QSize VideoDispDim,
45  float VideoAspect, QRect WindowRect, MythCodecID CodecID);
46  virtual void SetVideoFrameRate(float VideoFrameRate);
47  virtual void SetDeinterlacing(bool Enable, bool DoubleRate, MythDeintType Force = DEINT_NONE);
48  virtual void PrepareFrame (MythVideoFrame* Frame, FrameScanType Scan = kScan_Ignore) = 0;
49  virtual void RenderFrame (MythVideoFrame* Frame, FrameScanType) = 0;
50  virtual void RenderEnd () = 0;
51  virtual void EndFrame () = 0;
52  virtual bool InputChanged(QSize VideoDim, QSize VideoDispDim,
53  float VideoAspect, MythCodecID CodecID,
54  bool& AspectChanged, int ReferenceFrames, bool ForceChange);
55  virtual void GetOSDBounds(QRect& Total, QRect& Visible,
56  float& VisibleAspect, float& FontScaling,
57  float ThemeAspect) const;
58  virtual void SetFramesPlayed(long long FramesPlayed);
59  virtual long long GetFramesPlayed();
60  bool IsErrored() const;
61  VideoErrorState GetError() const;
62 
63  void SetPrebuffering(bool Normal);
64  virtual void ClearAfterSeek();
65  virtual int ValidVideoFrames() const;
66  int FreeVideoFrames();
67  bool EnoughFreeFrames();
68  bool EnoughDecodedFrames();
70  virtual void ReleaseFrame(MythVideoFrame* Frame);
71  virtual void DeLimboFrame(MythVideoFrame* Frame);
72  virtual void StartDisplayingFrame();
74  virtual void DiscardFrame(MythVideoFrame* Frame);
75  virtual void DiscardFrames(bool KeyFrame, bool Flushed);
76  virtual void CheckFrameStates() { }
79  QString GetFrameStatus() const;
80  QRect GetImageRect(QRect Rect, QRect* DisplayRect = nullptr);
81  QRect GetSafeRect();
82 
83  // These methods are only required by MythPlayerUI
85  virtual void InitPictureAttributes () { }
86  bool HasSoftwareFrames () const { return codec_sw_copy(m_videoCodecID); }
87  virtual void UpdatePauseFrame (std::chrono::milliseconds& /*DisplayTimecode*/,
88  FrameScanType /*Scan*/ = kScan_Progressive) {}
89 
90  protected:
92  QRect GetVisibleOSDBounds(float& VisibleAspect, float& FontScaling, float ThemeAspect) const;
93 
96  uint8_t m_clearColor { 0 };
97  uint8_t m_clearAlpha { 255 };
103  long long m_framesPlayed { 0 };
107  bool m_deinterlacing { false };
108  bool m_deinterlacing2X { false };
110 
111  private:
112  Q_DISABLE_COPY(MythVideoOutput)
113 };
114 
115 #endif
MythVideoOutput::GetOSDBounds
virtual void GetOSDBounds(QRect &Total, QRect &Visible, float &VisibleAspect, float &FontScaling, float ThemeAspect) const
Definition: mythvideoout.cpp:207
MythVideoOutput::m_dbLetterboxColour
LetterBoxColour m_dbLetterboxColour
Definition: mythvideoout.h:95
MythVideoOutput::InputChanged
virtual bool InputChanged(QSize VideoDim, QSize VideoDispDim, float VideoAspect, MythCodecID CodecID, bool &AspectChanged, int ReferenceFrames, bool ForceChange)
Tells video output to discard decoded frames and wait for new ones.
Definition: mythvideoout.cpp:187
MythVideoOutput
Definition: mythvideoout.h:35
kScan_Ignore
@ kScan_Ignore
Definition: videoouttypes.h:96
AudioPlayer
Definition: audioplayer.h:22
MythCodecID
MythCodecID
Definition: mythcodecid.h:11
MythVideoOutput::FreeVideoFrames
int FreeVideoFrames()
Returns number of frames available for decoding onto.
Definition: mythvideoout.cpp:284
MythVideoOutput::GetError
VideoErrorState GetError() const
Definition: mythvideoout.cpp:260
MythVideoOutput::m_framesPlayed
long long m_framesPlayed
Definition: mythvideoout.h:103
VideoBuffers
Definition: videobuffers.h:38
kScan_Progressive
@ kScan_Progressive
Definition: videoouttypes.h:100
MythVideoOutput::m_errorState
VideoErrorState m_errorState
Definition: mythvideoout.h:102
Frame
Definition: zmdefines.h:102
MythVideoOutput::PrepareFrame
virtual void PrepareFrame(MythVideoFrame *Frame, FrameScanType Scan=kScan_Ignore)=0
MythVideoOutput::~MythVideoOutput
~MythVideoOutput() override=default
MythVideoOutput::m_forcedDeinterlacer
MythDeintType m_forcedDeinterlacer
Definition: mythvideoout.h:109
kError_None
@ kError_None
Definition: videoouttypes.h:184
MythVideoOutput::SetFramesPlayed
virtual void SetFramesPlayed(long long FramesPlayed)
Definition: mythvideoout.cpp:245
mythframe.h
MythPlayer
Definition: mythplayer.h:83
codec_sw_copy
static bool codec_sw_copy(MythCodecID id)
Definition: mythcodecid.h:372
LetterBoxColour
LetterBoxColour
Definition: videoouttypes.h:86
Visible
Definition: channelsettings.cpp:416
mythdeinterlacer.h
kCodec_NONE
@ kCodec_NONE
Definition: mythcodecid.h:15
MythVideoOutput::SetPrebuffering
void SetPrebuffering(bool Normal)
Sets whether to use a normal number of buffers or fewer buffers.
Definition: mythvideoout.cpp:266
MythDeintType
MythDeintType
Definition: mythframe.h:66
videobuffers.h
MythVideoOutput::m_copyFrame
MythAVCopy m_copyFrame
Definition: mythvideoout.h:104
MythVideoOutput::EndFrame
virtual void EndFrame()=0
mythvideocolourspace.h
mythdisplay.h
MythVideoOutput::Init
virtual bool Init(QSize VideoDim, QSize VideoDispDim, float VideoAspect, QRect WindowRect, MythCodecID CodecID)
Definition: mythvideoout.cpp:110
VideoErrorState
VideoErrorState
Definition: videoouttypes.h:182
PictureAttributeSupported
PictureAttributeSupported
Definition: videoouttypes.h:116
RenderOptions
Definition: mythvideoprofile.h:41
MythVideoOutput::m_clearAlpha
uint8_t m_clearAlpha
Definition: mythvideoout.h:97
MythVideoOutput::ValidVideoFrames
virtual int ValidVideoFrames() const
Returns number of frames that are fully decoded.
Definition: mythvideoout.cpp:278
videoouttypes.h
MythVideoOutput::CheckFrameStates
virtual void CheckFrameStates()
Definition: mythvideoout.h:76
MythVideoOutput::ClearAfterSeek
virtual void ClearAfterSeek()
Tells video output to toss decoded buffers due to a seek.
Definition: mythvideoout.cpp:272
MythVideoOutput::DeLimboFrame
virtual void DeLimboFrame(MythVideoFrame *Frame)
Releases a frame for reuse if it is in limbo.
Definition: mythvideoout.cpp:406
VideoFrameTypes
std::vector< VideoFrameType > VideoFrameTypes
Definition: mythframe.h:82
MythVideoOutput::GetFrameStatus
QString GetFrameStatus() const
Returns string with status of each frame for debugging.
Definition: mythvideoout.cpp:309
MythVideoOutput::m_videoProfile
MythVideoProfilePtr m_videoProfile
Definition: mythvideoout.h:100
MythVideoOutput::GetNextFreeFrame
virtual MythVideoFrame * GetNextFreeFrame()
Blocks until it is possible to return a frame for decoding onto.
Definition: mythvideoout.cpp:393
MythVideoOutput::GetImageRect
QRect GetImageRect(QRect Rect, QRect *DisplayRect=nullptr)
translates caption/dvd button rectangle into 'screen' space
Definition: mythvideoout.cpp:322
MythDeinterlacer
Handles software based deinterlacing of video frames.
Definition: mythdeinterlacer.h:17
mythcodecid.h
MythVideoOutput::GetFramesPlayed
virtual long long GetFramesPlayed()
Definition: mythvideoout.cpp:250
kLetterBoxColour_Black
@ kLetterBoxColour_Black
Definition: videoouttypes.h:89
mythvideoprofile.h
MythVideoOutput::DiscardFrames
virtual void DiscardFrames(bool KeyFrame, bool Flushed)
Releases all frames not being actively displayed from any queue onto the queue of frames ready for de...
Definition: mythvideoout.cpp:434
MythVideoOutput::GetLastDecodedFrame
virtual MythVideoFrame * GetLastDecodedFrame()
Definition: mythvideoout.cpp:303
MythVideoOutput::m_videoCodecID
MythCodecID m_videoCodecID
Definition: mythvideoout.h:98
DEINT_NONE
@ DEINT_NONE
Definition: mythframe.h:68
MythVideoOutput::m_deinterlacer
MythDeinterlacer m_deinterlacer
Definition: mythvideoout.h:105
MythVideoBounds
Definition: mythvideobounds.h:23
MythVideoOutput::EnoughFreeFrames
bool EnoughFreeFrames()
Returns true iff enough frames are available to decode onto.
Definition: mythvideoout.cpp:290
MythVideoOutput::ReleaseFrame
virtual void ReleaseFrame(MythVideoFrame *Frame)
Releases a frame from the ready for decoding queue onto the queue of frames ready for display.
Definition: mythvideoout.cpp:400
MythVideoOutput::StartDisplayingFrame
virtual void StartDisplayingFrame()
Tell GetLastShownFrame() to return the next frame from the head of the queue of frames to display.
Definition: mythvideoout.cpp:413
MythVideoOutput::IsErrored
bool IsErrored() const
Definition: mythvideoout.cpp:255
MythVideoOutput::RenderFrame
virtual void RenderFrame(MythVideoFrame *Frame, FrameScanType)=0
MythVideoOutput::m_renderFormats
const VideoFrameTypes * m_renderFormats
Definition: mythvideoout.h:106
MythVideoOutput::DiscardFrame
virtual void DiscardFrame(MythVideoFrame *Frame)
Releases frame from any queue onto the queue of frames ready for decoding onto.
Definition: mythvideoout.cpp:427
MythVideoFrame::kDefaultRenderFormats
static const VideoFrameTypes kDefaultRenderFormats
Definition: mythframe.h:90
MythVideoOutput::GetSupportedPictureAttributes
PictureAttributeSupported GetSupportedPictureAttributes()
Definition: mythvideoout.cpp:240
MythRender
Definition: mythrender_base.h:23
MythPainter
Definition: mythpainter.h:34
MythVideoOutput::m_clearColor
uint8_t m_clearColor
Definition: mythvideoout.h:96
mythavutil.h
MythVideoOutput::MythVideoOutput
MythVideoOutput()
Definition: mythvideoout.cpp:99
MythVideoOutput::GetSafeRect
QRect GetSafeRect()
Returns a QRect describing an area of the screen on which it is 'safe' to render the On Screen Displa...
Definition: mythvideoout.cpp:379
MythAVCopy
Definition: mythavutil.h:44
MythVideoOutput::HasSoftwareFrames
bool HasSoftwareFrames() const
Definition: mythvideoout.h:86
FrameScanType
FrameScanType
Definition: videoouttypes.h:94
MythVideoProfilePtr
std::shared_ptr< MythVideoProfile > MythVideoProfilePtr
Definition: mythvideogpu.h:18
MythVideoOutput::GetRenderOptions
static void GetRenderOptions(RenderOptions &Options, MythRender *Render)
Definition: mythvideoout.cpp:24
MythVideoOutput::SetDeinterlacing
virtual void SetDeinterlacing(bool Enable, bool DoubleRate, MythDeintType Force=DEINT_NONE)
Definition: mythvideoout.cpp:141
MythVideoFrame
Definition: mythframe.h:87
MythVideoOutput::EnoughDecodedFrames
bool EnoughDecodedFrames()
Returns true iff there are plenty of decoded frames ready for display.
Definition: mythvideoout.cpp:297
MythVideoOutput::InitPictureAttributes
virtual void InitPictureAttributes()
Definition: mythvideoout.h:85
MythVideoOutput::GetLastShownFrame
virtual MythVideoFrame * GetLastShownFrame()
Returns frame from the head of the ready to be displayed queue, if StartDisplayingFrame has been call...
Definition: mythvideoout.cpp:316
MythVideoOutput::RenderEnd
virtual void RenderEnd()=0
MythVideoOutput::m_maxReferenceFrames
int m_maxReferenceFrames
Definition: mythvideoout.h:99
mythvideobounds.h
MythVideoOutput::GetVisibleOSDBounds
QRect GetVisibleOSDBounds(float &VisibleAspect, float &FontScaling, float ThemeAspect) const
Returns visible portions of total OSD bounds.
Definition: mythvideoout.cpp:222
MythVideoColourSpace
MythVideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.
Definition: mythvideocolourspace.h:18
OSD
Definition: osd.h:93
MythVideoOutput::UpdatePauseFrame
virtual void UpdatePauseFrame(std::chrono::milliseconds &, FrameScanType=kScan_Progressive)
Definition: mythvideoout.h:87
MythVideoOutput::SetVideoFrameRate
virtual void SetVideoFrameRate(float VideoFrameRate)
Definition: mythvideoout.cpp:135
MythVideoOutput::m_deinterlacing2X
bool m_deinterlacing2X
Definition: mythvideoout.h:108
MythVideoOutput::m_videoBuffers
VideoBuffers m_videoBuffers
Definition: mythvideoout.h:101
MythVideoOutput::m_videoColourSpace
MythVideoColourSpace m_videoColourSpace
Definition: mythvideoout.h:94
MythVideoOutput::m_deinterlacing
bool m_deinterlacing
Definition: mythvideoout.h:107
MythVideoOutput::DoneDisplayingFrame
virtual void DoneDisplayingFrame(MythVideoFrame *Frame)
Releases frame returned from GetLastShownFrame() onto the queue of frames ready for decoding onto.
Definition: mythvideoout.cpp:420