decoder-mp3.h
author nathan
Sat, 29 Dec 2007 14:58:47 +0100
branchtrunk
changeset 11 7f424cf3f798
parent 0 474a1293c3c0
permissions -rw-r--r--
use po2i18n for non-locale vdr
     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_MP3_H
    23 #define ___DECODER_MP3_H
    24 
    25 #define DEC_MP3     DEC_ID('M','P','3',' ')
    26 #define DEC_MP3_STR "MP3"
    27 
    28 #include <mad.h>
    29 #include <id3tag.h>
    30 
    31 #include "decoder.h"
    32 #include "decoder-core.h"
    33 
    34 #if MAD_F_FRACBITS != 28
    35 #warning libmad with MAD_F_FRACBITS != 28 not tested
    36 #endif
    37 
    38 class cStream;
    39 
    40 // ----------------------------------------------------------------
    41 
    42 class cScanID3 : public cSongInfo {
    43 private:
    44   bool keepOpen, *urgent;
    45   //
    46   bool Abort(bool result);
    47   struct id3_tag *GetID3(struct mad_stream *stream, id3_length_t tagsize) const;
    48   void ParseID3(const struct id3_tag *tag);
    49   void ParseStr(const struct id3_tag *tag, const char *id, char * &data);
    50   void ParsePic(const struct id3_tag *tag, const char *id, char * &name);
    51   int ParseXing(struct mad_bitptr *ptr, unsigned int bitlen) const;
    52 protected:
    53   cStream *str;
    54 public:
    55   cScanID3(cStream *Str, bool *Urgent);
    56   virtual ~cScanID3() {}
    57   virtual bool DoScan(bool KeepOpen=false);
    58   virtual void InfoHook(struct mad_header *header) {}
    59   };
    60 
    61 // ----------------------------------------------------------------
    62 
    63 class cMP3Decoder : public cDecoder {
    64 private:
    65   struct Decode ds;
    66   //
    67   struct mad_stream *stream;
    68   struct mad_frame *frame;
    69   struct mad_synth *synth;
    70   mad_timer_t playtime, skiptime;
    71   //
    72   struct FrameInfo {
    73     unsigned long long Pos;
    74     mad_timer_t Time;
    75     } *fi;
    76   int framenum, framemax, errcount, mute;
    77   //
    78   void Init(void);
    79   void Clean(void);
    80   struct Decode *Done(eDecodeStatus status);
    81   eDecodeStatus DecodeError(bool hdr);
    82   void MakeSkipTime(mad_timer_t *skiptime, mad_timer_t playtime, int secs, float bsecs);
    83 protected:
    84   cStream *str;
    85   cScanID3 *scan;
    86   bool isStream;
    87 public:
    88   cMP3Decoder(const char *Filename, bool preinit=true);
    89   virtual ~cMP3Decoder();
    90   virtual bool Valid(void);
    91   virtual cFileInfo *FileInfo(void);
    92   virtual cSongInfo *SongInfo(bool get);
    93   virtual cPlayInfo *PlayInfo(void);
    94   virtual bool Start(void);
    95   virtual bool Stop(void);
    96   virtual bool Skip(int Seconds, float bsecs);
    97   virtual struct Decode *Decode(void);
    98   };
    99 
   100 #endif //___DECODER_MP3_H