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 typedef vector<const NetworkInformationTable*> nit_vec_t;
13 typedef QMap<uint, nit_ptr_t> nit_cache_t; // section->sdts
14 
17 typedef vector<const ServiceDescriptionTable*> sdt_vec_t;
18 typedef QMap<uint, sdt_ptr_t> sdt_cache_t; // tsid+section->sdts
19 typedef QMap<uint, sdt_vec_t> sdt_map_t; // tsid->sdts
20 
23 typedef vector<const BouquetAssociationTable*> bat_vec_t;
24 typedef QMap<uint, bat_ptr_t> bat_cache_t; // batid+section->bats
25 
26 typedef vector<DVBMainStreamListener*> dvb_main_listener_vec_t;
27 typedef vector<DVBOtherStreamListener*> dvb_other_listener_vec_t;
28 typedef vector<DVBEITStreamListener*> dvb_eit_listener_vec_t;
29 
30 typedef QMap<uint, bool> dvb_has_eit_t;
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  virtual ~DVBStreamData();
38 
40  void Reset(void) override // MPEGStreamData
41  { Reset(0, 0, -1); }
42  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 _desired_netid; }
47  uint DesiredTransportID(void) const { return _desired_tsid; }
48 
49  // Table processing
50  bool HandleTables(uint pid, const PSIPTable&) override; // MPEGStreamData
51  bool IsRedundant(uint pid, const PSIPTable&) const override; // MPEGStreamData
52  void ProcessSDT(uint tsid, const ServiceDescriptionTable*);
53 
54  // NIT for broken providers
55  inline void SetRealNetworkID(int);
56 
57  // EIT info/processing
58  inline void SetDishNetEIT(bool);
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  _sdt_status.SetVersion(tsid, version, last_section);
70  }
71 
72  void SetVersionSDTo(uint tsid, int version, uint last_section)
73  {
74  _sdto_status.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&) 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*);
114  void AddDVBOtherListener(DVBOtherStreamListener*);
115  void AddDVBEITListener(DVBEITStreamListener*);
116 
117  void RemoveDVBMainListener(DVBMainStreamListener*);
118  void RemoveDVBOtherListener(DVBOtherStreamListener*);
119  void RemoveDVBEITListener(DVBEITStreamListener*);
120 
121  private:
122  // Caching
123  void CacheNIT(NetworkInformationTable*);
124  void CacheSDT(ServiceDescriptionTable*);
125  void CacheBAT(BouquetAssociationTable*);
126 
127  protected:
128  bool DeleteCachedTable(PSIPTable *psip) const override; // MPEGStreamData
129 
130  private:
134 
135  // Real network ID for broken providers
137 
142 
143  // Signals
147 
148  // Table versions
153 
157 
158  // Caching
159  mutable nit_cache_t _cached_nit; // section -> sdt
160  mutable sdt_cache_t _cached_sdts; // tsid+section -> sdt
161  mutable bat_cache_t _cached_bats; // batid+section -> sdt
162 };
163 
164 inline void DVBStreamData::SetDishNetEIT(bool use_dishnet_eit)
165 {
166  QMutexLocker locker(&_listener_lock);
167  _dvb_eit_dishnet_long = use_dishnet_eit;
168 }
169 
170 inline void DVBStreamData::SetRealNetworkID(int real_network_id)
171 {
172  QMutexLocker locker(&_listener_lock);
173  _dvb_real_network_id = real_network_id;
174 }
175 
176 inline bool DVBStreamData::HasAnyEIT(void) const
177 {
178  QMutexLocker locker(&_listener_lock);
179  return _dvb_has_eit.size();
180 }
181 
182 inline bool DVBStreamData::HasEIT(uint serviceid) const
183 {
184  QMutexLocker locker(&_listener_lock);
185 
186  dvb_has_eit_t::const_iterator it = _dvb_has_eit.find(serviceid);
187  if (it != _dvb_has_eit.end())
188  return *it;
189 
190  return false;
191 }
192 
193 #endif // DVBSTREAMDATA_H_
virtual void Reset(void)
bool HasAnyEIT(void) const
void SetVersionSDTo(uint tsid, int version, uint last_section)
Definition: dvbstreamdata.h:72
BouquetAssociationTable const * bat_const_ptr_t
Definition: dvbstreamdata.h:22
void SetVersionSDT(uint tsid, int version, uint last_section)
Definition: dvbstreamdata.h:67
virtual bool IsRedundant(uint pid, const PSIPTable &) const
Returns true if table already seen.
TableStatus _nito_status
This table tells the decoder on which PIDs to find A/V data.
Definition: dvbtables.h:101
dvb_eit_listener_vec_t _dvb_eit_listeners
uint _desired_netid
DVB table monitoring.
ServiceDescriptionTable const * sdt_const_ptr_t
Definition: dvbstreamdata.h:16
TableStatusMap _sdt_status
virtual bool HandleTables(uint pid, const PSIPTable &psip)
Process PSIP packets.
unsigned int uint
Definition: compat.h:140
dvb_other_listener_vec_t _dvb_other_listeners
bat_cache_t _cached_bats
uint DesiredTransportID(void) const
Definition: dvbstreamdata.h:47
bool HasEIT(uint serviceid) const
TableStatusMap _eit_status
int _dvb_real_network_id
NetworkInformationTable const * nit_const_ptr_t
Definition: dvbstreamdata.h:11
QMap< uint, sdt_ptr_t > sdt_cache_t
Definition: dvbstreamdata.h:18
QMap< uint, sdt_vec_t > sdt_map_t
Definition: dvbstreamdata.h:19
A PSIP table is a variant of a PES packet containing an MPEG, ATSC or DVB table.
Definition: mpegtables.h:371
#define MTV_PUBLIC
Definition: mythtvexp.h:15
vector< const BouquetAssociationTable * > bat_vec_t
Definition: dvbstreamdata.h:23
uint DesiredNetworkID(void) const
Definition: dvbstreamdata.h:46
void SetRealNetworkID(int)
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
sdt_cache_t _cached_sdts
TableStatusMap _sdto_status
TableStatusMap _bat_status
BouquetAssociationTable * bat_ptr_t
Definition: dvbstreamdata.h:21
vector< const NetworkInformationTable * > nit_vec_t
Definition: dvbstreamdata.h:12
vector< DVBOtherStreamListener * > dvb_other_listener_vec_t
Definition: dvbstreamdata.h:27
TableStatusMap _cit_status
nit_cache_t _cached_nit
vector< uint > uint_vec_t
dvb_main_listener_vec_t _dvb_main_listeners
void Reset(void) override
Definition: dvbstreamdata.h:40
virtual bool DeleteCachedTable(PSIPTable *psip) const
vector< DVBEITStreamListener * > dvb_eit_listener_vec_t
Definition: dvbstreamdata.h:28
void SetDishNetEIT(bool)
bool _dvb_eit_dishnet_long
Decode DishNet's long-term DVB EIT.
Tells what channels can be found on each transponder for one bouquet (a bunch of channels from one pr...
Definition: dvbtables.h:179
TableStatus _nit_status
QMap< uint, nit_ptr_t > nit_cache_t
Definition: dvbstreamdata.h:13
virtual bool HasEITPIDChanges(const uint_vec_t &) const
QMap< uint, bool > dvb_has_eit_t
Definition: dvbstreamdata.h:30
vector< const ServiceDescriptionTable * > sdt_vec_t
Definition: dvbstreamdata.h:17
dvb_has_eit_t _dvb_has_eit
Tell us if the DVB service has EIT.
NetworkInformationTable * nit_ptr_t
Definition: dvbstreamdata.h:10
This table tells the decoder on which PIDs to find other tables.
Definition: dvbtables.h:21
vector< DVBMainStreamListener * > dvb_main_listener_vec_t
Definition: dvbstreamdata.h:26
virtual bool GetEITPIDChanges(const uint_vec_t &, uint_vec_t &, uint_vec_t &) const
QMap< uint, bat_ptr_t > bat_cache_t
Definition: dvbstreamdata.h:24
ServiceDescriptionTable * sdt_ptr_t
Definition: dvbstreamdata.h:15
Encapsulates data about MPEG stream and emits events for each table.