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 "libmythtv/mythtvexp.h"
7 
8 #include "mpegstreamdata.h"
9 #include "tablestatus.h"
10 
11 using pid_tsid_vec_t = QMap<uint, uint_vec_t>;
16 using tvct_vec_t = std::vector<const TerrestrialVirtualChannelTable *>;
17 using cvct_vec_t = std::vector<const CableVirtualChannelTable *>;
18 using tvct_cache_t = QMap<uint, tvct_ptr_t>;
19 using cvct_cache_t = QMap<uint, cvct_ptr_t>;
20 using atsc_eit_pid_map_t = QMap<uint, uint>;
21 using atsc_ett_pid_map_t = QMap<uint, uint>;
22 
23 using atsc_main_listener_vec_t = std::vector<ATSCMainStreamListener *>;
24 using scte_main_listener_vec_t = std::vector<SCTEMainStreamListener *>;
25 using atsc_aux_listener_vec_t = std::vector<ATSCAuxStreamListener *>;
26 using atsc_eit_listener_vec_t = std::vector<ATSCEITStreamListener *>;
27 using atsc81_eit_listener_vec_t = std::vector<ATSC81EITStreamListener *>;
28 
30 {
31  public:
32  ATSCStreamData(int desiredMajorChannel,
33  int desiredMinorChannel,
34  int cardnum, bool cacheTables = false);
35  ~ATSCStreamData() override;
36 
37  void Reset(void) override { Reset(-1, -1); } // MPEGStreamData
38  void Reset(int desiredProgram) override; // MPEGStreamData
39  void Reset(int desiredMajorChannel, int desiredMinorChannel);
40  void SetDesiredChannel(int major, int minor);
41 
42  // Table processing
43  bool HandleTables(uint pid, const PSIPTable &psip) override; // MPEGStreamData
44  bool IsRedundant(uint pid, const PSIPTable &psip) const override; // MPEGStreamData
45 
47  uint GPSOffset(void) const { return m_gpsUtcOffset; }
48 
49  inline uint GetATSCMajorMinor(uint eit_sourceid) const;
50  inline bool HasATSCMajorMinorMap(void) const;
51  bool HasEITPIDChanges(const uint_vec_t &in_use_pid) const override; // MPEGStreamData
52  bool GetEITPIDChanges(const uint_vec_t &cur_pids,
53  uint_vec_t &add_pids,
54  uint_vec_t &del_pids) const override; // MPEGStreamData
55 
56  // Table versions
58  { m_mgtVersion = version; }
59  void SetVersionTVCT(uint tsid, int version)
60  { m_tvctVersion[tsid] = version; }
61  void SetVersionCVCT(uint tsid, int version)
62  { m_cvctVersion[tsid] = version; }
63  void SetVersionRRT(uint region, int version)
64  { m_rrtVersion[region&0xff] = version; }
65 
66  int VersionMGT() const { return m_mgtVersion; }
67  inline int VersionTVCT(uint tsid) const;
68  inline int VersionCVCT(uint tsid) const;
69  inline int VersionRRT(uint region) const;
70 
71  // Caching
72  bool HasCachedMGT(bool current = true) const;
73  bool HasCachedTVCT(uint pid, bool current = true) const;
74  bool HasCachedCVCT(uint pid, bool current = true) const;
75 
76  bool HasCachedAllTVCTs(bool current = true) const;
77  bool HasCachedAllCVCTs(bool current = true) const;
78  bool HasCachedAllVCTs(bool current = true) const
79  { return HasCachedAllTVCTs(current) && HasCachedAllCVCTs(current); }
80 
81  bool HasCachedAnyTVCTs(bool current = true) const;
82  bool HasCachedAnyCVCTs(bool current = true) const;
83  bool HasCachedAnyVCTs(bool current = true) const
84  { return HasCachedAnyTVCTs(current) || HasCachedAnyCVCTs(current); }
85 
86  const MasterGuideTable *GetCachedMGT(bool current = true) const;
87  tvct_const_ptr_t GetCachedTVCT(uint pid, bool current = true) const;
88  cvct_const_ptr_t GetCachedCVCT(uint pid, bool current = true) const;
89 
90  tvct_vec_t GetCachedTVCTs(bool current = true) const;
91  cvct_vec_t GetCachedCVCTs(bool current = true) const;
92 
93  void ReturnCachedTVCTTables(tvct_vec_t &tvcts) const;
94  void ReturnCachedCVCTTables(cvct_vec_t &cvcts) const;
95 
96  bool HasChannel(uint major, uint minor) const;
97 
98  // Single channel stuff
99  int DesiredMajorChannel(void) const { return m_desiredMajorChannel; }
100  int DesiredMinorChannel(void) const { return m_desiredMinorChannel; }
101 
102  void AddATSCMainListener(ATSCMainStreamListener *val);
103  void AddSCTEMainListener(SCTEMainStreamListener *val);
104  void AddATSCAuxListener(ATSCAuxStreamListener *val);
105  void AddATSCEITListener(ATSCEITStreamListener *val);
106  void AddATSC81EITListener(ATSC81EITStreamListener *val);
107 
108  void RemoveATSCMainListener(ATSCMainStreamListener *val);
109  void RemoveSCTEMainListener(SCTEMainStreamListener *val);
110  void RemoveATSCAuxListener(ATSCAuxStreamListener *val);
111  void RemoveATSCEITListener(ATSCEITStreamListener *val);
112  void RemoveATSC81EITListener(ATSC81EITStreamListener *val);
113 
114  private:
115  void ProcessMGT(const MasterGuideTable *mgt);
116  void ProcessVCT(uint tsid, const VirtualChannelTable *vct);
117  void ProcessTVCT(uint tsid, const TerrestrialVirtualChannelTable *vct);
118  void ProcessCVCT(uint tsid, const CableVirtualChannelTable *vct);
119 
120  // Caching
121  void CacheMGT(MasterGuideTable *mgt);
122  void CacheTVCT(uint pid, TerrestrialVirtualChannelTable *tvct);
123  void CacheCVCT(uint pid, CableVirtualChannelTable *cvct);
124  protected:
125  bool DeleteCachedTable(const PSIPTable *psip) const override; // MPEGStreamData
126 
127  private:
128  uint m_gpsUtcOffset { GPS_LEAP_SECONDS };
129  mutable bool m_atscEitReset { false };
132 
133  QMap<uint,uint> m_sourceIdToAtscMajMin;
134 
135 
136  // Signals
142 
143  // Table versions
144  int m_mgtVersion { -1 };
145  QMap<uint, int> m_tvctVersion;
146  QMap<uint, int> m_cvctVersion;
147  QMap<uint, int> m_rrtVersion;
149 
150  // Caching
151  mutable MasterGuideTable *m_cachedMgt { nullptr };
152  mutable tvct_cache_t m_cachedTvcts; // pid->tvct
153  mutable cvct_cache_t m_cachedCvcts; // pid->cvct
154 
155  // Single program variables
158 };
159 
160 
161 inline uint ATSCStreamData::GetATSCMajorMinor(uint eit_sourceid) const
162 {
163  QMutexLocker locker(&m_listenerLock);
164  return m_sourceIdToAtscMajMin[eit_sourceid];
165 }
166 
168 {
169  QMutexLocker locker(&m_listenerLock);
170  return !m_sourceIdToAtscMajMin.empty();
171 }
172 
173 inline int ATSCStreamData::VersionTVCT(uint tsid) const
174 {
175  const QMap<uint, int>::const_iterator it = m_tvctVersion.find(tsid);
176  if (it == m_tvctVersion.end())
177  return -1;
178  return *it;
179 }
180 
181 inline int ATSCStreamData::VersionCVCT(uint tsid) const
182 {
183  const QMap<uint, int>::const_iterator it = m_cvctVersion.find(tsid);
184  if (it == m_cvctVersion.end())
185  return -1;
186  return *it;
187 }
188 
189 inline int ATSCStreamData::VersionRRT(uint region) const
190 {
191  const QMap<uint, int>::const_iterator it = m_rrtVersion.find(region&0xff);
192  if (it == m_rrtVersion.end())
193  return -1;
194  return *it;
195 }
196 
197 #endif
VirtualChannelTable
This table contains information about the channels transmitted on this multiplex.
Definition: atsctables.h:192
ATSCStreamData::m_atscAuxListeners
atsc_aux_listener_vec_t m_atscAuxListeners
Definition: atscstreamdata.h:139
ATSCStreamData::VersionTVCT
int VersionTVCT(uint tsid) const
Definition: atscstreamdata.h:173
ATSCMainStreamListener
Definition: streamlisteners.h:112
pid_tsid_vec_t
QMap< uint, uint_vec_t > pid_tsid_vec_t
Definition: atscstreamdata.h:11
atsc_main_listener_vec_t
std::vector< ATSCMainStreamListener * > atsc_main_listener_vec_t
Definition: atscstreamdata.h:23
cvct_vec_t
std::vector< const CableVirtualChannelTable * > cvct_vec_t
Definition: atscstreamdata.h:17
atsc_eit_listener_vec_t
std::vector< ATSCEITStreamListener * > atsc_eit_listener_vec_t
Definition: atscstreamdata.h:26
MPEGStreamData::DeleteCachedTable
virtual bool DeleteCachedTable(const PSIPTable *psip) const
Definition: mpegstreamdata.cpp:1538
ATSCStreamData::m_cvctVersion
QMap< uint, int > m_cvctVersion
Definition: atscstreamdata.h:146
ATSCStreamData::DesiredMinorChannel
int DesiredMinorChannel(void) const
Definition: atscstreamdata.h:100
mythtvexp.h
tvct_vec_t
std::vector< const TerrestrialVirtualChannelTable * > tvct_vec_t
Definition: atscstreamdata.h:16
ATSCStreamData::m_tvctVersion
QMap< uint, int > m_tvctVersion
Definition: atscstreamdata.h:145
ATSCStreamData::m_sourceIdToAtscMajMin
QMap< uint, uint > m_sourceIdToAtscMajMin
Definition: atscstreamdata.h:133
MPEGStreamData::IsRedundant
virtual bool IsRedundant(uint pid, const PSIPTable &psip) const
Returns true if table already seen.
Definition: mpegstreamdata.cpp:641
ATSCStreamData::m_atscEttPids
atsc_ett_pid_map_t m_atscEttPids
Definition: atscstreamdata.h:131
uint_vec_t
std::vector< uint > uint_vec_t
Definition: mpegstreamdata.h:24
GPS_LEAP_SECONDS
static constexpr uint8_t GPS_LEAP_SECONDS
Leap seconds as of June 30th, 2022.
Definition: mpegtables.h:34
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:14
ATSCStreamData::VersionRRT
int VersionRRT(uint region) const
Definition: atscstreamdata.h:189
ATSCStreamData::Reset
void Reset(void) override
Definition: atscstreamdata.h:37
ATSCStreamData::SetVersionMGT
void SetVersionMGT(int version)
Definition: atscstreamdata.h:57
PSIPTable
A PSIP table is a variant of a PES packet containing an MPEG, ATSC or DVB table.
Definition: mpegtables.h:409
ATSCStreamData::GPSOffset
uint GPSOffset(void) const
Current UTC to GPS time offset in seconds.
Definition: atscstreamdata.h:47
ATSCStreamData::m_atscEitPids
atsc_eit_pid_map_t m_atscEitPids
Definition: atscstreamdata.h:130
scte_main_listener_vec_t
std::vector< SCTEMainStreamListener * > scte_main_listener_vec_t
Definition: atscstreamdata.h:24
ATSCStreamData::m_atscEitListeners
atsc_eit_listener_vec_t m_atscEitListeners
Definition: atscstreamdata.h:140
minor
#define minor(X)
Definition: compat.h:76
ATSCStreamData::HasATSCMajorMinorMap
bool HasATSCMajorMinorMap(void) const
Definition: atscstreamdata.h:167
ATSC81EITStreamListener
Definition: streamlisteners.h:163
ATSCStreamData::m_cachedCvcts
cvct_cache_t m_cachedCvcts
Definition: atscstreamdata.h:153
ATSCStreamData
Encapsulates data about ATSC stream and emits events for most tables.
Definition: atscstreamdata.h:29
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:668
ATSCAuxStreamListener
Definition: streamlisteners.h:122
ATSCStreamData::VersionMGT
int VersionMGT() const
Definition: atscstreamdata.h:66
MPEGStreamData
Encapsulates data about MPEG stream and emits events for each table.
Definition: mpegstreamdata.h:85
ATSCStreamData::m_cachedTvcts
tvct_cache_t m_cachedTvcts
Definition: atscstreamdata.h:152
TableStatusMap
Definition: tablestatus.h:35
tvct_cache_t
QMap< uint, tvct_ptr_t > tvct_cache_t
Definition: atscstreamdata.h:18
tablestatus.h
ATSCStreamData::m_desiredMinorChannel
int m_desiredMinorChannel
Definition: atscstreamdata.h:157
uint
unsigned int uint
Definition: compat.h:79
ATSCStreamData::m_rrtVersion
QMap< uint, int > m_rrtVersion
Definition: atscstreamdata.h:147
ATSCStreamData::m_desiredMajorChannel
int m_desiredMajorChannel
Definition: atscstreamdata.h:156
ATSCStreamData::SetVersionRRT
void SetVersionRRT(uint region, int version)
Definition: atscstreamdata.h:63
ATSCStreamData::m_scteMainlisteners
scte_main_listener_vec_t m_scteMainlisteners
Definition: atscstreamdata.h:138
ATSCStreamData::DesiredMajorChannel
int DesiredMajorChannel(void) const
Definition: atscstreamdata.h:99
mpegstreamdata.h
cvct_cache_t
QMap< uint, cvct_ptr_t > cvct_cache_t
Definition: atscstreamdata.h:19
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
MasterGuideTable
This table tells the decoder on which PIDs to find other tables, and their sizes and each table's cur...
Definition: atsctables.h:77
atsc_ett_pid_map_t
QMap< uint, uint > atsc_ett_pid_map_t
Definition: atscstreamdata.h:21
ATSCStreamData::HasCachedAllVCTs
bool HasCachedAllVCTs(bool current=true) const
Definition: atscstreamdata.h:78
SCTEMainStreamListener
Definition: streamlisteners.h:144
TerrestrialVirtualChannelTable
This table contains information about the terrestrial channels transmitted on this multiplex.
Definition: atsctables.h:348
atsc81_eit_listener_vec_t
std::vector< ATSC81EITStreamListener * > atsc81_eit_listener_vec_t
Definition: atscstreamdata.h:27
MPEGStreamData::Reset
virtual void Reset(void)
Definition: mpegstreamdata.h:94
atsc_aux_listener_vec_t
std::vector< ATSCAuxStreamListener * > atsc_aux_listener_vec_t
Definition: atscstreamdata.h:25
ATSCStreamData::m_atsc81EitListeners
atsc81_eit_listener_vec_t m_atsc81EitListeners
Definition: atscstreamdata.h:141
ATSCStreamData::GetATSCMajorMinor
uint GetATSCMajorMinor(uint eit_sourceid) const
Definition: atscstreamdata.h:161
CableVirtualChannelTable
This table contains information about the cable channels transmitted on this multiplex.
Definition: atsctables.h:417
MPEGStreamData::GetEITPIDChanges
virtual bool GetEITPIDChanges(const uint_vec_t &, uint_vec_t &, uint_vec_t &) const
Definition: mpegstreamdata.h:105
ATSCEITStreamListener
Definition: streamlisteners.h:135
ATSCStreamData::VersionCVCT
int VersionCVCT(uint tsid) const
Definition: atscstreamdata.h:181
atsc_eit_pid_map_t
QMap< uint, uint > atsc_eit_pid_map_t
Definition: atscstreamdata.h:20
ATSCStreamData::SetVersionCVCT
void SetVersionCVCT(uint tsid, int version)
Definition: atscstreamdata.h:61
ATSCStreamData::m_atscMainListeners
atsc_main_listener_vec_t m_atscMainListeners
Definition: atscstreamdata.h:137
ATSCStreamData::HasCachedAnyVCTs
bool HasCachedAnyVCTs(bool current=true) const
Definition: atscstreamdata.h:83
MPEGStreamData::HasEITPIDChanges
virtual bool HasEITPIDChanges(const uint_vec_t &) const
Definition: mpegstreamdata.h:103
nv_python_libs.bbciplayer.bbciplayer_api.version
string version
Definition: bbciplayer_api.py:77
ATSCStreamData::m_eitStatus
TableStatusMap m_eitStatus
Definition: atscstreamdata.h:148
ATSCStreamData::SetVersionTVCT
void SetVersionTVCT(uint tsid, int version)
Definition: atscstreamdata.h:59