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