Miam-Player  0.8.0
A nice music player
AudioEncoder.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_AUDIOENCODER_H
23 #define QTAV_AUDIOENCODER_H
24 
25 #include <QtAV/AVEncoder.h>
26 #include <QtAV/AudioFrame.h>
27 #include <QtCore/QStringList>
28 
29 namespace QtAV {
30 typedef int AudioEncoderId;
33 {
34  Q_OBJECT
35  Q_PROPERTY(QtAV::AudioFormat audioFormat READ audioFormat WRITE setAudioFormat NOTIFY audioFormatChanged)
36  Q_DISABLE_COPY(AudioEncoder)
38 public:
39  static QStringList supportedCodecs();
40  static AudioEncoder* create(AudioEncoderId id);
47  static AudioEncoder* create(const char* name = "FFmpeg");
48  virtual AudioEncoderId id() const = 0;
49  QString name() const Q_DECL_OVERRIDE; //name from factory
56  virtual bool encode(const AudioFrame& frame = AudioFrame()) = 0;
57 
59 
65  const AudioFormat& audioFormat() const;
66  void setAudioFormat(const AudioFormat& format);
67 Q_SIGNALS:
68  void audioFormatChanged();
69 public:
70  template<class C> static bool Register(AudioEncoderId id, const char* name) { return Register(id, create<C>, name);}
76  static AudioEncoderId* next(AudioEncoderId* id = 0);
77  static const char* name(AudioEncoderId id);
78  static AudioEncoderId id(const char* name);
79 private:
80  template<class C> static AudioEncoder* create() { return new C();}
81  typedef AudioEncoder* (*AudioEncoderCreator)();
82  static bool Register(AudioEncoderId id, AudioEncoderCreator, const char *name);
83 protected:
85 private:
86  AudioEncoder();
87 };
88 
89 } //namespace QtAV
90 #endif // QTAV_AUDIOENCODER_H
Definition: AVEncoder.h:33
#define Q_AV_EXPORT
Definition: QtAV_Global.h:40
#define DPTR_DECLARE_PRIVATE(Class)
Definition: dptr.h:107
Definition: AudioEncoder.h:32
static bool Register(AudioEncoderId id, const char *name)
Definition: AudioEncoder.h:70
Definition: AVEncoder_p.h:69
Definition: AudioFrame.h:31
Definition: AudioFormat.h:35
AudioOutput ao; ao.setAudioFormat(fmt); ao.open(); while (has_data) { data = read_data(ao->bufferSize...
Definition: AudioDecoder.h:31
#define Q_DECL_OVERRIDE
Definition: QtAV_Global.h:177
int AudioEncoderId
Definition: AudioEncoder.h:30