Miam-Player  0.8.0
A nice music player
VideoOutput.h
Go to the documentation of this file.
1 /******************************************************************************
2  QtAV: Multimedia framework based on Qt and FFmpeg
3  Copyright (C) 2012-2016 Wang Bin <wbsecg1@gmail.com>
4 
5 * This file is part of QtAV (from 2014)
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 ******************************************************************************/
21 
22 #ifndef QTAV_VIDEOOUTPUT_H
23 #define QTAV_VIDEOOUTPUT_H
24 
25 #include <QtCore/QObject>
26 #include <QtAV/VideoRenderer.h>
27 
28 namespace QtAV {
29 
30 class VideoOutputPrivate;
35 class Q_AV_EXPORT VideoOutput : public QObject, public VideoRenderer
36 {
38  Q_OBJECT
39  Q_PROPERTY(qreal brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged)
40  Q_PROPERTY(qreal contrast READ contrast WRITE setContrast NOTIFY contrastChanged)
41  Q_PROPERTY(qreal hue READ hue WRITE setHue NOTIFY hueChanged)
42  Q_PROPERTY(qreal saturation READ saturation WRITE setSaturation NOTIFY saturationChanged)
43  Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
44  Q_PROPERTY(QRectF regionOfInterest READ regionOfInterest WRITE setRegionOfInterest NOTIFY regionOfInterestChanged)
45  Q_PROPERTY(qreal sourceAspectRatio READ sourceAspectRatio NOTIFY sourceAspectRatioChanged)
46  Q_PROPERTY(qreal outAspectRatio READ outAspectRatio WRITE setOutAspectRatio NOTIFY outAspectRatioChanged)
47  //fillMode
48  // TODO: how to use enums in base class as property or Q_ENUM
49  Q_PROPERTY(OutAspectRatioMode outAspectRatioMode READ outAspectRatioMode WRITE setOutAspectRatioMode NOTIFY outAspectRatioModeChanged)
50  Q_ENUMS(OutAspectRatioMode)
51  Q_PROPERTY(int orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
52  Q_PROPERTY(QRect videoRect READ videoRect NOTIFY videoRectChanged)
53  Q_PROPERTY(QSize videoFrameSize READ videoFrameSize NOTIFY videoFrameSizeChanged)
54  Q_ENUMS(Quality)
55 public:
60  VideoOutput(QObject *parent = 0);
65  VideoOutput(VideoRendererId rendererId, QObject *parent = 0);
66  ~VideoOutput();
68 
69  VideoFormat::PixelFormat preferredPixelFormat() const Q_DECL_OVERRIDE;
70  bool isSupported(VideoFormat::PixelFormat pixfmt) const Q_DECL_OVERRIDE;
71  QWindow* qwindow() Q_DECL_OVERRIDE Q_DECL_FINAL;
72  QWidget* widget() Q_DECL_OVERRIDE Q_DECL_FINAL;
73  QGraphicsItem* graphicsItem() Q_DECL_OVERRIDE Q_DECL_FINAL;
74  OpenGLVideo* opengl() const Q_DECL_OVERRIDE;
75 Q_SIGNALS:
76  void sourceAspectRatioChanged(qreal value) Q_DECL_OVERRIDE Q_DECL_FINAL;
77  void regionOfInterestChanged() Q_DECL_OVERRIDE;
78  void outAspectRatioChanged() Q_DECL_OVERRIDE;
79  void outAspectRatioModeChanged() Q_DECL_OVERRIDE;
80  void brightnessChanged(qreal value) Q_DECL_OVERRIDE;
81  void contrastChanged(qreal) Q_DECL_OVERRIDE;
82  void hueChanged(qreal) Q_DECL_OVERRIDE;
83  void saturationChanged(qreal) Q_DECL_OVERRIDE;
84  void backgroundColorChanged() Q_DECL_OVERRIDE;
85  void orientationChanged() Q_DECL_OVERRIDE;
86  void videoRectChanged() Q_DECL_OVERRIDE;
87  void videoFrameSizeChanged() Q_DECL_OVERRIDE;
88 protected:
89  bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE;
90  bool receiveFrame(const VideoFrame& frame) Q_DECL_OVERRIDE;
91  void drawBackground() Q_DECL_OVERRIDE;
92  void drawFrame() Q_DECL_OVERRIDE;
93  void handlePaintEvent() Q_DECL_OVERRIDE;
94 
95 private:
96  virtual bool onSetPreferredPixelFormat(VideoFormat::PixelFormat pixfmt) Q_DECL_OVERRIDE;
97  virtual bool onForcePreferredPixelFormat(bool force = true) Q_DECL_OVERRIDE;
98  virtual void onSetOutAspectRatioMode(OutAspectRatioMode mode) Q_DECL_OVERRIDE;
99  virtual void onSetOutAspectRatio(qreal ratio) Q_DECL_OVERRIDE;
100  virtual bool onSetQuality(Quality q) Q_DECL_OVERRIDE;
101  virtual bool onSetOrientation(int value) Q_DECL_OVERRIDE;
102  virtual void onResizeRenderer(int width, int height) Q_DECL_OVERRIDE;
103  virtual bool onSetRegionOfInterest(const QRectF& roi) Q_DECL_OVERRIDE;
104  virtual QPointF onMapToFrame(const QPointF& p) const Q_DECL_OVERRIDE;
105  virtual QPointF onMapFromFrame(const QPointF& p) const Q_DECL_OVERRIDE;
106 
107  virtual bool onSetBrightness(qreal brightness) Q_DECL_OVERRIDE;
108  virtual bool onSetContrast(qreal contrast) Q_DECL_OVERRIDE;
109  virtual bool onSetHue(qreal hue) Q_DECL_OVERRIDE;
110  virtual bool onSetSaturation(qreal saturation) Q_DECL_OVERRIDE;
111  virtual void onSetBackgroundColor(const QColor& color) Q_DECL_OVERRIDE;
112  // from AVOutput
113  virtual void setStatistics(Statistics* statistics) Q_DECL_OVERRIDE; //called by friend AVPlayer
114  virtual bool onInstallFilter(Filter *filter, int index) Q_DECL_OVERRIDE;
115  virtual bool onUninstallFilter(Filter *filter) Q_DECL_OVERRIDE;
116  virtual bool onHanlePendingTasks() Q_DECL_OVERRIDE;
117 };
118 
119 } //namespace QtAV
120 
121 #endif // QTAV_VIDEOOUTPUT_H
#define Q_AV_EXPORT
Definition: QtAV_Global.h:40
The VideoFormat class Describes the layout of video data.
Definition: VideoFormat.h:39
#define DPTR_DECLARE_PRIVATE(Class)
Definition: dptr.h:107
The VideoOutput class A VideoRenderer wrapper with QObject features.
Definition: VideoOutput.h:35
OutAspectRatioMode
Definition: VideoRenderer.h:57
Definition: Filter.h:36
Definition: VideoFrame.h:32
Definition: Statistics.h:35
Quality
Definition: VideoRenderer.h:63
int VideoRendererId
Definition: VideoRenderer.h:45
Definition: FilterContext.h:102
AudioOutput ao; ao.setAudioFormat(fmt); ao.open(); while (has_data) { data = read_data(ao->bufferSize...
Definition: AudioDecoder.h:31
The OpenGLVideo class high level api for renderering a video frame.
Definition: OpenGLVideo.h:51
#define Q_DECL_OVERRIDE
Definition: QtAV_Global.h:177
Definition: VideoRenderer.h:51