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
19class PlayerContext;
20class RemoteEncoder;
21class 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;
40 QString m_startTime;
42};
43
44
45class 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);
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 };
75 std::chrono::seconds m_dbBrowseMaxForward { 0s };
76 bool m_dbBrowseAllTuners { false };
77 bool m_dbUseChannelGroups { false };
78 QHash<uint,QString> m_dbChanidToChannum;
79 QHash<uint,uint> m_dbChanidToSourceid;
80 QMultiMap<QString,uint> m_dbChannumToChanids;
81
82 mutable QMutex m_browseLock;
86 bool m_browseRun { true };
87 QWaitCondition m_browseWait;
88 QList<BrowseInfo> m_browseList;
89};
90
91#endif
std::vector< ChannelInfo > ChannelInfoList
Definition: channelinfo.h:131
QString m_chanNum
BrowseInfo(BrowseDirection Dir, QString Channum, uint Chanid, QString Starttime)
BrowseInfo(BrowseDirection Dir)
BrowseInfo(QString Channum, uint SourceId)
QString m_startTime
BrowseDirection m_dir
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:49
void GetNextProgramDB(BrowseDirection Direction, InfoMap &Infomap) const
bool m_dbUseChannelGroups
void BrowseEnd(bool ChangeChannel)
Ends channel browsing.
BrowseInfo GetBrowsedInfo() const
ChannelInfoList m_dbAllChannels
QHash< uint, QString > m_dbChanidToChannum
bool m_dbBrowseAllTuners
void BrowseDispInfo(const BrowseInfo &Browseinfo)
void GetNextProgram(BrowseDirection Direction, InfoMap &Infomap) const
Fetches information on the desired program from the backend.
TVBrowseHelper(TV *Parent)
QWaitCondition m_browseWait
QString m_browseStartTime
void BrowseChannel(const QString &Channum)
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
std::chrono::seconds m_dbBrowseMaxForward
~TVBrowseHelper() override
void BrowseInit(std::chrono::seconds BrowseMaxForward, bool BrowseAllTuners, bool UseChannelGroups, const QString &DBChannelOrdering)
QHash< uint, uint > m_dbChanidToSourceid
uint GetBrowseChanId(const QString &Channum, uint PrefCardid, uint PrefSourceid) const
Returns a chanid for the channum, or 0 if none is available.
QString m_browseChanNum
QList< BrowseInfo > m_browseList
bool BrowseStart(bool SkipBrowse=false)
Begins channel browsing.
QMultiMap< QString, uint > m_dbChannumToChanids
Control TV playback.
Definition: tv_play.h:156
void ChangeChannel(const ChannelInfoList &Options)
Definition: tv_play.cpp:6242
unsigned int uint
Definition: freesurround.h:24
static HostCheckBoxSetting * BrowseAllTuners()
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
STL namespace.
BrowseDirection
Used to request ProgramInfo for channel browsing.
Definition: tv.h:41
@ BROWSE_SAME
Fetch browse information on current channel and time.
Definition: tv.h:43