|
|
// ########################################################################## // #### #### // #### RTP Audio Server Project #### // #### ============================ #### // #### #### // #### MP3 Audio Reader #### // #### #### // #### Version 1.00 -- February 04, 2001 #### // #### #### // #### Copyright (C) 1999 Thomas Dreibholz #### // #### 2000 Universität Bonn, Abt. IV #### // #### 2001 EMail: Dreibholz@bigfoot.com #### // #### WWW: http://www.bigfoot.com/~dreibholz #### // #### #### // ########################################################################## #ifndef MP3AUDIOREADER_H #define MP3AUDIOREADER_H #include "system.h" #include "audioreaderinterface.h" #include "audioquality.h" // IMPORTANT: PTHREADEDMPEG *must* be defined, if libmpegsound.a is // compiled with PTHREADEDMPEG set!!! Otherwise initialization // of Mpegtoraw object will fail with segmentation fault! #define PTHREADEDMPEG 1 #define HAVE_PTHREAD_H #include "mpegsound.h" namespace Coral { /** * This class is a reader for MP3 audio files. * * @short MP3 Audio Reader * @author Thomas Dreibholz (Dreibholz@bigfoot.com) * @version 1.0 */ class MP3AudioReader : public Soundplayer, public AudioReaderInterface, public AudioQuality { // ====== Constructor/Destructor ========================================= public: /** * Constructor. * * @param name Name of MP3 file or NULL. */ MP3AudioReader(const char* name = NULL); /** * Destructor. */ ~MP3AudioReader(); // ====== Initialize ===================================================== /** * openMedia() implementation of AudioReaderInterface. * * @see AudioReaderInterface#openMedia */ bool openMedia(const char* name); /** * closeMedia() implementation of AudioReaderInterface. * * @see AudioReaderInterface#closeMedia */ void closeMedia(); /** * ready() implementation of AudioReaderInterface. * * @see AudioReaderInterface#ready */ bool ready() const; // ====== Input functions ================================================ /** * getMediaInfo() implementation of AudioReaderInterface. * * @see AudioReaderInterface#getMediaInfo */ void getMediaInfo(MediaInfo& mediaInfo) const; /** * getErrorCode() implementation of AudioReaderInterface. * * @see AudioReaderInterface#getErrorCode */ MediaError getErrorCode() const; /** * getPosition() implementation of AudioReaderInterface. * * @see AudioReaderInterface#getPosition */ card64 getPosition() const; /** * getMaxPosition() implementation of AudioReaderInterface. * * @see AudioReaderInterface#getMaxPosition */ card64 getMaxPosition() const; /** * setPosition() implementation of AudioReaderInterface. * * @see AudioReaderInterface#setPosition */ void setPosition(const card64 position); /** * getNextBlock() implementation of AudioReaderInterface. * * @see AudioReaderInterface#getNextBlock */ cardinal getNextBlock(void* buffer, const cardinal blockSize); // ====== Soundplayer implementation ===================================== private: bool initialize(char* filename); bool setsoundtype(int stereo, int samplesize, int speed); void set8bitmode(); bool putblock(void* buffer, int size); // ====== Private data =================================================== private: bool readNextFrame(); Mpegtoraw* MP3Decoder; Soundinputstreamfromfile* MP3Source; cardinal BufferPos; cardinal BufferSize; double FramesPerSecond; card64 Position; card64 MaxPosition; MediaError Error; char Buffer[RAWDATASIZE * sizeof(short int)]; }; } #endif
Generated by: viper@odin on Sun Feb 4 18:54:51 2001, using kdoc 2.0a22. |