MythTV  master
dvbstreamdata.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 // Copyright (c) 2003-2004, Daniel Thor Kristjansson
3 #ifndef DVBSTREAMDATA_H_
4 #define DVBSTREAMDATA_H_
5 
6 #include "libmythtv/mythtvexp.h"
7 
8 #include "mpegstreamdata.h"
9 #include "tablestatus.h"
10 
13 using nit_vec_t = std::vector<const NetworkInformationTable*>;
14 using nit_cache_t = QMap<uint, nit_ptr_t>; // section->sdts
15 
18 using sdt_vec_t = std::vector<const ServiceDescriptionTable*>;
19 using sdt_cache_t = QMap<uint, sdt_ptr_t>; // tsid+section->sdts
20 using sdt_map_t = QMap<uint, sdt_vec_t>; // tsid->sdts
21 
24 using bat_vec_t = std::vector<const BouquetAssociationTable*>;
25 using bat_cache_t = QMap<uint, bat_ptr_t>; // batid+section->bats
26 
27 using dvb_main_listener_vec_t = std::vector<DVBMainStreamListener*>;
28 using dvb_other_listener_vec_t = std::vector<DVBOtherStreamListener*>;
29 using dvb_eit_listener_vec_t = std::vector<DVBEITStreamListener*>;
30 
31 using dvb_has_eit_t = QMap<uint, bool>;
32 
33 class MTV_PUBLIC DVBStreamData : virtual public MPEGStreamData
34 {
35  public:
36  DVBStreamData(uint desired_netid, uint desired_tsid,
37  int desired_program, int cardnum, bool cacheTables = false);
38  ~DVBStreamData() override;
39 
41  void Reset(void) override // MPEGStreamData
42  { Reset(0, 0, -1); }
43  virtual void Reset(uint desired_netid, uint desired_tsid, int desired_serviceid);
44 
45  // DVB table monitoring
46  void SetDesiredService(uint netid, uint tsid, int serviceid);
47  uint DesiredNetworkID(void) const { return m_desiredNetId; }
48  uint DesiredTransportID(void) const { return m_desiredTsId; }
49 
50  // Table processing
51  bool HandleTables(uint pid, const PSIPTable &psip) override; // MPEGStreamData
52  bool IsRedundant(uint pid, const PSIPTable &psip) const override; // MPEGStreamData
53  void ProcessSDT(uint tsid, const ServiceDescriptionTable *sdt);
54 
55  // NIT for broken providers
56  inline void SetRealNetworkID(int real_network_id);
57 
58  // EIT info/processing
59  inline void SetDishNetEIT(bool use_dishnet_eit);
60  inline bool HasAnyEIT(void) const;
61  inline bool HasEIT(uint serviceid) const;
62  bool HasEITPIDChanges(const uint_vec_t &in_use_pids) const override; // MPEGStreamData
63  bool GetEITPIDChanges(const uint_vec_t &cur_pids,
64  uint_vec_t &add_pids,
65  uint_vec_t &del_pids) const override; // MPEGStreamData
66 
67  // Table versions
68  void SetVersionSDT(uint tsid, int version, uint last_section)
69  {
70  m_sdtStatus.SetVersion(tsid, version, last_section);
71  }
72 
73  void SetVersionSDTo(uint tsid, int version, uint last_section)
74  {
75  m_sdtoStatus.SetVersion(tsid, version, last_section);
76  }
77 
78  // Sections seen
79  bool HasAllNITSections(void) const;
80 
81  bool HasAllNIToSections(void) const;
82 
83  bool HasAllSDTSections(uint tsid) const;
84 
85  bool HasAllSDToSections(uint tsid) const;
86 
87  bool HasAllBATSections(uint bid) const;
88 
89  // Caching
90  bool HasCachedAnyNIT(bool current = true) const;
91  bool HasCachedAllNIT(bool current = true) const;
92  bool HasCachedAnySDT(uint tsid, bool current = true) const;
93  bool HasCachedAllSDT(uint tsid, bool current = true) const;
94  bool HasCachedSDT(bool current = true) const;
95  bool HasCachedAnySDTs(bool current = true) const;
96  bool HasCachedAllSDTs(bool current = true) const;
97  bool HasCachedAnyBAT(uint batid, bool current = true) const;
98  bool HasCachedAllBAT(uint batid, bool current = true) const;
99  bool HasCachedAnyBATs(bool current = true) const;
100  bool HasCachedAllBATs(bool current = true) const;
101 
102  nit_const_ptr_t GetCachedNIT(uint section_num, bool current = true) const;
103  nit_vec_t GetCachedNIT(bool current = true) const;
104  sdt_const_ptr_t GetCachedSDT(uint tsid, uint section_num,
105  bool current = true) const;
106  sdt_vec_t GetCachedSDTSections(uint tsid, bool current = true) const;
107  sdt_vec_t GetCachedSDTs(bool current = true) const;
108 
109  void ReturnCachedSDTTables(sdt_vec_t &sdts) const;
110 
111  bat_const_ptr_t GetCachedBAT(uint batid, uint section_num, bool current = true) const;
112  bat_vec_t GetCachedBATs(bool current = true) const;
113 
114  void AddDVBMainListener(DVBMainStreamListener *val);
115  void AddDVBOtherListener(DVBOtherStreamListener *val);
116  void AddDVBEITListener(DVBEITStreamListener *val);
117 
118  void RemoveDVBMainListener(DVBMainStreamListener *val);
119  void RemoveDVBOtherListener(DVBOtherStreamListener *val);
120  void RemoveDVBEITListener(DVBEITStreamListener *val);
121 
122  private:
123  // Caching
124  void CacheNIT(NetworkInformationTable *nit);
125  void CacheSDT(ServiceDescriptionTable *sdt);
126  void CacheBAT(BouquetAssociationTable * bat);
127 
128  protected:
129  bool DeleteCachedTable(const PSIPTable *psip) const override; // MPEGStreamData
130 
131  private:
135 
136  // Real network ID for broken providers
137  int m_dvbRealNetworkId { -1 };
138 
140  bool m_dvbEitDishnetLong{ false};
143 
144  // Signals
148 
149  // Table versions
154 
158 
159  // Caching
160  mutable nit_cache_t m_cachedNit; // section -> sdt
161  mutable sdt_cache_t m_cachedSdts; // tsid+section -> sdt
162  mutable bat_cache_t m_cachedBats; // batid+section -> sdt
163 };
164 
165 inline void DVBStreamData::SetDishNetEIT(bool use_dishnet_eit)
166 {
167  QMutexLocker locker(&m_listenerLock);
168  m_dvbEitDishnetLong = use_dishnet_eit;
169 }
170 
171 inline void DVBStreamData::SetRealNetworkID(int real_network_id)
172 {
173  QMutexLocker locker(&m_listenerLock);
174  m_dvbRealNetworkId = real_network_id;
175 }
176 
177 inline bool DVBStreamData::HasAnyEIT(void) const
178 {
179  QMutexLocker locker(&m_listenerLock);
180  return !m_dvbHasEit.empty();
181 }
182 
183 inline bool DVBStreamData::HasEIT(uint serviceid) const
184 {
185  QMutexLocker locker(&m_listenerLock);
186 
187  dvb_has_eit_t::const_iterator it = m_dvbHasEit.find(serviceid);
188  if (it != m_dvbHasEit.end())
189  return *it;
190 
191  return false;
192 }
193 
194 #endif // DVBSTREAMDATA_H_
DVBStreamData::DesiredTransportID
uint DesiredTransportID(void) const
Definition: dvbstreamdata.h:48
dvb_other_listener_vec_t
std::vector< DVBOtherStreamListener * > dvb_other_listener_vec_t
Definition: dvbstreamdata.h:28
DVBStreamData::SetVersionSDT
void SetVersionSDT(uint tsid, int version, uint last_section)
Definition: dvbstreamdata.h:68
MPEGStreamData::DeleteCachedTable
virtual bool DeleteCachedTable(const PSIPTable *psip) const
Definition: mpegstreamdata.cpp:1521
dvb_has_eit_t
QMap< uint, bool > dvb_has_eit_t
Definition: dvbstreamdata.h:31
DVBStreamData::m_dvbEitListeners
dvb_eit_listener_vec_t m_dvbEitListeners
Definition: dvbstreamdata.h:147
bat_cache_t
QMap< uint, bat_ptr_t > bat_cache_t
Definition: dvbstreamdata.h:25
DVBStreamData::m_batStatus
TableStatusMap m_batStatus
Definition: dvbstreamdata.h:157
mythtvexp.h
MPEGStreamData::IsRedundant
virtual bool IsRedundant(uint pid, const PSIPTable &psip) const
Returns true if table already seen.
Definition: mpegstreamdata.cpp:642
DVBStreamData::m_eitStatus
TableStatusMap m_eitStatus
Definition: dvbstreamdata.h:152
bat_const_ptr_t
BouquetAssociationTable const * bat_const_ptr_t
Definition: dvbstreamdata.h:23
DVBStreamData::m_cachedSdts
sdt_cache_t m_cachedSdts
Definition: dvbstreamdata.h:161
DVBStreamData::Reset
void Reset(void) override
Definition: dvbstreamdata.h:41
DVBStreamData::m_dvbHasEit
dvb_has_eit_t m_dvbHasEit
Tell us if the DVB service has EIT.
Definition: dvbstreamdata.h:142
uint_vec_t
std::vector< uint > uint_vec_t
Definition: mpegstreamdata.h:24
bat_vec_t
std::vector< const BouquetAssociationTable * > bat_vec_t
Definition: dvbstreamdata.h:24
sdt_map_t
QMap< uint, sdt_vec_t > sdt_map_t
Definition: dvbstreamdata.h:20
DVBStreamData::m_sdtStatus
TableStatusMap m_sdtStatus
Definition: dvbstreamdata.h:151
nit_const_ptr_t
NetworkInformationTable const * nit_const_ptr_t
Definition: dvbstreamdata.h:12
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:15
DVBStreamData::m_sdtoStatus
TableStatusMap m_sdtoStatus
Definition: dvbstreamdata.h:156
PSIPTable
A PSIP table is a variant of a PES packet containing an MPEG, ATSC or DVB table.
Definition: mpegtables.h:409
DVBStreamData::SetDishNetEIT
void SetDishNetEIT(bool use_dishnet_eit)
Definition: dvbstreamdata.h:165
sdt_vec_t
std::vector< const ServiceDescriptionTable * > sdt_vec_t
Definition: dvbstreamdata.h:18
DVBStreamData::HasEIT
bool HasEIT(uint serviceid) const
Definition: dvbstreamdata.h:183
sdt_const_ptr_t
ServiceDescriptionTable const * sdt_const_ptr_t
Definition: dvbstreamdata.h:17
MPEGStreamData::m_listenerLock
QRecursiveMutex m_listenerLock
Definition: mpegstreamdata.h:345
MPEGStreamData::HandleTables
virtual bool HandleTables(uint pid, const PSIPTable &psip)
Process PSIP packets.
Definition: mpegstreamdata.cpp:669
DVBStreamData::m_dvbMainListeners
dvb_main_listener_vec_t m_dvbMainListeners
Definition: dvbstreamdata.h:145
MPEGStreamData
Encapsulates data about MPEG stream and emits events for each table.
Definition: mpegstreamdata.h:85
dvb_main_listener_vec_t
std::vector< DVBMainStreamListener * > dvb_main_listener_vec_t
Definition: dvbstreamdata.h:27
dvb_eit_listener_vec_t
std::vector< DVBEITStreamListener * > dvb_eit_listener_vec_t
Definition: dvbstreamdata.h:29
ServiceDescriptionTable
This table tells the decoder on which PIDs to find A/V data.
Definition: dvbtables.h:110
DVBStreamData
Definition: dvbstreamdata.h:33
TableStatusMap
Definition: tablestatus.h:35
tablestatus.h
DVBStreamData::HasAnyEIT
bool HasAnyEIT(void) const
Definition: dvbstreamdata.h:177
uint
unsigned int uint
Definition: compat.h:79
TableStatus
Definition: tablestatus.h:14
mpegstreamdata.h
sdt_cache_t
QMap< uint, sdt_ptr_t > sdt_cache_t
Definition: dvbstreamdata.h:19
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
DVBStreamData::m_citStatus
TableStatusMap m_citStatus
Definition: dvbstreamdata.h:153
DVBStreamData::m_dvbOtherListeners
dvb_other_listener_vec_t m_dvbOtherListeners
Definition: dvbstreamdata.h:146
DVBMainStreamListener
Definition: streamlisteners.h:172
BouquetAssociationTable
Tells what channels can be found on each transponder for one bouquet (a bunch of channels from one pr...
Definition: dvbtables.h:189
nit_vec_t
std::vector< const NetworkInformationTable * > nit_vec_t
Definition: dvbstreamdata.h:13
DVBStreamData::m_desiredTsId
uint m_desiredTsId
Definition: dvbstreamdata.h:134
DVBStreamData::m_cachedNit
nit_cache_t m_cachedNit
Definition: dvbstreamdata.h:160
DVBStreamData::m_nitStatus
TableStatus m_nitStatus
Definition: dvbstreamdata.h:150
MPEGStreamData::Reset
virtual void Reset(void)
Definition: mpegstreamdata.h:94
DVBOtherStreamListener
Definition: streamlisteners.h:182
DVBStreamData::SetVersionSDTo
void SetVersionSDTo(uint tsid, int version, uint last_section)
Definition: dvbstreamdata.h:73
MPEGStreamData::GetEITPIDChanges
virtual bool GetEITPIDChanges(const uint_vec_t &, uint_vec_t &, uint_vec_t &) const
Definition: mpegstreamdata.h:105
DVBStreamData::m_nitoStatus
TableStatus m_nitoStatus
Definition: dvbstreamdata.h:155
DVBStreamData::m_cachedBats
bat_cache_t m_cachedBats
Definition: dvbstreamdata.h:162
nit_cache_t
QMap< uint, nit_ptr_t > nit_cache_t
Definition: dvbstreamdata.h:14
MPEGStreamData::HasEITPIDChanges
virtual bool HasEITPIDChanges(const uint_vec_t &) const
Definition: mpegstreamdata.h:103
DVBEITStreamListener
Definition: streamlisteners.h:192
nv_python_libs.bbciplayer.bbciplayer_api.version
string version
Definition: bbciplayer_api.py:77
DVBStreamData::m_dvbEitDishnetLong
bool m_dvbEitDishnetLong
Decode DishNet's long-term DVB EIT.
Definition: dvbstreamdata.h:140
DVBStreamData::m_dvbRealNetworkId
int m_dvbRealNetworkId
Definition: dvbstreamdata.h:137
DVBStreamData::SetRealNetworkID
void SetRealNetworkID(int real_network_id)
Definition: dvbstreamdata.h:171
DVBStreamData::DesiredNetworkID
uint DesiredNetworkID(void) const
Definition: dvbstreamdata.h:47
NetworkInformationTable
This table tells the decoder on which PIDs to find other tables.
Definition: dvbtables.h:30
DVBStreamData::m_desiredNetId
uint m_desiredNetId
DVB table monitoring.
Definition: dvbstreamdata.h:133