MythTV  master
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 /*
3  * Copyright (C) Daniel Kristjansson, Jens Rehaag 2008
4  *
5  * Copyright notice is in videooutwindow.cpp of the MythTV project.
6  */
11 // Qt headers
12 #include <QSize>
13 #include <QRect>
14 #include <QPoint>
15 #include <QRegion>
16 #include <QCoreApplication>
18 // MythTV headers
19 #include "videoouttypes.h"
21 class QScreen;
22 class MythDisplay;
23 class MythPlayer;
25 class VideoOutWindow : public QObject
26 {
29  public:
31  ~VideoOutWindow() override = default;
33  bool Init(const QSize &VideoDim, const QSize &VideoDispDim,
34  float Aspect, const QRect &WindowRect,
36  MythDisplay* Display);
38  signals:
39  // Note These are emitted from MoveResize - which must be called after any call
40  // that changes the current video dimensions or video rectangles.
41  void VideoSizeChanged (const QSize &VideoDim, const QSize &VideoDispDim);
42  void VideoRectsChanged (const QRect &DisplayVideoRect, const QRect &VideoRect);
43  void VisibleRectChanged (const QRect &DisplayVisibleRect);
44  void WindowRectChanged (const QRect &WindowRect);
46  public slots:
47  void ScreenChanged (QScreen*);
49  // Sets
50  void InputChanged (const QSize &VideoDim, const QSize &VideoDispDim, float Aspect);
51  void VideoAspectRatioChanged(float Aspect);
52  void EmbedInWidget (const QRect &Rect);
53  void StopEmbedding (void);
56  void ResizeDisplayWindow (const QRect &Rect, bool SaveVisibleRect);
57  void MoveResize (void);
58  void Zoom (ZoomDirection Direction);
59  void ToggleMoveBottomLine (void);
60  void SaveBottomLine (void);
61  void SetVideoScalingAllowed (bool Change);
62  void SetDisplayProperties (QSize DisplayDim, float DisplayAspect);
64  void SetWindowSize (QSize Size);
65  void SetITVResize (QRect Rect);
66  void SetRotation (int Rotation);
68  // Gets
69  bool IsEmbedding(void) const { return m_embedding; }
70  QSize GetVideoDim(void) const { return m_videoDim; }
71  QSize GetVideoDispDim(void) const { return m_videoDispDim; }
72  QSize GetDisplayDim(void) const { return m_displayDimensions; }
73  int GetPIPSize(void) const { return m_dbPipSize; }
74  PIPState GetPIPState(void) const { return m_pipState; }
75  float GetOverridenVideoAspect(void) const { return m_videoAspectOverride;}
76  QRect GetDisplayVisibleRect(void) const { return m_displayVisibleRect; }
77  QRect GetWindowRect(void) const { return m_windowRect; }
78  QRect GetScreenGeometry(void) const { return m_screenGeometry; }
79  QRect GetVideoRect(void) const { return m_videoRect; }
80  QRect GetDisplayVideoRect(void) const { return m_displayVideoRect; }
81  QRect GetEmbeddingRect(void) const { return m_embeddingRect; }
82  bool UsingXinerama(void) const { return m_usingXinerama; }
83  bool UsingGuiSize(void) const { return m_dbUseGUISize; }
84  bool GetITVResizing(void) const { return m_itvResizing; }
85  QRect GetITVDisplayRect(void) const { return m_itvDisplayVideoRect; }
86  QString GetZoomString(void) const;
88  AdjustFillMode GetAdjustFill(void) const { return m_adjustFill; }
89  float GetVideoAspect(void) const { return m_videoAspect; }
90  float GetDisplayAspect(void) const { return m_displayAspect; }
91  QRect GetTmpDisplayVisibleRect(void) const { return m_tmpDisplayVisibleRect; }
92  QRect GetVisibleOSDBounds(float &VisibleAspect, float &FontScaling, float ThemeAspect) const;
93  QRect GetTotalOSDBounds(void) const;
94  QRect GetPIPRect(PIPLocation Location, MythPlayer *PiPPlayer = nullptr,
95  bool DoPixelAdjustment = true) const;
96  bool VideoIsFullScreen(void) const;
97 #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
98  QRegion GetBoundingRegion(void) const;
99 #endif
101  private:
102  void PopulateGeometry (void);
103  void ApplyDBScaleAndMove (void);
104  void ApplyManualScaleAndMove (void);
105  void ApplyLetterboxing (void);
106  void PrintMoveResizeDebug (void);
107  void SetVideoAspectRatio (float Aspect);
108  static QSize Fix1088 (QSize Dimensions);
109  void Rotate (void);
111  private:
112  MythDisplay* m_display {nullptr};
113  QPoint m_dbMove {0,0};
114  float m_dbHorizScale {0.0F};
115  float m_dbVertScale {0.0F};
116  int m_dbPipSize {26};
117  bool m_dbScalingAllowed {true};
118  bool m_dbUseGUISize {false};
119  bool m_usingXinerama {false};
120  QRect m_screenGeometry {0,0,1024,768};
122  // Manual Zoom
123  float m_manualVertScale {1.0F};
124  float m_manualHorizScale {1.0F};
125  QPoint m_manualMove {0,0};
127  // Physical dimensions
128  QSize m_displayDimensions {400,300};
129  float m_displayAspect {1.3333F};
131  // Video dimensions
132  QSize m_videoDim {640,480};
133  QSize m_videoDispDim {640,480};
134  float m_videoAspect {1.3333F};
138  float m_videoAspectOverride {1.3333F};
143  int m_rotation {0};
146  QRect m_videoRect {0,0,0,0};
148  QRect m_displayVideoRect {0,0,0,0};
151  QRect m_displayVisibleRect {0,0,0,0};
153  QRect m_windowRect {0,0,0,0};
156  QRect m_tmpDisplayVisibleRect {0,0,0,0};
160  // Interactive TV (MHEG) video embedding
161  bool m_itvResizing {false};
165  bool m_embedding {false};
166  bool m_bottomLine {false};
169  // Constants
170  static const float kManualZoomMaxHorizontalZoom;
171  static const float kManualZoomMaxVerticalZoom;
172  static const float kManualZoomMinHorizontalZoom;
173  static const float kManualZoomMinVerticalZoom;
174  static const int kManualZoomMaxMove;
175 };
177 #endif /* VIDEOOUTWINDOW_H_ */
void ToggleAspectOverride(AspectOverrideMode AspectMode=kAspect_Toggle)
Enforce different aspect ration than detected, then calls VideoAspectRatioChanged(float) to apply the...
QRegion GetBoundingRegion(void) const
Return the region of DisplayVisibleRect that lies outside of DisplayVideoRect.
QRect m_displayVideoRect
Pixel rectangle in display window into which video_rect maps to.
unsigned int slots[4]
Definition: element.c:38
void PopulateGeometry(void)
bool UsingXinerama(void) const
QRect GetITVDisplayRect(void) const
QRect GetTotalOSDBounds(void) const
Returns total OSD bounds.
bool Init(const QSize &VideoDim, const QSize &VideoDispDim, float Aspect, const QRect &WindowRect, AspectOverrideMode AspectOverride, AdjustFillMode AdjustFill, MythDisplay *Display)
void VideoRectsChanged(const QRect &DisplayVideoRect, const QRect &VideoRect)
void Zoom(ZoomDirection Direction)
Sets up zooming into to different parts of the video.
bool m_dbScalingAllowed
disable this to prevent overscan/underscan
QRect m_tmpDisplayVisibleRect
Used to save the display_visible_rect for restoration after video embedding ends.
QRect GetVideoRect(void) const
void ResizeDisplayWindow(const QRect &Rect, bool SaveVisibleRect)
Resize Display Window.
void Rotate(void)
Adjust various settings to facilitate portrait mode calculations.
bool m_dbUseGUISize
Use the gui size for video window.
float m_videoAspect
Physical aspect ratio of video.
AspectOverrideMode GetAspectOverride(void) const
PIPState m_pipState
float m_videoAspectOverride
Normally this is the same as videoAspect, but may not be if the user has toggled the aspect override ...
QRect GetPIPRect(PIPLocation Location, MythPlayer *PiPPlayer=nullptr, bool DoPixelAdjustment=true) const
void SetVideoAspectRatio(float Aspect)
Sets VideoOutWindow::video_aspect to aspect, and sets VideoOutWindow::overriden_video_aspect if aspec...
static const float kManualZoomMinVerticalZoom
float GetDisplayAspect(void) const
QRect m_windowRect
Rectangle describing QWidget bounds.
void WindowRectChanged(const QRect &WindowRect)
bool GetITVResizing(void) const
static QSize Fix1088(QSize Dimensions)
QRect m_embeddingRect
Embedded video rectangle.
void EmbedInWidget(const QRect &Rect)
Tells video output to embed video in an existing window.
Definition: videoouttypes.h:46
QRect m_displayVisibleRect
Visible portion of display window in pixels.
bool UsingGuiSize(void) const
QSize m_videoDim
Pixel dimensions of video buffer.
QRect GetVisibleOSDBounds(float &VisibleAspect, float &FontScaling, float ThemeAspect) const
Returns visible portions of total OSD bounds.
float m_dbVertScale
Vertical Overscan/Underscan percentage.
void SaveBottomLine(void)
QRect m_itvDisplayVideoRect
QRect GetScreenGeometry(void) const
float m_manualVertScale
Manually applied vertical scaling.
void VideoAspectRatioChanged(float Aspect)
Calls SetVideoAspectRatio(float aspect), then calls MoveResize() to apply changes.
void SetWindowSize(QSize Size)
QRect GetEmbeddingRect(void) const
QRect GetTmpDisplayVisibleRect(void) const
void VisibleRectChanged(const QRect &DisplayVisibleRect)
float m_dbHorizScale
Horizontal Overscan/Underscan percentage.
MythDisplay * m_display
bool IsEmbedding(void) const
QSize GetVideoDispDim(void) const
static const int kManualZoomMaxMove
static HostComboBoxSetting * AspectOverride()
QRect GetDisplayVideoRect(void) const
void SetPIPState(PIPState Setting)
bool VideoIsFullScreen(void) const
Check whether the video display rect covers the entire window/framebuffer.
PIPState GetPIPState(void) const
void PrintMoveResizeDebug(void)
AdjustFillMode GetAdjustFill(void) const
Definition: videoouttypes.h:19
Definition: videoouttypes.h:57
QRect m_videoRect
Pixel rectangle in video frame to display.
QSize m_displayDimensions
Screen dimensions of playback window in mm.
QPoint m_dbMove
Percentage move from database.
AspectOverrideMode m_videoAspectOverrideMode
AspectOverrideMode to use to modify overriden_video_aspect.
bool m_usingXinerama
Display is using multiple screens.
~VideoOutWindow() override=default
QSize m_videoDispDim
Pixel dimensions of video display area.
Definition: videoouttypes.h:10
bool m_embedding
State variables.
void SetDisplayProperties(QSize DisplayDim, float DisplayAspect)
void ToggleMoveBottomLine(void)
static const float kManualZoomMinHorizontalZoom
void ScreenChanged(QScreen *)
float GetOverridenVideoAspect(void) const
static const float kManualZoomMaxVerticalZoom
void MoveResize(void)
performs all the calculations for video framing and any resizing.
void VideoSizeChanged(const QSize &VideoDim, const QSize &VideoDispDim)
void ToggleAdjustFill(AdjustFillMode AdjustFillMode=kAdjustFill_Toggle)
Sets up letterboxing for various standard video frame and monitor dimensions, then calls MoveResize()...
float GetVideoAspect(void) const
QRect GetDisplayVisibleRect(void) const
QRect GetWindowRect(void) const
QSize GetVideoDim(void) const
void ApplyLetterboxing(void)
int GetPIPSize(void) const
static const float kManualZoomMaxHorizontalZoom
QString GetZoomString(void) const
int m_dbPipSize
percentage of full window to use for PiP
void InputChanged(const QSize &VideoDim, const QSize &VideoDispDim, float Aspect)
Tells video output to discard decoded frames and wait for new ones.
QRect m_screenGeometry
Full screen geometry.
AdjustFillMode m_adjustFill
Zoom mode.
float m_displayAspect
Physical aspect ratio of playback window.
Definition: videoouttypes.h:28
void SetRotation(int Rotation)
Set the rotation in degrees.
void StopEmbedding(void)
Tells video output to stop embedding video in an existing window.
void ApplyManualScaleAndMove(void)
Apply scales and moves from "Zoom Mode" settings.
static HostComboBoxSetting * AdjustFill()
void ApplyDBScaleAndMove(void)
Apply scales and moves for "Overscan" and "Underscan" DB settings.
QPoint m_manualMove
Manually applied percentage move.
void SetITVResize(QRect Rect)
QSize GetDisplayDim(void) const
float m_manualHorizScale
Manually applied horizontal scaling.
void SetVideoScalingAllowed(bool Change)
Disable or enable underscan/overscan.
QMap< QString, bool > Setting