2 * MP3/MPlayer plugin to VDR (C++)
4 * (C) 2001-2005 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 <sys/types.h>
28 #include "decoder-mp3-stream.h"
31 // --- cNetScanID3 -------------------------------------------------------------
33 class cNetScanID3 : public cScanID3 {
39 cNetScanID3(cNetStream *Str, bool *Urgent);
40 virtual bool DoScan(bool KeepOpen=false);
41 virtual void InfoHook(struct mad_header *header);
44 cNetScanID3::cNetScanID3(cNetStream *Str, bool *Urgent)
50 bool cNetScanID3::DoScan(bool KeepOpen)
54 if(!Title) FakeTitle(nstr->Filename);
62 void cNetScanID3::InfoHook(struct mad_header *header)
64 if(nstr->IcyChanged()) IcyInfo();
65 SampleFreq=header->samplerate;
66 Channels=MAD_NCHANNELS(header);
69 int br=header->bitrate;
70 if(Bitrate<0) Bitrate=br;
71 else if(Bitrate!=br) {
73 if(Bitrate<br) MaxBitrate=br;
74 else { MaxBitrate=Bitrate; Bitrate=br; }
77 if(br>MaxBitrate) MaxBitrate=br;
78 if(br<Bitrate) Bitrate=br;
83 void cNetScanID3::IcyInfo(void)
85 const char *t=nstr->IcyTitle();
89 if(!a) a=nstr->IcyUrl();
95 if(t && (!Title || strcmp(t,Title))) {
99 if(a && (!Album || strcmp(a,Album))) {
105 // --- cMP3StreamDecoder -------------------------------------------------------
107 cMP3StreamDecoder::cMP3StreamDecoder(const char *Filename)
108 :cMP3Decoder(Filename,false)
110 nstr=new cNetStream(filename);
112 nscan=new cNetScanID3(nstr,&urgentLock);
117 bool cMP3StreamDecoder::Valid(void)
121 if(nstr->Valid()) res=true;