MythTV  master
mythvideobounds.h
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 mythvideobounds.cpp of the MythTV project.
6  */
7 
8 #ifndef MYTHVIDEOBOUNDS_H_
9 #define MYTHVIDEOBOUNDS_H_
10 
11 // Qt
12 #include <QRegion>
13 #include <QCoreApplication>
14 
15 // MythTV
16 #include "mythplayerstate.h"
17 #include "videoouttypes.h"
18 
19 class QScreen;
20 class MythDisplay;
21 class MythPlayer;
22 
23 class MythVideoBounds : public QObject
24 {
25  Q_OBJECT
26 
27  public:
29  ~MythVideoBounds() override = default;
30 
31  bool InitBounds(QSize VideoDim, QSize VideoDispDim,
32  float Aspect, QRect WindowRect);
33  void SetDisplay(MythDisplay* mDisplay);
34 
35  signals:
36  void UpdateOSDMessage (const QString& Message);
37  // Note These are emitted from MoveResize - which must be called after any call
38  // that changes the current video dimensions or video rectangles.
39  void VideoSizeChanged (const QSize &VideoDim, const QSize &VideoDispDim);
40  void VideoRectsChanged (const QRect &DisplayVideoRect, const QRect &VideoRect);
41  void VisibleRectChanged (const QRect &DisplayVisibleRect);
42  void WindowRectChanged (const QRect &WindowRect);
44 
45  public slots:
47  void ScreenChanged (QScreen *screen);
48  void PhysicalDPIChanged (qreal /*DPI*/);
49  void SourceChanged (QSize VideoDim, QSize VideoDispDim, float Aspect);
50  void VideoAspectRatioChanged(float Aspect);
51  virtual void EmbedPlayback (bool Embed, QRect Rect);
54  void ResizeDisplayWindow (QRect Rect, bool SaveVisibleRect);
55  void MoveResize (void);
56  void Zoom (ZoomDirection Direction);
57  void ToggleMoveBottomLine (void);
58  void SaveBottomLine (void);
59  void SetVideoScalingAllowed (bool Change);
60  void SetDisplayAspect (float DisplayAspect);
61  void SetWindowSize (QSize Size);
62  void SetITVResize (QRect Rect);
63  void SetRotation (int Rotation);
65 
66  public:
67  // Gets
68  bool IsEmbedding(void) const { return m_embedding; }
69  bool IsEmbeddingAndHidden() const { return m_embeddingHidden; }
70  QSize GetVideoDim(void) const { return m_videoDim; }
71  QSize GetVideoDispDim(void) const { return m_videoDispDim; }
72  float GetOverridenVideoAspect(void) const { return m_videoAspectOverride;}
73  QRect GetDisplayVisibleRect(void) const { return m_displayVisibleRect; }
74  QRect GetWindowRect(void) const { return m_windowRect; }
75  QRect GetRawWindowRect(void) const { return m_rawWindowRect; }
76  QRect GetVideoRect(void) const { return m_videoRect; }
77  QRect GetDisplayVideoRect(void) const { return m_displayVideoRect; }
78  QRect GetEmbeddingRect(void) const { return m_rawEmbeddingRect; }
79  bool UsingGuiSize(void) const { return m_dbUseGUISize; }
80  AdjustFillMode GetAdjustFill(void) const { return m_adjustFill; }
81  float GetVideoAspect(void) const { return m_videoAspect; }
82  float GetDisplayAspect(void) const { return m_displayAspect; }
84  bool VideoIsFullScreen(void) const;
85  QRegion GetBoundingRegion(void) const;
86 
87 
88  private:
89  void PopulateGeometry (void);
90  void ApplyDBScaleAndMove (void);
91  void ApplyManualScaleAndMove (void);
92  void ApplyLetterboxing (void);
93  void PrintMoveResizeDebug (void);
94  void SetVideoAspectRatio (float Aspect);
95  static QSize Fix1088 (QSize Dimensions);
96  void Rotate (void);
97 
98  protected:
99  MythDisplay* m_display {nullptr};
100 
101  private:
102  QPoint m_dbMove {0,0};
103  float m_dbHorizScale {0.0F};
104  float m_dbVertScale {0.0F};
105  bool m_dbScalingAllowed {true};
106  bool m_dbUseGUISize {false};
109  qreal m_devicePixelRatio {1.0};
110 
111  // Manual Zoom
112  float m_manualVertScale {1.0F};
113  float m_manualHorizScale {1.0F};
114  QPoint m_manualMove {0,0};
115 
116  // Physical dimensions
117  float m_displayAspect {1.3333F};
118 
119  // Video dimensions
120  QSize m_videoDim {640,480};
121  QSize m_videoDispDim {640,480};
122  float m_videoAspect {1.3333F};
123 
126  float m_videoAspectOverride {1.3333F};
131  int m_rotation {0};
133 
135  QRect m_videoRect {0,0,0,0};
137  QRect m_displayVideoRect {0,0,0,0};
140  QRect m_displayVisibleRect {0,0,0,0};
142  QRect m_windowRect {0,0,0,0};
144  QRect m_rawWindowRect {0,0,0,0};
147  QRect m_tmpDisplayVisibleRect {0,0,0,0};
151 
152  // Interactive TV (MHEG) video embedding
153  bool m_itvResizing {false};
156 
158  bool m_embedding {false};
159  bool m_embeddingHidden { false };
160  bool m_bottomLine {false};
161 
162  // Constants
163  static const float kManualZoomMaxHorizontalZoom;
164  static const float kManualZoomMaxVerticalZoom;
165  static const float kManualZoomMinHorizontalZoom;
166  static const float kManualZoomMinVerticalZoom;
167  static const int kManualZoomMaxMove;
168 };
169 
170 #endif
kAspect_Toggle
@ kAspect_Toggle
Definition: videoouttypes.h:62
MythVideoBounds::~MythVideoBounds
~MythVideoBounds() override=default
MythVideoBounds::IsEmbeddingAndHidden
bool IsEmbeddingAndHidden() const
Definition: mythvideobounds.h:69
kAdjustFill_Toggle
@ kAdjustFill_Toggle
Definition: videoouttypes.h:73
MythVideoBounds::kManualZoomMaxVerticalZoom
static const float kManualZoomMaxVerticalZoom
Definition: mythvideobounds.h:164
mythplayerstate.h
MythVideoBounds::IsEmbedding
bool IsEmbedding(void) const
Definition: mythvideobounds.h:68
MythVideoBounds::VideoAspectRatioChanged
void VideoAspectRatioChanged(float Aspect)
Calls SetVideoAspectRatio(float aspect), then calls MoveResize() to apply changes.
Definition: mythvideobounds.cpp:512
MythVideoBounds::PhysicalDPIChanged
void PhysicalDPIChanged(qreal)
Definition: mythvideobounds.cpp:94
MythVideoBounds::m_rawWindowRect
QRect m_rawWindowRect
Rectangle describing QWidget bounds - not adjusted for high DPI scaling (macos)
Definition: mythvideobounds.h:144
MythVideoBounds::m_displayVideoRect
QRect m_displayVideoRect
Pixel rectangle in display window into which video_rect maps to.
Definition: mythvideobounds.h:137
MythVideoBounds::m_tmpDisplayVisibleRect
QRect m_tmpDisplayVisibleRect
Used to save the display_visible_rect for restoration after video embedding ends.
Definition: mythvideobounds.h:147
MythVideoBounds::m_dbVertScale
float m_dbVertScale
Vertical Overscan/Underscan percentage.
Definition: mythvideobounds.h:104
MythVideoBounds::EmbedPlayback
virtual void EmbedPlayback(bool Embed, QRect Rect)
Definition: mythvideobounds.cpp:683
MythVideoBounds::MythVideoBounds
MythVideoBounds()
Definition: mythvideobounds.cpp:53
MythVideoBounds::GetDisplayVisibleRect
QRect GetDisplayVisibleRect(void) const
Definition: mythvideobounds.h:73
kAdjustFill_Off
@ kAdjustFill_Off
Definition: videoouttypes.h:74
MythVideoBounds::ApplyDBScaleAndMove
void ApplyDBScaleAndMove(void)
Apply scales and moves for "Overscan" and "Underscan" DB settings.
Definition: mythvideobounds.cpp:218
MythVideoBounds::GetDisplayAspect
float GetDisplayAspect(void) const
Definition: mythvideobounds.h:82
MythVideoBounds::RefreshVideoBoundsState
void RefreshVideoBoundsState()
Send out latest state to listeners.
Definition: mythvideobounds.cpp:67
MythVideoBounds::m_videoAspect
float m_videoAspect
Physical aspect ratio of video.
Definition: mythvideobounds.h:122
MythVideoBounds::m_rawItvDisplayVideoRect
QRect m_rawItvDisplayVideoRect
Definition: mythvideobounds.h:155
MythVideoBounds::m_devicePixelRatio
qreal m_devicePixelRatio
Definition: mythvideobounds.h:109
MythVideoBounds::m_itvResizing
bool m_itvResizing
Definition: mythvideobounds.h:153
kAspect_Off
@ kAspect_Off
Definition: videoouttypes.h:63
MythVideoBounds::VideoRectsChanged
void VideoRectsChanged(const QRect &DisplayVideoRect, const QRect &VideoRect)
MythVideoBounds::UsingGuiSize
bool UsingGuiSize(void) const
Definition: mythvideobounds.h:79
MythPlayer
Definition: mythplayer.h:86
MythVideoBounds::m_dbScalingAllowed
bool m_dbScalingAllowed
disable this to prevent overscan/underscan
Definition: mythvideobounds.h:105
MythVideoBounds::GetVideoRect
QRect GetVideoRect(void) const
Definition: mythvideobounds.h:76
MythVideoBounds::PrintMoveResizeDebug
void PrintMoveResizeDebug(void)
Definition: mythvideobounds.cpp:479
MythVideoBounds::GetDisplayVideoRect
QRect GetDisplayVideoRect(void) const
Definition: mythvideobounds.h:77
MythVideoBounds::UpdateOSDMessage
void UpdateOSDMessage(const QString &Message)
MythVideoBounds::SaveBottomLine
void SaveBottomLine(void)
Definition: mythvideobounds.cpp:896
MythVideoBounds::m_embedding
bool m_embedding
State variables.
Definition: mythvideobounds.h:158
MythVideoBounds::m_dbAspectOverride
AspectOverrideMode m_dbAspectOverride
Definition: mythvideobounds.h:107
MythVideoBounds::GetAdjustFill
AdjustFillMode GetAdjustFill(void) const
Definition: mythvideobounds.h:80
MythVideoBounds::kManualZoomMaxMove
static const int kManualZoomMaxMove
Definition: mythvideobounds.h:167
MythVideoBounds::SetDisplayAspect
void SetDisplayAspect(float DisplayAspect)
Definition: mythvideobounds.cpp:607
MythVideoBounds::m_adjustFill
AdjustFillMode m_adjustFill
Zoom mode.
Definition: mythvideobounds.h:130
videoouttypes.h
MythVideoBounds::SetDisplay
void SetDisplay(MythDisplay *mDisplay)
Definition: mythvideobounds.cpp:73
MythVideoBounds::ResizeDisplayWindow
void ResizeDisplayWindow(QRect Rect, bool SaveVisibleRect)
Resize Display Window.
Definition: mythvideobounds.cpp:675
MythVideoBounds::VisibleRectChanged
void VisibleRectChanged(const QRect &DisplayVisibleRect)
MythVideoBounds::m_dbHorizScale
float m_dbHorizScale
Horizontal Overscan/Underscan percentage.
Definition: mythvideobounds.h:103
MythVideoBounds::kManualZoomMaxHorizontalZoom
static const float kManualZoomMaxHorizontalZoom
Definition: mythvideobounds.h:163
MythVideoBounds::SourceChanged
void SourceChanged(QSize VideoDim, QSize VideoDispDim, float Aspect)
Update for new source video dimensions and aspect ratio.
Definition: mythvideobounds.cpp:524
MythVideoBounds::SetStereoOverride
void SetStereoOverride(StereoscopicMode Mode)
Definition: mythvideobounds.cpp:927
MythVideoBounds::Fix1088
static QSize Fix1088(QSize Dimensions)
Definition: mythvideobounds.cpp:546
AspectOverrideMode
AspectOverrideMode
Definition: videoouttypes.h:60
MythVideoBounds::ToggleAspectOverride
void ToggleAspectOverride(AspectOverrideMode AspectMode=kAspect_Toggle)
Enforce different aspect ratio than detected, then calls VideoAspectRatioChanged(float) to apply them...
Definition: mythvideobounds.cpp:721
MythVideoBounds::PopulateGeometry
void PopulateGeometry(void)
Definition: mythvideobounds.cpp:102
MythVideoBounds::m_windowRect
QRect m_windowRect
Rectangle describing QWidget bounds.
Definition: mythvideobounds.h:142
MythVideoBounds::m_videoAspectOverrideMode
AspectOverrideMode m_videoAspectOverrideMode
AspectOverrideMode to use to modify overriden_video_aspect.
Definition: mythvideobounds.h:128
MythVideoBounds::m_dbAdjustFill
AdjustFillMode m_dbAdjustFill
Definition: mythvideobounds.h:108
MythVideoBounds::m_videoAspectOverride
float m_videoAspectOverride
Normally this is the same as videoAspect, but may not be if the user has toggled the aspect override ...
Definition: mythvideobounds.h:126
MythVideoBounds::m_bottomLine
bool m_bottomLine
Definition: mythvideobounds.h:160
MythVideoBounds::m_manualHorizScale
float m_manualHorizScale
Manually applied horizontal scaling.
Definition: mythvideobounds.h:113
MythVideoBounds::m_displayVisibleRect
QRect m_displayVisibleRect
Visible portion of display window in pixels.
Definition: mythvideobounds.h:140
MythVideoBounds::GetEmbeddingRect
QRect GetEmbeddingRect(void) const
Definition: mythvideobounds.h:78
MythVideoBounds::ApplyLetterboxing
void ApplyLetterboxing(void)
Definition: mythvideobounds.cpp:349
MythVideoBounds::ToggleAdjustFill
void ToggleAdjustFill(AdjustFillMode AdjustFillMode=kAdjustFill_Toggle)
Sets up letterboxing for various standard video frame and monitor dimensions, then calls MoveResize()...
Definition: mythvideobounds.cpp:565
MythVideoBounds::SetRotation
void SetRotation(int Rotation)
Set the rotation in degrees.
Definition: mythvideobounds.cpp:660
MythVideoBounds::GetOverridenVideoAspect
float GetOverridenVideoAspect(void) const
Definition: mythvideobounds.h:72
MythVideoBounds::GetVideoDispDim
QSize GetVideoDispDim(void) const
Definition: mythvideobounds.h:71
MythVideoBounds::VideoSizeChanged
void VideoSizeChanged(const QSize &VideoDim, const QSize &VideoDispDim)
kStereoscopicModeAuto
@ kStereoscopicModeAuto
Definition: videoouttypes.h:136
MythDisplay
Definition: mythdisplay.h:22
MythVideoBounds::kManualZoomMinVerticalZoom
static const float kManualZoomMinVerticalZoom
Definition: mythvideobounds.h:166
MythVideoBounds
Definition: mythvideobounds.h:23
MythVideoBounds::ToggleMoveBottomLine
void ToggleMoveBottomLine(void)
Definition: mythvideobounds.cpp:857
StereoscopicMode
StereoscopicMode
Definition: videoouttypes.h:134
MythVideoBounds::SetITVResize
void SetITVResize(QRect Rect)
Definition: mythvideobounds.cpp:631
MythVideoBounds::MoveResize
void MoveResize(void)
performs all the calculations for video framing and any resizing.
Definition: mythvideobounds.cpp:136
MythVideoBounds::GetBoundingRegion
QRegion GetBoundingRegion(void) const
Return the region of DisplayVisibleRect that lies outside of DisplayVideoRect.
Definition: mythvideobounds.cpp:754
MythVideoBounds::Zoom
void Zoom(ZoomDirection Direction)
Sets up zooming into to different parts of the video.
Definition: mythvideobounds.cpp:765
MythVideoBounds::m_rotation
int m_rotation
Definition: mythvideobounds.h:131
MythVideoBounds::m_itvDisplayVideoRect
QRect m_itvDisplayVideoRect
Definition: mythvideobounds.h:154
AdjustFillMode
AdjustFillMode
Definition: videoouttypes.h:71
MythVideoBounds::SetVideoAspectRatio
void SetVideoAspectRatio(float Aspect)
Sets MythVideoBounds::video_aspect to aspect, and sets MythVideoBounds::overriden_video_aspect if asp...
Definition: mythvideobounds.cpp:501
MythVideoBounds::ScreenChanged
void ScreenChanged(QScreen *screen)
Definition: mythvideobounds.cpp:88
MythVideoBounds::kManualZoomMinHorizontalZoom
static const float kManualZoomMinHorizontalZoom
Definition: mythvideobounds.h:165
MythVideoBounds::InitBounds
bool InitBounds(QSize VideoDim, QSize VideoDispDim, float Aspect, QRect WindowRect)
Definition: mythvideobounds.cpp:451
MythVideoBounds::SetVideoScalingAllowed
void SetVideoScalingAllowed(bool Change)
Disable or enable underscan/overscan.
Definition: mythvideobounds.cpp:580
MythVideoBounds::m_manualMove
QPoint m_manualMove
Manually applied percentage move.
Definition: mythvideobounds.h:114
MythVideoBounds::m_videoDim
QSize m_videoDim
Pixel dimensions of video buffer.
Definition: mythvideobounds.h:120
MythVideoBounds::Rotate
void Rotate(void)
Adjust various settings to facilitate portrait mode calculations.
Definition: mythvideobounds.cpp:183
MythVideoBounds::ApplyManualScaleAndMove
void ApplyManualScaleAndMove(void)
Apply scales and moves from "Zoom Mode" settings.
Definition: mythvideobounds.cpp:321
MythVideoBounds::WindowRectChanged
void WindowRectChanged(const QRect &WindowRect)
MythVideoBounds::m_embeddingRect
QRect m_embeddingRect
Embedded video rectangle.
Definition: mythvideobounds.h:149
MythVideoBounds::GetWindowRect
QRect GetWindowRect(void) const
Definition: mythvideobounds.h:74
MythVideoBounds::GetRawWindowRect
QRect GetRawWindowRect(void) const
Definition: mythvideobounds.h:75
MythVideoBounds::m_dbUseGUISize
bool m_dbUseGUISize
Use the gui size for video window.
Definition: mythvideobounds.h:106
MythVideoBounds::m_videoRect
QRect m_videoRect
Pixel rectangle in video frame to display.
Definition: mythvideobounds.h:135
MythVideoBounds::VideoIsFullScreen
bool VideoIsFullScreen(void) const
Check whether the video display rect covers the entire window/framebuffer.
Definition: mythvideobounds.cpp:742
MythVideoBounds::VideoBoundsStateChanged
void VideoBoundsStateChanged(MythVideoBoundsState VideoState)
MythVideoBounds::GetVideoDim
QSize GetVideoDim(void) const
Definition: mythvideobounds.h:70
MythVideoBounds::m_stereoOverride
StereoscopicMode m_stereoOverride
Definition: mythvideobounds.h:132
MythVideoBounds::m_dbMove
QPoint m_dbMove
Percentage move from database.
Definition: mythvideobounds.h:102
MythVideoBounds::m_manualVertScale
float m_manualVertScale
Manually applied vertical scaling.
Definition: mythvideobounds.h:112
MythVideoBounds::m_embeddingHidden
bool m_embeddingHidden
Definition: mythvideobounds.h:159
MythVideoBounds::m_videoDispDim
QSize m_videoDispDim
Pixel dimensions of video display area.
Definition: mythvideobounds.h:121
MythVideoBounds::GetVideoAspect
float GetVideoAspect(void) const
Definition: mythvideobounds.h:81
MythVideoBounds::m_displayAspect
float m_displayAspect
Physical aspect ratio of playback window.
Definition: mythvideobounds.h:117
ZoomDirection
ZoomDirection
Definition: videoouttypes.h:42
MythVideoBoundsState
Definition: mythplayerstate.h:96
MythVideoBounds::m_rawEmbeddingRect
QRect m_rawEmbeddingRect
Definition: mythvideobounds.h:150
MythVideoBounds::SetWindowSize
void SetWindowSize(QSize Size)
Definition: mythvideobounds.cpp:618
MythVideoBounds::GetStereoOverride
StereoscopicMode GetStereoOverride() const
Definition: mythvideobounds.h:83
MythVideoBounds::m_display
MythDisplay * m_display
Definition: mythvideobounds.h:99