Debian Codegraph @

src/lib/tsreader/TSReader.h

raw
1 #pragma once
2 /*
3 * Copyright (C) 2005-2012 Team Kodi
4 * https://kodi.tv
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 *************************************************************************
20 * Parts of this file originate from Team MediaPortal's
21 * TsReader DirectShow filter
22 * MediaPortal is a GPL'ed HTPC-Application
23 * Copyright (C) 2005-2012 Team MediaPortal
24 * http://www.team-mediaportal.com
25 *
26 * Changes compared to Team MediaPortal's version:
27 * - Code cleanup for PVR addon usage
28 * - Code refactoring for cross platform usage
29 *************************************************************************/
30
31 #include "FileReader.h"
32 #include "DeMultiplexer.h"
33 #include "Cards.h"
34 #ifdef LIVE555
35 #include "MepoRTSPClient.h"
36 #include "MemoryBuffer.h"
37 #endif
38
39 namespace MPTV
40 {
41 typedef enum _TsReaderState
42 {
43 State_Stopped = 0,
44 State_Paused = 1,
45 State_Running = 2
46 } TsReaderState;
47
48 class CTsReader
49 {
50 public:
51 CTsReader();
52 ~CTsReader(void);
53 long Open(const char* pszFileName);
54 long Read(unsigned char* pbData, size_t lDataLength, size_t *dwReadBytes);
55 void Close();
56 int64_t SetFilePointer(int64_t llDistanceToMove, unsigned long dwMoveMethod);
57 int64_t GetFileSize();
58 int64_t GetFilePointer();
59
60 time_t GetStartTime();
61 int64_t GetPtsBegin();
62 int64_t GetPtsEnd();
63
64 bool OnZap(const char* pszFileName, int64_t timeShiftBufferPos, long timeshiftBufferID);
65
66 /**
67 * \brief Pass a pointer to the MediaPortal card settings to this class
68 * \param the cardSettings
69 */
70 void SetCardSettings(CCards* cardSettings);
71
72 /**
73 * \brief Override the search directory for timeshift buffer files
74 * \param the new search directory
75 */
76 void SetDirectory(std::string& directory);
77 void SetCardId(int id);
78 bool IsTimeShifting();
79 bool IsSeeking();
80 long Pause(bool bPaused);
81
82 TsReaderState State() { return m_State; };
83 /**
84 * \brief Translate the given path using the m_basePath setting
85 * \param The original (local) timeshift buffer file path on the TV server side
86 */
87 std::string TranslatePath(const char* pszFileName);
88
89 private:
90
91 bool m_bTimeShifting;
92 bool m_bRecording;
93 bool m_bLiveTv;
94 bool m_bIsRTSP;
95 std::string m_fileName;
96 FileReader* m_fileReader;
97 FileReader* m_fileDuration;
98 CDeMultiplexer m_demultiplexer;
99 #ifdef LIVE555
100 CRTSPClient* m_rtspClient;
101 CMemoryBuffer* m_buffer;
102 #endif
103 CCards* m_cardSettings; ///< Pointer to the MediaPortal card settings. Will be used to determine the base path of the timeshift buffer
104 int m_cardId; ///< Card id for the current Card used for this timeshift buffer
105 std::string m_basePath; ///< The base path shared by all timeshift buffers (to be determined from the Card settings)
106 TsReaderState m_State; ///< The current state of the TsReader
107 unsigned long long m_lastPause; ///< Last time instance at which the playback was paused
108 unsigned long long m_startTickCount; ///< Start tick count of the time shift buffer
109 time_t m_startTime; ///< Start time of the time shift buffer in UTC
110 int m_WaitForSeekToEof;
111 };
112 }