2 * MP3/MPlayer plugin to VDR (C++)
4 * (C) 2001-2009 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 // ----------------------------------------------------------------
40 bool infoDone, utf8clean;
43 void Set(cSongInfo *si, bool update=false);
44 void FakeTitle(const char *filename, const char *extention=0);
45 void InfoDone(void) { infoDone=true; }
49 bool HasInfo(void) { return infoDone; }
50 bool Utf8Clean(void) { return utf8clean; }
51 void ConvertToSys(void);
53 char *Title, *Artist, *Album;
54 int Year, Frames, Total;
55 int SampleFreq, Channels, Bitrate, MaxBitrate, ChMode;
62 // ----------------------------------------------------------------
70 void Set(cFileInfo *fi);
71 void InfoDone(void) { infoDone=true; }
74 cFileInfo(const char *Name);
76 bool FileInfo(bool log=true);
77 bool HasInfo(void) { return infoDone; }
80 char *Filename, *FsID;
81 unsigned long long Filesize;
86 // ----------------------------------------------------------------
93 // ----------------------------------------------------------------
98 cMutex lock, locklock;
105 void Lock(bool urgent=false);
109 cDecoder(const char *Filename);
112 virtual cFileInfo *FileInfo(void) { return 0; }
113 virtual cSongInfo *SongInfo(bool get) { return 0; }
114 virtual cPlayInfo *PlayInfo(void) { return 0; }
116 virtual bool Valid(void)=0;
117 virtual bool IsStream(void) { return false; }
118 virtual bool Start(void)=0;
119 virtual bool Stop(void)=0;
120 virtual bool Skip(int Seconds, float bsecs) { return false; }
121 virtual struct Decode *Decode(void)=0;
124 // ----------------------------------------------------------------
128 static cDecoder *FindDecoder(cFileObj *Obj);
129 static const char *ID2Str(int id);
130 static int Str2ID(const char *str);
133 // ----------------------------------------------------------------
135 #define CACHELINES 32
137 class cInfoCache : public cThread {
140 cList<cCacheData> lists[CACHELINES];
141 time_t lasttime, lastpurge;
142 bool modified, lastmod;
144 char *CacheFile(void);
145 void AddEntry(cCacheData *dat);
146 void DelEntry(cCacheData *dat);
147 cCacheData *FirstEntry(int hash);
148 void Modified(void) { modified=lastmod=true; }
150 virtual void Action(void);
154 void Save(bool force=false);
157 void Cache(cSongInfo *info, cFileInfo *file);
158 cCacheData *Search(cFileInfo *file);
161 extern cInfoCache InfoCache;
162 extern char *cachedir;
164 #endif //___DECODER_H