nathan@0: /* nathan@0: * MP3/MPlayer plugin to VDR (C++) nathan@0: * nathan@0: * (C) 2001-2005 Stefan Huelswitt nathan@0: * nathan@0: * This code is free software; you can redistribute it and/or nathan@0: * modify it under the terms of the GNU General Public License nathan@0: * as published by the Free Software Foundation; either version 2 nathan@0: * of the License, or (at your option) any later version. nathan@0: * nathan@0: * This code is distributed in the hope that it will be useful, nathan@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of nathan@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the nathan@0: * GNU General Public License for more details. nathan@0: * nathan@0: * You should have received a copy of the GNU General Public License nathan@0: * along with this program; if not, write to the Free Software nathan@0: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. nathan@0: * Or, point your browser to http://www.gnu.org/copyleft/gpl.html nathan@0: */ nathan@0: nathan@0: #ifndef ___DECODER_MP3_H nathan@0: #define ___DECODER_MP3_H nathan@0: nathan@0: #define DEC_MP3 DEC_ID('M','P','3',' ') nathan@0: #define DEC_MP3_STR "MP3" nathan@0: nathan@0: #include nathan@0: #include nathan@0: nathan@0: #include "decoder.h" nathan@0: #include "decoder-core.h" nathan@0: nathan@0: #if MAD_F_FRACBITS != 28 nathan@0: #warning libmad with MAD_F_FRACBITS != 28 not tested nathan@0: #endif nathan@0: nathan@0: class cStream; nathan@0: nathan@0: // ---------------------------------------------------------------- nathan@0: nathan@0: class cScanID3 : public cSongInfo { nathan@0: private: nathan@0: bool keepOpen, *urgent; nathan@0: // nathan@0: bool Abort(bool result); nathan@0: struct id3_tag *GetID3(struct mad_stream *stream, id3_length_t tagsize) const; nathan@0: void ParseID3(const struct id3_tag *tag); nathan@0: void ParseStr(const struct id3_tag *tag, const char *id, char * &data); nathan@0: void ParsePic(const struct id3_tag *tag, const char *id, char * &name); nathan@0: int ParseXing(struct mad_bitptr *ptr, unsigned int bitlen) const; nathan@0: protected: nathan@0: cStream *str; nathan@0: public: nathan@0: cScanID3(cStream *Str, bool *Urgent); nathan@0: virtual ~cScanID3() {} nathan@0: virtual bool DoScan(bool KeepOpen=false); nathan@0: virtual void InfoHook(struct mad_header *header) {} nathan@0: }; nathan@0: nathan@0: // ---------------------------------------------------------------- nathan@0: nathan@0: class cMP3Decoder : public cDecoder { nathan@0: private: nathan@0: struct Decode ds; nathan@0: // nathan@0: struct mad_stream *stream; nathan@0: struct mad_frame *frame; nathan@0: struct mad_synth *synth; nathan@0: mad_timer_t playtime, skiptime; nathan@0: // nathan@0: struct FrameInfo { nathan@0: unsigned long long Pos; nathan@0: mad_timer_t Time; nathan@0: } *fi; nathan@0: int framenum, framemax, errcount, mute; nathan@0: // nathan@0: void Init(void); nathan@0: void Clean(void); nathan@0: struct Decode *Done(eDecodeStatus status); nathan@0: eDecodeStatus DecodeError(bool hdr); nathan@0: void MakeSkipTime(mad_timer_t *skiptime, mad_timer_t playtime, int secs, float bsecs); nathan@0: protected: nathan@0: cStream *str; nathan@0: cScanID3 *scan; nathan@0: bool isStream; nathan@0: public: nathan@0: cMP3Decoder(const char *Filename, bool preinit=true); nathan@0: virtual ~cMP3Decoder(); nathan@0: virtual bool Valid(void); nathan@0: virtual cFileInfo *FileInfo(void); nathan@0: virtual cSongInfo *SongInfo(bool get); nathan@0: virtual cPlayInfo *PlayInfo(void); nathan@0: virtual bool Start(void); nathan@0: virtual bool Stop(void); nathan@0: virtual bool Skip(int Seconds, float bsecs); nathan@0: virtual struct Decode *Decode(void); nathan@0: }; nathan@0: nathan@0: #endif //___DECODER_MP3_H