nathan@0
|
1 |
/*
|
nathan@0
|
2 |
* MP3/MPlayer plugin to VDR (C++)
|
nathan@0
|
3 |
*
|
nathan@33
|
4 |
* (C) 2001-2009 Stefan Huelswitt <s.huelswitt@gmx.de>
|
nathan@0
|
5 |
*
|
nathan@0
|
6 |
* This code is free software; you can redistribute it and/or
|
nathan@0
|
7 |
* modify it under the terms of the GNU General Public License
|
nathan@0
|
8 |
* as published by the Free Software Foundation; either version 2
|
nathan@0
|
9 |
* of the License, or (at your option) any later version.
|
nathan@0
|
10 |
*
|
nathan@0
|
11 |
* This code is distributed in the hope that it will be useful,
|
nathan@0
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
nathan@0
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
nathan@0
|
14 |
* GNU General Public License for more details.
|
nathan@0
|
15 |
*
|
nathan@0
|
16 |
* You should have received a copy of the GNU General Public License
|
nathan@0
|
17 |
* along with this program; if not, write to the Free Software
|
nathan@0
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
nathan@0
|
19 |
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
|
nathan@0
|
20 |
*/
|
nathan@0
|
21 |
|
nathan@0
|
22 |
#ifndef ___DECODER_OGG_H
|
nathan@0
|
23 |
#define ___DECODER_OGG_H
|
nathan@0
|
24 |
|
nathan@0
|
25 |
#define DEC_OGG DEC_ID('O','G','G',' ')
|
nathan@0
|
26 |
#define DEC_OGG_STR "OGG"
|
nathan@0
|
27 |
|
nathan@0
|
28 |
#ifdef HAVE_VORBISFILE
|
nathan@0
|
29 |
|
nathan@0
|
30 |
#include <mad.h>
|
nathan@0
|
31 |
#include <vorbis/vorbisfile.h>
|
nathan@0
|
32 |
|
nathan@0
|
33 |
#include "decoder.h"
|
nathan@0
|
34 |
#include "decoder-core.h"
|
nathan@0
|
35 |
|
nathan@0
|
36 |
// ----------------------------------------------------------------
|
nathan@0
|
37 |
|
nathan@0
|
38 |
class cOggInfo;
|
nathan@0
|
39 |
|
nathan@0
|
40 |
class cOggFile : public cFileInfo {
|
nathan@0
|
41 |
friend class cOggInfo;
|
nathan@0
|
42 |
private:
|
nathan@33
|
43 |
bool canSeek;
|
nathan@33
|
44 |
protected:
|
nathan@33
|
45 |
bool opened;
|
nathan@0
|
46 |
OggVorbis_File vf;
|
nathan@0
|
47 |
//
|
nathan@0
|
48 |
void Error(const char *action, const int err);
|
nathan@0
|
49 |
public:
|
nathan@0
|
50 |
cOggFile(const char *Filename);
|
nathan@35
|
51 |
virtual ~cOggFile();
|
nathan@33
|
52 |
virtual bool Open(bool log=true);
|
nathan@0
|
53 |
void Close(void);
|
nathan@0
|
54 |
long long Seek(long long posMs=0, bool relativ=false);
|
nathan@0
|
55 |
int Stream(short *buffer, int samples);
|
nathan@0
|
56 |
bool CanSeek(void) { return canSeek; }
|
nathan@0
|
57 |
long long IndexMs(void);
|
nathan@0
|
58 |
};
|
nathan@0
|
59 |
|
nathan@0
|
60 |
// ----------------------------------------------------------------
|
nathan@0
|
61 |
|
nathan@0
|
62 |
class cOggInfo : public cSongInfo {
|
nathan@0
|
63 |
private:
|
nathan@0
|
64 |
cOggFile *file;
|
nathan@0
|
65 |
bool keepOpen;
|
nathan@0
|
66 |
//
|
nathan@0
|
67 |
bool Abort(bool result);
|
nathan@0
|
68 |
public:
|
nathan@0
|
69 |
cOggInfo(cOggFile *File);
|
nathan@35
|
70 |
virtual ~cOggInfo() {}
|
nathan@33
|
71 |
virtual bool DoScan(bool KeepOpen=false);
|
nathan@33
|
72 |
virtual void InfoHook(void) {};
|
nathan@0
|
73 |
};
|
nathan@0
|
74 |
|
nathan@0
|
75 |
// ----------------------------------------------------------------
|
nathan@0
|
76 |
|
nathan@0
|
77 |
class cOggDecoder : public cDecoder {
|
nathan@0
|
78 |
private:
|
nathan@0
|
79 |
struct Decode ds;
|
nathan@0
|
80 |
struct mad_pcm *pcm;
|
nathan@0
|
81 |
unsigned long long index;
|
nathan@0
|
82 |
//
|
nathan@0
|
83 |
void Init(void);
|
nathan@0
|
84 |
bool Clean(void);
|
nathan@0
|
85 |
bool GetInfo(bool keepOpen);
|
nathan@0
|
86 |
struct Decode *Done(eDecodeStatus status);
|
nathan@33
|
87 |
protected:
|
nathan@33
|
88 |
cOggFile *file;
|
nathan@33
|
89 |
cOggInfo *info;
|
nathan@0
|
90 |
public:
|
nathan@33
|
91 |
cOggDecoder(const char *Filename, bool preinit=true);
|
nathan@0
|
92 |
~cOggDecoder();
|
nathan@0
|
93 |
virtual bool Valid(void);
|
nathan@0
|
94 |
virtual cFileInfo *FileInfo(void);
|
nathan@0
|
95 |
virtual cSongInfo *SongInfo(bool get);
|
nathan@0
|
96 |
virtual cPlayInfo *PlayInfo(void);
|
nathan@0
|
97 |
virtual bool Start(void);
|
nathan@0
|
98 |
virtual bool Stop(void);
|
nathan@0
|
99 |
virtual bool Skip(int Seconds, float bsecs);
|
nathan@0
|
100 |
virtual struct Decode *Decode(void);
|
nathan@0
|
101 |
};
|
nathan@0
|
102 |
|
nathan@0
|
103 |
// ----------------------------------------------------------------
|
nathan@0
|
104 |
|
nathan@0
|
105 |
#endif //HAVE_VORBISFILE
|
nathan@0
|
106 |
#endif //___DECODER_OGG_H
|