forked from Raptor007/AutoDJ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAudioFile.h
44 lines (39 loc) · 1 KB
/
AudioFile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#define __STDC_CONSTANT_MACROS
#define __STDC_FORMAT_MACROS
extern "C" {
#include <libavutil/imgutils.h>
#include <libavutil/samplefmt.h>
#include <libavutil/timestamp.h>
#include <libavutil/opt.h>
#include <libavformat/avformat.h>
#include <libavresample/avresample.h>
}
#include <map>
#include <string>
class AudioFile
{
public:
uint8_t *Data;
size_t Allocated, Size;
size_t Channels, SampleRate, BytesPerSample;
AVSampleFormat SampleFormat;
std::map<std::string,std::string> Tags;
AudioFile( const char *filename = NULL, volatile bool *running_ptr = NULL );
~AudioFile();
void Clear( void );
bool AddData( uint8_t *add_data, size_t add_size );
bool Load( const char *filename, volatile bool *running_ptr );
private:
AVFormatContext *fmt_ctx;
AVCodecContext *audio_dec_ctx;
AVStream *audio_stream;
int audio_stream_idx;
AVFrame *frame;
AVPacket pkt;
int audio_frame_count;
int decoded;
int got_frame;
AVAudioResampleContext *avr;
bool DecodePacket( void );
bool OpenAudioCodecContext( void );
};