MythTV  master
dtvchannel.h
Go to the documentation of this file.
1 /* -*- Mode: c++ -*-
2  * DTVChannel
3  * Copyright (c) 2005,2006 by Daniel Kristjansson
4  * Contains base class for digital channels.
5  */
6 
7 #ifndef _DTVCHANNEL_H_
8 #define _DTVCHANNEL_H_
9 
10 // C++ headers
11 #include <cstdint>
12 #include <vector>
13 using namespace std;
14 
15 // Qt headers
16 #include <QReadWriteLock>
17 #include <QString>
18 #include <QMutex>
19 #include <QList> // for QList
20 #include <QMap> // for QMap
21 
22 // MythTV headers
23 #include "dtvconfparserhelpers.h" // for DTVTunerType
24 #include "channelbase.h"
25 #include "channelutil.h" // for pid_cache_t, IPTVTuningData
26 
28 class ProgramMapTable;
29 class TVRec;
30 
34 class DTVChannel : public ChannelBase
35 {
36  public:
37  explicit DTVChannel(TVRec *parent) : ChannelBase(parent) {}
38  virtual ~DTVChannel();
39 
40  // Commands
41  bool SetChannelByString(const QString &chan) override; // ChannelBase
42 
43  /* Allow 'MPTS' format to be set, so we know when to process the
44  full, unfiltered MPTS from the transport stream. */
45  void SetFormat(const QString & format) override // ChannelBase
46  { m_tvFormat = format; }
47  QString GetFormat(void) { return m_tvFormat; }
48 
50  virtual bool TuneMultiplex(uint mplexid, QString inputname);
57  virtual bool Tune(const DTVMultiplex &tuning) = 0;
59  virtual bool Tune(const IPTVTuningData&, bool /*scanning*/) { return false; }
64  virtual bool Tune(const QString &/*channum*/) { return true; }
66  virtual bool EnterPowerSavingMode(void)
67  {
68  return true;
69  }
76  bool Tune(const QString &freqid, int finetune) override // ChannelBase
77  {
78  (void) freqid; (void) finetune;
79  return false;
80  }
81 
82  virtual bool Tune(uint64_t frequency)
83  {
84  (void) frequency;
85  return false;
86  }
87 
88  // Gets
89 
91  int GetProgramNumber(void) const
92  { return m_currentProgramNum; };
93 
95  uint GetMajorChannel(void) const
96  { return m_currentATSCMajorChannel; };
97 
99  uint GetMinorChannel(void) const
100  { return m_currentATSCMinorChannel; };
101 
104  { return m_currentOriginalNetworkID; };
105 
107  uint GetTransportID(void) const
108  { return m_currentTransportID; };
109 
111  QString GetSIStandard(void) const;
112 
114  QString GetSuggestedTuningMode(bool is_live_tv) const;
115 
117  QString GetTuningMode(void) const;
118 
120  virtual vector<DTVTunerType> GetTunerTypes(void) const;
121 
122  void GetCachedPids(pid_cache_t &pid_cache) const;
123 
124  void RegisterForMaster(const QString &key);
125  void DeregisterForMaster(const QString &key);
126  static DTVChannel *GetMasterLock(const QString &key);
128  static void ReturnMasterLock(DTVChannelP&);
129 
131  virtual bool IsMaster(void) const { return false; }
132 
133  virtual bool IsPIDTuningSupported(void) const { return false; }
134 
135  virtual bool IsIPTV(void) const { return false; }
136 
137  bool HasGeneratedPAT(void) const { return m_genPAT != nullptr; }
138  bool HasGeneratedPMT(void) const { return m_genPMT != nullptr; }
139  const ProgramAssociationTable *GetGeneratedPAT(void) const {return m_genPAT;}
140  const ProgramMapTable *GetGeneratedPMT(void) const {return m_genPMT;}
141 
142  // Sets
143 
145  void SetTuningMode(const QString &tuning_mode);
146 
147  void SaveCachedPids(const pid_cache_t &pid_cache) const;
148 
149  protected:
151  void SetSIStandard(const QString&);
152  void SetDTVInfo(uint atsc_major, uint atsc_minor,
153  uint dvb_orig_netid,
154  uint mpeg_tsid, int mpeg_pnum);
155  void ClearDTVInfo(void) { SetDTVInfo(0, 0, 0, 0, -1); }
157  virtual void CheckOptions(DTVMultiplex &/*tuning*/) const {}
158  void HandleScriptEnd(bool ok) override; // ChannelBase
159 
160  protected:
161  mutable QMutex m_dtvinfo_lock;
162 
165  QString m_sistandard {"mpeg"};
166  QString m_tuningMode;
167  QString m_tvFormat;
168  int m_currentProgramNum {-1};
169  uint m_currentATSCMajorChannel {0};
170  uint m_currentATSCMinorChannel {0};
171  uint m_currentTransportID {0};
172  uint m_currentOriginalNetworkID {0};
173 
175  ProgramAssociationTable *m_genPAT {nullptr};
177  ProgramMapTable *m_genPMT {nullptr};
178 
179  typedef QMap<QString,QList<DTVChannel*> > MasterMap;
180  static QReadWriteLock s_master_map_lock;
182 };
183 
184 #endif // _DTVCHANNEL_H_
bool Tune(const QString &freqid, int finetune) override
This tunes on the frequency Identification parameter for hardware that supports it.
Definition: dtvchannel.h:76
static QReadWriteLock s_master_map_lock
Definition: dtvchannel.h:180
bool HasGeneratedPAT(void) const
Definition: dtvchannel.h:137
uint GetTransportID(void) const
Returns DVB transport_stream_id, 0 if unknown.
Definition: dtvchannel.h:107
int GetProgramNumber(void) const
Returns program number in PAT, -1 if unknown.
Definition: dtvchannel.h:91
static const int kTunerTypeUnknown
vector< pid_cache_item_t > pid_cache_t
Definition: channelutil.h:43
virtual bool Tune(uint64_t frequency)
Definition: dtvchannel.h:82
const ProgramAssociationTable * GetGeneratedPAT(void) const
Definition: dtvchannel.h:139
virtual bool Tune(const IPTVTuningData &, bool)
Performs IPTV Tuning. Only implemented by IPTVChannel.
Definition: dtvchannel.h:59
virtual bool EnterPowerSavingMode(void)
Enters power saving mode if the card supports it.
Definition: dtvchannel.h:66
unsigned int uint
Definition: compat.h:140
QString m_tuningMode
Definition: dtvchannel.h:166
QString m_tvFormat
Definition: dtvchannel.h:167
QMutex m_dtvinfo_lock
Definition: dtvchannel.h:161
static MasterMap s_master_map
Definition: dtvchannel.h:181
uint GetMajorChannel(void) const
Returns major channel, 0 if unknown.
Definition: dtvchannel.h:95
DTVChannel * DTVChannelP
Definition: dtvchannel.h:127
Class providing a generic interface to digital tuning hardware.
Definition: dtvchannel.h:34
QMap< QString, QList< DTVChannel * > > MasterMap
Definition: dtvchannel.h:179
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:150
uint GetMinorChannel(void) const
Returns minor channel, 0 if unknown.
Definition: dtvchannel.h:99
QString GetFormat(void)
Definition: dtvchannel.h:47
virtual bool IsIPTV(void) const
Definition: dtvchannel.h:135
virtual bool Tune(const QString &)
Leave it up to the implementation to map the channnum appropriately.
Definition: dtvchannel.h:64
virtual bool IsPIDTuningSupported(void) const
Definition: dtvchannel.h:133
The Program Association Table lists all the programs in a stream, and is always found on PID 0.
Definition: mpegtables.h:579
uint GetOriginalNetworkID(void) const
Returns DVB original_network_id, 0 if unknown.
Definition: dtvchannel.h:103
virtual void CheckOptions(DTVMultiplex &) const
Checks tuning for problems, and tries to fix them.
Definition: dtvchannel.h:157
Abstract class providing a generic interface to tuning hardware.
Definition: channelbase.h:31
void ClearDTVInfo(void)
Definition: dtvchannel.h:155
virtual bool IsMaster(void) const
Returns true if this is the first of a number of multi-rec devs.
Definition: dtvchannel.h:131
void SetFormat(const QString &format) override
Definition: dtvchannel.h:45
bool HasGeneratedPMT(void) const
Definition: dtvchannel.h:138
A PMT table maps a program described in the ProgramAssociationTable to various PID's which describe t...
Definition: mpegtables.h:656
const ProgramMapTable * GetGeneratedPMT(void) const
Definition: dtvchannel.h:140
DTVChannel(TVRec *parent)
Definition: dtvchannel.h:37