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