decoder-ogg.h
author nathan
Sun, 12 Dec 2010 11:31:54 +0100
branchtrunk
changeset 38 79b272a68eb4
parent 35 efc694fccc45
permissions -rw-r--r--
fix compile without OGG library
     1 /*
     2  * MP3/MPlayer plugin to VDR (C++)
     3  *
     4  * (C) 2001-2009 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 canSeek;
    44 protected:
    45   bool opened;
    46   OggVorbis_File vf;
    47   //
    48   void Error(const char *action, const int err);
    49 public:
    50   cOggFile(const char *Filename);
    51   virtual ~cOggFile();
    52   virtual bool Open(bool log=true);
    53   void Close(void);
    54   long long Seek(long long posMs=0, bool relativ=false);
    55   int Stream(short *buffer, int samples);
    56   bool CanSeek(void) { return canSeek; }
    57   long long IndexMs(void);
    58   };
    59 
    60 // ----------------------------------------------------------------
    61 
    62 class cOggInfo : public cSongInfo {
    63 private:
    64   cOggFile *file;
    65   bool keepOpen;
    66   //
    67   bool Abort(bool result);
    68 public:
    69   cOggInfo(cOggFile *File);
    70   virtual ~cOggInfo() {}
    71   virtual bool DoScan(bool KeepOpen=false);
    72   virtual void InfoHook(void) {};
    73   };
    74 
    75 // ----------------------------------------------------------------
    76 
    77 class cOggDecoder : public cDecoder {
    78 private:
    79   struct Decode ds;
    80   struct mad_pcm *pcm;
    81   unsigned long long index;
    82   //
    83   void Init(void);
    84   bool Clean(void);
    85   bool GetInfo(bool keepOpen);
    86   struct Decode *Done(eDecodeStatus status);
    87 protected:
    88   cOggFile *file;
    89   cOggInfo *info;
    90 public:
    91   cOggDecoder(const char *Filename, bool preinit=true);
    92   ~cOggDecoder();
    93   virtual bool Valid(void);
    94   virtual cFileInfo *FileInfo(void);
    95   virtual cSongInfo *SongInfo(bool get);
    96   virtual cPlayInfo *PlayInfo(void);
    97   virtual bool Start(void);
    98   virtual bool Stop(void);
    99   virtual bool Skip(int Seconds, float bsecs);
   100   virtual struct Decode *Decode(void);
   101   };
   102 
   103 // ----------------------------------------------------------------
   104 
   105 #endif //HAVE_VORBISFILE
   106 #endif //___DECODER_OGG_H