MythTV  master
Go to the documentation of this file.
1 #ifndef VIDEOOUT_XV_H_
2 #define VIDEOOUT_XV_H_
4 #include <qwindowdefs.h>
6 #include "videooutbase.h"
8 #include "mythxdisplay.h"
9 #include <X11/Xatom.h>
10 #include <X11/Xutil.h>
11 #include <X11/extensions/XShm.h>
12 #include <X11/extensions/Xvlib.h>
13 #include <X11/extensions/Xv.h>
15 #undef HAVE_AV_CONFIG_H
16 extern "C" {
17 #include "libavcodec/avcodec.h"
18 }
20 class MythPlayer;
21 class ChromaKeyOSD;
23 typedef enum VideoOutputSubType
24 {
26 } VOSType;
28 class VideoOutputXv : public VideoOutput
29 {
30  friend class ChromaKeyOSD;
31  public:
32  static void GetRenderOptions(render_opts &opts, QStringList &cpudeints);
33  VideoOutputXv();
36  bool Init(const QSize &video_dim_buf,
37  const QSize &video_dim_disp,
38  float aspect,
39  WId winid, const QRect &win_rect, MythCodecID codec_id) override; // VideoOutput
41  bool SetDeinterlacingEnabled(bool) override; // VideoOutput
42  bool SetupDeinterlace(bool interlaced, const QString& overridefilter="") override; // VideoOutput
43  bool ApproveDeintFilter(const QString& filtername) const override; // VideoOutput
45  void ProcessFrame(VideoFrame *frame, OSD *osd,
46  FilterChain *filterList,
47  const PIPMap &pipPlayers,
48  FrameScanType scan) override; // VideoOutput
50  void PrepareFrame(VideoFrame*, FrameScanType, OSD *osd) override; // VideoOutput
51  void Show(FrameScanType) override; // VideoOutput
53  void ClearAfterSeek(void) override; // VideoOutput
55  void WindowResized(const QSize &new_size) override; // VideoOutput
57  void MoveResize(void) override; // VideoOutput
58  bool InputChanged(const QSize &video_dim_buf,
59  const QSize &video_dim_disp,
60  float aspect,
61  MythCodecID av_codec_id,
62  void *codec_private,
63  bool &aspect_only) override; // VideoOutput
64  void Zoom(ZoomDirection direction) override; // VideoOutput
65  void VideoAspectRatioChanged(float aspect) override; // VideoOutput
66  void EmbedInWidget(const QRect &rect) override; // VideoOutput
67  void StopEmbedding(void) override; // VideoOutput
68  void MoveResizeWindow(QRect new_rect) override; // VideoOutput
69  void DrawUnusedRects(bool sync = true) override; // VideoOutput
70  void UpdatePauseFrame(int64_t &default_tc) override; // VideoOutput
71  int SetPictureAttribute(PictureAttribute attribute, int newValue) override; // VideoOutput
72  void InitPictureAttributes(void) override; // VideoOutput
74  bool IsPIPSupported(void) const override // VideoOutput
75  { return XVideo == VideoOutputSubType(); }
76  bool IsPBPSupported(void) const override // VideoOutput
77  { return XVideo == VideoOutputSubType(); }
78  bool NeedExtraAudioDecode(void) const override // VideoOutput
79  { return false; }
81  QRect GetPIPRect(PIPLocation location,
82  MythPlayer *pipplayer = nullptr,
83  bool do_pixel_adj = true) const override; // VideoOutput
85  static MythCodecID GetBestSupportedCodec(uint stream_type);
87  int GrabSuitableXvPort(MythXDisplay* disp, Window root,
89  uint width, uint height,
90  bool &xvsetdefaults,
91  QString *adaptor_name = nullptr);
92  static void UngrabXvPort(MythXDisplay* disp, int port);
94  static QStringList GetAllowedRenderers(MythCodecID myth_codec_id,
95  const QSize &video_dim);
98  MythPainter* GetOSDPainter(void) override; // VideoOutput
100  private:
101  bool hasFullScreenOSD(void) const override // VideoOutput
102  { return chroma_osd; }
103  void DiscardFrame(VideoFrame*) override; // VideoOutput
104  void DiscardFrames(bool next_frame_keyframe) override; // VideoOutput
106  void PrepareFrameXv(VideoFrame *);
111  int SetXVPictureAttribute(PictureAttribute attribute, int newValue);
112  void InitColorKey(bool turnoffautopaint);
114  bool InitVideoBuffers(bool use_xv, bool use_shm);
116  bool InitXVideo(void);
117  bool InitXShm(void);
118  bool InitXlib(void);
119  bool CreateOSD(void);
121  bool CreateBuffers(VOSType subtype);
122  vector<unsigned char*> CreateShmImages(uint num, bool use_xv);
123  void CreatePauseFrame(VOSType subtype);
125  void DeleteBuffers(VOSType subtype, bool delete_pause_frame);
127  bool InitSetupBuffers(void);
129  // Misc.
131  QMutex global_lock;
133  // Basic X11 info
134  Window XJ_win;
135  Window XJ_curwin;
137  unsigned long XJ_letterbox_colour;
141  vector<XShmSegmentInfo*> XJ_shm_infos;
142  vector<YUVInfo> XJ_yuv_infos;
144  // Basic non-Xv drawing info
149  AVPixelFormat non_xv_av_format;
152  // Basic Xv drawing info
153  int xv_port;
162  QMap<PictureAttribute,int> xv_attribute_min;
163  QMap<PictureAttribute,int> xv_attribute_max;
164  QMap<PictureAttribute,int> xv_attribute_def;
166  // Chromakey OSD info
168 };
170 #endif // VIDEOOUT_XV_H_
AVPixelFormat non_xv_av_format
Definition: videoout_xv.h:149
QMap< PictureAttribute, int > xv_attribute_max
Definition: videoout_xv.h:163
QMutex global_lock
Definition: videoout_xv.h:131
void DrawUnusedRects(bool sync=true) override
Draws non-video portions of the screen.
def scan(profile, smoonURL, gate)
void ProcessFrame(VideoFrame *frame, OSD *osd, FilterChain *filterList, const PIPMap &pipPlayers, FrameScanType scan) override
vector< XShmSegmentInfo * > XJ_shm_infos
Definition: videoout_xv.h:141
QMap< MythPlayer *, PIPLocation > PIPMap
Definition: videooutbase.h:37
ChromaKeyOSD * chroma_osd
Definition: videoout_xv.h:167
int SetXVPictureAttribute(PictureAttribute attribute, int newValue)
bool InitXShm(void)
Creates and initializes video buffers.
void InitColorKey(bool turnoffautopaint)
Initializes color keying support used by XVideo output methods.
Definition: mythcodecid.h:10
bool InitXVideo(void)
Creates and initializes video buffers.
bool CreateOSD(void)
bool ApproveDeintFilter(const QString &filtername) const override
Approves bobdeint filter for XVideo and otherwise defers to VideoOutput::ApproveDeintFilter(const QSt...
void ShowXVideo(FrameScanType scan)
bool IsPBPSupported(void) const override
Definition: videoout_xv.h:76
Definition: videoouttypes.h:80
int GrabSuitableXvPort(MythXDisplay *disp, Window root, MythCodecID type, uint width, uint height, bool &xvsetdefaults, QString *adaptor_name=nullptr)
Internal function used to grab a XVideo port with the desired properties.
This file is intended to hold X11 specific utility functions.
Definition: mythxdisplay.h:16
unsigned int uint
Definition: compat.h:140
MythXDisplay * disp
Definition: videoout_xv.h:136
VideoFrame av_pause_frame
Definition: videoout_xv.h:140
bool SetDeinterlacingEnabled(bool) override
Attempts to enable/disable deinterlacing using existing deinterlace method when enabling.
vector< unsigned char * > CreateShmImages(uint num, bool use_xv)
Creates Shared Memory Images.
bool xv_use_picture_controls
Definition: videoout_xv.h:161
VOSType video_output_subtype
Definition: videoout_xv.h:130
static void UngrabXvPort(MythXDisplay *disp, int port)
Internal function used to release an XVideo port.
static MythCodecID GetBestSupportedCodec(uint stream_type)
unsigned long XJ_letterbox_colour
Definition: videoout_xv.h:137
Window XJ_curwin
Definition: videoout_xv.h:135
enum VideoOutputSubType VOSType
void MoveResizeWindow(QRect new_rect) override
This class serves as the base class for all video output methods.
Definition: videooutbase.h:46
static QStringList GetAllowedRenderers(MythCodecID myth_codec_id, const QSize &video_dim)
bool Init(const QSize &video_dim_buf, const QSize &video_dim_disp, float aspect, WId winid, const QRect &win_rect, MythCodecID codec_id) override
Initializes class for video output.
bool SetupDeinterlace(bool interlaced, const QString &overridefilter="") override
Attempts to enable or disable deinterlacing.
void PrepareFrame(VideoFrame *, FrameScanType, OSD *osd) override
void PrepareFrameMem(VideoFrame *, FrameScanType)
void CreatePauseFrame(VOSType subtype)
Creates an extra frame for pause.
void UpdatePauseFrame(int64_t &default_tc) override
Updates frame displayed when video is paused.
bool NeedExtraAudioDecode(void) const override
Definition: videoout_xv.h:78
void PrepareFrameXv(VideoFrame *)
bool CreateBuffers(VOSType subtype)
int non_xv_show_frame
Definition: videoout_xv.h:147
Definition: videoouttypes.h:89
MythPainter * GetOSDPainter(void) override
void VideoAspectRatioChanged(float aspect) override
Calls SetVideoAspectRatio(float aspect), then calls MoveResize() to apply changes.
XImage * XJ_non_xv_image
Definition: videoout_xv.h:145
time_t non_xv_stop_time
Definition: videoout_xv.h:150
void ClearAfterSeek(void) override
Tells video output to toss decoded buffers due to a seek.
QMap< PictureAttribute, int > xv_attribute_def
Definition: videoout_xv.h:164
void DiscardFrames(bool next_frame_keyframe) override
Releases all frames not being actively displayed from any queue onto the queue of frames ready for de...
Supports common video output methods used with X11 Servers.
Definition: videoout_xv.h:28
bool IsPIPSupported(void) const override
Definition: videoout_xv.h:74
Definition: videoouttypes.h:19
void StopEmbedding(void) override
Tells video output to stop embedding video in an existing window.
buffer_map_t xv_buffers
Definition: videoout_xv.h:159
void DiscardFrame(VideoFrame *) override
Frame is ready to be reused by decoder added to the done or available list.
int SetPictureAttribute(PictureAttribute attribute, int newValue) override
Sets a specified picture attribute.
static void GetRenderOptions(render_opts &opts, QStringList &cpudeints)
Definition: videoout_xv.cpp:80
void EmbedInWidget(const QRect &rect) override
Tells video output to embed video in an existing window.
Definition: videoout_xv.h:23
bool xv_need_bobdeint_repaint
Definition: videoout_xv.h:160
void Show(FrameScanType) override
QMap< PictureAttribute, int > xv_attribute_min
Definition: videoout_xv.h:162
vector< YUVInfo > XJ_yuv_infos
Definition: videoout_xv.h:142
long long non_xv_frames_shown
Definition: videoout_xv.h:146
void MoveResize(void) override
performs all the calculations for video framing and any resizing.
Definition: osd.h:132
bool InitVideoBuffers(bool use_xv, bool use_shm)
Creates and initializes video buffers.
map< const unsigned char *, void * > buffer_map_t
Definition: videobuffers.h:24
void WindowResized(const QSize &new_size) override
VOSType VideoOutputSubType() const
Definition: videoout_xv.h:97
bool InitSetupBuffers(void)
bool InitXlib(void)
Creates and initializes video buffers.
void Zoom(ZoomDirection direction) override
Sets up zooming into to different parts of the video, the zoom is actually applied in MoveResize().
void DeleteBuffers(VOSType subtype, bool delete_pause_frame)
Definition: videoouttypes.h:28
void InitPictureAttributes(void) override
bool xv_draw_colorkey
Definition: videoout_xv.h:156
bool xv_set_defaults
Definition: videoout_xv.h:158
bool InputChanged(const QSize &video_dim_buf, const QSize &video_dim_disp, float aspect, MythCodecID av_codec_id, void *codec_private, bool &aspect_only) override
Tells video output to discard decoded frames and wait for new ones.
bool hasFullScreenOSD(void) const override
Definition: videoout_xv.h:101
QRect GetPIPRect(PIPLocation location, MythPlayer *pipplayer=nullptr, bool do_pixel_adj=true) const override
returns QRect of PIP based on PIPLocation