summaryrefslogtreecommitdiff
path: root/src/input_ogg.h
blob: 5bb09126295d10f3c590fb52b7cd2a18334c59d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef INPUT_OGG_H
#define INPUT_OGG_H


#ifdef ENABLE_TREMOR
#include <tremor/ivorbisfile.h>
#else
#include <vorbis/vorbisfile.h>
#endif
#include "audiere.h"
#include "basic_source.h"


namespace audiere {

  class OGGInputStream : public BasicSource {
  public:
    OGGInputStream();
    ~OGGInputStream();

    bool initialize(FilePtr file);

    void ADR_CALL getFormat(
      int& channel_count,
      int& sample_rate,
      SampleFormat& sample_format);
    int doRead(int frame_count, void* buffer);
    void ADR_CALL reset();

    bool ADR_CALL isSeekable();
    int  ADR_CALL getLength();
    void ADR_CALL setPosition(int position);
    int  ADR_CALL getPosition();

  private:
    static size_t FileRead(void* buffer, size_t size, size_t n, void* opaque);
    static int    FileSeek(void* opaque, ogg_int64_t offset, int whence);
    static int    FileClose(void* opaque);
    static long   FileTell(void* opaque);

  private:
    FilePtr m_file;

    OggVorbis_File m_vorbis_file;

    int m_channel_count;
    int m_sample_rate;
    SampleFormat m_sample_format;
  };

}

#endif