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