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([[maybe_unused]] const QString &freqid,
76  [[maybe_unused]] int finetune) override // ChannelBase
77  {
78  return false;
79  }
80 
81  virtual bool Tune([[maybe_unused]] uint64_t frequency)
82  {
83  return false;
84  }
85 
86  // Gets
87 
89  int GetProgramNumber(void) const
90  { return m_currentProgramNum; };
91 
93  uint GetMajorChannel(void) const
94  { return m_currentATSCMajorChannel; };
95 
97  uint GetMinorChannel(void) const
98  { return m_currentATSCMinorChannel; };
99 
102  { return m_currentOriginalNetworkID; };
103 
105  uint GetTransportID(void) const
106  { return m_currentTransportID; };
107 
109  QString GetSIStandard(void) const;
110 
112  QString GetSuggestedTuningMode(bool is_live_tv) const;
113 
115  QString GetTuningMode(void) const;
116 
118  virtual std::vector<DTVTunerType> GetTunerTypes(void) const;
119 
120  void GetCachedPids(pid_cache_t &pid_cache) const;
121 
122  void RegisterForMaster(const QString &key);
123  void DeregisterForMaster(const QString &key);
124  static DTVChannel *GetMasterLock(const QString &key);
126  static void ReturnMasterLock(DTVChannelP &chan);
127 
129  virtual bool IsMaster(void) const { return false; }
130 
131  virtual bool IsPIDTuningSupported(void) const { return false; }
132 
133  virtual bool IsIPTV(void) const { return false; }
134 
135  bool HasGeneratedPAT(void) const { return m_genPAT != nullptr; }
136  bool HasGeneratedPMT(void) const { return m_genPMT != nullptr; }
137  const ProgramAssociationTable *GetGeneratedPAT(void) const {return m_genPAT;}
138  const ProgramMapTable *GetGeneratedPMT(void) const {return m_genPMT;}
139 
140  // Sets
141 
143  void SetTuningMode(const QString &tuning_mode);
144 
145  void SaveCachedPids(const pid_cache_t &pid_cache) const;
146 
147  protected:
149  void SetSIStandard(const QString &si_std);
150  void SetDTVInfo(uint atsc_major, uint atsc_minor,
151  uint dvb_orig_netid,
152  uint mpeg_tsid, int mpeg_pnum);
153  void ClearDTVInfo(void) { SetDTVInfo(0, 0, 0, 0, -1); }
155  virtual void CheckOptions(DTVMultiplex &/*tuning*/) const {}
156  void HandleScriptEnd(bool ok) override; // ChannelBase
157 
158  protected:
159  mutable QMutex m_dtvinfoLock;
160 
163  QString m_sistandard {"mpeg"};
164  QString m_tuningMode;
165  QString m_tvFormat;
171 
176 
177  using MasterMap = QMap<QString,QList<DTVChannel*> >;
178  static QReadWriteLock s_master_map_lock;
180 };
181 
182 #endif // DTVCHANNEL_H
DTVChannel::GetTunerTypes
virtual std::vector< DTVTunerType > GetTunerTypes(void) const
Returns a vector of supported tuning types.
Definition: dtvchannel.cpp:79
DTVChannel::GetMajorChannel
uint GetMajorChannel(void) const
Returns major channel, 0 if unknown.
Definition: dtvchannel.h:93
DTVChannel::CheckOptions
virtual void CheckOptions(DTVMultiplex &) const
Checks tuning for problems, and tries to fix them.
Definition: dtvchannel.h:155
DTVMultiplex
Definition: dtvmultiplex.h:24
DTVChannel::RegisterForMaster
void RegisterForMaster(const QString &key)
Definition: dtvchannel.cpp:114
DTVChannel::m_tvFormat
QString m_tvFormat
Definition: dtvchannel.h:165
DTVChannel::ReturnMasterLock
static void ReturnMasterLock(DTVChannelP &chan)
Definition: dtvchannel.cpp:148
DTVChannel::m_currentTransportID
uint m_currentTransportID
Definition: dtvchannel.h:169
DTVChannel::s_master_map
static MasterMap s_master_map
Definition: dtvchannel.h:179
DTVChannel::ClearDTVInfo
void ClearDTVInfo(void)
Definition: dtvchannel.h:153
DTVChannel::IsIPTV
virtual bool IsIPTV(void) const
Definition: dtvchannel.h:133
ProgramMapTable
A PMT table maps a program described in the ProgramAssociationTable to various PID's which describe t...
Definition: mpegtables.h:694
DTVChannel::IsPIDTuningSupported
virtual bool IsPIDTuningSupported(void) const
Definition: dtvchannel.h:131
DTVChannel::GetMinorChannel
uint GetMinorChannel(void) const
Returns minor channel, 0 if unknown.
Definition: dtvchannel.h:97
DTVChannel::DTVChannel
DTVChannel(TVRec *parent)
Definition: dtvchannel.h:36
DTVChannel::SetChannelByString
bool SetChannelByString(const QString &chan) override
Definition: dtvchannel.cpp:157
DTVChannel::DeregisterForMaster
void DeregisterForMaster(const QString &key)
Definition: dtvchannel.cpp:121
DTVChannel::GetFormat
QString GetFormat(void)
Definition: dtvchannel.h:46
DTVChannel::GetMasterLock
static DTVChannel * GetMasterLock(const QString &key)
Definition: dtvchannel.cpp:136
channelbase.h
DTVChannel::Tune
bool Tune([[maybe_unused]] const QString &freqid, [[maybe_unused]] int finetune) override
This tunes on the frequency Identification parameter for hardware that supports it.
Definition: dtvchannel.h:75
DTVChannel::Tune
virtual bool Tune(const QString &)
Leave it up to the implementation to map the channnum appropriately.
Definition: dtvchannel.h:63
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:138
DTVChannel::MasterMap
QMap< QString, QList< DTVChannel * > > MasterMap
Definition: dtvchannel.h:177
DTVChannel::m_currentProgramNum
int m_currentProgramNum
Definition: dtvchannel.h:166
DTVTunerType
Definition: dtvconfparserhelpers.h:76
DTVChannel::GetTuningMode
QString GetTuningMode(void) const
Returns tuning mode last set by SetTuningMode().
Definition: dtvchannel.cpp:73
DTVChannel::GetOriginalNetworkID
uint GetOriginalNetworkID(void) const
Returns DVB original_network_id, 0 if unknown.
Definition: dtvchannel.h:101
DTVChannel::m_currentOriginalNetworkID
uint m_currentOriginalNetworkID
Definition: dtvchannel.h:170
DTVChannel::GetTransportID
uint GetTransportID(void) const
Returns DVB transport_stream_id, 0 if unknown.
Definition: dtvchannel.h:105
ChannelBase
Abstract class providing a generic interface to tuning hardware.
Definition: channelbase.h:31
DTVChannel::~DTVChannel
~DTVChannel() override
Definition: dtvchannel.cpp:18
DTVChannel::m_genPMT
ProgramMapTable * m_genPMT
This is a generated PMT for RAW pid tuning.
Definition: dtvchannel.h:175
DTVChannel::SaveCachedPids
void SaveCachedPids(const pid_cache_t &pid_cache) const
Saves MPEG PIDs to cache to database.
Definition: dtvchannel.cpp:107
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:51
pid_cache_t
std::vector< pid_cache_item_t > pid_cache_t
Definition: channelutil.h:43
DTVChannel::GetGeneratedPAT
const ProgramAssociationTable * GetGeneratedPAT(void) const
Definition: dtvchannel.h:137
IPTVTuningData
Definition: iptvtuningdata.h:21
DTVChannel::HasGeneratedPMT
bool HasGeneratedPMT(void) const
Definition: dtvchannel.h:136
DTVChannel::IsMaster
virtual bool IsMaster(void) const
Returns true if this is the first of a number of multi-rec devs.
Definition: dtvchannel.h:129
DTVChannel::Tune
virtual bool Tune(const IPTVTuningData &, bool)
Performs IPTV Tuning. Only implemented by IPTVChannel.
Definition: dtvchannel.h:58
DTVChannel::SetFormat
void SetFormat(const QString &format) override
Definition: dtvchannel.h:44
ProgramAssociationTable
The Program Association Table lists all the programs in a stream, and is always found on PID 0.
Definition: mpegtables.h:617
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:163
channelutil.h
DTVChannel::GetSIStandard
QString GetSIStandard(void) const
Returns PSIP table standard: MPEG, DVB, ATSC, or OpenCable.
Definition: dtvchannel.cpp:45
DTVChannel::HandleScriptEnd
void HandleScriptEnd(bool ok) override
Definition: dtvchannel.cpp:386
DTVChannel::m_tunerType
DTVTunerType m_tunerType
Definition: dtvchannel.h:161
DTVChannel::s_master_map_lock
static QReadWriteLock s_master_map_lock
Definition: dtvchannel.h:178
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:395
DTVChannel::m_genPAT
ProgramAssociationTable * m_genPAT
This is a generated PAT for RAW pid tuning.
Definition: dtvchannel.h:173
DTVChannel::SetTuningMode
void SetTuningMode(const QString &tuning_mode)
Sets tuning mode: "mpeg", "dvb", "atsc", etc.
Definition: dtvchannel.cpp:87
DTVChannel::m_dtvinfoLock
QMutex m_dtvinfoLock
Definition: dtvchannel.h:159
TVRec
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:142
DTVChannel::GetProgramNumber
int GetProgramNumber(void) const
Returns program number in PAT, -1 if unknown.
Definition: dtvchannel.h:89
DTVChannel::Tune
virtual bool Tune([[maybe_unused]] uint64_t frequency)
Definition: dtvchannel.h:81
DTVChannel::SetDTVInfo
void SetDTVInfo(uint atsc_major, uint atsc_minor, uint dvb_orig_netid, uint mpeg_tsid, int mpeg_pnum)
Definition: dtvchannel.cpp:33
DTVChannel::HasGeneratedPAT
bool HasGeneratedPAT(void) const
Definition: dtvchannel.h:135
DTVChannel
Class providing a generic interface to digital tuning hardware.
Definition: dtvchannel.h:33
DTVChannel::GetCachedPids
void GetCachedPids(pid_cache_t &pid_cache) const
Returns cached MPEG PIDs for last tuned channel.
Definition: dtvchannel.cpp:97
DTVChannel::GetSuggestedTuningMode
QString GetSuggestedTuningMode(bool is_live_tv) const
Returns suggested tuning mode: "mpeg", "dvb", or "atsc".
Definition: dtvchannel.cpp:57
DTVChannel::m_tuningMode
QString m_tuningMode
Definition: dtvchannel.h:164
DTVChannel::m_currentATSCMinorChannel
uint m_currentATSCMinorChannel
Definition: dtvchannel.h:168
DTVChannel::m_currentATSCMajorChannel
uint m_currentATSCMajorChannel
Definition: dtvchannel.h:167
dtvconfparserhelpers.h
uint
unsigned int uint
Definition: freesurround.h:24