00001 #ifndef _OGGSTREAM_H_ 00002 #define _OGGSTREAM_H_ 00003 00004 #include <iostream> 00005 #include <string> 00006 #include <vector> 00007 using namespace std; 00008 00009 #include <AL/al.h> 00010 #include <ogg/ogg.h> 00011 #include <vorbis/codec.h> 00012 #include <vorbis/vorbisenc.h> 00013 #include <vorbis/vorbisfile.h> 00014 00015 #include "Vector3.h" 00016 00017 #define BUFFER_SIZE (4096 * 8) 00018 00024 class OggStream 00025 { 00026 public: 00027 OggStream(); 00028 virtual ~OggStream(); 00029 00033 bool open(string filename) { return open(filename, Vector3(0.0, 0.0, 0.0), Vector3(0.0, 0.0, 0.0)); } 00034 bool open(string filename, Vector3 position, Vector3 velocity); 00038 void release(); 00042 bool play(); 00048 bool isPlaying(); 00052 bool update(); 00053 00054 protected: 00058 bool stream(ALuint buffer); 00062 void empty(); 00066 void rewind(); 00070 void checkError(); 00071 00072 // ogg info 00073 FILE *_oggFile; 00074 OggVorbis_File _oggStream; 00075 vorbis_info *_vorbisInfo; 00076 00077 // openal info 00078 ALuint _buffers[2]; 00079 ALuint _source; 00080 ALenum _format; 00081 }; 00082 00083 #endif