Merge pull request #5039 from CEikermann/patch-1
[vuplus_xbmc] / xbmc / filesystem / ShoutcastFile.h
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 // FileShoutcast.h: interface for the CShoutcastFile class.
22 //
23 //////////////////////////////////////////////////////////////////////
24
25 #pragma once
26
27 #include "IFile.h"
28 #include "CurlFile.h"
29 #include "utils/StdString.h"
30 #include "music/tags/MusicInfoTag.h"
31 #include "threads/Thread.h"
32
33 namespace XFILE
34 {
35
36 class CFileCache;
37
38 class CShoutcastFile : public IFile, public CThread
39 {
40 public:
41   CShoutcastFile();
42   virtual ~CShoutcastFile();
43   virtual int64_t GetPosition();
44   virtual int64_t GetLength();
45   virtual bool Open(const CURL& url);
46   virtual bool Exists(const CURL& url) { return true;};
47   virtual int Stat(const CURL& url, struct __stat64* buffer) { errno = ENOENT; return -1; };
48   virtual unsigned int Read(void* lpBuf, int64_t uiBufSize);
49   virtual int64_t Seek(int64_t iFilePosition, int iWhence = SEEK_SET);
50   virtual void Close();
51   int IoControl(EIoControl request, void* param);
52
53   void Process();
54 protected:
55   bool ExtractTagInfo(const char* buf);
56   void ReadTruncated(char* buf2, int size);
57
58   CCurlFile m_file;
59   std::string m_fileCharset;
60   int m_metaint;
61   int m_discarded; // data used for tags
62   int m_currint;
63   char* m_buffer; // buffer used for tags
64   MUSIC_INFO::CMusicInfoTag m_tag;
65
66   CFileCache* m_cacheReader;
67   CEvent m_tagChange;
68   int64_t m_tagPos;
69 };
70 }
71