1 /*
2  *  Copyright (C) 2005-2021 Team Kodi (https://kodi.tv)
3  *
4  *  SPDX-License-Identifier: GPL-2.0-or-later
5  *  See LICENSE.md for more information.
6  */
7 
8 #pragma once
9 
10 #include <string>
11 
12 namespace kodi
13 {
14 namespace addon
15 {
16 class PVRRecording;
17 }
18 } // namespace kodi
19 
20 namespace tvheadend
21 {
22 
23 class HTSPConnection;
24 
25 /*
26  * HTSP VFS - recordings
27  */
28 class HTSPVFS
29 {
30 public:
31   HTSPVFS(HTSPConnection& conn);
32   ~HTSPVFS();
33 
34   void RebuildState();
35 
36   bool Open(const kodi::addon::PVRRecording& rec);
37   void Close();
38   int64_t Read(unsigned char* buf, unsigned int len, bool inprogress);
39   long long Seek(long long pos, int whence, bool inprogress);
40   long long Size();
41   void PauseStream(bool paused);
42   bool IsRealTimeStream();
43 
44 private:
45   bool SendFileOpen(bool force = false);
46   void SendFileClose();
47   int64_t SendFileRead(unsigned char* buf, unsigned int len);
48   long long SendFileSeek(int64_t pos, int whence, bool force = false);
49 
50   HTSPConnection& m_conn;
51   std::string m_path;
52   uint32_t m_fileId;
53   int64_t m_offset;
54   int64_t m_fileStart;
55   int64_t m_eofOffsetSecs;
56   int64_t m_pauseTime;
57   bool m_paused;
58   bool m_isRealTimeStream;
59 };
60 
61 } // namespace tvheadend
62