From f6e1539d43d2ffd4a7b9ee7691c9d7df84155bf8 Mon Sep 17 00:00:00 2001 From: seife Date: Sat, 20 Nov 2010 14:10:52 +0000 Subject: [PATCH] SIsections: add parsing of PDC descriptor (VPS time) Tdd the VPS time to the event if available. Not yet used for anything useful ;-) git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@888 e54a6e83-5905-42d5-8d5c-058d10e6a962 --- src/sectionsd/SIevents.hpp | 10 ++++++++++ src/sectionsd/SIsections.cpp | 26 ++++++++++++++++++++++++++ src/sectionsd/SIsections.hpp | 1 + 3 files changed, 37 insertions(+) diff --git a/src/sectionsd/SIevents.hpp b/src/sectionsd/SIevents.hpp index a66a45516..c9e8eee8a 100644 --- a/src/sectionsd/SIevents.hpp +++ b/src/sectionsd/SIevents.hpp @@ -90,6 +90,14 @@ struct descr_linkage_header { unsigned linkage_type : 8; } __attribute__ ((packed)) ; +struct descr_pdc_header { + unsigned descriptor_tag : 8; + unsigned descriptor_length : 8; + unsigned pil0 : 8; + unsigned pil1 : 8; + unsigned pil2 : 8; +} __attribute__ ((packed)) ; + class SIlinkage { public: SIlinkage(const struct descr_linkage_header *link) { @@ -344,6 +352,7 @@ public: original_network_id = 0; transport_stream_id = 0; eventID = 0; + vps = 0; // dauer=0; // startzeit=0; } @@ -383,6 +392,7 @@ public: SIparentalRatings ratings; SIlinkage_descs linkage_descs; SItimes times; + time_t vps; // Der Operator zum sortieren bool operator < (const SIevent& e) const { return uniqueKey()= sizeof(struct descr_pdc_header)) + { + const struct descr_pdc_header *s = (struct descr_pdc_header *)buf; + time_t now = time(NULL); + struct tm tm_r; + struct tm t = *localtime_r(&now, &tm_r); // this initializes the time zone in 't' + t.tm_isdst = -1; // makes sure mktime() will determine the correct DST setting + int month = t.tm_mon; + t.tm_mon = ((s->pil1 >> 3) & 0x0F) - 1; + t.tm_mday = ((s->pil0 & 0x0F) << 1) | ((s->pil1 & 0x80) >> 7); + t.tm_hour = ((s->pil1 & 0x07) << 2) | ((s->pil2 & 0xC0) >> 6); + t.tm_min = s->pil2 & 0x3F; + t.tm_sec = 0; + if (month == 11 && t.tm_mon == 0) // current month is dec, but event is in jan + t.tm_year++; + else if (month == 0 && t.tm_mon == 11) // current month is jan, but event is in dec + t.tm_year--; + e.vps = mktime(&t); + // fprintf(stderr, "SIsectionEIT::parsePDCDescriptor: vps: %ld %s", e.vps, ctime(&e.vps)); + } +} + void SIsectionEIT::parseComponentDescriptor(const char *buf, SIevent &e, unsigned maxlen) { if(maxlen>=sizeof(struct descr_component_header)) @@ -454,6 +478,8 @@ void SIsectionEIT::parseDescriptors(const char *des, unsigned len, SIevent &e) parseParentalRatingDescriptor((const char *)desc, e, len); else if(desc->descriptor_tag==0x4A) parseLinkageDescriptor((const char *)desc, e, len); + else if(desc->descriptor_tag==0x69) + parsePDCDescriptor((const char *)desc, e, len); if((unsigned)(desc->descriptor_length+2)>len) break; len-=desc->descriptor_length+2; diff --git a/src/sectionsd/SIsections.hpp b/src/sectionsd/SIsections.hpp index 73b99c47d..9d497536d 100644 --- a/src/sectionsd/SIsections.hpp +++ b/src/sectionsd/SIsections.hpp @@ -544,6 +544,7 @@ protected: void parseComponentDescriptor(const char *buf, SIevent &e, unsigned maxlen); void parseParentalRatingDescriptor(const char *buf, SIevent &e, unsigned maxlen); void parseLinkageDescriptor(const char *buf, SIevent &e, unsigned maxlen); + void parsePDCDescriptor(const char *buf, SIevent &e, unsigned maxlen); #ifdef ENABLE_FREESATEPG std::string freesatHuffmanDecode(std::string input); #endif