MythTV  master
channelbase.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 
3 #ifndef CHANNELBASE_H
4 #define CHANNELBASE_H
5 
6 // Qt headers
7 #include <QWaitCondition>
8 #include <QStringList>
9 #include <QMutex>
10 
11 // MythTV headers
12 #include "channelinfo.h"
13 #include "mythsystemlegacy.h"
14 #include "tv.h"
15 #include "videoouttypes.h" // for PictureAttribute
16 
17 class FireWireDBOptions;
18 class GeneralDBOptions;
19 class DVBDBOptions;
20 class ChannelBase;
21 class TVRec;
22 
32 {
33  friend class SignalMonitor;
34 
35  public:
36  explicit ChannelBase(TVRec *parent) : m_pParent(parent) {}
37  virtual ~ChannelBase(void);
38 
39  virtual bool Init(QString &startchannel, bool setchan);
40  virtual bool IsTunable(const QString &channum) const;
41 
42  // Methods that must be implemented.
44  virtual bool Open(void) = 0;
46  virtual void Close(void) = 0;
48  virtual bool IsOpen(void) const = 0;
49  virtual bool SetChannelByString(const QString &chan) = 0;
50 
51  // Methods that one might want to specialize
52  virtual void SetFormat(const QString &/*format*/) {}
53  virtual int SetFreqTable(const QString &/*tablename*/) { return 0; }
55  virtual void SetFd(int fd) { (void)fd; };
57  virtual int GetFd(void) const { return -1; };
58  virtual bool Tune(const QString &, int) { return true; }
59  virtual bool IsExternalChannelChangeInUse(void);
60 
61  // Gets
62  virtual uint GetNextChannel(uint chanid, ChannelChangeDirection direction) const;
63  virtual uint GetNextChannel(const QString &channum, ChannelChangeDirection direction) const;
64  virtual QString GetChannelName(void) const
65  { return m_curchannelname; }
66  virtual int GetChanID(void) const;
67  virtual int GetInputID(void) const
68  { return m_inputid; }
69  virtual QString GetInputName(void) const
70  { return m_name; }
71  virtual uint GetSourceID(void) const
72  { return m_sourceid; }
73 
75  // on current channel, for BBC, CBC, etc.
76  bool IsCommercialFree(void) const { return m_commfree; }
78  virtual QString GetDevice(void) const { return ""; }
79 
80  // Sets
81  virtual void Renumber(uint sourceid, const QString &oldChanNum,
82  const QString &newChanNum);
83 
84  virtual bool InitializeInput(void);
85 
86  // Misc. Commands
87  virtual bool Retune(void) { return false; }
88 
90  virtual void StoreInputChannels(void);
91 
92  // Picture attribute settings
93  virtual bool InitPictureAttributes(void) { return false; }
94  virtual int GetPictureAttribute(PictureAttribute) const { return -1; }
96  PictureAdjustType, PictureAttribute, bool) { return -1; }
97 
98  bool CheckChannel(const QString &channum) const;
99 
100  // \brief Set inputid for scanning
101  void SetInputID(uint _inputid) { m_inputid = _inputid; }
102 
103  // \brief Get major input ID
104  int GetMajorID(void);
105 
106  static ChannelBase *CreateChannel(
107  TVRec *tvrec,
108  const GeneralDBOptions &genOpt,
109  const DVBDBOptions &dvbOpt,
110  const FireWireDBOptions &fwOpt,
111  const QString &startchannel,
112  bool enter_power_save_mode,
113  QString &rbFileExt,
114  bool setchan);
115 
116  protected:
119  virtual bool IsInputAvailable(uint &mplexid_restriction,
120  uint &chanid_restriction) const;
121  virtual bool IsExternalChannelChangeSupported(void) { return false; }
122 
123  protected:
124  bool KillScript(void);
125  void HandleScript(const QString &freqid);
126  virtual void HandleScriptEnd(bool ok);
127  uint GetScriptStatus(bool holding_lock = false);
128 
129  bool ChangeExternalChannel(const QString &changer,
130  const QString &freqid);
131  bool ChangeInternalChannel(const QString &freqid,
132  uint cardinputid);
133 
134  TVRec *m_pParent {nullptr};
136  bool m_commfree {false};
139  QString m_name;
140  QString m_startChanNum;
144 
151 };
152 
153 
154 #endif
QMutex m_system_lock
Definition: channelbase.h:145
virtual int ChangePictureAttribute(PictureAdjustType, PictureAttribute, bool)
Definition: channelbase.h:95
bool ChangeInternalChannel(const QString &freqid, uint cardinputid)
virtual int GetChanID(void) const
MythSystemLegacy * m_system
Definition: channelbase.h:146
virtual void HandleScriptEnd(bool ok)
virtual void Close(void)=0
Closes the channel changing hardware to use.
ChannelChangeDirection
ChannelChangeDirection is an enumeration of possible channel changing directions.
Definition: tv.h:28
virtual QString GetChannelName(void) const
Definition: channelbase.h:64
virtual bool IsOpen(void) const =0
Reports whether channel is already open.
TVRec * m_pParent
Definition: channelbase.h:134
bool m_commfree
Definition: channelbase.h:136
static ChannelBase * CreateChannel(TVRec *tvrec, const GeneralDBOptions &genOpt, const DVBDBOptions &dvbOpt, const FireWireDBOptions &fwOpt, const QString &startchannel, bool enter_power_save_mode, QString &rbFileExt, bool setchan)
virtual void Renumber(uint sourceid, const QString &oldChanNum, const QString &newChanNum)
Changes a channum if we have it cached anywhere.
virtual bool IsTunable(const QString &channum) const
virtual bool Init(QString &startchannel, bool setchan)
Definition: channelbase.cpp:57
QString m_name
Definition: channelbase.h:139
unsigned int uint
Definition: compat.h:140
virtual bool IsExternalChannelChangeSupported(void)
Definition: channelbase.h:121
virtual bool Open(void)=0
Opens the channel changing hardware for use.
uint m_inputid
Definition: channelbase.h:137
void HandleScript(const QString &freqid)
virtual int GetPictureAttribute(PictureAttribute) const
Definition: channelbase.h:94
virtual bool IsExternalChannelChangeInUse(void)
uint m_sourceid
Definition: channelbase.h:138
ChannelBase(TVRec *parent)
Definition: channelbase.h:36
ChannelInfoList m_channels
channels across all inputs
Definition: channelbase.h:143
virtual bool IsInputAvailable(uint &mplexid_restriction, uint &chanid_restriction) const
Switches to another input on hardware, and sets the channel is setstarting is true.
QString m_curchannelname
Definition: channelbase.h:135
QString m_startChanNum
Definition: channelbase.h:140
QString m_tuneToChannel
Definition: channelbase.h:142
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:150
uint GetScriptStatus(bool holding_lock=false)
virtual bool InitPictureAttributes(void)
Definition: channelbase.h:93
virtual void SetFormat(const QString &)
Definition: channelbase.h:52
bool KillScript(void)
bool IsCommercialFree(void) const
Returns true iff commercial detection is not required.
Definition: channelbase.h:76
PictureAttribute
Definition: videoouttypes.h:89
bool CheckChannel(const QString &channum) const
virtual void StoreInputChannels(void)
Saves current channel as the default channel for the current input.
virtual bool Tune(const QString &, int)
Definition: channelbase.h:58
virtual int SetFreqTable(const QString &)
Definition: channelbase.h:53
vector< ChannelInfo > ChannelInfoList
Definition: channelinfo.h:120
bool ChangeExternalChannel(const QString &changer, const QString &freqid)
virtual QString GetDevice(void) const
Returns String representing device, useful for debugging.
Definition: channelbase.h:78
Signal monitoring base class.
Definition: signalmonitor.h:32
virtual bool Retune(void)
Definition: channelbase.h:87
Abstract class providing a generic interface to tuning hardware.
Definition: channelbase.h:31
PictureAdjustType
Definition: tv.h:120
virtual uint GetNextChannel(uint chanid, ChannelChangeDirection direction) const
void SetInputID(uint _inputid)
Definition: channelbase.h:101
virtual void SetFd(int fd)
Sets file descriptor.
Definition: channelbase.h:55
virtual int GetFd(void) const
Returns file descriptor, -1 if it does not exist.
Definition: channelbase.h:57
virtual bool SetChannelByString(const QString &chan)=0
QString m_externalChanger
Definition: channelbase.h:141
virtual int GetInputID(void) const
Definition: channelbase.h:67
virtual uint GetSourceID(void) const
Definition: channelbase.h:71
uint m_system_status
These get mapped from the GENERIC_EXIT_* to these values for use with the signalmonitor code.
Definition: channelbase.h:150
int GetMajorID(void)
virtual QString GetInputName(void) const
Definition: channelbase.h:69
virtual bool InitializeInput(void)
Fills in input map from DB.
virtual ~ChannelBase(void)
Definition: channelbase.cpp:50