1 /* 2 * Copyright (C) 2005-2018 Team Kodi 3 * This file is part of Kodi - https://kodi.tv 4 * 5 * SPDX-License-Identifier: GPL-2.0-or-later 6 * See LICENSES/README.md for more information. 7 */ 8 9 #pragma once 10 11 // FileShoutcast.h: interface for the CShoutcastFile class. 12 // 13 ////////////////////////////////////////////////////////////////////// 14 15 #include "CurlFile.h" 16 #include "IFile.h" 17 #include "threads/Thread.h" 18 19 #include <memory> 20 #include <queue> 21 #include <utility> 22 23 namespace MUSIC_INFO 24 { 25 class CMusicInfoTag; 26 } 27 28 namespace XFILE 29 { 30 31 class CFileCache; 32 33 class CShoutcastFile : public IFile, public CThread 34 { 35 public: 36 CShoutcastFile(); 37 ~CShoutcastFile() override; 38 int64_t GetPosition() override; 39 int64_t GetLength() override; 40 bool Open(const CURL& url) override; Exists(const CURL & url)41 bool Exists(const CURL& url) override { return true;}; Stat(const CURL & url,struct __stat64 * buffer)42 int Stat(const CURL& url, struct __stat64* buffer) override { errno = ENOENT; return -1; }; 43 ssize_t Read(void* lpBuf, size_t uiBufSize) override; 44 int64_t Seek(int64_t iFilePosition, int iWhence = SEEK_SET) override; 45 void Close() override; 46 int IoControl(EIoControl request, void* param) override; 47 48 void Process() override; 49 protected: 50 bool ExtractTagInfo(const char* buf); 51 void ReadTruncated(char* buf2, int size); 52 53 private: 54 std::string DecodeToUTF8(const std::string& str); 55 56 CCurlFile m_file; 57 std::string m_fileCharset; 58 int m_metaint; 59 int m_discarded; // data used for tags 60 int m_currint; 61 char* m_buffer; // buffer used for tags 62 std::string m_title; 63 64 CFileCache* m_cacheReader; 65 CEvent m_tagChange; 66 CCriticalSection m_tagSection; 67 using TagInfo = std::pair<int64_t, std::shared_ptr<MUSIC_INFO::CMusicInfoTag>>; 68 std::queue<TagInfo> m_tags; // tagpos, tag 69 std::shared_ptr<MUSIC_INFO::CMusicInfoTag> m_masterTag; 70 }; 71 } 72 73