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