Labyrinth
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
oggdatasource.hpp
1 //////////////////////////////
2 //
3 // File: lxs/audio/oggdatasource.hpp
4 // Author: Maciej Kaminski
5 // E-mail: maciej.a.kaminski@gmail.com
6 // Website: maciejkaminski.pl
7 //
8 // File creation date: Nov 2 2012
9 // This file is part of Project Labyrinth
10 // This file is going to be released under terms of GNU GPL in near future
11 //
12 //////////////////////////////
13 
14 #ifndef _AUDIO_VORBIS_UTILS
15 #define _AUDIO_VORBIS_UTILS
16 #include <string>
17 #include "libs/Tremor/ivorbisfile.h"
18 
19 namespace LxS
20 {
21  namespace Audio
22  {
23  //! class for reading and decoding OGG/Vorbis stream
25  {
26  char * data;
27  off_t offset;
28  off_t fisize;
29  OggVorbis_File vf;
30  static size_t read_func (void *ptr, size_t size, size_t nmemb, void *datasource);
31  static int seek_func (void *datasource, ogg_int64_t offset, int whence);
32  static int close_func (void *datasource);
33  static long tell_func (void *datasource);
34  public:
35  OggDataSource();
36  //! load file given name
37  OggDataSource(const std::string & pathname);
38  ~OggDataSource();
39  //! open file given name
40  void Open(const std::string & pathname);
41  //! close (don't do it before finished; file is never read as a whole
42  void Close();
43  //! mono or stereo
44  int GetNumChannels();
45  //! sampling freq
46  size_t GetFrequency();
47  //! get OggVorbis_File representation
48  OggVorbis_File * GetVF();
49  //! if offset points to end; i.e. whole file is decoded;
50  bool Finished();
51  //! attempt to decode given amount of bytes
52  size_t Decode(char * target_buffer, size_t buffer_size);
53  };
54  }
55 }
56 
57 #endif