2010-02-09 06:58:27 +01:00
|
|
|
#ifndef CMP3DECODER_H
|
|
|
|
#define CMP3DECODER_H
|
|
|
|
|
2010-02-16 04:00:21 +01:00
|
|
|
#include "../../include/IAudioDecoder.h"
|
2010-02-13 00:11:26 +01:00
|
|
|
#include "mpaudec/mpaudec.h"
|
2010-02-09 06:58:27 +01:00
|
|
|
|
|
|
|
using namespace cAudio;
|
|
|
|
|
2010-02-13 00:11:26 +01:00
|
|
|
class cMP3Packet
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cMP3Packet()
|
|
|
|
{
|
|
|
|
data = 0x0;
|
|
|
|
reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void reset()
|
|
|
|
{
|
|
|
|
size = 0;
|
|
|
|
read = 0;
|
|
|
|
}
|
|
|
|
int size;
|
|
|
|
int read;
|
|
|
|
unsigned char* data;
|
|
|
|
};
|
|
|
|
|
2010-02-09 06:58:27 +01:00
|
|
|
class cMP3Decoder : public IAudioDecoder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cMP3Decoder(IDataSource* stream);
|
|
|
|
~cMP3Decoder();
|
|
|
|
|
|
|
|
//!Returns the format of the audio data
|
|
|
|
virtual AudioFormats getFormat();
|
|
|
|
|
|
|
|
//!Returns the frequency of the audio data
|
|
|
|
virtual int getFrequency();
|
|
|
|
|
|
|
|
//!Returns whether seeking is supported
|
|
|
|
virtual bool isSeekingSupported();
|
|
|
|
|
|
|
|
//!Returns whether the stream is valid for this codec
|
|
|
|
virtual bool isValid();
|
|
|
|
|
|
|
|
//!Reads a section of data out of the audio stream
|
|
|
|
virtual int readAudioData(void* output, int amount);
|
|
|
|
|
|
|
|
//!Sets the position to read data out of
|
|
|
|
virtual bool setPosition(int position, bool relative);
|
|
|
|
|
|
|
|
//!If seeking is supported, will seek the stream to seconds
|
|
|
|
virtual bool seek(float seconds, bool relative);
|
2010-02-13 00:11:26 +01:00
|
|
|
|
2010-02-17 04:49:22 +01:00
|
|
|
virtual float getTotalTime();
|
|
|
|
virtual int getTotalSize();
|
|
|
|
virtual int getCompressedSize();
|
|
|
|
|
|
|
|
virtual float getCurrentTime();
|
|
|
|
virtual int getCurrentPosition();
|
|
|
|
virtual int getCurrentCompressedPosition();
|
|
|
|
|
2010-02-13 00:11:26 +01:00
|
|
|
protected:
|
|
|
|
MPAuDecContext* Context;
|
|
|
|
bool Valid;
|
|
|
|
unsigned int DataOffset;
|
|
|
|
int NumChannels;
|
|
|
|
int Frequency;
|
|
|
|
|
2010-02-17 04:49:22 +01:00
|
|
|
int TotalSize;
|
|
|
|
int CurrentPosition;
|
|
|
|
|
2010-02-13 00:11:26 +01:00
|
|
|
cMP3Packet CurrentPacket;
|
2010-02-09 06:58:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //! CMP3DECODER_H
|