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 *screen);
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 SetDisplayAspect (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  int GetPIPSize(void) const { return m_dbPipSize; }
73  PIPState GetPIPState(void) const { return m_pipState; }
74  float GetOverridenVideoAspect(void) const { return m_videoAspectOverride;}
75  QRect GetDisplayVisibleRect(void) const { return m_displayVisibleRect; }
76  QRect GetWindowRect(void) const { return m_windowRect; }
77  QRect GetScreenGeometry(void) const { return m_screenGeometry; }
78  QRect GetVideoRect(void) const { return m_videoRect; }
79  QRect GetDisplayVideoRect(void) const { return m_displayVideoRect; }
80  QRect GetEmbeddingRect(void) const { return m_embeddingRect; }
81  bool UsingGuiSize(void) const { return m_dbUseGUISize; }
82  bool GetITVResizing(void) const { return m_itvResizing; }
83  QRect GetITVDisplayRect(void) const { return m_itvDisplayVideoRect; }
84  QString GetZoomString(void) const;
86  AdjustFillMode GetAdjustFill(void) const { return m_adjustFill; }
87  float GetVideoAspect(void) const { return m_videoAspect; }
88  float GetDisplayAspect(void) const { return m_displayAspect; }
89  QRect GetTmpDisplayVisibleRect(void) const { return m_tmpDisplayVisibleRect; }
90  QRect GetVisibleOSDBounds(float &VisibleAspect, float &FontScaling, float ThemeAspect) const;
91  QRect GetTotalOSDBounds(void) const;
92  QRect GetPIPRect(PIPLocation Location, MythPlayer *PiPPlayer = nullptr,
93  bool DoPixelAdjustment = true) const;
94  bool VideoIsFullScreen(void) const;
95 #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
96  QRegion GetBoundingRegion(void) const;
97 #endif
99  private:
100  void PopulateGeometry (void);
101  void ApplyDBScaleAndMove (void);
102  void ApplyManualScaleAndMove (void);
103  void ApplyLetterboxing (void);
104  void PrintMoveResizeDebug (void);
105  void SetVideoAspectRatio (float Aspect);
106  static QSize Fix1088 (QSize Dimensions);
107  void Rotate (void);
109  private:
110  MythDisplay* m_display {nullptr};
111  QPoint m_dbMove {0,0};
112  float m_dbHorizScale {0.0F};
113  float m_dbVertScale {0.0F};
114  int m_dbPipSize {26};
115  bool m_dbScalingAllowed {true};
116  bool m_dbUseGUISize {false};
117  QRect m_screenGeometry {0,0,1024,768};
119  // Manual Zoom
120  float m_manualVertScale {1.0F};
121  float m_manualHorizScale {1.0F};
122  QPoint m_manualMove {0,0};
124  // Physical dimensions
125  float m_displayAspect {1.3333F};
127  // Video dimensions
128  QSize m_videoDim {640,480};
129  QSize m_videoDispDim {640,480};
130  float m_videoAspect {1.3333F};
134  float m_videoAspectOverride {1.3333F};
139  int m_rotation {0};
142  QRect m_videoRect {0,0,0,0};
144  QRect m_displayVideoRect {0,0,0,0};
147  QRect m_displayVisibleRect {0,0,0,0};
149  QRect m_windowRect {0,0,0,0};
152  QRect m_tmpDisplayVisibleRect {0,0,0,0};
156  // Interactive TV (MHEG) video embedding
157  bool m_itvResizing {false};
161  bool m_embedding {false};
162  bool m_bottomLine {false};
165  // Constants
166  static const float kManualZoomMaxHorizontalZoom;
167  static const float kManualZoomMaxVerticalZoom;
168  static const float kManualZoomMinHorizontalZoom;
169  static const float kManualZoomMinVerticalZoom;
170  static const int kManualZoomMaxMove;
171 };
173 #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.
void PopulateGeometry(void)
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.
unsigned int slots[4]
Definition: element.cpp:38
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:44
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)
void ScreenChanged(QScreen *screen)
void SetDisplayAspect(float DisplayAspect)
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:17
Definition: videoouttypes.h:55
QRect m_videoRect
Pixel rectangle in video frame to display.
QPoint m_dbMove
Percentage move from database.
AspectOverrideMode m_videoAspectOverrideMode
AspectOverrideMode to use to modify overriden_video_aspect.
~VideoOutWindow() override=default
QSize m_videoDispDim
Pixel dimensions of video display area.
Definition: videoouttypes.h:8
bool m_embedding
State variables.
void ToggleMoveBottomLine(void)
static const float kManualZoomMinHorizontalZoom
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:26
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)
float m_manualHorizScale
Manually applied horizontal scaling.
void SetVideoScalingAllowed(bool Change)
Disable or enable underscan/overscan.
QMap< QString, bool > Setting