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
7
8#include "mpegstreamdata.h"
9#include "tablestatus.h"
10
11using pid_tsid_vec_t = QMap<uint, uint_vec_t>;
16using tvct_vec_t = std::vector<const TerrestrialVirtualChannelTable *>;
17using cvct_vec_t = std::vector<const CableVirtualChannelTable *>;
18using tvct_cache_t = QMap<uint, tvct_ptr_t>;
19using cvct_cache_t = QMap<uint, cvct_ptr_t>;
20using atsc_eit_pid_map_t = QMap<uint, uint>;
21using atsc_ett_pid_map_t = QMap<uint, uint>;
22
23using atsc_main_listener_vec_t = std::vector<ATSCMainStreamListener *>;
24using scte_main_listener_vec_t = std::vector<SCTEMainStreamListener *>;
25using atsc_aux_listener_vec_t = std::vector<ATSCAuxStreamListener *>;
26using atsc_eit_listener_vec_t = std::vector<ATSCEITStreamListener *>;
27using 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
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
173inline 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
181inline 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
189inline 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
std::vector< ATSCMainStreamListener * > atsc_main_listener_vec_t
std::vector< ATSCAuxStreamListener * > atsc_aux_listener_vec_t
std::vector< const TerrestrialVirtualChannelTable * > tvct_vec_t
QMap< uint, uint > atsc_eit_pid_map_t
QMap< uint, uint_vec_t > pid_tsid_vec_t
QMap< uint, cvct_ptr_t > cvct_cache_t
std::vector< SCTEMainStreamListener * > scte_main_listener_vec_t
QMap< uint, uint > atsc_ett_pid_map_t
QMap< uint, tvct_ptr_t > tvct_cache_t
std::vector< ATSC81EITStreamListener * > atsc81_eit_listener_vec_t
std::vector< ATSCEITStreamListener * > atsc_eit_listener_vec_t
std::vector< const CableVirtualChannelTable * > cvct_vec_t
Encapsulates data about ATSC stream and emits events for most tables.
QMap< uint, int > m_cvctVersion
bool HasCachedAllVCTs(bool current=true) const
atsc_eit_listener_vec_t m_atscEitListeners
void SetVersionTVCT(uint tsid, int version)
bool HasATSCMajorMinorMap(void) const
void SetVersionCVCT(uint tsid, int version)
atsc_ett_pid_map_t m_atscEttPids
void SetVersionMGT(int version)
int DesiredMajorChannel(void) const
atsc81_eit_listener_vec_t m_atsc81EitListeners
void Reset(void) override
bool HasCachedAnyVCTs(bool current=true) const
uint GPSOffset(void) const
Current UTC to GPS time offset in seconds.
QMap< uint, int > m_rrtVersion
tvct_cache_t m_cachedTvcts
void SetVersionRRT(uint region, int version)
atsc_eit_pid_map_t m_atscEitPids
TableStatusMap m_eitStatus
uint GetATSCMajorMinor(uint eit_sourceid) const
cvct_cache_t m_cachedCvcts
int DesiredMinorChannel(void) const
int VersionMGT() const
int VersionCVCT(uint tsid) const
atsc_main_listener_vec_t m_atscMainListeners
int VersionTVCT(uint tsid) const
scte_main_listener_vec_t m_scteMainlisteners
QMap< uint, int > m_tvctVersion
int VersionRRT(uint region) const
atsc_aux_listener_vec_t m_atscAuxListeners
QMap< uint, uint > m_sourceIdToAtscMajMin
This table contains information about the cable channels transmitted on this multiplex.
Definition: atsctables.h:423
Encapsulates data about MPEG stream and emits events for each table.
QRecursiveMutex m_listenerLock
virtual bool GetEITPIDChanges(const uint_vec_t &, uint_vec_t &, uint_vec_t &) const
virtual bool DeleteCachedTable(const PSIPTable *psip) const
virtual bool IsRedundant(uint pid, const PSIPTable &psip) const
Returns true if table already seen.
virtual void Reset(void)
virtual bool HasEITPIDChanges(const uint_vec_t &) const
virtual bool HandleTables(uint pid, const PSIPTable &psip)
Process PSIP packets.
This table tells the decoder on which PIDs to find other tables, and their sizes and each table's cur...
Definition: atsctables.h:83
A PSIP table is a variant of a PES packet containing an MPEG, ATSC or DVB table.
Definition: mpegtables.h:410
This table contains information about the terrestrial channels transmitted on this multiplex.
Definition: atsctables.h:354
This table contains information about the channels transmitted on this multiplex.
Definition: atsctables.h:197
#define minor(X)
Definition: compat.h:74
unsigned int uint
Definition: freesurround.h:24
std::vector< uint > uint_vec_t
static constexpr uint8_t GPS_LEAP_SECONDS
Leap seconds as of June 30th, 2022.
Definition: mpegtables.h:34
#define MTV_PUBLIC
Definition: mythtvexp.h:15
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:15
string version
Definition: giantbomb.py:185