MythTV  master
atscstreamdata.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 // Copyright (c) 2003-2004, Daniel Thor Kristjansson
3 #ifndef ATSCSTREAMDATA_H_
4 #define ATSCSTREAMDATA_H_
5 
6 #include "mpegstreamdata.h"
7 #include "mythtvexp.h"
8 #include "tablestatus.h"
9 
10 typedef QMap<uint, uint_vec_t> pid_tsid_vec_t;
15 typedef vector<const TerrestrialVirtualChannelTable*> tvct_vec_t;
16 typedef vector<const CableVirtualChannelTable*> cvct_vec_t;
17 typedef QMap<uint, tvct_ptr_t> tvct_cache_t;
18 typedef QMap<uint, cvct_ptr_t> cvct_cache_t;
19 typedef QMap<uint, uint> atsc_eit_pid_map_t;
20 typedef QMap<uint, uint> atsc_ett_pid_map_t;
21 
22 typedef vector<ATSCMainStreamListener*> atsc_main_listener_vec_t;
23 typedef vector<SCTEMainStreamListener*> scte_main_listener_vec_t;
24 typedef vector<ATSCAuxStreamListener*> atsc_aux_listener_vec_t;
25 typedef vector<ATSCEITStreamListener*> atsc_eit_listener_vec_t;
26 typedef vector<ATSC81EITStreamListener*> atsc81_eit_listener_vec_t;
27 
29 {
30  public:
31  ATSCStreamData(int desiredMajorChannel,
32  int desiredMinorChannel,
33  int cardnum, bool cacheTables = false);
34  virtual ~ATSCStreamData();
35 
36  void Reset(void) override { Reset(-1, -1); } // MPEGStreamData
37  void Reset(int desiredProgram) override; // MPEGStreamData
38  void Reset(int desiredMajorChannel, int desiredMinorChannel);
39  void SetDesiredChannel(int major, int minor);
40 
41  // Table processing
42  bool HandleTables(uint pid, const PSIPTable &psip) override; // MPEGStreamData
43  bool IsRedundant(uint, const PSIPTable&) const override; // MPEGStreamData
44 
46  uint GPSOffset(void) const { return _GPS_UTC_offset; }
47 
48  inline uint GetATSCMajorMinor(uint eit_sourceid) const;
49  inline bool HasATSCMajorMinorMap(void) const;
50  bool HasEITPIDChanges(const uint_vec_t &in_use_pid) const override; // MPEGStreamData
51  bool GetEITPIDChanges(const uint_vec_t &cur_pids,
52  uint_vec_t &add_pids,
53  uint_vec_t &del_pids) const override; // MPEGStreamData
54 
55  // Table versions
57  { _mgt_version = version; }
58  void SetVersionTVCT(uint tsid, int version)
59  { _tvct_version[tsid] = version; }
60  void SetVersionCVCT(uint tsid, int version)
61  { _cvct_version[tsid] = version; }
62  void SetVersionRRT(uint region, int version)
63  { _rrt_version[region&0xff] = version; }
64 
65  int VersionMGT() const { return _mgt_version; }
66  inline int VersionTVCT(uint tsid) const;
67  inline int VersionCVCT(uint tsid) const;
68  inline int VersionRRT(uint region) const;
69 
70  // Caching
71  bool HasCachedMGT(bool current = true) const;
72  bool HasCachedTVCT(uint pid, bool current = true) const;
73  bool HasCachedCVCT(uint pid, bool current = true) const;
74 
75  bool HasCachedAllTVCTs(bool current = true) const;
76  bool HasCachedAllCVCTs(bool current = true) const;
77  bool HasCachedAllVCTs(bool current = true) const
78  { return HasCachedAllTVCTs(current) && HasCachedAllCVCTs(current); }
79 
80  bool HasCachedAnyTVCTs(bool current = true) const;
81  bool HasCachedAnyCVCTs(bool current = true) const;
82  bool HasCachedAnyVCTs(bool current = true) const
83  { return HasCachedAnyTVCTs(current) || HasCachedAnyCVCTs(current); }
84 
85  const MasterGuideTable *GetCachedMGT(bool current = true) const;
86  tvct_const_ptr_t GetCachedTVCT(uint pid, bool current = true) const;
87  cvct_const_ptr_t GetCachedCVCT(uint pid, bool current = true) const;
88 
89  tvct_vec_t GetCachedTVCTs(bool current = true) const;
90  cvct_vec_t GetCachedCVCTs(bool current = true) const;
91 
92  void ReturnCachedTVCTTables(tvct_vec_t&) const;
93  void ReturnCachedCVCTTables(cvct_vec_t&) const;
94 
95  bool HasChannel(uint major, uint minor) const;
96 
97  // Single channel stuff
98  int DesiredMajorChannel(void) const { return _desired_major_channel; }
99  int DesiredMinorChannel(void) const { return _desired_minor_channel; }
100 
101  void AddATSCMainListener(ATSCMainStreamListener*);
102  void AddSCTEMainListener(SCTEMainStreamListener*);
103  void AddATSCAuxListener(ATSCAuxStreamListener*);
104  void AddATSCEITListener(ATSCEITStreamListener*);
105  void AddATSC81EITListener(ATSC81EITStreamListener*);
106 
107  void RemoveATSCMainListener(ATSCMainStreamListener*);
108  void RemoveSCTEMainListener(SCTEMainStreamListener*);
109  void RemoveATSCAuxListener(ATSCAuxStreamListener*);
110  void RemoveATSCEITListener(ATSCEITStreamListener*);
111  void RemoveATSC81EITListener(ATSC81EITStreamListener*);
112 
113  private:
114  void ProcessMGT(const MasterGuideTable*);
115  void ProcessVCT(uint tsid, const VirtualChannelTable*);
116  void ProcessTVCT(uint tsid, const TerrestrialVirtualChannelTable*);
117  void ProcessCVCT(uint tsid, const CableVirtualChannelTable*);
118 
119  // Caching
120  void CacheMGT(MasterGuideTable*);
121  void CacheTVCT(uint pid, TerrestrialVirtualChannelTable*);
122  void CacheCVCT(uint pid, CableVirtualChannelTable*);
123  protected:
124  bool DeleteCachedTable(const PSIPTable *psip) const override; // MPEGStreamData
125 
126  private:
128  mutable bool _atsc_eit_reset;
131 
132  QMap<uint,uint> _sourceid_to_atsc_maj_min;
133 
134 
135  // Signals
141 
142  // Table versions
144  QMap<uint, int> _tvct_version;
145  QMap<uint, int> _cvct_version;
146  QMap<uint, int> _rrt_version;
148 
149  // Caching
151  mutable tvct_cache_t _cached_tvcts; // pid->tvct
152  mutable cvct_cache_t _cached_cvcts; // pid->cvct
153 
154  // Single program variables
157 };
158 
159 
160 inline uint ATSCStreamData::GetATSCMajorMinor(uint eit_sourceid) const
161 {
162  QMutexLocker locker(&_listener_lock);
163  return _sourceid_to_atsc_maj_min[eit_sourceid];
164 }
165 
167 {
168  QMutexLocker locker(&_listener_lock);
169  return !_sourceid_to_atsc_maj_min.empty();
170 }
171 
172 inline int ATSCStreamData::VersionTVCT(uint tsid) const
173 {
174  const QMap<uint, int>::const_iterator it = _tvct_version.find(tsid);
175  if (it == _tvct_version.end())
176  return -1;
177  return *it;
178 }
179 
180 inline int ATSCStreamData::VersionCVCT(uint tsid) const
181 {
182  const QMap<uint, int>::const_iterator it = _cvct_version.find(tsid);
183  if (it == _cvct_version.end())
184  return -1;
185  return *it;
186 }
187 
188 inline int ATSCStreamData::VersionRRT(uint region) const
189 {
190  const QMap<uint, int>::const_iterator it = _rrt_version.find(region&0xff);
191  if (it == _rrt_version.end())
192  return -1;
193  return *it;
194 }
195 
196 #endif
QMap< uint, uint > _sourceid_to_atsc_maj_min
virtual void Reset(void)
int VersionTVCT(uint tsid) const
void SetVersionRRT(uint region, int version)
virtual bool IsRedundant(uint pid, const PSIPTable &) const
Returns true if table already seen.
int DesiredMinorChannel(void) const
void SetVersionCVCT(uint tsid, int version)
int VersionMGT() const
atsc_aux_listener_vec_t _atsc_aux_listeners
atsc_ett_pid_map_t _atsc_ett_pids
TerrestrialVirtualChannelTable * tvct_ptr_t
void SetVersionTVCT(uint tsid, int version)
virtual bool HandleTables(uint pid, const PSIPTable &psip)
Process PSIP packets.
QMap< uint, int > _cvct_version
CableVirtualChannelTable * cvct_ptr_t
virtual bool DeleteCachedTable(const PSIPTable *psip) const
atsc_eit_listener_vec_t _atsc_eit_listeners
int DesiredMajorChannel(void) const
vector< ATSCEITStreamListener * > atsc_eit_listener_vec_t
tvct_cache_t _cached_tvcts
QMap< uint, uint > atsc_eit_pid_map_t
QMap< uint, int > _tvct_version
QMap< uint, uint_vec_t > pid_tsid_vec_t
A PSIP table is a variant of a PES packet containing an MPEG, ATSC or DVB table.
Definition: mpegtables.h:371
bool HasCachedAnyVCTs(bool current=true) const
This table contains information about the cable channels transmitted on this multiplex.
Definition: atsctables.h:415
bool HasATSCMajorMinorMap(void) const
QMap< uint, uint > atsc_ett_pid_map_t
#define MTV_PUBLIC
Definition: mythtvexp.h:15
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
vector< ATSC81EITStreamListener * > atsc81_eit_listener_vec_t
MasterGuideTable * _cached_mgt
#define minor(X)
Definition: compat.h:138
vector< const CableVirtualChannelTable * > cvct_vec_t
vector< const TerrestrialVirtualChannelTable * > tvct_vec_t
unsigned int uint
Definition: compat.h:140
vector< uint > uint_vec_t
QMap< uint, cvct_ptr_t > cvct_cache_t
atsc_main_listener_vec_t _atsc_main_listeners
int VersionCVCT(uint tsid) const
This table tells the decoder on which PIDs to find other tables, and their sizes and each table's cur...
Definition: atsctables.h:74
vector< ATSCAuxStreamListener * > atsc_aux_listener_vec_t
atsc_eit_pid_map_t _atsc_eit_pids
atsc81_eit_listener_vec_t _atsc81_eit_listeners
uint GPSOffset(void) const
Current UTC to GPS time offset in seconds.
TerrestrialVirtualChannelTable const * tvct_const_ptr_t
void SetVersionMGT(int version)
QMap< uint, tvct_ptr_t > tvct_cache_t
TableStatusMap _eit_status
bool HasCachedAllVCTs(bool current=true) const
This table contains information about the channels transmitted on this multiplex.
Definition: atsctables.h:189
uint GetATSCMajorMinor(uint eit_sourceid) const
int VersionRRT(uint region) const
virtual bool HasEITPIDChanges(const uint_vec_t &) const
CableVirtualChannelTable const * cvct_const_ptr_t
This table contains information about the terrestrial channels transmitted on this multiplex.
Definition: atsctables.h:346
Encapsulates data about ATSC stream and emits events for most tables.
cvct_cache_t _cached_cvcts
virtual bool GetEITPIDChanges(const uint_vec_t &, uint_vec_t &, uint_vec_t &) const
vector< ATSCMainStreamListener * > atsc_main_listener_vec_t
vector< SCTEMainStreamListener * > scte_main_listener_vec_t
Encapsulates data about MPEG stream and emits events for each table.
scte_main_listener_vec_t _scte_main_listeners
QMap< uint, int > _rrt_version
void Reset(void) override