forked from MythTV/mythtv
/
tv_play.h
860 lines (750 loc) · 33.3 KB
/
tv_play.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
// -*- Mode: c++ -*-
#ifndef TVPLAY_H
#define TVPLAY_H
// C
#include <stdint.h>
// C++
#include <vector>
using namespace std;
// Qt
#include <QReadWriteLock>
#include <QWaitCondition>
#include <QStringList>
#include <QDateTime>
#include <QKeyEvent>
#include <QObject>
#include <QRegExp>
#include <QString>
#include <QEvent>
#include <QMutex>
#include <QHash>
#include <QTime>
#include <QMap>
#include <QSet>
// MythTV
#include "mythdeque.h"
#include "tv.h"
#include "mythmiscutil.h"
#include "programinfo.h"
#include "channelutil.h"
#include "videoouttypes.h"
#include "volumebase.h"
#include "inputinfo.h"
#include "channelgroup.h"
#include "osd.h"
class QDateTime;
class OSD;
class RemoteEncoder;
class MythPlayer;
class DetectLetterbox;
class RingBuffer;
class ProgramInfo;
class MythDialog;
class PlayerContext;
class TvPlayWindow;
class TV;
class TVBrowseHelper;
class DDLoader;
struct osdInfo;
typedef QMap<QString,InfoMap> DDValueMap;
typedef QMap<QString,DDValueMap> DDKeyMap;
typedef void (*EMBEDRETURNVOID) (void *, bool);
typedef void (*EMBEDRETURNVOIDEPG) (uint, const QString &, TV *, bool, bool, int);
typedef void (*EMBEDRETURNVOIDFINDER) (TV *, bool, bool);
typedef void (*EMBEDRETURNVOIDSCHEDIT) (const ProgramInfo *, void *);
// Locking order
//
// playerLock -> askAllowLock -> osdLock
// -> progListLock -> osdLock
// -> chanEditMapLock -> osdLock
// -> lastProgramLock
// -> is_tunable_cache_lock
// -> recorderPlaybackInfoLock
// -> timerIdLock
// -> mainLoopCondLock
// -> channelGroupLock
//
// When holding one of these locks, you may lock any lock of the locks to
// the right of the current lock, but may not lock any lock to the left of
// this lock (which will cause a deadlock). Nor should you lock any other
// lock in the TV class without first adding it to the locking order list
// above.
//
// Note: Taking a middle lock such as askAllowLock, without taking a
// playerLock first does not violate these rules, but once you are
// holding it, you cannot later lock playerLock.
//
// It goes without saying that any locks outside of this class should only
// be taken one at a time, and should be taken last and released first of
// all the locks required for any algorithm. (Unless you use tryLock and
// release all locks if it can't gather them all at once, see the
// "multi_lock()" function as an example; but this is not efficient nor
// desirable and should be avoided when possible.)
//
enum scheduleEditTypes {
kScheduleProgramGuide = 0,
kScheduleProgramFinder,
kScheduledRecording,
kViewSchedule,
kPlaybackBox
};
/**
* Type of message displayed in ShowNoRecorderDialog()
*/
typedef enum
{
kNoRecorders = 0, ///< No free recorders
kNoCurrRec = 1, ///< No current recordings
kNoTuners = 2, ///< No capture cards configured
} NoRecorderMsg;
enum {
kStartTVNoFlags = 0x00,
kStartTVInGuide = 0x01,
kStartTVInPlayList = 0x02,
kStartTVByNetworkCommand = 0x04,
kStartTVIgnoreBookmark = 0x08,
};
class AskProgramInfo
{
public:
AskProgramInfo() :
has_rec(false), has_later(false),
is_in_same_input_group(false), is_conflicting(false),
info(NULL) {}
AskProgramInfo(const QDateTime &e, bool r, bool l, ProgramInfo *i) :
expiry(e), has_rec(r), has_later(l),
is_in_same_input_group(false), is_conflicting(false),
info(i) {}
QDateTime expiry;
bool has_rec;
bool has_later;
bool is_in_same_input_group;
bool is_conflicting;
ProgramInfo *info;
};
class MTV_PUBLIC TV : public QObject
{
friend class PlaybackBox;
friend class GuideGrid;
friend class ProgFinder;
friend class ViewScheduled;
friend class ScheduleEditor;
friend class TvPlayWindow;
friend class TVBrowseHelper;
friend class DDLoader;
Q_OBJECT
public:
// Check whether we already have a TV object
static bool IsTVRunning(void);
// Start media playback
static bool StartTV(ProgramInfo *tvrec = NULL,
uint flags = kStartTVNoFlags);
// Public event handling
bool event(QEvent *e);
bool eventFilter(QObject *o, QEvent *e);
// Public PlaybackBox methods
/// true iff program is the same as the one in the selected player
bool IsSameProgram(int player_idx, const ProgramInfo *p) const;
// Public recorder methods
void FinishRecording(int player_idx); ///< Finishes player's recording
// static functions
static void InitKeys(void);
static void ReloadKeys(void);
static void SetFuncPtr(const char *, void *);
static int ConfiguredTunerCards(void);
/// \brief Helper class for Sleep Timer code.
class SleepTimerInfo
{
public:
SleepTimerInfo(QString str, unsigned long secs)
: dispString(str), seconds(secs) { ; }
QString dispString;
unsigned long seconds;
};
public slots:
void HandleOSDClosed(int osdType);
void timerEvent(QTimerEvent*);
protected:
// Protected event handling
void customEvent(QEvent *e);
static QStringList lastProgramStringList;
static EMBEDRETURNVOID RunPlaybackBoxPtr;
static EMBEDRETURNVOID RunViewScheduledPtr;
static EMBEDRETURNVOIDEPG RunProgramGuidePtr;
static EMBEDRETURNVOIDFINDER RunProgramFinderPtr;
static EMBEDRETURNVOIDSCHEDIT RunScheduleEditorPtr;
private:
TV();
~TV();
static TV* GetTV(void);
static void ReleaseTV(TV* tv);
static QMutex *gTVLock;
static TV *gTV;
// Private initialisation
bool Init(bool createWindow = true);
void InitFromDB(void);
// Top level playback methods
bool LiveTV(bool showDialogs = true);
bool StartLiveTVInGuide(void) { return db_start_in_guide; }
int Playback(const ProgramInfo &rcinfo);
void PlaybackLoop(void);
// Private event handling
bool ProcessKeypress(PlayerContext*, QKeyEvent *e);
void ProcessNetworkControlCommand(PlayerContext *, const QString &command);
bool HandleTrackAction(PlayerContext*, const QString &action);
bool ActiveHandleAction(PlayerContext*,
const QStringList &actions,
bool isDVD, bool isDVDStillFrame);
bool BrowseHandleAction(PlayerContext*, const QStringList &actions);
void OSDDialogEvent(int result, QString text, QString action);
bool PxPHandleAction(PlayerContext*,const QStringList &actions);
bool ToggleHandleAction(PlayerContext*,
const QStringList &actions, bool isDVD);
bool FFRewHandleAction(PlayerContext*, const QStringList &actions);
bool ActivePostQHandleAction(PlayerContext*, const QStringList &actions);
bool HandleJumpToProgramAction(PlayerContext *ctx,
const QStringList &actions);
bool SeekHandleAction(PlayerContext *actx, const QStringList &actions,
const bool isDVD);
bool TimeStretchHandleAction(PlayerContext*,
const QStringList &actions);
bool DiscMenuHandleAction(PlayerContext*, const QStringList &actions);
bool Handle3D(PlayerContext *ctx, const QString &action);
// Timers and timer events
int StartTimer(int interval, int line);
void KillTimer(int id);
void SetSpeedChangeTimer(uint when, int line);
void HandleEndOfPlaybackTimerEvent(void);
void HandleIsNearEndWhenEmbeddingTimerEvent(void);
void HandleEndOfRecordingExitPromptTimerEvent(void);
void HandleVideoExitDialogTimerEvent(void);
void HandlePseudoLiveTVTimerEvent(void);
void HandleSpeedChangeTimerEvent(void);
void ToggleSleepTimer(const PlayerContext*);
void ToggleSleepTimer(const PlayerContext*, const QString &time);
bool HandlePxPTimerEvent(void);
bool HandleLCDTimerEvent(void);
void HandleLCDVolumeTimerEvent(void);
// Commands used by frontend UI screens (PlaybackBox, GuideGrid etc)
void EditSchedule(const PlayerContext*,
int editType = kScheduleProgramGuide);
bool StartEmbedding(const QRect&);
void StopEmbedding(void);
bool IsTunable(const PlayerContext*, uint chanid, bool use_cache = false);
QSet<uint> IsTunableOn(const PlayerContext*, uint chanid,
bool use_cache, bool early_exit);
void ClearTunableCache(void);
void ChangeChannel(const PlayerContext*, const DBChanInfoList &options);
void DrawUnusedRects(void);
void DoEditSchedule(int editType = kScheduleProgramGuide);
QString GetRecordingGroup(int player_idx) const;
void ChangeVolume(PlayerContext*, bool up, int newvolume = -1);
void ToggleMute(PlayerContext*, const bool muteIndividualChannels = false);
void UpdateChannelList(int groupID);
// Lock handling
OSD *GetOSDL(const char *, int);
OSD *GetOSDL(const PlayerContext*,const char *, int);
void ReturnOSDLock(const PlayerContext*,OSD*&);
PlayerContext *GetPlayerWriteLock(
int which, const char *file, int location);
PlayerContext *GetPlayerReadLock(
int which, const char *file, int location);
const PlayerContext *GetPlayerReadLock(
int which, const char *file, int location) const;
PlayerContext *GetPlayerHaveLock(
PlayerContext*,
int which, const char *file, int location);
const PlayerContext *GetPlayerHaveLock(
const PlayerContext*,
int which, const char *file, int location) const;
void ReturnPlayerLock(PlayerContext*&);
void ReturnPlayerLock(const PlayerContext*&) const;
// Other toggles
void ToggleAutoExpire(PlayerContext*);
void ToggleRecord(PlayerContext*);
// General TV state
static bool StateIsRecording(TVState state);
static bool StateIsPlaying(TVState state);
static bool StateIsLiveTV(TVState state);
TVState GetState(int player_idx) const;
TVState GetState(const PlayerContext*) const;
void HandleStateChange(PlayerContext *mctx, PlayerContext *ctx);
void GetStatus(void);
void ForceNextStateNone(PlayerContext*);
void ScheduleStateChange(PlayerContext*);
void SetErrored(PlayerContext*);
void setInPlayList(bool setting) { inPlaylist = setting; }
void setUnderNetworkControl(bool setting) { underNetworkControl = setting; }
void PrepToSwitchToRecordedProgram(PlayerContext*,
const ProgramInfo &);
enum BookmarkAction {
kBookmarkAlways,
kBookmarkNever,
kBookmarkAuto // set iff db_playback_exit_prompt==2
};
void PrepareToExitPlayer(PlayerContext*, int line,
BookmarkAction bookmark = kBookmarkAuto);
void SetExitPlayer(bool set_it, bool wants_to);
bool RequestNextRecorder(PlayerContext *, bool);
void DeleteRecorder();
bool StartRecorder(PlayerContext *ctx, int maxWait=-1);
void StopStuff(PlayerContext *mctx, PlayerContext *ctx,
bool stopRingbuffers, bool stopPlayers, bool stopRecorders);
void TeardownPlayer(PlayerContext *mctx, PlayerContext *ctx);
bool StartPlayer(PlayerContext *mctx, PlayerContext *ctx,
TVState desiredState);
vector<long long> TeardownAllPlayers(PlayerContext*);
void RestartAllPlayers(PlayerContext *lctx,
const vector<long long> &pos,
MuteState mctx_mute);
void RestartMainPlayer(PlayerContext *mctx);
/// Returns true if we are currently in the process of switching recorders.
bool IsSwitchingCards(void) const { return switchToRec; }
/// Returns true if the user told Mythtv to allow re-recording of the show
bool getAllowRerecord(void) const { return allowRerecord; }
/// This is set to true if the player reaches the end of the
/// recording without the user explicitly exiting the player.
bool getEndOfRecording(void) const { return endOfRecording; }
/// This is set if the user asked MythTV to jump to the previous
/// recording in the playlist.
bool getJumpToProgram(void) const { return jumpToProgram; }
bool IsDeleteAllowed(const PlayerContext*) const;
// Channels
void ToggleChannelFavorite(PlayerContext *ctx);
void ToggleChannelFavorite(PlayerContext*, QString);
void ChangeChannel(PlayerContext*, int direction);
void ChangeChannel(PlayerContext*, uint chanid, const QString &channum);
void ShowPreviousChannel(PlayerContext*);
void PopPreviousChannel(PlayerContext*, bool immediate_change);
// key queue commands
void AddKeyToInputQueue(PlayerContext*, char key);
void ClearInputQueues(const PlayerContext*, bool hideosd);
bool CommitQueuedInput(PlayerContext*);
bool ProcessSmartChannel(const PlayerContext*, QString&);
// query key queues
bool HasQueuedInput(void) const
{ return !GetQueuedInput().isEmpty(); }
bool HasQueuedChannel(void) const
{ return queuedChanID || !GetQueuedChanNum().isEmpty(); }
// get queued up input
QString GetQueuedInput(void) const;
int GetQueuedInputAsInt(bool *ok = NULL, int base = 10) const;
QString GetQueuedChanNum(void) const;
uint GetQueuedChanID(void) const { return queuedChanID; }
// Source and input
void SwitchSource(PlayerContext*, uint source_direction);
void SwitchInputs(PlayerContext*, uint inputid);
void ToggleInputs(PlayerContext*, uint inputid = 0);
void SwitchCards(PlayerContext*,
uint chanid = 0, QString channum = "", uint inputid = 0);
// Pause/play
void PauseLiveTV(PlayerContext*);
void UnpauseLiveTV(PlayerContext*, bool bQuietly = false);
void DoPlay(PlayerContext*);
float DoTogglePauseStart(PlayerContext*);
void DoTogglePauseFinish(PlayerContext*, float time, bool showOSD);
void DoTogglePause(PlayerContext*, bool showOSD);
vector<bool> DoSetPauseState(PlayerContext *lctx, const vector<bool>&);
bool ContextIsPaused(PlayerContext *ctx, const char *file, int location);
// Program jumping stuff
void SetLastProgram(const ProgramInfo *rcinfo);
ProgramInfo *GetLastProgram(void) const;
// Seek, skip, jump, speed
void DoSeek(PlayerContext*, float time, const QString &mesg,
bool timeIsOffset, bool honorCutlist);
bool DoPlayerSeek(PlayerContext*, float time);
enum ArbSeekWhence {
ARBSEEK_SET = 0,
ARBSEEK_REWIND,
ARBSEEK_FORWARD,
ARBSEEK_END
};
void DoSeekAbsolute(PlayerContext *ctx, long long seconds, bool honorCutlist);
void DoArbSeek(PlayerContext*, ArbSeekWhence whence, bool honorCutlist);
void DoJumpFFWD(PlayerContext *ctx);
void DoJumpRWND(PlayerContext *ctx);
void NormalSpeed(PlayerContext*);
void ChangeSpeed(PlayerContext*, int direction);
void ToggleTimeStretch(PlayerContext*);
void ChangeTimeStretch(PlayerContext*, int dir, bool allowEdit = true);
void DVDJumpBack(PlayerContext*);
void DVDJumpForward(PlayerContext*);
float StopFFRew(PlayerContext*);
void ChangeFFRew(PlayerContext*, int direction);
void SetFFRew(PlayerContext*, int index);
// Private audio methods
void EnableUpmix(PlayerContext*, bool enable, bool toggle = false);
void ChangeAudioSync(PlayerContext*, int dir, int newsync = -9999);
bool AudioSyncHandleAction(PlayerContext*, const QStringList &actions);
void PauseAudioUntilBuffered(PlayerContext *ctx);
// Chapters, titles and angles
int GetNumChapters(const PlayerContext*) const;
void GetChapterTimes(const PlayerContext*, QList<long long> ×) const;
int GetCurrentChapter(const PlayerContext*) const;
int GetNumTitles(const PlayerContext *ctx) const;
int GetCurrentTitle(const PlayerContext *ctx) const;
int GetTitleDuration(const PlayerContext *ctx, int title) const;
QString GetTitleName(const PlayerContext *ctx, int title) const;
void DoSwitchTitle(PlayerContext*, int title);
int GetNumAngles(const PlayerContext *ctx) const;
int GetCurrentAngle(const PlayerContext *ctx) const;
QString GetAngleName(const PlayerContext *ctx, int angle) const;
void DoSwitchAngle(PlayerContext*, int angle);
void DoJumpChapter(PlayerContext*, int chapter);
// Commercial skipping
void DoSkipCommercials(PlayerContext*, int direction);
void SetAutoCommercialSkip(const PlayerContext*,
CommSkipMode skipMode = kCommSkipOff);
// Transcode
void DoQueueTranscode(PlayerContext*, QString profile);
// Bookmarks
bool IsBookmarkAllowed(const PlayerContext*) const;
void SetBookmark(PlayerContext* ctx, bool clear = false);
// OSD
bool ClearOSD(const PlayerContext*);
void ToggleOSD(PlayerContext*, bool includeStatusOSD);
void ToggleOSDDebug(PlayerContext*);
void UpdateOSDDebug(const PlayerContext *ctx);
void UpdateOSDProgInfo(const PlayerContext*, const char *whichInfo);
void UpdateOSDStatus(const PlayerContext *ctx, QString title, QString desc,
QString value, int type, QString units,
int position = 0, int prev = 0, int next = 0,
enum OSDTimeout timeout = kOSDTimeout_Med);
void UpdateOSDStatus(const PlayerContext *ctx, osdInfo &info,
int type, enum OSDTimeout timeout);
void UpdateOSDSeekMessage(const PlayerContext*,
const QString &mesg, enum OSDTimeout timeout);
void UpdateOSDInput(const PlayerContext*,
QString inputname = QString::null);
void UpdateOSDSignal(const PlayerContext*, const QStringList &strlist);
void UpdateOSDTimeoutMessage(PlayerContext*);
void UpdateOSDAskAllowDialog(PlayerContext*);
void SetUpdateOSDPosition(bool set_it);
// PxP handling
bool CreatePBP(PlayerContext *lctx, const ProgramInfo *info);
bool CreatePIP(PlayerContext *lctx, const ProgramInfo *info);
bool ResizePIPWindow(PlayerContext*);
bool IsPBPSupported(const PlayerContext *ctx = NULL) const;
bool IsPIPSupported(const PlayerContext *ctx = NULL) const;
void PxPToggleView( PlayerContext *actx, bool wantPBP);
void PxPCreateView( PlayerContext *actx, bool wantPBP);
void PxPTeardownView(PlayerContext *actx);
void PxPToggleType( PlayerContext *mctx, bool wantPBP);
void PxPSwap( PlayerContext *mctx, PlayerContext *pipctx);
bool PIPAddPlayer( PlayerContext *mctx, PlayerContext *ctx);
bool PIPRemovePlayer(PlayerContext *mctx, PlayerContext *ctx);
void PBPRestartMainPlayer(PlayerContext *mctx);
void SetActive(PlayerContext *lctx, int index, bool osd_msg);
// Video controls
void ToggleAspectOverride(PlayerContext*,
AspectOverrideMode aspectMode = kAspect_Toggle);
void ToggleAdjustFill(PlayerContext*,
AdjustFillMode adjustfillMode = kAdjustFill_Toggle);
void DoToggleStudioLevels(const PlayerContext *ctx);
void DoToggleNightMode(const PlayerContext*);
void DoTogglePictureAttribute(const PlayerContext*,
PictureAdjustType type);
void DoChangePictureAttribute(
PlayerContext*,
PictureAdjustType type, PictureAttribute attr,
bool up, int newvalue = -1);
bool PictureAttributeHandleAction(PlayerContext*,
const QStringList &actions);
static PictureAttribute NextPictureAdjustType(
PictureAdjustType type, MythPlayer *mp, PictureAttribute attr);
void HandleDeinterlacer(PlayerContext* ctx, const QString &action);
// Sundry on screen
void ITVRestart(PlayerContext*, bool isLive);
void EnableVisualisation(const PlayerContext*, bool enable, bool toggle = false,
const QString &action = QString(""));
// Manual zoom mode
void SetManualZoom(const PlayerContext *, bool enabled, QString msg);
bool ManualZoomHandleAction(PlayerContext *actx,
const QStringList &actions);
// Channel editing support
void StartChannelEditMode(PlayerContext*);
bool HandleOSDChannelEdit(PlayerContext*, QString action);
void ChannelEditAutoFill(const PlayerContext*, InfoMap&) const;
void ChannelEditAutoFill(const PlayerContext*, InfoMap&,
const QMap<QString,bool>&) const;
void ChannelEditXDSFill(const PlayerContext*, InfoMap&) const;
void ChannelEditDDFill(InfoMap&, const QMap<QString,bool>&, bool) const;
QString GetDataDirect(QString key, QString value,
QString field, bool allow_partial = false) const;
bool LoadDDMap(uint sourceid);
void RunLoadDDMap(uint sourceid);
// General dialog handling
bool DialogIsVisible(PlayerContext *ctx, const QString &dialog);
void HandleOSDInfo(PlayerContext *ctx, QString action);
void ShowNoRecorderDialog(const PlayerContext*,
NoRecorderMsg msgType = kNoRecorders);
// AskAllow dialog handling
void ShowOSDAskAllow(PlayerContext *ctx);
void HandleOSDAskAllow(PlayerContext *ctx, QString action);
void AskAllowRecording(PlayerContext*, const QStringList&, int, bool, bool);
// Program editing support
void ShowOSDCutpoint(PlayerContext *ctx, const QString &type);
bool HandleOSDCutpoint(PlayerContext *ctx, QString action, long long frame);
void StartProgramEditMode(PlayerContext*);
// Already editing dialog
void ShowOSDAlreadyEditing(PlayerContext *ctx);
void HandleOSDAlreadyEditing(PlayerContext *ctx, QString action,
bool was_paused);
// Sleep dialog handling
void ShowOSDSleep(void);
void HandleOSDSleep(PlayerContext *ctx, QString action);
void SleepDialogTimeout(void);
// Idle dialog handling
void ShowOSDIdle(void);
void HandleOSDIdle(PlayerContext *ctx, QString action);
void IdleDialogTimeout(void);
// Exit/delete dialog handling
void ShowOSDStopWatchingRecording(PlayerContext *ctx);
void ShowOSDPromptDeleteRecording(PlayerContext *ctx, QString title,
bool force = false);
bool HandleOSDVideoExit(PlayerContext *ctx, QString action);
// Menu dialog
void ShowOSDMenu(const PlayerContext*, const QString category = "",
const QString selected = "");
void FillOSDMenuAudio (const PlayerContext *ctx, OSD *osd,
QString category, const QString selected,
QString ¤ttext, QString &backaction);
void FillOSDMenuVideo (const PlayerContext *ctx, OSD *osd,
QString category, const QString selected,
QString ¤ttext, QString &backaction);
void FillOSDMenuSubtitles(const PlayerContext *ctx, OSD *osd,
QString category, const QString selected,
QString ¤ttext, QString &backaction);
void FillOSDMenuNavigate (const PlayerContext *ctx, OSD *osd,
QString category, const QString selected,
QString ¤ttext, QString &backaction);
void FillOSDMenuJobs (const PlayerContext *ctx, OSD *osd,
QString category, const QString selected,
QString ¤ttext, QString &backaction);
void FillOSDMenuPlayback (const PlayerContext *ctx, OSD *osd,
QString category, const QString selected,
QString ¤ttext, QString &backaction);
void FillOSDMenuSchedule (const PlayerContext *ctx, OSD *osd,
QString category, const QString selected,
QString ¤ttext, QString &backaction);
void FillOSDMenuSource (const PlayerContext *ctx, OSD *osd,
QString category, const QString selected,
QString ¤ttext, QString &backaction);
void FillOSDMenuJumpRec (PlayerContext* ctx, const QString category = "",
int level = 0, const QString selected = "");
// LCD
void UpdateLCD(void);
void ShowLCDChannelInfo(const PlayerContext*);
void ShowLCDDVDInfo(const PlayerContext*);
// Other stuff
int GetLastRecorderNum(int player_idx) const;
static QStringList GetValidRecorderList(uint chanid);
static QStringList GetValidRecorderList(const QString &channum);
static QStringList GetValidRecorderList(uint, const QString&);
static TVState RemoveRecording(TVState state);
void RestoreScreenSaver(const PlayerContext*);
// for temp debugging only..
int find_player_index(const PlayerContext*) const;
private:
// Configuration variables from database
QString baseFilters;
QString db_channel_format;
uint db_idle_timeout;
int db_playback_exit_prompt;
uint db_autoexpire_default;
bool db_auto_set_watched;
bool db_end_of_rec_exit_prompt;
bool db_jump_prefer_osd;
bool db_use_gui_size_for_tv;
bool db_start_in_guide;
bool db_toggle_bookmark;
bool db_run_jobs_on_remote;
bool db_continue_embedded;
bool db_use_fixed_size;
bool db_browse_always;
bool db_browse_all_tuners;
bool db_use_channel_groups;
bool db_remember_last_channel_group;
ChannelGroupList db_channel_groups;
CommSkipMode autoCommercialSkip;
bool tryUnflaggedSkip;
bool smartForward;
float ff_rew_repos;
bool ff_rew_reverse;
bool jumped_back; ///< Used by PromptDeleteRecording
vector<int> ff_rew_speeds;
uint vbimode;
QTime ctorTime;
uint switchToInputId;
QMutex initFromDBLock;
bool initFromDBDone;
QWaitCondition initFromDBWait;
/// True if the user told MythTV to stop plaback. If this is false
/// when we exit the player, we display an error screen.
mutable bool wantsToQuit;
bool stretchAdjustment; ///< True if time stretch is turned on
bool audiosyncAdjustment; ///< True if audiosync is turned on
bool editmode; ///< Are we in video editing mode
bool zoomMode;
bool sigMonMode; ///< Are we in signal monitoring mode?
bool endOfRecording; ///< !player->IsPlaying() && StateIsPlaying()
bool requestDelete; ///< User wants last video deleted
bool allowRerecord; ///< User wants to rerecord the last video if deleted
bool doSmartForward;
bool queuedTranscode;
/// Picture attribute type to modify.
PictureAdjustType adjustingPicture;
/// Picture attribute to modify (on arrow left or right)
PictureAttribute adjustingPictureAttribute;
// Ask Allow state
QMap<QString,AskProgramInfo> askAllowPrograms;
QMutex askAllowLock;
MythDeque<QString> changePxP;
QMutex progListsLock;
QMap<QString,ProgramList> progLists;
mutable QMutex chanEditMapLock; ///< Lock for chanEditMap and ddMap
InfoMap chanEditMap; ///< Channel Editing initial map
DDKeyMap ddMap; ///< DataDirect channel map
uint ddMapSourceId; ///< DataDirect channel map sourceid
DDLoader *ddMapLoader; ///< DataDirect map loader runnable
/// Vector or sleep timer sleep times in seconds,
/// with the appropriate UI message.
vector<SleepTimerInfo> sleep_times;
uint sleep_index; ///< Index into sleep_times.
uint sleepTimerTimeout; ///< Current sleep timeout in msec
int sleepTimerId; ///< Timer for turning off playback.
int sleepDialogTimerId; ///< Timer for sleep dialog.
/// Timer for turning off playback after idle period.
int idleTimerId;
int idleDialogTimerId; ///< Timer for idle dialog.
/// Queue of unprocessed key presses.
MythTimer keyRepeatTimer; ///< Timeout timer for repeat key filtering
// CC/Teletex input state variables
/// Are we in CC/Teletext page/stream selection mode?
bool ccInputMode;
// Arbitrary Seek input state variables
/// Are we in Arbitrary seek input mode?
bool asInputMode;
// Channel changing state variables
/// Input key presses queued up so far...
QString queuedInput;
/// Input key presses queued up so far to form a valid ChanNum
mutable QString queuedChanNum;
/// Queued ChanID (from EPG channel selector)
uint queuedChanID;
// Channel changing timeout notification variables
QTime lockTimer;
bool lockTimerOn;
QDateTime lastLockSeenTime;
// Channel browsing state variables
TVBrowseHelper *browsehelper;
// Program Info for currently playing video
// (or next video if InChangeState() is true)
mutable QMutex lastProgramLock;
ProgramInfo *lastProgram; ///< last program played with this player
bool inPlaylist; ///< show is part of a playlist
bool underNetworkControl; ///< initial show started via by the network control interface
// Program Jumping
PIPState jumpToProgramPIPState;
bool jumpToProgram;
// Video Players
vector<PlayerContext*> player;
/// Video Player to which events are sent to
int playerActive;
/// lock on player and playerActive changes
mutable QReadWriteLock playerLock;
bool noHardwareDecoders;
// Remote Encoders
/// Main recorder to use after a successful SwitchCards() call.
RemoteEncoder *switchToRec;
// OSD info
QMap<OSD*,const PlayerContext*> osd_lctx;
// LCD Info
QString lcdTitle;
QString lcdSubtitle;
QString lcdCallsign;
// Window info (GUI is optional, transcoding, preview img, etc)
TvPlayWindow *myWindow; ///< Our screen, if it exists
///< player bounds, for after DoEditSchedule() returns to normal playing.
QRect player_bounds;
///< Prior GUI window bounds, for DoEditSchedule() and player exit().
QRect saved_gui_bounds;
/// true if this instance disabled MythUI drawing.
bool weDisabledGUI;
/// true if video chromakey and frame should not be drawn
bool disableDrawUnusedRects;
// embedded status
bool isEmbedded; ///< are we currently embedded
bool ignoreKeyPresses; ///< should we ignore keypresses
vector<bool> saved_pause; ///< saved pause state before embedding
// IsTunable() cache, used by embedded program guide
mutable QMutex is_tunable_cache_lock;
QMap< uint,vector<InputInfo> > is_tunable_cache_inputs;
// Channel group stuff
/// \brief Lock necessary when modifying channel group variables.
/// These are only modified in UI thread, so no lock is needed
/// to read this value in the UI thread.
mutable QMutex channelGroupLock;
volatile int channelGroupId;
DBChanInfoList channelGroupChannelList;
// Network Control stuff
MythDeque<QString> networkControlCommands;
// Timers
typedef QMap<int,PlayerContext*> TimerContextMap;
typedef QMap<int,const PlayerContext*> TimerContextConstMap;
mutable QMutex timerIdLock;
volatile int lcdTimerId;
volatile int lcdVolumeTimerId;
volatile int networkControlTimerId;
volatile int jumpMenuTimerId;
volatile int pipChangeTimerId;
volatile int switchToInputTimerId;
volatile int ccInputTimerId;
volatile int asInputTimerId;
volatile int queueInputTimerId;
volatile int browseTimerId;
volatile int updateOSDPosTimerId;
volatile int updateOSDDebugTimerId;
volatile int endOfPlaybackTimerId;
volatile int embedCheckTimerId;
volatile int endOfRecPromptTimerId;
volatile int videoExitDialogTimerId;
volatile int pseudoChangeChanTimerId;
volatile int speedChangeTimerId;
volatile int errorRecoveryTimerId;
mutable volatile int exitPlayerTimerId;
TimerContextMap stateChangeTimerId;
TimerContextMap signalMonitorTimerId;
TimerContextMap tvchainUpdateTimerId;
public:
// Constants
static const int kInitFFRWSpeed; ///< 1x, default to normal speed
static const uint kInputKeysMax; ///< When to start discarding early keys
static const uint kNextSource;
static const uint kPreviousSource;
static const uint kMaxPIPCount;
static const uint kMaxPBPCount;
///< Timeout for entry modes in msec
static const uint kInputModeTimeout;
/// Timeout for updating LCD info in msec
static const uint kLCDTimeout;
/// Timeout for browse mode exit in msec
static const uint kBrowseTimeout;
/// Seek key repeat timeout in msec
static const uint kKeyRepeatTimeout;
/// How long to wait before applying all previous channel keypresses in msec
static const uint kPrevChanTimeout;
/// How long to display sleep timer dialog in msec
static const uint kSleepTimerDialogTimeout;
/// How long to display idle timer dialog in seconds
static const uint kIdleTimerDialogTimeout;
/// How long to display idle timer dialog in msec
static const uint kVideoExitDialogTimeout;
static const uint kEndOfPlaybackCheckFrequency;
static const uint kEmbedCheckFrequency;
static const uint kSpeedChangeCheckFrequency;
static const uint kErrorRecoveryCheckFrequency;
static const uint kEndOfRecPromptCheckFrequency;
static const uint kEndOfPlaybackFirstCheckTimer;
};
#endif