decoder-mp3.h
branchtrunk
changeset 0 474a1293c3c0
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/decoder-mp3.h	Sat Dec 29 14:47:40 2007 +0100
     1.3 @@ -0,0 +1,100 @@
     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_MP3_H
    1.26 +#define ___DECODER_MP3_H
    1.27 +
    1.28 +#define DEC_MP3     DEC_ID('M','P','3',' ')
    1.29 +#define DEC_MP3_STR "MP3"
    1.30 +
    1.31 +#include <mad.h>
    1.32 +#include <id3tag.h>
    1.33 +
    1.34 +#include "decoder.h"
    1.35 +#include "decoder-core.h"
    1.36 +
    1.37 +#if MAD_F_FRACBITS != 28
    1.38 +#warning libmad with MAD_F_FRACBITS != 28 not tested
    1.39 +#endif
    1.40 +
    1.41 +class cStream;
    1.42 +
    1.43 +// ----------------------------------------------------------------
    1.44 +
    1.45 +class cScanID3 : public cSongInfo {
    1.46 +private:
    1.47 +  bool keepOpen, *urgent;
    1.48 +  //
    1.49 +  bool Abort(bool result);
    1.50 +  struct id3_tag *GetID3(struct mad_stream *stream, id3_length_t tagsize) const;
    1.51 +  void ParseID3(const struct id3_tag *tag);
    1.52 +  void ParseStr(const struct id3_tag *tag, const char *id, char * &data);
    1.53 +  void ParsePic(const struct id3_tag *tag, const char *id, char * &name);
    1.54 +  int ParseXing(struct mad_bitptr *ptr, unsigned int bitlen) const;
    1.55 +protected:
    1.56 +  cStream *str;
    1.57 +public:
    1.58 +  cScanID3(cStream *Str, bool *Urgent);
    1.59 +  virtual ~cScanID3() {}
    1.60 +  virtual bool DoScan(bool KeepOpen=false);
    1.61 +  virtual void InfoHook(struct mad_header *header) {}
    1.62 +  };
    1.63 +
    1.64 +// ----------------------------------------------------------------
    1.65 +
    1.66 +class cMP3Decoder : public cDecoder {
    1.67 +private:
    1.68 +  struct Decode ds;
    1.69 +  //
    1.70 +  struct mad_stream *stream;
    1.71 +  struct mad_frame *frame;
    1.72 +  struct mad_synth *synth;
    1.73 +  mad_timer_t playtime, skiptime;
    1.74 +  //
    1.75 +  struct FrameInfo {
    1.76 +    unsigned long long Pos;
    1.77 +    mad_timer_t Time;
    1.78 +    } *fi;
    1.79 +  int framenum, framemax, errcount, mute;
    1.80 +  //
    1.81 +  void Init(void);
    1.82 +  void Clean(void);
    1.83 +  struct Decode *Done(eDecodeStatus status);
    1.84 +  eDecodeStatus DecodeError(bool hdr);
    1.85 +  void MakeSkipTime(mad_timer_t *skiptime, mad_timer_t playtime, int secs, float bsecs);
    1.86 +protected:
    1.87 +  cStream *str;
    1.88 +  cScanID3 *scan;
    1.89 +  bool isStream;
    1.90 +public:
    1.91 +  cMP3Decoder(const char *Filename, bool preinit=true);
    1.92 +  virtual ~cMP3Decoder();
    1.93 +  virtual bool Valid(void);
    1.94 +  virtual cFileInfo *FileInfo(void);
    1.95 +  virtual cSongInfo *SongInfo(bool get);
    1.96 +  virtual cPlayInfo *PlayInfo(void);
    1.97 +  virtual bool Start(void);
    1.98 +  virtual bool Stop(void);
    1.99 +  virtual bool Skip(int Seconds, float bsecs);
   1.100 +  virtual struct Decode *Decode(void);
   1.101 +  };
   1.102 +
   1.103 +#endif //___DECODER_MP3_H