Miam-Player  0.8.0
A nice music player
AudioResampler.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 2013)
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_AUDIORESAMPLER_H
23 #define QTAV_AUDIORESAMPLER_H
24 
25 #include <QtAV/QtAV_Global.h>
26 
27 namespace QtAV {
28 
29 typedef int AudioResamplerId;
30 class AudioFormat;
32 class Q_AV_EXPORT AudioResampler //export is required for users who want add their own subclass outside QtAV
33 {
35 public:
36  virtual ~AudioResampler();
37  // if QtAV is static linked (ios for example), components may be not automatically registered. Add registerAll() to workaround
38  static void registerAll();
39  template<class C>
40  static bool Register(AudioResamplerId id, const char* name) { return Register(id, create<C>, name);}
41  static AudioResampler* create(AudioResamplerId id);
47  static AudioResampler* create(const char* name);
53  static AudioResamplerId* next(AudioResamplerId* id = 0);
54  static const char* name(AudioResamplerId id);
55  static AudioResamplerId id(const char* name);
56 
57  QByteArray outData() const;
58  /* check whether the parameters are supported. If not, you should use ff*/
64  virtual bool prepare();
65  virtual bool convert(const quint8** data);
66  //speed: >0, default is 1
67  void setSpeed(qreal speed); //out_sample_rate = out_sample_rate/speed
68  qreal speed() const;
69 
70  void setInAudioFormat(const AudioFormat& format);
71  AudioFormat& inAudioFormat();
72  const AudioFormat& inAudioFormat() const;
73 
74  void setOutAudioFormat(const AudioFormat& format);
75  AudioFormat& outAudioFormat();
76  const AudioFormat& outAudioFormat() const;
77 
78  //decoded frame's samples/channel
79  void setInSampesPerChannel(int samples);
80  // > 0 valid after resample done
81  int outSamplesPerChannel() const;
82  //channel count can be computed by av_get_channel_layout_nb_channels(chl)
83  void setInSampleRate(int isr);
84  void setOutSampleRate(int osr); //default is in
85  //TODO: enum
86  void setInSampleFormat(int isf); //FFmpeg sample format
87  void setOutSampleFormat(int osf); //FFmpeg sample format. set by user. default is in
88  //TODO: enum. layout will be set to the default layout of the channels if not defined
89  void setInChannelLayout(qint64 icl);
90  void setOutChannelLayout(qint64 ocl); //default is in
91  void setInChannels(int channels);
92  void setOutChannels(int channels);
93  //Are getter functions required?
94 private:
96  template<class C>
97  static AudioResampler* create() {
98  return new C();
99  }
100  typedef AudioResampler* (*AudioResamplerCreator)();
101  static bool Register(AudioResamplerId id, AudioResamplerCreator, const char *name);
102 
103 protected:
106 };
107 
108 extern Q_AV_EXPORT AudioResamplerId AudioResamplerId_FF;
109 extern Q_AV_EXPORT AudioResamplerId AudioResamplerId_Libav;
110 } //namespace QtAV
111 #endif // QTAV_AUDIORESAMPLER_H
Definition: AudioResampler_p.h:32
#define Q_AV_EXPORT
Definition: QtAV_Global.h:40
int AudioResamplerId
Definition: AudioResampler.h:29
#define DPTR_DECLARE_PRIVATE(Class)
Definition: dptr.h:107
static bool Register(AudioResamplerId id, const char *name)
Definition: AudioResampler.h:40
Definition: AudioFormat.h:35
Definition: AudioResampler.h:32
Q_AV_EXPORT AudioResamplerId AudioResamplerId_FF
#define DPTR_DECLARE(Class)
Definition: dptr.h:105
AudioOutput ao; ao.setAudioFormat(fmt); ao.open(); while (has_data) { data = read_data(ao->bufferSize...
Definition: AudioDecoder.h:31
Q_AV_EXPORT AudioResamplerId AudioResamplerId_Libav