00001
00002
00003 #ifndef DVBSTREAMDATA_H_
00004 #define DVBSTREAMDATA_H_
00005
00006 #include "mpegstreamdata.h"
00007
00008 typedef NetworkInformationTable* nit_ptr_t;
00009 typedef vector<const nit_ptr_t> nit_vec_t;
00010 typedef QMap<uint, nit_ptr_t> nit_cache_t;
00011
00012 typedef ServiceDescriptionTable* sdt_ptr_t;
00013 typedef vector<const ServiceDescriptionTable*> sdt_vec_t;
00014 typedef QMap<uint, sdt_ptr_t> sdt_cache_t;
00015
00016 typedef vector<DVBMainStreamListener*> dvb_main_listener_vec_t;
00017 typedef vector<DVBOtherStreamListener*> dvb_other_listener_vec_t;
00018 typedef vector<DVBEITStreamListener*> dvb_eit_listener_vec_t;
00019
00020 typedef QMap<uint, bool> dvb_has_eit_t;
00021
00022 class DVBStreamData : virtual public MPEGStreamData
00023 {
00024 public:
00025 DVBStreamData(uint desired_netid, uint desired_tsid,
00026 int desired_program, bool cacheTables = false);
00027 ~DVBStreamData();
00028
00029 void Reset(void) { Reset(0, 0, -1); }
00030 void Reset(uint desired_netid, uint desired_tsid, int desired_sid);
00031
00032
00033 void SetDesiredService(uint netid, uint tsid, int serviceid);
00034 uint DesiredNetworkID(void) const { return _desired_netid; }
00035 uint DesiredTransportID(void) const { return _desired_tsid; }
00036
00037
00038 bool HandleTables(uint pid, const PSIPTable&);
00039 bool IsRedundant(uint pid, const PSIPTable&) const;
00040 void ProcessSDT(uint tsid, const ServiceDescriptionTable*);
00041
00042
00043 inline void SetDishNetEIT(bool);
00044 inline bool HasAnyEIT(void) const;
00045 inline bool HasEIT(uint serviceid) const;
00046 bool HasEITPIDChanges(const uint_vec_t &in_use_pids) const;
00047 bool GetEITPIDChanges(const uint_vec_t &in_use_pids,
00048 uint_vec_t &add_pids,
00049 uint_vec_t &del_pids) const;
00050
00051
00052 void SetVersionNIT(int version, uint last_section)
00053 {
00054 if (_nit_version == version)
00055 return;
00056 _nit_version = version;
00057 init_sections(_nit_section_seen, last_section);
00058 }
00059 int VersionNIT() const { return _nit_version; }
00060
00061 void SetVersionNITo(int version, uint last_section)
00062 {
00063 if (_nito_version == version)
00064 return;
00065 _nito_version = version;
00066 init_sections(_nito_section_seen, last_section);
00067 }
00068 int VersionNITo() const { return _nito_version; }
00069
00070 void SetVersionSDT(uint tsid, int version, uint last_section)
00071 {
00072 if (VersionSDT(tsid) == version)
00073 return;
00074 _sdt_versions[tsid] = version;
00075 init_sections(_sdt_section_seen[tsid], last_section);
00076 }
00077 int VersionSDT(uint tsid) const
00078 {
00079 const QMap<uint, int>::const_iterator it = _sdt_versions.find(tsid);
00080 if (it == _sdt_versions.end())
00081 return -1;
00082 return *it;
00083 }
00084
00085 void SetVersionSDTo(uint tsid, int version, uint last_section)
00086 {
00087 if (_sdto_versions[tsid] == version)
00088 return;
00089 _sdto_versions[tsid] = version;
00090 init_sections(_sdto_section_seen[tsid], last_section);
00091 }
00092 int VersionSDTo(uint tsid) const
00093 {
00094 const QMap<uint, int>::const_iterator it = _sdto_versions.find(tsid);
00095 if (it == _sdto_versions.end())
00096 return -1;
00097 return *it;
00098 }
00099
00100 void SetVersionEIT(uint tableid, uint serviceid, int version, uint last_section)
00101 {
00102 if (VersionEIT(tableid, serviceid) == version)
00103 return;
00104 uint key = (tableid << 16) | serviceid;
00105 _eit_version[key] = version;
00106 init_sections(_eit_section_seen[key], last_section);
00107 }
00108
00109 int VersionEIT(uint tableid, uint serviceid) const
00110 {
00111 uint key = (tableid << 16) | serviceid;
00112 const QMap<uint, int>::const_iterator it = _eit_version.find(key);
00113 if (it == _eit_version.end())
00114 return -1;
00115 return *it;
00116 }
00117
00118
00119 void SetVersionCIT(uint contentid, int version)
00120 {
00121 if (VersionCIT(contentid) == version)
00122 return;
00123 _cit_version[contentid] = version;
00124 }
00125
00126 int VersionCIT(uint contentid) const
00127 {
00128 const QMap<uint, int>::const_iterator it = _cit_version.find(contentid);
00129 if (it == _cit_version.end())
00130 return -1;
00131 return *it;
00132 }
00133
00134
00135 void SetNITSectionSeen(uint section);
00136 bool NITSectionSeen(uint section) const;
00137 bool HasAllNITSections(void) const;
00138
00139 void SetNIToSectionSeen(uint section);
00140 bool NIToSectionSeen(uint section) const;
00141 bool HasAllNIToSections(void) const;
00142
00143 void SetSDTSectionSeen(uint tsid, uint section);
00144 bool SDTSectionSeen(uint tsid, uint section) const;
00145 bool HasAllSDTSections(uint tsid) const;
00146
00147 void SetSDToSectionSeen(uint tsid, uint section);
00148 bool SDToSectionSeen(uint tsid, uint section) const;
00149 bool HasAllSDToSections(uint tsid) const;
00150
00151 void SetEITSectionSeen(uint tableid, uint serviceid, uint section);
00152 bool EITSectionSeen(uint tableid, uint serviceid, uint section) const;
00153
00154
00155 void SetCITSectionSeen(uint contentid, uint section);
00156 bool CITSectionSeen(uint contentid, uint section) const;
00157
00158
00159 bool HasCachedAnyNIT(bool current = true) const;
00160 bool HasCachedAllNIT(bool current = true) const;
00161 bool HasCachedAnySDT(uint tsid, bool current = true) const;
00162 bool HasCachedAllSDT(uint tsid, bool current = true) const;
00163 bool HasCachedSDT(bool current = true) const;
00164 bool HasCachedAllSDTs(bool current = true) const;
00165
00166 const nit_ptr_t GetCachedNIT(uint section_num, bool current = true) const;
00167 const sdt_ptr_t GetCachedSDT(uint tsid, uint section_num,
00168 bool current = true) const;
00169 const sdt_vec_t GetAllCachedSDTs(bool current = true) const;
00170
00171 void ReturnCachedSDTTables(sdt_vec_t&) const;
00172
00173 void AddDVBMainListener(DVBMainStreamListener*);
00174 void AddDVBOtherListener(DVBOtherStreamListener*);
00175 void AddDVBEITListener(DVBEITStreamListener*);
00176
00177 void RemoveDVBMainListener(DVBMainStreamListener*);
00178 void RemoveDVBOtherListener(DVBOtherStreamListener*);
00179 void RemoveDVBEITListener(DVBEITStreamListener*);
00180
00181 private:
00182
00183 void CacheNIT(NetworkInformationTable*);
00184 void CacheSDT(ServiceDescriptionTable*);
00185 protected:
00186 virtual void DeleteCachedTable(PSIPTable *psip) const;
00187
00188 private:
00190 uint _desired_netid;
00191 uint _desired_tsid;
00192
00194 bool _dvb_eit_dishnet_long;
00196 dvb_has_eit_t _dvb_has_eit;
00197
00198
00199 dvb_main_listener_vec_t _dvb_main_listeners;
00200 dvb_other_listener_vec_t _dvb_other_listeners;
00201 dvb_eit_listener_vec_t _dvb_eit_listeners;
00202
00203
00204 int _nit_version;
00205 QMap<uint, int> _sdt_versions;
00206 sections_t _nit_section_seen;
00207 sections_map_t _sdt_section_seen;
00208 QMap<uint, int> _eit_version;
00209 sections_map_t _eit_section_seen;
00210
00211 QMap<uint, int> _cit_version;
00212 sections_map_t _cit_section_seen;
00213
00214 int _nito_version;
00215 QMap<uint, int> _sdto_versions;
00216 sections_t _nito_section_seen;
00217 sections_map_t _sdto_section_seen;
00218
00219
00220 mutable nit_cache_t _cached_nit;
00221 mutable sdt_cache_t _cached_sdts;
00222 };
00223
00224 inline void DVBStreamData::SetDishNetEIT(bool use_dishnet_eit)
00225 {
00226 QMutexLocker locker(&_listener_lock);
00227 _dvb_eit_dishnet_long = use_dishnet_eit;
00228 }
00229
00230 inline bool DVBStreamData::HasAnyEIT(void) const
00231 {
00232 QMutexLocker locker(&_listener_lock);
00233 return _dvb_has_eit.size();
00234 }
00235
00236 inline bool DVBStreamData::HasEIT(uint serviceid) const
00237 {
00238 QMutexLocker locker(&_listener_lock);
00239
00240 dvb_has_eit_t::const_iterator it = _dvb_has_eit.find(serviceid);
00241 if (it != _dvb_has_eit.end())
00242 return *it;
00243
00244 return false;
00245 }
00246
00247 #endif // DVBSTREAMDATA_H_