Ticket #1427: eit-signatures.diff
File eit-signatures.diff, 6.3 KB (added by , 18 years ago) |
---|
-
libs/libmythtv/siparser.cpp
old new 1177 1177 1178 1178 for (uint i = 0; i < eit->EventCount(); i++) 1179 1179 { 1180 if (eitcache.addEIT(eit->TSID(), eit->EventID(i), eit->ServiceID(), 1181 eit->TableID(), eit->Version(), eit->Descriptors(i), 1182 eit->DescriptorsLength(i))) 1183 { 1184 1180 1185 // Event to use temporarily to fill in data 1181 1186 Event event; 1182 1187 event.ServiceID = eit->ServiceID(); … … 1252 1257 } 1253 1258 #endif 1254 1259 events[eit->ServiceID()][eit->EventID(i)] = event; 1260 } 1255 1261 } 1256 1262 #endif //USING_DVB_EIT 1257 1263 } -
new file mythtv/libs/libmythtv/eitcache.cpp
- + 1 /* 2 * Copyright 2006 (C) Stuart Auchterlonie <stuarta at squashedfrog.net> 3 * License: GPL v2 4 */ 5 6 #include "eitcache.h" 7 #include <stdio.h> 8 9 // Highest version number. version is 5bits 10 const uint EITCache::kVersionMax = 31; 11 12 EITCache::EITCache() 13 { 14 statsReset(); 15 } 16 17 QString EITCache::statistics(void) 18 { 19 QString tmp("EITCache::statistics: "); 20 tmp.append(QString("Accesses: %1, Hits: %2, Table Upgrades %3, New Versions: %4").arg(stats.accesses).arg(stats.hits).arg(stats.tables).arg(stats.versions)); 21 return tmp; 22 } 23 24 void EITCache::statsReset(void) 25 { 26 stats.accesses = 0; 27 stats.hits = 0; 28 stats.tables = 0; 29 stats.versions = 0; 30 } 31 32 bool EITCache::addEIT(const uint16_t tsid, const uint16_t eventId, 33 const uint16_t serviceId, const uint8_t tableId, const uint8_t version, 34 const unsigned char * const eitdata, const uint16_t eitlength) 35 { 36 long long key = eventKey(tsid, eventId, serviceId); 37 38 stats.accesses++; 39 bool found = eventMap.contains(key); 40 41 if (found) 42 { 43 if (get_table_id(key) > tableId) 44 { 45 // EIT from lower (ie. better) table number 46 stats.tables++; 47 } 48 else if ((get_table_id(key) == tableId) && 49 ((get_version(key) < version) || 50 ((get_version(key) == kVersionMax) && version < kVersionMax))) 51 { 52 // EIT updated version on current table 53 stats.versions++; 54 } 55 else 56 { 57 // EIT data previously seen 58 stats.hits++; 59 return false; 60 } 61 } 62 63 uint32_t chksum = 0; 64 long long eit_sig = eventSig(tableId, version, chksum); 65 eventMap.insert(key, eit_sig); 66 return true; 67 } 68 69 /* vim: set expandtab tabstop=4 shiftwidth=4: */ -
new file mythtv/libs/libmythtv/eitcache.h
- + 1 /* 2 * Copyright 2006 (C) Stuart Auchterlonie <stuarta at squashedfrog.net> 3 * License: GPL v2 4 */ 5 6 #ifndef _EIT_CACHE_H 7 #define _EIT_CACHE_H 8 9 #include <stdint.h> 10 11 // QT includes 12 #include <qmap.h> 13 #include <qpair.h> 14 #include <qstring.h> 15 16 typedef QMap<long long, long long> eventMap_t; 17 typedef struct 18 { 19 unsigned int accesses; 20 unsigned int hits; 21 unsigned int tables; 22 unsigned int versions; 23 } eit_stats_t; 24 25 class EITCache 26 { 27 public: 28 EITCache(); 29 ~EITCache() {}; 30 bool addEIT(const uint16_t tsid, const uint16_t eventId, 31 const uint16_t serviceId, const uint8_t tableId, 32 const uint8_t version, const unsigned char * const eitdata, 33 const uint16_t eitlength); 34 QString statistics(void); 35 void statsReset(void); 36 private: 37 eventMap_t eventMap; 38 eit_stats_t stats; 39 static const uint kVersionMax; 40 41 inline long long eventKey(const uint16_t tsid, const uint16_t eventId, 42 const uint16_t serviceId) 43 { 44 long long key = 0; 45 key = ((long long) tsid << 48) | 46 ((long long) eventId << 32) | 47 ((long long) serviceId <<16); 48 return key; 49 }; 50 inline long long eventSig(const uint8_t tableId, const uint8_t version, 51 uint32_t chksum) 52 { 53 long long sig = 0; 54 sig = ((long long) tableId << 40) | 55 ((long long) version << 32) | 56 (long long) chksum; 57 return sig; 58 }; 59 inline const uint8_t get_table_id(long long key) 60 { 61 uint8_t tableId; 62 tableId = (uint8_t) ((eventMap[key] & 0x0000FF0000000000LL) >> 40); 63 return tableId; 64 }; 65 inline const uint8_t get_version(long long key) 66 { 67 uint8_t version; 68 version = (uint8_t) ((eventMap[key] & 0x0000001F00000000LL) >> 32); 69 return version; 70 }; 71 }; 72 73 #endif // _EIT_CACHE_H 74 75 /* vim: set expandtab tabstop=4 shiftwidth=4: */ -
libs/libmythtv/libmythtv.pro
old new 326 326 327 327 DEFINES += USING_DVB 328 328 using_dvb_eit { 329 HEADERS += eithelper.h eitscanner.h eitfixup.h eit.h 330 SOURCES += eithelper.cpp eitscanner.cpp eitfixup.cpp eit.cpp 329 HEADERS += eithelper.h eitscanner.h eitfixup.h eit.h eitcache.h 330 SOURCES += eithelper.cpp eitscanner.cpp eitfixup.cpp eit.cpp eitcache.cpp 331 331 DEFINES += USING_DVB_EIT 332 332 } 333 333 } -
libs/libmythtv/siparser.h
old new 33 33 34 34 #ifdef USING_DVB_EIT 35 35 #include "eitfixup.h" 36 #include "eitcache.h" 36 37 #else // if !USING_DVB_EIT 37 38 typedef void QMap_Events; 38 39 #endif // !USING_DVB_EIT … … 235 236 #ifdef USING_DVB_EIT 236 237 /// EITFixUp instance 237 238 EITFixUp eitfixup; 239 EITCache eitcache; 238 240 #endif 239 241 240 242 // statistics