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