Miam-Player  0.8.0
A nice music player
AudioDecoder.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
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 QAV_AUDIODECODER_H
23 #define QAV_AUDIODECODER_H
24 
25 #include <QtAV/AVDecoder.h>
26 #include <QtAV/AudioFrame.h>
27 #include <QtCore/QStringList>
28 
29 #define USE_AUDIO_FRAME 1
30 //TODO: decoder.in/outAudioFormat()?
31 namespace QtAV {
32 typedef int AudioDecoderId;
33 // built-in decoders
34 extern Q_AV_EXPORT AudioDecoderId AudioDecoderId_FFmpeg;
35 
36 class AudioResampler;
39 {
40  Q_DISABLE_COPY(AudioDecoder)
42 public:
43  static QStringList supportedCodecs();
44  static AudioDecoder* create(AudioDecoderId id);
51  static AudioDecoder* create(const char* name = "FFmpeg");
52  virtual AudioDecoderId id() const = 0;
53  QString name() const; //name from factory
54  virtual QByteArray data() const; //decoded data
55  virtual AudioFrame frame() = 0;
56  AudioResampler *resampler(); //TODO: remove. can not share the same resampler for multiple frames
57 public:
58  template<class C> static bool Register(AudioDecoderId id, const char* name) { return Register(id, create<C>, name);}
64  static AudioDecoderId* next(AudioDecoderId* id = 0);
65  static const char* name(AudioDecoderId id);
66  static AudioDecoderId id(const char* name);
67 private:
68  // if QtAV is static linked (ios for example), components may be not automatically registered. Add registerAll() to workaround
69  static void registerAll();
70  template<class C> static AudioDecoder* create() { return new C();}
71  typedef AudioDecoder* (*AudioDecoderCreator)();
72  static bool Register(AudioDecoderId id, AudioDecoderCreator, const char *name);
73 protected:
75 private:
76  AudioDecoder();
77 };
78 
79 } //namespace QtAV
80 #endif // QAV_AUDIODECODER_H
Definition: AudioDecoder.h:38
#define Q_AV_EXPORT
Definition: QtAV_Global.h:40
#define DPTR_DECLARE_PRIVATE(Class)
Definition: dptr.h:107
Q_AV_EXPORT AudioDecoderId AudioDecoderId_FFmpeg
Definition: AVDecoder.h:33
static bool Register(AudioDecoderId id, const char *name)
Definition: AudioDecoder.h:58
Definition: AudioFrame.h:31
int AudioDecoderId
Definition: AudioDecoder.h:32
Definition: AudioResampler.h:32
AudioOutput ao; ao.setAudioFormat(fmt); ao.open(); while (has_data) { data = read_data(ao->bufferSize...
Definition: AudioDecoder.h:31
Definition: AVDecoder_p.h:125