2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
7 #ifndef CAFU_SOUNDSYS_MP3_STREAM_HPP_INCLUDED
8 #define CAFU_SOUNDSYS_MP3_STREAM_HPP_INCLUDED
10 #include "SoundStream.hpp"
13 struct mpg123_handle_struct
;
14 typedef struct mpg123_handle_struct mpg123_handle
;
15 namespace cf
{ namespace FileSys
{ class InFileI
; } }
18 /// Represents an MP3 stream.
19 /// Audio data is decompressed and readable as 16 bit enconded mono or stereo raw PCM data.
20 /// This class uses the mpg123 library to read PCM data from an MP3 file.
21 class MP3StreamT
: public SoundStreamT
25 /// The constructor. Throws an exception of type std::runtime_error on failure.
26 /// Creates an audio data stream from an MP3 file.
27 /// @param FileName The path to the file from which the stream should be created.
28 MP3StreamT(const std::string
& FileName
);
33 // SoundStream implementation.
34 int Read(unsigned char* Buffer
, unsigned int Size
);
36 unsigned int GetChannels();
37 unsigned int GetRate();
42 mpg123_handle
* StreamHandle
; ///< Handle to the mpg123 stream.
43 cf::FileSys::InFileI
* StreamFile
; ///< The file handle from which the mp3 data is streamed.
45 long Rate
; ///< Sampling rate of this stream in Hz.
46 int Channels
; ///< Number of channels in this stream.