MythTV master
tv_play.h
Go to the documentation of this file.
1// -*- Mode: c++ -*-
2
3#ifndef TVPLAY_H
4#define TVPLAY_H
5
6// C++
7#include <array>
8#include <cstdint>
9#include <utility>
10#include <vector>
11
12// Qt
13#include <QReadWriteLock>
14#include <QWaitCondition>
15#include <QStringList>
16#include <QDateTime>
17#include <QObject>
18#include <QString>
19#include <QMutex>
20#include <QMap>
21#include <QRecursiveMutex>
22#include <QVector>
23
24// MythTV
25#include "libmythbase/mythconfig.h"
30
31#include "channelgroup.h"
32#include "channelinfo.h"
34#include "inputinfo.h"
35#include "mythtvmenu.h"
36#include "osd.h"
37#include "playercontext.h"
38#include "tv.h"
39#include "tvbrowsehelper.h"
40#include "tvplaybackstate.h"
41#include "videoouttypes.h"
42
43class QEvent;
44class QKeyEvent;
45class QTimerEvent;
46class QDateTime;
47class QDomDocument;
48class QDomNode;
49class OSD;
50class RemoteEncoder;
51class MythPlayer;
52class MythPlayerUI;
53class MythMediaBuffer;
54class ProgramInfo;
55class TvPlayWindow;
56class TV;
57class MythMainWindow;
58struct osdInfo;
59
60using EMBEDRETURNVOID = void (*) (void *, bool);
61using EMBEDRETURNVOIDEPG = void (*) (uint, const QString &, const QDateTime, TV *, bool, bool, int);
62using EMBEDRETURNVOIDFINDER = void (*) (TV *, bool, bool);
63using EMBEDRETURNVOIDPROGLIST = void (*) (TV *, int, const QString &);
64using EMBEDRETURNVOIDSCHEDIT = void (*) (const ProgramInfo *, void *);
65
66// Locking order
67//
68// playerLock -> askAllowLock -> osdLock
69// -> progListLock -> osdLock
70// -> chanEditMapLock -> osdLock
71// -> lastProgramLock
72// -> recorderPlaybackInfoLock
73// -> timerIdLock
74// -> mainLoopCondLock
75// -> channelGroupLock
76//
77// When holding one of these locks, you may lock any lock of the locks to
78// the right of the current lock, but may not lock any lock to the left of
79// this lock (which will cause a deadlock). Nor should you lock any other
80// lock in the TV class without first adding it to the locking order list
81// above.
82//
83// Note: Taking a middle lock such as askAllowLock, without taking a
84// playerLock first does not violate these rules, but once you are
85// holding it, you cannot later lock playerLock.
86//
87// It goes without saying that any locks outside of this class should only
88// be taken one at a time, and should be taken last and released first of
89// all the locks required for any algorithm. (Unless you use tryLock and
90// release all locks if it can't gather them all at once, see the
91// "multi_lock()" function as an example; but this is not efficient nor
92// desirable and should be avoided when possible.)
93//
94
95enum scheduleEditTypes : uint8_t {
103
107enum NoRecorderMsg : uint8_t
108{
112};
113
114enum : uint8_t {
121};
122
124{
125 public:
126 AskProgramInfo() = default;
127 AskProgramInfo(QDateTime e, bool r, bool l, ProgramInfo *i) :
128 m_expiry(std::move(e)), m_hasRec(r), m_hasLater(l), m_info(i) {}
129
130 QDateTime m_expiry;
131 bool m_hasRec {false};
132 bool m_hasLater {false};
134 bool m_isConflicting {false};
135 ProgramInfo *m_info {nullptr};
136};
137
157{
158 friend class PlaybackBox;
159 friend class GuideGrid;
160 friend class TVBrowseHelper;
161
162 using string_pair = QPair<QString, QString>;
163
164 Q_OBJECT
165
166 public:
167 bool event(QEvent* Event) override;
168 bool eventFilter(QObject* Object, QEvent* Event) override;
169
170 static bool IsTVRunning();
171 static bool StartTV(ProgramInfo* TVRec, uint Flags, const ChannelInfoList& Selection = ChannelInfoList());
172 static bool IsPaused();
173 static void InitKeys();
174 static void SetFuncPtr(const char* Name, void* Pointer);
175 static int ConfiguredTunerCards();
176 static bool IsTunable(uint ChanId);
177 void ReloadKeys();
178 MThreadPool* GetPosThreadPool();
179
180 bool IsSameProgram(const ProgramInfo* ProgInfo) const;
181 bool MenuItemDisplay(const MythTVMenuItemContext& Context, MythOSDDialogData* Menu) override;
182
183 public slots:
184 void StopPlayback();
185 void HandleOSDClosed(int OSDType);
186
187 signals:
189
190 protected:
191 void timerEvent(QTimerEvent* Event) override;
192
193 protected slots:
194 void onApplicationStateChange(Qt::ApplicationState State);
195 void customEvent(QEvent* Event) override;
196 void VolumeChange(bool Up, int NewVolume = -1);
197
198 private slots:
199 void Embed(bool Embed, QRect Rect = {}, const QStringList& Data = {});
200
201 private:
202 static inline QStringList lastProgramStringList = {};
203 static inline EMBEDRETURNVOID RunPlaybackBoxPtr = nullptr;
204 static inline EMBEDRETURNVOID RunViewScheduledPtr = nullptr;
205 static inline EMBEDRETURNVOIDEPG RunProgramGuidePtr = nullptr;
206 static inline EMBEDRETURNVOIDFINDER RunProgramFinderPtr = nullptr;
207 static inline EMBEDRETURNVOIDSCHEDIT RunScheduleEditorPtr = nullptr;
208 static inline EMBEDRETURNVOIDPROGLIST RunProgramListPtr = nullptr;
209
210 explicit TV(MythMainWindow* MainWindow);
211 ~TV() override;
212 PlayerContext* GetPlayerContext();
213 bool CreatePlayer(TVState State, bool Muted = false);
214 bool StartPlaying(std::chrono::milliseconds MaxWait = -1ms);
215
216 // Private initialisation
217 static TV* AcquireRelease(int& RefCount, bool Acquire, bool Create = false);
218 bool Init();
219 void InitFromDB();
220 static QList<QKeyEvent*> ConvertScreenPressKeyMap(const QString& KeyList);
221
222 // Top level playback methods
223 bool LiveTV(bool ShowDialogs, const ChannelInfoList &Selection);
224 int Playback(const ProgramInfo &ProgInfo);
225 void PlaybackLoop();
226
227 // Private event handling
228 bool ProcessKeypressOrGesture(QEvent* Event);
229 bool TranslateKeyPressOrGesture(const QString& Context, QEvent* Event,
230 QStringList& Actions, bool IsLiveTV,
231 bool AllowJumps = true);
232 bool TranslateGesture(const QString &Context, MythGestureEvent *Event,
233 QStringList& Actions, bool IsLiveTV);
234 void ProcessNetworkControlCommand(const QString& Command);
235
236 bool HandleTrackAction(const QString& Action);
237 bool ActiveHandleAction(const QStringList& Actions, bool IsDVD, bool IsDVDStillFrame);
238 bool BrowseHandleAction(const QStringList& Actions);
239 void OSDDialogEvent(int Result, const QString& Text, QString Action);
240 bool ToggleHandleAction(const QStringList& Actions, bool IsDVD);
241 bool FFRewHandleAction(const QStringList& Actions);
242 bool ActivePostQHandleAction(const QStringList& Actions);
243 bool HandleJumpToProgramAction(const QStringList& Actions);
244 bool SeekHandleAction(const QStringList& Actions, bool IsDVD);
245 bool TimeStretchHandleAction(const QStringList& Actions);
246 bool DiscMenuHandleAction(const QStringList& Actions) const;
247
248 // Timers and timer events
249 int StartTimer(std::chrono::milliseconds Interval, int Line);
250 void KillTimer(int Id);
251
252 void SetSpeedChangeTimer(std::chrono::milliseconds When, int Line);
253 void HandleEndOfPlaybackTimerEvent();
254 void HandleEndOfRecordingExitPromptTimerEvent();
255 void HandleVideoExitDialogTimerEvent();
256 void HandlePseudoLiveTVTimerEvent();
257 void HandleSpeedChangeTimerEvent();
258 void ToggleSleepTimer();
259 void ToggleSleepTimer(const QString& Time);
260 bool HandleLCDTimerEvent();
261 void HandleLCDVolumeTimerEvent();
262 void HandleSaveLastPlayPosEvent();
263
264 // Commands used by frontend UI screens (PlaybackBox, GuideGrid etc)
265 void EditSchedule(int EditType = kScheduleProgramGuide,
266 const QString& arg = "");
267 bool IsTunablePriv(uint ChanId);
268 static QVector<uint> IsTunableOn(PlayerContext* Context, uint ChanId);
269 void ChangeChannel(const ChannelInfoList& Options);
270 void DoEditSchedule(int EditType = kScheduleProgramGuide,
271 const QString & EditArg = "");
272 QString GetRecordingGroup() const;
273 void UpdateChannelList(int GroupID);
274
275 // Lock handling
276 OSD* GetOSDL();
277 void ReturnOSDLock() const;
278 void GetPlayerWriteLock() const;
279 void GetPlayerReadLock() const;
280 void ReturnPlayerLock() const;
281
282 // Other toggles
283 void ToggleAutoExpire();
284 void QuickRecord();
285
286 // General TV state
287 static bool StateIsRecording(TVState State);
288 static bool StateIsPlaying(TVState State);
289 static bool StateIsLiveTV(TVState State);
290
291 TVState GetState() const;
292 void HandleStateChange();
293 void GetStatus();
294 void ForceNextStateNone();
295 void ScheduleStateChange();
296 void ScheduleInputChange();
297 void SetErrored();
298 void SetInPlayList(bool InPlayList) { m_inPlaylist = InPlayList; }
299 void setUnderNetworkControl(bool setting) { m_underNetworkControl = setting; }
300 void PrepToSwitchToRecordedProgram(const ProgramInfo& ProgInfo);
301 enum BookmarkAction : uint8_t {
304 kBookmarkAuto // set iff db_playback_exit_prompt==2
305 };
306 void PrepareToExitPlayer(int Line);
307 void SetExitPlayer(bool SetIt, bool WantsTo);
308
309 bool RequestNextRecorder(bool ShowDialogs, const ChannelInfoList &Selection = ChannelInfoList());
311
312 bool StartRecorder(std::chrono::milliseconds MaxWait = -1ms);
313 void StopStuff(bool StopRingBuffer, bool StopPlayer, bool StopRecorder);
314 bool StartPlayer(TVState desiredState);
315
317 bool IsSwitchingCards() const { return m_switchToRec; }
319 bool GetAllowRerecord() const { return m_allowRerecord; }
322 bool GetEndOfRecording() const { return m_endOfRecording; }
325 bool GetJumpToProgram() const { return m_jumpToProgram; }
326 bool IsDeleteAllowed();
327
328 // Channels
329 static void ToggleChannelFavorite();
330 void ToggleChannelFavorite(const QString &ChangroupName) const;
331 void ChangeChannel(ChannelChangeDirection Direction);
332 void ChangeChannel(uint Chanid, const QString& Channum);
333
334 void ShowPreviousChannel();
335 void PopPreviousChannel(bool ImmediateChange);
336
337 // key queue commands
338 void AddKeyToInputQueue(char Key);
339 void ClearInputQueues(bool Hideosd);
340 bool CommitQueuedInput();
341 bool ProcessSmartChannel(QString &InputStr);
342
343 // query key queues
344 bool HasQueuedInput() const { return !GetQueuedInput().isEmpty(); }
345 bool HasQueuedChannel() const { return m_queuedChanID || !GetQueuedChanNum().isEmpty(); }
346
347 // get queued up input
348 QString GetQueuedInput() const;
349 int GetQueuedInputAsInt(bool *OK = nullptr, int Base = 10) const;
350 QString GetQueuedChanNum() const;
351 uint GetQueuedChanID() const { return m_queuedChanID; }
352
353 // Source and input
354 void SwitchSource(uint Direction);
355 void SwitchInputs(uint ChanID = 0, QString ChanNum = "", uint InputID = 0);
356
357 // Pause/play
358 void PauseLiveTV();
359 void UnpauseLiveTV(bool Quietly = false);
360 void DoPlay();
361 float DoTogglePauseStart();
362 void DoTogglePauseFinish(float Time, bool ShowOSD);
363 void DoTogglePause(bool ShowOSD);
364 bool DoSetPauseState(bool Pause);
365 bool ContextIsPaused(const char* File, int Location);
366
367 // Program jumping stuff
368 void SetLastProgram(const ProgramInfo* ProgInfo);
369 ProgramInfo *GetLastProgram() const;
370
371 // Seek, skip, jump, speed
372 void DoSeek(float Time, const QString &Msg, bool TimeIsOffset, bool HonorCutlist);
373 void DoSeek(std::chrono::seconds TimeInSec, const QString &Msg, bool TimeIsOffset, bool HonorCutlist) {
374 DoSeek(TimeInSec.count(), Msg, TimeIsOffset, HonorCutlist); };
375 bool DoPlayerSeek(float Time);
376 bool DoPlayerSeekToFrame(uint64_t FrameNum);
377 enum ArbSeekWhence : uint8_t { ARBSEEK_SET = 0, ARBSEEK_REWIND, ARBSEEK_FORWARD, ARBSEEK_END };
378 void DoSeekAbsolute(long long Seconds, bool HonorCutlist);
379 void DoArbSeek(ArbSeekWhence Whence, bool HonorCutlist);
380 void DoJumpFFWD();
381 void DoJumpRWND();
382 void DoSeekFFWD();
383 void DoSeekRWND();
384 void NormalSpeed();
385 void ChangeSpeed(int Direction);
386 void ToggleTimeStretch();
387 void ChangeTimeStretch(int Dir, bool AllowEdit = true);
388 void DVDJumpBack();
389 void DVDJumpForward();
390 float StopFFRew();
391 void ChangeFFRew(int Direction);
392 void SetFFRew(int Index);
393
394 // Private audio methods
395 bool AudioSyncHandleAction(const QStringList& Actions);
396
397 // Chapters, titles and angles
398 int GetNumChapters();
399 void GetChapterTimes(QList<std::chrono::seconds> &Times);
400 int GetCurrentChapter();
401 int GetNumTitles();
402 int GetCurrentTitle();
403 std::chrono::seconds GetTitleDuration(int Title);
404 QString GetTitleName(int Title);
405 void DoSwitchTitle(int Title);
406 int GetNumAngles();
407 int GetCurrentAngle();
408 QString GetAngleName(int Angle);
409 void DoSwitchAngle(int Angle);
410 void DoJumpChapter(int Chapter);
411
412 // Commercial skipping
413 void DoSkipCommercials(int Direction);
414 void SetAutoCommercialSkip(CommSkipMode SkipMode = kCommSkipOff);
415
416 // Transcode
417 void DoQueueTranscode(const QString& Profile);
418
419 // Bookmarks
420 bool IsBookmarkAllowed();
421 void SetBookmark(bool Clear = false);
422
423 // OSD
424 void ClearOSD();
425 void ToggleOSD( bool IncludeStatusOSD);
426 void UpdateOSDProgInfo(const char *WhichInfo);
427 void UpdateOSDStatus(const QString& Title, const QString& Desc,
428 const QString& Value, int Type, const QString& Units,
429 int Position = 0, enum OSDTimeout Timeout = kOSDTimeout_Med);
430 void UpdateOSDStatus(osdInfo &Info, int Type, enum OSDTimeout Timeout);
431 void UpdateOSDSeekMessage(const QString &Msg, enum OSDTimeout Timeout);
432 void UpdateOSDInput();
433 void UpdateOSDSignal(const QStringList &List);
434 void UpdateOSDTimeoutMessage();
435 bool CalcPlayerSliderPosition(osdInfo &info, bool paddedFields = false) const;
436 void HideOSDWindow(const char *window);
437
438 // Captions/subtitles
439 bool SubtitleZoomHandleAction(const QStringList& Actions);
440 bool SubtitleDelayHandleAction(const QStringList &Actions);
441
442 // Video controls
443 void DoTogglePictureAttribute(PictureAdjustType Type);
444 bool PictureAttributeHandleAction(const QStringList &Actions);
445 PictureAttribute NextPictureAdjustType(PictureAdjustType Type, PictureAttribute Attr);
446 void OverrideScan(FrameScanType Scan);
447
448 // Sundry on screen
449 void ITVRestart(bool IsLive);
450
451 // Manual zoom mode
452 void SetManualZoom(bool ZoomON, const QString& Desc);
453 bool ManualZoomHandleAction(const QStringList &Actions);
454
455 // Channel editing support
456 void StartChannelEditMode();
457 bool HandleOSDChannelEdit(const QString& Action);
458 void ChannelEditAutoFill(InfoMap &Info);
459 void ChannelEditXDSFill(InfoMap &Info);
460
461 // General dialog handling
462 bool DialogIsVisible(const QString &Dialog);
463 void HandleOSDInfo(const QString& Action);
464 void ShowNoRecorderDialog(NoRecorderMsg MsgType = kNoRecorders);
465
466 // AskAllow dialog handling
467 void ShowOSDAskAllow();
468 void HandleOSDAskAllow(const QString& Action);
469 void AskAllowRecording(const QStringList &Msg, int Timeuntil, bool HasRec, bool HasLater);
470
471 // Program editing support
472 void ShowOSDCutpoint(const QString &Type);
473 bool HandleOSDCutpoint(const QString& Action);
474 void StartProgramEditMode();
475
476 // Already editing dialog
477 void ShowOSDAlreadyEditing();
478 void HandleOSDAlreadyEditing(const QString& Action, bool WasPaused);
479
480 // Sleep dialog handling
481 void ShowOSDSleep();
482 void HandleOSDSleep(const QString& Action);
483 void SleepDialogTimeout();
484
485 // Idle dialog handling
486 void ShowOSDIdle();
487 void HandleOSDIdle(const QString& Action);
488 void IdleDialogTimeout();
489
490 // Exit/delete dialog handling
491 void ShowOSDStopWatchingRecording();
492 void ShowOSDPromptDeleteRecording(const QString& Title, bool Force = false);
493 bool HandleOSDVideoExit(const QString& Action);
494
495 // Navigation Dialog
496 void StartOsdNavigation();
497
498 // Menu dialog
499 void ShowOSDMenu(bool isCompact = false);
500 void FillOSDMenuJumpRec(const QString &Category = "", int Level = 0, const QString &Selected = "");
501 static void FillOSDMenuCastButton(MythOSDDialogData & dialog,
502 const QVector<string_pair> & people);
503 void FillOSDMenuCast(void);
504 void FillOSDMenuActorShows(const QString & actor, int person_id,
505 const QString & category = "");
506 void PlaybackMenuShow(const MythTVMenu &Menu, const QDomNode &Node, const QDomNode &Selected);
507 bool MenuItemDisplayPlayback(const MythTVMenuItemContext& Context, MythOSDDialogData* Menu);
508 bool MenuItemDisplayCutlist(const MythTVMenuItemContext& Context, MythOSDDialogData* Menu);
509 void PlaybackMenuInit(const MythTVMenu& Menu);
510 void PlaybackMenuDeinit(const MythTVMenu& Menu);
511 static void MenuStrings();
512 void MenuLazyInit(void* Field);
513 const MythTVMenu& getMenuFromId(MenuTypeId id);
514
515 // LCD
516 void UpdateLCD();
517 void ShowLCDChannelInfo();
518 void ShowLCDDVDInfo();
519
520 // Active ChannelGroup
521 static inline int m_activeChannelGroupId {-1};
522 static void SetActiveChannelGroupId(int channelgroupid) {m_activeChannelGroupId = channelgroupid; }
523 static int GetActiveChannelGroupId() {return m_activeChannelGroupId; }
524
525 private:
526 void RetrieveCast(const ProgramInfo& ProgInfo);
527
528 MythMainWindow* m_mainWindow { nullptr };
529 MThreadPool* m_posThreadPool { nullptr };
530
531 // Configuration variables from database
532 QString m_dbChannelFormat {"<num> <sign>"};
533 std::chrono::milliseconds m_dbIdleTimeout {0ms};
534 int m_dbPlaybackExitPrompt {0};
535 uint m_dbAutoexpireDefault {0};
536 bool m_dbAutoSetWatched {false};
537 bool m_dbEndOfRecExitPrompt {false};
538 bool m_dbJumpPreferOsd {true};
539 bool m_dbUseGuiSizeForTv {false};
540 bool m_dbUseVideoModes {false};
541 bool m_dbRunJobsOnRemote {false};
542 bool m_dbContinueEmbedded {false};
543 bool m_dbBrowseAlways {false};
546 bool m_dbRememberLastChannelGroup {false};
548
549 bool m_smartForward {false};
550 float m_ffRewRepos {1.0F};
551 bool m_ffRewReverse {false};
552 std::vector<int> m_ffRewSpeeds;
553
554 uint m_vbimode {VBIMode::None};
555 uint m_switchToInputId {0};
556
559 mutable bool m_wantsToQuit {true};
560 bool m_stretchAdjustment {false};
561 bool m_audiosyncAdjustment {false};
562 bool m_subtitleZoomAdjustment {false};
563 bool m_subtitleDelayAdjustment {false};
564 bool m_zoomMode {false};
565 bool m_sigMonMode {false};
566 bool m_endOfRecording {false};
567 bool m_requestDelete {false};
568 bool m_allowRerecord {false};
569 bool m_doSmartForward {false};
570 bool m_queuedTranscode {false};
571 bool m_savePosOnExit {false};
572 bool m_clearPosOnExit {false};
576 PictureAttribute m_adjustingPictureAttribute {kPictureAttribute_None};
577
578 // Ask Allow state
579 QMap<QString,AskProgramInfo> m_askAllowPrograms;
580 QRecursiveMutex m_askAllowLock;
581
583 QMap<QString,ProgramList> m_progLists;
584
585 QVector<string_pair> m_actors;
586 QVector<string_pair> m_guestStars;
587 QVector<string_pair> m_guests;
588
589 mutable QRecursiveMutex m_chanEditMapLock;
591
592 class SleepTimerInfo;
593 static const std::vector<SleepTimerInfo> kSleepTimes;
594 uint m_sleepIndex {0};
595 std::chrono::milliseconds m_sleepTimerTimeout {0ms};
596 int m_sleepTimerId {0};
597 int m_sleepDialogTimerId {0};
599 int m_idleTimerId {0};
600 int m_idleDialogTimerId {0};
601
604
605 // CC/Teletex input state variables
607 bool m_ccInputMode {false};
608
609 // Arbitrary Seek input state variables
611 bool m_asInputMode {false};
612
613 // Channel changing state variables
617 mutable QString m_queuedChanNum;
619 uint m_queuedChanID {0};
621 uint m_initialChanID {0};
622
628 static const int kScreenPressRegionCount = 12;
630 QList<QKeyEvent*> m_screenPressKeyMapLiveTV;
631
632 // Channel changing timeout notification variables
633 QElapsedTimer m_lockTimer;
634 bool m_lockTimerOn {false};
636
637 // Program Info for currently playing video
638 // (or next video if InChangeState() is true)
639 mutable QMutex m_lastProgramLock;
640 ProgramInfo *m_lastProgram {nullptr};
641 bool m_inPlaylist {false};
642 bool m_underNetworkControl {false};
643
644 // Program Jumping
645 bool m_jumpToProgram {false};
646
647 // Video Player
648 PlayerContext m_playerContext { kPlayerInUseID };
649 // Ugly temporary workaround. We need a full MythPlayerInterface object but
650 // avoid endless casts
651 MythPlayerUI* m_player { nullptr };
653 mutable QReadWriteLock m_playerLock;
654
655 bool m_noHardwareDecoders {false};
656
657 // Remote Encoders
659 RemoteEncoder *m_switchToRec {nullptr};
660
661 // LCD Info
662 QString m_lcdTitle;
665
666 // Window info (GUI is optional, transcoding, preview img, etc)
667 TvPlayWindow *m_myWindow {nullptr};
673 bool m_weDisabledGUI {false};
674
675 // embedded and suspended status
676 bool m_ignoreKeyPresses {false};
677 bool m_savedPause {false};
678
679 // Channel group stuff
683 mutable QMutex m_channelGroupLock;
684 volatile int m_channelGroupId {-1};
686
687 // Network Control stuff
689
690 // Timers
691 volatile int m_lcdTimerId {0};
692 volatile int m_lcdVolumeTimerId {0};
693 volatile int m_networkControlTimerId {0};
694 volatile int m_ccInputTimerId {0};
695 volatile int m_asInputTimerId {0};
696 volatile int m_queueInputTimerId {0};
697 volatile int m_endOfPlaybackTimerId {0};
698 volatile int m_endOfRecPromptTimerId {0};
699 volatile int m_videoExitDialogTimerId {0};
700 volatile int m_pseudoChangeChanTimerId {0};
701 volatile int m_speedChangeTimerId {0};
702 volatile int m_errorRecoveryTimerId {0};
703 mutable volatile int m_exitPlayerTimerId {0};
704 volatile int m_saveLastPlayPosTimerId {0};
705 volatile int m_signalMonitorTimerId {0};
706
707 // Various tracks
708 // XXX This ignores kTrackTypeTextSubtitle which is greater than
709 // kTrackTypeCount, and it unnecessarily includes
710 // kTrackTypeUnknown.
711 std::array<QStringList,kTrackTypeCount> m_tvmTracks;
712 std::array<int,kTrackTypeCount> m_tvmCurtrack {};
713
714 // Audio
715 bool m_tvmAvsync {true};
716
717 // Video
718 bool m_tvmFillAutoDetect {false};
719
720 // Playback
721 int m_tvmSpeedX100 {100};
722 TVState m_tvmState {kState_None};
723 bool m_tvmIsRecording {false};
724 bool m_tvmIsRecorded {false};
725 bool m_tvmIsVideo {false};
727 bool m_tvmIsPaused {false};
728 int m_tvmFreeRecorderCount {-1};
729 bool m_tvmIsDvd {false};
730 bool m_tvmIsBd {false};
731 bool m_tvmJump {false};
732 bool m_tvmIsLiveTv {false};
733 bool m_tvmPreviousChan {false};
734
735 // Navigate
736 int m_tvmNumChapters {0};
737 int m_tvmCurrentChapter {0};
738 QList<std::chrono::seconds> m_tvmChapterTimes;
739 int m_tvmNumAngles {0};
740 int m_tvmCurrentAngle {0};
741 int m_tvmNumTitles {0};
742 int m_tvmCurrentTitle {0};
743 // Subtitles
744 bool m_tvmSubsForcedOn {true};
745 bool m_tvmSubsHaveSubs {false};
746
747 bool m_tvmIsOn {false};
748 bool m_tvmTranscoding {false};
749
751 // End of playback menu state caching
752
757
758 public:
759 static inline const int kInitFFRWSpeed = 0; // 1x, default to normal speed
760 static inline const uint kInputKeysMax = 6; // When to start discarding early keys
761 static inline const uint kNextSource = 1;
762 static inline const uint kPreviousSource = 2;
763
764 static inline const std::chrono::milliseconds kInputModeTimeout = 5s;
765 static inline const std::chrono::milliseconds kLCDTimeout = 1s;
766 static inline const std::chrono::milliseconds kBrowseTimeout = 30s;
767 static inline const std::chrono::milliseconds kKeyRepeatTimeout = 300ms;
768 static inline const std::chrono::milliseconds kPrevChanTimeout = 750ms;
769 static inline const std::chrono::milliseconds kSleepTimerDialogTimeout = 45s;
770 static inline const std::chrono::milliseconds kIdleTimerDialogTimeout = 45s;
771 static inline const std::chrono::milliseconds kVideoExitDialogTimeout = 2min;
772 static inline const std::chrono::milliseconds kEndOfPlaybackCheckFrequency = 250ms;
773 static inline const std::chrono::milliseconds kEmbedCheckFrequency = 250ms;
774 static inline const std::chrono::milliseconds kSpeedChangeCheckFrequency = 250ms;
775 static inline const std::chrono::milliseconds kErrorRecoveryCheckFrequency = 250ms;
776 static inline const std::chrono::milliseconds kEndOfRecPromptCheckFrequency = 250ms;
777 static inline const std::chrono::milliseconds kSaveLastPlayPosTimeout = 5s;
778#if CONFIG_VALGRIND
779 static inline const std::chrono::milliseconds kEndOfPlaybackFirstCheckTimer = 1min;
780#else
781 static inline const std::chrono::milliseconds kEndOfPlaybackFirstCheckTimer = 5s;
782#endif
783};
784
785class SavePositionThread : public QRunnable
786{
787 public:
788 SavePositionThread(ProgramInfo *progInfoPtr, uint64_t framesPos):
789 m_progInfo(progInfoPtr),
790 m_framesPlayed(framesPos)
791 {
792 }
793
794 void run() override; // QRunnable
795
796 private:
798 uint64_t m_framesPlayed {0};
799};
800
801#endif
#define Clear(a)
#define GetState(a, b)
std::vector< ChannelGroupItem > ChannelGroupList
Definition: channelgroup.h:31
std::vector< ChannelInfo > ChannelInfoList
Definition: channelinfo.h:130
An action (for this plugin) consists of a description, and a set of key sequences.
Definition: action.h:41
AskProgramInfo(QDateTime e, bool r, bool l, ProgramInfo *i)
Definition: tv_play.h:127
bool m_hasLater
Definition: tv_play.h:132
QDateTime m_expiry
Definition: tv_play.h:130
AskProgramInfo()=default
bool m_hasRec
Definition: tv_play.h:131
bool m_isInSameInputGroup
Definition: tv_play.h:133
ProgramInfo * m_info
Definition: tv_play.h:135
bool m_isConflicting
Definition: tv_play.h:134
Event details.
Definition: zmdefines.h:28
A custom event that represents a mouse gesture.
Definition: mythgesture.h:40
virtual bool MenuItemDisplay(const MythTVMenuItemContext &Context, MythOSDDialogData *Menu)=0
A QElapsedTimer based timer to replace use of QTime as a timer.
Definition: mythtimer.h:14
Definition: osd.h:94
Holds information on recordings and videos.
Definition: programinfo.h:74
General purpose reference counter.
uint64_t m_framesPlayed
Definition: tv_play.h:798
SavePositionThread(ProgramInfo *progInfoPtr, uint64_t framesPos)
Definition: tv_play.h:788
ProgramInfo * m_progInfo
Definition: tv_play.h:797
void run() override
Definition: tv_play.cpp:10575
bool m_dbUseChannelGroups
bool m_dbBrowseAllTuners
friend class TV
Tracks current playback state, as signalled by the player, and requests changes to the current state.
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:142
Control TV playback.
Definition: tv_play.h:157
QList< std::chrono::seconds > m_tvmChapterTimes
Definition: tv_play.h:738
QString m_lcdTitle
Definition: tv_play.h:662
MythTVMenu m_playbackCompactMenu
Definition: tv_play.h:754
InfoMap m_chanEditMap
Channel Editing initial map.
Definition: tv_play.h:590
QList< QKeyEvent * > m_screenPressKeyMapLiveTV
Definition: tv_play.h:630
bool GetJumpToProgram() const
This is set if the user asked MythTV to jump to the previous recording in the playlist.
Definition: tv_play.h:325
QList< QKeyEvent * > m_screenPressKeyMapPlayback
Definition: tv_play.h:629
uint GetQueuedChanID() const
Definition: tv_play.h:351
QMap< QString, ProgramList > m_progLists
Definition: tv_play.h:583
MythDeque< QString > m_networkControlCommands
Definition: tv_play.h:688
MythTVMenu m_cutlistCompactMenu
Definition: tv_play.h:756
bool HasQueuedChannel() const
Definition: tv_play.h:345
bool GetAllowRerecord() const
Returns true if the user told Mythtv to allow re-recording of the show.
Definition: tv_play.h:319
QVector< string_pair > m_guests
Definition: tv_play.h:587
ChannelGroupList m_dbChannelGroups
Definition: tv_play.h:547
void setUnderNetworkControl(bool setting)
Definition: tv_play.h:299
bool GetEndOfRecording() const
This is set to true if the player reaches the end of the recording without the user explicitly exitin...
Definition: tv_play.h:322
QVariant m_tvmJumprecBackHack
Definition: tv_play.h:750
QMap< QString, AskProgramInfo > m_askAllowPrograms
Definition: tv_play.h:579
QString m_queuedChanNum
Input key presses queued up so far to form a valid ChanNum.
Definition: tv_play.h:617
static void SetActiveChannelGroupId(int channelgroupid)
Definition: tv_play.h:522
BookmarkAction
Definition: tv_play.h:301
@ kBookmarkAlways
Definition: tv_play.h:302
@ kBookmarkNever
Definition: tv_play.h:303
static const std::vector< SleepTimerInfo > kSleepTimes
Definition: tv_play.h:593
MythTimer m_keyRepeatTimer
Queue of unprocessed key presses.
Definition: tv_play.h:603
static int GetActiveChannelGroupId()
Definition: tv_play.h:523
QRect m_playerBounds
Prior GUI window bounds, for DoEditSchedule() and player exit().
Definition: tv_play.h:669
QReadWriteLock m_playerLock
lock on player and playerActive changes
Definition: tv_play.h:653
QRecursiveMutex m_askAllowLock
Definition: tv_play.h:580
void PlaybackExiting(TV *Player)
QVector< string_pair > m_guestStars
Definition: tv_play.h:586
QString m_lcdCallsign
Definition: tv_play.h:664
std::array< QStringList, kTrackTypeCount > m_tvmTracks
Definition: tv_play.h:711
QPair< QString, QString > string_pair
Definition: tv_play.h:162
void DeleteRecorder()
QMutex m_channelGroupLock
Lock necessary when modifying channel group variables.
Definition: tv_play.h:683
std::vector< int > m_ffRewSpeeds
Definition: tv_play.h:552
QMutex m_lastProgramLock
Definition: tv_play.h:639
QMutex m_progListsLock
Definition: tv_play.h:582
MythTVMenu m_cutlistMenu
Definition: tv_play.h:755
QString m_lcdSubtitle
Definition: tv_play.h:663
QDateTime m_lastLockSeenTime
Definition: tv_play.h:635
QString m_queuedInput
Input key presses queued up so far...
Definition: tv_play.h:615
MythTVMenu m_playbackMenu
Definition: tv_play.h:753
bool IsSwitchingCards() const
Returns true if we are currently in the process of switching recorders.
Definition: tv_play.h:317
void DoSeek(std::chrono::seconds TimeInSec, const QString &Msg, bool TimeIsOffset, bool HonorCutlist)
Definition: tv_play.h:373
QElapsedTimer m_lockTimer
Definition: tv_play.h:633
QRect m_savedGuiBounds
Definition: tv_play.h:671
QRecursiveMutex m_chanEditMapLock
Lock for chanEditMap and ddMap.
Definition: tv_play.h:589
bool HasQueuedInput() const
Definition: tv_play.h:344
QVector< string_pair > m_actors
Definition: tv_play.h:585
void SetInPlayList(bool InPlayList)
Definition: tv_play.h:298
ChannelInfoList m_channelGroupChannelList
Definition: tv_play.h:685
ArbSeekWhence
Definition: tv_play.h:377
Simple screen shown while the video player is starting up.
Definition: tv_play_win.h:13
@ None
Definition: tv.h:12
unsigned int uint
Definition: compat.h:60
static constexpr int OK
Definition: dvbci.cpp:72
static void ReloadKeys(void)
static void InitKeys(void)
#define MTV_PUBLIC
Definition: mythtvexp.h:8
MenuTypeId
Definition: mythtvmenu.h:37
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
dictionary info
Definition: azlyrics.py:7
OSDTimeout
Definition: osd.h:56
@ kOSDTimeout_Med
Definition: osd.h:60
const QString kPlayerInUseID
CommSkipMode
Definition: tv.h:134
@ kCommSkipOff
Definition: tv.h:135
PictureAdjustType
Definition: tv.h:124
@ kAdjustingPicture_None
Definition: tv.h:125
ChannelChangeDirection
ChannelChangeDirection is an enumeration of possible channel changing directions.
Definition: tv.h:32
TVState
TVState is an enumeration of the states used by TV and TVRec.
Definition: tv.h:54
@ 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
void(*)(const ProgramInfo *, void *) EMBEDRETURNVOIDSCHEDIT
Definition: tv_play.h:64
void(*)(void *, bool) EMBEDRETURNVOID
Definition: tv_play.h:60
void(*)(uint, const QString &, const QDateTime, TV *, bool, bool, int) EMBEDRETURNVOIDEPG
Definition: tv_play.h:61
void(*)(TV *, int, const QString &) EMBEDRETURNVOIDPROGLIST
Definition: tv_play.h:63
@ kStartTVIgnoreLastPlayPos
Definition: tv_play.h:120
@ kStartTVIgnoreProgStart
Definition: tv_play.h:119
@ kStartTVNoFlags
Definition: tv_play.h:115
@ kStartTVByNetworkCommand
Definition: tv_play.h:117
@ kStartTVInPlayList
Definition: tv_play.h:116
@ kStartTVIgnoreBookmark
Definition: tv_play.h:118
scheduleEditTypes
Definition: tv_play.h:95
@ kViewSchedule
Definition: tv_play.h:99
@ kScheduleProgramList
Definition: tv_play.h:101
@ kScheduleProgramGuide
Definition: tv_play.h:96
@ kScheduleProgramFinder
Definition: tv_play.h:97
@ kPlaybackBox
Definition: tv_play.h:100
@ kScheduledRecording
Definition: tv_play.h:98
void(*)(TV *, bool, bool) EMBEDRETURNVOIDFINDER
Definition: tv_play.h:62
NoRecorderMsg
Type of message displayed in ShowNoRecorderDialog()
Definition: tv_play.h:108
@ kNoRecorders
No free recorders.
Definition: tv_play.h:109
@ kNoCurrRec
No current recordings.
Definition: tv_play.h:110
@ kNoTuners
No capture cards configured.
Definition: tv_play.h:111
FrameScanType
Definition: videoouttypes.h:95
PictureAttribute
@ kPictureAttribute_None
State
Definition: zmserver.h:69