decoder-mp3.h
author nathan
Sun, 12 Dec 2010 11:31:54 +0100
branchtrunk
changeset 38 79b272a68eb4
parent 0 474a1293c3c0
permissions -rw-r--r--
fix compile without OGG library
nathan@0
     1
/*
nathan@0
     2
 * MP3/MPlayer plugin to VDR (C++)
nathan@0
     3
 *
nathan@0
     4
 * (C) 2001-2005 Stefan Huelswitt <s.huelswitt@gmx.de>
nathan@0
     5
 *
nathan@0
     6
 * This code is free software; you can redistribute it and/or
nathan@0
     7
 * modify it under the terms of the GNU General Public License
nathan@0
     8
 * as published by the Free Software Foundation; either version 2
nathan@0
     9
 * of the License, or (at your option) any later version.
nathan@0
    10
 *
nathan@0
    11
 * This code is distributed in the hope that it will be useful,
nathan@0
    12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nathan@0
    13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nathan@0
    14
 * GNU General Public License for more details.
nathan@0
    15
 *
nathan@0
    16
 * You should have received a copy of the GNU General Public License
nathan@0
    17
 * along with this program; if not, write to the Free Software
nathan@0
    18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
nathan@0
    19
 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
nathan@0
    20
 */
nathan@0
    21
nathan@0
    22
#ifndef ___DECODER_MP3_H
nathan@0
    23
#define ___DECODER_MP3_H
nathan@0
    24
nathan@0
    25
#define DEC_MP3     DEC_ID('M','P','3',' ')
nathan@0
    26
#define DEC_MP3_STR "MP3"
nathan@0
    27
nathan@0
    28
#include <mad.h>
nathan@0
    29
#include <id3tag.h>
nathan@0
    30
nathan@0
    31
#include "decoder.h"
nathan@0
    32
#include "decoder-core.h"
nathan@0
    33
nathan@0
    34
#if MAD_F_FRACBITS != 28
nathan@0
    35
#warning libmad with MAD_F_FRACBITS != 28 not tested
nathan@0
    36
#endif
nathan@0
    37
nathan@0
    38
class cStream;
nathan@0
    39
nathan@0
    40
// ----------------------------------------------------------------
nathan@0
    41
nathan@0
    42
class cScanID3 : public cSongInfo {
nathan@0
    43
private:
nathan@0
    44
  bool keepOpen, *urgent;
nathan@0
    45
  //
nathan@0
    46
  bool Abort(bool result);
nathan@0
    47
  struct id3_tag *GetID3(struct mad_stream *stream, id3_length_t tagsize) const;
nathan@0
    48
  void ParseID3(const struct id3_tag *tag);
nathan@0
    49
  void ParseStr(const struct id3_tag *tag, const char *id, char * &data);
nathan@0
    50
  void ParsePic(const struct id3_tag *tag, const char *id, char * &name);
nathan@0
    51
  int ParseXing(struct mad_bitptr *ptr, unsigned int bitlen) const;
nathan@0
    52
protected:
nathan@0
    53
  cStream *str;
nathan@0
    54
public:
nathan@0
    55
  cScanID3(cStream *Str, bool *Urgent);
nathan@0
    56
  virtual ~cScanID3() {}
nathan@0
    57
  virtual bool DoScan(bool KeepOpen=false);
nathan@0
    58
  virtual void InfoHook(struct mad_header *header) {}
nathan@0
    59
  };
nathan@0
    60
nathan@0
    61
// ----------------------------------------------------------------
nathan@0
    62
nathan@0
    63
class cMP3Decoder : public cDecoder {
nathan@0
    64
private:
nathan@0
    65
  struct Decode ds;
nathan@0
    66
  //
nathan@0
    67
  struct mad_stream *stream;
nathan@0
    68
  struct mad_frame *frame;
nathan@0
    69
  struct mad_synth *synth;
nathan@0
    70
  mad_timer_t playtime, skiptime;
nathan@0
    71
  //
nathan@0
    72
  struct FrameInfo {
nathan@0
    73
    unsigned long long Pos;
nathan@0
    74
    mad_timer_t Time;
nathan@0
    75
    } *fi;
nathan@0
    76
  int framenum, framemax, errcount, mute;
nathan@0
    77
  //
nathan@0
    78
  void Init(void);
nathan@0
    79
  void Clean(void);
nathan@0
    80
  struct Decode *Done(eDecodeStatus status);
nathan@0
    81
  eDecodeStatus DecodeError(bool hdr);
nathan@0
    82
  void MakeSkipTime(mad_timer_t *skiptime, mad_timer_t playtime, int secs, float bsecs);
nathan@0
    83
protected:
nathan@0
    84
  cStream *str;
nathan@0
    85
  cScanID3 *scan;
nathan@0
    86
  bool isStream;
nathan@0
    87
public:
nathan@0
    88
  cMP3Decoder(const char *Filename, bool preinit=true);
nathan@0
    89
  virtual ~cMP3Decoder();
nathan@0
    90
  virtual bool Valid(void);
nathan@0
    91
  virtual cFileInfo *FileInfo(void);
nathan@0
    92
  virtual cSongInfo *SongInfo(bool get);
nathan@0
    93
  virtual cPlayInfo *PlayInfo(void);
nathan@0
    94
  virtual bool Start(void);
nathan@0
    95
  virtual bool Stop(void);
nathan@0
    96
  virtual bool Skip(int Seconds, float bsecs);
nathan@0
    97
  virtual struct Decode *Decode(void);
nathan@0
    98
  };
nathan@0
    99
nathan@0
   100
#endif //___DECODER_MP3_H