1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/decoder-ogg.h Sat Dec 29 14:47:40 2007 +0100
1.3 @@ -0,0 +1,101 @@
1.4 +/*
1.5 + * MP3/MPlayer plugin to VDR (C++)
1.6 + *
1.7 + * (C) 2001-2005 Stefan Huelswitt <s.huelswitt@gmx.de>
1.8 + *
1.9 + * This code is free software; you can redistribute it and/or
1.10 + * modify it under the terms of the GNU General Public License
1.11 + * as published by the Free Software Foundation; either version 2
1.12 + * of the License, or (at your option) any later version.
1.13 + *
1.14 + * This code is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 + * GNU General Public License for more details.
1.18 + *
1.19 + * You should have received a copy of the GNU General Public License
1.20 + * along with this program; if not, write to the Free Software
1.21 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1.22 + * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
1.23 + */
1.24 +
1.25 +#ifndef ___DECODER_OGG_H
1.26 +#define ___DECODER_OGG_H
1.27 +
1.28 +#define DEC_OGG DEC_ID('O','G','G',' ')
1.29 +#define DEC_OGG_STR "OGG"
1.30 +
1.31 +#ifdef HAVE_VORBISFILE
1.32 +
1.33 +#include <mad.h>
1.34 +#include <vorbis/vorbisfile.h>
1.35 +
1.36 +#include "decoder.h"
1.37 +#include "decoder-core.h"
1.38 +
1.39 +// ----------------------------------------------------------------
1.40 +
1.41 +class cOggInfo;
1.42 +
1.43 +class cOggFile : public cFileInfo {
1.44 +friend class cOggInfo;
1.45 +private:
1.46 + bool opened, canSeek;
1.47 + OggVorbis_File vf;
1.48 + //
1.49 + void Error(const char *action, const int err);
1.50 +public:
1.51 + cOggFile(const char *Filename);
1.52 + ~cOggFile();
1.53 + bool Open(bool log=true);
1.54 + void Close(void);
1.55 + long long Seek(long long posMs=0, bool relativ=false);
1.56 + int Stream(short *buffer, int samples);
1.57 + bool CanSeek(void) { return canSeek; }
1.58 + long long IndexMs(void);
1.59 + };
1.60 +
1.61 +// ----------------------------------------------------------------
1.62 +
1.63 +class cOggInfo : public cSongInfo {
1.64 +private:
1.65 + cOggFile *file;
1.66 + bool keepOpen;
1.67 + //
1.68 + bool Abort(bool result);
1.69 +public:
1.70 + cOggInfo(cOggFile *File);
1.71 + bool DoScan(bool KeepOpen=false);
1.72 + };
1.73 +
1.74 +// ----------------------------------------------------------------
1.75 +
1.76 +class cOggDecoder : public cDecoder {
1.77 +private:
1.78 + cOggFile file;
1.79 + cOggInfo info;
1.80 + struct Decode ds;
1.81 + struct mad_pcm *pcm;
1.82 + unsigned long long index;
1.83 + //
1.84 + void Init(void);
1.85 + bool Clean(void);
1.86 + bool GetInfo(bool keepOpen);
1.87 + struct Decode *Done(eDecodeStatus status);
1.88 +public:
1.89 + cOggDecoder(const char *Filename);
1.90 + ~cOggDecoder();
1.91 + virtual bool Valid(void);
1.92 + virtual cFileInfo *FileInfo(void);
1.93 + virtual cSongInfo *SongInfo(bool get);
1.94 + virtual cPlayInfo *PlayInfo(void);
1.95 + virtual bool Start(void);
1.96 + virtual bool Stop(void);
1.97 + virtual bool Skip(int Seconds, float bsecs);
1.98 + virtual struct Decode *Decode(void);
1.99 + };
1.100 +
1.101 +// ----------------------------------------------------------------
1.102 +
1.103 +#endif //HAVE_VORBISFILE
1.104 +#endif //___DECODER_OGG_H