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_
kAspect_Toggle
@ kAspect_Toggle
Definition: videoouttypes.h:46
kAdjustFill_Toggle
@ kAdjustFill_Toggle
Definition: videoouttypes.h:57
PictureAttributeSupported
PictureAttributeSupported
Definition: videoouttypes.h:101
MythVideoOutput
Definition: mythvideoout.h:37
MythVideoOutput::GetProfile
VideoDisplayProfile * GetProfile()
Definition: mythvideoout.h:60
MythVideoOutput::GetVisualisation
VideoVisual * GetVisualisation(void)
Definition: mythvideoout.h:134
AudioPlayer
Definition: audioplayer.h:27
kCodec_NONE
@ kCodec_NONE
Definition: mythcodecid.h:14
MythVideoOutput::ProcessFrame
virtual void ProcessFrame(VideoFrame *Frame, OSD *Osd, const PIPMap &PipPlayers, FrameScanType Scan=kScan_Ignore)=0
kError_None
@ kError_None
Definition: videoouttypes.h:170
VideoBuffers
Definition: videobuffers.h:40
kAdjustFill_Off
@ kAdjustFill_Off
Definition: videoouttypes.h:58
Frame
Definition: zmdefines.h:94
kLetterBoxColour_Black
@ kLetterBoxColour_Black
Definition: videoouttypes.h:73
VideoErrorState
VideoErrorState
Definition: videoouttypes.h:169
DEINT_NONE
@ DEINT_NONE
Definition: mythframe.h:123
FrameScanType
FrameScanType
Definition: videoouttypes.h:79
kAspect_Off
@ kAspect_Off
Definition: videoouttypes.h:47
videooutwindow.h
mythframe.h
MythVideoOutput::m_videoColourSpace
VideoColourSpace m_videoColourSpace
Definition: mythvideoout.h:160
PlayerFlags
PlayerFlags
Definition: mythplayer.h:88
MythPlayer
Definition: mythplayer.h:165
VideoFrame
Definition: mythframe.h:138
MythVideoOutput::IsPIPSupported
virtual bool IsPIPSupported(void) const
Definition: mythvideoout.h:89
MythVideoOutput::UpdatePauseFrame
virtual void UpdatePauseFrame(int64_t &DisplayTimecode, FrameScanType Scan=kScan_Progressive)=0
Visible
Definition: channelsettings.cpp:392
mythdeinterlacer.h
MythMultiLocker
Definition: mythplayer.h:122
MythVideoOutput::GetOSDPainter
virtual MythPainter * GetOSDPainter(void)
Definition: mythvideoout.h:124
videobuffers.h
MythVideoOutput::m_copyFrame
MythAVCopy m_copyFrame
Definition: mythvideoout.h:172
MythCodecID
MythCodecID
Definition: mythcodecid.h:11
MythVideoOutput::PrepareFrame
virtual void PrepareFrame(VideoFrame *Frame, FrameScanType, OSD *Osd)=0
videodisplayprofile.h
MythVideoOutput::CheckFrameStates
virtual void CheckFrameStates(void)
Definition: mythvideoout.h:111
Decoder
Definition: decoder.h:66
MythVideoOutput::m_window
VideoOutWindow m_window
Definition: mythvideoout.h:159
mythdisplay.h
RenderOptions
Definition: videodisplayprofile.h:28
videoouttypes.h
kScan_Progressive
@ kScan_Progressive
Definition: videoouttypes.h:84
AspectOverrideMode
AspectOverrideMode
Definition: videoouttypes.h:45
MythVideoOutput::Show
virtual void Show(FrameScanType)=0
MythDeinterlacer
Handles software based deinterlacing of video frames.
Definition: mythdeinterlacer.h:15
FrameRate
Definition: recorderbase.h:37
mythcodecid.h
kStereoscopicModeNone
@ kStereoscopicModeNone
Definition: videoouttypes.h:120
uint
unsigned int uint
Definition: compat.h:140
PIPMap
QMap< MythPlayer *, PIPLocation > PIPMap
Definition: mythvideoout.h:32
MythDisplay
Definition: mythdisplay.h:19
MythVideoOutput::RemovePIP
virtual void RemovePIP(MythPlayer *)
Definition: mythvideoout.h:122
videocolourspace.h
MythVideoOutput::m_deinterlacer
MythDeinterlacer m_deinterlacer
Definition: mythvideoout.h:173
codec_sw_copy
#define codec_sw_copy(id)
Definition: mythcodecid.h:349
PictureAttribute
PictureAttribute
Definition: videoouttypes.h:88
StereoscopicMode
StereoscopicMode
Definition: videoouttypes.h:119
VideoDisplayProfile
Definition: videodisplayprofile.h:70
Setting
QMap< QString, bool > Setting
Definition: mythsystemlegacy.h:59
MythVideoOutput::SetStereoscopicMode
void SetStereoscopicMode(StereoscopicMode mode)
Definition: mythvideoout.h:142
VideoColourSpace
VideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.
Definition: videocolourspace.h:18
MythDeintType
MythDeintType
Definition: mythframe.h:122
MythVideoOutput::InitPictureAttributes
virtual void InitPictureAttributes(void)
Definition: mythvideoout.h:88
VideoOutWindow
Definition: videooutwindow.h:26
PIPLocation
PIPLocation
Definition: videoouttypes.h:18
MythRender
Definition: mythrender_base.h:23
MythPainter
Definition: mythpainter.h:33
MythVideoOutput::StereoscopicModesAllowed
virtual bool StereoscopicModesAllowed(void) const
Definition: mythvideoout.h:141
Name
Definition: channelsettings.cpp:47
AdjustFillMode
AdjustFillMode
Definition: videoouttypes.h:56
LetterBoxColour
LetterBoxColour
Definition: videoouttypes.h:71
MythVideoOutput::HasSoftwareFrames
bool HasSoftwareFrames(void) const
Definition: mythvideoout.h:91
mythavutil.h
PIPState
PIPState
Definition: videoouttypes.h:9
MythAVCopy
MythAVCopy Copy AVFrame<->frame, performing the required conversion if any.
Definition: mythavutil.h:108
MythVideoOutput::IsPBPSupported
virtual bool IsPBPSupported(void) const
Definition: mythvideoout.h:90
videovisual.h
VideoVisual
Definition: videovisual.h:41
MythVideoOutput::WindowResized
virtual void WindowResized(const QSize &)
Definition: mythvideoout.h:61
VideoFrameType
VideoFrameType
Definition: mythframe.h:25
MythVideoOutput::ShowPIP
virtual void ShowPIP(VideoFrame *, MythPlayer *, PIPLocation)
Definition: mythvideoout.h:149
MythVideoOutput::GetStereoscopicMode
StereoscopicMode GetStereoscopicMode(void) const
Definition: mythvideoout.h:143
OSD
Definition: osd.h:132
MythVideoOutput::m_videoBuffers
VideoBuffers m_videoBuffers
Definition: mythvideoout.h:167
kScan_Ignore
@ kScan_Ignore
Definition: videoouttypes.h:80
ZoomDirection
ZoomDirection
Definition: videoouttypes.h:27