MythTV  master
tvbrowsehelper.h
Go to the documentation of this file.
1 #ifndef TV_BROWSE_HELPER_H
2 #define TV_BROWSE_HELPER_H
3 
4 // Qt
5 #include <QHash>
6 #include <QMultiMap>
7 #include <QString>
8 #include <QWaitCondition>
9 
10 // MythTV
11 #include "libmythbase/mthread.h"
13 #include "channelinfo.h"
14 #include "tv.h"
15 
16 // Std
17 #include <utility>
18 
19 class PlayerContext;
20 class RemoteEncoder;
21 class TV;
22 
24 {
25  public:
27  : m_dir(Dir) {}
28  BrowseInfo(BrowseDirection Dir, QString Channum, uint Chanid, QString Starttime)
29  : m_dir(Dir),
30  m_chanNum(std::move(Channum)),
31  m_chanId(Chanid),
32  m_startTime(std::move(Starttime)) { }
33  BrowseInfo(QString Channum, uint SourceId)
34  : m_chanNum(std::move(Channum)),
35  m_sourceId(SourceId) { }
36 
38  QString m_chanNum;
39  uint m_chanId { 0 };
40  QString m_startTime;
42 };
43 
44 
45 class TVBrowseHelper : public MThread
46 {
47  friend class TV;
48 
49  protected:
50  explicit TVBrowseHelper(TV* Parent);
51  ~TVBrowseHelper() override;
52 
53  void BrowseInit(std::chrono::seconds BrowseMaxForward, bool BrowseAllTuners,
54  bool UseChannelGroups, const QString& DBChannelOrdering);
55  void BrowseStop();
56  void BrowseWait();
57  bool BrowseStart(bool SkipBrowse = false);
58  void BrowseEnd(bool ChangeChannel);
59  void BrowseDispInfo(const BrowseInfo& Browseinfo);
60  void BrowseDispInfo(BrowseDirection Direction);
61  void BrowseChannel(const QString& Channum);
62  BrowseInfo GetBrowsedInfo() const;
63  uint GetBrowseChanId(const QString& Channum, uint PrefCardid, uint PrefSourceid) const;
64 
65  int m_browseTimerId { 0 };
66 
67  private:
68  Q_DISABLE_COPY(TVBrowseHelper)
69  void GetNextProgram(BrowseDirection Direction, InfoMap& Infomap) const;
70  void GetNextProgramDB(BrowseDirection Direction, InfoMap& Infomap) const;
71  void run() override;
72 
73  TV* m_parent { nullptr };
76  std::chrono::seconds m_dbBrowseMaxForward { 0s };
77  bool m_dbBrowseAllTuners { false };
78  bool m_dbUseChannelGroups { false };
79  QHash<uint,QString> m_dbChanidToChannum;
80  QHash<uint,uint> m_dbChanidToSourceid;
81  QMultiMap<QString,uint> m_dbChannumToChanids;
82 
83  mutable QMutex m_browseLock;
84  QString m_browseChanNum;
87  bool m_browseRun { true };
88  QWaitCondition m_browseWait;
89  QList<BrowseInfo> m_browseList;
90 };
91 
92 #endif
BrowseInfo::BrowseInfo
BrowseInfo(BrowseDirection Dir)
Definition: tvbrowsehelper.h:26
TVBrowseHelper::m_dbChannumToChanids
QMultiMap< QString, uint > m_dbChannumToChanids
Definition: tvbrowsehelper.h:81
tv.h
TVBrowseHelper::BrowseEnd
void BrowseEnd(bool ChangeChannel)
Ends channel browsing.
Definition: tvbrowsehelper.cpp:117
BrowseInfo::m_chanNum
QString m_chanNum
Definition: tvbrowsehelper.h:38
TVBrowseHelper::~TVBrowseHelper
~TVBrowseHelper() override
Definition: tvbrowsehelper.cpp:34
TVBrowseHelper::m_browseStartTime
QString m_browseStartTime
Definition: tvbrowsehelper.h:86
TVBrowseHelper::TVBrowseHelper
TVBrowseHelper(TV *Parent)
Definition: tvbrowsehelper.cpp:28
BrowseInfo::m_chanId
uint m_chanId
Definition: tvbrowsehelper.h:39
TVBrowseHelper::m_browseTimerId
int m_browseTimerId
Definition: tvbrowsehelper.h:65
TVBrowseHelper::m_dbChanidToSourceid
QHash< uint, uint > m_dbChanidToSourceid
Definition: tvbrowsehelper.h:80
TV::ChangeChannel
void ChangeChannel(const ChannelInfoList &Options)
Definition: tv_play.cpp:6114
TVBrowseHelper::m_browseChanNum
QString m_browseChanNum
Definition: tvbrowsehelper.h:84
TVBrowseHelper::GetBrowseChanId
uint GetBrowseChanId(const QString &Channum, uint PrefCardid, uint PrefSourceid) const
Returns a chanid for the channum, or 0 if none is available.
Definition: tvbrowsehelper.cpp:214
RemoteEncoder
Definition: remoteencoder.h:24
programtypes.h
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
TVBrowseHelper::BrowseWait
void BrowseWait()
Definition: tvbrowsehelper.cpp:70
TVBrowseHelper::GetNextProgram
void GetNextProgram(BrowseDirection Direction, InfoMap &Infomap) const
Fetches information on the desired program from the backend.
Definition: tvbrowsehelper.cpp:250
TVBrowseHelper::m_dbChanidToChannum
QHash< uint, QString > m_dbChanidToChannum
Definition: tvbrowsehelper.h:79
BrowseAllTuners
static HostCheckBoxSetting * BrowseAllTuners()
Definition: globalsettings.cpp:1728
TVBrowseHelper::m_dbUseChannelGroups
bool m_dbUseChannelGroups
Definition: tvbrowsehelper.h:78
TVBrowseHelper::BrowseInit
void BrowseInit(std::chrono::seconds BrowseMaxForward, bool BrowseAllTuners, bool UseChannelGroups, const QString &DBChannelOrdering)
Definition: tvbrowsehelper.cpp:40
TVBrowseHelper::m_dbBrowseAllTuners
bool m_dbBrowseAllTuners
Definition: tvbrowsehelper.h:77
BrowseInfo::BrowseInfo
BrowseInfo(BrowseDirection Dir, QString Channum, uint Chanid, QString Starttime)
Definition: tvbrowsehelper.h:28
TVBrowseHelper::BrowseStop
void BrowseStop()
Definition: tvbrowsehelper.cpp:62
TVBrowseHelper::GetNextProgramDB
void GetNextProgramDB(BrowseDirection Direction, InfoMap &Infomap) const
Definition: tvbrowsehelper.cpp:322
TVBrowseHelper::m_browseRun
bool m_browseRun
Definition: tvbrowsehelper.h:87
TVBrowseHelper::m_browseChanId
uint m_browseChanId
Definition: tvbrowsehelper.h:85
uint
unsigned int uint
Definition: compat.h:79
TVBrowseHelper
Definition: tvbrowsehelper.h:45
TVBrowseHelper::BrowseDispInfo
void BrowseDispInfo(const BrowseInfo &Browseinfo)
Definition: tvbrowsehelper.cpp:142
TVBrowseHelper::GetBrowsedInfo
BrowseInfo GetBrowsedInfo() const
Definition: tvbrowsehelper.cpp:197
channelinfo.h
TVBrowseHelper::m_browseWait
QWaitCondition m_browseWait
Definition: tvbrowsehelper.h:88
TVBrowseHelper::m_browseLock
QMutex m_browseLock
Definition: tvbrowsehelper.h:83
Channum
Definition: channelsettings.cpp:57
BrowseInfo
Definition: tvbrowsehelper.h:23
TVBrowseHelper::m_dbAllVisibleChannels
ChannelInfoList m_dbAllVisibleChannels
Definition: tvbrowsehelper.h:75
BrowseInfo::m_sourceId
uint m_sourceId
Definition: tvbrowsehelper.h:41
std
Definition: mythchrono.h:23
BROWSE_SAME
@ BROWSE_SAME
Fetch browse information on current channel and time.
Definition: tv.h:40
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:48
mthread.h
TVBrowseHelper::m_parent
TV * m_parent
Definition: tvbrowsehelper.h:73
PlayerContext
Definition: playercontext.h:53
TVBrowseHelper::BrowseChannel
void BrowseChannel(const QString &Channum)
Definition: tvbrowsehelper.cpp:167
BrowseInfo::m_dir
BrowseDirection m_dir
Definition: tvbrowsehelper.h:37
TVBrowseHelper::m_browseList
QList< BrowseInfo > m_browseList
Definition: tvbrowsehelper.h:89
BrowseDirection
BrowseDirection
Used to request ProgramInfo for channel browsing.
Definition: tv.h:37
BrowseInfo::BrowseInfo
BrowseInfo(QString Channum, uint SourceId)
Definition: tvbrowsehelper.h:33
TVBrowseHelper::BrowseStart
bool BrowseStart(bool SkipBrowse=false)
Begins channel browsing.
Definition: tvbrowsehelper.cpp:77
TVBrowseHelper::m_dbAllChannels
ChannelInfoList m_dbAllChannels
Definition: tvbrowsehelper.h:74
TVBrowseHelper::m_dbBrowseMaxForward
std::chrono::seconds m_dbBrowseMaxForward
Definition: tvbrowsehelper.h:76
TVBrowseHelper::run
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: tvbrowsehelper.cpp:398
BrowseInfo::m_startTime
QString m_startTime
Definition: tvbrowsehelper.h:40
TV
Control TV playback.
Definition: tv_play.h:154
ChannelInfoList
std::vector< ChannelInfo > ChannelInfoList
Definition: channelinfo.h:131