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