MythTV  master
videooutwindow.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 videooutwindow.cpp of the MythTV project.
6  */
7 
8 #ifndef VIDEOOUTWINDOW_H_
9 #define VIDEOOUTWINDOW_H_
10 
11 // Qt headers
12 #include <QSize>
13 #include <QRect>
14 #include <QPoint>
15 #include <QCoreApplication>
16 
17 // MythTV headers
18 #include "mythcodecid.h"
19 #include "videoouttypes.h"
20 
21 class MythPlayer;
22 
24 {
26 
27  public:
29 
30  bool Init(const QSize &new_video_dim_buf,
31  const QSize &new_video_dim_disp, float aspect,
32  const QRect &new_display_visible_rect,
35 
36  bool InputChanged(const QSize &input_size_buf,
37  const QSize &input_size_disp, float aspect,
38  MythCodecID myth_codec_id, void *codec_private);
39  void VideoAspectRatioChanged(float aspect);
40 
41  void EmbedInWidget(const QRect&);
42  void StopEmbedding(void);
43 
44  void ToggleAdjustFill(
45  AdjustFillMode adjustFillMode = kAdjustFill_Toggle);
46 
48  AspectOverrideMode aspectMode = kAspect_Toggle);
49 
50  void ResizeDisplayWindow(const QRect&, bool);
51 
52  void MoveResize(void);
53  void Zoom(ZoomDirection direction);
54  void ToggleMoveBottomLine(void);
55  void SaveBottomLine(void);
56 
57  // Sets
58  void SetVideoScalingAllowed(bool change);
59  void SetAllowPreviewEPG(bool allowPreviewEPG)
60  { allowpreviewepg = allowPreviewEPG; }
61  void SetDisplayDim(QSize displayDim)
62  { display_dim = displayDim; }
63  void SetDisplayAspect(float displayAspect)
64  { display_aspect = displayAspect; }
65  void SetPIPState(PIPState setting);
66  void SetVideoDim(QSize dim)
67  { video_dim = dim; }
68  void SetDisplayVisibleRect(QRect rect)
69  { display_visible_rect = rect; }
70  void SetNeedRepaint(bool needRepaint)
71  { needrepaint = needRepaint; }
72 
73  void populateGeometry(void);
74  // Gets
75  bool IsVideoScalingAllowed(void) const { return db_scaling_allowed; }
77  bool IsEmbedding(void) const { return embedding; }
78  QSize GetVideoDim(void) const { return video_dim; }
79  QSize GetActualVideoDim(void) const { return video_dim_act; }
80  QSize GetVideoDispDim(void) const { return video_disp_dim; }
81  QSize GetDisplayDim(void) const { return display_dim; }
82  float GetMzScaleV(void) const { return mz_scale_v; }
83  float GetMzScaleH(void) const { return mz_scale_h; }
84  QPoint GetMzMove(void) const { return mz_move; }
85  int GetPIPSize(void) const { return db_pip_size; }
86  PIPState GetPIPState(void) const { return pip_state; }
87  float GetOverridenVideoAspect(void) const { return overriden_video_aspect;}
88  QRect GetDisplayVisibleRect(void) const { return display_visible_rect; }
89  QRect GetScreenGeometry(void) const { return screen_geom; }
90  QRect GetVideoRect(void) const { return video_rect; }
91  QRect GetDisplayVideoRect(void) const { return display_video_rect; }
92  QRect GetEmbeddingRect(void) const { return embedding_rect; }
93  bool UsingXinerama(void) const { return using_xinerama; }
94  bool UsingGuiSize(void) const { return db_use_gui_size; }
95  QString GetZoomString(void) const;
96 
100  { return aspectoverride; }
103  AdjustFillMode GetAdjustFill(void) const { return adjustfill; }
104 
105  float GetVideoAspect(void) const { return video_aspect; }
106  bool IsPreviewEPGAllowed(void) const { return allowpreviewepg; }
107  bool IsRepaintNeeded(void) const { return needrepaint; }
109  float GetDisplayAspect(void) const { return display_aspect; }
110  QRect GetTmpDisplayVisibleRect(void) const
111  { return tmp_display_visible_rect; }
112  QRect GetVisibleOSDBounds(float&, float&, float) const;
113  QRect GetTotalOSDBounds(void) const;
114 
115  QRect GetPIPRect(PIPLocation location,
116  MythPlayer *pipplayer = nullptr,
117  bool do_pixel_adj = true) const;
118 
119  protected:
120  void ApplyDBScaleAndMove(void);
121  void ApplyManualScaleAndMove(void);
122  void ApplyLetterboxing(void);
123  void ApplySnapToVideoRect(void);
124  void PrintMoveResizeDebug(void);
125  void SetVideoAspectRatio(float aspect);
126 
127  private:
128  QPoint db_move;
134 
136  QRect screen_geom;
137 
138  // Manual Zoom
139  float mz_scale_v;
140  float mz_scale_h;
141  QPoint mz_move;
142 
143  // Physical dimensions
144  QSize display_dim;
146 
147  // Video dimensions
148  QSize video_dim;
151  float video_aspect;
152 
160 
162  QRect video_rect;
173 
175  bool embedding;
180 
181  // Constants
182  static const float kManualZoomMaxHorizontalZoom;
183  static const float kManualZoomMaxVerticalZoom;
184  static const float kManualZoomMinHorizontalZoom;
185  static const float kManualZoomMinVerticalZoom;
186  static const int kManualZoomMaxMove;
187 };
188 
189 #endif /* VIDEOOUTWINDOW_H_ */
QSize video_disp_dim
Pixel dimensions of video display area.
void ToggleAspectOverride(AspectOverrideMode aspectMode=kAspect_Toggle)
Enforce different aspect ration than detected, then calls VideoAspectRatioChanged(float) to apply the...
QPoint db_move
Percentage move from database.
void SetDisplayAspect(float displayAspect)
bool UsingXinerama(void) const
bool IsRepaintNeeded(void) const
QRect GetTotalOSDBounds(void) const
Returns total OSD bounds.
MythCodecID
Definition: mythcodecid.h:10
int db_pip_size
percentage of full window to use for PiP
QRect GetPIPRect(PIPLocation location, MythPlayer *pipplayer=nullptr, bool do_pixel_adj=true) const
bool embedding
State variables.
QRect GetVideoRect(void) const
float mz_scale_h
Manually applied horizontal scaling.
QRect embedding_rect
Embedded video rectangle.
float mz_scale_v
Manually applied vertical scaling.
AspectOverrideMode GetAspectOverride(void) const
Returns current aspect override mode.
QPoint mz_move
Manually applied percentage move.
QRect tmp_display_visible_rect
Used to save the display_visible_rect for restoration after video embedding ends.
static const float kManualZoomMinVerticalZoom
void SetPIPState(PIPState setting)
void populateGeometry(void)
void SetVideoScalingAllowed(bool change)
Disable or enable underscan/overscan.
void SetVideoDim(QSize dim)
QSize display_dim
Screen dimensions of playback window in mm.
float GetDisplayAspect(void) const
Returns current display aspect ratio.
QSize video_dim
Pixel dimensions of video buffer.
bool db_scaling_allowed
disable this to prevent overscan/underscan
bool using_xinerama
Display is using multiple screens.
AspectOverrideMode
Definition: videoouttypes.h:46
PIPState pip_state
void ApplySnapToVideoRect(void)
Snap displayed rectagle to video rectange if they are close.
bool UsingGuiSize(void) const
QRect video_rect
Pixel rectangle in video frame to display.
bool IsPreviewEPGAllowed(void) const
void SaveBottomLine(void)
float db_scale_horiz
Horizontal Overscan/Underscan percentage.
QRect GetScreenGeometry(void) const
QRect GetEmbeddingRect(void) const
QRect GetTmpDisplayVisibleRect(void) const
void SetNeedRepaint(bool needRepaint)
bool IsEmbedding(void) const
Returns if videooutput is embedding.
Q_DECLARE_TR_FUNCTIONS(VideoOutWindow)
QRect GetVisibleOSDBounds(float &, float &, float) const
Returns visible portions of total OSD bounds.
QSize GetVideoDispDim(void) const
AdjustFillMode adjustfill
Zoom mode.
static const int kManualZoomMaxMove
QRect GetDisplayVideoRect(void) const
AspectOverrideMode aspectoverride
AspectOverrideMode to use to modify overriden_video_aspect.
float GetMzScaleH(void) const
bool IsVideoScalingAllowed(void) const
void EmbedInWidget(const QRect &)
Tells video output to embed video in an existing window.
QSize video_dim_act
Pixel dimensions of the raw video stream.
PIPState GetPIPState(void) const
void PrintMoveResizeDebug(void)
AdjustFillMode GetAdjustFill(void) const
Returns current adjust fill mode.
QRect display_visible_rect
Visible portion of display window in pixels.
QRect display_video_rect
Pixel rectangle in display window into which video_rect maps to.
PIPLocation
Definition: videoouttypes.h:19
AdjustFillMode
Definition: videoouttypes.h:57
QPoint GetMzMove(void) const
QSize GetActualVideoDim(void) const
float overriden_video_aspect
Normally this is the same as videoAspect, but may not be if the user has toggled the aspect override ...
void ResizeDisplayWindow(const QRect &, bool)
Resize Display Window.
float display_aspect
Physical aspect ratio of playback window.
PIPState
Definition: videoouttypes.h:10
bool InputChanged(const QSize &input_size_buf, const QSize &input_size_disp, float aspect, MythCodecID myth_codec_id, void *codec_private)
Tells video output to discard decoded frames and wait for new ones.
float db_scale_vert
Vertical Overscan/Underscan percentage.
void ToggleMoveBottomLine(void)
static const float kManualZoomMinHorizontalZoom
float GetOverridenVideoAspect(void) const
void VideoAspectRatioChanged(float aspect)
Calls SetVideoAspectRatio(float aspect), then calls MoveResize() to apply changes.
static const float kManualZoomMaxVerticalZoom
void SetDisplayDim(QSize displayDim)
void MoveResize(void)
performs all the calculations for video framing and any resizing.
float GetVideoAspect(void) const
void SetVideoAspectRatio(float aspect)
Sets VideoOutWindow::video_aspect to aspect, and sets VideoOutWindow::overriden_video_aspect if aspec...
bool Init(const QSize &new_video_dim_buf, const QSize &new_video_dim_disp, float aspect, const QRect &new_display_visible_rect, AspectOverrideMode aspectoverride, AdjustFillMode adjustfill)
QRect GetDisplayVisibleRect(void) const
void SetAllowPreviewEPG(bool allowPreviewEPG)
QSize GetVideoDim(void) const
QRect screen_geom
Full screen geometry.
void ApplyLetterboxing(void)
int GetPIPSize(void) const
bool db_use_gui_size
Use the gui size for video window.
static const float kManualZoomMaxHorizontalZoom
QString GetZoomString(void) const
float video_aspect
Physical aspect ratio of video.
void ToggleAdjustFill(AdjustFillMode adjustFillMode=kAdjustFill_Toggle)
Sets up letterboxing for various standard video frame and monitor dimensions, then calls MoveResize()...
ZoomDirection
Definition: videoouttypes.h:28
float GetMzScaleV(void) const
void StopEmbedding(void)
Tells video output to stop embedding video in an existing window.
void SetDisplayVisibleRect(QRect rect)
void ApplyManualScaleAndMove(void)
Apply scales and moves from "Zoom Mode" settings.
void Zoom(ZoomDirection direction)
Sets up zooming into to different parts of the video, the zoom is actually applied in MoveResize().
void ApplyDBScaleAndMove(void)
Apply scales and moves for "Overscan" and "Underscan" DB settings.
QSize GetDisplayDim(void) const