OggFileReader.h

Go to the documentation of this file.
00001 
00002 //    Copyright 2004, SenseGraphics AB
00003 //
00004 //    This file is part of H3D API.
00005 //
00006 //    H3D API is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    H3D API is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with H3D API; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 //
00020 //    A commercial license is also available. Please contact us at 
00021 //    www.sensegraphics.com for more information.
00022 //
00023 //
00027 //
00029 
00030 #ifndef __OGGFILEREADER_H__
00031 #define __OGGFILEREADER_H__
00032 
00033 #include "H3DSoundFileNode.h"
00034 
00035 #ifdef HAVE_LIBVORBIS
00036 #ifdef _MSC_VER
00037 #pragma comment( lib, "vorbisfile.lib" )
00038 #endif
00039 #include <vorbis/vorbisfile.h>
00040 
00041 namespace H3D {
00042 
00048   class H3DAPI_API OggFileReader : public H3DSoundFileNode {
00049   public:
00050 
00052     OggFileReader() {}
00053 
00055     ~OggFileReader() {
00056       ov_clear( &ogg_file );
00057     }
00058 
00061     unsigned int load( const string &_url );
00062           
00064     virtual H3DTime duration() {
00065       return ov_time_total( &ogg_file, -1 );
00066     }
00067     
00069     virtual void reset() {
00070       ov_raw_seek( &ogg_file, 0 );
00071     }
00072     
00074     virtual unsigned int totalDataSize() {
00075       return ov_raw_total( &ogg_file, -1 );
00076     }
00077       
00080     virtual unsigned int nrChannels() {
00081       return info->channels;
00082     }
00083     
00085     virtual unsigned int bitsPerSample() {
00086       return 16;
00087     }
00088 
00093     virtual unsigned int read( char *buffer, unsigned int size );
00094     
00097     virtual unsigned int samplesPerSecond() {
00098       return info->rate;
00099     }
00100     
00103     static bool supportsFileType( const string &url );
00104 
00106     static H3DNodeDatabase database;
00107 
00109     static FileReaderRegistration reader_registration;
00110 
00111   protected:
00112     OggVorbis_File ogg_file;
00113     vorbis_info* info;
00114     vorbis_comment *comment;
00115     string url;
00116   };
00117 }
00118 
00119 #endif
00120 #endif

Generated on Thu Aug 24 12:38:33 2006 for H3D API by  doxygen 1.4.5