xbmc
ShoutcastFile.h
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 //
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:
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
43  {
44  errno = ENOENT;
45  return -1;
46  }
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;
51 
52  void Process() override;
53 protected:
54  bool ExtractTagInfo(const char* buf);
55  void ReadTruncated(char* buf2, int size);
56 
57 private:
58  std::string DecodeToUTF8(const std::string& str);
59 
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;
67 
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;
74 };
75 }
76 
This is an Event class built from a ConditionVariable.
Definition: Event.h:35
Definition: Scraper.h:41
Definition: Thread.h:44
Definition: URL.h:20
Definition: ShoutcastFile.h:33
Definition: IFile.h:42
Definition: FileCache.h:23
Definition: CurlFile.h:24
int Stat(const CURL &url, struct __stat64 *buffer) override
Fills struct __stat64 with information about file specified by url.
Definition: ShoutcastFile.h:42
Definition: Application.h:79