MythTV  master
mythvideoout.h
Go to the documentation of this file.
1 #ifndef MYTH_VIDEOOUT_H_
2 #define MYTH_VIDEOOUT_H_
3 
4 // Qt
5 #include <QSize>
6 #include <QRect>
7 #include <QString>
8 #include <QPoint>
9 #include <QMap>
10 #include <qwindowdefs.h>
11 
12 // MythTV
13 #include "mythframe.h"
14 #include "videobuffers.h"
15 #include "mythcodecid.h"
16 #include "videoouttypes.h"
17 #include "videooutwindow.h"
18 #include "mythdisplay.h"
19 #include "videodisplayprofile.h"
20 #include "videocolourspace.h"
22 #include "mythavutil.h"
23 #include "mythdeinterlacer.h"
24 
25 using namespace std;
26 
27 class MythPlayer;
28 class OSD;
29 class AudioPlayer;
30 class MythRender;
31 
32 using PIPMap = QMap<MythPlayer*,PIPLocation>;
33 
34 class MythMultiLocker;
35 
37 {
38  public:
39  static void GetRenderOptions(RenderOptions &Options);
40  static MythVideoOutput *Create(const QString &Decoder, MythCodecID CodecID,
41  PIPState PiPState, const QSize &VideoDim,
42  const QSize &VideoDispDim, float VideoAspect,
43  QWidget *ParentWidget, const QRect &EmbedRect,
44  float FrameRate, uint PlayerFlags,
45  QString &Codec, int ReferenceFrames);
46 
48  virtual ~MythVideoOutput();
49 
50  virtual bool Init(const QSize &VideoDim, const QSize &VideoDispDim,
51  float VideoAspect, MythDisplay *Display,
52  const QRect &WindowRect, MythCodecID CodecID);
53  virtual void SetVideoFrameRate(float playback_fps);
54  virtual void SetDeinterlacing(bool Enable, bool DoubleRate, MythDeintType Force = DEINT_NONE);
55  virtual void ProcessFrame(VideoFrame *Frame, OSD *Osd, const PIPMap &PipPlayers,
56  FrameScanType Scan = kScan_Ignore) = 0;
57  virtual void PrepareFrame(VideoFrame *Frame, FrameScanType, OSD *Osd) = 0;
58  virtual void Show(FrameScanType) = 0;
59  void SetReferenceFrames(int ReferenceFrames);
60  VideoDisplayProfile *GetProfile() { return m_dbDisplayProfile; }
61  virtual void WindowResized(const QSize &/*size*/) {}
62  virtual bool InputChanged(const QSize &VideoDim, const QSize &VideoDispDim,
63  float VideoAspect, MythCodecID CodecID,
64  bool &AspectChanged, MythMultiLocker* Locks,
65  int ReferenceFrames, bool ForceChange);
66  virtual void VideoAspectRatioChanged(float VideoAspect);
67  virtual void ResizeDisplayWindow(const QRect& Rect, bool SaveVisible);
68  virtual void EmbedInWidget(const QRect &EmbedRect);
69  bool IsEmbedding(void);
70  virtual void StopEmbedding(void);
71  virtual void ResizeForVideo(QSize Size = QSize());
72  virtual void Zoom(ZoomDirection Direction);
73  virtual void ToggleMoveBottomLine(void);
74  virtual void SaveBottomLine(void);
75  virtual void GetOSDBounds(QRect &Total, QRect &Visible,
76  float &VisibleAspect, float &FontScaling,
77  float ThemeAspect) const;
78  QRect GetMHEGBounds(void);
79  AspectOverrideMode GetAspectOverride(void) const;
80  virtual void ToggleAspectOverride(AspectOverrideMode AspectMode = kAspect_Toggle);
81  AdjustFillMode GetAdjustFill(void) const;
82  virtual void ToggleAdjustFill(AdjustFillMode FillMode = kAdjustFill_Toggle);
83  QString GetZoomString(void) const;
84  PictureAttributeSupported GetSupportedPictureAttributes(void);
85  int ChangePictureAttribute(PictureAttribute AttributeType, bool Direction);
86  virtual int SetPictureAttribute(PictureAttribute Attribute, int NewValue);
87  int GetPictureAttribute(PictureAttribute AttributeType);
88  virtual void InitPictureAttributes(void) { }
89  virtual bool IsPIPSupported(void) const { return false; }
90  virtual bool IsPBPSupported(void) const { return false; }
91  bool HasSoftwareFrames(void) const { return codec_sw_copy(m_videoCodecID); }
92  virtual void SetFramesPlayed(long long FramesPlayed);
93  virtual long long GetFramesPlayed(void);
94  bool IsErrored() const;
95  VideoErrorState GetError(void) const;
96 
97  void SetPrebuffering(bool Normal);
98  virtual void ClearAfterSeek(void);
99  virtual int ValidVideoFrames(void) const;
100  int FreeVideoFrames(void);
101  bool EnoughFreeFrames(void);
102  bool EnoughDecodedFrames(void);
103  virtual VideoFrameType* DirectRenderFormats(void);
104  virtual VideoFrame *GetNextFreeFrame(void);
105  virtual void ReleaseFrame(VideoFrame *Frame);
106  virtual void DeLimboFrame(VideoFrame *Frame);
107  virtual void StartDisplayingFrame(void);
108  virtual void DoneDisplayingFrame(VideoFrame *Frame);
109  virtual void DiscardFrame(VideoFrame *frame);
110  virtual void DiscardFrames(bool KeyFrame, bool Flushed);
111  virtual void CheckFrameStates(void) { }
112  virtual VideoFrame *GetLastDecodedFrame(void);
113  virtual VideoFrame *GetLastShownFrame(void);
114  QString GetFrameStatus(void) const;
115  virtual void UpdatePauseFrame(int64_t &DisplayTimecode, FrameScanType Scan = kScan_Progressive) = 0;
116 
117  void SetVideoResize(const QRect &VideoRect);
118  void SetVideoScalingAllowed(bool Allow);
119  virtual QRect GetPIPRect(PIPLocation Location,
120  MythPlayer *PiPPlayer = nullptr,
121  bool DoPixelAdj = true) const;
122  virtual void RemovePIP(MythPlayer */*pipplayer*/) { }
123  virtual void SetPIPState(PIPState Setting);
124  virtual MythPainter *GetOSDPainter(void) { return nullptr; }
125 
126  QRect GetImageRect(const QRect &Rect, QRect *DisplayRect = nullptr);
127  QRect GetSafeRect(void);
128 
129  bool EnableVisualisation(AudioPlayer *Audio, bool Enable,
130  const QString &Name = QString(""));
131  virtual bool CanVisualise(AudioPlayer *Audio, MythRender *Render);
132  virtual bool SetupVisualisation(AudioPlayer *Audio, MythRender *Render,
133  const QString &Name);
134  VideoVisual* GetVisualisation(void) { return m_visual; }
135  QString GetVisualiserName(void);
136  virtual QStringList GetVisualiserList(void);
137  void DestroyVisualisation(void);
138 
139  static int CalcHueBase(const QString &AdaptorName);
140  static MythDeintType ParseDeinterlacer(const QString &Deinterlacer);
141  virtual bool StereoscopicModesAllowed(void) const { return false; }
142  void SetStereoscopicMode(StereoscopicMode mode) { m_stereo = mode; }
143  StereoscopicMode GetStereoscopicMode(void) const { return m_stereo; }
144 
145  protected:
146  virtual void MoveResize(void);
147  void InitDisplayMeasurements(void);
148  virtual void ShowPIPs(VideoFrame *Frame, const PIPMap &PiPPlayers);
149  virtual void ShowPIP(VideoFrame* /*Frame*/, MythPlayer */*PiPPlayer*/, PIPLocation /*Location*/) { }
150 
151  QRect GetVisibleOSDBounds(float& VisibleAspect,
152  float& FontScaling,
153  float ThemeAspect) const;
154  QRect GetTotalOSDBounds(void) const;
155 
156  static void CopyFrame(VideoFrame* To, const VideoFrame* From);
157 
158  MythDisplay* m_display {nullptr};
161  AspectOverrideMode m_dbAspectOverride {kAspect_Off};
162  AdjustFillMode m_dbAdjustFill {kAdjustFill_Off};
164  MythCodecID m_videoCodecID {kCodec_NONE};
165  int m_maxReferenceFrames {16};
166  VideoDisplayProfile *m_dbDisplayProfile {nullptr};
168  VideoErrorState m_errorState {kError_None};
169  long long m_framesPlayed {0};
170  VideoVisual *m_visual {nullptr};
174 };
175 
176 #endif // MYTH_VIDEOOUT_H_
VideoDisplayProfile * GetProfile()
Definition: mythvideoout.h:60
StereoscopicMode GetStereoscopicMode(void) const
Definition: mythvideoout.h:143
#define codec_sw_copy(id)
Definition: mythcodecid.h:349
QMap< MythPlayer *, PIPLocation > PIPMap
Definition: mythvideoout.h:32
VideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.
PlayerFlags
Definition: mythplayer.h:87
virtual MythPainter * GetOSDPainter(void)
Definition: mythvideoout.h:124
VideoColourSpace m_videoColourSpace
Definition: mythvideoout.h:160
PictureAttributeSupported
MythDeinterlacer m_deinterlacer
Definition: mythvideoout.h:173
MythCodecID
Definition: mythcodecid.h:10
void SetStereoscopicMode(StereoscopicMode mode)
Definition: mythvideoout.h:142
MythAVCopy Copy AVFrame<->frame, performing the required conversion if any.
Definition: mythavutil.h:106
FrameScanType
Definition: videoouttypes.h:78
VideoFrameType
Definition: mythframe.h:23
VideoErrorState
MythAVCopy m_copyFrame
Definition: mythvideoout.h:172
virtual bool IsPBPSupported(void) const
Definition: mythvideoout.h:90
MythDeintType
Definition: mythframe.h:120
virtual void WindowResized(const QSize &)
Definition: mythvideoout.h:61
AspectOverrideMode
Definition: videoouttypes.h:44
virtual bool IsPIPSupported(void) const
Definition: mythvideoout.h:89
VideoOutWindow m_window
Definition: mythvideoout.h:159
VideoBuffers m_videoBuffers
Definition: mythvideoout.h:167
PictureAttribute
Definition: videoouttypes.h:87
unsigned int uint
Definition: compat.h:140
Handles software based deinterlacing of video frames.
virtual bool StereoscopicModesAllowed(void) const
Definition: mythvideoout.h:141
PIPLocation
Definition: videoouttypes.h:17
AdjustFillMode
Definition: videoouttypes.h:55
virtual void RemovePIP(MythPlayer *)
Definition: mythvideoout.h:122
StereoscopicMode
virtual void ShowPIP(VideoFrame *, MythPlayer *, PIPLocation)
Definition: mythvideoout.h:149
PIPState
Definition: videoouttypes.h:8
LetterBoxColour
Definition: videoouttypes.h:70
Definition: osd.h:131
virtual void InitPictureAttributes(void)
Definition: mythvideoout.h:88
virtual void CheckFrameStates(void)
Definition: mythvideoout.h:111
This class creates tracks the state of the buffers used by various VideoOutput derived classes.
Definition: videobuffers.h:39
ZoomDirection
Definition: videoouttypes.h:26
bool HasSoftwareFrames(void) const
Definition: mythvideoout.h:91
VideoVisual * GetVisualisation(void)
Definition: mythvideoout.h:134
QMap< QString, bool > Setting