MythTV  master
playercontext.h
Go to the documentation of this file.
1 #ifndef PLAYER_CONTEXT_H
2 #define PLAYER_CONTEXT_H
3 
4 #include <vector>
5 #include <deque>
6 
7 // Qt headers
8 #include <QWidget>
9 #include <QString>
10 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
11 #include <QMutex>
12 #else
13 #include <QRecursiveMutex>
14 #endif
15 #include <QHash>
16 #include <QRect>
17 #include <QObject>
18 #include <QDateTime>
19 
20 // MythTV headers
21 #include "libmythbase/mythdate.h"
22 #include "libmythbase/mythdeque.h"
23 #include "libmythbase/mythtimer.h"
24 #include "libmythbase/mythtypes.h"
25 #include "libmythtv/mythtvexp.h"
26 #include "libmythtv/tv.h"
28 
29 class TV;
30 class RemoteEncoder;
31 class MythPlayer;
32 class MythMediaBuffer;
33 class ProgramInfo;
34 class LiveTVChain;
35 class QPainter;
36 class MythMainWindow;
37 
38 struct osdInfo
39 {
41  QHash<QString,int> values;
42 };
43 
45 {
49 };
50 
51 using StringDeque = std::deque<QString>;
52 
54 {
55  public:
56  explicit PlayerContext(QString inUseID = QString("Unknown"));
57  ~PlayerContext();
58 
59  // Actions
60  void TeardownPlayer(void);
61  void StopPlaying(void) const;
62  void UpdateTVChain(const QStringList &data = QStringList());
63  bool ReloadTVChain(void);
64  void PushPreviousChannel(void);
65  QString PopPreviousChannel(void);
66 
67  void ChangeState(TVState newState);
68  void ForceNextStateNone(void);
69  TVState DequeueNextState(void);
70 
71  bool HandlePlayerSpeedChangeFFRew(void);
72  bool HandlePlayerSpeedChangeEOF(void);
73 
74  // Locking
75  void LockState(void) const;
76  void UnlockState(void) const;
77 
78  void LockPlayingInfo(const char *file, int line) const;
79  void UnlockPlayingInfo(const char *file, int line) const;
80 
81  void LockDeletePlayer(const char *file, int line) const;
82  void UnlockDeletePlayer(const char *file, int line) const;
83 
84  // Sets
85  void SetInitialTVState(bool islivetv);
86  void SetPlayer(MythPlayer *newplayer);
87  void SetRecorder(RemoteEncoder *rec);
88  void SetTVChain(LiveTVChain *chain);
89  void SetRingBuffer(MythMediaBuffer *Buffer);
90  void SetPlayingInfo(const ProgramInfo *info);
91  void SetPlayGroup(const QString &group);
92  void SetPseudoLiveTV(const ProgramInfo *pi, PseudoState new_state);
93  void SetPlayerChangingBuffers(bool val) { m_playerUnsafe = val; }
94 
95  // Gets
96  QString GetPreviousChannel(void) const;
97  uint GetCardID(void) const { return m_lastCardid; }
98  QString GetFilters(const QString &baseFilters) const;
99  QString GetPlayMessage(void) const;
100  TVState GetState(void) const;
101  bool GetPlayingInfoMap(InfoMap &infoMap) const;
102 
103  // Boolean Gets
104  bool IsPlayerChangingBuffers(void) const { return m_playerUnsafe; }
105  bool HasPlayer(void) const;
106  bool IsPlayerErrored(void) const;
107  bool IsPlayerPlaying(void) const;
108  bool IsRecorderErrored(void) const;
109  bool InStateChange(void) const;
111  bool IsErrored(void) const { return m_errored; }
112  bool IsSameProgram(const ProgramInfo &p) const;
113 
114  public:
115  QString m_recUsage;
116  MythPlayer *m_player {nullptr};
117  volatile bool m_playerUnsafe {false};
118  RemoteEncoder *m_recorder {nullptr};
119  LiveTVChain *m_tvchain {nullptr};
120  MythMediaBuffer *m_buffer {nullptr};
121  ProgramInfo *m_playingInfo {nullptr};
122  std::chrono::seconds m_playingLen {0s};
123  QDateTime m_playingRecStart;
124  int m_lastCardid {-1};
125  int m_ffRewState {0};
128  int m_ffRewIndex {0};
130  int m_ffRewSpeed {0};
131  TVState m_playingState {kState_None};
132 
133  bool m_errored {false};
134 
135  // Previous channel functionality state variables
137 
138  // Recording to play next, after LiveTV
139  ProgramInfo *m_pseudoLiveTVRec {nullptr};
140  PseudoState m_pseudoLiveTVState {kPseudoNormalLiveTV};
141 
142  std::chrono::seconds m_fftime {0s};
143  std::chrono::seconds m_rewtime {0s};
144  std::chrono::minutes m_jumptime {0min};
151  float m_tsNormal {1.0F};
152  float m_tsAlt {1.5F};
153 
154 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
155  mutable QMutex m_playingInfoLock {QMutex::Recursive};
156  mutable QMutex m_deletePlayerLock {QMutex::Recursive};
157  mutable QMutex m_stateLock {QMutex::Recursive};
158 #else
159  mutable QRecursiveMutex m_playingInfoLock;
160  mutable QRecursiveMutex m_deletePlayerLock;
161  mutable QRecursiveMutex m_stateLock;
162 #endif
163 
164  // Signal info
165  mutable QStringList m_lastSignalMsg;
169 
170  // tv state related
172 
174  static constexpr std::chrono::milliseconds kSMExitTimeout { 2s };
175  static constexpr uint kMaxChannelHistory { 30 };
176 };
177 
178 #endif // PLAYER_CONTEXT_H
PlayerContext::IsErrored
bool IsErrored(void) const
This is set if the player encountered some irrecoverable error.
Definition: playercontext.h:111
PlayerContext::m_lastSignalUIInfo
InfoMap m_lastSignalUIInfo
Definition: playercontext.h:167
tv.h
osdInfo
Definition: playercontext.h:38
PlayerContext::IsPlayerChangingBuffers
bool IsPlayerChangingBuffers(void) const
Definition: playercontext.h:104
PlayerContext::m_stateLock
QRecursiveMutex m_stateLock
Definition: playercontext.h:161
PlayerContext::m_lastSignalMsg
QStringList m_lastSignalMsg
Definition: playercontext.h:165
MythTimer
A QElapsedTimer based timer to replace use of QTime as a timer.
Definition: mythtimer.h:13
mythtvexp.h
PlayerContext::SetPlayerChangingBuffers
void SetPlayerChangingBuffers(bool val)
Definition: playercontext.h:93
PlayerContext::m_playingRecStart
QDateTime m_playingRecStart
Definition: playercontext.h:123
MythMediaBuffer
Definition: mythmediabuffer.h:50
kPseudoChangeChannel
@ kPseudoChangeChannel
Definition: playercontext.h:47
MythPlayer
Definition: mythplayer.h:84
build_compdb.file
file
Definition: build_compdb.py:55
mythdeque.h
RemoteEncoder
Definition: remoteencoder.h:24
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
PlayerContext::GetCardID
uint GetCardID(void) const
Definition: playercontext.h:97
kState_None
@ kState_None
None State, this is the initial state in both TV and TVRec, it indicates that we are ready to change ...
Definition: tv.h:58
PlayerContext::m_prevChan
StringDeque m_prevChan
Previous channels.
Definition: playercontext.h:136
mythdate.h
videoouttypes.h
hardwareprofile.config.p
p
Definition: config.py:33
osdInfo::values
QHash< QString, int > values
Definition: playercontext.h:41
osdInfo::text
InfoMap text
Definition: playercontext.h:40
PlayerContext::m_deletePlayerLock
QRecursiveMutex m_deletePlayerLock
Definition: playercontext.h:160
mythtypes.h
PlayerContext::m_recUsage
QString m_recUsage
Definition: playercontext.h:115
StringDeque
std::deque< QString > StringDeque
Definition: playercontext.h:51
kPseudoRecording
@ kPseudoRecording
Definition: playercontext.h:48
GetState
#define GetState(a, b)
Definition: audiooutputopensles.cpp:47
uint
unsigned int uint
Definition: compat.h:79
PlayerContext::m_playingInfoLock
QRecursiveMutex m_playingInfoLock
Definition: playercontext.h:159
PlayerContext::m_lastSignalUIInfoTime
MythTimer m_lastSignalUIInfoTime
Definition: playercontext.h:168
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
Buffer
Definition: MythExternControl.h:36
ProgramInfo
Holds information on recordings and videos.
Definition: programinfo.h:67
TVState
TVState
TVState is an enumeration of the states used by TV and TVRec.
Definition: tv.h:50
PlayerContext::m_lastSignalMsgTime
MythTimer m_lastSignalMsgTime
Definition: playercontext.h:166
MythDeque< TVState >
PlayerContext
Definition: playercontext.h:53
mythtimer.h
PlayerContext::m_nextState
MythDeque< TVState > m_nextState
Definition: playercontext.h:171
MythMainWindow
Definition: mythmainwindow.h:28
kPseudoNormalLiveTV
@ kPseudoNormalLiveTV
Definition: playercontext.h:46
PseudoState
PseudoState
Definition: playercontext.h:44
LiveTVChain
Keeps track of recordings in a current LiveTV instance.
Definition: livetvchain.h:34
TV
Control TV playback.
Definition: tv_play.h:154