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 
14 // Qt headers
15 #include <QReadWriteLock>
16 #include <QString>
17 #include <QMutex>
18 #include <QList> // for QList
19 #include <QMap> // for QMap
20 
21 // MythTV headers
22 #include "dtvconfparserhelpers.h" // for DTVTunerType
23 #include "channelbase.h"
24 #include "channelutil.h" // for pid_cache_t, IPTVTuningData
25 
27 class ProgramMapTable;
28 class TVRec;
29 
33 class DTVChannel : public ChannelBase
34 {
35  public:
36  explicit DTVChannel(TVRec *parent) : ChannelBase(parent) {}
37  ~DTVChannel() override;
38 
39  // Commands
40  bool SetChannelByString(const QString &chan) override; // ChannelBase
41 
42  /* Allow 'MPTS' format to be set, so we know when to process the
43  full, unfiltered MPTS from the transport stream. */
44  void SetFormat(const QString & format) override // ChannelBase
45  { m_tvFormat = format; }
46  QString GetFormat(void) { return m_tvFormat; }
47 
49  virtual bool TuneMultiplex(uint mplexid, const QString& inputname);
56  virtual bool Tune(const DTVMultiplex &tuning) = 0;
58  virtual bool Tune(const IPTVTuningData &/*tuning*/, bool /*scanning*/) { return false; }
63  virtual bool Tune(const QString &/*channum*/) { return true; }
65  virtual bool EnterPowerSavingMode(void)
66  {
67  return true;
68  }
75  bool Tune(const QString &freqid, int finetune) override // ChannelBase
76  {
77  (void) freqid; (void) finetune;
78  return false;
79  }
80 
81  virtual bool Tune(uint64_t frequency)
82  {
83  (void) frequency;
84  return false;
85  }
86 
87  // Gets
88 
90  int GetProgramNumber(void) const
91  { return m_currentProgramNum; };
92 
94  uint GetMajorChannel(void) const
95  { return m_currentATSCMajorChannel; };
96 
98  uint GetMinorChannel(void) const
99  { return m_currentATSCMinorChannel; };
100 
103  { return m_currentOriginalNetworkID; };
104 
106  uint GetTransportID(void) const
107  { return m_currentTransportID; };
108 
110  QString GetSIStandard(void) const;
111 
113  QString GetSuggestedTuningMode(bool is_live_tv) const;
114 
116  QString GetTuningMode(void) const;
117 
119  virtual std::vector<DTVTunerType> GetTunerTypes(void) const;
120 
121  void GetCachedPids(pid_cache_t &pid_cache) const;
122 
123  void RegisterForMaster(const QString &key);
124  void DeregisterForMaster(const QString &key);
125  static DTVChannel *GetMasterLock(const QString &key);
127  static void ReturnMasterLock(DTVChannelP &chan);
128 
130  virtual bool IsMaster(void) const { return false; }
131 
132  virtual bool IsPIDTuningSupported(void) const { return false; }
133 
134  virtual bool IsIPTV(void) const { return false; }
135 
136  bool HasGeneratedPAT(void) const { return m_genPAT != nullptr; }
137  bool HasGeneratedPMT(void) const { return m_genPMT != nullptr; }
138  const ProgramAssociationTable *GetGeneratedPAT(void) const {return m_genPAT;}
139  const ProgramMapTable *GetGeneratedPMT(void) const {return m_genPMT;}
140 
141  // Sets
142 
144  void SetTuningMode(const QString &tuning_mode);
145 
146  void SaveCachedPids(const pid_cache_t &pid_cache) const;
147 
148  protected:
150  void SetSIStandard(const QString &si_std);
151  void SetDTVInfo(uint atsc_major, uint atsc_minor,
152  uint dvb_orig_netid,
153  uint mpeg_tsid, int mpeg_pnum);
154  void ClearDTVInfo(void) { SetDTVInfo(0, 0, 0, 0, -1); }
156  virtual void CheckOptions(DTVMultiplex &/*tuning*/) const {}
157  void HandleScriptEnd(bool ok) override; // ChannelBase
158 
159  protected:
160  mutable QMutex m_dtvinfoLock;
161 
164  QString m_sistandard {"mpeg"};
165  QString m_tuningMode;
166  QString m_tvFormat;
172 
177 
178  using MasterMap = QMap<QString,QList<DTVChannel*> >;
179  static QReadWriteLock s_master_map_lock;
181 };
182 
183 #endif // DTVCHANNEL_H
DTVChannel::GetTunerTypes
virtual std::vector< DTVTunerType > GetTunerTypes(void) const
Returns a vector of supported tuning types.
Definition: dtvchannel.cpp:78
DTVChannel::GetMajorChannel
uint GetMajorChannel(void) const
Returns major channel, 0 if unknown.
Definition: dtvchannel.h:94
DTVChannel::CheckOptions
virtual void CheckOptions(DTVMultiplex &) const
Checks tuning for problems, and tries to fix them.
Definition: dtvchannel.h:156
DTVMultiplex
Definition: dtvmultiplex.h:25
DTVChannel::RegisterForMaster
void RegisterForMaster(const QString &key)
Definition: dtvchannel.cpp:113
DTVChannel::m_tvFormat
QString m_tvFormat
Definition: dtvchannel.h:166
DTVChannel::ReturnMasterLock
static void ReturnMasterLock(DTVChannelP &chan)
Definition: dtvchannel.cpp:147
DTVChannel::m_currentTransportID
uint m_currentTransportID
Definition: dtvchannel.h:170
DTVChannel::s_master_map
static MasterMap s_master_map
Definition: dtvchannel.h:180
DTVChannel::ClearDTVInfo
void ClearDTVInfo(void)
Definition: dtvchannel.h:154
DTVChannel::IsIPTV
virtual bool IsIPTV(void) const
Definition: dtvchannel.h:134
ProgramMapTable
A PMT table maps a program described in the ProgramAssociationTable to various PID's which describe t...
Definition: mpegtables.h:682
DTVChannel::IsPIDTuningSupported
virtual bool IsPIDTuningSupported(void) const
Definition: dtvchannel.h:132
DTVChannel::GetMinorChannel
uint GetMinorChannel(void) const
Returns minor channel, 0 if unknown.
Definition: dtvchannel.h:98
DTVChannel::DTVChannel
DTVChannel(TVRec *parent)
Definition: dtvchannel.h:36
DTVChannel::SetChannelByString
bool SetChannelByString(const QString &chan) override
Definition: dtvchannel.cpp:156
DTVChannel::DeregisterForMaster
void DeregisterForMaster(const QString &key)
Definition: dtvchannel.cpp:120
DTVChannel::GetFormat
QString GetFormat(void)
Definition: dtvchannel.h:46
DTVChannel::GetMasterLock
static DTVChannel * GetMasterLock(const QString &key)
Definition: dtvchannel.cpp:135
channelbase.h
DTVChannel::Tune
virtual bool Tune(const DTVMultiplex &tuning)=0
This performs the actual frequency tuning and in some cases input switching.
DTVChannel::GetGeneratedPMT
const ProgramMapTable * GetGeneratedPMT(void) const
Definition: dtvchannel.h:139
DTVChannel::MasterMap
QMap< QString, QList< DTVChannel * > > MasterMap
Definition: dtvchannel.h:178
DTVChannel::m_currentProgramNum
int m_currentProgramNum
Definition: dtvchannel.h:167
DTVTunerType
Definition: dtvconfparserhelpers.h:77
DTVChannel::GetTuningMode
QString GetTuningMode(void) const
Returns tuning mode last set by SetTuningMode().
Definition: dtvchannel.cpp:72
DTVChannel::GetOriginalNetworkID
uint GetOriginalNetworkID(void) const
Returns DVB original_network_id, 0 if unknown.
Definition: dtvchannel.h:102
DTVChannel::m_currentOriginalNetworkID
uint m_currentOriginalNetworkID
Definition: dtvchannel.h:171
DTVChannel::GetTransportID
uint GetTransportID(void) const
Returns DVB transport_stream_id, 0 if unknown.
Definition: dtvchannel.h:106
ChannelBase
Abstract class providing a generic interface to tuning hardware.
Definition: channelbase.h:32
DTVChannel::~DTVChannel
~DTVChannel() override
Definition: dtvchannel.cpp:17
DTVChannel::m_genPMT
ProgramMapTable * m_genPMT
This is a generated PMT for RAW pid tuning.
Definition: dtvchannel.h:176
DTVChannel::SaveCachedPids
void SaveCachedPids(const pid_cache_t &pid_cache) const
Saves MPEG PIDs to cache to database.
Definition: dtvchannel.cpp:106
DTVTunerType::kTunerTypeUnknown
static const int kTunerTypeUnknown
Definition: dtvconfparserhelpers.h:103
DTVChannel::SetSIStandard
void SetSIStandard(const QString &si_std)
Sets PSIP table standard: MPEG, DVB, ATSC, or OpenCable.
Definition: dtvchannel.cpp:50
pid_cache_t
std::vector< pid_cache_item_t > pid_cache_t
Definition: channelutil.h:42
DTVChannel::GetGeneratedPAT
const ProgramAssociationTable * GetGeneratedPAT(void) const
Definition: dtvchannel.h:138
IPTVTuningData
Definition: iptvtuningdata.h:17
DTVChannel::HasGeneratedPMT
bool HasGeneratedPMT(void) const
Definition: dtvchannel.h:137
DTVChannel::IsMaster
virtual bool IsMaster(void) const
Returns true if this is the first of a number of multi-rec devs.
Definition: dtvchannel.h:130
DTVChannel::SetFormat
void SetFormat(const QString &format) override
Definition: dtvchannel.h:44
uint
unsigned int uint
Definition: compat.h:141
ProgramAssociationTable
The Program Association Table lists all the programs in a stream, and is always found on PID 0.
Definition: mpegtables.h:605
DTVChannel::EnterPowerSavingMode
virtual bool EnterPowerSavingMode(void)
Enters power saving mode if the card supports it.
Definition: dtvchannel.h:65
DTVChannel::m_sistandard
QString m_sistandard
PSIP table standard: MPEG, DVB, ATSC, OpenCable.
Definition: dtvchannel.h:164
channelutil.h
DTVChannel::GetSIStandard
QString GetSIStandard(void) const
Returns PSIP table standard: MPEG, DVB, ATSC, or OpenCable.
Definition: dtvchannel.cpp:44
DTVChannel::HandleScriptEnd
void HandleScriptEnd(bool ok) override
Definition: dtvchannel.cpp:385
DTVChannel::m_tunerType
DTVTunerType m_tunerType
Definition: dtvchannel.h:162
DTVChannel::s_master_map_lock
static QReadWriteLock s_master_map_lock
Definition: dtvchannel.h:179
DTVChannel::TuneMultiplex
virtual bool TuneMultiplex(uint mplexid, const QString &inputname)
To be used by the channel scanner and possibly the EIT scanner.
Definition: dtvchannel.cpp:394
DTVChannel::m_genPAT
ProgramAssociationTable * m_genPAT
This is a generated PAT for RAW pid tuning.
Definition: dtvchannel.h:174
DTVChannel::SetTuningMode
void SetTuningMode(const QString &tuning_mode)
Sets tuning mode: "mpeg", "dvb", "atsc", etc.
Definition: dtvchannel.cpp:86
DTVChannel::m_dtvinfoLock
QMutex m_dtvinfoLock
Definition: dtvchannel.h:160
TVRec
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:143
DTVChannel::GetProgramNumber
int GetProgramNumber(void) const
Returns program number in PAT, -1 if unknown.
Definition: dtvchannel.h:90
DTVChannel::SetDTVInfo
void SetDTVInfo(uint atsc_major, uint atsc_minor, uint dvb_orig_netid, uint mpeg_tsid, int mpeg_pnum)
Definition: dtvchannel.cpp:32
DTVChannel::HasGeneratedPAT
bool HasGeneratedPAT(void) const
Definition: dtvchannel.h:136
DTVChannel
Class providing a generic interface to digital tuning hardware.
Definition: dtvchannel.h:34
DTVChannel::GetCachedPids
void GetCachedPids(pid_cache_t &pid_cache) const
Returns cached MPEG PIDs for last tuned channel.
Definition: dtvchannel.cpp:96
DTVChannel::GetSuggestedTuningMode
QString GetSuggestedTuningMode(bool is_live_tv) const
Returns suggested tuning mode: "mpeg", "dvb", or "atsc".
Definition: dtvchannel.cpp:56
DTVChannel::m_tuningMode
QString m_tuningMode
Definition: dtvchannel.h:165
DTVChannel::m_currentATSCMinorChannel
uint m_currentATSCMinorChannel
Definition: dtvchannel.h:169
DTVChannel::m_currentATSCMajorChannel
uint m_currentATSCMajorChannel
Definition: dtvchannel.h:168
dtvconfparserhelpers.h