Miam-Player  0.8.0
A nice music player
VideoEncoder.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 2015)
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_VIDEOENCODER_H
23 #define QTAV_VIDEOENCODER_H
24 
25 #include <QtAV/AVEncoder.h>
26 #include <QtAV/VideoFrame.h>
27 #include <QtCore/QStringList>
28 
29 namespace QtAV {
30 typedef int VideoEncoderId;
33 {
34  Q_OBJECT
35  Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
36  Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
37  Q_PROPERTY(qreal frameRate READ frameRate WRITE setFrameRate NOTIFY frameRateChanged)
38  Q_PROPERTY(QtAV::VideoFormat::PixelFormat pixelFormat READ pixelFormat WRITE setPixelFormat NOTIFY pixelFormatChanged)
39  Q_DISABLE_COPY(VideoEncoder)
41 public:
42  static QStringList supportedCodecs();
43  static VideoEncoder* create(VideoEncoderId id);
50  static VideoEncoder* create(const char* name = "FFmpeg");
51  virtual VideoEncoderId id() const = 0;
52  QString name() const Q_DECL_OVERRIDE; //name from factory
59  virtual bool encode(const VideoFrame& frame = VideoFrame()) = 0;
61 
65  void setWidth(int value);
66  int width() const;
67  void setHeight(int value);
68  int height() const;
70 
75  void setFrameRate(qreal value);
76  qreal frameRate() const;
77  static qreal defaultFrameRate() { return 25;}
83  void setPixelFormat(const VideoFormat::PixelFormat format);
84  VideoFormat::PixelFormat pixelFormat() const;
85  // TODO: supportedPixelFormats() const;
86 Q_SIGNALS:
87  void widthChanged();
88  void heightChanged();
89  void frameRateChanged();
90  void pixelFormatChanged();
91 
92 public:
93  template<class C> static bool Register(VideoEncoderId id, const char* name) { return Register(id, create<C>, name);}
99  static VideoEncoderId* next(VideoEncoderId* id = 0);
100  static const char* name(VideoEncoderId id);
101  static VideoEncoderId id(const char* name);
102 private:
103  template<class C> static VideoEncoder* create() { return new C();}
104  typedef VideoEncoder* (*VideoEncoderCreator)();
105  static bool Register(VideoEncoderId id, VideoEncoderCreator, const char *name);
106 protected:
108 private:
109  VideoEncoder();
110 };
111 
112 } //namespace QtAV
113 #endif // QTAV_VIDEOENCODER_H
Definition: AVEncoder.h:33
#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
Definition: AVEncoder_p.h:84
PixelFormat
The PixelFormat enum 32 bit rgba format enum name indicates it&#39;s channel layout.
Definition: VideoFormat.h:51
static bool Register(VideoEncoderId id, const char *name)
Definition: VideoEncoder.h:93
Definition: VideoFrame.h:32
int VideoEncoderId
Definition: VideoEncoder.h:30
AudioOutput ao; ao.setAudioFormat(fmt); ao.open(); while (has_data) { data = read_data(ao->bufferSize...
Definition: AudioDecoder.h:31
Definition: VideoEncoder.h:32
#define Q_DECL_OVERRIDE
Definition: QtAV_Global.h:177