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 
21 typedef vector<DVBMainStreamListener*> dvb_main_listener_vec_t;
22 typedef vector<DVBOtherStreamListener*> dvb_other_listener_vec_t;
23 typedef vector<DVBEITStreamListener*> dvb_eit_listener_vec_t;
24 
25 typedef QMap<uint, bool> dvb_has_eit_t;
26 
27 class MTV_PUBLIC DVBStreamData : virtual public MPEGStreamData
28 {
29  public:
30  DVBStreamData(uint desired_netid, uint desired_tsid,
31  int desired_program, int cardnum, bool cacheTables = false);
32  virtual ~DVBStreamData();
33 
35  void Reset(void) override // MPEGStreamData
36  { Reset(0, 0, -1); }
37  void Reset(uint desired_netid, uint desired_tsid, int desired_serviceid);
38 
39  // DVB table monitoring
40  void SetDesiredService(uint netid, uint tsid, int serviceid);
41  uint DesiredNetworkID(void) const { return _desired_netid; }
42  uint DesiredTransportID(void) const { return _desired_tsid; }
43 
44  // Table processing
45  bool HandleTables(uint pid, const PSIPTable&) override; // MPEGStreamData
46  bool IsRedundant(uint pid, const PSIPTable&) const override; // MPEGStreamData
47  void ProcessSDT(uint tsid, const ServiceDescriptionTable*);
48 
49  // NIT for broken providers
50  inline void SetRealNetworkID(int);
51 
52  // EIT info/processing
53  inline void SetDishNetEIT(bool);
54  inline bool HasAnyEIT(void) const;
55  inline bool HasEIT(uint serviceid) const;
56  bool HasEITPIDChanges(const uint_vec_t &in_use_pids) const override; // MPEGStreamData
57  bool GetEITPIDChanges(const uint_vec_t &cur_pids,
58  uint_vec_t &add_pids,
59  uint_vec_t &del_pids) const override; // MPEGStreamData
60 
61  // Table versions
62  void SetVersionSDT(uint tsid, int version, uint last_section)
63  {
64  _sdt_status.SetVersion(tsid, version, last_section);
65  }
66 
67  void SetVersionSDTo(uint tsid, int version, uint last_section)
68  {
69  _sdto_status.SetVersion(tsid, version, last_section);
70  }
71 
72  // Sections seen
73  bool HasAllNITSections(void) const;
74 
75  bool HasAllNIToSections(void) const;
76 
77  bool HasAllSDTSections(uint tsid) const;
78 
79  bool HasAllSDToSections(uint tsid) const;
80 
81  bool HasAllBATSections(uint bid) const;
82 
83  // Caching
84  bool HasCachedAnyNIT(bool current = true) const;
85  bool HasCachedAllNIT(bool current = true) const;
86  bool HasCachedAnySDT(uint tsid, bool current = true) const;
87  bool HasCachedAllSDT(uint tsid, bool current = true) const;
88  bool HasCachedSDT(bool current = true) const;
89  bool HasCachedAnySDTs(bool current = true) const;
90  bool HasCachedAllSDTs(bool current = true) const;
91 
92  nit_const_ptr_t GetCachedNIT(uint section_num, bool current = true) const;
93  nit_vec_t GetCachedNIT(bool current = true) const;
94  sdt_const_ptr_t GetCachedSDT(uint tsid, uint section_num,
95  bool current = true) const;
96  sdt_vec_t GetCachedSDTSections(uint tsid, bool current = true) const;
97  sdt_vec_t GetCachedSDTs(bool current = true) const;
98 
99  void ReturnCachedSDTTables(sdt_vec_t&) const;
100 
101  void AddDVBMainListener(DVBMainStreamListener*);
102  void AddDVBOtherListener(DVBOtherStreamListener*);
103  void AddDVBEITListener(DVBEITStreamListener*);
104 
105  void RemoveDVBMainListener(DVBMainStreamListener*);
106  void RemoveDVBOtherListener(DVBOtherStreamListener*);
107  void RemoveDVBEITListener(DVBEITStreamListener*);
108 
109  private:
110  // Caching
111  void CacheNIT(NetworkInformationTable*);
112  void CacheSDT(ServiceDescriptionTable*);
113  protected:
114  bool DeleteCachedTable(PSIPTable *psip) const override; // MPEGStreamData
115 
116  private:
120 
121  // Real network ID for broken providers
123 
128 
129  // Signals
133 
134  // Table versions
139 
143 
144  // Caching
145  mutable nit_cache_t _cached_nit; // section -> sdt
146  mutable sdt_cache_t _cached_sdts; // tsid+section -> sdt
147 };
148 
149 inline void DVBStreamData::SetDishNetEIT(bool use_dishnet_eit)
150 {
151  QMutexLocker locker(&_listener_lock);
152  _dvb_eit_dishnet_long = use_dishnet_eit;
153 }
154 
155 inline void DVBStreamData::SetRealNetworkID(int real_network_id)
156 {
157  QMutexLocker locker(&_listener_lock);
158  _dvb_real_network_id = real_network_id;
159 }
160 
161 inline bool DVBStreamData::HasAnyEIT(void) const
162 {
163  QMutexLocker locker(&_listener_lock);
164  return _dvb_has_eit.size();
165 }
166 
167 inline bool DVBStreamData::HasEIT(uint serviceid) const
168 {
169  QMutexLocker locker(&_listener_lock);
170 
171  dvb_has_eit_t::const_iterator it = _dvb_has_eit.find(serviceid);
172  if (it != _dvb_has_eit.end())
173  return *it;
174 
175  return false;
176 }
177 
178 #endif // DVBSTREAMDATA_H_
virtual void Reset(void)
bool HasAnyEIT(void) const
void SetVersionSDTo(uint tsid, int version, uint last_section)
Definition: dvbstreamdata.h:67
void SetVersionSDT(uint tsid, int version, uint last_section)
Definition: dvbstreamdata.h:62
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)
Assembles PSIP packets and processes them.
unsigned int uint
Definition: compat.h:140
dvb_other_listener_vec_t _dvb_other_listeners
uint DesiredTransportID(void) const
Definition: dvbstreamdata.h:42
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
uint DesiredNetworkID(void) const
Definition: dvbstreamdata.h:41
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
vector< const NetworkInformationTable * > nit_vec_t
Definition: dvbstreamdata.h:12
vector< DVBOtherStreamListener * > dvb_other_listener_vec_t
Definition: dvbstreamdata.h:22
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:35
virtual bool DeleteCachedTable(PSIPTable *psip) const
vector< DVBEITStreamListener * > dvb_eit_listener_vec_t
Definition: dvbstreamdata.h:23
void SetDishNetEIT(bool)
bool _dvb_eit_dishnet_long
Decode DishNet's long-term DVB EIT.
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:25
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:21
virtual bool GetEITPIDChanges(const uint_vec_t &, uint_vec_t &, uint_vec_t &) const
ServiceDescriptionTable * sdt_ptr_t
Definition: dvbstreamdata.h:15
Encapsulates data about MPEG stream and emits events for each table.