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 &/*freqid*/, int /*finetune*/) { 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 /*attr*/) const { return -1; }
96  PictureAdjustType /*type*/, PictureAttribute /*attr*/, bool /*direction*/) { 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) const;
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
GeneralDBOptions
Definition: tv_rec.h:65
ChannelBase::Close
virtual void Close(void)=0
Closes the channel changing hardware to use.
ChannelBase::Init
virtual bool Init(QString &startchannel, bool setchan)
Definition: channelbase.cpp:57
tv.h
ChannelChangeDirection
ChannelChangeDirection
ChannelChangeDirection is an enumeration of possible channel changing directions.
Definition: tv.h:28
MythSystemLegacy
Definition: mythsystemlegacy.h:68
ChannelBase::m_name
QString m_name
Definition: channelbase.h:139
ChannelBase::HandleScriptEnd
virtual void HandleScriptEnd(bool ok)
Definition: channelbase.cpp:475
ChannelBase::Open
virtual bool Open(void)=0
Opens the channel changing hardware for use.
ChannelBase::GetInputName
virtual QString GetInputName(void) const
Definition: channelbase.h:69
PictureAdjustType
PictureAdjustType
Definition: tv.h:120
ChannelBase::IsOpen
virtual bool IsOpen(void) const =0
Reports whether channel is already open.
ChannelBase::CreateChannel
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)
Definition: channelbase.cpp:694
ChannelBase::m_inputId
uint m_inputId
Definition: channelbase.h:137
ChannelBase::IsTunable
virtual bool IsTunable(const QString &channum) const
Definition: channelbase.cpp:126
ChannelBase::GetChannelName
virtual QString GetChannelName(void) const
Definition: channelbase.h:64
ChannelBase::m_startChanNum
QString m_startChanNum
Definition: channelbase.h:140
ChannelBase::GetPictureAttribute
virtual int GetPictureAttribute(PictureAttribute) const
Definition: channelbase.h:94
ChannelBase::m_tuneToChannel
QString m_tuneToChannel
Definition: channelbase.h:142
ChannelBase::IsExternalChannelChangeSupported
virtual bool IsExternalChannelChangeSupported(void)
Definition: channelbase.h:121
ChannelBase::Renumber
virtual void Renumber(uint sourceid, const QString &oldChanNum, const QString &newChanNum)
Changes a channum if we have it cached anywhere.
Definition: channelbase.cpp:625
mythsystemlegacy.h
ChannelBase::m_channels
ChannelInfoList m_channels
channels across all inputs
Definition: channelbase.h:143
ChannelBase::IsInputAvailable
virtual bool IsInputAvailable(uint &mplexid_restriction, uint &chanid_restriction) const
Switches to another input on hardware, and sets the channel is setstarting is true.
Definition: channelbase.cpp:224
ChannelBase::HandleScript
void HandleScript(const QString &freqid)
Definition: channelbase.cpp:276
ChannelBase::InitPictureAttributes
virtual bool InitPictureAttributes(void)
Definition: channelbase.h:93
ChannelBase::SetFormat
virtual void SetFormat(const QString &)
Definition: channelbase.h:52
ChannelBase::IsCommercialFree
bool IsCommercialFree(void) const
Returns true iff commercial detection is not required.
Definition: channelbase.h:76
ChannelBase
Abstract class providing a generic interface to tuning hardware.
Definition: channelbase.h:31
videoouttypes.h
ChannelBase::StoreInputChannels
virtual void StoreInputChannels(void)
Saves current channel as the default channel for the current input.
Definition: channelbase.cpp:645
ChannelBase::m_curChannelName
QString m_curChannelName
Definition: channelbase.h:135
ChannelBase::ChannelBase
ChannelBase(TVRec *parent)
Definition: channelbase.h:36
ChannelBase::IsExternalChannelChangeInUse
virtual bool IsExternalChannelChangeInUse(void)
Definition: channelbase.cpp:834
ChannelInfoList
vector< ChannelInfo > ChannelInfoList
Definition: channelinfo.h:133
uint
unsigned int uint
Definition: compat.h:140
SignalMonitor
Signal monitoring base class.
Definition: signalmonitor.h:32
ChannelBase::SetFd
virtual void SetFd(int fd)
Sets file descriptor.
Definition: channelbase.h:55
PictureAttribute
PictureAttribute
Definition: videoouttypes.h:87
channelinfo.h
ChannelBase::GetScriptStatus
uint GetScriptStatus(bool holding_lock=false)
Definition: channelbase.cpp:427
ChannelBase::ChangeInternalChannel
bool ChangeInternalChannel(const QString &freqid, uint cardinputid) const
Definition: channelbase.cpp:358
ChannelBase::SetChannelByString
virtual bool SetChannelByString(const QString &chan)=0
ChannelBase::Tune
virtual bool Tune(const QString &, int)
Definition: channelbase.h:58
ChannelBase::SetInputID
void SetInputID(uint _inputid)
Definition: channelbase.h:101
ChannelBase::m_systemStatus
uint m_systemStatus
These get mapped from the GENERIC_EXIT_* to these values for use with the signalmonitor code.
Definition: channelbase.h:150
ChannelBase::KillScript
bool KillScript(void)
Definition: channelbase.cpp:263
ChannelBase::SetFreqTable
virtual int SetFreqTable(const QString &)
Definition: channelbase.h:53
ChannelBase::m_sourceId
uint m_sourceId
Definition: channelbase.h:138
ChannelBase::CheckChannel
bool CheckChannel(const QString &channum) const
Definition: channelbase.cpp:663
DVBDBOptions
Definition: tv_rec.h:81
TVRec
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:142
FireWireDBOptions
Definition: tv_rec.h:91
ChannelBase::GetInputID
virtual int GetInputID(void) const
Definition: channelbase.h:67
ChannelBase::GetDevice
virtual QString GetDevice(void) const
Returns String representing device, useful for debugging.
Definition: channelbase.h:78
ChannelBase::ChangeExternalChannel
bool ChangeExternalChannel(const QString &changer, const QString &freqid)
Definition: channelbase.cpp:408
ChannelBase::Retune
virtual bool Retune(void)
Definition: channelbase.h:87
ChannelBase::GetSourceID
virtual uint GetSourceID(void) const
Definition: channelbase.h:71
ChannelBase::m_system_lock
QMutex m_system_lock
Definition: channelbase.h:145
ChannelBase::GetFd
virtual int GetFd(void) const
Returns file descriptor, -1 if it does not exist.
Definition: channelbase.h:57
ChannelBase::GetNextChannel
virtual uint GetNextChannel(uint chanid, ChannelChangeDirection direction) const
Definition: channelbase.cpp:196
ChannelBase::m_system
MythSystemLegacy * m_system
Definition: channelbase.h:146
ChannelBase::GetMajorID
int GetMajorID(void)
Definition: channelbase.cpp:850
ChannelBase::InitializeInput
virtual bool InitializeInput(void)
Fills in input map from DB.
Definition: channelbase.cpp:546
ChannelBase::~ChannelBase
virtual ~ChannelBase(void)
Definition: channelbase.cpp:50
ChannelBase::m_pParent
TVRec * m_pParent
Definition: channelbase.h:134
ChannelBase::ChangePictureAttribute
virtual int ChangePictureAttribute(PictureAdjustType, PictureAttribute, bool)
Definition: channelbase.h:95
ChannelBase::m_commFree
bool m_commFree
Definition: channelbase.h:136
ChannelBase::m_externalChanger
QString m_externalChanger
Definition: channelbase.h:141
ChannelBase::GetChanID
virtual int GetChanID(void) const
Definition: channelbase.cpp:492