2 * MP3/MPlayer plugin to VDR (C++)
4 * (C) 2001-2007 Stefan Huelswitt <s.huelswitt@gmx.de>
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.
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.
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
25 #include <vdr/thread.h>
26 #include <vdr/tools.h>
28 // ----------------------------------------------------------------
33 extern int MakeHashBuff(const char *buff, int len);
34 #define MakeHash(str) MakeHashBuff((str),strlen(str))
36 // ----------------------------------------------------------------
43 void Set(cSongInfo *si);
44 void FakeTitle(const char *filename, const char *extention=0);
45 void InfoDone(void) { infoDone=true; }
49 bool HasInfo(void) { return infoDone; }
51 char *Title, *Artist, *Album;
52 int Year, Frames, Total;
53 int SampleFreq, Channels, Bitrate, MaxBitrate, ChMode;
60 // ----------------------------------------------------------------
68 void Set(cFileInfo *fi);
69 void InfoDone(void) { infoDone=true; }
72 cFileInfo(const char *Name);
74 bool FileInfo(bool log=true);
75 bool HasInfo(void) { return infoDone; }
78 char *Filename, *FsID;
79 unsigned long long Filesize;
84 // ----------------------------------------------------------------
91 // ----------------------------------------------------------------
96 cMutex lock, locklock;
103 void Lock(bool urgent=false);
107 cDecoder(const char *Filename);
110 virtual cFileInfo *FileInfo(void) { return 0; }
111 virtual cSongInfo *SongInfo(bool get) { return 0; }
112 virtual cPlayInfo *PlayInfo(void) { return 0; }
114 virtual bool Valid(void)=0;
115 virtual bool IsStream(void) { return false; }
116 virtual bool Start(void)=0;
117 virtual bool Stop(void)=0;
118 virtual bool Skip(int Seconds, float bsecs) { return false; }
119 virtual struct Decode *Decode(void)=0;
122 // ----------------------------------------------------------------
126 static cDecoder *FindDecoder(cFileObj *Obj);
127 static const char *ID2Str(int id);
128 static int Str2ID(const char *str);
131 // ----------------------------------------------------------------
133 #define CACHELINES 32
135 class cInfoCache : public cThread {
138 cList<cCacheData> lists[CACHELINES];
139 time_t lasttime, lastpurge;
140 bool modified, lastmod;
142 char *CacheFile(void);
143 void AddEntry(cCacheData *dat);
144 void DelEntry(cCacheData *dat);
145 cCacheData *FirstEntry(int hash);
146 void Modified(void) { modified=lastmod=true; }
148 virtual void Action(void);
152 void Save(bool force=false);
155 void Cache(cSongInfo *info, cFileInfo *file);
156 cCacheData *Search(cFileInfo *file);
159 extern cInfoCache InfoCache;
160 extern char *cachedir;
162 #endif //___DECODER_H