From 35d5843a396a5b3144e3abc2571e150c514801e4 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Thu, 22 Sep 2011 17:24:02 +0200 Subject: re-factored code added stars rating --- dish.c | 248 +++++++++++++++++++++++++++++++++++++++++++++-------------------- dish.h | 56 +++++++++------ eepg.c | 96 +++++++++++-------------- 3 files changed, 247 insertions(+), 153 deletions(-) diff --git a/dish.c b/dish.c index 75ea611..7ea85b1 100644 --- a/dish.c +++ b/dish.c @@ -20,82 +20,92 @@ namespace SI { // returns the value of a sequence of bits in the byte array - static unsigned int getBits(int bitIndex, int bitCount, const unsigned char *byteptr, int length) - { - union { - unsigned char b[4]; - unsigned long val; - } chunk; + static unsigned int getBits(int bitIndex, int bitCount, const unsigned char *byteptr, + int length) { + union + { + unsigned char b[4]; + unsigned long val; + } chunk; - int offset = bitIndex >> 3; - int bitnum = bitIndex - (offset << 3); - int rightend = 32 - bitnum - bitCount; + int offset = bitIndex >> 3; + int bitnum = bitIndex - (offset << 3); + int rightend = 32 - bitnum - bitCount; - chunk.b[3] = byteptr[offset]; - chunk.b[2] = (offset+1 < length) ? byteptr[offset+1] : 0; - chunk.b[1] = (offset+2 < length) ? byteptr[offset+2] : 0; - chunk.b[0] = 0; // Never need to look this far ahead. + chunk.b[3] = byteptr[offset]; + chunk.b[2] = (offset + 1 < length) ? byteptr[offset + 1] : 0; + chunk.b[1] = (offset + 2 < length) ? byteptr[offset + 2] : 0; + chunk.b[0] = 0; // Never need to look this far ahead. - return (unsigned int)(((chunk.val & (0xFFFFFFFF >> bitnum)) >> rightend)); + return (unsigned int) ((((((chunk.val & (0xFFFFFFFF >> bitnum)) >> rightend))))); } - DishDescriptor::DishDescriptor(UnimplementedDescriptor *unimplementedDesc) + DishDescriptor::DishDescriptor() { - text = NULL; + name = NULL; shortText = NULL; + description = NULL; decompressed = NULL; - this->unimplementedDesc = unimplementedDesc; + DishTheme = 0; + DishCategory = 0; + mpaaRating = 0; + starRating = 0; } DishDescriptor::~DishDescriptor() { delete [] decompressed; decompressed = NULL; - delete unimplementedDesc; + delete name; + name = NULL; + delete shortText; + shortText = NULL; + delete description; + description = NULL; } - const char *DishDescriptor::getTheme(int contentNibleLvl2) + const char *DishDescriptor::getTheme() { - const char* theme; - using namespace DISH_THEMES; + const char *theme; + using namespace DISH_THEMES; - switch (contentNibleLvl2) { - case Movie: - theme = "Movie"; - break; - case Sports: - theme = "Sports"; - break; - case News_Business: - theme = "News/Business"; - break; - case Family_Children: - theme = "Family/Children"; - break; - case Education: - theme = "Education"; - break; - case Series_Special: - theme = "Series/Special"; - break; - case Music_Art: - theme = "Music/Art"; - break; - case Religious: - theme = "Religious"; - break; - default: - theme = ""; - break; - } - return theme; + switch (DishTheme){ + case Movie: + theme = "Movie"; + break; + case Sports: + theme = "Sports"; + break; + case News_Business: + theme = "News/Business"; + break; + case Family_Children: + theme = "Family/Children"; + break; + case Education: + theme = "Education"; + break; + case Series_Special: + theme = "Series/Special"; + break; + case Music_Art: + theme = "Music/Art"; + break; + case Religious: + theme = "Religious"; + break; + default: + theme = ""; + break; + } + return theme; } - const char *DishDescriptor::getCategory(int userNible) + const char *DishDescriptor::getCategory() { - using namespace DISH_CATEGORIES; + using namespace DISH_CATEGORIES; - switch (userNible) { + switch (DishCategory) { case Action: return "Action"; case ActionSports: return "Action Sports"; case Adults_only: return "Adults only"; @@ -253,13 +263,108 @@ namespace SI case Yoga: return "Yoga"; default: return ""; } + } + void DishDescriptor::setExtendedtData(unsigned char Tid, CharArray data) + { + Decompress(Tid, data); + if (decompressed) { + char *split = strchr((char*)((decompressed)), 0x0D); // Look for carriage return + //LogD(2, prep("dLength:%d, length:%d, count:%d, decompressed: %s"), dLength, length, count, decompressed); + if(split){ + *split = 0; + shortText = new string((char*)decompressed); + description = new string((split[1] == 0x20) ? split + 2 : split + 1); + }else{ + description = new string((char*)decompressed); + } + delete[] decompressed; + decompressed = NULL; + } else { + shortText = new string(); + description = new string(); + } } - void DishDescriptor::Decompress(unsigned char Tid) + const char *DishDescriptor::getShortText(void) { - const unsigned char *str = unimplementedDesc->getData().getData(); - const unsigned char *cmp = NULL; // Compressed data + string tmp = ""; + if (shortText != NULL) tmp += *shortText; + if(DishTheme > 0){ + if(tmp != "") tmp += " - "; + + tmp += getTheme(); + } + if(DishCategory > 0){ + if(tmp != "") tmp += " - "; + + tmp += getCategory(); + } + return tmp.c_str(); + } + + const char *DishDescriptor::getDescription(void) { + string tmp = ""; + if (description != NULL) tmp += *description; + char* rating = getRating(); + if (rating && rating != "") { + if(tmp != "") tmp += "|"; + tmp += rating; + } + if (starRating > 0) { + if(tmp != "") tmp += "|"; + tmp += getStarRating(); + } + return tmp.c_str(); + } + + void DishDescriptor::setContent(ContentDescriptor::Nibble Nibble) + { + DishTheme = Nibble.getContentNibbleLevel2() & 0xF; + DishCategory = ((Nibble.getUserNibble1() & 0xF) << 4) | (Nibble.getUserNibble2() & 0xF); + } + + void DishDescriptor::setRating(uint16_t rating) + { + uint16_t newRating = (rating >> 10) & 0x07; + if (newRating == 0) newRating = 5; + if (newRating == 6) newRating = 0; + mpaaRating = (newRating << 10) | (rating & 0x3FF); + starRating = (rating >> 13) & 0x07; + } + + const char* DishDescriptor::getRating(){ + static const char *const ratings[8] = { "", "G", "PG", "PG-13", "R", "NR/AO", "", "NC-17" }; + char buffer[19]; + buffer[0] = 0; + strcpy(buffer, ratings[(mpaaRating >> 10) & 0x07]); + if (mpaaRating & 0x3A7F) { + strcat(buffer, " ["); + if (mpaaRating & 0x0230) + strcat(buffer, "V,"); + if (mpaaRating & 0x000A) + strcat(buffer, "L,"); + if (mpaaRating & 0x0044) + strcat(buffer, "N,"); + if (mpaaRating & 0x0101) + strcat(buffer, "SC,"); + if (char *s = strrchr(buffer, ',')) + s[0] = ']'; + } + + return isempty(buffer) ? NULL : buffer; + } + + const char* DishDescriptor::getStarRating(){ + static const char *const critiques[8] = { "", "*", "*+", "**", "**+", "***", "***+", "****" }; + return critiques[starRating & 0x07]; + } + + + void DishDescriptor::Decompress(unsigned char Tid, CharArray data) + { + const unsigned char *str = data.getData(); + const unsigned char *cmp = NULL; int length = 0; // Length of compressed data unsigned int dLength = 0; // Length of decompressed data if((str[3] & 0xFC) == 0x80){ @@ -278,15 +383,14 @@ namespace SI HuffmanTable *table; unsigned int tableSize, numBits; if (Tid > 0x80) { - table = Table255; - tableSize = SIZE_TABLE_255; - numBits = 13; - } - else { - table = Table128; - tableSize = SIZE_TABLE_128; - numBits = 11; - } + table = Table255; + tableSize = SIZE_TABLE_255; + numBits = 13; + } else { + table = Table128; + tableSize = SIZE_TABLE_128; + numBits = 11; + } unsigned int bLength = length << 3; // number of bits unsigned int currentBit = 0, count = 0; while(currentBit < bLength - 1 && count < dLength){ @@ -305,18 +409,8 @@ namespace SI } decompressed[count] = 0; - char *split = strchr((char*)(decompressed), 0x0D); // Look for carriage return - //LogD(2, prep("dLength:%d, length:%d, count:%d, decompressed: %s"), dLength, length, count, decompressed); - if(split){ - *split = 0; - shortText = (char*)(decompressed); - text = (split[1] == 0x20) ? split + 2 : split + 1; - }else{ - text = (char*)(decompressed); - } } - struct DishDescriptor::HuffmanTable DishDescriptor::Table128[SIZE_TABLE_128] = { { 0x0000, 0x20, 0x03 }, { 0x0100, 0x65, 0x04 }, { 0x0180, 0x74, 0x04 }, { 0x0200, 0x61, 0x04 }, { 0x0280, 0x6F, 0x04 }, { 0x0300, 0x73, 0x04 }, @@ -451,4 +545,4 @@ struct DishDescriptor::HuffmanTable DishDescriptor::Table255[SIZE_TABLE_255] = { { 0x1FFD, 0x02, 0x0D }, { 0x1FFE, 0x01, 0x0D }, { 0x1FFF, 0x00, 0x0D } }; -} //end of namespace +} //end of namespace diff --git a/dish.h b/dish.h index fb1689c..7510c67 100644 --- a/dish.h +++ b/dish.h @@ -239,33 +239,47 @@ namespace SI #define SIZE_TABLE_128 128 #define SIZE_TABLE_255 255 -class UnimplementedDescriptor; +using namespace std; class DishDescriptor { public: - DishDescriptor(UnimplementedDescriptor*); - virtual ~DishDescriptor(); - const char* getText(void) const { return text; } + DishDescriptor(); + virtual ~DishDescriptor(); + const char* getName(void) const { return name?name->c_str():""; } + const char* getShortText(void); + const char *getDescription(void); + // const char* getShortText(void) const { return shortText?shortText->c_str():""; } + // const char* getDescription(void) const { return description?description->c_str():""; } + const char *getTheme(); + const char *getCategory(); + const char *getRating(); + const char *getStarRating(); + void setShortData(unsigned char Tid, CharArray data); + void setExtendedtData(unsigned char Tid, CharArray data); + void setRating(uint16_t value); + void setContent(ContentDescriptor::Nibble Nibble); - const char* getShortText(void) const { return shortText; } - const char* getTheme(int contentNibleLvl2); - const char* getCategory(int userNible); - // Decompress the byte arrary and stores the result to a text string - void Decompress(unsigned char Tid); -protected: - const char* text; // name or description of the event - const char* shortText; // usually the episode name - unsigned char* decompressed; - UnimplementedDescriptor* unimplementedDesc; - struct HuffmanTable { - unsigned int startingAddress; - unsigned char character; - unsigned char numberOfBits; - }; - static HuffmanTable Table128[SIZE_TABLE_128]; - static HuffmanTable Table255[SIZE_TABLE_255]; +protected: + // Decompress the byte array and stores the result to a text string + void Decompress(unsigned char Tid, CharArray data); + string *name; // name of the event + string *shortText; // usually the episode name + string *description; // description of the event + unsigned char *decompressed; + uchar DishTheme; + uchar DishCategory; + uint16_t mpaaRating; + uint16_t starRating; + struct HuffmanTable + { + unsigned int startingAddress; + unsigned char character; + unsigned char numberOfBits; + }; + static HuffmanTable Table128[SIZE_TABLE_128]; + static HuffmanTable Table255[SIZE_TABLE_255]; }; } /* namespace SI */ diff --git a/eepg.c b/eepg.c index 5f5f52b..478a9aa 100644 --- a/eepg.c +++ b/eepg.c @@ -10,6 +10,7 @@ * -Freesat patch written by dom /at/ suborbital.org.uk * * + * This code is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. @@ -344,6 +345,7 @@ public: cFilterEEPG (void); virtual void SetStatus (bool On); void Trigger (void); + static const int EIT_PID = 0x12; }; cFilterEEPG::cFilterEEPG (void) @@ -2823,15 +2825,13 @@ extern bool SystemCharacterTableIsSingleByte;*/ class cEIT2:public SI::EIT { public: - cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool OnlyRunningStatus = false); + cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool isEITPid = false, bool OnlyRunningStatus = false); }; -cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool OnlyRunningStatus) +cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool isEITPid, bool OnlyRunningStatus) : SI::EIT (Data, false) { //LogD(2, prep("cEIT2::cEIT2")); - if (Tid > 0 && Format == DISH_BEV) Tid--; - if (!CheckCRCAndParse ()) { LogD(2, prep("!CheckCRCAndParse ()")); return; @@ -2846,7 +2846,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat return; // only collect data for known channels } - LogD(4, prep("channelID: %s format:%d"), *channel->GetChannelID().ToString(), Format); + //LogD(4, prep("channelID: %s format:%d"), *channel->GetChannelID().ToString(), Format); #ifdef USE_NOEPG // only use epg from channels not blocked by noEPG-patch @@ -2874,6 +2874,11 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat if (!SegmentStart) SegmentStart = SiEitEvent.getStartTime (); SegmentEnd = SiEitEvent.getStartTime () + SiEitEvent.getDuration (); + int versionNumber = getVersionNumber(); + // increase version number for DISH_BEV EIT so it does not get overwriten by VDR. + // TODO check the same for other providers. + if (Format == DISH_BEV && isEITPid) versionNumber++; + cEvent *newEvent = NULL; cEvent *rEvent = NULL; cEvent *pEvent = (cEvent *) pSchedule->GetEvent (SiEitEvent.getEventId (), SiEitEvent.getStartTime ()); @@ -2962,7 +2967,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat continue; } #else - if (pEvent->Version () == getVersionNumber ()) + if (pEvent->Version () == versionNumber) continue; #endif /* DDEPGENTRY */ HasExternalData = ExternalData = true; @@ -2977,7 +2982,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat // the actual Premiere transponder and the Sat.1/Pro7 transponder), but use different version numbers on // each of them :-( So if one DVB card is tuned to the Premiere transponder, while an other one is tuned // to the Sat.1/Pro7 transponder, events will keep toggling because of the bogus version numbers. - else if (Tid == pEvent->TableID() && pEvent->Version() == getVersionNumber()) + else if (Tid == pEvent->TableID() && pEvent->Version() == versionNumber) continue; } if (!ExternalData) { @@ -2998,7 +3003,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat } if (OnlyRunningStatus) continue; // do this before setting the version, so that the full update can be done later - pEvent->SetVersion (getVersionNumber()); + pEvent->SetVersion (versionNumber); int LanguagePreferenceShort = -1; int LanguagePreferenceExt = -1; @@ -3006,9 +3011,9 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat SI::Descriptor * d; SI::ExtendedEventDescriptors * ExtendedEventDescriptors = NULL; SI::ShortEventDescriptor * ShortEventDescriptor = NULL; - SI::DishDescriptor *DishExtendedEventDescriptor = NULL; - SI::DishDescriptor *DishShortEventDescriptor = NULL; - uchar DishTheme = 0, DishCategory = 0; + //SI::DishDescriptor *DishExtendedEventDescriptor = NULL; + SI::DishDescriptor *DishEventDescriptor = NULL; + //uchar DishTheme = 0, DishCategory = 0; cLinkChannels *LinkChannels = NULL; @@ -3060,13 +3065,11 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat Contents[NumContents] = ((Nibble.getContentNibbleLevel1() & 0xF) << 4) | (Nibble.getContentNibbleLevel2() & 0xF); NumContents++; } - if (Format == DISH_BEV && NumContents == 1) { - DishTheme = Nibble.getContentNibbleLevel2() & 0xF; - DishCategory = ((Nibble.getUserNibble1() & 0xF) << 4) | (Nibble.getUserNibble2() & 0xF); - //LogD(2, prep("EEPGDEBUG:DishTheme:%x-DishCategory:%x)"), DishTheme, DishCategory); + if (DishEventDescriptor && NumContents == 1) { + DishEventDescriptor->setContent(Nibble); } - //LogD(2, prep("EEPGDEBUG:Nibble:%x-%x-%x-%x)"), Nibble.getContentNibbleLevel1(),Nibble.getContentNibbleLevel2() - // , Nibble.getUserNibble1(), Nibble.getUserNibble2()); +// LogD(2, prep("EEPGDEBUG:Nibble:%x-%x-%x-%x)"), Nibble.getContentNibbleLevel1(),Nibble.getContentNibbleLevel2() +// , Nibble.getUserNibble1(), Nibble.getUserNibble2()); } pEvent->SetContents(Contents); @@ -3190,33 +3193,27 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat } break; case SI::DishExtendedEventDescriptorTag: { - SI::DishDescriptor *deed = new SI::DishDescriptor((SI::UnimplementedDescriptor *)d); - deed->Decompress(Tid); - if (!DishExtendedEventDescriptor) { - DishExtendedEventDescriptor = deed; - d = NULL; // so that it is not deleted + SI::UnimplementedDescriptor *deed = (SI::UnimplementedDescriptor *)d; + if (!DishEventDescriptor) { + DishEventDescriptor = new SI::DishDescriptor(); } + DishEventDescriptor->setExtendedtData(Tid, deed->getData()); HasExternalData = true; } break; case SI::DishShortEventDescriptorTag: { - SI::DishDescriptor *dsed = new SI::DishDescriptor((SI::UnimplementedDescriptor *)d); - dsed->Decompress(Tid); - if (!DishShortEventDescriptor) { - DishShortEventDescriptor = dsed; - d = NULL; // so that it is not deleted + SI::UnimplementedDescriptor *dsed = (SI::UnimplementedDescriptor *)d; + if (!DishEventDescriptor) { + DishEventDescriptor = new SI::DishDescriptor(); } + DishEventDescriptor->setShortData(Tid, dsed->getData()); HasExternalData = true; } break; case SI::DishRatingDescriptorTag: { - if (d->getLength() == 4) { + if (d->getLength() == 4 && DishEventDescriptor) { uint16_t rating = d->getData().TwoBytes(2); - uint16_t newRating = (rating >> 10) & 0x07; - if (newRating == 0) newRating = 5; - if (newRating == 6) newRating = 0; - pEvent->SetParentalRating((newRating << 10) | (rating & 0x3FF)); -// pEvent->SetStarRating((rating >> 13) & 0x07); + DishEventDescriptor->setRating(rating); } } break; @@ -3250,30 +3247,19 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat } else if (!HasExternalData) pEvent->SetDescription (NULL); - if (DishShortEventDescriptor) { - pEvent->SetTitle(DishShortEventDescriptor->getText()); - //LogD(2, prep("channelID: %s DishTitle: %s"), *channel->GetChannelID().ToString(), DishShortEventDescriptor->getText()); - } - if (DishExtendedEventDescriptor) { - pEvent->SetDescription(DishExtendedEventDescriptor->getText()); - char *tmp; - if (DishTheme >= 0) { - Asprintf (&tmp, "%s - %s ~ %s", DishExtendedEventDescriptor->getShortText() - , DishExtendedEventDescriptor->getTheme(DishTheme) - , DishExtendedEventDescriptor->getCategory(DishCategory)); - pEvent->SetShortText(tmp); - //LogD(2, prep("EEPGDEBUG:DishTheme:%x-DishCategory:%x)"), DishTheme, DishCategory); - free(tmp); - } else - pEvent->SetShortText(DishExtendedEventDescriptor->getShortText()); + if (DishEventDescriptor) { + pEvent->SetTitle(DishEventDescriptor->getName()); + pEvent->SetDescription(DishEventDescriptor->getDescription()); + pEvent->SetShortText(DishEventDescriptor->getShortText()); + //LogD(2, prep("channelID: %s DishTitle: %s"), *channel->GetChannelID().ToString(), DishEventDescriptor->getName()); //LogD(2, prep("DishDescription: %s"), DishExtendedEventDescriptor->getText()); //LogD(2, prep("DishShortText: %s"), DishExtendedEventDescriptor->getShortText()); } + } delete ExtendedEventDescriptors; delete ShortEventDescriptor; - delete DishExtendedEventDescriptor; - delete DishShortEventDescriptor; + delete DishEventDescriptor; pEvent->SetComponents (Components); @@ -3471,7 +3457,7 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) AddFilter (pid, 0xb0); //perhaps TID is equal to first data byte? break; case DISH_BEV: - AddFilter (0x12, 0, 0); // event info, actual(0x4e)/other(0x4f) TS, present/following + AddFilter (EIT_PID, 0, 0); // event info, actual(0x4e)/other(0x4f) TS, present/following AddFilter (0x0300, 0, 0); // Dish Network EEPG event info, actual(0x4e)/other(0x4f) TS, present/following AddFilter (0x0441, 0, 0); // Dish Network EEPG event info, actual(0x4e)/other(0x4f) TS, present/following // AddFilter (0x0441, 0x50, 0xf0); // Bell ExpressVU EEPG @@ -3490,7 +3476,7 @@ void cFilterEEPG::ProccessContinuous(u_short Pid, u_char Tid, int Length, const cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); //Look for other satelite positions only if Dish/Bell ExpressVU for the moment hardcoded pid check if(Schedules) - SI::cEIT2 EIT(Schedules, Source(), Tid, Data); + SI::cEIT2 EIT(Schedules, Source(), Tid, Data, Pid == EIT_PID); else//cEIT EIT (Schedules, Source (), Tid, Data); { @@ -3501,7 +3487,7 @@ void cFilterEEPG::ProccessContinuous(u_short Pid, u_char Tid, int Length, const cSchedulesLock SchedulesLock; cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); if(Schedules) - SI::cEIT2 EIT(Schedules, Source(), Tid, Data, true); + SI::cEIT2 EIT(Schedules, Source(), Tid, Data, Pid == EIT_PID, true); //cEIT EIT (Schedules, Source (), Tid, Data, true); } @@ -3665,7 +3651,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len } //if pmtpid else if (Source ()) { - if ( Pid == 0x12 || Pid == 0x0300 || Pid == 0x0441 ) { + if ( Pid == EIT_PID || Pid == 0x0300 || Pid == 0x0441 ) { if (Tid >= 0x4E) ProccessContinuous(Pid, Tid, Length, Data); return; -- cgit v1.2.3 From 3c9b4d23704e9460e7c3a0d5baa2c9d32feee116 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Thu, 22 Sep 2011 18:38:52 +0200 Subject: fix compile --- dish.c | 7 ++++--- dish.h | 8 ++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dish.c b/dish.c index 7ea85b1..d24c32f 100644 --- a/dish.c +++ b/dish.c @@ -12,9 +12,10 @@ #include "dish.h" #include -#include +//#include #include #include +#include namespace SI { @@ -306,8 +307,8 @@ namespace SI const char *DishDescriptor::getDescription(void) { string tmp = ""; if (description != NULL) tmp += *description; - char* rating = getRating(); - if (rating && rating != "") { + const char* rating = getRating(); + if (rating && strcmp(rating,"") != 0) { if(tmp != "") tmp += "|"; tmp += rating; } diff --git a/dish.h b/dish.h index 7510c67..e6a5b9b 100644 --- a/dish.h +++ b/dish.h @@ -10,6 +10,10 @@ #ifndef LIBSI_DISH_H #define LIBSI_DISH_H +#include +#include +#include + namespace SI { @@ -267,8 +271,8 @@ protected: string *shortText; // usually the episode name string *description; // description of the event unsigned char *decompressed; - uchar DishTheme; - uchar DishCategory; + unsigned char DishTheme; + unsigned char DishCategory; uint16_t mpaaRating; uint16_t starRating; -- cgit v1.2.3 From d826a6882e10a69336aa6c751e6822eada604100 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Thu, 22 Sep 2011 19:48:39 +0200 Subject: added missing setShortData --- dish.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dish.c b/dish.c index d24c32f..74e53ff 100644 --- a/dish.c +++ b/dish.c @@ -266,6 +266,18 @@ namespace SI } } + void DishDescriptor::setShortData(unsigned char Tid, CharArray data) + { + Decompress(Tid, data); + if (decompressed) { + name = new string((char*)decompressed); + delete[] decompressed; + decompressed = NULL; + } else { + name = new string(); + } + } + void DishDescriptor::setExtendedtData(unsigned char Tid, CharArray data) { Decompress(Tid, data); -- cgit v1.2.3 From e228e74a720c8f0b7e48c0909a2a29ddc7620252 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sun, 2 Oct 2011 17:54:14 +0200 Subject: do not use member pointers --- dish.c | 47 +++++++++++++++++++++++++++-------------------- dish.h | 8 ++++---- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/dish.c b/dish.c index 74e53ff..4919ad8 100644 --- a/dish.c +++ b/dish.c @@ -43,9 +43,9 @@ namespace SI DishDescriptor::DishDescriptor() { - name = NULL; - shortText = NULL; - description = NULL; + name = ""; + shortText = ""; + description = ""; decompressed = NULL; DishTheme = 0; DishCategory = 0; @@ -57,12 +57,12 @@ namespace SI { delete [] decompressed; decompressed = NULL; - delete name; - name = NULL; - delete shortText; - shortText = NULL; - delete description; - description = NULL; +// delete name; +// name = NULL; +// delete shortText; +// shortText = NULL; +// delete description; +// description = NULL; } const char *DishDescriptor::getTheme() @@ -270,11 +270,11 @@ namespace SI { Decompress(Tid, data); if (decompressed) { - name = new string((char*)decompressed); + name = string((char*)decompressed); delete[] decompressed; decompressed = NULL; } else { - name = new string(); +// name = new string(); } } @@ -286,23 +286,24 @@ namespace SI //LogD(2, prep("dLength:%d, length:%d, count:%d, decompressed: %s"), dLength, length, count, decompressed); if(split){ *split = 0; - shortText = new string((char*)decompressed); - description = new string((split[1] == 0x20) ? split + 2 : split + 1); + shortText = string((char*)decompressed); + description = string((split[1] == 0x20) ? split + 2 : split + 1); }else{ - description = new string((char*)decompressed); + description = string((char*)decompressed); } delete[] decompressed; decompressed = NULL; } else { - shortText = new string(); - description = new string(); +// shortText = new string(); +// description = new string(); } } const char *DishDescriptor::getShortText(void) { string tmp = ""; - if (shortText != NULL) tmp += *shortText; +// if (shortText != NULL) tmp += *shortText; + tmp += shortText; if(DishTheme > 0){ if(tmp != "") tmp += " - "; @@ -318,14 +319,15 @@ namespace SI const char *DishDescriptor::getDescription(void) { string tmp = ""; - if (description != NULL) tmp += *description; +// if (description != NULL) tmp += *description; + tmp += description; const char* rating = getRating(); if (rating && strcmp(rating,"") != 0) { - if(tmp != "") tmp += "|"; + if(tmp != "") tmp += " ~ "; tmp += rating; } if (starRating > 0) { - if(tmp != "") tmp += "|"; + if(tmp != "") tmp += " ~ "; tmp += getStarRating(); } return tmp.c_str(); @@ -348,6 +350,11 @@ namespace SI const char* DishDescriptor::getRating(){ static const char *const ratings[8] = { "", "G", "PG", "PG-13", "R", "NR/AO", "", "NC-17" }; + + if (mpaaRating == 0) { + return ratings[mpaaRating]; + } + char buffer[19]; buffer[0] = 0; strcpy(buffer, ratings[(mpaaRating >> 10) & 0x07]); diff --git a/dish.h b/dish.h index e6a5b9b..b4efe1c 100644 --- a/dish.h +++ b/dish.h @@ -249,7 +249,7 @@ class DishDescriptor { public: DishDescriptor(); virtual ~DishDescriptor(); - const char* getName(void) const { return name?name->c_str():""; } + const char* getName(void) const { return name.c_str(); } const char* getShortText(void); const char *getDescription(void); // const char* getShortText(void) const { return shortText?shortText->c_str():""; } @@ -267,9 +267,9 @@ public: protected: // Decompress the byte array and stores the result to a text string void Decompress(unsigned char Tid, CharArray data); - string *name; // name of the event - string *shortText; // usually the episode name - string *description; // description of the event + string name; // name of the event + string shortText; // usually the episode name + string description; // description of the event unsigned char *decompressed; unsigned char DishTheme; unsigned char DishCategory; -- cgit v1.2.3 From 45aa02d117af1e6f0b5584de8b06827c4b5fd301 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sun, 2 Oct 2011 20:06:49 +0200 Subject: enable EIT scan in eepg --- eepg.c | 11 +++++++++++ eepg.h | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/eepg.c b/eepg.c index 478a9aa..e243287 100644 --- a/eepg.c +++ b/eepg.c @@ -3463,6 +3463,11 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) // AddFilter (0x0441, 0x50, 0xf0); // Bell ExpressVU EEPG // AddFilter (0x0441, 0x60, 0xf0); // Bell ExpressVU EEPG break; + case EIT: + AddFilter (pid, 0x4e, 0xfe); //event info, actual(0x4e)/other(0x4f) TS, present/following + AddFilter (pid, 0x50, 0xf0); //event info, actual TS, schedule(0x50)/schedule for future days(0x5X) + AddFilter (pid, 0x60, 0xf0); //event info, other TS, schedule(0x60)/schedule for future days(0x6X) + break; default: break; } @@ -3631,6 +3636,12 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len && !UnprocessedFormat[DISH_BEV]) { UnprocessedFormat[DISH_BEV] = stream.getPid (); } + + // Enable EIT scan for all except DISH_BEV since it is already enabled + // TODO add setup option + if (!UnprocessedFormat[DISH_BEV]) { + UnprocessedFormat[EIT] = EIT_PID; + } } //if data[1] && data [3] } //if streamtype /*if (Format != PREMIERE) //any format found diff --git a/eepg.h b/eepg.h index 503e800..d306ca0 100644 --- a/eepg.h +++ b/eepg.h @@ -30,14 +30,15 @@ enum EFormat { PREMIERE , FREEVIEW , DISH_BEV , + EIT , //the highest number of EPG-formats that is supported by this plugin - HIGHEST_FORMAT = DISH_BEV + HIGHEST_FORMAT = EIT } Format; #define NAGRA_TABLE_ID 0x55 //the lower the table Id, the more "current" it is; table_id 0x00 never gets overwritten, now/next are at 0x4e or 0x4f! #define DEFAULT_TABLE_ID 0x30 -const char *FormatName[]= {"MediaHighWay 1","MediaHighWay 2","Sky Italy","Sky UK","NagraGuide","Premiere","FreeView","Dish/Bev"}; +const char *FormatName[]= {"MediaHighWay 1","MediaHighWay 2","Sky Italy","Sky UK","NagraGuide","Premiere","FreeView","Dish/Bev","EIT"}; struct sNode { -- cgit v1.2.3 From c55aa9e24581640a036e19cf871c6075354928be Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Mon, 3 Oct 2011 13:57:03 +0200 Subject: added logging for EIT debug fixed table ID initialization --- eepg.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/eepg.c b/eepg.c index e243287..48519e7 100644 --- a/eepg.c +++ b/eepg.c @@ -2151,6 +2151,7 @@ int cFilterEEPG::GetTitlesMHW2 (const u_char * Data, int Length) CleanString (T->Text); Pos += Len + 8; // Sub Theme starts here T->ThemeId = ((Data[7] & 0x3f) << 6) | (Data[Pos] & 0x3f); + T->TableId = DEFAULT_TABLE_ID; //TODO locate the actual table id T->EventId = (Data[Pos + 1] << 8) | Data[Pos + 2]; T->SummaryAvailable = (T->EventId != 0xFFFF); LogI(3, prep("EventId %04x Titlenr %d:SummAv:%x,Name:%s."), T->EventId, @@ -2476,6 +2477,7 @@ int cFilterEEPG::GetTitlesSKYBOX (const u_char * Data, int Length) T->StartTime = ((MjdTime - 40587) * 86400) + ((Data[p + 2] << 9) | (Data[p + 3] << 1)); T->Duration = ((Data[p + 4] << 9) | (Data[p + 5] << 1)); T->ThemeId = Data[p + 6]; + T->TableId = DEFAULT_TABLE_ID; //TODO locate the actual table id //TODO Data[p + 7] is Quality value add it to description //int quality = Data[p + 7]; switch (Data[p + 8] & 0x0F) { @@ -2846,7 +2848,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat return; // only collect data for known channels } - //LogD(4, prep("channelID: %s format:%d"), *channel->GetChannelID().ToString(), Format); + //LogD(5, prep("channelID: %s format:%d"), *channel->GetChannelID().ToString(), Format); #ifdef USE_NOEPG // only use epg from channels not blocked by noEPG-patch @@ -2891,6 +2893,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat if (!pEvent) continue; } else { + //LogD(3, prep("existing event channelID: %s Title: %s TableID 0x%02X new TID 0x%02X Version %i, new version %i"), *channel->GetChannelID().ToString(), pEvent->Title(), pEvent->TableID(), Tid, pEvent->Version(), versionNumber); // We have found an existing event, either through its event ID or its start time. pEvent->SetSeen (); // If the existing event has a zero table ID it was defined externally and shall @@ -3025,7 +3028,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat continue; } - //LogD(2, prep("EEPGDEBUG:d->getDescriptorTAG():%x)"), d->getDescriptorTag ()); + LogD(2, prep("EEPGDEBUG:d->getDescriptorTAG():%x)"), d->getDescriptorTag ()); switch (d->getDescriptorTag ()) { case SI::ExtendedEventDescriptorTag: { @@ -3232,18 +3235,22 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat decodeText2 (f, l, buffer, sizeof (buffer)); //ShortEventDescriptor->name.getText(buffer, sizeof(buffer)); pEvent->SetTitle (buffer); + LogD(3, prep("channelID: %s Title: %s"), *channel->GetChannelID().ToString(), pEvent->Title()); l = ShortEventDescriptor->text.getLength(); f = (unsigned char *) ShortEventDescriptor->text.getData().getData(); decodeText2 (f, l, buffer, sizeof (buffer)); //ShortEventDescriptor->text.getText(buffer, sizeof(buffer)); pEvent->SetShortText (buffer); + LogD(3, prep("ShortText: %s"), pEvent->ShortText()); } else if (!HasExternalData) { pEvent->SetTitle (NULL); pEvent->SetShortText (NULL); + LogD(3, prep("SetTitle (NULL)")); } if (ExtendedEventDescriptors) { char buffer[Utf8BufSize (ExtendedEventDescriptors->getMaximumTextLength (": ")) + 1]; pEvent->SetDescription (ExtendedEventDescriptors->getText (buffer, sizeof (buffer), ": ")); + LogD(3, prep("Description: %s"), pEvent->Description()); } else if (!HasExternalData) pEvent->SetDescription (NULL); -- cgit v1.2.3 From 0bbc1965541f357ab6470010d63d7c42e096fafd Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Mon, 3 Oct 2011 14:11:30 +0200 Subject: fix table ID initialization --- eepg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eepg.c b/eepg.c index e243287..354471c 100644 --- a/eepg.c +++ b/eepg.c @@ -2151,6 +2151,7 @@ int cFilterEEPG::GetTitlesMHW2 (const u_char * Data, int Length) CleanString (T->Text); Pos += Len + 8; // Sub Theme starts here T->ThemeId = ((Data[7] & 0x3f) << 6) | (Data[Pos] & 0x3f); + T->TableId = DEFAULT_TABLE_ID; //TODO locate the actual table id T->EventId = (Data[Pos + 1] << 8) | Data[Pos + 2]; T->SummaryAvailable = (T->EventId != 0xFFFF); LogI(3, prep("EventId %04x Titlenr %d:SummAv:%x,Name:%s."), T->EventId, @@ -2476,6 +2477,7 @@ int cFilterEEPG::GetTitlesSKYBOX (const u_char * Data, int Length) T->StartTime = ((MjdTime - 40587) * 86400) + ((Data[p + 2] << 9) | (Data[p + 3] << 1)); T->Duration = ((Data[p + 4] << 9) | (Data[p + 5] << 1)); T->ThemeId = Data[p + 6]; + T->TableId = DEFAULT_TABLE_ID; //TODO locate the actual table id //TODO Data[p + 7] is Quality value add it to description //int quality = Data[p + 7]; switch (Data[p + 8] & 0x0F) { @@ -2974,7 +2976,8 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat } // If the new event has a higher table ID, let's skip it. // The lower the table ID, the more "current" the information. - else if (Tid > pEvent->TableID ()) + // if the Table ID is DEFAULT_TABLE_ID it is most probably EEPG event so we can overwrite + else if (Tid > pEvent->TableID() && pEvent->TableID () != DEFAULT_TABLE_ID) continue; // If the new event comes from the same table and has the same version number // as the existing one, let's skip it to avoid unnecessary work. -- cgit v1.2.3 From f30f80745607fe4573d8bcba3f643e8eb5ca72ac Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Mon, 3 Oct 2011 15:02:19 +0200 Subject: add process eit setup option for the moment in debug only --- eepg.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/eepg.c b/eepg.c index 2b6c702..1232119 100644 --- a/eepg.c +++ b/eepg.c @@ -110,6 +110,7 @@ public: int RatingInfo; int FixEpg; int DisplayMessage; + int ProcessEIT; #ifdef DEBUG int LogLevel; #endif @@ -127,6 +128,7 @@ cSetupEEPG::cSetupEEPG (void) RatingInfo = 1; FixEpg = 0; DisplayMessage = 1; + ProcessEIT = 0; #ifdef DEBUG LogLevel = 0; #endif @@ -163,6 +165,7 @@ cMenuSetupPremiereEpg::cMenuSetupPremiereEpg (void) Add (new cMenuEditBoolItem (tr ("Display summary message"), &data.DisplayMessage)); #ifdef DEBUG Add (new cMenuEditIntItem (tr ("Level of logging verbosity"), &data.LogLevel, 0, 5)); + Add (new cMenuEditBoolItem (tr ("Process EIT info with EEPG"), &data.ProcessEIT)); #endif } @@ -176,6 +179,7 @@ void cMenuSetupPremiereEpg::Store (void) SetupStore ("DisplayMessage", SetupPE.DisplayMessage); #ifdef DEBUG SetupStore ("LogLevel", SetupPE.LogLevel); + SetupStore ("ProcessEIT", SetupPE.ProcessEIT); #endif } @@ -2879,7 +2883,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat int versionNumber = getVersionNumber(); // increase version number for DISH_BEV EIT so it does not get overwriten by VDR. // TODO check the same for other providers. - if (Format == DISH_BEV && isEITPid) versionNumber++; + if ((Format == DISH_BEV || SetupPE.ProcessEIT )&& isEITPid) versionNumber++; cEvent *newEvent = NULL; cEvent *rEvent = NULL; @@ -2978,7 +2982,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat // If the new event has a higher table ID, let's skip it. // The lower the table ID, the more "current" the information. // if the Table ID is DEFAULT_TABLE_ID it is most probably EEPG event so we can overwrite - else if (Tid > pEvent->TableID() && pEvent->TableID () != DEFAULT_TABLE_ID) + else if (Tid > pEvent->TableID() && (SetupPE.ProcessEIT ? pEvent->TableID () != DEFAULT_TABLE_ID : true)) continue; // If the new event comes from the same table and has the same version number // as the existing one, let's skip it to avoid unnecessary work. @@ -3646,8 +3650,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len } // Enable EIT scan for all except DISH_BEV since it is already enabled - // TODO add setup option - if (!UnprocessedFormat[DISH_BEV]) { + if (SetupPE.ProcessEIT && !UnprocessedFormat[DISH_BEV]) { UnprocessedFormat[EIT] = EIT_PID; } } //if data[1] && data [3] @@ -4328,6 +4331,8 @@ bool cPluginEEPG::SetupParse (const char *Name, const char *Value) #ifdef DEBUG else if (!strcasecmp (Name, "LogLevel")) SetupPE.LogLevel = atoi (Value); + else if (!strcasecmp (Name, "ProcessEIT")) + SetupPE.ProcessEIT = atoi (Value); #endif else return false; -- cgit v1.2.3 From b4da1b8b6dfec941cb97cc14c7fc14040a7695ff Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Thu, 13 Oct 2011 19:58:23 +0200 Subject: NA tests, not working --- dish.c | 27 ++++++++++++++++++--------- eepg.c | 4 +++- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/dish.c b/dish.c index 4919ad8..7dd8c37 100644 --- a/dish.c +++ b/dish.c @@ -270,7 +270,7 @@ namespace SI { Decompress(Tid, data); if (decompressed) { - name = string((char*)decompressed); + name = string(reinterpret_cast(decompressed)); delete[] decompressed; decompressed = NULL; } else { @@ -282,14 +282,15 @@ namespace SI { Decompress(Tid, data); if (decompressed) { - char *split = strchr((char*)((decompressed)), 0x0D); // Look for carriage return + string str; + char *split = strchr(reinterpret_cast(decompressed), 0x0D); // Look for carriage return //LogD(2, prep("dLength:%d, length:%d, count:%d, decompressed: %s"), dLength, length, count, decompressed); if(split){ *split = 0; - shortText = string((char*)decompressed); + shortText = string(reinterpret_cast(decompressed)); description = string((split[1] == 0x20) ? split + 2 : split + 1); }else{ - description = string((char*)decompressed); + description = string(reinterpret_cast(decompressed)); } delete[] decompressed; decompressed = NULL; @@ -301,35 +302,43 @@ namespace SI const char *DishDescriptor::getShortText(void) { - string tmp = ""; + isyslog("EEPG DISH: shortText: %s", shortText.c_str()); + string tmp = shortText; // if (shortText != NULL) tmp += *shortText; - tmp += shortText; + //if (shortText != NULL) tmp.append(shortText); if(DishTheme > 0){ if(tmp != "") tmp += " - "; - tmp += getTheme(); + tmp.append(getTheme()); + isyslog("EEPG DISH: theme: %s", getTheme()); } if(DishCategory > 0){ if(tmp != "") tmp += " - "; - tmp += getCategory(); + isyslog("EEPG DISH: category: %s", getCategory()); + tmp.append(getCategory()); } + isyslog("EEPG DISH: full shorttext: %s", tmp.c_str()); return tmp.c_str(); } const char *DishDescriptor::getDescription(void) { - string tmp = ""; + string tmp = description; // if (description != NULL) tmp += *description; tmp += description; + isyslog("EEPG DISH: description: %s", description.c_str()); const char* rating = getRating(); if (rating && strcmp(rating,"") != 0) { if(tmp != "") tmp += " ~ "; tmp += rating; + isyslog("EEPG DISH: rating: %s", rating); } if (starRating > 0) { if(tmp != "") tmp += " ~ "; tmp += getStarRating(); + isyslog("EEPG DISH: star: %s", getStarRating()); } + isyslog("EEPG DISH: full description: %s", tmp.c_str()); return tmp.c_str(); } diff --git a/eepg.c b/eepg.c index 1232119..63394d0 100644 --- a/eepg.c +++ b/eepg.c @@ -3256,8 +3256,10 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat char buffer[Utf8BufSize (ExtendedEventDescriptors->getMaximumTextLength (": ")) + 1]; pEvent->SetDescription (ExtendedEventDescriptors->getText (buffer, sizeof (buffer), ": ")); LogD(3, prep("Description: %s"), pEvent->Description()); - } else if (!HasExternalData) + } else if (!HasExternalData) { pEvent->SetDescription (NULL); + LogD(3, prep("SetDescription (NULL)")); + } if (DishEventDescriptor) { pEvent->SetTitle(DishEventDescriptor->getName()); -- cgit v1.2.3 From 7fa4996bd7c20ee606cdf5e464bd8aca9ef3d936 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 29 Oct 2011 13:14:37 +0200 Subject: fix compile from forgoten { --- eepg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eepg.c b/eepg.c index 15e1329..99cd7c3 100644 --- a/eepg.c +++ b/eepg.c @@ -3272,7 +3272,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat char buffer[Utf8BufSize (ExtendedEventDescriptors->getMaximumTextLength (": ")) + 1]; pEvent->SetDescription (ExtendedEventDescriptors->getText (buffer, sizeof (buffer), ": ")); LogD(3, prep("Description: %s"), pEvent->Description()); - } else if (!HasExternalData) { + } else if (!HasExternalData) pEvent->SetDescription (NULL); if (DishEventDescriptor) { -- cgit v1.2.3 From ca097cfc4edec21238debe223a9a0110173444f2 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 29 Oct 2011 13:18:46 +0200 Subject: enable DEBUG for testing --- eepg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eepg.c b/eepg.c index 99cd7c3..53cfa31 100644 --- a/eepg.c +++ b/eepg.c @@ -54,7 +54,7 @@ #define trNOOP(s) (s) #endif -//#define DEBUG +#define DEBUG //#define DEBUG2 /*#ifdef DEBUG -- cgit v1.2.3 From a00a672563ef11d3ae7b26cd0c33d993a802a447 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 29 Oct 2011 13:19:30 +0200 Subject: disable DEBUG --- eepg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eepg.c b/eepg.c index 53cfa31..99cd7c3 100644 --- a/eepg.c +++ b/eepg.c @@ -54,7 +54,7 @@ #define trNOOP(s) (s) #endif -#define DEBUG +//#define DEBUG //#define DEBUG2 /*#ifdef DEBUG -- cgit v1.2.3 From fe74fa75423e7a63a295a4913a4650bb48cd0267 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 29 Oct 2011 19:32:02 +0200 Subject: try to use equivalent channels for continuous formats as well --- eepg.c | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 151 insertions(+), 35 deletions(-) diff --git a/eepg.c b/eepg.c index 99cd7c3..ec649d4 100644 --- a/eepg.c +++ b/eepg.c @@ -263,6 +263,9 @@ static int AvailableSources[32]; static int NumberOfAvailableSources = 0; static int LastVersionNagra = -1; //currently only used for Nagra, should be stored per transponder, per system +static multimap equiChanMap; + + #ifdef USE_NOEPG bool allowedEPG (tChannelID kanalID) { @@ -1034,6 +1037,76 @@ void decodeText2 (const unsigned char *from, int len, char *buffer, int buffsize //LogE(5, prep("decodeText2 buffer %s - buffsize %d"), buffer, buffsize); } +void loadEquivalentChannelMap (void) +{ + char Buffer[1024]; + char *Line; + FILE *File; + string FileName = string(ConfDir) + "/" + EEPG_FILE_EQUIV; + multimap::iterator it; + pair::iterator,multimap::iterator> ret; + + + File = fopen (FileName.c_str(), "r"); + if (File) { + memset (Buffer, 0, sizeof (Buffer)); + char origChanID[256]; + char equiChanID[256]; + char source[256]; + int nid = 0; + int tid = 0; + int sid = 0; + int rid = 0; + while ((Line = fgets (Buffer, sizeof (Buffer), File)) != NULL) { + Line = compactspace (skipspace (stripspace (Line))); + if (!isempty (Line)) { + if (sscanf (Line, "%[^ ] %[^ ] %[^\n]\n", origChanID, equiChanID, source) == 3) { + if (origChanID[0] != '#' && origChanID[0] != ';') { + nid = 0; + tid = 0; + sid = 0; + rid = 0; + if (sscanf (origChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) + if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { + if (sscanf (origChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) != 5) { + rid = 0; + } + tChannelID OriginalChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); + bool found = false; + int i = 0; + cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); + if (!OriginalChannel) { + LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalency is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? + continue; + } + if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { + if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) + != 5) { + rid = 0; + } + tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); + cChannel *EquivChannel = Channels.GetByChannelID (EquivChID, false); //TODO use valid function? + if (EquivChannel) { + ret = equiChanMap.equal_range(OriginalChID.ToString()); + for (it=ret.first; it!=ret.second; ++it) + if ((*it).second == OriginalChID.ToString()) { + found = true; + break; + } + + if (!found) + equiChanMap.insert(pair(OriginalChID.ToString(),EquivChID.ToString())); + } else + LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); + } + } //if scanf string1 + } //if string1 + } //if scanf + } //if isempty + } //while + fclose (File); + } //if file +} void cFilterEEPG::LoadEquivalentChannels (void) { char Buffer[1024]; @@ -1044,52 +1117,52 @@ void cFilterEEPG::LoadEquivalentChannels (void) File = fopen (FileName.c_str(), "r"); if (File) { memset (Buffer, 0, sizeof (Buffer)); - char string1[256]; - char string2[256]; - char string3[256]; - int int1; - int int2; - int int3; - int int4; + char origChanID[256]; + char equiChanID[256]; + char source[256]; + int nid; + int tid; + int sid; + int rid; while ((Line = fgets (Buffer, sizeof (Buffer), File)) != NULL) { Line = compactspace (skipspace (stripspace (Line))); if (!isempty (Line)) { - if (sscanf (Line, "%[^ ] %[^ ] %[^\n]\n", string1, string2, string3) == 3) { - if (string1[0] != '#' && string1[0] != ';') { - int1 = 0; //TODO: this could be made more readable - int2 = 0; - int3 = 0; - int4 = 0; - if (sscanf (string1, "%[^-]-%i -%i -%i ", string3, &int1, &int2, &int3) == 4) - if (sscanf (string2, "%[^-]-%i -%i -%i ", string3, &int1, &int2, &int3) == 4) { - if (sscanf (string1, "%[^-]-%i -%i -%i -%i ", string3, &int1, &int2, &int3, &int4) != 5) { - int4 = 0; + if (sscanf (Line, "%[^ ] %[^ ] %[^\n]\n", origChanID, equiChanID, source) == 3) { + if (origChanID[0] != '#' && origChanID[0] != ';') { + nid = 0; + tid = 0; + sid = 0; + rid = 0; + if (sscanf (origChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) + if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { + if (sscanf (origChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) != 5) { + rid = 0; } - tChannelID OriginalChID = tChannelID (cSource::FromString (string3), int1, int2, int3, int4); + tChannelID OriginalChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); bool found = false; int i = 0; sChannel *C = NULL; while (i < nChannels && (!found)) { C = &sChannels[i]; - if (C->Src[0] == (unsigned int)cSource::FromString (string3) && C->Nid[0] == int1 - && C->Tid[0] == int2 && C->Sid[0] == int3) + if (C->Src[0] == (unsigned int)cSource::FromString (source) && C->Nid[0] == nid + && C->Tid[0] == tid && C->Sid[0] == sid) found = true; else i++; } if (!found) { LogI(2, prep("Warning: in equivalence file, cannot find original channel %s. Perhaps you are tuned to another transponder right now."), - string1); + origChanID); } else { cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); if (!OriginalChannel) - LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalency is assumed to be valid, but perhaps you should check the entry in the equivalents file"), string1); //TODO: skip this ing? - if (sscanf (string2, "%[^-]-%i -%i -%i ", string3, &int1, &int2, &int3) == 4) { - if (sscanf (string2, "%[^-]-%i -%i -%i -%i ", string3, &int1, &int2, &int3, &int4) + LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalency is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? + if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { + if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) != 5) { - int4 = 0; + rid = 0; } - tChannelID EquivChID = tChannelID (cSource::FromString (string3), int1, int2, int3, int4); + tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); cChannel *EquivChannel = Channels.GetByChannelID (EquivChID, false); //TODO use valid function? if (EquivChannel) { if (C->NumberOfEquivalences < MAX_EQUIVALENCES) { @@ -1107,7 +1180,7 @@ void cFilterEEPG::LoadEquivalentChannels (void) LogE(0, prep("Error, channel with id %i has more than %i equivalences. Increase MAX_EQUIVALENCES."), i, MAX_EQUIVALENCES); } else - LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), string2); + LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); } } //else !found } //if scanf string1 @@ -1119,6 +1192,9 @@ void cFilterEEPG::LoadEquivalentChannels (void) } //if file } //end of loadequiv +//end of loadequiv + + /** * \brief Get MHW channels * @@ -2834,8 +2910,40 @@ class cEIT2:public SI::EIT { public: cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool isEITPid = false, bool OnlyRunningStatus = false); +protected: + void updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent); }; +void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent){ + multimap::iterator it; + pair::iterator,multimap::iterator> ret; + + ret = equiChanMap.equal_range(channelID.ToString()); + for (it=ret.first; it!=ret.second; ++it) { + tChannelID equChannelID (tChannelID::FromString((*it).second)); + cChannel *equChannel = GetChannelByID (equChannelID, false); + if (equChannel) { + cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (equChannel, true); + cEvent *pEqvEvent = (cEvent *) pSchedule->GetEvent (pEvent->EventID(), pEvent->StartTime()); + if (pEqvEvent) { + LogD(1, prep("equivalent event exists")); + if (pEqvEvent == pEvent) { + LogD(1, prep("equal event exists")); + + } else { + LogD(1, prep("remove equivalent")); + pSchedule->DelEvent(pEqvEvent); + pSchedule->AddEvent(pEvent); + } + + } else { + LogD(1, prep("equivalent event does not exist")); + pSchedule->AddEvent(pEvent); + } + } + } +} + cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool isEITPid, bool OnlyRunningStatus) : SI::EIT (Data, false) { @@ -2897,10 +3005,13 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat pEvent = newEvent = new cEvent (SiEitEvent.getEventId ()); if (!pEvent) continue; + updateEquivalent(Schedules, channel->GetChannelID(), pEvent); } else { //LogD(3, prep("existing event channelID: %s Title: %s TableID 0x%02X new TID 0x%02X Version %i, new version %i"), *channel->GetChannelID().ToString(), pEvent->Title(), pEvent->TableID(), Tid, pEvent->Version(), versionNumber); // We have found an existing event, either through its event ID or its start time. pEvent->SetSeen (); + + updateEquivalent(Schedules, channel->GetChannelID(), pEvent); // If the existing event has a zero table ID it was defined externally and shall // not be overwritten. if (pEvent->TableID () == 0x00) { @@ -3258,10 +3369,12 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat pEvent->SetTitle (buffer); LogD(3, prep("channelID: %s Title: %s"), *channel->GetChannelID().ToString(), pEvent->Title()); l = ShortEventDescriptor->text.getLength(); - f = (unsigned char *) ShortEventDescriptor->text.getData().getData(); - decodeText2 (f, l, buffer, sizeof (buffer)); - //ShortEventDescriptor->text.getText(buffer, sizeof(buffer)); - pEvent->SetShortText (buffer); + if (l > 0) { //Set the Short Text only if ther is data so that we do not overwrite valid data + f = (unsigned char *) ShortEventDescriptor->text.getData().getData(); + decodeText2 (f, l, buffer, sizeof (buffer)); + //ShortEventDescriptor->text.getText(buffer, sizeof(buffer)); + pEvent->SetShortText (buffer); + } LogD(3, prep("ShortText: %s"), pEvent->ShortText()); } else if (!HasExternalData) { pEvent->SetTitle (NULL); @@ -3476,6 +3589,13 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) FreeTitles (); FreeSummaries (); + // Enable EIT scan for all except DISH_BEV since it is already enabled + if (SetupPE.ProcessEIT && !UnprocessedFormat[EIT] + && !UnprocessedFormat[FREEVIEW] && !UnprocessedFormat[DISH_BEV]) { + UnprocessedFormat[EIT] = EIT_PID; + loadEquivalentChannelMap(); + } + //now start looking for next format to process int pid; for (int i = 0; i <= HIGHEST_FORMAT; i++){ //find first format that is detected @@ -3712,10 +3832,6 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len UnprocessedFormat[DISH_BEV] = stream.getPid (); } - // Enable EIT scan for all except DISH_BEV since it is already enabled - if (SetupPE.ProcessEIT && !UnprocessedFormat[DISH_BEV]) { - UnprocessedFormat[EIT] = EIT_PID; - } } //if data[1] && data [3] } //if streamtype /*if (Format != PREMIERE) //any format found -- cgit v1.2.3 From fd141db09413ec5c48bd03d692163a72a18884d1 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 28 Feb 2012 00:06:48 +0100 Subject: modified map to use const char* instead of cString which has problems with < operator --- eepg.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/eepg.c b/eepg.c index 882babc..3ae9c9e 100644 --- a/eepg.c +++ b/eepg.c @@ -263,7 +263,7 @@ static int AvailableSources[32]; static int NumberOfAvailableSources = 0; static int LastVersionNagra = -1; //currently only used for Nagra, should be stored per transponder, per system -static multimap equiChanMap; +static multimap equiChanMap; #ifdef USE_NOEPG @@ -1045,8 +1045,8 @@ void loadEquivalentChannelMap (void) char *Line; FILE *File; string FileName = string(ConfDir) + "/" + EEPG_FILE_EQUIV; - multimap::iterator it; - pair::iterator,multimap::iterator> ret; + multimap::iterator it; + pair::iterator,multimap::iterator> ret; File = fopen (FileName.c_str(), "r"); @@ -1075,7 +1075,7 @@ void loadEquivalentChannelMap (void) } tChannelID OriginalChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); bool found = false; - int i = 0; + //int i = 0; cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); if (!OriginalChannel) { LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalency is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? @@ -1089,9 +1089,9 @@ void loadEquivalentChannelMap (void) tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); cChannel *EquivChannel = Channels.GetByChannelID (EquivChID, false); //TODO use valid function? if (EquivChannel) { - ret = equiChanMap.equal_range(OriginalChID.ToString()); + ret = equiChanMap.equal_range(*OriginalChID.ToString()); for (it=ret.first; it!=ret.second; ++it) - if ((*it).second == OriginalChID.ToString()) { + if ((*it).second == *OriginalChID.ToString()) { found = true; break; } @@ -2917,10 +2917,10 @@ protected: }; void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent){ - multimap::iterator it; - pair::iterator,multimap::iterator> ret; + multimap::iterator it; + pair::iterator,multimap::iterator> ret; - ret = equiChanMap.equal_range(channelID.ToString()); + ret = equiChanMap.equal_range(*channelID.ToString()); for (it=ret.first; it!=ret.second; ++it) { tChannelID equChannelID (tChannelID::FromString((*it).second)); cChannel *equChannel = GetChannelByID (equChannelID, false); -- cgit v1.2.3 From d367ef95a8ff4a42dec4aff085e9bad5546a3c1f Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 28 Feb 2012 21:46:26 +0100 Subject: equivalent channels logging --- eepg.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eepg.c b/eepg.c index 3ae9c9e..96efeda 100644 --- a/eepg.c +++ b/eepg.c @@ -1107,6 +1107,7 @@ void loadEquivalentChannelMap (void) } //if isempty } //while fclose (File); + LogD(3, prep("Loaded %i equivalents."), equiChanMap.size()); } //if file } void cFilterEEPG::LoadEquivalentChannels (void) @@ -2920,6 +2921,8 @@ void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEven multimap::iterator it; pair::iterator,multimap::iterator> ret; + LogD(3, prep("Start updateEquivalent"), equiChanMap.size()); + ret = equiChanMap.equal_range(*channelID.ToString()); for (it=ret.first; it!=ret.second; ++it) { tChannelID equChannelID (tChannelID::FromString((*it).second)); -- cgit v1.2.3 From 9aea13ab42937e62243f833c960e452966b9f115 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 28 Feb 2012 21:59:51 +0100 Subject: logging --- eepg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eepg.c b/eepg.c index 96efeda..810923a 100644 --- a/eepg.c +++ b/eepg.c @@ -2921,13 +2921,14 @@ void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEven multimap::iterator it; pair::iterator,multimap::iterator> ret; - LogD(3, prep("Start updateEquivalent"), equiChanMap.size()); + LogD(3, prep("Start updateEquivalent %s"), *channelID.ToString()); ret = equiChanMap.equal_range(*channelID.ToString()); for (it=ret.first; it!=ret.second; ++it) { tChannelID equChannelID (tChannelID::FromString((*it).second)); cChannel *equChannel = GetChannelByID (equChannelID, false); if (equChannel) { + LogD(3, prep("found Equivalent channel %s"), *equChannelID.ToString()); cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (equChannel, true); cEvent *pEqvEvent = (cEvent *) pSchedule->GetEvent (pEvent->EventID(), pEvent->StartTime()); if (pEqvEvent) { -- cgit v1.2.3 From 2a191f66333019b5e284b48e1a097b12f3129040 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 28 Feb 2012 22:12:40 +0100 Subject: forgotten cString --- eepg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eepg.c b/eepg.c index 810923a..b4f7636 100644 --- a/eepg.c +++ b/eepg.c @@ -1097,7 +1097,7 @@ void loadEquivalentChannelMap (void) } if (!found) - equiChanMap.insert(pair(OriginalChID.ToString(),EquivChID.ToString())); + equiChanMap.insert(pair(*OriginalChID.ToString(),*EquivChID.ToString())); } else LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); } -- cgit v1.2.3 From 31cdcf57887573af3eff234f08dd23f1749a2d1e Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 29 Feb 2012 09:12:20 +0100 Subject: do not reload equivalents if already loaded --- eepg.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eepg.c b/eepg.c index b4f7636..edf06fd 100644 --- a/eepg.c +++ b/eepg.c @@ -1048,6 +1048,10 @@ void loadEquivalentChannelMap (void) multimap::iterator it; pair::iterator,multimap::iterator> ret; + //TODO DPE add code to reload if file is changed + if (equiChanMap.size() > 0) + return; + File = fopen (FileName.c_str(), "r"); if (File) { -- cgit v1.2.3 From c77f11f852016b78d57bea006d11fe440b27edd9 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 29 Feb 2012 11:50:12 +0100 Subject: Applied patch to Load Huffman dictionaries only on first use --- eepg.c | 484 +++++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 262 insertions(+), 222 deletions(-) diff --git a/eepg.c b/eepg.c index e8d5edb..5f220cd 100644 --- a/eepg.c +++ b/eepg.c @@ -315,7 +315,6 @@ protected: virtual void ProcessNextFormat (bool FirstTime); virtual int GetChannelsSKYBOX (const u_char * Data, int Length); virtual bool GetThemesSKYBOX (void); - virtual bool ReadFileDictionary (void); //Reads Huffman tables for SKY virtual int GetTitlesSKYBOX (const u_char * Data, int Length); virtual int GetSummariesSKYBOX (const u_char * Data, int Length); virtual int GetChannelsMHW (const u_char * Data, int Length, int MHW); //TODO replace MHW by Format? @@ -347,6 +346,7 @@ public: cFilterEEPG (void); virtual void SetStatus (bool On); void Trigger (void); + bool InitDictionary (void); //Initialize the Huffman tables for SKY and Freesat }; cFilterEEPG::cFilterEEPG (void) @@ -432,6 +432,7 @@ int freesat_decode_error = 0; /* If set an error has occurred during decoding */ static struct hufftab *tables[2][256]; static int table_size[2][256]; +sNodeH sky_tables[2]; /** \brief Convert a textual character description into a value * @@ -484,8 +485,9 @@ static unsigned long decode_binary (char *binary) * * \param tableid - Table id that should be loaded * \param filename - Filename to load + * \return Success of operation */ -static void load_file (int tableid, const char *filename) +static bool load_freesat_file (int tableid, const char *filename) { char buf[1024]; char *from, *to, *binary; @@ -493,7 +495,7 @@ static void load_file (int tableid, const char *filename) tableid--; if ((fp = fopen (filename, "r")) != NULL) { - LogI(0, prep("Loading table %d Filename <%s>"), tableid + 1, filename); + LogI(2, prep("Loading table %d Filename <%s>"), tableid + 1, filename); while (fgets (buf, sizeof (buf), fp) != NULL) { from = binary = to = NULL; @@ -518,9 +520,139 @@ static void load_file (int tableid, const char *filename) fclose (fp); } else { LogE(0, prep("Cannot load <%s> for table %d"), filename, tableid + 1); + return false; } + return true; } +/** \brief Load an individual freesat data file + * + * \param filename - Filename to load + * \return Success of operation + */ +static bool load_sky_file (const char *filename) +{ + FILE *FileDict; + char *Line; + char Buffer[256]; + sNodeH *nH; + int tableId; + + FileDict = fopen (filename, "r"); + if (FileDict == NULL) { + LogE (0, prep("Error opening file '%s'. %s"), filename, strerror (errno)); + return false; + } else { + int i; + int LenPrefix; + char string1[256]; + char string2[256]; + + tableId = Format == SKY_IT ? 0 : 1; + sky_tables[tableId].Value = NULL; + sky_tables[tableId].P0 = NULL; + sky_tables[tableId].P1 = NULL; + while ((Line = fgets (Buffer, sizeof (Buffer), FileDict)) != NULL) { + if (!isempty (Line)) { + memset (string1, 0, sizeof (string1)); + memset (string2, 0, sizeof (string2)); + if (sscanf (Line, "%c=%[^\n]\n", string1, string2) == 2 + || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) { + nH = & sky_tables[tableId]; + LenPrefix = strlen (string2); + for (i = 0; i < LenPrefix; i++) { + switch (string2[i]) { + case '0': + if (nH->P0 == NULL) { + nH->P0 = new sNodeH (); + nH = nH->P0; + nH->Value = NULL; + nH->P0 = NULL; + nH->P1 = NULL; + if ((LenPrefix - 1) == i) { + Asprintf (&nH->Value, "%s", string1); + } + } else { + nH = nH->P0; + if (nH->Value != NULL || (LenPrefix - 1) == i) { + LogE (0 ,prep("Error, huffman prefix code already exists for \"%s\"=%s with '%s'"), string1, + string2, nH->Value); + } + } + break; + case '1': + if (nH->P1 == NULL) { + nH->P1 = new sNodeH (); + nH = nH->P1; + nH->Value = NULL; + nH->P0 = NULL; + nH->P1 = NULL; + if ((LenPrefix - 1) == i) { + Asprintf (&nH->Value, "%s", string1); + } + } else { + nH = nH->P1; + if (nH->Value != NULL || (LenPrefix - 1) == i) { + LogE (0, prep("Error, huffman prefix code already exists for \"%s\"=%s with '%s'"), string1, + string2, nH->Value); + } + } + break; + default: + break; + } + } + } + } + } + fclose (FileDict); + } + + // check tree huffman nodes + FileDict = fopen (filename, "r"); + if (FileDict) { + int i; + int LenPrefix; + char string1[256]; + char string2[256]; + while ((Line = fgets (Buffer, sizeof (Buffer), FileDict)) != NULL) { + if (!isempty (Line)) { + memset (string1, 0, sizeof (string1)); + memset (string2, 0, sizeof (string2)); + if (sscanf (Line, "%c=%[^\n]\n", string1, string2) == 2 + || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) { + nH = &sky_tables[tableId]; + LenPrefix = strlen (string2); + for (i = 0; i < LenPrefix; i++) { + switch (string2[i]) { + case '0': + if (nH->P0 != NULL) { + nH = nH->P0; + } + break; + case '1': + if (nH->P1 != NULL) { + nH = nH->P1; + } + break; + default: + break; + } + } + if (nH->Value != NULL) { + if (memcmp (nH->Value, string1, strlen (nH->Value)) != 0) { + LogE (0, prep("Error, huffman prefix value '%s' not equal to '%s'"), nH->Value, string1); + } + } else { + LogE (0, prep("Error, huffman prefix value is not exists for \"%s\"=%s"), string1, string2); + } + } + } + } + fclose (FileDict); + } + return true; +} /** \brief Decode an EPG string as necessary * @@ -617,12 +749,103 @@ char *freesat_huffman_decode (const unsigned char *src, size_t size) return NULL; } +int sky_huffman_decode (const u_char * Data, int Length, unsigned char *DecodeText) +{ + sNodeH *nH, &H=(Format==SKY_IT)?sky_tables[0]:sky_tables[1]; + int i; + int p; + int q; + bool CodeError; + bool IsFound; + unsigned char Byte; + unsigned char lastByte; + unsigned char Mask; + unsigned char lastMask; + nH = &H; + p = 0; + q = 0; + DecodeText[0] = '\0'; + //DecodeErrorText[0] = '\0'; + CodeError = false; + IsFound = false; + lastByte = 0; + lastMask = 0; + for (i = 0; i < Length; i++) { + Byte = Data[i]; + Mask = 0x80; + if (i == 0) { + Mask = 0x20; + lastByte = i; + lastMask = Mask; + } +loop1: + if (IsFound) { + lastByte = i; + lastMask = Mask; + IsFound = false; + } + if ((Byte & Mask) == 0) { + if (CodeError) { + //DecodeErrorText[q] = 0x30; + q++; + goto nextloop1; + } + if (nH->P0 != NULL) { + nH = nH->P0; + if (nH->Value != NULL) { + memcpy (&DecodeText[p], nH->Value, strlen (nH->Value)); + p += strlen (nH->Value); + nH = &H; + IsFound = true; + } + } else { + memcpy (&DecodeText[p], "<...?...>", 9); + p += 9; + i = lastByte; + Byte = Data[lastByte]; + Mask = lastMask; + CodeError = true; + goto loop1; + } + } else { + if (CodeError) { + //DecodeErrorText[q] = 0x31; + q++; + goto nextloop1; + } + if (nH->P1 != NULL) { + nH = nH->P1; + if (nH->Value != NULL) { + memcpy (&DecodeText[p], nH->Value, strlen (nH->Value)); + p += strlen (nH->Value); + nH = &H; + IsFound = true; + } + } else { + memcpy (&DecodeText[p], "<...?...>", 9); + p += 9; + i = lastByte; + Byte = Data[lastByte]; + Mask = lastMask; + CodeError = true; + goto loop1; + } + } +nextloop1: + Mask = Mask >> 1; + if (Mask > 0) { + goto loop1; + } + } + DecodeText[p] = '\0'; + //DecodeErrorText[q] = '\0'; + return p; +} + //here all declarations for global variables over all devices char *ConfDir; -sNodeH *nH, H; - //unsigned char DecodeErrorText[4096]; //TODO only used for debugging? int Yesterday; @@ -776,7 +999,11 @@ bool cFilterEEPG::GetThemesSKYBOX (void) //TODO can't we read this from the DVB return true; } -bool cFilterEEPG::ReadFileDictionary (void) +/** + * \brief Initialize the Huffman dictionaries if they are not already initialized. + * + */ +bool cFilterEEPG::InitDictionary (void) { string FileName = ConfDir; FILE *FileDict; @@ -784,230 +1011,43 @@ bool cFilterEEPG::ReadFileDictionary (void) char Buffer[256]; switch (Format) { case SKY_IT: - FileName += "/sky_it.dict"; + if (sky_tables[0] == NULL) { + FileName += "/sky_it.dict"; + LogD (1, prep("EEPGDebug: loading sky_it.dict")); + return load_sky_file(FileName.c_str()); + } else + LogD (1, prep("EEPGDebug: sky_it.dict already loaded")); break; case SKY_UK: - FileName += "/sky_uk.dict"; + if (sky_tables[1] == NULL) { + FileName += "/sky_uk.dict"; + LogD (1, prep("EEPGDebug: loading sky_uk.dict")); + return load_sky_file(FileName.c_str()); + } else + LogD (1, prep("EEPGDebug: sky_uk.dict already loaded")); break; case FREEVIEW: - FileName += "/freesat.t1"; - load_file (1, FileName.c_str()); - FileName = ConfDir; - FileName += "/freesat.t2"; - load_file (2, FileName.c_str()); + if (tables == NULL) { + LogD (1, prep("EEPGDebug: loading freesat.dict")); + FileName += "/freesat.t1"; + if (!load_freesat_file (1, FileName.c_str())) + return false; + FileName = ConfDir; + FileName += "/freesat.t2"; + return load_freesat_file (2, FileName.c_str()); + } else + LogD (1, prep("EEPGDebug: freesat.dict already loaded")); break; default: LogE (0 ,prep("Error, wrong format detected in ReadFileDictionary. Format = %i."), Format); return false; } - if ((Format == SKY_IT) || (Format == SKY_UK)) { //SKY - FileDict = fopen (FileName.c_str(), "r"); - if (FileDict == NULL) { - LogE (0, prep("Error opening file '%s'. %s"), FileName.c_str(), strerror (errno)); - return false; - } else { - int i; - int LenPrefix; - char string1[256]; - char string2[256]; - H.Value = NULL; - H.P0 = NULL; - H.P1 = NULL; - while ((Line = fgets (Buffer, sizeof (Buffer), FileDict)) != NULL) { - if (!isempty (Line)) { - memset (string1, 0, sizeof (string1)); - memset (string2, 0, sizeof (string2)); - if (sscanf (Line, "%c=%[^\n]\n", string1, string2) == 2 - || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) { - nH = &H; - LenPrefix = strlen (string2); - for (i = 0; i < LenPrefix; i++) { - switch (string2[i]) { - case '0': - if (nH->P0 == NULL) { - nH->P0 = new sNodeH (); - nH = nH->P0; - nH->Value = NULL; - nH->P0 = NULL; - nH->P1 = NULL; - if ((LenPrefix - 1) == i) { - Asprintf (&nH->Value, "%s", string1); - } - } else { - nH = nH->P0; - if (nH->Value != NULL || (LenPrefix - 1) == i) { - LogE (0 ,prep("Error, huffman prefix code already exists for \"%s\"=%s with '%s'"), string1, - string2, nH->Value); - } - } - break; - case '1': - if (nH->P1 == NULL) { - nH->P1 = new sNodeH (); - nH = nH->P1; - nH->Value = NULL; - nH->P0 = NULL; - nH->P1 = NULL; - if ((LenPrefix - 1) == i) { - Asprintf (&nH->Value, "%s", string1); - } - } else { - nH = nH->P1; - if (nH->Value != NULL || (LenPrefix - 1) == i) { - LogE (0, prep("Error, huffman prefix code already exists for \"%s\"=%s with '%s'"), string1, - string2, nH->Value); - } - } - break; - default: - break; - } - } - } - } - } - fclose (FileDict); - } - - // check tree huffman nodes - FileDict = fopen (FileName.c_str(), "r"); - if (FileDict) { - int i; - int LenPrefix; - char string1[256]; - char string2[256]; - while ((Line = fgets (Buffer, sizeof (Buffer), FileDict)) != NULL) { - if (!isempty (Line)) { - memset (string1, 0, sizeof (string1)); - memset (string2, 0, sizeof (string2)); - if (sscanf (Line, "%c=%[^\n]\n", string1, string2) == 2 - || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) { - nH = &H; - LenPrefix = strlen (string2); - for (i = 0; i < LenPrefix; i++) { - switch (string2[i]) { - case '0': - if (nH->P0 != NULL) { - nH = nH->P0; - } - break; - case '1': - if (nH->P1 != NULL) { - nH = nH->P1; - } - break; - default: - break; - } - } - if (nH->Value != NULL) { - if (memcmp (nH->Value, string1, strlen (nH->Value)) != 0) { - LogE (0, prep("Error, huffman prefix value '%s' not equal to '%s'"), nH->Value, string1); - } - } else { - LogE (0, prep("Error, huffman prefix value is not exists for \"%s\"=%s"), string1, string2); - } - } - } - } - fclose (FileDict); - } - } //if Format == 3 || Format == 4 +// if ((Format == SKY_IT) || (Format == SKY_UK)) { //SKY +// return load_sky_file(FileName.c_str()); +// } //if Format == 3 || Format == 4 return true; } -int DecodeHuffmanCode (const u_char * Data, int Length, unsigned char *DecodeText) -{ - int i; - int p; - int q; - bool CodeError; - bool IsFound; - unsigned char Byte; - unsigned char lastByte; - unsigned char Mask; - unsigned char lastMask; - nH = &H; - p = 0; - q = 0; - DecodeText[0] = '\0'; - //DecodeErrorText[0] = '\0'; - CodeError = false; - IsFound = false; - lastByte = 0; - lastMask = 0; - for (i = 0; i < Length; i++) { - Byte = Data[i]; - Mask = 0x80; - if (i == 0) { - Mask = 0x20; - lastByte = i; - lastMask = Mask; - } -loop1: - if (IsFound) { - lastByte = i; - lastMask = Mask; - IsFound = false; - } - if ((Byte & Mask) == 0) { - if (CodeError) { - //DecodeErrorText[q] = 0x30; - q++; - goto nextloop1; - } - if (nH->P0 != NULL) { - nH = nH->P0; - if (nH->Value != NULL) { - memcpy (&DecodeText[p], nH->Value, strlen (nH->Value)); - p += strlen (nH->Value); - nH = &H; - IsFound = true; - } - } else { - memcpy (&DecodeText[p], "<...?...>", 9); - p += 9; - i = lastByte; - Byte = Data[lastByte]; - Mask = lastMask; - CodeError = true; - goto loop1; - } - } else { - if (CodeError) { - //DecodeErrorText[q] = 0x31; - q++; - goto nextloop1; - } - if (nH->P1 != NULL) { - nH = nH->P1; - if (nH->Value != NULL) { - memcpy (&DecodeText[p], nH->Value, strlen (nH->Value)); - p += strlen (nH->Value); - nH = &H; - IsFound = true; - } - } else { - memcpy (&DecodeText[p], "<...?...>", 9); - p += 9; - i = lastByte; - Byte = Data[lastByte]; - Mask = lastMask; - CodeError = true; - goto loop1; - } - } -nextloop1: - Mask = Mask >> 1; - if (Mask > 0) { - goto loop1; - } - } - DecodeText[p] = '\0'; - //DecodeErrorText[q] = '\0'; - return p; -} - void decodeText2 (const unsigned char *from, int len, char *buffer, int buffsize) { if (from[0] == 0x1f) { @@ -2505,7 +2545,7 @@ int cFilterEEPG::GetTitlesSKYBOX (const u_char * Data, int Length) T->Unknown2 = Data[p + 4 - 12]; //FIXME T->Unknown3 = Data[p + 4 - 11]; //FIXME unsigned char tmp[4096]; //TODO smarter - Len2 = DecodeHuffmanCode (&Data[p + 9], Len2, tmp); + Len2 = sky_huffman_decode (&Data[p + 9], Len2, tmp); if (Len2 == 0) { LogE(0, prep("Warning, could not huffman-decode title-text, skipping title.")); return 1; //non-fatal error @@ -2583,7 +2623,7 @@ int cFilterEEPG::GetSummariesSKYBOX (const u_char * Data, int Length) p += 4; Len2 = Data[p + 1]; unsigned char tmp[4096]; //TODO can this be done better? - Len2 = DecodeHuffmanCode (&Data[p + 2], Len2, tmp); + Len2 = sky_huffman_decode (&Data[p + 2], Len2, tmp); if (Len2 == 0) { LogE(0, prep("Warning, could not huffman-decode text, skipping summary.")); return 1; //non-fatal error @@ -3513,7 +3553,7 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) AddFilter (0x11, 0x4a); //Sky Channels break; case FREEVIEW: //Freeview, CONT mode //TODO streamline this for other modes - ReadFileDictionary (); + InitDictionary (); AddFilter (pid, 0x4e, 0xfe); //event info, actual(0x4e)/other(0x4f) TS, present/following AddFilter (pid, 0x50, 0xf0); //event info, actual TS, schedule(0x50)/schedule for future days(0x5X) AddFilter (pid, 0x60, 0xf0); //event info, other TS, schedule(0x60)/schedule for future days(0x6X) @@ -3868,7 +3908,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len Del (Pid, Tid); //Read all channels, clean up filter if (Result == 2) { GetThemesSKYBOX (); //Sky Themes from file; must be called AFTER first channels to have lThemes initialized FIXME - if (ReadFileDictionary ()) + if (InitDictionary ()) AddFilter (0x30, 0xa0, 0xfc); //SKY Titles batch 0 of 7 else { esyslog ("EEPG: Fatal error reading huffman table."); -- cgit v1.2.3 From 38a666dcf41e83f4e5bb9eb3318fbca11fb0b4e1 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 29 Feb 2012 13:25:36 +0100 Subject: initializations modification --- eepg.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/eepg.c b/eepg.c index 5f220cd..6ab26bb 100644 --- a/eepg.c +++ b/eepg.c @@ -432,7 +432,7 @@ int freesat_decode_error = 0; /* If set an error has occurred during decoding */ static struct hufftab *tables[2][256]; static int table_size[2][256]; -sNodeH sky_tables[2]; +static sNodeH* sky_tables[2]; /** \brief Convert a textual character description into a value * @@ -549,16 +549,16 @@ static bool load_sky_file (const char *filename) char string2[256]; tableId = Format == SKY_IT ? 0 : 1; - sky_tables[tableId].Value = NULL; - sky_tables[tableId].P0 = NULL; - sky_tables[tableId].P1 = NULL; +// sky_tables[tableId].Value = NULL; +// sky_tables[tableId].P0 = NULL; +// sky_tables[tableId].P1 = NULL; while ((Line = fgets (Buffer, sizeof (Buffer), FileDict)) != NULL) { if (!isempty (Line)) { memset (string1, 0, sizeof (string1)); memset (string2, 0, sizeof (string2)); if (sscanf (Line, "%c=%[^\n]\n", string1, string2) == 2 || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) { - nH = & sky_tables[tableId]; + nH = sky_tables[tableId]; LenPrefix = strlen (string2); for (i = 0; i < LenPrefix; i++) { switch (string2[i]) { @@ -621,7 +621,7 @@ static bool load_sky_file (const char *filename) memset (string2, 0, sizeof (string2)); if (sscanf (Line, "%c=%[^\n]\n", string1, string2) == 2 || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) { - nH = &sky_tables[tableId]; + nH = sky_tables[tableId]; LenPrefix = strlen (string2); for (i = 0; i < LenPrefix; i++) { switch (string2[i]) { @@ -751,7 +751,7 @@ char *freesat_huffman_decode (const unsigned char *src, size_t size) int sky_huffman_decode (const u_char * Data, int Length, unsigned char *DecodeText) { - sNodeH *nH, &H=(Format==SKY_IT)?sky_tables[0]:sky_tables[1]; + sNodeH *nH, H=(Format==SKY_IT)?*sky_tables[0]:*sky_tables[1]; int i; int p; int q; @@ -1011,7 +1011,7 @@ bool cFilterEEPG::InitDictionary (void) char Buffer[256]; switch (Format) { case SKY_IT: - if (sky_tables[0] == NULL) { + if (sky_tables[0]->Value == NULL) { FileName += "/sky_it.dict"; LogD (1, prep("EEPGDebug: loading sky_it.dict")); return load_sky_file(FileName.c_str()); @@ -1019,7 +1019,7 @@ bool cFilterEEPG::InitDictionary (void) LogD (1, prep("EEPGDebug: sky_it.dict already loaded")); break; case SKY_UK: - if (sky_tables[1] == NULL) { + if (sky_tables[1]->Value == NULL) { FileName += "/sky_uk.dict"; LogD (1, prep("EEPGDebug: loading sky_uk.dict")); return load_sky_file(FileName.c_str()); @@ -4360,6 +4360,8 @@ bool cPluginEEPG::Start (void) CheckCreateFile("freesat.t2", FreesatT2); CheckCreateFile("sky_uk.themes", SkyUkThemes); + sky_tables[0] = (sNodeH*) calloc(1,sizeof(sNodeH)); + sky_tables[1] = (sNodeH*) calloc(1,sizeof(sNodeH)); //store all available sources, so when a channel is not found on current satellite, we can look for alternate sat positions. //perhaps this can be done smarter through existing VDR function??? for (cChannel * Channel = Channels.First (); Channel; Channel = Channels.Next (Channel)) { @@ -4389,10 +4391,17 @@ void cPluginEEPG::Stop (void) epg[i].device = 0; epg[i].filter = 0; } + // Clean up after yourself! if (ConfDir) { free (ConfDir); } + if (sky_tables[0]) { + free(sky_tables[0]); + } + if (sky_tables[1]) { + free(sky_tables[1]); + } } cMenuSetupPage *cPluginEEPG::SetupMenu (void) -- cgit v1.2.3 From 0e293db6129139bb6e7925fa8292f453f1919258 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 29 Feb 2012 18:22:47 +0100 Subject: fixed initialization of dictionaires --- eepg.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/eepg.c b/eepg.c index 6ab26bb..bbf4557 100644 --- a/eepg.c +++ b/eepg.c @@ -549,9 +549,14 @@ static bool load_sky_file (const char *filename) char string2[256]; tableId = Format == SKY_IT ? 0 : 1; -// sky_tables[tableId].Value = NULL; -// sky_tables[tableId].P0 = NULL; -// sky_tables[tableId].P1 = NULL; + if (!sky_tables[tableId]) { + sky_tables[tableId] = (sNodeH*) calloc(1,sizeof(sNodeH)); + if (!sky_tables[tableId]) { + LogE (0, prep("Not enough memory to load file '%s'."), filename); + return false; + } + } + while ((Line = fgets (Buffer, sizeof (Buffer), FileDict)) != NULL) { if (!isempty (Line)) { memset (string1, 0, sizeof (string1)); @@ -1006,36 +1011,33 @@ bool cFilterEEPG::GetThemesSKYBOX (void) //TODO can't we read this from the DVB bool cFilterEEPG::InitDictionary (void) { string FileName = ConfDir; - FILE *FileDict; - char *Line; - char Buffer[256]; switch (Format) { case SKY_IT: - if (sky_tables[0]->Value == NULL) { - FileName += "/sky_it.dict"; + if (sky_tables[0] == NULL) { + FileName += "/sky_it.dict"; LogD (1, prep("EEPGDebug: loading sky_it.dict")); - return load_sky_file(FileName.c_str()); - } else + return load_sky_file(FileName.c_str()); + } else LogD (1, prep("EEPGDebug: sky_it.dict already loaded")); break; case SKY_UK: - if (sky_tables[1]->Value == NULL) { + if (sky_tables[1] == NULL) { FileName += "/sky_uk.dict"; LogD (1, prep("EEPGDebug: loading sky_uk.dict")); - return load_sky_file(FileName.c_str()); - } else + return load_sky_file(FileName.c_str()); + } else LogD (1, prep("EEPGDebug: sky_uk.dict already loaded")); break; case FREEVIEW: - if (tables == NULL) { + if (tables[0][0] == NULL) { LogD (1, prep("EEPGDebug: loading freesat.dict")); FileName += "/freesat.t1"; if (!load_freesat_file (1, FileName.c_str())) - return false; + return false; FileName = ConfDir; FileName += "/freesat.t2"; return load_freesat_file (2, FileName.c_str()); - } else + } else LogD (1, prep("EEPGDebug: freesat.dict already loaded")); break; default: @@ -2684,10 +2686,9 @@ void cFilterEEPG::FreeTitles (void) void cFilterEEPG::LoadIntoSchedule (void) { - int i, j, k; + int i, j; i = 0; j = 0; - k = 0; bool foundtitle; foundtitle = false; Title_t *T; @@ -4360,8 +4361,9 @@ bool cPluginEEPG::Start (void) CheckCreateFile("freesat.t2", FreesatT2); CheckCreateFile("sky_uk.themes", SkyUkThemes); - sky_tables[0] = (sNodeH*) calloc(1,sizeof(sNodeH)); - sky_tables[1] = (sNodeH*) calloc(1,sizeof(sNodeH)); + sky_tables[0] = NULL; + sky_tables[1] = NULL; + tables[0][0] = NULL; //store all available sources, so when a channel is not found on current satellite, we can look for alternate sat positions. //perhaps this can be done smarter through existing VDR function??? for (cChannel * Channel = Channels.First (); Channel; Channel = Channels.Next (Channel)) { -- cgit v1.2.3 From 36b6183fc9221a2dbcfc7569e8d280ca6bde849d Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 29 Feb 2012 19:04:07 +0100 Subject: add debug logging --- eepg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eepg.c b/eepg.c index abb580f..ec778ff 100644 --- a/eepg.c +++ b/eepg.c @@ -1140,8 +1140,10 @@ void loadEquivalentChannelMap (void) break; } - if (!found) + if (!found) { equiChanMap.insert(pair(*OriginalChID.ToString(),*EquivChID.ToString())); + LogD(4, prep("Found %s equivalent to %s."), *EquivChID.ToString(), *OriginalChID.ToString()); + } } else LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); } @@ -2968,6 +2970,7 @@ void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEven ret = equiChanMap.equal_range(*channelID.ToString()); for (it=ret.first; it!=ret.second; ++it) { + LogD(1, prep("equivalent channel exists")); tChannelID equChannelID (tChannelID::FromString((*it).second)); cChannel *equChannel = GetChannelByID (equChannelID, false); if (equChannel) { -- cgit v1.2.3 From c3a38eabb59bdb9b6ee631ed2220e09b6e528692 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Fri, 2 Mar 2012 18:15:58 +0100 Subject: use string instead of const char * for multimap --- eepg.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/eepg.c b/eepg.c index ec778ff..10b1912 100644 --- a/eepg.c +++ b/eepg.c @@ -263,7 +263,7 @@ static int AvailableSources[32]; static int NumberOfAvailableSources = 0; static int LastVersionNagra = -1; //currently only used for Nagra, should be stored per transponder, per system -static multimap equiChanMap; +static multimap equiChanMap; #ifdef USE_NOEPG @@ -1085,8 +1085,8 @@ void loadEquivalentChannelMap (void) char *Line; FILE *File; string FileName = string(ConfDir) + "/" + EEPG_FILE_EQUIV; - multimap::iterator it; - pair::iterator,multimap::iterator> ret; + multimap::iterator it,it2; + pair::iterator,multimap::iterator> ret; //TODO DPE add code to reload if file is changed if (equiChanMap.size() > 0) @@ -1141,8 +1141,12 @@ void loadEquivalentChannelMap (void) } if (!found) { - equiChanMap.insert(pair(*OriginalChID.ToString(),*EquivChID.ToString())); - LogD(4, prep("Found %s equivalent to %s."), *EquivChID.ToString(), *OriginalChID.ToString()); + string origCh(*OriginalChID.ToString()); + string equiCh(*EquivChID.ToString()); + equiChanMap.insert(pair(origCh.c_str(),equiCh.c_str())); + LogD(4, prep("Found %s equivalent to %s. origCh %s"), *EquivChID.ToString(), *OriginalChID.ToString(), origCh.c_str()); + for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) + LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); } } else LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); @@ -1154,6 +1158,8 @@ void loadEquivalentChannelMap (void) } //while fclose (File); LogD(3, prep("Loaded %i equivalents."), equiChanMap.size()); + for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) + LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); } //if file } void cFilterEEPG::LoadEquivalentChannels (void) @@ -2963,15 +2969,15 @@ protected: }; void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent){ - multimap::iterator it; - pair::iterator,multimap::iterator> ret; + multimap::iterator it; + pair::iterator,multimap::iterator> ret; LogD(3, prep("Start updateEquivalent %s"), *channelID.ToString()); ret = equiChanMap.equal_range(*channelID.ToString()); for (it=ret.first; it!=ret.second; ++it) { LogD(1, prep("equivalent channel exists")); - tChannelID equChannelID (tChannelID::FromString((*it).second)); + tChannelID equChannelID (tChannelID::FromString((*it).second.c_str())); cChannel *equChannel = GetChannelByID (equChannelID, false); if (equChannel) { LogD(3, prep("found Equivalent channel %s"), *equChannelID.ToString()); @@ -3057,13 +3063,13 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat pEvent = newEvent = new cEvent (SiEitEvent.getEventId ()); if (!pEvent) continue; - updateEquivalent(Schedules, channel->GetChannelID(), pEvent); + //updateEquivalent(Schedules, channel->GetChannelID(), pEvent); } else { //LogD(3, prep("existing event channelID: %s Title: %s TableID 0x%02X new TID 0x%02X Version %i, new version %i"), *channel->GetChannelID().ToString(), pEvent->Title(), pEvent->TableID(), Tid, pEvent->Version(), versionNumber); // We have found an existing event, either through its event ID or its start time. pEvent->SetSeen (); - updateEquivalent(Schedules, channel->GetChannelID(), pEvent); + //updateEquivalent(Schedules, channel->GetChannelID(), pEvent); // If the existing event has a zero table ID it was defined externally and shall // not be overwritten. if (pEvent->TableID () == 0x00) { @@ -3576,6 +3582,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat } } #endif /* DDEPGENTRY */ + updateEquivalent(Schedules, channel->GetChannelID(), pEvent); } if (Empty && Tid == 0x4E && getSectionNumber () == 0) // ETR 211: an empty entry in section 0 of table 0x4E means there is currently no event running -- cgit v1.2.3 From acff803d168899971989e15429f1274dce55a35f Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Fri, 2 Mar 2012 18:35:41 +0100 Subject: create copy of equivalent event before adding --- eepg.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/eepg.c b/eepg.c index 10b1912..8574426 100644 --- a/eepg.c +++ b/eepg.c @@ -2991,12 +2991,40 @@ void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEven } else { LogD(1, prep("remove equivalent")); pSchedule->DelEvent(pEqvEvent); - pSchedule->AddEvent(pEvent); + cEvent* newEvent = new cEvent (pEvent->EventID()); + newEvent->SetTableID (pEvent->TableID()); + newEvent->SetStartTime (pEvent->StartTime()); + newEvent->SetDuration (pEvent->Duration()); + newEvent->SetVersion (pEvent->Version()); + // newEvent->SetContents(pEvent->Contents()); + newEvent->SetParentalRating(pEvent->ParentalRating()); + newEvent->SetVps (pEvent->Vps()); + newEvent->SetTitle (pEvent->Title ()); + newEvent->SetShortText (pEvent->ShortText ()); + newEvent->SetDescription (pEvent->Description ()); + // newEvent->SetComponents (pEvent->Components()); + newEvent->FixEpgBugs (); + + pSchedule->AddEvent(newEvent); } } else { LogD(1, prep("equivalent event does not exist")); - pSchedule->AddEvent(pEvent); + cEvent* newEvent = new cEvent (pEvent->EventID()); + newEvent->SetTableID (pEvent->TableID()); + newEvent->SetStartTime (pEvent->StartTime()); + newEvent->SetDuration (pEvent->Duration()); + newEvent->SetVersion (pEvent->Version()); +// newEvent->SetContents(pEvent->Contents()); + newEvent->SetParentalRating(pEvent->ParentalRating()); + newEvent->SetVps (pEvent->Vps()); + newEvent->SetTitle (pEvent->Title ()); + newEvent->SetShortText (pEvent->ShortText ()); + newEvent->SetDescription (pEvent->Description ()); +// newEvent->SetComponents (pEvent->Components()); + newEvent->FixEpgBugs (); + + pSchedule->AddEvent(newEvent); } } } -- cgit v1.2.3 From ad84fc4f2ebd0e36283f9cb8fb351820e789e448 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 7 Mar 2012 16:25:45 +0100 Subject: convert DescriptorTag to int before switch to reduce warnings add some logging to test missing break --- eepg.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/eepg.c b/eepg.c index 8574426..0dfd9fe 100644 --- a/eepg.c +++ b/eepg.c @@ -3212,6 +3212,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat int LanguagePreferenceShort = -1; int LanguagePreferenceExt = -1; + int nDescriptorTag; bool UseExtendedEventDescriptor = false; SI::Descriptor * d; SI::ExtendedEventDescriptors * ExtendedEventDescriptors = NULL; @@ -3231,8 +3232,8 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat } //LogD(2, prep("EEPGDEBUG:d->getDescriptorTAG():%x)"), d->getDescriptorTag ()); - - switch (d->getDescriptorTag ()) { + nDescriptorTag = d->getDescriptorTag (); + switch (nDescriptorTag) { case SI::ExtendedEventDescriptorTag: { SI::ExtendedEventDescriptor * eed = (SI::ExtendedEventDescriptor *) d; if (I18nIsPreferredLanguage (Setup.EPGLanguages, eed->languageCode, LanguagePreferenceExt) @@ -3842,9 +3843,11 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len } //Format = 0; // 0 = premiere, 1 = MHW1, 2 = MHW2, 3 = Sky Italy (OpenTV), 4 = Sky UK (OpenTV), 5 = Freesat (Freeview), 6 = Nagraguide SI::Descriptor * d; + int nDescriptorTag; for (SI::Loop::Iterator it; (d = stream.streamDescriptors.getNext (it));) { LogD(4, prep("EEPGDEBUG:d->getDescriptorTAG():%x,SI::PrivateTag:%x\n"), d->getDescriptorTag (), SI::PrivateDataSpecifierDescriptorTag); - switch (d->getDescriptorTag ()) { + nDescriptorTag = d->getDescriptorTag (); + switch (nDescriptorTag) { case SI::PrivateDataSpecifierDescriptorTag: //esyslog ("prv: %d %08x\n", d->getLength (), d->getData ().FourBytes (2)); if (d->getLength () == 6 && d->getData ().FourBytes (2) == 0x000000be) @@ -3952,6 +3955,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len ProcessPremiere(Data); break; } //if citpid == 0xb11 Premiere + LogD(0, prep("!!!!!! case 0xA0: Without break test")); case 0xa1: case 0xa2: case 0xa3: @@ -3970,6 +3974,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len case 0xaa: case 0xab: Result = GetSummariesSKYBOX (Data, Length - 4); + LogD(0, prep("!!!!!! Tid: 0x%02x Result: %i"), Tid, Result); if (Result != 1) //when fatal error or finished Del (Pid, 0xa8, 0xfc); //kill filter if (Result == 0) { @@ -4197,11 +4202,13 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) { time_t firstTime = 0; SI::Descriptor * d; + int nDescriptorTag; bool UseExtendedEventDescriptor = false; int LanguagePreferenceShort = -1; int LanguagePreferenceExt = -1; for (SI::Loop::Iterator it; (d = cit.eventDescriptors.getNext (it));) { - switch (d->getDescriptorTag ()) { + nDescriptorTag = d->getDescriptorTag (); + switch (nDescriptorTag) { case 0xF0: // order information if (SetupPE.OrderInfo) { static const char *text[] = { -- cgit v1.2.3 From c3e1fff38e6dd21d0252acbe4a6f6959d4b35732 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 7 Mar 2012 16:40:48 +0100 Subject: removed unneeded test logging and a TODO --- eepg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/eepg.c b/eepg.c index 0dfd9fe..a5d4b86 100644 --- a/eepg.c +++ b/eepg.c @@ -3949,13 +3949,13 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len } int Result; switch (Tid) { - case 0xA0: //TODO DPE test this missing break but it seems a bug + case 0xA0: if ((Pid < 0x30) || (Pid > 0x37)) { ProcessPremiere(Data); break; } //if citpid == 0xb11 Premiere - LogD(0, prep("!!!!!! case 0xA0: Without break test")); + /* no break - used for sky also*/ case 0xa1: case 0xa2: case 0xa3: @@ -3974,7 +3974,6 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len case 0xaa: case 0xab: Result = GetSummariesSKYBOX (Data, Length - 4); - LogD(0, prep("!!!!!! Tid: 0x%02x Result: %i"), Tid, Result); if (Result != 1) //when fatal error or finished Del (Pid, 0xa8, 0xfc); //kill filter if (Result == 0) { -- cgit v1.2.3 From f5cd47b2193b7be1c87256293978964b3b5ca6a5 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 7 Mar 2012 17:50:25 +0100 Subject: int -> unsigned char --- eepg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eepg.c b/eepg.c index a5d4b86..76f3746 100644 --- a/eepg.c +++ b/eepg.c @@ -3212,7 +3212,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat int LanguagePreferenceShort = -1; int LanguagePreferenceExt = -1; - int nDescriptorTag; + unsigned char nDescriptorTag; bool UseExtendedEventDescriptor = false; SI::Descriptor * d; SI::ExtendedEventDescriptors * ExtendedEventDescriptors = NULL; @@ -3843,7 +3843,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len } //Format = 0; // 0 = premiere, 1 = MHW1, 2 = MHW2, 3 = Sky Italy (OpenTV), 4 = Sky UK (OpenTV), 5 = Freesat (Freeview), 6 = Nagraguide SI::Descriptor * d; - int nDescriptorTag; + unsigned char nDescriptorTag; for (SI::Loop::Iterator it; (d = stream.streamDescriptors.getNext (it));) { LogD(4, prep("EEPGDEBUG:d->getDescriptorTAG():%x,SI::PrivateTag:%x\n"), d->getDescriptorTag (), SI::PrivateDataSpecifierDescriptorTag); nDescriptorTag = d->getDescriptorTag (); @@ -4201,7 +4201,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) { time_t firstTime = 0; SI::Descriptor * d; - int nDescriptorTag; + unsigned char nDescriptorTag; bool UseExtendedEventDescriptor = false; int LanguagePreferenceShort = -1; int LanguagePreferenceExt = -1; -- cgit v1.2.3 From b24e6091e88ea015bd6296a091504902ddb4b396 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Fri, 9 Mar 2012 22:04:11 +0100 Subject: sort schedule after update --- eepg.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eepg.c b/eepg.c index 76f3746..b478870 100644 --- a/eepg.c +++ b/eepg.c @@ -3006,6 +3006,8 @@ void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEven newEvent->FixEpgBugs (); pSchedule->AddEvent(newEvent); + pSchedule->Sort (); + } } else { @@ -3025,6 +3027,7 @@ void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEven newEvent->FixEpgBugs (); pSchedule->AddEvent(newEvent); + pSchedule->Sort (); } } } -- cgit v1.2.3 From 5387679550714151a3b8637e01ff941b498921c2 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 8 May 2012 13:58:27 +0200 Subject: test new vdr eit api --- eepg.c | 49 +++++++++++++++++++++++++++--------------------- epghandler.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ epghandler.h | 33 ++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+), 21 deletions(-) create mode 100644 epghandler.c create mode 100644 epghandler.h diff --git a/eepg.c b/eepg.c index b478870..d787951 100644 --- a/eepg.c +++ b/eepg.c @@ -1211,7 +1211,7 @@ void cFilterEEPG::LoadEquivalentChannels (void) } else { cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); if (!OriginalChannel) - LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalency is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? + LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalence is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) != 5) { @@ -1331,7 +1331,7 @@ int cFilterEEPG::GetChannelsMHW (const u_char * Data, int Length, int MHW) } //else nChannels > MAX_CHANNELS LoadEquivalentChannels (); GetLocalTimeOffset (); //reread timing variables, only used for MHW - return 2; //obviously, when you get here, channels are read succesfully, but since all channels are sent at once, you can stop now + return 2; //obviously, when you get here, channels are read successfully, but since all channels are sent at once, you can stop now } //if nChannels == 0 LogE (0, prep("Warning: Trying to read Channels more than once!")); //you will only get here when GetChannelsMHW is called, and nChannels !=0, e.g. when multiple citpids cause channels to be read multiple times. Second time, do nothing, give error so that the rest of the chain is not restarted also. @@ -1578,15 +1578,25 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse p += 29; //skip fixed part of block if (SD->NumberOfBlocks == 1) - p -= 4; //in this case there is NO summarytext AND no GBR??!! + p -= 4; //in this case there is NO summary text AND no GBR??!! for (int i = 1; i < (SD->NumberOfBlocks - 1); i++) { - LogD(3, prep("DEBUG: Extra Blockinfo: %02x %02x %02x %02x."), *p, *(p + 1), *(p + 2), *(p + 3)); - p += 4; //skip this extra blockinfo + LogD(3, prep("DEBUG: Extra Block info: %02x %02x %02x %02x."), *p, *(p + 1), *(p + 2), *(p + 3)); + p += 4; //skip this extra block info } return (char *) Text; } -void cFilterEEPG::PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]) //gets a channel and returns an array of schedules that WriteToSchedule can write to. Call this routine before a batch of titles with the same ChannelId will be WriteToScheduled; batchsize can be 1 +/** + * \brief Prepare to Write to Schedule + * + * gets a channel and returns an array of schedules that WriteToSchedule can write to. + * Call this routine before a batch of titles with the same ChannelId will be WriteToScheduled; batchsize can be 1 + * + * \param C channel to prepare + * \param s VDR epg schedules + * \param ps pointer to the schedules that WriteToSchedule can write to + */ +void cFilterEEPG::PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]) { for (int eq = 0; eq < C->NumberOfEquivalences; eq++) { tChannelID channelID = tChannelID (C->Src[eq], C->Nid[eq], C->Tid[eq], C->Sid[eq]); @@ -1598,7 +1608,7 @@ void cFilterEEPG::PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSched ps[eq] = s->AddSchedule (channelID); //open a a schedule for each equivalent channel else { ps[eq] = NULL; - LogE(5, prep("ERROR: Titleblock has invalid (equivalent) channel ID: Equivalence: %i, Source:%x, C->Nid:%x,C->Tid:%x,C->Sid:%x."), + LogE(5, prep("ERROR: Title block has invalid (equivalent) channel ID: Equivalence: %i, Source:%x, C->Nid:%x,C->Tid:%x,C->Sid:%x."), eq, C->Src[eq], C->Nid[eq], C->Tid[eq], C->Sid[eq]); } } @@ -1722,13 +1732,13 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor LogD(3, prep("DEBUG: ChannelId %04x, Blocklength %04x, NumberOfTitles %lu."), ChannelId, Blocklength, NumberOfTitles); - p += 4; //skip ChannelId and Blocklength + p += 4; //skip ChannelId and Block length next_p = p + Blocklength; if (next_p > DataEnd) { //only process if block is complete LogE(0, prep("ERROR, Block exceeds end of Data. p:%p, Blocklength:%x,DataEnd:%p."), p, Blocklength, DataEnd); return; //fatal error, this should never happen } - p += 4; //skip Titlenumber + p += 4; //skip Title number sChannel *C = &sChannels[ChannelSeq[ChannelId]]; //find channel cSchedule *ps[MAX_EQUIVALENCES]; @@ -1747,7 +1757,7 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor tmCurrent->tm_mon = CurrentMonth; tmCurrent->tm_mday = MonthdayTitles; tmCurrent->tm_hour = 0; - tmCurrent->tm_min = StartTime; //if starttime is bigger than 1 hour, mktime will correct this! + tmCurrent->tm_min = StartTime; //if start time is bigger than 1 hour, mktime will correct this! tmCurrent->tm_sec = 0; tmCurrent->tm_isdst = -1; //now correct with daylight savings if (MonthdayTitles < CurrentMonthday - 7) //the titles that are older than one week are not from the past, but from next month! @@ -1775,7 +1785,7 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor else SummText = GetSummaryTextNagra (DataStartSummaries, HILO32 (Title->SumDataOffset), EventId); - LogD(3, prep("DEBUG: Eventid: %08x ChannelId:%x, Starttime %02i:%02i, Duration %i, OffsetToText:%08x, OffsetToText2:%08x, SumDataOffset:%08x ThemeId:%x Title:%s \n SummaryText:%s"), + LogD(3, prep("DEBUG: Eventid: %08x ChannelId:%x, Start time %02i:%02i, Duration %i, OffsetToText:%08x, OffsetToText2:%08x, SumDataOffset:%08x ThemeId:%x Title:%s \n SummaryText:%s"), EventId, ChannelId, Hours, Minutes, Title->Duration, HILO32 (Title->OffsetToText), HILO32 (Title->OffsetToText2), HILO32 (Title->SumDataOffset), Title->ThemeId, Text, SummText); @@ -1935,7 +1945,7 @@ int cFilterEEPG::GetChannelsNagra (const u_char * Data, int Length) sChannelsNagraGuide *Channel = (sChannelsNagraGuide *) p; sChannel *C = &sChannels[j]; C->ChannelId = j + 1; //Nagra starts numbering at 1 - ChannelSeq[C->ChannelId] = j; //fill lookup table to go from channel-id to sequence nr in table; lookuptable starts with 0 + ChannelSeq[C->ChannelId] = j; //fill lookup table to go from channel-id to sequence nr in table; lookup table starts with 0 C->SkyNumber = 0; C->NumberOfEquivalences = 1; //there is always an original channel. every equivalence adds 1 C->Src[0] = Source(); //assume all EPG channels are on same satellite, if not, manage this via equivalents!!! @@ -2126,11 +2136,11 @@ void cFilterEEPG::ProcessNagra () NumberOfTables--; } - for (int i = 0; i < NagraCounter; i++) { //first prcoess all themes, since they all use the same codes + for (int i = 0; i < NagraCounter; i++) { //first process all themes, since they all use the same codes unsigned short int TableIdExtension = NagraTIE[i]; int TIE = TableIdExtension - 0x0200; //from 0x0400 to 0x0200 -> titles LogI(0, prep("Processing TableIdExtension:%04x"), TableIdExtension); - GetTitlesNagra (buffer[TIE] + 4, bufsize[TIE] - 4, TableIdExtension); //assume title-reading is completed //TODO Language code terminatd by 0 is ignored + GetTitlesNagra (buffer[TIE] + 4, bufsize[TIE] - 4, TableIdExtension); //assume title-reading is completed //TODO Language code terminated by 0 is ignored free (buffer[TIE]); buffer[TIE] = NULL; NumberOfTables--; @@ -2155,7 +2165,7 @@ int cFilterEEPG::GetTitlesMHW1 (const u_char * Data, int Length) sTitleMHW1 *Title = (sTitleMHW1 *) Data; if (Title->ChannelId == 0xff) { //FF is separator packet if (memcmp (InitialTitle, Data, 46) == 0) { //data is the same as initial title //TODO use easier notation - LogD(2, prep("End procesing titles")); + LogD(2, prep("End processing titles")); return 2; } if (nTitles == 0) @@ -2753,7 +2763,7 @@ void cFilterEEPG::FreeSummaries (void) S = Summaries[i]; if (i < nSummaries - 1) { S2 = Summaries[i + 1]; //look at next summary - if (S->Text != S2->Text && S->Text != 0x00) //this is the last summary that points to this textblock; needed in case NumReplays > 1, multiple pointers to same textblock + if (S->Text != S2->Text && S->Text != 0x00) //this is the last summary that points to this text block; needed in case NumReplays > 1, multiple pointers to same textblock free (S->Text); } else if (S->Text != 0x00) free (S->Text); @@ -3094,13 +3104,11 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat pEvent = newEvent = new cEvent (SiEitEvent.getEventId ()); if (!pEvent) continue; - //updateEquivalent(Schedules, channel->GetChannelID(), pEvent); } else { //LogD(3, prep("existing event channelID: %s Title: %s TableID 0x%02X new TID 0x%02X Version %i, new version %i"), *channel->GetChannelID().ToString(), pEvent->Title(), pEvent->TableID(), Tid, pEvent->Version(), versionNumber); // We have found an existing event, either through its event ID or its start time. pEvent->SetSeen (); - //updateEquivalent(Schedules, channel->GetChannelID(), pEvent); // If the existing event has a zero table ID it was defined externally and shall // not be overwritten. if (pEvent->TableID () == 0x00) { @@ -3460,7 +3468,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat pEvent->SetTitle (buffer); LogD(3, prep("channelID: %s Title: %s"), *channel->GetChannelID().ToString(), pEvent->Title()); l = ShortEventDescriptor->text.getLength(); - if (l > 0) { //Set the Short Text only if ther is data so that we do not overwrite valid data + if (l > 0) { //Set the Short Text only if there is data so that we do not overwrite valid data f = (unsigned char *) ShortEventDescriptor->text.getData().getData(); decodeText2 (f, l, buffer, sizeof (buffer)); //ShortEventDescriptor->text.getText(buffer, sizeof(buffer)); @@ -3720,8 +3728,7 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) EndThemes = false; switch (Format) { case PREMIERE: - if (!Matches (pid, 0xA0)) - Add (pid, 0xA0); + AddFilter (pid, 0xA0); break; case MHW1: AddFilter (0xd3, 0x92); //ThemesMHW1//TODO: all filters are serialized, strictly speaking Themes is non-fatal... diff --git a/epghandler.c b/epghandler.c new file mode 100644 index 0000000..a467426 --- /dev/null +++ b/epghandler.c @@ -0,0 +1,61 @@ +/* + * cEEpgHandler.c + * + * Created on: 11.3.2012 + * Author: d.petrovski + */ + +#include "epghandler.h" + +cEEpgHandler::cEEpgHandler() { + // TODO Auto-generated constructor stub + +} + +cEEpgHandler::~cEEpgHandler() { + // TODO Auto-generated destructor stub +} + +bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, + const SI::EIT::Event* EitEvent, uchar TableID, uchar Version) { + return true; +} + +bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) { +} + +bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { +} + +bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) { +} + +bool cEEpgHandler::SetDescription(cEvent* Event, const char* Description) { +} + +bool cEEpgHandler::SetContents(cEvent* Event, uchar* Contents) { +} + +bool cEEpgHandler::SetParentalRating(cEvent* Event, int ParentalRating) { +} + +bool cEEpgHandler::SetStartTime(cEvent* Event, time_t StartTime) { +} + +bool cEEpgHandler::SetDuration(cEvent* Event, int Duration) { +} + +bool cEEpgHandler::SetVps(cEvent* Event, time_t Vps) { +} + +bool cEEpgHandler::HandleEvent(cEvent* Event) { +} + +bool cEEpgHandler::SortSchedule(cSchedule* Schedule) { +} + +bool cEEpgHandler::DropOutdated(cSchedule* Schedule, time_t SegmentStart, + time_t SegmentEnd, uchar TableID, uchar Version) { +} + + diff --git a/epghandler.h b/epghandler.h new file mode 100644 index 0000000..1dee4f2 --- /dev/null +++ b/epghandler.h @@ -0,0 +1,33 @@ +/* + * cEEpgHandler.h + * + * Created on: 11.3.2012 + * Author: d.petrovski + */ + +#ifndef CEEPGHANDLER_H_ +#define CEEPGHANDLER_H_ +#include + +class cEEpgHandler : public cEpgDataReader { +public: + cEEpgHandler(); + virtual ~cEEpgHandler(); + virtual bool IgnoreChannel(const cChannel *Channel) { return false; } + virtual bool HandleEitEvent(cSchedule *Schedule, const SI::EIT::Event *EitEvent, uchar TableID, uchar Version); + virtual bool SetEventID(cEvent *Event, tEventID EventID); + virtual bool SetTitle(cEvent *Event, const char *Title); + virtual bool SetShortText(cEvent *Event, const char *ShortText); + virtual bool SetDescription(cEvent *Event, const char *Description); + virtual bool SetContents(cEvent *Event, uchar *Contents); + virtual bool SetParentalRating(cEvent *Event, int ParentalRating); + virtual bool SetStartTime(cEvent *Event, time_t StartTime); + virtual bool SetDuration(cEvent *Event, int Duration); + virtual bool SetVps(cEvent *Event, time_t Vps); + virtual bool FixEpgBugs(cEvent *Event) { return false; } + virtual bool HandleEvent(cEvent *Event); + virtual bool SortSchedule(cSchedule *Schedule); + virtual bool DropOutdated(cSchedule *Schedule, time_t SegmentStart, time_t SegmentEnd, uchar TableID, uchar Version); +}; + +#endif /* CEEPGHANDLER_H_ */ -- cgit v1.2.3 From 2b14567643d2879c8db64a8e5fa7c0abb6d921bc Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 8 May 2012 14:31:06 +0200 Subject: start eepghandler --- eepg.c | 1 + epghandler.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/eepg.c b/eepg.c index d787951..ab684f4 100644 --- a/eepg.c +++ b/eepg.c @@ -4577,6 +4577,7 @@ bool cPluginEEPG::Start (void) for (int i = 0; i < NumberOfAvailableSources; i++) isyslog ("EEPG: Available sources:%s.", *cSource::ToString (AvailableSources[i])); + new cEEpgHandler(); return true; } diff --git a/epghandler.c b/epghandler.c index a467426..9bb7776 100644 --- a/epghandler.c +++ b/epghandler.c @@ -22,40 +22,65 @@ bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, } bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) { + Event->SetEventID(EventID); + return true; } bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { + if (Event->Title() == "" || (Title != "" && Title != Event->Title())) + Event->SetTitle(Title); + return true; } bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) { + if (Event->ShortText() == "" || (ShortText != "" && ShortText != Event->ShortText())) + Event->SetShortText(ShortText); + return true; } bool cEEpgHandler::SetDescription(cEvent* Event, const char* Description) { + if (Event->Description() == "" || (Description != "" && Description != Event->Description())) + Event->SetDescription(Description); + return true; } bool cEEpgHandler::SetContents(cEvent* Event, uchar* Contents) { + Event->SetContents(Contents); + return true; } bool cEEpgHandler::SetParentalRating(cEvent* Event, int ParentalRating) { + Event->SetParentalRating(ParentalRating); + return true; } bool cEEpgHandler::SetStartTime(cEvent* Event, time_t StartTime) { + Event->SetStartTime(StartTime); + return true; } bool cEEpgHandler::SetDuration(cEvent* Event, int Duration) { + Event->SetDuration(Duration); + return true; } bool cEEpgHandler::SetVps(cEvent* Event, time_t Vps) { + Event->SetVps(Vps); + return true; } bool cEEpgHandler::HandleEvent(cEvent* Event) { + return true; } bool cEEpgHandler::SortSchedule(cSchedule* Schedule) { + Schedule->Sort(); + return true; } bool cEEpgHandler::DropOutdated(cSchedule* Schedule, time_t SegmentStart, time_t SegmentEnd, uchar TableID, uchar Version) { + return false; } -- cgit v1.2.3 From c994b221ae2e9b5a395ab5641f5a6f66f0de18cc Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 8 May 2012 16:01:49 +0200 Subject: fix Makefile and include --- Makefile | 2 +- eepg.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 19c0684..0bebc82 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"' ### The object files (add further files here): -OBJS = $(PLUGIN).o dish.o +OBJS = $(PLUGIN).o dish.o epghandler.o ifdef DBG CXXFLAGS += -g diff --git a/eepg.c b/eepg.c index ab684f4..7aa3fe0 100644 --- a/eepg.c +++ b/eepg.c @@ -38,6 +38,7 @@ #include #include "eepg.h" #include "dish.h" +#include "epghandler.h" #include #include -- cgit v1.2.3 From b38d4c6e66df5226f37f0dd36d3cf8070a95ae7e Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 8 May 2012 16:11:14 +0200 Subject: fix string comparison --- epghandler.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/epghandler.c b/epghandler.c index 9bb7776..51074ad 100644 --- a/epghandler.c +++ b/epghandler.c @@ -27,19 +27,19 @@ bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) { } bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { - if (Event->Title() == "" || (Title != "" && Title != Event->Title())) + if (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title))) Event->SetTitle(Title); return true; } bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) { - if (Event->ShortText() == "" || (ShortText != "" && ShortText != Event->ShortText())) + if (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText))) Event->SetShortText(ShortText); return true; } bool cEEpgHandler::SetDescription(cEvent* Event, const char* Description) { - if (Event->Description() == "" || (Description != "" && Description != Event->Description())) + if (!strcmp(Event->Description(),"") || (strcmp(Description,"") && strcmp(Event->Description(),Description))) Event->SetDescription(Description); return true; } -- cgit v1.2.3 From c7f2963f994ef2b2e9862da82a7065a6067dad4f Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 8 May 2012 18:27:16 +0200 Subject: modified logging and added logging to epghandler.c --- eepg.c | 60 +---------------------------------------------- epghandler.c | 7 +++++- log.h | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 60 deletions(-) create mode 100644 log.h diff --git a/eepg.c b/eepg.c index 7aa3fe0..22ee520 100644 --- a/eepg.c +++ b/eepg.c @@ -39,14 +39,12 @@ #include "eepg.h" #include "dish.h" #include "epghandler.h" +#include "log.h" #include #include #include -#define VERBOSE 1 -/* 0 = only print errors, 1 = print channels and themes, 2 = print channels, themes, titles, summaries 3 = debug mode */ -/* all is logged into /var/log/syslog */ #if APIVERSNUM < 10401 #error You need at least VDR API version 1.4.1 for this plugin @@ -184,62 +182,6 @@ void cMenuSetupPremiereEpg::Store (void) #endif } -bool CheckLevel(int level) -{ -#ifdef DEBUG - if (SetupPE.LogLevel >= level) -#else - if (VERBOSE >= level) -#endif - { - return true; - } - return false; -} - -const char* PrepareLog(string message) -{ - message = "EEPG: " + message; - return message.c_str(); -} - -#define MAXSYSLOGBUF 256 - -//void LogVsyslog(int errLevel, const char * message, ...) -void LogVsyslog(int errLevel, int const& lineNum, const char * function, const char * message, ...) -{ - va_list ap; - char fmt[MAXSYSLOGBUF]; - if (errLevel == LOG_DEBUG) { - snprintf(fmt, sizeof(fmt), "[%d] %s:%d %s", cThread::ThreadId(), function, lineNum, message); - } else { - snprintf(fmt, sizeof(fmt), "[%d] %s", cThread::ThreadId(), message); - } - va_start(ap,message); - vsyslog ( errLevel, fmt, ap ); - va_end(ap); -} - -#define LogI(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_INFO, __LINE__, __FUNCTION__, b ) : void() ) -#define LogE(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_ERR, __LINE__, __FUNCTION__, b ) : void() ) -#define LogD(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_DEBUG, __LINE__, __FUNCTION__, b ) : void() ) -//#define LogE(a, b...) void( CheckLevel(a) ? esyslog ( b ) : void() ) -//#define LogD(a, b...) void( CheckLevel(a) ? dsyslog ( b ) : void() ) -#define prep(s) PrepareLog(s) -#define prep2(s) s - -//void LogF(int level, const char * message, ...) __attribute__ ((format (printf,2,3))); - -//void LogF(int level, const char * message, ...) -//{ -// if (CheckLevel(level)) { -// va_list ap; -// va_start(ap,message); -// vsyslog (LOG_ERR, PrepareLog(message), ap ); -// va_end(ap); -// } -//} - #define Asprintf(a, b, c...) void( asprintf(a, b, c) < 0 ? esyslog("memory allocation error - %s", b) : void() ) // --- CRC16 ------------------------------------------------------------------- diff --git a/epghandler.c b/epghandler.c index 51074ad..abc4c38 100644 --- a/epghandler.c +++ b/epghandler.c @@ -6,6 +6,7 @@ */ #include "epghandler.h" +#include "log.h" cEEpgHandler::cEEpgHandler() { // TODO Auto-generated constructor stub @@ -27,13 +28,17 @@ bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) { } bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { + LogD(1, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title); + if (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title))) Event->SetTitle(Title); return true; } bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) { - if (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText))) + LogD(1, prep("Event id:%d ShortText:%s new ShortText:%s"), Event->EventID(), Event->ShortText(), ShortText); + + if (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText))) Event->SetShortText(ShortText); return true; } diff --git a/log.h b/log.h new file mode 100644 index 0000000..900aed6 --- /dev/null +++ b/log.h @@ -0,0 +1,76 @@ +/* + * log.h + * + * Created on: 08.5.2012 + * Author: d.petrovski + */ + +#ifndef LOG_H_ +#define LOG_H_ + +#include +#include + +#define VERBOSE 1 +/* 0 = only print errors, 1 = print channels and themes, 2 = print channels, themes, titles, summaries 3 = debug mode */ +/* all is logged into /var/log/syslog */ + + +bool CheckLevel(int level) +{ +#ifdef DEBUG + if (SetupPE.LogLevel >= level) +#else + if (VERBOSE >= level) +#endif + { + return true; + } + return false; +} + +const char* PrepareLog(std::string message) +{ + message = "EEPG: " + message; + return message.c_str(); +} + +#define MAXSYSLOGBUF 256 + +//void LogVsyslog(int errLevel, const char * message, ...) +void LogVsyslog(int errLevel, int const& lineNum, const char * function, const char * message, ...) +{ + va_list ap; + char fmt[MAXSYSLOGBUF]; + if (errLevel == LOG_DEBUG) { + snprintf(fmt, sizeof(fmt), "[%d] %s:%d %s", cThread::ThreadId(), function, lineNum, message); + } else { + snprintf(fmt, sizeof(fmt), "[%d] %s", cThread::ThreadId(), message); + } + va_start(ap,message); + vsyslog ( errLevel, fmt, ap ); + va_end(ap); +} + +#define LogI(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_INFO, __LINE__, __FUNCTION__, b ) : void() ) +#define LogE(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_ERR, __LINE__, __FUNCTION__, b ) : void() ) +#define LogD(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_DEBUG, __LINE__, __FUNCTION__, b ) : void() ) +//#define LogE(a, b...) void( CheckLevel(a) ? esyslog ( b ) : void() ) +//#define LogD(a, b...) void( CheckLevel(a) ? dsyslog ( b ) : void() ) +#define prep(s) PrepareLog(s) +#define prep2(s) s + + +//void LogF(int level, const char * message, ...) __attribute__ ((format (printf,2,3))); + +//void LogF(int level, const char * message, ...) +//{ +// if (CheckLevel(level)) { +// va_list ap; +// va_start(ap,message); +// vsyslog (LOG_ERR, PrepareLog(message), ap ); +// va_end(ap); +// } +//} + +#endif /* LOG_H_ */ -- cgit v1.2.3 From d91b6baad0e8f377254fdc67780602d03e745433 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 9 May 2012 13:00:11 +0200 Subject: move cSetupEEPG to separate files --- eepg.c | 35 ++--------------------------------- log.h | 3 ++- setupeepg.c | 33 +++++++++++++++++++++++++++++++++ setupeepg.h | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 34 deletions(-) create mode 100644 setupeepg.c create mode 100644 setupeepg.h diff --git a/eepg.c b/eepg.c index 22ee520..2ed8f2f 100644 --- a/eepg.c +++ b/eepg.c @@ -40,6 +40,7 @@ #include "dish.h" #include "epghandler.h" #include "log.h" +#include "setupeepg.h" #include #include @@ -75,8 +76,6 @@ static const char *DESCRIPTION = trNOOP ("Parses Extended EPG data"); using namespace std; -// --- cSetupEEPG ------------------------------------------------------- - const char *optPats[] = { "%s", "%s (Option %d)", @@ -101,38 +100,8 @@ char *cs_hexdump (int m, const uchar * buf, int n) return (dump); } -class cSetupEEPG -{ -public: - int OptPat; - int OrderInfo; - int RatingInfo; - int FixEpg; - int DisplayMessage; - int ProcessEIT; -#ifdef DEBUG - int LogLevel; -#endif - -public: - cSetupEEPG (void); -}; - -cSetupEEPG SetupPE; +cSetupEEPG SetupPE = *cSetupEEPG::getInstance(); -cSetupEEPG::cSetupEEPG (void) -{ - OptPat = 1; - OrderInfo = 1; - RatingInfo = 1; - FixEpg = 0; - DisplayMessage = 1; - ProcessEIT = 0; -#ifdef DEBUG - LogLevel = 0; -#endif - -} // --- cMenuSetupPremiereEpg ------------------------------------------------------------ diff --git a/log.h b/log.h index 900aed6..c771d5f 100644 --- a/log.h +++ b/log.h @@ -10,6 +10,7 @@ #include #include +#include "setupeepg.h" #define VERBOSE 1 /* 0 = only print errors, 1 = print channels and themes, 2 = print channels, themes, titles, summaries 3 = debug mode */ @@ -19,7 +20,7 @@ bool CheckLevel(int level) { #ifdef DEBUG - if (SetupPE.LogLevel >= level) + if (cSetupEEPG::getInstance().LogLevel >= level) #else if (VERBOSE >= level) #endif diff --git a/setupeepg.c b/setupeepg.c new file mode 100644 index 0000000..4c6693d --- /dev/null +++ b/setupeepg.c @@ -0,0 +1,33 @@ +/* + * setupeepg.c + * + * Created on: 08.5.2012 + * Author: d.petrovski + */ + +#include "setupeepg.h" + +// --- cSetupEEPG ------------------------------------------------------- + +cSetupEEPG::cSetupEEPG (void) +{ + OptPat = 1; + OrderInfo = 1; + RatingInfo = 1; + FixEpg = 0; + DisplayMessage = 1; + ProcessEIT = 0; +#ifdef DEBUG + LogLevel = 0; +#endif + +} + +static cSetupEEPG* cSetupEEPG::getInstance() +{ + if (!_setupEEPG) + _setupEEPG = new cSetupEEPG(); + + return _setupEEPG; +} + diff --git a/setupeepg.h b/setupeepg.h new file mode 100644 index 0000000..7441223 --- /dev/null +++ b/setupeepg.h @@ -0,0 +1,33 @@ +/* + * setupeepg.h + * + * Created on: 08.5.2012 + * Author: d.petrovski + */ + +#ifndef SETUPEEPG_H_ +#define SETUPEEPG_H_ + +class cSetupEEPG +{ +public: + int OptPat; + int OrderInfo; + int RatingInfo; + int FixEpg; + int DisplayMessage; + int ProcessEIT; +#ifdef DEBUG + int LogLevel; +#endif + +public: + static cSetupEEPG* getInstance(); + +private: + cSetupEEPG (void); + cSetupEEPG* _setupEEPG; + +}; + +#endif /* SETUPEEPG_H_ */ -- cgit v1.2.3 From 9bb23fd7bd0e651fa4e4902e7033ced95e18d373 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 9 May 2012 13:49:46 +0200 Subject: changes in cSetupEEPG --- eepg.c | 2 +- log.h | 2 +- setupeepg.c | 3 +++ setupeepg.h | 4 +++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/eepg.c b/eepg.c index 2ed8f2f..7cfb745 100644 --- a/eepg.c +++ b/eepg.c @@ -119,7 +119,7 @@ public: cMenuSetupPremiereEpg::cMenuSetupPremiereEpg (void) { - data = SetupPE; + data = *cSetupEEPG::getInstance(); SetSection (tr ("PremiereEPG")); optDisp[0] = tr ("off"); for (unsigned int i = 1; i < NUM_PATS; i++) { diff --git a/log.h b/log.h index c771d5f..1a0e88f 100644 --- a/log.h +++ b/log.h @@ -20,7 +20,7 @@ bool CheckLevel(int level) { #ifdef DEBUG - if (cSetupEEPG::getInstance().LogLevel >= level) + if (cSetupEEPG::getInstance()->LogLevel >= level) #else if (VERBOSE >= level) #endif diff --git a/setupeepg.c b/setupeepg.c index 4c6693d..4d9471e 100644 --- a/setupeepg.c +++ b/setupeepg.c @@ -5,10 +5,13 @@ * Author: d.petrovski */ +#include #include "setupeepg.h" // --- cSetupEEPG ------------------------------------------------------- +cSetupEEPG* cSetupEEPG::_setupEEPG = NULL; + cSetupEEPG::cSetupEEPG (void) { OptPat = 1; diff --git a/setupeepg.h b/setupeepg.h index 7441223..ef1ad2a 100644 --- a/setupeepg.h +++ b/setupeepg.h @@ -26,7 +26,9 @@ public: private: cSetupEEPG (void); - cSetupEEPG* _setupEEPG; + cSetupEEPG(cSetupEEPG const&){}; // copy constructor is private + cSetupEEPG& operator=(cSetupEEPG const&){}; // assignment operator is private + static cSetupEEPG* _setupEEPG; }; -- cgit v1.2.3 From b9ebcef5352ba8d70edc4ea6531b7560569af88b Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 9 May 2012 14:14:02 +0200 Subject: changed SetupPE to pointer --- eepg.c | 60 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/eepg.c b/eepg.c index 7cfb745..042180d 100644 --- a/eepg.c +++ b/eepg.c @@ -100,7 +100,7 @@ char *cs_hexdump (int m, const uchar * buf, int n) return (dump); } -cSetupEEPG SetupPE = *cSetupEEPG::getInstance(); +cSetupEEPG* SetupPE = cSetupEEPG::getInstance(); // --- cMenuSetupPremiereEpg ------------------------------------------------------------ @@ -108,7 +108,7 @@ cSetupEEPG SetupPE = *cSetupEEPG::getInstance(); class cMenuSetupPremiereEpg:public cMenuSetupPage { private: - cSetupEEPG data; + cSetupEEPG* data; const char *optDisp[NUM_PATS]; char buff[NUM_PATS][32]; protected: @@ -119,35 +119,35 @@ public: cMenuSetupPremiereEpg::cMenuSetupPremiereEpg (void) { - data = *cSetupEEPG::getInstance(); + data = cSetupEEPG::getInstance(); SetSection (tr ("PremiereEPG")); optDisp[0] = tr ("off"); for (unsigned int i = 1; i < NUM_PATS; i++) { snprintf (buff[i], sizeof (buff[i]), optPats[i], "Event", 1); optDisp[i] = buff[i]; } - Add (new cMenuEditStraItem (tr ("Tag option events"), &data.OptPat, NUM_PATS, optDisp)); - Add (new cMenuEditBoolItem (tr ("Show order information"), &data.OrderInfo)); - Add (new cMenuEditBoolItem (tr ("Show rating information"), &data.RatingInfo)); - Add (new cMenuEditBoolItem (tr ("Fix EPG data"), &data.FixEpg)); - Add (new cMenuEditBoolItem (tr ("Display summary message"), &data.DisplayMessage)); + Add (new cMenuEditStraItem (tr ("Tag option events"), &data->OptPat, NUM_PATS, optDisp)); + Add (new cMenuEditBoolItem (tr ("Show order information"), &data->OrderInfo)); + Add (new cMenuEditBoolItem (tr ("Show rating information"), &data->RatingInfo)); + Add (new cMenuEditBoolItem (tr ("Fix EPG data"), &data->FixEpg)); + Add (new cMenuEditBoolItem (tr ("Display summary message"), &data->DisplayMessage)); #ifdef DEBUG - Add (new cMenuEditIntItem (tr ("Level of logging verbosity"), &data.LogLevel, 0, 5)); - Add (new cMenuEditBoolItem (tr ("Process EIT info with EEPG"), &data.ProcessEIT)); + Add (new cMenuEditIntItem (tr ("Level of logging verbosity"), &data->LogLevel, 0, 5)); + Add (new cMenuEditBoolItem (tr ("Process EIT info with EEPG"), &data->ProcessEIT)); #endif } void cMenuSetupPremiereEpg::Store (void) { - SetupPE = data; - SetupStore ("OptionPattern", SetupPE.OptPat); - SetupStore ("OrderInfo", SetupPE.OrderInfo); - SetupStore ("RatingInfo", SetupPE.RatingInfo); - SetupStore ("FixEpg", SetupPE.FixEpg); - SetupStore ("DisplayMessage", SetupPE.DisplayMessage); + //SetupPE = data; + SetupStore ("OptionPattern", SetupPE->OptPat); + SetupStore ("OrderInfo", SetupPE->OrderInfo); + SetupStore ("RatingInfo", SetupPE->RatingInfo); + SetupStore ("FixEpg", SetupPE->FixEpg); + SetupStore ("DisplayMessage", SetupPE->DisplayMessage); #ifdef DEBUG - SetupStore ("LogLevel", SetupPE.LogLevel); - SetupStore ("ProcessEIT", SetupPE.ProcessEIT); + SetupStore ("LogLevel", SetupPE->LogLevel); + SetupStore ("ProcessEIT", SetupPE->ProcessEIT); #endif } @@ -2959,7 +2959,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat : SI::EIT (Data, false) { //LogD(2, prep("cEIT2::cEIT2")); - if (Tid > 0 && (Format == DISH_BEV || (SetupPE.ProcessEIT && isEITPid))) Tid--; + if (Tid > 0 && (Format == DISH_BEV || (SetupPE->ProcessEIT && isEITPid))) Tid--; if (!CheckCRCAndParse ()) { LogD(2, prep("!CheckCRCAndParse ()")); @@ -3573,7 +3573,7 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) isyslog ("EEPG: written %i summaries", SummaryCounter); isyslog ("EEPG: rejected %i titles/summaries because of higher TableId", RejectTableId); //Send message when finished - if (SetupPE.DisplayMessage) { + if (SetupPE->DisplayMessage) { char *mesg; Asprintf(&mesg, "EEPG: written %i summaries", SummaryCounter); Skins.QueueMessage(mtInfo, mesg, 2); @@ -3603,7 +3603,7 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) FreeSummaries (); // Enable EIT scan for all except DISH_BEV since it is already enabled - if (SetupPE.ProcessEIT && !UnprocessedFormat[EIT] + if (SetupPE->ProcessEIT && !UnprocessedFormat[EIT] && !UnprocessedFormat[FREEVIEW] && !UnprocessedFormat[DISH_BEV]) { UnprocessedFormat[EIT] = EIT_PID; loadEquivalentChannelMap(); @@ -4131,7 +4131,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) nDescriptorTag = d->getDescriptorTag (); switch (nDescriptorTag) { case 0xF0: // order information - if (SetupPE.OrderInfo) { + if (SetupPE->OrderInfo) { static const char *text[] = { trNOOP ("Ordernumber"), trNOOP ("Price"), @@ -4153,7 +4153,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) } break; case 0xF1: // parental rating - if (SetupPE.RatingInfo) { + if (SetupPE->RatingInfo) { char buff[512]; int p = 0; const unsigned char *data = d->getData ().getData () + 2; @@ -4233,7 +4233,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) int nid = pct->getOriginalNetworkId (); int tid = pct->getTransportStreamId (); int sid = pct->getServiceId (); - if (SetupPE.FixEpg) { + if (SetupPE->FixEpg) { if (nid == 133) { if (tid == 0x03 && sid == 0xf0) { tid = 0x02; @@ -4327,7 +4327,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) ShortEventDescriptor->name.getText (buffer, sizeof (buffer)); if (isOpt) { char buffer2[sizeof (buffer) + 32]; - snprintf (buffer2, sizeof (buffer2), optPats[SetupPE.OptPat], buffer, optCount); + snprintf (buffer2, sizeof (buffer2), optPats[SetupPE->OptPat], buffer, optCount); pEvent->SetTitle (buffer2); } else pEvent->SetTitle (buffer); @@ -4537,15 +4537,15 @@ bool cPluginEEPG::SetupParse (const char *Name, const char *Value) if (!strcasecmp (Name, "OptionPattern")) - SetupPE.OptPat = atoi (Value); + SetupPE->OptPat = atoi (Value); else if (!strcasecmp (Name, "OrderInfo")) - SetupPE.OrderInfo = atoi (Value); + SetupPE->OrderInfo = atoi (Value); else if (!strcasecmp (Name, "RatingInfo")) - SetupPE.RatingInfo = atoi (Value); + SetupPE->RatingInfo = atoi (Value); else if (!strcasecmp (Name, "FixEpg")) - SetupPE.FixEpg = atoi (Value); + SetupPE->FixEpg = atoi (Value); else if (!strcasecmp (Name, "DisplayMessage")) - SetupPE.DisplayMessage = atoi (Value); + SetupPE->DisplayMessage = atoi (Value); #ifdef DEBUG else if (!strcasecmp (Name, "LogLevel")) SetupPE.LogLevel = atoi (Value); -- cgit v1.2.3 From 76ec1833ba62798c671935014a10677f514ffc0a Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 9 May 2012 14:45:29 +0200 Subject: fix compile --- Makefile | 2 +- eepg.c | 4 ++-- log.h | 6 +++--- setupeepg.c | 2 +- setupeepg.h | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 0bebc82..a2d413e 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"' ### The object files (add further files here): -OBJS = $(PLUGIN).o dish.o epghandler.o +OBJS = $(PLUGIN).o dish.o epghandler.o setupeepg.o ifdef DBG CXXFLAGS += -g diff --git a/eepg.c b/eepg.c index 042180d..902c271 100644 --- a/eepg.c +++ b/eepg.c @@ -4548,9 +4548,9 @@ bool cPluginEEPG::SetupParse (const char *Name, const char *Value) SetupPE->DisplayMessage = atoi (Value); #ifdef DEBUG else if (!strcasecmp (Name, "LogLevel")) - SetupPE.LogLevel = atoi (Value); + SetupPE->LogLevel = atoi (Value); else if (!strcasecmp (Name, "ProcessEIT")) - SetupPE.ProcessEIT = atoi (Value); + SetupPE->ProcessEIT = atoi (Value); #endif else return false; diff --git a/log.h b/log.h index 1a0e88f..35942d3 100644 --- a/log.h +++ b/log.h @@ -17,7 +17,7 @@ /* all is logged into /var/log/syslog */ -bool CheckLevel(int level) +inline bool CheckLevel(int level) { #ifdef DEBUG if (cSetupEEPG::getInstance()->LogLevel >= level) @@ -30,7 +30,7 @@ bool CheckLevel(int level) return false; } -const char* PrepareLog(std::string message) +inline const char* PrepareLog(std::string message) { message = "EEPG: " + message; return message.c_str(); @@ -39,7 +39,7 @@ const char* PrepareLog(std::string message) #define MAXSYSLOGBUF 256 //void LogVsyslog(int errLevel, const char * message, ...) -void LogVsyslog(int errLevel, int const& lineNum, const char * function, const char * message, ...) +inline void LogVsyslog(int errLevel, int const& lineNum, const char * function, const char * message, ...) { va_list ap; char fmt[MAXSYSLOGBUF]; diff --git a/setupeepg.c b/setupeepg.c index 4d9471e..3738227 100644 --- a/setupeepg.c +++ b/setupeepg.c @@ -26,7 +26,7 @@ cSetupEEPG::cSetupEEPG (void) } -static cSetupEEPG* cSetupEEPG::getInstance() +cSetupEEPG* cSetupEEPG::getInstance() { if (!_setupEEPG) _setupEEPG = new cSetupEEPG(); diff --git a/setupeepg.h b/setupeepg.h index ef1ad2a..f5e342a 100644 --- a/setupeepg.h +++ b/setupeepg.h @@ -26,8 +26,8 @@ public: private: cSetupEEPG (void); - cSetupEEPG(cSetupEEPG const&){}; // copy constructor is private - cSetupEEPG& operator=(cSetupEEPG const&){}; // assignment operator is private + cSetupEEPG(cSetupEEPG const&); // copy constructor is private + cSetupEEPG& operator=(cSetupEEPG const&); // assignment operator is private static cSetupEEPG* _setupEEPG; }; -- cgit v1.2.3 From 9b91e6882c17955d4e48e5d0a7f250f559cf5359 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 9 May 2012 14:51:23 +0200 Subject: more debug logging --- epghandler.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/epghandler.c b/epghandler.c index abc4c38..b9057c1 100644 --- a/epghandler.c +++ b/epghandler.c @@ -10,6 +10,7 @@ cEEpgHandler::cEEpgHandler() { // TODO Auto-generated constructor stub + LogD(1, prep("cEEpgHandler()")); } @@ -19,6 +20,7 @@ cEEpgHandler::~cEEpgHandler() { bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, const SI::EIT::Event* EitEvent, uchar TableID, uchar Version) { + LogD(1, prep("HandleEitEvent")); return true; } @@ -75,6 +77,7 @@ bool cEEpgHandler::SetVps(cEvent* Event, time_t Vps) { } bool cEEpgHandler::HandleEvent(cEvent* Event) { + LogD(1, prep("HandleEvent")); return true; } -- cgit v1.2.3 From ea7e60395beaa885b6c6f8fcf86899412cab8199 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 9 May 2012 16:54:35 +0200 Subject: change conditions --- epghandler.c | 27 +++++++++++++++------------ epghandler.h | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/epghandler.c b/epghandler.c index b9057c1..68f68d5 100644 --- a/epghandler.c +++ b/epghandler.c @@ -20,8 +20,9 @@ cEEpgHandler::~cEEpgHandler() { bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, const SI::EIT::Event* EitEvent, uchar TableID, uchar Version) { - LogD(1, prep("HandleEitEvent")); - return true; + //LogD(1, prep("HandleEitEvent")); + return false; +// return true; } bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) { @@ -32,23 +33,25 @@ bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) { bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { LogD(1, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title); - if (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title))) - Event->SetTitle(Title); - return true; + if (!Event->Title() || Title && (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title)))) + Event->SetTitle(Title); + return true; } bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) { LogD(1, prep("Event id:%d ShortText:%s new ShortText:%s"), Event->EventID(), Event->ShortText(), ShortText); - if (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText))) - Event->SetShortText(ShortText); - return true; + if (!Event->ShortText() || ShortText && (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText)))) + Event->SetShortText(ShortText); + return true; } bool cEEpgHandler::SetDescription(cEvent* Event, const char* Description) { - if (!strcmp(Event->Description(),"") || (strcmp(Description,"") && strcmp(Event->Description(),Description))) - Event->SetDescription(Description); - return true; + LogD(1, prep("Event id:%d Description:%s new Description:%s"), Event->EventID(), Event->Description(), Description); + + if (!Event->Description() || Description && (!strcmp(Event->Description(),"") || (strcmp(Description,"") && strcmp(Event->Description(),Description)))) + Event->SetDescription(Description); + return true; } bool cEEpgHandler::SetContents(cEvent* Event, uchar* Contents) { @@ -77,7 +80,7 @@ bool cEEpgHandler::SetVps(cEvent* Event, time_t Vps) { } bool cEEpgHandler::HandleEvent(cEvent* Event) { - LogD(1, prep("HandleEvent")); + //LogD(1, prep("HandleEvent")); return true; } diff --git a/epghandler.h b/epghandler.h index 1dee4f2..fd4911e 100644 --- a/epghandler.h +++ b/epghandler.h @@ -9,7 +9,7 @@ #define CEEPGHANDLER_H_ #include -class cEEpgHandler : public cEpgDataReader { +class cEEpgHandler : public cEpgHandler { public: cEEpgHandler(); virtual ~cEEpgHandler(); -- cgit v1.2.3 From 0ab5c2dcb92ad4e75b0ed41167a12b1178882bdb Mon Sep 17 00:00:00 2001 From: Dime Date: Sun, 13 May 2012 13:31:03 +0200 Subject: use the original eepg Short Text and Description if missing in EIT --- epghandler.c | 26 ++++++++++++++++++++++++-- epghandler.h | 5 +++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/epghandler.c b/epghandler.c index 68f68d5..5bed74f 100644 --- a/epghandler.c +++ b/epghandler.c @@ -41,15 +41,25 @@ bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) { LogD(1, prep("Event id:%d ShortText:%s new ShortText:%s"), Event->EventID(), Event->ShortText(), ShortText); - if (!Event->ShortText() || ShortText && (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText)))) + if (Event->ShortText() && !strcmp(Event->ShortText(),"")) + origShortText = Event->ShortText(); + else + origShortText.clear(); + + //if (!Event->ShortText() || ShortText && (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText)))) Event->SetShortText(ShortText); return true; } bool cEEpgHandler::SetDescription(cEvent* Event, const char* Description) { LogD(1, prep("Event id:%d Description:%s new Description:%s"), Event->EventID(), Event->Description(), Description); + + if (Event->Description() && !strcmp(Event->Description(),"")) + origDescription = Event->Description(); + else + origDescription.clear(); - if (!Event->Description() || Description && (!strcmp(Event->Description(),"") || (strcmp(Description,"") && strcmp(Event->Description(),Description)))) + //if (!Event->Description() || Description && (!strcmp(Event->Description(),"") || (strcmp(Description,"") && strcmp(Event->Description(),Description)))) Event->SetDescription(Description); return true; } @@ -81,6 +91,18 @@ bool cEEpgHandler::SetVps(cEvent* Event, time_t Vps) { bool cEEpgHandler::HandleEvent(cEvent* Event) { //LogD(1, prep("HandleEvent")); + + //After FixEpgBugs of cEvent set the original Short Text if empty + if (!Event->ShortText() && !strcmp(Event->ShortText(),"")) + Event->SetShortText(origShortText.c_str()); + + //TODO just to see the difference + if (!origDescription.empty() && !origDescription.compare(Event->Description())) { + origDescription.append(" | EIT: "); + origDescription.append(Event->Description()); + Event->SetDescription(origDescription.c_str()); + } + return true; } diff --git a/epghandler.h b/epghandler.h index fd4911e..3256153 100644 --- a/epghandler.h +++ b/epghandler.h @@ -8,6 +8,7 @@ #ifndef CEEPGHANDLER_H_ #define CEEPGHANDLER_H_ #include +#include class cEEpgHandler : public cEpgHandler { public: @@ -28,6 +29,10 @@ public: virtual bool HandleEvent(cEvent *Event); virtual bool SortSchedule(cSchedule *Schedule); virtual bool DropOutdated(cSchedule *Schedule, time_t SegmentStart, time_t SegmentEnd, uchar TableID, uchar Version); + +private: + std::string origShortText; + std::string origDescription; }; #endif /* CEEPGHANDLER_H_ */ -- cgit v1.2.3 From 1a3ea541feb02657c6fc3882c941c5143bc79a73 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sun, 13 May 2012 18:20:18 +0200 Subject: corected epghandler --- epghandler.c | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/epghandler.c b/epghandler.c index 5bed74f..2c25268 100644 --- a/epghandler.c +++ b/epghandler.c @@ -10,7 +10,7 @@ cEEpgHandler::cEEpgHandler() { // TODO Auto-generated constructor stub - LogD(1, prep("cEEpgHandler()")); + LogD(4, prep("cEEpgHandler()")); } @@ -31,7 +31,7 @@ bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) { } bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { - LogD(1, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title); + LogD(3, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title); if (!Event->Title() || Title && (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title)))) Event->SetTitle(Title); @@ -39,12 +39,14 @@ bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { } bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) { - LogD(1, prep("Event id:%d ShortText:%s new ShortText:%s"), Event->EventID(), Event->ShortText(), ShortText); + LogD(3, prep("Event id:%d ShortText:%s new ShortText:%s"), Event->EventID(), Event->ShortText(), ShortText); - if (Event->ShortText() && !strcmp(Event->ShortText(),"")) - origShortText = Event->ShortText(); - else + if (Event->ShortText() && strcmp(Event->ShortText(),"") != 0) { + origShortText = std::string(Event->ShortText()); + } + else { origShortText.clear(); + } //if (!Event->ShortText() || ShortText && (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText)))) Event->SetShortText(ShortText); @@ -52,9 +54,9 @@ bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) { } bool cEEpgHandler::SetDescription(cEvent* Event, const char* Description) { - LogD(1, prep("Event id:%d Description:%s new Description:%s"), Event->EventID(), Event->Description(), Description); + LogD(3, prep("Event id:%d Description:%s new Description:%s"), Event->EventID(), Event->Description(), Description); - if (Event->Description() && !strcmp(Event->Description(),"")) + if (Event->Description() && strcmp(Event->Description(),"") != 0) origDescription = Event->Description(); else origDescription.clear(); @@ -90,18 +92,22 @@ bool cEEpgHandler::SetVps(cEvent* Event, time_t Vps) { } bool cEEpgHandler::HandleEvent(cEvent* Event) { - //LogD(1, prep("HandleEvent")); - - //After FixEpgBugs of cEvent set the original Short Text if empty - if (!Event->ShortText() && !strcmp(Event->ShortText(),"")) - Event->SetShortText(origShortText.c_str()); - - //TODO just to see the difference - if (!origDescription.empty() && !origDescription.compare(Event->Description())) { - origDescription.append(" | EIT: "); - origDescription.append(Event->Description()); - Event->SetDescription(origDescription.c_str()); - } + + LogD(3, prep("HandleEvent st:%s ost:%s desc:%s odesc:%s"),Event->ShortText(),origShortText.c_str(),Event->Description(),origDescription.c_str()); + + //After FixEpgBugs of cEvent set the original Short Text if empty + if (!Event->ShortText() || !strcmp(Event->ShortText(),"")) + Event->SetShortText(origShortText.c_str()); + + if (!Event->Description() && !origDescription.empty()) { + Event->SetDescription(origDescription.c_str()); + } + //TODO just to see the difference + //else if (!origDescription.empty() && !origDescription.compare(Event->Description())) { +// origDescription.append(" | EIT: "); +// origDescription.append(Event->Description()); +// Event->SetDescription(origDescription.c_str()); + // } return true; } -- cgit v1.2.3 From eb3124a781a2ec0536aa78a4c9b17311f0387969 Mon Sep 17 00:00:00 2001 From: Dime Date: Wed, 16 May 2012 13:24:24 +0200 Subject: add defines to compile wit VDR < 1.7.26 --- eepg.c | 2 ++ epghandler.c | 3 ++- epghandler.h | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/eepg.c b/eepg.c index bb4b5f5..4bfd5d7 100644 --- a/eepg.c +++ b/eepg.c @@ -4497,7 +4497,9 @@ bool cPluginEEPG::Start (void) for (int i = 0; i < NumberOfAvailableSources; i++) isyslog ("EEPG: Available sources:%s.", *cSource::ToString (AvailableSources[i])); +#if APIVERSNUM > 10725 new cEEpgHandler(); +#endif closedir(ConfigDir); return true; diff --git a/epghandler.c b/epghandler.c index 2c25268..36aaf74 100644 --- a/epghandler.c +++ b/epghandler.c @@ -5,6 +5,7 @@ * Author: d.petrovski */ +#if APIVERSNUM > 10725 #include "epghandler.h" #include "log.h" @@ -122,4 +123,4 @@ bool cEEpgHandler::DropOutdated(cSchedule* Schedule, time_t SegmentStart, return false; } - +#endif diff --git a/epghandler.h b/epghandler.h index 3256153..8d3615a 100644 --- a/epghandler.h +++ b/epghandler.h @@ -7,6 +7,7 @@ #ifndef CEEPGHANDLER_H_ #define CEEPGHANDLER_H_ +#if APIVERSNUM > 10725 #include #include @@ -35,4 +36,5 @@ private: std::string origDescription; }; +#endif /*APIVERSNUM > 10725*/ #endif /* CEEPGHANDLER_H_ */ -- cgit v1.2.3 From d83f0216f4eee94ea6f945cc1fab83a5e93b8303 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Thu, 17 May 2012 13:00:58 +0200 Subject: fix some indentation --- eepg.c | 384 ++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 191 insertions(+), 193 deletions(-) diff --git a/eepg.c b/eepg.c index 4bfd5d7..80ad23f 100644 --- a/eepg.c +++ b/eepg.c @@ -234,7 +234,7 @@ private: unsigned char InitialSummary[64]; void NextPmt (void); - void ProccessContinuous(u_short Pid, u_char Tid, int Length, const u_char *Data); + void ProccessContinuous(u_short Pid, u_char Tid, int Length, const u_char *Data); protected: virtual void Process (u_short Pid, u_char Tid, const u_char * Data, int Length); virtual void AddFilter (u_short Pid, u_char Tid); @@ -262,9 +262,9 @@ protected: virtual void PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]); //gets a channel and returns an array of schedules that WriteToSchedule can write to. Call this routine before a batch of titles with the same ChannelId will be WriteToScheduled; batchsize can be 1 virtual void FinishWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]); virtual void WriteToSchedule (cSchedule * ps[MAX_EQUIVALENCES], unsigned short int NumberOfEquivalences, - unsigned int EventId, unsigned int StartTime, unsigned int Duration, char *Text, - char *SummText, unsigned short int ThemeId, unsigned short int TableId, - unsigned short int Version, char Rating = 0x00); + unsigned int EventId, unsigned int StartTime, unsigned int Duration, char *Text, + char *SummText, unsigned short int ThemeId, unsigned short int TableId, + unsigned short int Version, char Rating = 0x00); virtual void LoadIntoSchedule (void); virtual void LoadEquivalentChannels (void); @@ -491,7 +491,7 @@ static bool load_sky_file (const char *filename) memset (string1, 0, sizeof (string1)); memset (string2, 0, sizeof (string2)); if (sscanf (Line, "%c=%[^\n]\n", string1, string2) == 2 - || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) { + || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) { nH = sky_tables[tableId]; LenPrefix = strlen (string2); for (i = 0; i < LenPrefix; i++) { @@ -510,7 +510,7 @@ static bool load_sky_file (const char *filename) nH = nH->P0; if (nH->Value != NULL || (LenPrefix - 1) == i) { LogE (0 ,prep("Error, huffman prefix code already exists for \"%s\"=%s with '%s'"), string1, - string2, nH->Value); + string2, nH->Value); } } break; @@ -528,7 +528,7 @@ static bool load_sky_file (const char *filename) nH = nH->P1; if (nH->Value != NULL || (LenPrefix - 1) == i) { LogE (0, prep("Error, huffman prefix code already exists for \"%s\"=%s with '%s'"), string1, - string2, nH->Value); + string2, nH->Value); } } break; @@ -554,7 +554,7 @@ static bool load_sky_file (const char *filename) memset (string1, 0, sizeof (string1)); memset (string2, 0, sizeof (string2)); if (sscanf (Line, "%c=%[^\n]\n", string1, string2) == 2 - || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) { + || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) { nH = sky_tables[tableId]; LenPrefix = strlen (string2); for (i = 0; i < LenPrefix; i++) { @@ -873,20 +873,20 @@ void CleanString (unsigned char *String) cChannel *GetChannelByID(tChannelID & channelID, bool searchOtherPos) { - cChannel *VC = Channels.GetByChannelID(channelID, true); - if(!VC && searchOtherPos){ - //look on other satpositions - for(int i = 0;i < NumberOfAvailableSources;i++){ - channelID = tChannelID(AvailableSources[i], channelID.Nid(), channelID.Tid(), channelID.Sid()); - VC = Channels.GetByChannelID(channelID, true); - if(VC){ - //found this actually on satellite nextdoor... - break; - } - } + cChannel *VC = Channels.GetByChannelID(channelID, true); + if(!VC && searchOtherPos){ + //look on other satpositions + for(int i = 0;i < NumberOfAvailableSources;i++){ + channelID = tChannelID(AvailableSources[i], channelID.Nid(), channelID.Tid(), channelID.Sid()); + VC = Channels.GetByChannelID(channelID, true); + if(VC){ + //found this actually on satellite nextdoor... + break; + } } + } - return VC; + return VC; } bool cFilterEEPG::GetThemesSKYBOX (void) //TODO can't we read this from the DVB stream? @@ -962,7 +962,7 @@ bool cFilterEEPG::InitDictionary (void) LogD (4, prep("EEPGDebug: loading freesat.dict")); FileName += "/freesat.t1"; if (!load_freesat_file (1, FileName.c_str())) - return false; + return false; FileName = ConfDir; FileName += "/freesat.t2"; return load_freesat_file (2, FileName.c_str()); @@ -1010,7 +1010,7 @@ void loadEquivalentChannelMap (void) //TODO DPE add code to reload if file is changed if (equiChanMap.size() > 0) - return; + return; File = fopen (FileName.c_str(), "r"); @@ -1040,37 +1040,37 @@ void loadEquivalentChannelMap (void) tChannelID OriginalChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); bool found = false; //int i = 0; - cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); - if (!OriginalChannel) { - LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalency is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? - continue; + cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); + if (!OriginalChannel) { + LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalency is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? + continue; + } + if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { + if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) + != 5) { + rid = 0; } - if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { - if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) - != 5) { - rid = 0; + tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); + cChannel *EquivChannel = Channels.GetByChannelID (EquivChID, false); //TODO use valid function? + if (EquivChannel) { + ret = equiChanMap.equal_range(*OriginalChID.ToString()); + for (it=ret.first; it!=ret.second; ++it) + if ((*it).second == *OriginalChID.ToString()) { + found = true; + break; + } + + if (!found) { + string origCh(*OriginalChID.ToString()); + string equiCh(*EquivChID.ToString()); + equiChanMap.insert(pair(origCh.c_str(),equiCh.c_str())); + LogD(4, prep("Found %s equivalent to %s. origCh %s"), *EquivChID.ToString(), *OriginalChID.ToString(), origCh.c_str()); + for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) + LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); } - tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); - cChannel *EquivChannel = Channels.GetByChannelID (EquivChID, false); //TODO use valid function? - if (EquivChannel) { - ret = equiChanMap.equal_range(*OriginalChID.ToString()); - for (it=ret.first; it!=ret.second; ++it) - if ((*it).second == *OriginalChID.ToString()) { - found = true; - break; - } - - if (!found) { - string origCh(*OriginalChID.ToString()); - string equiCh(*EquivChID.ToString()); - equiChanMap.insert(pair(origCh.c_str(),equiCh.c_str())); - LogD(4, prep("Found %s equivalent to %s. origCh %s"), *EquivChID.ToString(), *OriginalChID.ToString(), origCh.c_str()); - for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) - LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); - } - } else - LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); - } + } else + LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); + } } //if scanf string1 } //if string1 } //if scanf @@ -1079,7 +1079,7 @@ void loadEquivalentChannelMap (void) fclose (File); LogD(3, prep("Loaded %i equivalents."), equiChanMap.size()); for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) - LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); + LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); } //if file } void cFilterEEPG::LoadEquivalentChannels (void) @@ -1120,21 +1120,21 @@ void cFilterEEPG::LoadEquivalentChannels (void) while (i < nChannels && (!found)) { C = &sChannels[i]; if (C->Src[0] == (unsigned int)cSource::FromString (source) && C->Nid[0] == nid - && C->Tid[0] == tid && C->Sid[0] == sid) + && C->Tid[0] == tid && C->Sid[0] == sid) found = true; else i++; } if (!found) { LogI(2, prep("Warning: in equivalence file, cannot find original channel %s. Perhaps you are tuned to another transponder right now."), - origChanID); + origChanID); } else { cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); if (!OriginalChannel) LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalence is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) - != 5) { + != 5) { rid = 0; } tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); @@ -1153,7 +1153,7 @@ void cFilterEEPG::LoadEquivalentChannels (void) C->Sid[C->NumberOfEquivalences - 1], i); } else LogE(0, prep("Error, channel with id %i has more than %i equivalences. Increase MAX_EQUIVALENCES."), - i, MAX_EQUIVALENCES); + i, MAX_EQUIVALENCES); } else LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); } @@ -1238,7 +1238,7 @@ int cFilterEEPG::GetChannelsMHW (const u_char * Data, int Length, int MHW) cChannel *VC = GetChannelByID(channelID, true); bool IsFound = (VC); if(IsFound) { - C->Src[0] = VC->Source(); + C->Src[0] = VC->Source(); } CleanString (C->Name); @@ -1254,7 +1254,7 @@ int cFilterEEPG::GetChannelsMHW (const u_char * Data, int Length, int MHW) return 2; //obviously, when you get here, channels are read successfully, but since all channels are sent at once, you can stop now } //if nChannels == 0 LogE (0, prep("Warning: Trying to read Channels more than once!")); -//you will only get here when GetChannelsMHW is called, and nChannels !=0, e.g. when multiple citpids cause channels to be read multiple times. Second time, do nothing, give error so that the rest of the chain is not restarted also. + //you will only get here when GetChannelsMHW is called, and nChannels !=0, e.g. when multiple citpids cause channels to be read multiple times. Second time, do nothing, give error so that the rest of the chain is not restarted also. return 0; } @@ -1384,7 +1384,7 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse if (TitleEventId != HILO32 (SD->EventId)) { LogI(0, prep("ERROR, Title has EventId %08x and points to Summary with EventId %08x."), TitleEventId, - HILO32 (SD->EventId)); + HILO32 (SD->EventId)); return 0; //return empty string } @@ -1425,7 +1425,7 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse ("EEPGDEBUG: EventId %08x NumberOfBlocks %02x BlockId %08x SummTxtOffset %08x *p2: %02x Unkn1:%02x, Unkn2:%02x.", HILO32 (SD->EventId), SD->NumberOfBlocks, HILO32 (SD->BlockId), HILO32 (SD->SummTxtOffset), *p2, SD->Unknown1, SD->Unknown2); - */ + */ unsigned char *Text = NULL; //makes first realloc work like malloc int TotLength = 0; //and also makes empty summaries if *p2 != 0x4e if (SD->NumberOfBlocks > 1) { @@ -1487,8 +1487,8 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse break; default: LogE(0, prep("ERROR *p2 has strange value: EventId %08x NumberOfBlocks %02x BlockId %08x SummTxtOffset %08x *p2: %02x Unkn1:%02x, Unkn2:%02x."), - HILO32 (SD->EventId), SD->NumberOfBlocks, HILO32 (SD->BlockId), HILO32 (SD->SummTxtOffset), *p2, - SD->Unknown1, SD->Unknown2); + HILO32 (SD->EventId), SD->NumberOfBlocks, HILO32 (SD->BlockId), HILO32 (SD->SummTxtOffset), *p2, + SD->Unknown1, SD->Unknown2); break; } //end of switch } //NrOfBlocks > 1 @@ -1691,7 +1691,7 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor //u_char *t2 = (u_char *) Data + HILO32 (Title->OffsetToText2); if (t >= DataEnd) LogE(0, prep("ERROR, Title Text out of range: t:%p, DataEnd:%p, Data:%p, Length:%i."), t, DataEnd, Data, - Length); + Length); else { Asprintf (&Text, "%.*s", *t, t + 1); //asprintf (&Text, "%.*s %.*s", *t, t + 1, *t2, t2 + 1); //FIXME second text string is not processed right now @@ -1791,7 +1791,7 @@ int cFilterEEPG::GetThemesNagra (const u_char * Data, int Length, unsigned short u_char *NewThemeId = DataStartTitles + HILO32 (TT->TitleOffset) + 28; if (NewThemeId >= DataEndTitles) LogE(0, prep("ERROR, ThemeId out of range: NewThemeId:%p, DataEndTitles:%p, DataStartTitles:%p."), NewThemeId, - DataEndTitles, DataStartTitles); + DataEndTitles, DataStartTitles); else { //esyslog("EEPGDEBUG: NewThemeId:%02x, Text:%s.",*NewThemeId, Text); if (Themes[*NewThemeId][0] != 0x00) { //theme is already filled, break off @@ -1803,7 +1803,7 @@ int cFilterEEPG::GetThemesNagra (const u_char * Data, int Length, unsigned short else if (ThemeId != *NewThemeId) { //different theme ids in block if ((ThemeId & 0xf0) != (*NewThemeId & 0xf0)) { //major nible of themeid does not correspond LogE(3, prep("ERROR, Theme has multiple indices which differ in major nibble, old index = %x, new index = %x. Ignoring both indices."), - ThemeId, *NewThemeId); + ThemeId, *NewThemeId); AnyDoubt = true; break; } else if ((ThemeId & 0x0f) != 0) //ThemeId is like 1a, 2a, not like 10,20. So it is minor in tree-structure, and it should be labeled in major part of tree @@ -1825,7 +1825,7 @@ int cFilterEEPG::GetThemesNagra (const u_char * Data, int Length, unsigned short Textlength = 63; //leave room for trailing NULL if (Themes[ThemeId][0] != 0) { LogE(0, prep("Trying to add new theme, but Id already exists. ThemeId = %x, Old theme with this Id:%s, new theme: %s."), - ThemeId, Themes[ThemeId], Text); + ThemeId, Themes[ThemeId], Text); continue; } memcpy (&Themes[ThemeId], Text, Textlength); @@ -1876,9 +1876,9 @@ int cFilterEEPG::GetChannelsNagra (const u_char * Data, int Length) cChannel *VC = GetChannelByID(channelID, true); bool IsFound = (VC); if(IsFound) { - strncpy((char*)(C->Name), VC->Name (), 64); - C->Src[0] = VC->Source(); - CleanString (C->Name); + strncpy((char*)(C->Name), VC->Name (), 64); + C->Src[0] = VC->Source(); + CleanString (C->Name); } else C->Name[0] = '\0'; //empty string @@ -1930,7 +1930,7 @@ int cFilterEEPG::GetChannelsNagra (const u_char * Data, int Length) isyslog ("EEPGDEBUG: Always0x81 is NOT 0x81:%x.", Channel->Always0x81); if (Channel->Always0x44 != 0x44) isyslog ("EEPGDEBUG: Always0x44 is NOT 0x44:%x.", Channel->Always0x44); - */ + */ } if (p != DataEnd) @@ -1959,7 +1959,7 @@ int cFilterEEPG::GetNagra (const u_char * Data, int Length) u_char *p = (u_char *) Data + 8; if (*p != 0x01) { LogE(0, prep("Error, Nagra first byte in table_id_extension 0x00 is not 0x01 but %02x. Format unknown, exiting."), - *p); + *p); return 0; //fatal error } p++; //skip 0x01 byte @@ -2008,7 +2008,7 @@ int cFilterEEPG::GetNagra (const u_char * Data, int Length) (0x0810) bouquet info; references to channels within a package, day 1 of the month (0x0820) same day 2 of the month (0x09f0) same day 31 of the month - */ + */ if (!(TBH->TableIdExtensionHigh >= 0x02 && TBH->TableIdExtensionHigh <= 0x07)) //here we regulate which tables we are testing return (1); @@ -2071,7 +2071,7 @@ void cFilterEEPG::ProcessNagra () } if (NumberOfTables != 0) LogE(0, prep("ERROR, Not all tables processed and stream is already repeating. NumberOfTables = %i."), - NumberOfTables); + NumberOfTables); } /** @@ -2321,7 +2321,7 @@ int cFilterEEPG::GetSummariesMHW1 (const u_char * Data, int Length) } //numreplays <10 else { LogE(0, prep("Warning, number of replays %d > 10, cannot process."), - Summary->NumReplays); + Summary->NumReplays); return 1; //nonfatal error } } //length >11 @@ -2716,7 +2716,7 @@ void cFilterEEPG::LoadIntoSchedule (void) Title_t *T; Summary_t *S; int remembersummary; -//keep statistics + //keep statistics int SummariesNotFound = 0; int NoSummary = 0; int NotMatching = 0; @@ -2746,7 +2746,7 @@ void cFilterEEPG::LoadIntoSchedule (void) if (!foundtitle) //no more titles with summaries break; if ((T->EventId == S->EventId) && (T->MjdTime == S->Replays[0].MjdTime) - && ((T->ChannelId == S->Replays[0].ChannelId) || ((Format != SKY_IT) && (Format != SKY_UK)))) { //should always be true, titles and summaries are broadcasted in order... + && ((T->ChannelId == S->Replays[0].ChannelId) || ((Format != SKY_IT) && (Format != SKY_UK)))) { //should always be true, titles and summaries are broadcasted in order... LogD(3, prep("T->EventId == S->EventId")); //MjdTime = 0 for all but SKY //S->ChannelId must be equal to T->ChannelId only for SKY; in MHW1 S->ChannelId overrides T->ChannelId when NumReplays > 1 @@ -2794,8 +2794,8 @@ void cFilterEEPG::LoadIntoSchedule (void) } //while while (index < S->NumReplays); -//TODO: why load events that have already past, and then run Cleanup -//end of putting title and summary in schedule + //TODO: why load events that have already past, and then run Cleanup + //end of putting title and summary in schedule i++; //move to next title } //if T->EventId == S->EventId else { @@ -2811,7 +2811,7 @@ void cFilterEEPG::LoadIntoSchedule (void) //esyslog ("EEPG Error: could not find summary for summary-available Title %d.", i); esyslog ("EEPG: Error, summary not found for EventId %08x Titlenr %d:SummAv:%x,Unknown1:%x,Unknown2:%x,Un3:%x,Name:%s.", - T->EventId, i, T->SummaryAvailable, T->Unknown1, T->Unknown2, T->Unknown3, T->Text); + T->EventId, i, T->SummaryAvailable, T->Unknown1, T->Unknown2, T->Unknown3, T->Text); /* write Title info to schedule */ sChannel *C = &sChannels[ChannelSeq[T->ChannelId]]; //find channel @@ -2851,7 +2851,7 @@ void cFilterEEPG::LoadIntoSchedule (void) esyslog ("EEPG: %i summaries not found", SummariesNotFound); if (NotMatching > nSummaries) LogI (0, prep("Warning: lost sync %i times, summary did not match %i times."), - LostSync, NotMatching); + LostSync, NotMatching); FreeSummaries (); //do NOT free channels, themes and bouquets here because they will be reused in SKY! FreeTitles (); @@ -2885,7 +2885,7 @@ namespace SI DishSeriesDescriptorTag = 0x96, }; - // typedef InheritEnum< DescriptorTagExt, SI::DescriptorTag > ExtendedDescriptorTag; +// typedef InheritEnum< DescriptorTagExt, SI::DescriptorTag > ExtendedDescriptorTag; /*extern const char *getCharacterTable(const unsigned char *&buffer, int &length, bool *isSingleByte = NULL); extern bool convertCharacterTable(const char *from, size_t fromLength, char *to, size_t toLength, const char *fromCode); @@ -2926,13 +2926,13 @@ void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEven newEvent->SetStartTime (pEvent->StartTime()); newEvent->SetDuration (pEvent->Duration()); newEvent->SetVersion (pEvent->Version()); - // newEvent->SetContents(pEvent->Contents()); +// newEvent->SetContents(pEvent->Contents()); newEvent->SetParentalRating(pEvent->ParentalRating()); newEvent->SetVps (pEvent->Vps()); newEvent->SetTitle (pEvent->Title ()); newEvent->SetShortText (pEvent->ShortText ()); newEvent->SetDescription (pEvent->Description ()); - // newEvent->SetComponents (pEvent->Components()); +// newEvent->SetComponents (pEvent->Components()); newEvent->FixEpgBugs (); pSchedule->AddEvent(newEvent); @@ -2947,13 +2947,13 @@ void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEven newEvent->SetStartTime (pEvent->StartTime()); newEvent->SetDuration (pEvent->Duration()); newEvent->SetVersion (pEvent->Version()); -// newEvent->SetContents(pEvent->Contents()); +// newEvent->SetContents(pEvent->Contents()); newEvent->SetParentalRating(pEvent->ParentalRating()); newEvent->SetVps (pEvent->Vps()); newEvent->SetTitle (pEvent->Title ()); newEvent->SetShortText (pEvent->ShortText ()); newEvent->SetDescription (pEvent->Description ()); -// newEvent->SetComponents (pEvent->Components()); +// newEvent->SetComponents (pEvent->Components()); newEvent->FixEpgBugs (); pSchedule->AddEvent(newEvent); @@ -2964,7 +2964,7 @@ void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEven } cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool isEITPid, bool OnlyRunningStatus) - : SI::EIT (Data, false) +: SI::EIT (Data, false) { //LogD(2, prep("cEIT2::cEIT2")); if (Tid > 0 && (Format == DISH_BEV || (SetupPE->ProcessEIT && isEITPid))) Tid--; @@ -3052,7 +3052,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat int LanguagePreferenceShort = -1; SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d; if (I18nIsPreferredLanguage (Setup.EPGLanguages, sed->languageCode, LanguagePreferenceShort) - || !ShortEventDescriptor) { + || !ShortEventDescriptor) { delete ShortEventDescriptor; ShortEventDescriptor = sed; d = NULL; // so that it is not deleted @@ -3062,7 +3062,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat bool UseExtendedEventDescriptor = false; SI::ExtendedEventDescriptor * eed = (SI::ExtendedEventDescriptor *) d; if (I18nIsPreferredLanguage (Setup.EPGLanguages, eed->languageCode, LanguagePreferenceExt) - || !ExtendedEventDescriptors) { + || !ExtendedEventDescriptors) { delete ExtendedEventDescriptors; ExtendedEventDescriptors = new SI::ExtendedEventDescriptors; UseExtendedEventDescriptor = true; @@ -3168,7 +3168,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat case SI::ExtendedEventDescriptorTag: { SI::ExtendedEventDescriptor * eed = (SI::ExtendedEventDescriptor *) d; if (I18nIsPreferredLanguage (Setup.EPGLanguages, eed->languageCode, LanguagePreferenceExt) - || !ExtendedEventDescriptors) { + || !ExtendedEventDescriptors) { delete ExtendedEventDescriptors; ExtendedEventDescriptors = new SI::ExtendedEventDescriptors; UseExtendedEventDescriptor = true; @@ -3184,7 +3184,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat case SI::ShortEventDescriptorTag: { SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d; if (I18nIsPreferredLanguage (Setup.EPGLanguages, sed->languageCode, LanguagePreferenceShort) - || !ShortEventDescriptor) { + || !ShortEventDescriptor) { delete ShortEventDescriptor; ShortEventDescriptor = sed; d = NULL; // so that it is not deleted @@ -3221,7 +3221,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat if (I18nIsPreferredLanguage(Setup.EPGLanguages, Rating.languageCode, LanguagePreferenceRating)) { int ParentalRating = (Rating.getRating() & 0xFF); switch (ParentalRating) { - // values defined by the DVB standard (minimum age = rating + 3 years): + // values defined by the DVB standard (minimum age = rating + 3 years): case 0x01 ... 0x0F: ParentalRating += 3; break; @@ -3284,7 +3284,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat if (ld->getLinkageType () == 0xB0) { // Premiere World time_t now = time (NULL); bool hit = SiEitEvent.getStartTime () <= now - && now < SiEitEvent.getStartTime () + SiEitEvent.getDuration (); + && now < SiEitEvent.getStartTime () + SiEitEvent.getDuration (); if (hit) { char linkName[ld->privateData.getLength () + 1]; strn0cpy (linkName, (const char *) ld->privateData.getData (), sizeof (linkName)); @@ -3301,7 +3301,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat transponder = Channels.GetByTransponderID (linkID); link = Channels.NewChannel (transponder, linkName, "", "", ld->getOriginalNetworkId (), - ld->getTransportStreamId (), ld->getServiceId ()); + ld->getTransportStreamId (), ld->getServiceId ()); } if (link) { if (!LinkChannels) @@ -3324,15 +3324,15 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat Components = new cComponents; char buffer[Utf8BufSize (256)]; Components->SetComponent (Components->NumComponents (), Stream, Type, - I18nNormalizeLanguageCode (cd->languageCode), - cd->description.getText (buffer, sizeof (buffer))); + I18nNormalizeLanguageCode (cd->languageCode), + cd->description.getText (buffer, sizeof (buffer))); } } break; case SI::DishExtendedEventDescriptorTag: { SI::UnimplementedDescriptor *deed = (SI::UnimplementedDescriptor *)d; if (!DishEventDescriptor) { - DishEventDescriptor = new SI::DishDescriptor(); + DishEventDescriptor = new SI::DishDescriptor(); } DishEventDescriptor->setExtendedtData(Tid+1, deed->getData()); HasExternalData = true; @@ -3341,7 +3341,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat case SI::DishShortEventDescriptorTag: { SI::UnimplementedDescriptor *dsed = (SI::UnimplementedDescriptor *)d; if (!DishEventDescriptor) { - DishEventDescriptor = new SI::DishDescriptor(); + DishEventDescriptor = new SI::DishDescriptor(); } DishEventDescriptor->setShortData(Tid+1, dsed->getData()); HasExternalData = true; @@ -3356,7 +3356,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat DishEventDescriptor->setRating(rating); } } - break; + break; case SI::DishSeriesDescriptorTag: { if (d->getLength() == 10) { //LogD(2, prep("DishSeriesDescriptorTag: %s)"), (const char*) d->getData().getData()); @@ -3369,7 +3369,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat // LogD(2, prep("DishSeriesDescriptorTag length: %d)"), d->getLength()); // } } - break; + break; default: break; } @@ -3409,59 +3409,59 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat pEvent->SetDescription (NULL); if (DishEventDescriptor) { - if (DishEventDescriptor->getName()) - pEvent->SetTitle(DishEventDescriptor->getName()); - //LogD(2, prep("channelID: %s DishTitle: %s"), *channel->GetChannelID().ToString(), DishShortEventDescriptor->getText()); -// pEvent->SetDescription(DishExtendedEventDescriptor->getText()); - char *tmp; - string fmt; - fmt = "%s"; - if (0 != strcmp(DishEventDescriptor->getShortText(),"") && DishEventDescriptor->hasTheme()) { - fmt += " - "; - } - fmt += "%s"; - if (DishEventDescriptor->hasTheme() && DishEventDescriptor->hasCategory()) { - fmt += " ~ "; - } - fmt += "%s"; - - Asprintf (&tmp, fmt.c_str(), DishEventDescriptor->getShortText() - , DishEventDescriptor->getTheme() - , DishEventDescriptor->getCategory()); - pEvent->SetShortText(tmp); - //LogD(2, prep("EEPGDEBUG:DishTheme:%x-DishCategory:%x)"), DishTheme, DishCategory); - free(tmp); - - fmt = "%s"; - if (0 != strcmp(DishEventDescriptor->getDescription(),"") - && (0 != strcmp(DishEventDescriptor->getRating(),"") - || 0 != strcmp(DishEventDescriptor->getStarRating(),""))) { - fmt += "\n\nRating: "; - } - fmt += "%s %s"; - if (0 != strcmp(DishEventDescriptor->getProgramId(),"")) { - fmt += "\n\nProgram ID: "; - } - fmt += "%s %s%s"; - time_t orgAirDate = DishEventDescriptor->getOriginalAirDate(); - char datestr [80]; - bool dateok = false; - if (orgAirDate == 0) { - dateok = strftime (datestr,80," Original Air Date: %a %b %d %Y",gmtime(&orgAirDate)) > 0; - } - - Asprintf (&tmp, fmt.c_str(), DishEventDescriptor->getDescription() - , DishEventDescriptor->getRating() - , DishEventDescriptor->getStarRating() - , DishEventDescriptor->getProgramId() - , DishEventDescriptor->getSeriesId() - , orgAirDate == 0 || !dateok ? "" : datestr); - pEvent->SetDescription(tmp); - free(tmp); - - - //LogD(2, prep("DishDescription: %s"), DishExtendedEventDescriptor->getText()); - //LogD(2, prep("DishShortText: %s"), DishExtendedEventDescriptor->getShortText()); + if (DishEventDescriptor->getName()) + pEvent->SetTitle(DishEventDescriptor->getName()); + //LogD(2, prep("channelID: %s DishTitle: %s"), *channel->GetChannelID().ToString(), DishShortEventDescriptor->getText()); + // pEvent->SetDescription(DishExtendedEventDescriptor->getText()); + char *tmp; + string fmt; + fmt = "%s"; + if (0 != strcmp(DishEventDescriptor->getShortText(),"") && DishEventDescriptor->hasTheme()) { + fmt += " - "; + } + fmt += "%s"; + if (DishEventDescriptor->hasTheme() && DishEventDescriptor->hasCategory()) { + fmt += " ~ "; + } + fmt += "%s"; + + Asprintf (&tmp, fmt.c_str(), DishEventDescriptor->getShortText() + , DishEventDescriptor->getTheme() + , DishEventDescriptor->getCategory()); + pEvent->SetShortText(tmp); + //LogD(2, prep("EEPGDEBUG:DishTheme:%x-DishCategory:%x)"), DishTheme, DishCategory); + free(tmp); + + fmt = "%s"; + if (0 != strcmp(DishEventDescriptor->getDescription(),"") + && (0 != strcmp(DishEventDescriptor->getRating(),"") + || 0 != strcmp(DishEventDescriptor->getStarRating(),""))) { + fmt += "\n\nRating: "; + } + fmt += "%s %s"; + if (0 != strcmp(DishEventDescriptor->getProgramId(),"")) { + fmt += "\n\nProgram ID: "; + } + fmt += "%s %s%s"; + time_t orgAirDate = DishEventDescriptor->getOriginalAirDate(); + char datestr [80]; + bool dateok = false; + if (orgAirDate == 0) { + dateok = strftime (datestr,80," Original Air Date: %a %b %d %Y",gmtime(&orgAirDate)) > 0; + } + + Asprintf (&tmp, fmt.c_str(), DishEventDescriptor->getDescription() + , DishEventDescriptor->getRating() + , DishEventDescriptor->getStarRating() + , DishEventDescriptor->getProgramId() + , DishEventDescriptor->getSeriesId() + , orgAirDate == 0 || !dateok ? "" : datestr); + pEvent->SetDescription(tmp); + free(tmp); + + + //LogD(2, prep("DishDescription: %s"), DishExtendedEventDescriptor->getText()); + //LogD(2, prep("DishShortText: %s"), DishExtendedEventDescriptor->getShortText()); } } @@ -3525,7 +3525,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat if (pPreviousEvent->Description ()) len_title_extern = snprintf (buffer_title_extern, sizeof (buffer_title_extern) - 1, "%s", - pPreviousEvent->Description ()); + pPreviousEvent->Description ()); if (len_title_intern > 0) { if (len_title_extern < 1) pPreviousEvent->SetDescription (buffer_title_intern); @@ -3542,7 +3542,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat } } #endif /* DDEPGENTRY */ - updateEquivalent(Schedules, channel->GetChannelID(), pEvent); + updateEquivalent(Schedules, channel->GetChannelID(), pEvent); } if (Empty && Tid == 0x4E && getSectionNumber () == 0) // ETR 211: an empty entry in section 0 of table 0x4E means there is currently no event running @@ -3612,9 +3612,9 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) // Enable EIT scan for all except DISH_BEV since it is already enabled if (SetupPE->ProcessEIT && !UnprocessedFormat[EIT] - && !UnprocessedFormat[FREEVIEW] && !UnprocessedFormat[DISH_BEV]) { - UnprocessedFormat[EIT] = EIT_PID; - loadEquivalentChannelMap(); + && !UnprocessedFormat[FREEVIEW] && !UnprocessedFormat[DISH_BEV]) { + UnprocessedFormat[EIT] = EIT_PID; + loadEquivalentChannelMap(); } //now start looking for next format to process @@ -3690,27 +3690,27 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) void cFilterEEPG::ProccessContinuous(u_short Pid, u_char Tid, int Length, const u_char *Data) { - //0x39 Viasat, 0x0300 Dish Network EEPG, 0x0441 Bell ExpressVU EEPG - LogD(4, prep("Pid: 0x%02x Tid: %d Length: %d"), Pid, Tid, Length); - cSchedulesLock SchedulesLock(true, 10); + //0x39 Viasat, 0x0300 Dish Network EEPG, 0x0441 Bell ExpressVU EEPG + LogD(4, prep("Pid: 0x%02x Tid: %d Length: %d"), Pid, Tid, Length); + cSchedulesLock SchedulesLock(true, 10); + cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); + //Look for other satelite positions only if Dish/Bell ExpressVU for the moment hardcoded pid check + if(Schedules) + SI::cEIT2 EIT(Schedules, Source(), Tid, Data, Pid == EIT_PID); + + else//cEIT EIT (Schedules, Source (), Tid, Data); + { + // If we don't get a write lock, let's at least get a read lock, so + // that we can set the running status and 'seen' timestamp (well, actually + // with a read lock we shouldn't be doing that, but it's only integers that + // get changed, so it should be ok) + cSchedulesLock SchedulesLock; cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); - //Look for other satelite positions only if Dish/Bell ExpressVU for the moment hardcoded pid check if(Schedules) - SI::cEIT2 EIT(Schedules, Source(), Tid, Data, Pid == EIT_PID); + SI::cEIT2 EIT(Schedules, Source(), Tid, Data, Pid == EIT_PID, true); - else//cEIT EIT (Schedules, Source (), Tid, Data); - { - // If we don't get a write lock, let's at least get a read lock, so - // that we can set the running status and 'seen' timestamp (well, actually - // with a read lock we shouldn't be doing that, but it's only integers that - // get changed, so it should be ok) - cSchedulesLock SchedulesLock; - cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); - if(Schedules) - SI::cEIT2 EIT(Schedules, Source(), Tid, Data, Pid == EIT_PID, true); - - //cEIT EIT (Schedules, Source (), Tid, Data, true); - } + //cEIT EIT (Schedules, Source (), Tid, Data, true); + } } void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Length) @@ -3773,7 +3773,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len } //Format = 0; // 0 = premiere, 1 = MHW1, 2 = MHW2, 3 = Sky Italy (OpenTV), 4 = Sky UK (OpenTV), 5 = Freesat (Freeview), 6 = Nagraguide SI::Descriptor * d; - unsigned char nDescriptorTag; + unsigned char nDescriptorTag; for (SI::Loop::Iterator it; (d = stream.streamDescriptors.getNext (it));) { LogD(4, prep("EEPGDEBUG:d->getDescriptorTAG():%x,SI::PrivateTag:%x\n"), d->getDescriptorTag (), SI::PrivateDataSpecifierDescriptorTag); nDescriptorTag = d->getDescriptorTag (); @@ -3850,7 +3850,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len if (((Source() == cSource::FromString("S119.0W") && Transponder() == cChannel::Transponder(12472,'H')) || (Source() == cSource::FromString("S91.0W") - && Transponder() == cChannel::Transponder(12224,'R'))) + && Transponder() == cChannel::Transponder(12224,'R'))) && !UnprocessedFormat[DISH_BEV]) { UnprocessedFormat[DISH_BEV] = stream.getPid (); } @@ -4131,7 +4131,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) { time_t firstTime = 0; SI::Descriptor * d; - unsigned char nDescriptorTag; + unsigned char nDescriptorTag; bool UseExtendedEventDescriptor = false; int LanguagePreferenceShort = -1; int LanguagePreferenceExt = -1; @@ -4197,7 +4197,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) case SI::ExtendedEventDescriptorTag: { SI::ExtendedEventDescriptor * eed = (SI::ExtendedEventDescriptor *) d; if (I18nIsPreferredLanguage (Setup.EPGLanguages, eed->languageCode, LanguagePreferenceExt) - || !ExtendedEventDescriptors) { + || !ExtendedEventDescriptors) { delete ExtendedEventDescriptors; ExtendedEventDescriptors = new SI::ExtendedEventDescriptors; UseExtendedEventDescriptor = true; @@ -4213,7 +4213,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) case SI::ShortEventDescriptorTag: { SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d; if (I18nIsPreferredLanguage (Setup.EPGLanguages, sed->languageCode, LanguagePreferenceShort) - || !ShortEventDescriptor) { + || !ShortEventDescriptor) { delete ShortEventDescriptor; ShortEventDescriptor = sed; d = NULL; // so that it is not deleted @@ -4234,10 +4234,10 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) crc[0] = cit.getContentId (); SI::PremiereContentTransmissionDescriptor * pct; for (SI::Loop::Iterator it; - (pct = - (SI::PremiereContentTransmissionDescriptor *) cit.eventDescriptors.getNext (it, - SI:: - PremiereContentTransmissionDescriptorTag));) { + (pct = + (SI::PremiereContentTransmissionDescriptor *) cit.eventDescriptors.getNext (it, + SI:: + PremiereContentTransmissionDescriptorTag));) { int nid = pct->getOriginalNetworkId (); int tid = pct->getTransportStreamId (); int sid = pct->getServiceId (); @@ -4287,12 +4287,10 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) for (SI::Loop::Iterator it2; sd.startTimeLoop.getNext (st, it2);) { time_t StartTime = st.getStartTime (mjd); time_t EndTime = StartTime + cit.getDuration (); - int runningStatus = (StartTime < now - && now < EndTime) ? SI::RunningStatusRunning : ((StartTime - 30 < now - && now < - StartTime) ? SI:: - RunningStatusStartsInAFewSeconds - : SI::RunningStatusNotRunning); + int runningStatus = + (StartTime < now && now < EndTime) ? SI::RunningStatusRunning : + ((StartTime - 30 < now && now < StartTime) ? + SI::RunningStatusStartsInAFewSeconds : SI::RunningStatusNotRunning); bool isOpt = false; if (index++ == 0 && nCount > 1) isOpt = true; @@ -4348,7 +4346,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) } if (order || rating) { int len = (pEvent->Description ()? strlen (pEvent->Description ()) : 0) + - (order ? strlen (order) : 0) + (rating ? strlen (rating) : 0); + (order ? strlen (order) : 0) + (rating ? strlen (rating) : 0); char buffer[len + 32]; buffer[0] = 0; if (pEvent->Description ()) @@ -4521,10 +4519,10 @@ void cPluginEEPG::Stop (void) free (ConfDir); } if (sky_tables[0]) { - free(sky_tables[0]); + free(sky_tables[0]); } if (sky_tables[1]) { - free(sky_tables[1]); + free(sky_tables[1]); } } -- cgit v1.2.3 From 3a1c661a2573115e965161f78688c633a92dd10b Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Thu, 17 May 2012 14:15:55 +0200 Subject: removed EIT filter for NA since it should be done by epg-handler modified indentation --- eepg.c | 2 + epghandler.c | 132 +++++++++++++++++++++++++++++------------------------------ epghandler.h | 38 ++++++++--------- 3 files changed, 87 insertions(+), 85 deletions(-) diff --git a/eepg.c b/eepg.c index 80ad23f..fac41e5 100644 --- a/eepg.c +++ b/eepg.c @@ -3672,7 +3672,9 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) AddFilter (pid, 0xb0); //perhaps TID is equal to first data byte? break; case DISH_BEV: +#if APIVERSNUM < 10726 AddFilter (EIT_PID, 0, 0); // event info, actual(0x4e)/other(0x4f) TS, present/following +#endif AddFilter (0x0300, 0, 0); // Dish Network EEPG event info, actual(0x4e)/other(0x4f) TS, present/following AddFilter (0x0441, 0, 0); // Dish Network EEPG event info, actual(0x4e)/other(0x4f) TS, present/following // AddFilter (0x0441, 0x50, 0xf0); // Bell ExpressVU EEPG diff --git a/epghandler.c b/epghandler.c index 36aaf74..29f092b 100644 --- a/epghandler.c +++ b/epghandler.c @@ -5,122 +5,122 @@ * Author: d.petrovski */ -#if APIVERSNUM > 10725 #include "epghandler.h" +#if APIVERSNUM > 10725 #include "log.h" cEEpgHandler::cEEpgHandler() { - // TODO Auto-generated constructor stub - LogD(4, prep("cEEpgHandler()")); + // TODO Auto-generated constructor stub + LogD(4, prep("cEEpgHandler()")); } cEEpgHandler::~cEEpgHandler() { - // TODO Auto-generated destructor stub + // TODO Auto-generated destructor stub } bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, - const SI::EIT::Event* EitEvent, uchar TableID, uchar Version) { - //LogD(1, prep("HandleEitEvent")); - return false; -// return true; + const SI::EIT::Event* EitEvent, uchar TableID, uchar Version) { + //LogD(1, prep("HandleEitEvent")); + return false; + // return true; } bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) { - Event->SetEventID(EventID); - return true; + Event->SetEventID(EventID); + return true; } bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { - LogD(3, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title); + LogD(3, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title); - if (!Event->Title() || Title && (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title)))) - Event->SetTitle(Title); - return true; + if (!Event->Title() || Title && (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title)))) + Event->SetTitle(Title); + return true; } bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) { - LogD(3, prep("Event id:%d ShortText:%s new ShortText:%s"), Event->EventID(), Event->ShortText(), ShortText); - - if (Event->ShortText() && strcmp(Event->ShortText(),"") != 0) { - origShortText = std::string(Event->ShortText()); - } - else { - origShortText.clear(); - } - - //if (!Event->ShortText() || ShortText && (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText)))) - Event->SetShortText(ShortText); - return true; + LogD(3, prep("Event id:%d ShortText:%s new ShortText:%s"), Event->EventID(), Event->ShortText(), ShortText); + + if (Event->ShortText() && strcmp(Event->ShortText(),"") != 0) { + origShortText = std::string(Event->ShortText()); + } + else { + origShortText.clear(); + } + + //if (!Event->ShortText() || ShortText && (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText)))) + Event->SetShortText(ShortText); + return true; } bool cEEpgHandler::SetDescription(cEvent* Event, const char* Description) { - LogD(3, prep("Event id:%d Description:%s new Description:%s"), Event->EventID(), Event->Description(), Description); - - if (Event->Description() && strcmp(Event->Description(),"") != 0) - origDescription = Event->Description(); - else - origDescription.clear(); - - //if (!Event->Description() || Description && (!strcmp(Event->Description(),"") || (strcmp(Description,"") && strcmp(Event->Description(),Description)))) - Event->SetDescription(Description); - return true; + LogD(3, prep("Event id:%d Description:%s new Description:%s"), Event->EventID(), Event->Description(), Description); + + if (Event->Description() && strcmp(Event->Description(),"") != 0) + origDescription = Event->Description(); + else + origDescription.clear(); + + //if (!Event->Description() || Description && (!strcmp(Event->Description(),"") || (strcmp(Description,"") && strcmp(Event->Description(),Description)))) + Event->SetDescription(Description); + return true; } bool cEEpgHandler::SetContents(cEvent* Event, uchar* Contents) { - Event->SetContents(Contents); - return true; + Event->SetContents(Contents); + return true; } bool cEEpgHandler::SetParentalRating(cEvent* Event, int ParentalRating) { - Event->SetParentalRating(ParentalRating); - return true; + Event->SetParentalRating(ParentalRating); + return true; } bool cEEpgHandler::SetStartTime(cEvent* Event, time_t StartTime) { - Event->SetStartTime(StartTime); - return true; + Event->SetStartTime(StartTime); + return true; } bool cEEpgHandler::SetDuration(cEvent* Event, int Duration) { - Event->SetDuration(Duration); - return true; + Event->SetDuration(Duration); + return true; } bool cEEpgHandler::SetVps(cEvent* Event, time_t Vps) { - Event->SetVps(Vps); - return true; + Event->SetVps(Vps); + return true; } bool cEEpgHandler::HandleEvent(cEvent* Event) { - - LogD(3, prep("HandleEvent st:%s ost:%s desc:%s odesc:%s"),Event->ShortText(),origShortText.c_str(),Event->Description(),origDescription.c_str()); - - //After FixEpgBugs of cEvent set the original Short Text if empty - if (!Event->ShortText() || !strcmp(Event->ShortText(),"")) - Event->SetShortText(origShortText.c_str()); - - if (!Event->Description() && !origDescription.empty()) { - Event->SetDescription(origDescription.c_str()); - } - //TODO just to see the difference - //else if (!origDescription.empty() && !origDescription.compare(Event->Description())) { -// origDescription.append(" | EIT: "); -// origDescription.append(Event->Description()); -// Event->SetDescription(origDescription.c_str()); + + LogD(3, prep("HandleEvent st:%s ost:%s desc:%s odesc:%s"),Event->ShortText(),origShortText.c_str(),Event->Description(),origDescription.c_str()); + + //After FixEpgBugs of cEvent set the original Short Text if empty + if (!Event->ShortText() || !strcmp(Event->ShortText(),"")) + Event->SetShortText(origShortText.c_str()); + + if (!Event->Description() && !origDescription.empty()) { + Event->SetDescription(origDescription.c_str()); + } + //TODO just to see the difference + //else if (!origDescription.empty() && !origDescription.compare(Event->Description())) { + // origDescription.append(" | EIT: "); + // origDescription.append(Event->Description()); + // Event->SetDescription(origDescription.c_str()); // } - return true; + return true; } bool cEEpgHandler::SortSchedule(cSchedule* Schedule) { - Schedule->Sort(); - return true; + Schedule->Sort(); + return true; } bool cEEpgHandler::DropOutdated(cSchedule* Schedule, time_t SegmentStart, - time_t SegmentEnd, uchar TableID, uchar Version) { - return false; + time_t SegmentEnd, uchar TableID, uchar Version) { + return false; } #endif diff --git a/epghandler.h b/epghandler.h index 8d3615a..16dbca3 100644 --- a/epghandler.h +++ b/epghandler.h @@ -13,27 +13,27 @@ class cEEpgHandler : public cEpgHandler { public: - cEEpgHandler(); - virtual ~cEEpgHandler(); - virtual bool IgnoreChannel(const cChannel *Channel) { return false; } - virtual bool HandleEitEvent(cSchedule *Schedule, const SI::EIT::Event *EitEvent, uchar TableID, uchar Version); - virtual bool SetEventID(cEvent *Event, tEventID EventID); - virtual bool SetTitle(cEvent *Event, const char *Title); - virtual bool SetShortText(cEvent *Event, const char *ShortText); - virtual bool SetDescription(cEvent *Event, const char *Description); - virtual bool SetContents(cEvent *Event, uchar *Contents); - virtual bool SetParentalRating(cEvent *Event, int ParentalRating); - virtual bool SetStartTime(cEvent *Event, time_t StartTime); - virtual bool SetDuration(cEvent *Event, int Duration); - virtual bool SetVps(cEvent *Event, time_t Vps); - virtual bool FixEpgBugs(cEvent *Event) { return false; } - virtual bool HandleEvent(cEvent *Event); - virtual bool SortSchedule(cSchedule *Schedule); - virtual bool DropOutdated(cSchedule *Schedule, time_t SegmentStart, time_t SegmentEnd, uchar TableID, uchar Version); + cEEpgHandler(); + virtual ~cEEpgHandler(); + virtual bool IgnoreChannel(const cChannel *Channel) { return false; } + virtual bool HandleEitEvent(cSchedule *Schedule, const SI::EIT::Event *EitEvent, uchar TableID, uchar Version); + virtual bool SetEventID(cEvent *Event, tEventID EventID); + virtual bool SetTitle(cEvent *Event, const char *Title); + virtual bool SetShortText(cEvent *Event, const char *ShortText); + virtual bool SetDescription(cEvent *Event, const char *Description); + virtual bool SetContents(cEvent *Event, uchar *Contents); + virtual bool SetParentalRating(cEvent *Event, int ParentalRating); + virtual bool SetStartTime(cEvent *Event, time_t StartTime); + virtual bool SetDuration(cEvent *Event, int Duration); + virtual bool SetVps(cEvent *Event, time_t Vps); + virtual bool FixEpgBugs(cEvent *Event) { return false; } + virtual bool HandleEvent(cEvent *Event); + virtual bool SortSchedule(cSchedule *Schedule); + virtual bool DropOutdated(cSchedule *Schedule, time_t SegmentStart, time_t SegmentEnd, uchar TableID, uchar Version); private: - std::string origShortText; - std::string origDescription; + std::string origShortText; + std::string origDescription; }; #endif /*APIVERSNUM > 10725*/ -- cgit v1.2.3 From 6c2887ff73678a872d6588a48c87476ab670d7e6 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Thu, 17 May 2012 20:36:31 +0200 Subject: added include for APIVERSNUM --- eepg.c | 2 ++ epghandler.c | 2 +- epghandler.h | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/eepg.c b/eepg.c index 4bfd5d7..de411c9 100644 --- a/eepg.c +++ b/eepg.c @@ -38,7 +38,9 @@ #include #include "eepg.h" #include "dish.h" +#if APIVERSNUM > 10725 #include "epghandler.h" +#endif #include "log.h" #include "setupeepg.h" diff --git a/epghandler.c b/epghandler.c index 36aaf74..515ae6c 100644 --- a/epghandler.c +++ b/epghandler.c @@ -5,8 +5,8 @@ * Author: d.petrovski */ -#if APIVERSNUM > 10725 #include "epghandler.h" +#if APIVERSNUM > 10725 #include "log.h" cEEpgHandler::cEEpgHandler() { diff --git a/epghandler.h b/epghandler.h index 8d3615a..07862ce 100644 --- a/epghandler.h +++ b/epghandler.h @@ -7,6 +7,7 @@ #ifndef CEEPGHANDLER_H_ #define CEEPGHANDLER_H_ +#include #if APIVERSNUM > 10725 #include #include -- cgit v1.2.3 From bcd0b697d5953b286878542fb4c33238d65c6cb2 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Fri, 18 May 2012 09:19:32 +0200 Subject: eepghandler for new vdr eit api --- Makefile | 2 +- eepg.c | 51 ++++++++++++++++++++--------------- epghandler.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ epghandler.h | 33 +++++++++++++++++++++++ 4 files changed, 150 insertions(+), 22 deletions(-) create mode 100644 epghandler.c create mode 100644 epghandler.h diff --git a/Makefile b/Makefile index 19c0684..0bebc82 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"' ### The object files (add further files here): -OBJS = $(PLUGIN).o dish.o +OBJS = $(PLUGIN).o dish.o epghandler.o ifdef DBG CXXFLAGS += -g diff --git a/eepg.c b/eepg.c index b478870..7aa3fe0 100644 --- a/eepg.c +++ b/eepg.c @@ -38,6 +38,7 @@ #include #include "eepg.h" #include "dish.h" +#include "epghandler.h" #include #include @@ -1211,7 +1212,7 @@ void cFilterEEPG::LoadEquivalentChannels (void) } else { cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); if (!OriginalChannel) - LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalency is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? + LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalence is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) != 5) { @@ -1331,7 +1332,7 @@ int cFilterEEPG::GetChannelsMHW (const u_char * Data, int Length, int MHW) } //else nChannels > MAX_CHANNELS LoadEquivalentChannels (); GetLocalTimeOffset (); //reread timing variables, only used for MHW - return 2; //obviously, when you get here, channels are read succesfully, but since all channels are sent at once, you can stop now + return 2; //obviously, when you get here, channels are read successfully, but since all channels are sent at once, you can stop now } //if nChannels == 0 LogE (0, prep("Warning: Trying to read Channels more than once!")); //you will only get here when GetChannelsMHW is called, and nChannels !=0, e.g. when multiple citpids cause channels to be read multiple times. Second time, do nothing, give error so that the rest of the chain is not restarted also. @@ -1578,15 +1579,25 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse p += 29; //skip fixed part of block if (SD->NumberOfBlocks == 1) - p -= 4; //in this case there is NO summarytext AND no GBR??!! + p -= 4; //in this case there is NO summary text AND no GBR??!! for (int i = 1; i < (SD->NumberOfBlocks - 1); i++) { - LogD(3, prep("DEBUG: Extra Blockinfo: %02x %02x %02x %02x."), *p, *(p + 1), *(p + 2), *(p + 3)); - p += 4; //skip this extra blockinfo + LogD(3, prep("DEBUG: Extra Block info: %02x %02x %02x %02x."), *p, *(p + 1), *(p + 2), *(p + 3)); + p += 4; //skip this extra block info } return (char *) Text; } -void cFilterEEPG::PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]) //gets a channel and returns an array of schedules that WriteToSchedule can write to. Call this routine before a batch of titles with the same ChannelId will be WriteToScheduled; batchsize can be 1 +/** + * \brief Prepare to Write to Schedule + * + * gets a channel and returns an array of schedules that WriteToSchedule can write to. + * Call this routine before a batch of titles with the same ChannelId will be WriteToScheduled; batchsize can be 1 + * + * \param C channel to prepare + * \param s VDR epg schedules + * \param ps pointer to the schedules that WriteToSchedule can write to + */ +void cFilterEEPG::PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]) { for (int eq = 0; eq < C->NumberOfEquivalences; eq++) { tChannelID channelID = tChannelID (C->Src[eq], C->Nid[eq], C->Tid[eq], C->Sid[eq]); @@ -1598,7 +1609,7 @@ void cFilterEEPG::PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSched ps[eq] = s->AddSchedule (channelID); //open a a schedule for each equivalent channel else { ps[eq] = NULL; - LogE(5, prep("ERROR: Titleblock has invalid (equivalent) channel ID: Equivalence: %i, Source:%x, C->Nid:%x,C->Tid:%x,C->Sid:%x."), + LogE(5, prep("ERROR: Title block has invalid (equivalent) channel ID: Equivalence: %i, Source:%x, C->Nid:%x,C->Tid:%x,C->Sid:%x."), eq, C->Src[eq], C->Nid[eq], C->Tid[eq], C->Sid[eq]); } } @@ -1722,13 +1733,13 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor LogD(3, prep("DEBUG: ChannelId %04x, Blocklength %04x, NumberOfTitles %lu."), ChannelId, Blocklength, NumberOfTitles); - p += 4; //skip ChannelId and Blocklength + p += 4; //skip ChannelId and Block length next_p = p + Blocklength; if (next_p > DataEnd) { //only process if block is complete LogE(0, prep("ERROR, Block exceeds end of Data. p:%p, Blocklength:%x,DataEnd:%p."), p, Blocklength, DataEnd); return; //fatal error, this should never happen } - p += 4; //skip Titlenumber + p += 4; //skip Title number sChannel *C = &sChannels[ChannelSeq[ChannelId]]; //find channel cSchedule *ps[MAX_EQUIVALENCES]; @@ -1747,7 +1758,7 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor tmCurrent->tm_mon = CurrentMonth; tmCurrent->tm_mday = MonthdayTitles; tmCurrent->tm_hour = 0; - tmCurrent->tm_min = StartTime; //if starttime is bigger than 1 hour, mktime will correct this! + tmCurrent->tm_min = StartTime; //if start time is bigger than 1 hour, mktime will correct this! tmCurrent->tm_sec = 0; tmCurrent->tm_isdst = -1; //now correct with daylight savings if (MonthdayTitles < CurrentMonthday - 7) //the titles that are older than one week are not from the past, but from next month! @@ -1775,7 +1786,7 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor else SummText = GetSummaryTextNagra (DataStartSummaries, HILO32 (Title->SumDataOffset), EventId); - LogD(3, prep("DEBUG: Eventid: %08x ChannelId:%x, Starttime %02i:%02i, Duration %i, OffsetToText:%08x, OffsetToText2:%08x, SumDataOffset:%08x ThemeId:%x Title:%s \n SummaryText:%s"), + LogD(3, prep("DEBUG: Eventid: %08x ChannelId:%x, Start time %02i:%02i, Duration %i, OffsetToText:%08x, OffsetToText2:%08x, SumDataOffset:%08x ThemeId:%x Title:%s \n SummaryText:%s"), EventId, ChannelId, Hours, Minutes, Title->Duration, HILO32 (Title->OffsetToText), HILO32 (Title->OffsetToText2), HILO32 (Title->SumDataOffset), Title->ThemeId, Text, SummText); @@ -1935,7 +1946,7 @@ int cFilterEEPG::GetChannelsNagra (const u_char * Data, int Length) sChannelsNagraGuide *Channel = (sChannelsNagraGuide *) p; sChannel *C = &sChannels[j]; C->ChannelId = j + 1; //Nagra starts numbering at 1 - ChannelSeq[C->ChannelId] = j; //fill lookup table to go from channel-id to sequence nr in table; lookuptable starts with 0 + ChannelSeq[C->ChannelId] = j; //fill lookup table to go from channel-id to sequence nr in table; lookup table starts with 0 C->SkyNumber = 0; C->NumberOfEquivalences = 1; //there is always an original channel. every equivalence adds 1 C->Src[0] = Source(); //assume all EPG channels are on same satellite, if not, manage this via equivalents!!! @@ -2126,11 +2137,11 @@ void cFilterEEPG::ProcessNagra () NumberOfTables--; } - for (int i = 0; i < NagraCounter; i++) { //first prcoess all themes, since they all use the same codes + for (int i = 0; i < NagraCounter; i++) { //first process all themes, since they all use the same codes unsigned short int TableIdExtension = NagraTIE[i]; int TIE = TableIdExtension - 0x0200; //from 0x0400 to 0x0200 -> titles LogI(0, prep("Processing TableIdExtension:%04x"), TableIdExtension); - GetTitlesNagra (buffer[TIE] + 4, bufsize[TIE] - 4, TableIdExtension); //assume title-reading is completed //TODO Language code terminatd by 0 is ignored + GetTitlesNagra (buffer[TIE] + 4, bufsize[TIE] - 4, TableIdExtension); //assume title-reading is completed //TODO Language code terminated by 0 is ignored free (buffer[TIE]); buffer[TIE] = NULL; NumberOfTables--; @@ -2155,7 +2166,7 @@ int cFilterEEPG::GetTitlesMHW1 (const u_char * Data, int Length) sTitleMHW1 *Title = (sTitleMHW1 *) Data; if (Title->ChannelId == 0xff) { //FF is separator packet if (memcmp (InitialTitle, Data, 46) == 0) { //data is the same as initial title //TODO use easier notation - LogD(2, prep("End procesing titles")); + LogD(2, prep("End processing titles")); return 2; } if (nTitles == 0) @@ -2753,7 +2764,7 @@ void cFilterEEPG::FreeSummaries (void) S = Summaries[i]; if (i < nSummaries - 1) { S2 = Summaries[i + 1]; //look at next summary - if (S->Text != S2->Text && S->Text != 0x00) //this is the last summary that points to this textblock; needed in case NumReplays > 1, multiple pointers to same textblock + if (S->Text != S2->Text && S->Text != 0x00) //this is the last summary that points to this text block; needed in case NumReplays > 1, multiple pointers to same textblock free (S->Text); } else if (S->Text != 0x00) free (S->Text); @@ -3094,13 +3105,11 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat pEvent = newEvent = new cEvent (SiEitEvent.getEventId ()); if (!pEvent) continue; - //updateEquivalent(Schedules, channel->GetChannelID(), pEvent); } else { //LogD(3, prep("existing event channelID: %s Title: %s TableID 0x%02X new TID 0x%02X Version %i, new version %i"), *channel->GetChannelID().ToString(), pEvent->Title(), pEvent->TableID(), Tid, pEvent->Version(), versionNumber); // We have found an existing event, either through its event ID or its start time. pEvent->SetSeen (); - //updateEquivalent(Schedules, channel->GetChannelID(), pEvent); // If the existing event has a zero table ID it was defined externally and shall // not be overwritten. if (pEvent->TableID () == 0x00) { @@ -3460,7 +3469,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat pEvent->SetTitle (buffer); LogD(3, prep("channelID: %s Title: %s"), *channel->GetChannelID().ToString(), pEvent->Title()); l = ShortEventDescriptor->text.getLength(); - if (l > 0) { //Set the Short Text only if ther is data so that we do not overwrite valid data + if (l > 0) { //Set the Short Text only if there is data so that we do not overwrite valid data f = (unsigned char *) ShortEventDescriptor->text.getData().getData(); decodeText2 (f, l, buffer, sizeof (buffer)); //ShortEventDescriptor->text.getText(buffer, sizeof(buffer)); @@ -3720,8 +3729,7 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) EndThemes = false; switch (Format) { case PREMIERE: - if (!Matches (pid, 0xA0)) - Add (pid, 0xA0); + AddFilter (pid, 0xA0); break; case MHW1: AddFilter (0xd3, 0x92); //ThemesMHW1//TODO: all filters are serialized, strictly speaking Themes is non-fatal... @@ -4570,6 +4578,7 @@ bool cPluginEEPG::Start (void) for (int i = 0; i < NumberOfAvailableSources; i++) isyslog ("EEPG: Available sources:%s.", *cSource::ToString (AvailableSources[i])); + new cEEpgHandler(); return true; } diff --git a/epghandler.c b/epghandler.c new file mode 100644 index 0000000..51074ad --- /dev/null +++ b/epghandler.c @@ -0,0 +1,86 @@ +/* + * cEEpgHandler.c + * + * Created on: 11.3.2012 + * Author: d.petrovski + */ + +#include "epghandler.h" + +cEEpgHandler::cEEpgHandler() { + // TODO Auto-generated constructor stub + +} + +cEEpgHandler::~cEEpgHandler() { + // TODO Auto-generated destructor stub +} + +bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, + const SI::EIT::Event* EitEvent, uchar TableID, uchar Version) { + return true; +} + +bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) { + Event->SetEventID(EventID); + return true; +} + +bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { + if (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title))) + Event->SetTitle(Title); + return true; +} + +bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) { + if (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText))) + Event->SetShortText(ShortText); + return true; +} + +bool cEEpgHandler::SetDescription(cEvent* Event, const char* Description) { + if (!strcmp(Event->Description(),"") || (strcmp(Description,"") && strcmp(Event->Description(),Description))) + Event->SetDescription(Description); + return true; +} + +bool cEEpgHandler::SetContents(cEvent* Event, uchar* Contents) { + Event->SetContents(Contents); + return true; +} + +bool cEEpgHandler::SetParentalRating(cEvent* Event, int ParentalRating) { + Event->SetParentalRating(ParentalRating); + return true; +} + +bool cEEpgHandler::SetStartTime(cEvent* Event, time_t StartTime) { + Event->SetStartTime(StartTime); + return true; +} + +bool cEEpgHandler::SetDuration(cEvent* Event, int Duration) { + Event->SetDuration(Duration); + return true; +} + +bool cEEpgHandler::SetVps(cEvent* Event, time_t Vps) { + Event->SetVps(Vps); + return true; +} + +bool cEEpgHandler::HandleEvent(cEvent* Event) { + return true; +} + +bool cEEpgHandler::SortSchedule(cSchedule* Schedule) { + Schedule->Sort(); + return true; +} + +bool cEEpgHandler::DropOutdated(cSchedule* Schedule, time_t SegmentStart, + time_t SegmentEnd, uchar TableID, uchar Version) { + return false; +} + + diff --git a/epghandler.h b/epghandler.h new file mode 100644 index 0000000..1dee4f2 --- /dev/null +++ b/epghandler.h @@ -0,0 +1,33 @@ +/* + * cEEpgHandler.h + * + * Created on: 11.3.2012 + * Author: d.petrovski + */ + +#ifndef CEEPGHANDLER_H_ +#define CEEPGHANDLER_H_ +#include + +class cEEpgHandler : public cEpgDataReader { +public: + cEEpgHandler(); + virtual ~cEEpgHandler(); + virtual bool IgnoreChannel(const cChannel *Channel) { return false; } + virtual bool HandleEitEvent(cSchedule *Schedule, const SI::EIT::Event *EitEvent, uchar TableID, uchar Version); + virtual bool SetEventID(cEvent *Event, tEventID EventID); + virtual bool SetTitle(cEvent *Event, const char *Title); + virtual bool SetShortText(cEvent *Event, const char *ShortText); + virtual bool SetDescription(cEvent *Event, const char *Description); + virtual bool SetContents(cEvent *Event, uchar *Contents); + virtual bool SetParentalRating(cEvent *Event, int ParentalRating); + virtual bool SetStartTime(cEvent *Event, time_t StartTime); + virtual bool SetDuration(cEvent *Event, int Duration); + virtual bool SetVps(cEvent *Event, time_t Vps); + virtual bool FixEpgBugs(cEvent *Event) { return false; } + virtual bool HandleEvent(cEvent *Event); + virtual bool SortSchedule(cSchedule *Schedule); + virtual bool DropOutdated(cSchedule *Schedule, time_t SegmentStart, time_t SegmentEnd, uchar TableID, uchar Version); +}; + +#endif /* CEEPGHANDLER_H_ */ -- cgit v1.2.3 From 46f6510bb78a19f862bd3c1ffff6ac322ca6d6b4 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 8 May 2012 18:27:16 +0200 Subject: modified logging and added logging to epghandler.c --- eepg.c | 60 +---------------------------------------------- epghandler.c | 7 +++++- log.h | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 60 deletions(-) create mode 100644 log.h diff --git a/eepg.c b/eepg.c index 7aa3fe0..22ee520 100644 --- a/eepg.c +++ b/eepg.c @@ -39,14 +39,12 @@ #include "eepg.h" #include "dish.h" #include "epghandler.h" +#include "log.h" #include #include #include -#define VERBOSE 1 -/* 0 = only print errors, 1 = print channels and themes, 2 = print channels, themes, titles, summaries 3 = debug mode */ -/* all is logged into /var/log/syslog */ #if APIVERSNUM < 10401 #error You need at least VDR API version 1.4.1 for this plugin @@ -184,62 +182,6 @@ void cMenuSetupPremiereEpg::Store (void) #endif } -bool CheckLevel(int level) -{ -#ifdef DEBUG - if (SetupPE.LogLevel >= level) -#else - if (VERBOSE >= level) -#endif - { - return true; - } - return false; -} - -const char* PrepareLog(string message) -{ - message = "EEPG: " + message; - return message.c_str(); -} - -#define MAXSYSLOGBUF 256 - -//void LogVsyslog(int errLevel, const char * message, ...) -void LogVsyslog(int errLevel, int const& lineNum, const char * function, const char * message, ...) -{ - va_list ap; - char fmt[MAXSYSLOGBUF]; - if (errLevel == LOG_DEBUG) { - snprintf(fmt, sizeof(fmt), "[%d] %s:%d %s", cThread::ThreadId(), function, lineNum, message); - } else { - snprintf(fmt, sizeof(fmt), "[%d] %s", cThread::ThreadId(), message); - } - va_start(ap,message); - vsyslog ( errLevel, fmt, ap ); - va_end(ap); -} - -#define LogI(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_INFO, __LINE__, __FUNCTION__, b ) : void() ) -#define LogE(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_ERR, __LINE__, __FUNCTION__, b ) : void() ) -#define LogD(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_DEBUG, __LINE__, __FUNCTION__, b ) : void() ) -//#define LogE(a, b...) void( CheckLevel(a) ? esyslog ( b ) : void() ) -//#define LogD(a, b...) void( CheckLevel(a) ? dsyslog ( b ) : void() ) -#define prep(s) PrepareLog(s) -#define prep2(s) s - -//void LogF(int level, const char * message, ...) __attribute__ ((format (printf,2,3))); - -//void LogF(int level, const char * message, ...) -//{ -// if (CheckLevel(level)) { -// va_list ap; -// va_start(ap,message); -// vsyslog (LOG_ERR, PrepareLog(message), ap ); -// va_end(ap); -// } -//} - #define Asprintf(a, b, c...) void( asprintf(a, b, c) < 0 ? esyslog("memory allocation error - %s", b) : void() ) // --- CRC16 ------------------------------------------------------------------- diff --git a/epghandler.c b/epghandler.c index 51074ad..abc4c38 100644 --- a/epghandler.c +++ b/epghandler.c @@ -6,6 +6,7 @@ */ #include "epghandler.h" +#include "log.h" cEEpgHandler::cEEpgHandler() { // TODO Auto-generated constructor stub @@ -27,13 +28,17 @@ bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) { } bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { + LogD(1, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title); + if (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title))) Event->SetTitle(Title); return true; } bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) { - if (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText))) + LogD(1, prep("Event id:%d ShortText:%s new ShortText:%s"), Event->EventID(), Event->ShortText(), ShortText); + + if (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText))) Event->SetShortText(ShortText); return true; } diff --git a/log.h b/log.h new file mode 100644 index 0000000..900aed6 --- /dev/null +++ b/log.h @@ -0,0 +1,76 @@ +/* + * log.h + * + * Created on: 08.5.2012 + * Author: d.petrovski + */ + +#ifndef LOG_H_ +#define LOG_H_ + +#include +#include + +#define VERBOSE 1 +/* 0 = only print errors, 1 = print channels and themes, 2 = print channels, themes, titles, summaries 3 = debug mode */ +/* all is logged into /var/log/syslog */ + + +bool CheckLevel(int level) +{ +#ifdef DEBUG + if (SetupPE.LogLevel >= level) +#else + if (VERBOSE >= level) +#endif + { + return true; + } + return false; +} + +const char* PrepareLog(std::string message) +{ + message = "EEPG: " + message; + return message.c_str(); +} + +#define MAXSYSLOGBUF 256 + +//void LogVsyslog(int errLevel, const char * message, ...) +void LogVsyslog(int errLevel, int const& lineNum, const char * function, const char * message, ...) +{ + va_list ap; + char fmt[MAXSYSLOGBUF]; + if (errLevel == LOG_DEBUG) { + snprintf(fmt, sizeof(fmt), "[%d] %s:%d %s", cThread::ThreadId(), function, lineNum, message); + } else { + snprintf(fmt, sizeof(fmt), "[%d] %s", cThread::ThreadId(), message); + } + va_start(ap,message); + vsyslog ( errLevel, fmt, ap ); + va_end(ap); +} + +#define LogI(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_INFO, __LINE__, __FUNCTION__, b ) : void() ) +#define LogE(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_ERR, __LINE__, __FUNCTION__, b ) : void() ) +#define LogD(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_DEBUG, __LINE__, __FUNCTION__, b ) : void() ) +//#define LogE(a, b...) void( CheckLevel(a) ? esyslog ( b ) : void() ) +//#define LogD(a, b...) void( CheckLevel(a) ? dsyslog ( b ) : void() ) +#define prep(s) PrepareLog(s) +#define prep2(s) s + + +//void LogF(int level, const char * message, ...) __attribute__ ((format (printf,2,3))); + +//void LogF(int level, const char * message, ...) +//{ +// if (CheckLevel(level)) { +// va_list ap; +// va_start(ap,message); +// vsyslog (LOG_ERR, PrepareLog(message), ap ); +// va_end(ap); +// } +//} + +#endif /* LOG_H_ */ -- cgit v1.2.3 From 5745ef4a6bfeede40fe69067f51e714718243045 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Fri, 18 May 2012 09:19:41 +0200 Subject: move cSetupEEPG to separate files --- Makefile | 2 +- eepg.c | 97 +++++++++++++++++++++---------------------------------------- log.h | 9 +++--- setupeepg.c | 36 +++++++++++++++++++++++ setupeepg.h | 35 ++++++++++++++++++++++ 5 files changed, 110 insertions(+), 69 deletions(-) create mode 100644 setupeepg.c create mode 100644 setupeepg.h diff --git a/Makefile b/Makefile index 0bebc82..a2d413e 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"' ### The object files (add further files here): -OBJS = $(PLUGIN).o dish.o epghandler.o +OBJS = $(PLUGIN).o dish.o epghandler.o setupeepg.o ifdef DBG CXXFLAGS += -g diff --git a/eepg.c b/eepg.c index 22ee520..902c271 100644 --- a/eepg.c +++ b/eepg.c @@ -40,6 +40,7 @@ #include "dish.h" #include "epghandler.h" #include "log.h" +#include "setupeepg.h" #include #include @@ -75,8 +76,6 @@ static const char *DESCRIPTION = trNOOP ("Parses Extended EPG data"); using namespace std; -// --- cSetupEEPG ------------------------------------------------------- - const char *optPats[] = { "%s", "%s (Option %d)", @@ -101,45 +100,15 @@ char *cs_hexdump (int m, const uchar * buf, int n) return (dump); } -class cSetupEEPG -{ -public: - int OptPat; - int OrderInfo; - int RatingInfo; - int FixEpg; - int DisplayMessage; - int ProcessEIT; -#ifdef DEBUG - int LogLevel; -#endif - -public: - cSetupEEPG (void); -}; - -cSetupEEPG SetupPE; +cSetupEEPG* SetupPE = cSetupEEPG::getInstance(); -cSetupEEPG::cSetupEEPG (void) -{ - OptPat = 1; - OrderInfo = 1; - RatingInfo = 1; - FixEpg = 0; - DisplayMessage = 1; - ProcessEIT = 0; -#ifdef DEBUG - LogLevel = 0; -#endif - -} // --- cMenuSetupPremiereEpg ------------------------------------------------------------ class cMenuSetupPremiereEpg:public cMenuSetupPage { private: - cSetupEEPG data; + cSetupEEPG* data; const char *optDisp[NUM_PATS]; char buff[NUM_PATS][32]; protected: @@ -150,35 +119,35 @@ public: cMenuSetupPremiereEpg::cMenuSetupPremiereEpg (void) { - data = SetupPE; + data = cSetupEEPG::getInstance(); SetSection (tr ("PremiereEPG")); optDisp[0] = tr ("off"); for (unsigned int i = 1; i < NUM_PATS; i++) { snprintf (buff[i], sizeof (buff[i]), optPats[i], "Event", 1); optDisp[i] = buff[i]; } - Add (new cMenuEditStraItem (tr ("Tag option events"), &data.OptPat, NUM_PATS, optDisp)); - Add (new cMenuEditBoolItem (tr ("Show order information"), &data.OrderInfo)); - Add (new cMenuEditBoolItem (tr ("Show rating information"), &data.RatingInfo)); - Add (new cMenuEditBoolItem (tr ("Fix EPG data"), &data.FixEpg)); - Add (new cMenuEditBoolItem (tr ("Display summary message"), &data.DisplayMessage)); + Add (new cMenuEditStraItem (tr ("Tag option events"), &data->OptPat, NUM_PATS, optDisp)); + Add (new cMenuEditBoolItem (tr ("Show order information"), &data->OrderInfo)); + Add (new cMenuEditBoolItem (tr ("Show rating information"), &data->RatingInfo)); + Add (new cMenuEditBoolItem (tr ("Fix EPG data"), &data->FixEpg)); + Add (new cMenuEditBoolItem (tr ("Display summary message"), &data->DisplayMessage)); #ifdef DEBUG - Add (new cMenuEditIntItem (tr ("Level of logging verbosity"), &data.LogLevel, 0, 5)); - Add (new cMenuEditBoolItem (tr ("Process EIT info with EEPG"), &data.ProcessEIT)); + Add (new cMenuEditIntItem (tr ("Level of logging verbosity"), &data->LogLevel, 0, 5)); + Add (new cMenuEditBoolItem (tr ("Process EIT info with EEPG"), &data->ProcessEIT)); #endif } void cMenuSetupPremiereEpg::Store (void) { - SetupPE = data; - SetupStore ("OptionPattern", SetupPE.OptPat); - SetupStore ("OrderInfo", SetupPE.OrderInfo); - SetupStore ("RatingInfo", SetupPE.RatingInfo); - SetupStore ("FixEpg", SetupPE.FixEpg); - SetupStore ("DisplayMessage", SetupPE.DisplayMessage); + //SetupPE = data; + SetupStore ("OptionPattern", SetupPE->OptPat); + SetupStore ("OrderInfo", SetupPE->OrderInfo); + SetupStore ("RatingInfo", SetupPE->RatingInfo); + SetupStore ("FixEpg", SetupPE->FixEpg); + SetupStore ("DisplayMessage", SetupPE->DisplayMessage); #ifdef DEBUG - SetupStore ("LogLevel", SetupPE.LogLevel); - SetupStore ("ProcessEIT", SetupPE.ProcessEIT); + SetupStore ("LogLevel", SetupPE->LogLevel); + SetupStore ("ProcessEIT", SetupPE->ProcessEIT); #endif } @@ -2990,7 +2959,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat : SI::EIT (Data, false) { //LogD(2, prep("cEIT2::cEIT2")); - if (Tid > 0 && (Format == DISH_BEV || (SetupPE.ProcessEIT && isEITPid))) Tid--; + if (Tid > 0 && (Format == DISH_BEV || (SetupPE->ProcessEIT && isEITPid))) Tid--; if (!CheckCRCAndParse ()) { LogD(2, prep("!CheckCRCAndParse ()")); @@ -3604,7 +3573,7 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) isyslog ("EEPG: written %i summaries", SummaryCounter); isyslog ("EEPG: rejected %i titles/summaries because of higher TableId", RejectTableId); //Send message when finished - if (SetupPE.DisplayMessage) { + if (SetupPE->DisplayMessage) { char *mesg; Asprintf(&mesg, "EEPG: written %i summaries", SummaryCounter); Skins.QueueMessage(mtInfo, mesg, 2); @@ -3634,7 +3603,7 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) FreeSummaries (); // Enable EIT scan for all except DISH_BEV since it is already enabled - if (SetupPE.ProcessEIT && !UnprocessedFormat[EIT] + if (SetupPE->ProcessEIT && !UnprocessedFormat[EIT] && !UnprocessedFormat[FREEVIEW] && !UnprocessedFormat[DISH_BEV]) { UnprocessedFormat[EIT] = EIT_PID; loadEquivalentChannelMap(); @@ -4162,7 +4131,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) nDescriptorTag = d->getDescriptorTag (); switch (nDescriptorTag) { case 0xF0: // order information - if (SetupPE.OrderInfo) { + if (SetupPE->OrderInfo) { static const char *text[] = { trNOOP ("Ordernumber"), trNOOP ("Price"), @@ -4184,7 +4153,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) } break; case 0xF1: // parental rating - if (SetupPE.RatingInfo) { + if (SetupPE->RatingInfo) { char buff[512]; int p = 0; const unsigned char *data = d->getData ().getData () + 2; @@ -4264,7 +4233,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) int nid = pct->getOriginalNetworkId (); int tid = pct->getTransportStreamId (); int sid = pct->getServiceId (); - if (SetupPE.FixEpg) { + if (SetupPE->FixEpg) { if (nid == 133) { if (tid == 0x03 && sid == 0xf0) { tid = 0x02; @@ -4358,7 +4327,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) ShortEventDescriptor->name.getText (buffer, sizeof (buffer)); if (isOpt) { char buffer2[sizeof (buffer) + 32]; - snprintf (buffer2, sizeof (buffer2), optPats[SetupPE.OptPat], buffer, optCount); + snprintf (buffer2, sizeof (buffer2), optPats[SetupPE->OptPat], buffer, optCount); pEvent->SetTitle (buffer2); } else pEvent->SetTitle (buffer); @@ -4568,20 +4537,20 @@ bool cPluginEEPG::SetupParse (const char *Name, const char *Value) if (!strcasecmp (Name, "OptionPattern")) - SetupPE.OptPat = atoi (Value); + SetupPE->OptPat = atoi (Value); else if (!strcasecmp (Name, "OrderInfo")) - SetupPE.OrderInfo = atoi (Value); + SetupPE->OrderInfo = atoi (Value); else if (!strcasecmp (Name, "RatingInfo")) - SetupPE.RatingInfo = atoi (Value); + SetupPE->RatingInfo = atoi (Value); else if (!strcasecmp (Name, "FixEpg")) - SetupPE.FixEpg = atoi (Value); + SetupPE->FixEpg = atoi (Value); else if (!strcasecmp (Name, "DisplayMessage")) - SetupPE.DisplayMessage = atoi (Value); + SetupPE->DisplayMessage = atoi (Value); #ifdef DEBUG else if (!strcasecmp (Name, "LogLevel")) - SetupPE.LogLevel = atoi (Value); + SetupPE->LogLevel = atoi (Value); else if (!strcasecmp (Name, "ProcessEIT")) - SetupPE.ProcessEIT = atoi (Value); + SetupPE->ProcessEIT = atoi (Value); #endif else return false; diff --git a/log.h b/log.h index 900aed6..35942d3 100644 --- a/log.h +++ b/log.h @@ -10,16 +10,17 @@ #include #include +#include "setupeepg.h" #define VERBOSE 1 /* 0 = only print errors, 1 = print channels and themes, 2 = print channels, themes, titles, summaries 3 = debug mode */ /* all is logged into /var/log/syslog */ -bool CheckLevel(int level) +inline bool CheckLevel(int level) { #ifdef DEBUG - if (SetupPE.LogLevel >= level) + if (cSetupEEPG::getInstance()->LogLevel >= level) #else if (VERBOSE >= level) #endif @@ -29,7 +30,7 @@ bool CheckLevel(int level) return false; } -const char* PrepareLog(std::string message) +inline const char* PrepareLog(std::string message) { message = "EEPG: " + message; return message.c_str(); @@ -38,7 +39,7 @@ const char* PrepareLog(std::string message) #define MAXSYSLOGBUF 256 //void LogVsyslog(int errLevel, const char * message, ...) -void LogVsyslog(int errLevel, int const& lineNum, const char * function, const char * message, ...) +inline void LogVsyslog(int errLevel, int const& lineNum, const char * function, const char * message, ...) { va_list ap; char fmt[MAXSYSLOGBUF]; diff --git a/setupeepg.c b/setupeepg.c new file mode 100644 index 0000000..3738227 --- /dev/null +++ b/setupeepg.c @@ -0,0 +1,36 @@ +/* + * setupeepg.c + * + * Created on: 08.5.2012 + * Author: d.petrovski + */ + +#include +#include "setupeepg.h" + +// --- cSetupEEPG ------------------------------------------------------- + +cSetupEEPG* cSetupEEPG::_setupEEPG = NULL; + +cSetupEEPG::cSetupEEPG (void) +{ + OptPat = 1; + OrderInfo = 1; + RatingInfo = 1; + FixEpg = 0; + DisplayMessage = 1; + ProcessEIT = 0; +#ifdef DEBUG + LogLevel = 0; +#endif + +} + +cSetupEEPG* cSetupEEPG::getInstance() +{ + if (!_setupEEPG) + _setupEEPG = new cSetupEEPG(); + + return _setupEEPG; +} + diff --git a/setupeepg.h b/setupeepg.h new file mode 100644 index 0000000..f5e342a --- /dev/null +++ b/setupeepg.h @@ -0,0 +1,35 @@ +/* + * setupeepg.h + * + * Created on: 08.5.2012 + * Author: d.petrovski + */ + +#ifndef SETUPEEPG_H_ +#define SETUPEEPG_H_ + +class cSetupEEPG +{ +public: + int OptPat; + int OrderInfo; + int RatingInfo; + int FixEpg; + int DisplayMessage; + int ProcessEIT; +#ifdef DEBUG + int LogLevel; +#endif + +public: + static cSetupEEPG* getInstance(); + +private: + cSetupEEPG (void); + cSetupEEPG(cSetupEEPG const&); // copy constructor is private + cSetupEEPG& operator=(cSetupEEPG const&); // assignment operator is private + static cSetupEEPG* _setupEEPG; + +}; + +#endif /* SETUPEEPG_H_ */ -- cgit v1.2.3 From 5bbab08c9ff074509d2c7efe1d17e5b5254c7f9f Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 9 May 2012 14:51:23 +0200 Subject: more debug logging --- epghandler.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/epghandler.c b/epghandler.c index abc4c38..b9057c1 100644 --- a/epghandler.c +++ b/epghandler.c @@ -10,6 +10,7 @@ cEEpgHandler::cEEpgHandler() { // TODO Auto-generated constructor stub + LogD(1, prep("cEEpgHandler()")); } @@ -19,6 +20,7 @@ cEEpgHandler::~cEEpgHandler() { bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, const SI::EIT::Event* EitEvent, uchar TableID, uchar Version) { + LogD(1, prep("HandleEitEvent")); return true; } @@ -75,6 +77,7 @@ bool cEEpgHandler::SetVps(cEvent* Event, time_t Vps) { } bool cEEpgHandler::HandleEvent(cEvent* Event) { + LogD(1, prep("HandleEvent")); return true; } -- cgit v1.2.3 From 3b57ef95c261d53f21fb7db1a283cca1aca64f0f Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 9 May 2012 16:54:35 +0200 Subject: change conditions --- epghandler.c | 27 +++++++++++++++------------ epghandler.h | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/epghandler.c b/epghandler.c index b9057c1..68f68d5 100644 --- a/epghandler.c +++ b/epghandler.c @@ -20,8 +20,9 @@ cEEpgHandler::~cEEpgHandler() { bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, const SI::EIT::Event* EitEvent, uchar TableID, uchar Version) { - LogD(1, prep("HandleEitEvent")); - return true; + //LogD(1, prep("HandleEitEvent")); + return false; +// return true; } bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) { @@ -32,23 +33,25 @@ bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) { bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { LogD(1, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title); - if (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title))) - Event->SetTitle(Title); - return true; + if (!Event->Title() || Title && (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title)))) + Event->SetTitle(Title); + return true; } bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) { LogD(1, prep("Event id:%d ShortText:%s new ShortText:%s"), Event->EventID(), Event->ShortText(), ShortText); - if (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText))) - Event->SetShortText(ShortText); - return true; + if (!Event->ShortText() || ShortText && (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText)))) + Event->SetShortText(ShortText); + return true; } bool cEEpgHandler::SetDescription(cEvent* Event, const char* Description) { - if (!strcmp(Event->Description(),"") || (strcmp(Description,"") && strcmp(Event->Description(),Description))) - Event->SetDescription(Description); - return true; + LogD(1, prep("Event id:%d Description:%s new Description:%s"), Event->EventID(), Event->Description(), Description); + + if (!Event->Description() || Description && (!strcmp(Event->Description(),"") || (strcmp(Description,"") && strcmp(Event->Description(),Description)))) + Event->SetDescription(Description); + return true; } bool cEEpgHandler::SetContents(cEvent* Event, uchar* Contents) { @@ -77,7 +80,7 @@ bool cEEpgHandler::SetVps(cEvent* Event, time_t Vps) { } bool cEEpgHandler::HandleEvent(cEvent* Event) { - LogD(1, prep("HandleEvent")); + //LogD(1, prep("HandleEvent")); return true; } diff --git a/epghandler.h b/epghandler.h index 1dee4f2..fd4911e 100644 --- a/epghandler.h +++ b/epghandler.h @@ -9,7 +9,7 @@ #define CEEPGHANDLER_H_ #include -class cEEpgHandler : public cEpgDataReader { +class cEEpgHandler : public cEpgHandler { public: cEEpgHandler(); virtual ~cEEpgHandler(); -- cgit v1.2.3 From 4a30d62b0614e2a2af4b862e9ab5c5c471c8d5a5 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sun, 13 May 2012 11:33:27 +0200 Subject: applied patch - fix some cppcheck warnings --- eepg.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/eepg.c b/eepg.c index 902c271..5624478 100644 --- a/eepg.c +++ b/eepg.c @@ -74,6 +74,14 @@ static const char *VERSION = "0.0.6pre"; static const char *DESCRIPTION = trNOOP ("Parses Extended EPG data"); +template T REALLOC(T Var, size_t Size) +{ + T p = (T)realloc(Var, Size); + if (!p) + free(Var); + return p; +} + using namespace std; const char *optPats[] = { @@ -429,7 +437,7 @@ static bool load_freesat_file (int tableid, const char *filename) int i = table_size[tableid][from_char]++; tables[tableid][from_char] = - (struct hufftab *) realloc (tables[tableid][from_char], (i + 1) * sizeof (tables[tableid][from_char][0])); + (struct hufftab *) REALLOC (tables[tableid][from_char], (i + 1) * sizeof (tables[tableid][from_char][0])); tables[tableid][from_char][i].value = bin; tables[tableid][from_char][i].next = to_char; tables[tableid][from_char][i].bits = bin_len; @@ -620,7 +628,7 @@ char *freesat_huffman_decode (const unsigned char *src, size_t size) lastch = nextCh; if (p >= uncompressed_len) { uncompressed_len += 10; - uncompressed = (char *) realloc (uncompressed, uncompressed_len + 1); + uncompressed = (char *) REALLOC (uncompressed, uncompressed_len + 1); } uncompressed[p++] = nextCh; uncompressed[p] = 0; @@ -639,7 +647,7 @@ char *freesat_huffman_decode (const unsigned char *src, size_t size) if (nextCh != STOP && nextCh != ESCAPE) { if (p >= uncompressed_len) { uncompressed_len += 10; - uncompressed = (char *) realloc (uncompressed, uncompressed_len + 1); + uncompressed = (char *) REALLOC (uncompressed, uncompressed_len + 1); } uncompressed[p++] = nextCh; uncompressed[p] = 0; @@ -1438,7 +1446,7 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse LogI(5, prep("DEBUG: Textnr %i, Lasttxt %i."), ST->TextNr, ST->LastTextNr); int SummaryLength = ST->Textlength; - Text = (unsigned char *) realloc (Text, SummaryLength + TotLength); + Text = (unsigned char *) REALLOC (Text, SummaryLength + TotLength); if (Text == NULL) { LogI(0, prep("Summaries memory allocation error.")); return 0; //empty text @@ -1449,7 +1457,7 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse LastTextBlock = ((ST->LastTextNr == 0) || (ST->TextNr >= ST->LastTextNr)); } while (!LastTextBlock); - Text = (unsigned char *) realloc (Text, 1 + TotLength); //allocate 1 extra byte + Text = (unsigned char *) REALLOC (Text, 1 + TotLength); //allocate 1 extra byte Text[TotLength] = '\0'; //terminate string by NULL char LogD(5, prep("DEBUG: Full Text:%s."), Text); @@ -2015,7 +2023,7 @@ int cFilterEEPG::GetNagra (const u_char * Data, int Length) //since the data has to be stored anyway; summaries do not seem to have channelid included, so storing titles and separately storing summaries will not work... //GetEventId only works for a specific Schedule for a specific ChannelId.... buffer[TableIdExtension] = - (unsigned char *) realloc (buffer[TableIdExtension], SectionLength - 9 + bufsize[TableIdExtension]); + (unsigned char *) REALLOC (buffer[TableIdExtension], SectionLength - 9 + bufsize[TableIdExtension]); memcpy (buffer[TableIdExtension] + bufsize[TableIdExtension], Data + 8, SectionLength - 9); //append new section bufsize[TableIdExtension] += SectionLength - 9; if (TBH->SectionNumber >= TBH->LastSectionNumber) { @@ -4489,6 +4497,7 @@ bool cPluginEEPG::Start (void) for (int i = 0; i < NumberOfAvailableSources; i++) isyslog ("EEPG: Available sources:%s.", *cSource::ToString (AvailableSources[i])); + closedir(ConfigDir); new cEEpgHandler(); return true; -- cgit v1.2.3 From 68eb397f7d419c4caf58220b62de22ac3244d682 Mon Sep 17 00:00:00 2001 From: Dime Date: Sun, 13 May 2012 13:31:03 +0200 Subject: use the original eepg Short Text and Description if missing in EIT --- epghandler.c | 26 ++++++++++++++++++++++++-- epghandler.h | 5 +++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/epghandler.c b/epghandler.c index 68f68d5..5bed74f 100644 --- a/epghandler.c +++ b/epghandler.c @@ -41,15 +41,25 @@ bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) { LogD(1, prep("Event id:%d ShortText:%s new ShortText:%s"), Event->EventID(), Event->ShortText(), ShortText); - if (!Event->ShortText() || ShortText && (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText)))) + if (Event->ShortText() && !strcmp(Event->ShortText(),"")) + origShortText = Event->ShortText(); + else + origShortText.clear(); + + //if (!Event->ShortText() || ShortText && (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText)))) Event->SetShortText(ShortText); return true; } bool cEEpgHandler::SetDescription(cEvent* Event, const char* Description) { LogD(1, prep("Event id:%d Description:%s new Description:%s"), Event->EventID(), Event->Description(), Description); + + if (Event->Description() && !strcmp(Event->Description(),"")) + origDescription = Event->Description(); + else + origDescription.clear(); - if (!Event->Description() || Description && (!strcmp(Event->Description(),"") || (strcmp(Description,"") && strcmp(Event->Description(),Description)))) + //if (!Event->Description() || Description && (!strcmp(Event->Description(),"") || (strcmp(Description,"") && strcmp(Event->Description(),Description)))) Event->SetDescription(Description); return true; } @@ -81,6 +91,18 @@ bool cEEpgHandler::SetVps(cEvent* Event, time_t Vps) { bool cEEpgHandler::HandleEvent(cEvent* Event) { //LogD(1, prep("HandleEvent")); + + //After FixEpgBugs of cEvent set the original Short Text if empty + if (!Event->ShortText() && !strcmp(Event->ShortText(),"")) + Event->SetShortText(origShortText.c_str()); + + //TODO just to see the difference + if (!origDescription.empty() && !origDescription.compare(Event->Description())) { + origDescription.append(" | EIT: "); + origDescription.append(Event->Description()); + Event->SetDescription(origDescription.c_str()); + } + return true; } diff --git a/epghandler.h b/epghandler.h index fd4911e..3256153 100644 --- a/epghandler.h +++ b/epghandler.h @@ -8,6 +8,7 @@ #ifndef CEEPGHANDLER_H_ #define CEEPGHANDLER_H_ #include +#include class cEEpgHandler : public cEpgHandler { public: @@ -28,6 +29,10 @@ public: virtual bool HandleEvent(cEvent *Event); virtual bool SortSchedule(cSchedule *Schedule); virtual bool DropOutdated(cSchedule *Schedule, time_t SegmentStart, time_t SegmentEnd, uchar TableID, uchar Version); + +private: + std::string origShortText; + std::string origDescription; }; #endif /* CEEPGHANDLER_H_ */ -- cgit v1.2.3 From 23260abbe50c8315663b4f63fdaed38c26372a29 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sun, 13 May 2012 18:20:18 +0200 Subject: corected epghandler --- epghandler.c | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/epghandler.c b/epghandler.c index 5bed74f..2c25268 100644 --- a/epghandler.c +++ b/epghandler.c @@ -10,7 +10,7 @@ cEEpgHandler::cEEpgHandler() { // TODO Auto-generated constructor stub - LogD(1, prep("cEEpgHandler()")); + LogD(4, prep("cEEpgHandler()")); } @@ -31,7 +31,7 @@ bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) { } bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { - LogD(1, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title); + LogD(3, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title); if (!Event->Title() || Title && (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title)))) Event->SetTitle(Title); @@ -39,12 +39,14 @@ bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { } bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) { - LogD(1, prep("Event id:%d ShortText:%s new ShortText:%s"), Event->EventID(), Event->ShortText(), ShortText); + LogD(3, prep("Event id:%d ShortText:%s new ShortText:%s"), Event->EventID(), Event->ShortText(), ShortText); - if (Event->ShortText() && !strcmp(Event->ShortText(),"")) - origShortText = Event->ShortText(); - else + if (Event->ShortText() && strcmp(Event->ShortText(),"") != 0) { + origShortText = std::string(Event->ShortText()); + } + else { origShortText.clear(); + } //if (!Event->ShortText() || ShortText && (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText)))) Event->SetShortText(ShortText); @@ -52,9 +54,9 @@ bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) { } bool cEEpgHandler::SetDescription(cEvent* Event, const char* Description) { - LogD(1, prep("Event id:%d Description:%s new Description:%s"), Event->EventID(), Event->Description(), Description); + LogD(3, prep("Event id:%d Description:%s new Description:%s"), Event->EventID(), Event->Description(), Description); - if (Event->Description() && !strcmp(Event->Description(),"")) + if (Event->Description() && strcmp(Event->Description(),"") != 0) origDescription = Event->Description(); else origDescription.clear(); @@ -90,18 +92,22 @@ bool cEEpgHandler::SetVps(cEvent* Event, time_t Vps) { } bool cEEpgHandler::HandleEvent(cEvent* Event) { - //LogD(1, prep("HandleEvent")); - - //After FixEpgBugs of cEvent set the original Short Text if empty - if (!Event->ShortText() && !strcmp(Event->ShortText(),"")) - Event->SetShortText(origShortText.c_str()); - - //TODO just to see the difference - if (!origDescription.empty() && !origDescription.compare(Event->Description())) { - origDescription.append(" | EIT: "); - origDescription.append(Event->Description()); - Event->SetDescription(origDescription.c_str()); - } + + LogD(3, prep("HandleEvent st:%s ost:%s desc:%s odesc:%s"),Event->ShortText(),origShortText.c_str(),Event->Description(),origDescription.c_str()); + + //After FixEpgBugs of cEvent set the original Short Text if empty + if (!Event->ShortText() || !strcmp(Event->ShortText(),"")) + Event->SetShortText(origShortText.c_str()); + + if (!Event->Description() && !origDescription.empty()) { + Event->SetDescription(origDescription.c_str()); + } + //TODO just to see the difference + //else if (!origDescription.empty() && !origDescription.compare(Event->Description())) { +// origDescription.append(" | EIT: "); +// origDescription.append(Event->Description()); +// Event->SetDescription(origDescription.c_str()); + // } return true; } -- cgit v1.2.3 From aa7d6a705d56f11c327ebe4c09a8a0a0f517e8fd Mon Sep 17 00:00:00 2001 From: Dime Date: Wed, 16 May 2012 13:24:24 +0200 Subject: add defines to compile wit VDR < 1.7.26 --- eepg.c | 4 +++- epghandler.c | 3 ++- epghandler.h | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/eepg.c b/eepg.c index 5624478..4bfd5d7 100644 --- a/eepg.c +++ b/eepg.c @@ -4497,9 +4497,11 @@ bool cPluginEEPG::Start (void) for (int i = 0; i < NumberOfAvailableSources; i++) isyslog ("EEPG: Available sources:%s.", *cSource::ToString (AvailableSources[i])); - closedir(ConfigDir); +#if APIVERSNUM > 10725 new cEEpgHandler(); +#endif + closedir(ConfigDir); return true; } diff --git a/epghandler.c b/epghandler.c index 2c25268..36aaf74 100644 --- a/epghandler.c +++ b/epghandler.c @@ -5,6 +5,7 @@ * Author: d.petrovski */ +#if APIVERSNUM > 10725 #include "epghandler.h" #include "log.h" @@ -122,4 +123,4 @@ bool cEEpgHandler::DropOutdated(cSchedule* Schedule, time_t SegmentStart, return false; } - +#endif diff --git a/epghandler.h b/epghandler.h index 3256153..8d3615a 100644 --- a/epghandler.h +++ b/epghandler.h @@ -7,6 +7,7 @@ #ifndef CEEPGHANDLER_H_ #define CEEPGHANDLER_H_ +#if APIVERSNUM > 10725 #include #include @@ -35,4 +36,5 @@ private: std::string origDescription; }; +#endif /*APIVERSNUM > 10725*/ #endif /* CEEPGHANDLER_H_ */ -- cgit v1.2.3 From d08ebcb625422089db9e1521a70a65a4efe96b81 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Thu, 17 May 2012 13:00:58 +0200 Subject: fix some indentation --- eepg.c | 384 ++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 191 insertions(+), 193 deletions(-) diff --git a/eepg.c b/eepg.c index 4bfd5d7..80ad23f 100644 --- a/eepg.c +++ b/eepg.c @@ -234,7 +234,7 @@ private: unsigned char InitialSummary[64]; void NextPmt (void); - void ProccessContinuous(u_short Pid, u_char Tid, int Length, const u_char *Data); + void ProccessContinuous(u_short Pid, u_char Tid, int Length, const u_char *Data); protected: virtual void Process (u_short Pid, u_char Tid, const u_char * Data, int Length); virtual void AddFilter (u_short Pid, u_char Tid); @@ -262,9 +262,9 @@ protected: virtual void PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]); //gets a channel and returns an array of schedules that WriteToSchedule can write to. Call this routine before a batch of titles with the same ChannelId will be WriteToScheduled; batchsize can be 1 virtual void FinishWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]); virtual void WriteToSchedule (cSchedule * ps[MAX_EQUIVALENCES], unsigned short int NumberOfEquivalences, - unsigned int EventId, unsigned int StartTime, unsigned int Duration, char *Text, - char *SummText, unsigned short int ThemeId, unsigned short int TableId, - unsigned short int Version, char Rating = 0x00); + unsigned int EventId, unsigned int StartTime, unsigned int Duration, char *Text, + char *SummText, unsigned short int ThemeId, unsigned short int TableId, + unsigned short int Version, char Rating = 0x00); virtual void LoadIntoSchedule (void); virtual void LoadEquivalentChannels (void); @@ -491,7 +491,7 @@ static bool load_sky_file (const char *filename) memset (string1, 0, sizeof (string1)); memset (string2, 0, sizeof (string2)); if (sscanf (Line, "%c=%[^\n]\n", string1, string2) == 2 - || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) { + || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) { nH = sky_tables[tableId]; LenPrefix = strlen (string2); for (i = 0; i < LenPrefix; i++) { @@ -510,7 +510,7 @@ static bool load_sky_file (const char *filename) nH = nH->P0; if (nH->Value != NULL || (LenPrefix - 1) == i) { LogE (0 ,prep("Error, huffman prefix code already exists for \"%s\"=%s with '%s'"), string1, - string2, nH->Value); + string2, nH->Value); } } break; @@ -528,7 +528,7 @@ static bool load_sky_file (const char *filename) nH = nH->P1; if (nH->Value != NULL || (LenPrefix - 1) == i) { LogE (0, prep("Error, huffman prefix code already exists for \"%s\"=%s with '%s'"), string1, - string2, nH->Value); + string2, nH->Value); } } break; @@ -554,7 +554,7 @@ static bool load_sky_file (const char *filename) memset (string1, 0, sizeof (string1)); memset (string2, 0, sizeof (string2)); if (sscanf (Line, "%c=%[^\n]\n", string1, string2) == 2 - || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) { + || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) { nH = sky_tables[tableId]; LenPrefix = strlen (string2); for (i = 0; i < LenPrefix; i++) { @@ -873,20 +873,20 @@ void CleanString (unsigned char *String) cChannel *GetChannelByID(tChannelID & channelID, bool searchOtherPos) { - cChannel *VC = Channels.GetByChannelID(channelID, true); - if(!VC && searchOtherPos){ - //look on other satpositions - for(int i = 0;i < NumberOfAvailableSources;i++){ - channelID = tChannelID(AvailableSources[i], channelID.Nid(), channelID.Tid(), channelID.Sid()); - VC = Channels.GetByChannelID(channelID, true); - if(VC){ - //found this actually on satellite nextdoor... - break; - } - } + cChannel *VC = Channels.GetByChannelID(channelID, true); + if(!VC && searchOtherPos){ + //look on other satpositions + for(int i = 0;i < NumberOfAvailableSources;i++){ + channelID = tChannelID(AvailableSources[i], channelID.Nid(), channelID.Tid(), channelID.Sid()); + VC = Channels.GetByChannelID(channelID, true); + if(VC){ + //found this actually on satellite nextdoor... + break; + } } + } - return VC; + return VC; } bool cFilterEEPG::GetThemesSKYBOX (void) //TODO can't we read this from the DVB stream? @@ -962,7 +962,7 @@ bool cFilterEEPG::InitDictionary (void) LogD (4, prep("EEPGDebug: loading freesat.dict")); FileName += "/freesat.t1"; if (!load_freesat_file (1, FileName.c_str())) - return false; + return false; FileName = ConfDir; FileName += "/freesat.t2"; return load_freesat_file (2, FileName.c_str()); @@ -1010,7 +1010,7 @@ void loadEquivalentChannelMap (void) //TODO DPE add code to reload if file is changed if (equiChanMap.size() > 0) - return; + return; File = fopen (FileName.c_str(), "r"); @@ -1040,37 +1040,37 @@ void loadEquivalentChannelMap (void) tChannelID OriginalChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); bool found = false; //int i = 0; - cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); - if (!OriginalChannel) { - LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalency is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? - continue; + cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); + if (!OriginalChannel) { + LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalency is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? + continue; + } + if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { + if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) + != 5) { + rid = 0; } - if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { - if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) - != 5) { - rid = 0; + tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); + cChannel *EquivChannel = Channels.GetByChannelID (EquivChID, false); //TODO use valid function? + if (EquivChannel) { + ret = equiChanMap.equal_range(*OriginalChID.ToString()); + for (it=ret.first; it!=ret.second; ++it) + if ((*it).second == *OriginalChID.ToString()) { + found = true; + break; + } + + if (!found) { + string origCh(*OriginalChID.ToString()); + string equiCh(*EquivChID.ToString()); + equiChanMap.insert(pair(origCh.c_str(),equiCh.c_str())); + LogD(4, prep("Found %s equivalent to %s. origCh %s"), *EquivChID.ToString(), *OriginalChID.ToString(), origCh.c_str()); + for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) + LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); } - tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); - cChannel *EquivChannel = Channels.GetByChannelID (EquivChID, false); //TODO use valid function? - if (EquivChannel) { - ret = equiChanMap.equal_range(*OriginalChID.ToString()); - for (it=ret.first; it!=ret.second; ++it) - if ((*it).second == *OriginalChID.ToString()) { - found = true; - break; - } - - if (!found) { - string origCh(*OriginalChID.ToString()); - string equiCh(*EquivChID.ToString()); - equiChanMap.insert(pair(origCh.c_str(),equiCh.c_str())); - LogD(4, prep("Found %s equivalent to %s. origCh %s"), *EquivChID.ToString(), *OriginalChID.ToString(), origCh.c_str()); - for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) - LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); - } - } else - LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); - } + } else + LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); + } } //if scanf string1 } //if string1 } //if scanf @@ -1079,7 +1079,7 @@ void loadEquivalentChannelMap (void) fclose (File); LogD(3, prep("Loaded %i equivalents."), equiChanMap.size()); for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) - LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); + LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); } //if file } void cFilterEEPG::LoadEquivalentChannels (void) @@ -1120,21 +1120,21 @@ void cFilterEEPG::LoadEquivalentChannels (void) while (i < nChannels && (!found)) { C = &sChannels[i]; if (C->Src[0] == (unsigned int)cSource::FromString (source) && C->Nid[0] == nid - && C->Tid[0] == tid && C->Sid[0] == sid) + && C->Tid[0] == tid && C->Sid[0] == sid) found = true; else i++; } if (!found) { LogI(2, prep("Warning: in equivalence file, cannot find original channel %s. Perhaps you are tuned to another transponder right now."), - origChanID); + origChanID); } else { cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); if (!OriginalChannel) LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalence is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) - != 5) { + != 5) { rid = 0; } tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); @@ -1153,7 +1153,7 @@ void cFilterEEPG::LoadEquivalentChannels (void) C->Sid[C->NumberOfEquivalences - 1], i); } else LogE(0, prep("Error, channel with id %i has more than %i equivalences. Increase MAX_EQUIVALENCES."), - i, MAX_EQUIVALENCES); + i, MAX_EQUIVALENCES); } else LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); } @@ -1238,7 +1238,7 @@ int cFilterEEPG::GetChannelsMHW (const u_char * Data, int Length, int MHW) cChannel *VC = GetChannelByID(channelID, true); bool IsFound = (VC); if(IsFound) { - C->Src[0] = VC->Source(); + C->Src[0] = VC->Source(); } CleanString (C->Name); @@ -1254,7 +1254,7 @@ int cFilterEEPG::GetChannelsMHW (const u_char * Data, int Length, int MHW) return 2; //obviously, when you get here, channels are read successfully, but since all channels are sent at once, you can stop now } //if nChannels == 0 LogE (0, prep("Warning: Trying to read Channels more than once!")); -//you will only get here when GetChannelsMHW is called, and nChannels !=0, e.g. when multiple citpids cause channels to be read multiple times. Second time, do nothing, give error so that the rest of the chain is not restarted also. + //you will only get here when GetChannelsMHW is called, and nChannels !=0, e.g. when multiple citpids cause channels to be read multiple times. Second time, do nothing, give error so that the rest of the chain is not restarted also. return 0; } @@ -1384,7 +1384,7 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse if (TitleEventId != HILO32 (SD->EventId)) { LogI(0, prep("ERROR, Title has EventId %08x and points to Summary with EventId %08x."), TitleEventId, - HILO32 (SD->EventId)); + HILO32 (SD->EventId)); return 0; //return empty string } @@ -1425,7 +1425,7 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse ("EEPGDEBUG: EventId %08x NumberOfBlocks %02x BlockId %08x SummTxtOffset %08x *p2: %02x Unkn1:%02x, Unkn2:%02x.", HILO32 (SD->EventId), SD->NumberOfBlocks, HILO32 (SD->BlockId), HILO32 (SD->SummTxtOffset), *p2, SD->Unknown1, SD->Unknown2); - */ + */ unsigned char *Text = NULL; //makes first realloc work like malloc int TotLength = 0; //and also makes empty summaries if *p2 != 0x4e if (SD->NumberOfBlocks > 1) { @@ -1487,8 +1487,8 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse break; default: LogE(0, prep("ERROR *p2 has strange value: EventId %08x NumberOfBlocks %02x BlockId %08x SummTxtOffset %08x *p2: %02x Unkn1:%02x, Unkn2:%02x."), - HILO32 (SD->EventId), SD->NumberOfBlocks, HILO32 (SD->BlockId), HILO32 (SD->SummTxtOffset), *p2, - SD->Unknown1, SD->Unknown2); + HILO32 (SD->EventId), SD->NumberOfBlocks, HILO32 (SD->BlockId), HILO32 (SD->SummTxtOffset), *p2, + SD->Unknown1, SD->Unknown2); break; } //end of switch } //NrOfBlocks > 1 @@ -1691,7 +1691,7 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor //u_char *t2 = (u_char *) Data + HILO32 (Title->OffsetToText2); if (t >= DataEnd) LogE(0, prep("ERROR, Title Text out of range: t:%p, DataEnd:%p, Data:%p, Length:%i."), t, DataEnd, Data, - Length); + Length); else { Asprintf (&Text, "%.*s", *t, t + 1); //asprintf (&Text, "%.*s %.*s", *t, t + 1, *t2, t2 + 1); //FIXME second text string is not processed right now @@ -1791,7 +1791,7 @@ int cFilterEEPG::GetThemesNagra (const u_char * Data, int Length, unsigned short u_char *NewThemeId = DataStartTitles + HILO32 (TT->TitleOffset) + 28; if (NewThemeId >= DataEndTitles) LogE(0, prep("ERROR, ThemeId out of range: NewThemeId:%p, DataEndTitles:%p, DataStartTitles:%p."), NewThemeId, - DataEndTitles, DataStartTitles); + DataEndTitles, DataStartTitles); else { //esyslog("EEPGDEBUG: NewThemeId:%02x, Text:%s.",*NewThemeId, Text); if (Themes[*NewThemeId][0] != 0x00) { //theme is already filled, break off @@ -1803,7 +1803,7 @@ int cFilterEEPG::GetThemesNagra (const u_char * Data, int Length, unsigned short else if (ThemeId != *NewThemeId) { //different theme ids in block if ((ThemeId & 0xf0) != (*NewThemeId & 0xf0)) { //major nible of themeid does not correspond LogE(3, prep("ERROR, Theme has multiple indices which differ in major nibble, old index = %x, new index = %x. Ignoring both indices."), - ThemeId, *NewThemeId); + ThemeId, *NewThemeId); AnyDoubt = true; break; } else if ((ThemeId & 0x0f) != 0) //ThemeId is like 1a, 2a, not like 10,20. So it is minor in tree-structure, and it should be labeled in major part of tree @@ -1825,7 +1825,7 @@ int cFilterEEPG::GetThemesNagra (const u_char * Data, int Length, unsigned short Textlength = 63; //leave room for trailing NULL if (Themes[ThemeId][0] != 0) { LogE(0, prep("Trying to add new theme, but Id already exists. ThemeId = %x, Old theme with this Id:%s, new theme: %s."), - ThemeId, Themes[ThemeId], Text); + ThemeId, Themes[ThemeId], Text); continue; } memcpy (&Themes[ThemeId], Text, Textlength); @@ -1876,9 +1876,9 @@ int cFilterEEPG::GetChannelsNagra (const u_char * Data, int Length) cChannel *VC = GetChannelByID(channelID, true); bool IsFound = (VC); if(IsFound) { - strncpy((char*)(C->Name), VC->Name (), 64); - C->Src[0] = VC->Source(); - CleanString (C->Name); + strncpy((char*)(C->Name), VC->Name (), 64); + C->Src[0] = VC->Source(); + CleanString (C->Name); } else C->Name[0] = '\0'; //empty string @@ -1930,7 +1930,7 @@ int cFilterEEPG::GetChannelsNagra (const u_char * Data, int Length) isyslog ("EEPGDEBUG: Always0x81 is NOT 0x81:%x.", Channel->Always0x81); if (Channel->Always0x44 != 0x44) isyslog ("EEPGDEBUG: Always0x44 is NOT 0x44:%x.", Channel->Always0x44); - */ + */ } if (p != DataEnd) @@ -1959,7 +1959,7 @@ int cFilterEEPG::GetNagra (const u_char * Data, int Length) u_char *p = (u_char *) Data + 8; if (*p != 0x01) { LogE(0, prep("Error, Nagra first byte in table_id_extension 0x00 is not 0x01 but %02x. Format unknown, exiting."), - *p); + *p); return 0; //fatal error } p++; //skip 0x01 byte @@ -2008,7 +2008,7 @@ int cFilterEEPG::GetNagra (const u_char * Data, int Length) (0x0810) bouquet info; references to channels within a package, day 1 of the month (0x0820) same day 2 of the month (0x09f0) same day 31 of the month - */ + */ if (!(TBH->TableIdExtensionHigh >= 0x02 && TBH->TableIdExtensionHigh <= 0x07)) //here we regulate which tables we are testing return (1); @@ -2071,7 +2071,7 @@ void cFilterEEPG::ProcessNagra () } if (NumberOfTables != 0) LogE(0, prep("ERROR, Not all tables processed and stream is already repeating. NumberOfTables = %i."), - NumberOfTables); + NumberOfTables); } /** @@ -2321,7 +2321,7 @@ int cFilterEEPG::GetSummariesMHW1 (const u_char * Data, int Length) } //numreplays <10 else { LogE(0, prep("Warning, number of replays %d > 10, cannot process."), - Summary->NumReplays); + Summary->NumReplays); return 1; //nonfatal error } } //length >11 @@ -2716,7 +2716,7 @@ void cFilterEEPG::LoadIntoSchedule (void) Title_t *T; Summary_t *S; int remembersummary; -//keep statistics + //keep statistics int SummariesNotFound = 0; int NoSummary = 0; int NotMatching = 0; @@ -2746,7 +2746,7 @@ void cFilterEEPG::LoadIntoSchedule (void) if (!foundtitle) //no more titles with summaries break; if ((T->EventId == S->EventId) && (T->MjdTime == S->Replays[0].MjdTime) - && ((T->ChannelId == S->Replays[0].ChannelId) || ((Format != SKY_IT) && (Format != SKY_UK)))) { //should always be true, titles and summaries are broadcasted in order... + && ((T->ChannelId == S->Replays[0].ChannelId) || ((Format != SKY_IT) && (Format != SKY_UK)))) { //should always be true, titles and summaries are broadcasted in order... LogD(3, prep("T->EventId == S->EventId")); //MjdTime = 0 for all but SKY //S->ChannelId must be equal to T->ChannelId only for SKY; in MHW1 S->ChannelId overrides T->ChannelId when NumReplays > 1 @@ -2794,8 +2794,8 @@ void cFilterEEPG::LoadIntoSchedule (void) } //while while (index < S->NumReplays); -//TODO: why load events that have already past, and then run Cleanup -//end of putting title and summary in schedule + //TODO: why load events that have already past, and then run Cleanup + //end of putting title and summary in schedule i++; //move to next title } //if T->EventId == S->EventId else { @@ -2811,7 +2811,7 @@ void cFilterEEPG::LoadIntoSchedule (void) //esyslog ("EEPG Error: could not find summary for summary-available Title %d.", i); esyslog ("EEPG: Error, summary not found for EventId %08x Titlenr %d:SummAv:%x,Unknown1:%x,Unknown2:%x,Un3:%x,Name:%s.", - T->EventId, i, T->SummaryAvailable, T->Unknown1, T->Unknown2, T->Unknown3, T->Text); + T->EventId, i, T->SummaryAvailable, T->Unknown1, T->Unknown2, T->Unknown3, T->Text); /* write Title info to schedule */ sChannel *C = &sChannels[ChannelSeq[T->ChannelId]]; //find channel @@ -2851,7 +2851,7 @@ void cFilterEEPG::LoadIntoSchedule (void) esyslog ("EEPG: %i summaries not found", SummariesNotFound); if (NotMatching > nSummaries) LogI (0, prep("Warning: lost sync %i times, summary did not match %i times."), - LostSync, NotMatching); + LostSync, NotMatching); FreeSummaries (); //do NOT free channels, themes and bouquets here because they will be reused in SKY! FreeTitles (); @@ -2885,7 +2885,7 @@ namespace SI DishSeriesDescriptorTag = 0x96, }; - // typedef InheritEnum< DescriptorTagExt, SI::DescriptorTag > ExtendedDescriptorTag; +// typedef InheritEnum< DescriptorTagExt, SI::DescriptorTag > ExtendedDescriptorTag; /*extern const char *getCharacterTable(const unsigned char *&buffer, int &length, bool *isSingleByte = NULL); extern bool convertCharacterTable(const char *from, size_t fromLength, char *to, size_t toLength, const char *fromCode); @@ -2926,13 +2926,13 @@ void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEven newEvent->SetStartTime (pEvent->StartTime()); newEvent->SetDuration (pEvent->Duration()); newEvent->SetVersion (pEvent->Version()); - // newEvent->SetContents(pEvent->Contents()); +// newEvent->SetContents(pEvent->Contents()); newEvent->SetParentalRating(pEvent->ParentalRating()); newEvent->SetVps (pEvent->Vps()); newEvent->SetTitle (pEvent->Title ()); newEvent->SetShortText (pEvent->ShortText ()); newEvent->SetDescription (pEvent->Description ()); - // newEvent->SetComponents (pEvent->Components()); +// newEvent->SetComponents (pEvent->Components()); newEvent->FixEpgBugs (); pSchedule->AddEvent(newEvent); @@ -2947,13 +2947,13 @@ void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEven newEvent->SetStartTime (pEvent->StartTime()); newEvent->SetDuration (pEvent->Duration()); newEvent->SetVersion (pEvent->Version()); -// newEvent->SetContents(pEvent->Contents()); +// newEvent->SetContents(pEvent->Contents()); newEvent->SetParentalRating(pEvent->ParentalRating()); newEvent->SetVps (pEvent->Vps()); newEvent->SetTitle (pEvent->Title ()); newEvent->SetShortText (pEvent->ShortText ()); newEvent->SetDescription (pEvent->Description ()); -// newEvent->SetComponents (pEvent->Components()); +// newEvent->SetComponents (pEvent->Components()); newEvent->FixEpgBugs (); pSchedule->AddEvent(newEvent); @@ -2964,7 +2964,7 @@ void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEven } cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool isEITPid, bool OnlyRunningStatus) - : SI::EIT (Data, false) +: SI::EIT (Data, false) { //LogD(2, prep("cEIT2::cEIT2")); if (Tid > 0 && (Format == DISH_BEV || (SetupPE->ProcessEIT && isEITPid))) Tid--; @@ -3052,7 +3052,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat int LanguagePreferenceShort = -1; SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d; if (I18nIsPreferredLanguage (Setup.EPGLanguages, sed->languageCode, LanguagePreferenceShort) - || !ShortEventDescriptor) { + || !ShortEventDescriptor) { delete ShortEventDescriptor; ShortEventDescriptor = sed; d = NULL; // so that it is not deleted @@ -3062,7 +3062,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat bool UseExtendedEventDescriptor = false; SI::ExtendedEventDescriptor * eed = (SI::ExtendedEventDescriptor *) d; if (I18nIsPreferredLanguage (Setup.EPGLanguages, eed->languageCode, LanguagePreferenceExt) - || !ExtendedEventDescriptors) { + || !ExtendedEventDescriptors) { delete ExtendedEventDescriptors; ExtendedEventDescriptors = new SI::ExtendedEventDescriptors; UseExtendedEventDescriptor = true; @@ -3168,7 +3168,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat case SI::ExtendedEventDescriptorTag: { SI::ExtendedEventDescriptor * eed = (SI::ExtendedEventDescriptor *) d; if (I18nIsPreferredLanguage (Setup.EPGLanguages, eed->languageCode, LanguagePreferenceExt) - || !ExtendedEventDescriptors) { + || !ExtendedEventDescriptors) { delete ExtendedEventDescriptors; ExtendedEventDescriptors = new SI::ExtendedEventDescriptors; UseExtendedEventDescriptor = true; @@ -3184,7 +3184,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat case SI::ShortEventDescriptorTag: { SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d; if (I18nIsPreferredLanguage (Setup.EPGLanguages, sed->languageCode, LanguagePreferenceShort) - || !ShortEventDescriptor) { + || !ShortEventDescriptor) { delete ShortEventDescriptor; ShortEventDescriptor = sed; d = NULL; // so that it is not deleted @@ -3221,7 +3221,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat if (I18nIsPreferredLanguage(Setup.EPGLanguages, Rating.languageCode, LanguagePreferenceRating)) { int ParentalRating = (Rating.getRating() & 0xFF); switch (ParentalRating) { - // values defined by the DVB standard (minimum age = rating + 3 years): + // values defined by the DVB standard (minimum age = rating + 3 years): case 0x01 ... 0x0F: ParentalRating += 3; break; @@ -3284,7 +3284,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat if (ld->getLinkageType () == 0xB0) { // Premiere World time_t now = time (NULL); bool hit = SiEitEvent.getStartTime () <= now - && now < SiEitEvent.getStartTime () + SiEitEvent.getDuration (); + && now < SiEitEvent.getStartTime () + SiEitEvent.getDuration (); if (hit) { char linkName[ld->privateData.getLength () + 1]; strn0cpy (linkName, (const char *) ld->privateData.getData (), sizeof (linkName)); @@ -3301,7 +3301,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat transponder = Channels.GetByTransponderID (linkID); link = Channels.NewChannel (transponder, linkName, "", "", ld->getOriginalNetworkId (), - ld->getTransportStreamId (), ld->getServiceId ()); + ld->getTransportStreamId (), ld->getServiceId ()); } if (link) { if (!LinkChannels) @@ -3324,15 +3324,15 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat Components = new cComponents; char buffer[Utf8BufSize (256)]; Components->SetComponent (Components->NumComponents (), Stream, Type, - I18nNormalizeLanguageCode (cd->languageCode), - cd->description.getText (buffer, sizeof (buffer))); + I18nNormalizeLanguageCode (cd->languageCode), + cd->description.getText (buffer, sizeof (buffer))); } } break; case SI::DishExtendedEventDescriptorTag: { SI::UnimplementedDescriptor *deed = (SI::UnimplementedDescriptor *)d; if (!DishEventDescriptor) { - DishEventDescriptor = new SI::DishDescriptor(); + DishEventDescriptor = new SI::DishDescriptor(); } DishEventDescriptor->setExtendedtData(Tid+1, deed->getData()); HasExternalData = true; @@ -3341,7 +3341,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat case SI::DishShortEventDescriptorTag: { SI::UnimplementedDescriptor *dsed = (SI::UnimplementedDescriptor *)d; if (!DishEventDescriptor) { - DishEventDescriptor = new SI::DishDescriptor(); + DishEventDescriptor = new SI::DishDescriptor(); } DishEventDescriptor->setShortData(Tid+1, dsed->getData()); HasExternalData = true; @@ -3356,7 +3356,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat DishEventDescriptor->setRating(rating); } } - break; + break; case SI::DishSeriesDescriptorTag: { if (d->getLength() == 10) { //LogD(2, prep("DishSeriesDescriptorTag: %s)"), (const char*) d->getData().getData()); @@ -3369,7 +3369,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat // LogD(2, prep("DishSeriesDescriptorTag length: %d)"), d->getLength()); // } } - break; + break; default: break; } @@ -3409,59 +3409,59 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat pEvent->SetDescription (NULL); if (DishEventDescriptor) { - if (DishEventDescriptor->getName()) - pEvent->SetTitle(DishEventDescriptor->getName()); - //LogD(2, prep("channelID: %s DishTitle: %s"), *channel->GetChannelID().ToString(), DishShortEventDescriptor->getText()); -// pEvent->SetDescription(DishExtendedEventDescriptor->getText()); - char *tmp; - string fmt; - fmt = "%s"; - if (0 != strcmp(DishEventDescriptor->getShortText(),"") && DishEventDescriptor->hasTheme()) { - fmt += " - "; - } - fmt += "%s"; - if (DishEventDescriptor->hasTheme() && DishEventDescriptor->hasCategory()) { - fmt += " ~ "; - } - fmt += "%s"; - - Asprintf (&tmp, fmt.c_str(), DishEventDescriptor->getShortText() - , DishEventDescriptor->getTheme() - , DishEventDescriptor->getCategory()); - pEvent->SetShortText(tmp); - //LogD(2, prep("EEPGDEBUG:DishTheme:%x-DishCategory:%x)"), DishTheme, DishCategory); - free(tmp); - - fmt = "%s"; - if (0 != strcmp(DishEventDescriptor->getDescription(),"") - && (0 != strcmp(DishEventDescriptor->getRating(),"") - || 0 != strcmp(DishEventDescriptor->getStarRating(),""))) { - fmt += "\n\nRating: "; - } - fmt += "%s %s"; - if (0 != strcmp(DishEventDescriptor->getProgramId(),"")) { - fmt += "\n\nProgram ID: "; - } - fmt += "%s %s%s"; - time_t orgAirDate = DishEventDescriptor->getOriginalAirDate(); - char datestr [80]; - bool dateok = false; - if (orgAirDate == 0) { - dateok = strftime (datestr,80," Original Air Date: %a %b %d %Y",gmtime(&orgAirDate)) > 0; - } - - Asprintf (&tmp, fmt.c_str(), DishEventDescriptor->getDescription() - , DishEventDescriptor->getRating() - , DishEventDescriptor->getStarRating() - , DishEventDescriptor->getProgramId() - , DishEventDescriptor->getSeriesId() - , orgAirDate == 0 || !dateok ? "" : datestr); - pEvent->SetDescription(tmp); - free(tmp); - - - //LogD(2, prep("DishDescription: %s"), DishExtendedEventDescriptor->getText()); - //LogD(2, prep("DishShortText: %s"), DishExtendedEventDescriptor->getShortText()); + if (DishEventDescriptor->getName()) + pEvent->SetTitle(DishEventDescriptor->getName()); + //LogD(2, prep("channelID: %s DishTitle: %s"), *channel->GetChannelID().ToString(), DishShortEventDescriptor->getText()); + // pEvent->SetDescription(DishExtendedEventDescriptor->getText()); + char *tmp; + string fmt; + fmt = "%s"; + if (0 != strcmp(DishEventDescriptor->getShortText(),"") && DishEventDescriptor->hasTheme()) { + fmt += " - "; + } + fmt += "%s"; + if (DishEventDescriptor->hasTheme() && DishEventDescriptor->hasCategory()) { + fmt += " ~ "; + } + fmt += "%s"; + + Asprintf (&tmp, fmt.c_str(), DishEventDescriptor->getShortText() + , DishEventDescriptor->getTheme() + , DishEventDescriptor->getCategory()); + pEvent->SetShortText(tmp); + //LogD(2, prep("EEPGDEBUG:DishTheme:%x-DishCategory:%x)"), DishTheme, DishCategory); + free(tmp); + + fmt = "%s"; + if (0 != strcmp(DishEventDescriptor->getDescription(),"") + && (0 != strcmp(DishEventDescriptor->getRating(),"") + || 0 != strcmp(DishEventDescriptor->getStarRating(),""))) { + fmt += "\n\nRating: "; + } + fmt += "%s %s"; + if (0 != strcmp(DishEventDescriptor->getProgramId(),"")) { + fmt += "\n\nProgram ID: "; + } + fmt += "%s %s%s"; + time_t orgAirDate = DishEventDescriptor->getOriginalAirDate(); + char datestr [80]; + bool dateok = false; + if (orgAirDate == 0) { + dateok = strftime (datestr,80," Original Air Date: %a %b %d %Y",gmtime(&orgAirDate)) > 0; + } + + Asprintf (&tmp, fmt.c_str(), DishEventDescriptor->getDescription() + , DishEventDescriptor->getRating() + , DishEventDescriptor->getStarRating() + , DishEventDescriptor->getProgramId() + , DishEventDescriptor->getSeriesId() + , orgAirDate == 0 || !dateok ? "" : datestr); + pEvent->SetDescription(tmp); + free(tmp); + + + //LogD(2, prep("DishDescription: %s"), DishExtendedEventDescriptor->getText()); + //LogD(2, prep("DishShortText: %s"), DishExtendedEventDescriptor->getShortText()); } } @@ -3525,7 +3525,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat if (pPreviousEvent->Description ()) len_title_extern = snprintf (buffer_title_extern, sizeof (buffer_title_extern) - 1, "%s", - pPreviousEvent->Description ()); + pPreviousEvent->Description ()); if (len_title_intern > 0) { if (len_title_extern < 1) pPreviousEvent->SetDescription (buffer_title_intern); @@ -3542,7 +3542,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat } } #endif /* DDEPGENTRY */ - updateEquivalent(Schedules, channel->GetChannelID(), pEvent); + updateEquivalent(Schedules, channel->GetChannelID(), pEvent); } if (Empty && Tid == 0x4E && getSectionNumber () == 0) // ETR 211: an empty entry in section 0 of table 0x4E means there is currently no event running @@ -3612,9 +3612,9 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) // Enable EIT scan for all except DISH_BEV since it is already enabled if (SetupPE->ProcessEIT && !UnprocessedFormat[EIT] - && !UnprocessedFormat[FREEVIEW] && !UnprocessedFormat[DISH_BEV]) { - UnprocessedFormat[EIT] = EIT_PID; - loadEquivalentChannelMap(); + && !UnprocessedFormat[FREEVIEW] && !UnprocessedFormat[DISH_BEV]) { + UnprocessedFormat[EIT] = EIT_PID; + loadEquivalentChannelMap(); } //now start looking for next format to process @@ -3690,27 +3690,27 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) void cFilterEEPG::ProccessContinuous(u_short Pid, u_char Tid, int Length, const u_char *Data) { - //0x39 Viasat, 0x0300 Dish Network EEPG, 0x0441 Bell ExpressVU EEPG - LogD(4, prep("Pid: 0x%02x Tid: %d Length: %d"), Pid, Tid, Length); - cSchedulesLock SchedulesLock(true, 10); + //0x39 Viasat, 0x0300 Dish Network EEPG, 0x0441 Bell ExpressVU EEPG + LogD(4, prep("Pid: 0x%02x Tid: %d Length: %d"), Pid, Tid, Length); + cSchedulesLock SchedulesLock(true, 10); + cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); + //Look for other satelite positions only if Dish/Bell ExpressVU for the moment hardcoded pid check + if(Schedules) + SI::cEIT2 EIT(Schedules, Source(), Tid, Data, Pid == EIT_PID); + + else//cEIT EIT (Schedules, Source (), Tid, Data); + { + // If we don't get a write lock, let's at least get a read lock, so + // that we can set the running status and 'seen' timestamp (well, actually + // with a read lock we shouldn't be doing that, but it's only integers that + // get changed, so it should be ok) + cSchedulesLock SchedulesLock; cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); - //Look for other satelite positions only if Dish/Bell ExpressVU for the moment hardcoded pid check if(Schedules) - SI::cEIT2 EIT(Schedules, Source(), Tid, Data, Pid == EIT_PID); + SI::cEIT2 EIT(Schedules, Source(), Tid, Data, Pid == EIT_PID, true); - else//cEIT EIT (Schedules, Source (), Tid, Data); - { - // If we don't get a write lock, let's at least get a read lock, so - // that we can set the running status and 'seen' timestamp (well, actually - // with a read lock we shouldn't be doing that, but it's only integers that - // get changed, so it should be ok) - cSchedulesLock SchedulesLock; - cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); - if(Schedules) - SI::cEIT2 EIT(Schedules, Source(), Tid, Data, Pid == EIT_PID, true); - - //cEIT EIT (Schedules, Source (), Tid, Data, true); - } + //cEIT EIT (Schedules, Source (), Tid, Data, true); + } } void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Length) @@ -3773,7 +3773,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len } //Format = 0; // 0 = premiere, 1 = MHW1, 2 = MHW2, 3 = Sky Italy (OpenTV), 4 = Sky UK (OpenTV), 5 = Freesat (Freeview), 6 = Nagraguide SI::Descriptor * d; - unsigned char nDescriptorTag; + unsigned char nDescriptorTag; for (SI::Loop::Iterator it; (d = stream.streamDescriptors.getNext (it));) { LogD(4, prep("EEPGDEBUG:d->getDescriptorTAG():%x,SI::PrivateTag:%x\n"), d->getDescriptorTag (), SI::PrivateDataSpecifierDescriptorTag); nDescriptorTag = d->getDescriptorTag (); @@ -3850,7 +3850,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len if (((Source() == cSource::FromString("S119.0W") && Transponder() == cChannel::Transponder(12472,'H')) || (Source() == cSource::FromString("S91.0W") - && Transponder() == cChannel::Transponder(12224,'R'))) + && Transponder() == cChannel::Transponder(12224,'R'))) && !UnprocessedFormat[DISH_BEV]) { UnprocessedFormat[DISH_BEV] = stream.getPid (); } @@ -4131,7 +4131,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) { time_t firstTime = 0; SI::Descriptor * d; - unsigned char nDescriptorTag; + unsigned char nDescriptorTag; bool UseExtendedEventDescriptor = false; int LanguagePreferenceShort = -1; int LanguagePreferenceExt = -1; @@ -4197,7 +4197,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) case SI::ExtendedEventDescriptorTag: { SI::ExtendedEventDescriptor * eed = (SI::ExtendedEventDescriptor *) d; if (I18nIsPreferredLanguage (Setup.EPGLanguages, eed->languageCode, LanguagePreferenceExt) - || !ExtendedEventDescriptors) { + || !ExtendedEventDescriptors) { delete ExtendedEventDescriptors; ExtendedEventDescriptors = new SI::ExtendedEventDescriptors; UseExtendedEventDescriptor = true; @@ -4213,7 +4213,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) case SI::ShortEventDescriptorTag: { SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d; if (I18nIsPreferredLanguage (Setup.EPGLanguages, sed->languageCode, LanguagePreferenceShort) - || !ShortEventDescriptor) { + || !ShortEventDescriptor) { delete ShortEventDescriptor; ShortEventDescriptor = sed; d = NULL; // so that it is not deleted @@ -4234,10 +4234,10 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) crc[0] = cit.getContentId (); SI::PremiereContentTransmissionDescriptor * pct; for (SI::Loop::Iterator it; - (pct = - (SI::PremiereContentTransmissionDescriptor *) cit.eventDescriptors.getNext (it, - SI:: - PremiereContentTransmissionDescriptorTag));) { + (pct = + (SI::PremiereContentTransmissionDescriptor *) cit.eventDescriptors.getNext (it, + SI:: + PremiereContentTransmissionDescriptorTag));) { int nid = pct->getOriginalNetworkId (); int tid = pct->getTransportStreamId (); int sid = pct->getServiceId (); @@ -4287,12 +4287,10 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) for (SI::Loop::Iterator it2; sd.startTimeLoop.getNext (st, it2);) { time_t StartTime = st.getStartTime (mjd); time_t EndTime = StartTime + cit.getDuration (); - int runningStatus = (StartTime < now - && now < EndTime) ? SI::RunningStatusRunning : ((StartTime - 30 < now - && now < - StartTime) ? SI:: - RunningStatusStartsInAFewSeconds - : SI::RunningStatusNotRunning); + int runningStatus = + (StartTime < now && now < EndTime) ? SI::RunningStatusRunning : + ((StartTime - 30 < now && now < StartTime) ? + SI::RunningStatusStartsInAFewSeconds : SI::RunningStatusNotRunning); bool isOpt = false; if (index++ == 0 && nCount > 1) isOpt = true; @@ -4348,7 +4346,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) } if (order || rating) { int len = (pEvent->Description ()? strlen (pEvent->Description ()) : 0) + - (order ? strlen (order) : 0) + (rating ? strlen (rating) : 0); + (order ? strlen (order) : 0) + (rating ? strlen (rating) : 0); char buffer[len + 32]; buffer[0] = 0; if (pEvent->Description ()) @@ -4521,10 +4519,10 @@ void cPluginEEPG::Stop (void) free (ConfDir); } if (sky_tables[0]) { - free(sky_tables[0]); + free(sky_tables[0]); } if (sky_tables[1]) { - free(sky_tables[1]); + free(sky_tables[1]); } } -- cgit v1.2.3 From 4ce3841972c23d31a1dfb64f068ceeb6e8d35cd9 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Thu, 17 May 2012 14:15:55 +0200 Subject: removed EIT filter for NA since it should be done by epg-handler modified indentation --- eepg.c | 2 + epghandler.c | 132 +++++++++++++++++++++++++++++------------------------------ epghandler.h | 38 ++++++++--------- 3 files changed, 87 insertions(+), 85 deletions(-) diff --git a/eepg.c b/eepg.c index 80ad23f..fac41e5 100644 --- a/eepg.c +++ b/eepg.c @@ -3672,7 +3672,9 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) AddFilter (pid, 0xb0); //perhaps TID is equal to first data byte? break; case DISH_BEV: +#if APIVERSNUM < 10726 AddFilter (EIT_PID, 0, 0); // event info, actual(0x4e)/other(0x4f) TS, present/following +#endif AddFilter (0x0300, 0, 0); // Dish Network EEPG event info, actual(0x4e)/other(0x4f) TS, present/following AddFilter (0x0441, 0, 0); // Dish Network EEPG event info, actual(0x4e)/other(0x4f) TS, present/following // AddFilter (0x0441, 0x50, 0xf0); // Bell ExpressVU EEPG diff --git a/epghandler.c b/epghandler.c index 36aaf74..29f092b 100644 --- a/epghandler.c +++ b/epghandler.c @@ -5,122 +5,122 @@ * Author: d.petrovski */ -#if APIVERSNUM > 10725 #include "epghandler.h" +#if APIVERSNUM > 10725 #include "log.h" cEEpgHandler::cEEpgHandler() { - // TODO Auto-generated constructor stub - LogD(4, prep("cEEpgHandler()")); + // TODO Auto-generated constructor stub + LogD(4, prep("cEEpgHandler()")); } cEEpgHandler::~cEEpgHandler() { - // TODO Auto-generated destructor stub + // TODO Auto-generated destructor stub } bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, - const SI::EIT::Event* EitEvent, uchar TableID, uchar Version) { - //LogD(1, prep("HandleEitEvent")); - return false; -// return true; + const SI::EIT::Event* EitEvent, uchar TableID, uchar Version) { + //LogD(1, prep("HandleEitEvent")); + return false; + // return true; } bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) { - Event->SetEventID(EventID); - return true; + Event->SetEventID(EventID); + return true; } bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { - LogD(3, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title); + LogD(3, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title); - if (!Event->Title() || Title && (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title)))) - Event->SetTitle(Title); - return true; + if (!Event->Title() || Title && (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title)))) + Event->SetTitle(Title); + return true; } bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) { - LogD(3, prep("Event id:%d ShortText:%s new ShortText:%s"), Event->EventID(), Event->ShortText(), ShortText); - - if (Event->ShortText() && strcmp(Event->ShortText(),"") != 0) { - origShortText = std::string(Event->ShortText()); - } - else { - origShortText.clear(); - } - - //if (!Event->ShortText() || ShortText && (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText)))) - Event->SetShortText(ShortText); - return true; + LogD(3, prep("Event id:%d ShortText:%s new ShortText:%s"), Event->EventID(), Event->ShortText(), ShortText); + + if (Event->ShortText() && strcmp(Event->ShortText(),"") != 0) { + origShortText = std::string(Event->ShortText()); + } + else { + origShortText.clear(); + } + + //if (!Event->ShortText() || ShortText && (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText)))) + Event->SetShortText(ShortText); + return true; } bool cEEpgHandler::SetDescription(cEvent* Event, const char* Description) { - LogD(3, prep("Event id:%d Description:%s new Description:%s"), Event->EventID(), Event->Description(), Description); - - if (Event->Description() && strcmp(Event->Description(),"") != 0) - origDescription = Event->Description(); - else - origDescription.clear(); - - //if (!Event->Description() || Description && (!strcmp(Event->Description(),"") || (strcmp(Description,"") && strcmp(Event->Description(),Description)))) - Event->SetDescription(Description); - return true; + LogD(3, prep("Event id:%d Description:%s new Description:%s"), Event->EventID(), Event->Description(), Description); + + if (Event->Description() && strcmp(Event->Description(),"") != 0) + origDescription = Event->Description(); + else + origDescription.clear(); + + //if (!Event->Description() || Description && (!strcmp(Event->Description(),"") || (strcmp(Description,"") && strcmp(Event->Description(),Description)))) + Event->SetDescription(Description); + return true; } bool cEEpgHandler::SetContents(cEvent* Event, uchar* Contents) { - Event->SetContents(Contents); - return true; + Event->SetContents(Contents); + return true; } bool cEEpgHandler::SetParentalRating(cEvent* Event, int ParentalRating) { - Event->SetParentalRating(ParentalRating); - return true; + Event->SetParentalRating(ParentalRating); + return true; } bool cEEpgHandler::SetStartTime(cEvent* Event, time_t StartTime) { - Event->SetStartTime(StartTime); - return true; + Event->SetStartTime(StartTime); + return true; } bool cEEpgHandler::SetDuration(cEvent* Event, int Duration) { - Event->SetDuration(Duration); - return true; + Event->SetDuration(Duration); + return true; } bool cEEpgHandler::SetVps(cEvent* Event, time_t Vps) { - Event->SetVps(Vps); - return true; + Event->SetVps(Vps); + return true; } bool cEEpgHandler::HandleEvent(cEvent* Event) { - - LogD(3, prep("HandleEvent st:%s ost:%s desc:%s odesc:%s"),Event->ShortText(),origShortText.c_str(),Event->Description(),origDescription.c_str()); - - //After FixEpgBugs of cEvent set the original Short Text if empty - if (!Event->ShortText() || !strcmp(Event->ShortText(),"")) - Event->SetShortText(origShortText.c_str()); - - if (!Event->Description() && !origDescription.empty()) { - Event->SetDescription(origDescription.c_str()); - } - //TODO just to see the difference - //else if (!origDescription.empty() && !origDescription.compare(Event->Description())) { -// origDescription.append(" | EIT: "); -// origDescription.append(Event->Description()); -// Event->SetDescription(origDescription.c_str()); + + LogD(3, prep("HandleEvent st:%s ost:%s desc:%s odesc:%s"),Event->ShortText(),origShortText.c_str(),Event->Description(),origDescription.c_str()); + + //After FixEpgBugs of cEvent set the original Short Text if empty + if (!Event->ShortText() || !strcmp(Event->ShortText(),"")) + Event->SetShortText(origShortText.c_str()); + + if (!Event->Description() && !origDescription.empty()) { + Event->SetDescription(origDescription.c_str()); + } + //TODO just to see the difference + //else if (!origDescription.empty() && !origDescription.compare(Event->Description())) { + // origDescription.append(" | EIT: "); + // origDescription.append(Event->Description()); + // Event->SetDescription(origDescription.c_str()); // } - return true; + return true; } bool cEEpgHandler::SortSchedule(cSchedule* Schedule) { - Schedule->Sort(); - return true; + Schedule->Sort(); + return true; } bool cEEpgHandler::DropOutdated(cSchedule* Schedule, time_t SegmentStart, - time_t SegmentEnd, uchar TableID, uchar Version) { - return false; + time_t SegmentEnd, uchar TableID, uchar Version) { + return false; } #endif diff --git a/epghandler.h b/epghandler.h index 8d3615a..16dbca3 100644 --- a/epghandler.h +++ b/epghandler.h @@ -13,27 +13,27 @@ class cEEpgHandler : public cEpgHandler { public: - cEEpgHandler(); - virtual ~cEEpgHandler(); - virtual bool IgnoreChannel(const cChannel *Channel) { return false; } - virtual bool HandleEitEvent(cSchedule *Schedule, const SI::EIT::Event *EitEvent, uchar TableID, uchar Version); - virtual bool SetEventID(cEvent *Event, tEventID EventID); - virtual bool SetTitle(cEvent *Event, const char *Title); - virtual bool SetShortText(cEvent *Event, const char *ShortText); - virtual bool SetDescription(cEvent *Event, const char *Description); - virtual bool SetContents(cEvent *Event, uchar *Contents); - virtual bool SetParentalRating(cEvent *Event, int ParentalRating); - virtual bool SetStartTime(cEvent *Event, time_t StartTime); - virtual bool SetDuration(cEvent *Event, int Duration); - virtual bool SetVps(cEvent *Event, time_t Vps); - virtual bool FixEpgBugs(cEvent *Event) { return false; } - virtual bool HandleEvent(cEvent *Event); - virtual bool SortSchedule(cSchedule *Schedule); - virtual bool DropOutdated(cSchedule *Schedule, time_t SegmentStart, time_t SegmentEnd, uchar TableID, uchar Version); + cEEpgHandler(); + virtual ~cEEpgHandler(); + virtual bool IgnoreChannel(const cChannel *Channel) { return false; } + virtual bool HandleEitEvent(cSchedule *Schedule, const SI::EIT::Event *EitEvent, uchar TableID, uchar Version); + virtual bool SetEventID(cEvent *Event, tEventID EventID); + virtual bool SetTitle(cEvent *Event, const char *Title); + virtual bool SetShortText(cEvent *Event, const char *ShortText); + virtual bool SetDescription(cEvent *Event, const char *Description); + virtual bool SetContents(cEvent *Event, uchar *Contents); + virtual bool SetParentalRating(cEvent *Event, int ParentalRating); + virtual bool SetStartTime(cEvent *Event, time_t StartTime); + virtual bool SetDuration(cEvent *Event, int Duration); + virtual bool SetVps(cEvent *Event, time_t Vps); + virtual bool FixEpgBugs(cEvent *Event) { return false; } + virtual bool HandleEvent(cEvent *Event); + virtual bool SortSchedule(cSchedule *Schedule); + virtual bool DropOutdated(cSchedule *Schedule, time_t SegmentStart, time_t SegmentEnd, uchar TableID, uchar Version); private: - std::string origShortText; - std::string origDescription; + std::string origShortText; + std::string origDescription; }; #endif /*APIVERSNUM > 10725*/ -- cgit v1.2.3 From f45501c9a660c888b2fecccbc66249c38a7d40ed Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Thu, 17 May 2012 20:36:31 +0200 Subject: added include for APIVERSNUM --- eepg.c | 2 ++ epghandler.h | 1 + 2 files changed, 3 insertions(+) diff --git a/eepg.c b/eepg.c index fac41e5..1b7c0a2 100644 --- a/eepg.c +++ b/eepg.c @@ -38,7 +38,9 @@ #include #include "eepg.h" #include "dish.h" +#if APIVERSNUM > 10725 #include "epghandler.h" +#endif #include "log.h" #include "setupeepg.h" diff --git a/epghandler.h b/epghandler.h index 16dbca3..61f295b 100644 --- a/epghandler.h +++ b/epghandler.h @@ -7,6 +7,7 @@ #ifndef CEEPGHANDLER_H_ #define CEEPGHANDLER_H_ +#include #if APIVERSNUM > 10725 #include #include -- cgit v1.2.3 From 8f360572204b983ee963678359498a0ad2b8848a Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Fri, 18 May 2012 16:53:52 +0200 Subject: use equivalents map for all equivalents --- eepg.c | 466 +++++++++++++++++++++++++++++++++++------------------------------ eepg.h | 12 +- 2 files changed, 257 insertions(+), 221 deletions(-) diff --git a/eepg.c b/eepg.c index 1b7c0a2..d5de0d8 100644 --- a/eepg.c +++ b/eepg.c @@ -261,14 +261,13 @@ protected: virtual int GetSummariesMHW2 (const u_char * Data, int Length); virtual void FreeSummaries (void); virtual void FreeTitles (void); - virtual void PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]); //gets a channel and returns an array of schedules that WriteToSchedule can write to. Call this routine before a batch of titles with the same ChannelId will be WriteToScheduled; batchsize can be 1 - virtual void FinishWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]); - virtual void WriteToSchedule (cSchedule * ps[MAX_EQUIVALENCES], unsigned short int NumberOfEquivalences, - unsigned int EventId, unsigned int StartTime, unsigned int Duration, char *Text, - char *SummText, unsigned short int ThemeId, unsigned short int TableId, - unsigned short int Version, char Rating = 0x00); + virtual void PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps/*[MAX_EQUIVALENCES]*/); //gets a channel and returns an array of schedules that WriteToSchedule can write to. Call this routine before a batch of titles with the same ChannelId will be WriteToScheduled; batchsize can be 1 + //virtual void FinishWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]); + virtual void WriteToSchedule (cSchedule * ps, cSchedules* s, unsigned int EventId, unsigned int StartTime, + unsigned int Duration, char *Text, char *SummText, unsigned short int ThemeId, + unsigned short int TableId, unsigned short int Version, char Rating = 0x00); virtual void LoadIntoSchedule (void); - virtual void LoadEquivalentChannels (void); + //virtual void LoadEquivalentChannels (void); void ProcessPremiere(const u_char *& Data); public: @@ -1084,90 +1083,182 @@ void loadEquivalentChannelMap (void) LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); } //if file } -void cFilterEEPG::LoadEquivalentChannels (void) -{ - char Buffer[1024]; - char *Line; - FILE *File; - string FileName = string(ConfDir) + "/" + EEPG_FILE_EQUIV; - File = fopen (FileName.c_str(), "r"); - if (File) { - memset (Buffer, 0, sizeof (Buffer)); - char origChanID[256]; - char equiChanID[256]; - char source[256]; - int nid; - int tid; - int sid; - int rid; - while ((Line = fgets (Buffer, sizeof (Buffer), File)) != NULL) { - Line = compactspace (skipspace (stripspace (Line))); - if (!isempty (Line)) { - if (sscanf (Line, "%[^ ] %[^ ] %[^\n]\n", origChanID, equiChanID, source) == 3) { - if (origChanID[0] != '#' && origChanID[0] != ';') { - nid = 0; - tid = 0; - sid = 0; - rid = 0; - if (sscanf (origChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) - if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { - if (sscanf (origChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) != 5) { - rid = 0; - } - tChannelID OriginalChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); - bool found = false; - int i = 0; - sChannel *C = NULL; - while (i < nChannels && (!found)) { - C = &sChannels[i]; - if (C->Src[0] == (unsigned int)cSource::FromString (source) && C->Nid[0] == nid - && C->Tid[0] == tid && C->Sid[0] == sid) - found = true; - else - i++; - } - if (!found) { - LogI(2, prep("Warning: in equivalence file, cannot find original channel %s. Perhaps you are tuned to another transponder right now."), - origChanID); - } else { - cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); - if (!OriginalChannel) - LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalence is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? - if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { - if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) - != 5) { - rid = 0; - } - tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); - cChannel *EquivChannel = Channels.GetByChannelID (EquivChID, false); //TODO use valid function? - if (EquivChannel) { - if (C->NumberOfEquivalences < MAX_EQUIVALENCES) { - C->Src[C->NumberOfEquivalences] = EquivChannel->Source (); - C->Nid[C->NumberOfEquivalences] = EquivChannel->Nid (); - C->Tid[C->NumberOfEquivalences] = EquivChannel->Tid (); - C->Sid[C->NumberOfEquivalences] = EquivChannel->Sid (); - C->NumberOfEquivalences++; - nEquivChannels++; - LogI(3, prep("Added equivalent nr %i with Channel Id %s-%i-%i-%i to channel with id %i."), - C->NumberOfEquivalences, *cSource::ToString (C->Src[C->NumberOfEquivalences - 1]), - C->Nid[C->NumberOfEquivalences - 1], C->Tid[C->NumberOfEquivalences - 1], - C->Sid[C->NumberOfEquivalences - 1], i); - } else - LogE(0, prep("Error, channel with id %i has more than %i equivalences. Increase MAX_EQUIVALENCES."), - i, MAX_EQUIVALENCES); - } else - LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); - } - } //else !found - } //if scanf string1 - } //if string1 - } //if scanf - } //if isempty - } //while - fclose (File); - } //if file -} //end of loadequiv +void updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent){ + multimap::iterator it; + pair::iterator,multimap::iterator> ret; + + LogD(3, prep("Start updateEquivalent %s"), *channelID.ToString()); + + ret = equiChanMap.equal_range(*channelID.ToString()); + for (it=ret.first; it!=ret.second; ++it) { + LogD(1, prep("equivalent channel exists")); + tChannelID equChannelID (tChannelID::FromString((*it).second.c_str())); + cChannel *equChannel = GetChannelByID (equChannelID, false); + if (equChannel) { + LogD(3, prep("found Equivalent channel %s"), *equChannelID.ToString()); + cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (equChannel, true); + cEvent *pEqvEvent = (cEvent *) pSchedule->GetEvent (pEvent->EventID(), pEvent->StartTime()); + if (pEqvEvent) { + LogD(1, prep("equivalent event exists")); + if (pEqvEvent == pEvent) { + LogD(1, prep("equal event exists")); + + } else { + LogD(1, prep("remove equivalent")); + pSchedule->DelEvent(pEqvEvent); + cEvent* newEvent = new cEvent (pEvent->EventID()); + newEvent->SetTableID (pEvent->TableID()); + newEvent->SetStartTime (pEvent->StartTime()); + newEvent->SetDuration (pEvent->Duration()); + newEvent->SetVersion (pEvent->Version()); +// newEvent->SetContents(pEvent->Contents()); + newEvent->SetParentalRating(pEvent->ParentalRating()); + newEvent->SetVps (pEvent->Vps()); + newEvent->SetTitle (pEvent->Title ()); + newEvent->SetShortText (pEvent->ShortText ()); + newEvent->SetDescription (pEvent->Description ()); +// newEvent->SetComponents (pEvent->Components()); + newEvent->FixEpgBugs (); + + pSchedule->AddEvent(newEvent); + + } + + } else { + LogD(1, prep("equivalent event does not exist")); + cEvent* newEvent = new cEvent (pEvent->EventID()); + newEvent->SetTableID (pEvent->TableID()); + newEvent->SetStartTime (pEvent->StartTime()); + newEvent->SetDuration (pEvent->Duration()); + newEvent->SetVersion (pEvent->Version()); +// newEvent->SetContents(pEvent->Contents()); + newEvent->SetParentalRating(pEvent->ParentalRating()); + newEvent->SetVps (pEvent->Vps()); + newEvent->SetTitle (pEvent->Title ()); + newEvent->SetShortText (pEvent->ShortText ()); + newEvent->SetDescription (pEvent->Description ()); +// newEvent->SetComponents (pEvent->Components()); + newEvent->FixEpgBugs (); + + pSchedule->AddEvent(newEvent); + + } + } + } +} + +void sortSchedules(cSchedules * Schedules, tChannelID channelID){ + multimap::iterator it; + pair::iterator,multimap::iterator> ret; + + LogD(3, prep("Start sortEquivalent %s"), *channelID.ToString()); + + cChannel *pChannel = GetChannelByID (channelID, false); + cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (pChannel, true); + pSchedule->Sort (); + Schedules->SetModified (pSchedule); + + ret = equiChanMap.equal_range(*channelID.ToString()); + for (it=ret.first; it!=ret.second; ++it) { + LogD(3, prep("equivalent channel exists")); + tChannelID equChannelID (tChannelID::FromString((*it).second.c_str())); + pChannel = GetChannelByID (equChannelID, false); + if (pChannel) { + LogD(3, prep("found Equivalent channel %s"), *equChannelID.ToString()); + pSchedule = (cSchedule *) Schedules->GetSchedule (pChannel, true); + + pSchedule->Sort (); + Schedules->SetModified (pSchedule); + } + } +} + + +//void cFilterEEPG::LoadEquivalentChannels (void) +//{ +// char Buffer[1024]; +// char *Line; +// FILE *File; +// string FileName = string(ConfDir) + "/" + EEPG_FILE_EQUIV; +// +// File = fopen (FileName.c_str(), "r"); +// if (File) { +// memset (Buffer, 0, sizeof (Buffer)); +// char origChanID[256]; +// char equiChanID[256]; +// char source[256]; +// int nid; +// int tid; +// int sid; +// int rid; +// while ((Line = fgets (Buffer, sizeof (Buffer), File)) != NULL) { +// Line = compactspace (skipspace (stripspace (Line))); +// if (!isempty (Line)) { +// if (sscanf (Line, "%[^ ] %[^ ] %[^\n]\n", origChanID, equiChanID, source) == 3) { +// if (origChanID[0] != '#' && origChanID[0] != ';') { +// nid = 0; +// tid = 0; +// sid = 0; +// rid = 0; +// if (sscanf (origChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) +// if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { +// if (sscanf (origChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) != 5) { +// rid = 0; +// } +// tChannelID OriginalChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); +// bool found = false; +// int i = 0; +// sChannel *C = NULL; +// while (i < nChannels && (!found)) { +// C = &sChannels[i]; +// if (C->Src[0] == (unsigned int)cSource::FromString (source) && C->Nid[0] == nid +// && C->Tid[0] == tid && C->Sid[0] == sid) +// found = true; +// else +// i++; +// } +// if (!found) { +// LogI(2, prep("Warning: in equivalence file, cannot find original channel %s. Perhaps you are tuned to another transponder right now."), +// origChanID); +// } else { +// cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); +// if (!OriginalChannel) +// LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalence is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? +// if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { +// if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) +// != 5) { +// rid = 0; +// } +// tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); +// cChannel *EquivChannel = Channels.GetByChannelID (EquivChID, false); //TODO use valid function? +// if (EquivChannel) { +// if (C->NumberOfEquivalences < MAX_EQUIVALENCES) { +// C->Src[C->NumberOfEquivalences] = EquivChannel->Source (); +// C->Nid[C->NumberOfEquivalences] = EquivChannel->Nid (); +// C->Tid[C->NumberOfEquivalences] = EquivChannel->Tid (); +// C->Sid[C->NumberOfEquivalences] = EquivChannel->Sid (); +// C->NumberOfEquivalences++; +// nEquivChannels++; +// LogI(3, prep("Added equivalent nr %i with Channel Id %s-%i-%i-%i to channel with id %i."), +// C->NumberOfEquivalences, *cSource::ToString (C->Src[C->NumberOfEquivalences - 1]), +// C->Nid[C->NumberOfEquivalences - 1], C->Tid[C->NumberOfEquivalences - 1], +// C->Sid[C->NumberOfEquivalences - 1], i); +// } else +// LogE(0, prep("Error, channel with id %i has more than %i equivalences. Increase MAX_EQUIVALENCES."), +// i, MAX_EQUIVALENCES); +// } else +// LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); +// } +// } //else !found +// } //if scanf string1 +// } //if string1 +// } //if scanf +// } //if isempty +// } //while +// fclose (File); +// } //if file +//} //end of loadequiv //end of loadequiv @@ -1231,27 +1322,28 @@ int cFilterEEPG::GetChannelsMHW (const u_char * Data, int Length, int MHW) //memcpy (C->Name, &Data[pName + 1], 256); pName += (lenName + 1); } - C->NumberOfEquivalences = 1; //there is always an original channel. every equivalence adds 1 - C->Src[0] = Source (); //assume all EPG channels are on same satellite, if not, manage this via equivalents!!! - C->Nid[0] = HILO16 (Channel->NetworkId); - C->Tid[0] = HILO16 (Channel->TransportId); - C->Sid[0] = HILO16 (Channel->ServiceId); - tChannelID channelID = tChannelID (C->Src[0], C->Nid[0], C->Tid[0], C->Sid[0]); + //C->NumberOfEquivalences = 1; //there is always an original channel. every equivalence adds 1 + C->Src = Source (); //assume all EPG channels are on same satellite, if not, manage this via equivalents!!! + C->Nid = HILO16 (Channel->NetworkId); + C->Tid = HILO16 (Channel->TransportId); + C->Sid = HILO16 (Channel->ServiceId); + tChannelID channelID = tChannelID (C->Src, C->Nid, C->Tid, C->Sid); cChannel *VC = GetChannelByID(channelID, true); bool IsFound = (VC); if(IsFound) { - C->Src[0] = VC->Source(); + C->Src = VC->Source(); } CleanString (C->Name); LogI(1, "|% 5d | %-26.26s | %-22.22s | %-3.3s | % 6d |\n", C->ChannelId - , *tChannelID (C->Src[0], C->Nid[0], C->Tid[0], C->Sid[0]).ToString() + , *tChannelID (C->Src, C->Nid, C->Tid, C->Sid).ToString() , C->Name, IsFound ? "YES" : "NO", C->SkyNumber); Off += Size; } //for loop } //else nChannels > MAX_CHANNELS - LoadEquivalentChannels (); + //LoadEquivalentChannels (); + loadEquivalentChannelMap(); GetLocalTimeOffset (); //reread timing variables, only used for MHW return 2; //obviously, when you get here, channels are read successfully, but since all channels are sent at once, you can stop now } //if nChannels == 0 @@ -1518,32 +1610,32 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse * \param s VDR epg schedules * \param ps pointer to the schedules that WriteToSchedule can write to */ -void cFilterEEPG::PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]) +void cFilterEEPG::PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps/*[MAX_EQUIVALENCES]*/) { - for (int eq = 0; eq < C->NumberOfEquivalences; eq++) { - tChannelID channelID = tChannelID (C->Src[eq], C->Nid[eq], C->Tid[eq], C->Sid[eq]); + //for (int eq = 0; eq < C->NumberOfEquivalences; eq++) { + tChannelID channelID = tChannelID (C->Src/*[eq]*/, C->Nid/*[eq]*/, C->Tid/*[eq]*/, C->Sid/*[eq]*/); #ifdef USE_NOEPG if (allowedEPG (channelID) && (channelID.Valid ())) #else if (channelID.Valid ()) //only add channels that are known to vdr #endif /* NOEPG */ - ps[eq] = s->AddSchedule (channelID); //open a a schedule for each equivalent channel + ps/*[eq]*/ = s->AddSchedule (channelID); //open a a schedule for each equivalent channel else { - ps[eq] = NULL; - LogE(5, prep("ERROR: Title block has invalid (equivalent) channel ID: Equivalence: %i, Source:%x, C->Nid:%x,C->Tid:%x,C->Sid:%x."), - eq, C->Src[eq], C->Nid[eq], C->Tid[eq], C->Sid[eq]); + ps/*[eq]*/ = NULL; +// LogE(5, prep("ERROR: Title block has invalid (equivalent) channel ID: Equivalence: %i, Source:%x, C->Nid:%x,C->Tid:%x,C->Sid:%x."), +// eq, C->Src[eq], C->Nid[eq], C->Tid[eq], C->Sid[eq]); } - } + //} } -void cFilterEEPG::FinishWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]) -{ - for (int eq = 0; eq < C->NumberOfEquivalences; eq++) - if (ps[eq]) { - ps[eq]->Sort (); - s->SetModified (ps[eq]); - } -} +//void cFilterEEPG::FinishWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]) +//{ +// for (int eq = 0; eq < C->NumberOfEquivalences; eq++) +// if (ps[eq]) { +// ps[eq]->Sort (); +// s->SetModified (ps[eq]); +// } +//} /** * \brief write event to schedule @@ -1551,20 +1643,20 @@ void cFilterEEPG::FinishWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * \param Duration the Duration of the event in minutes * \param ps points to array of schedules ps[eq], where eq is equivalence number of the channel. If channelId is invalid then ps[eq]=NULL */ -void cFilterEEPG::WriteToSchedule (cSchedule * ps[MAX_EQUIVALENCES], unsigned short int NumberOfEquivalences, unsigned int EventId, unsigned int StartTime, unsigned int Duration, char *Text, char *SummText, unsigned short int ThemeId, unsigned short int TableId, unsigned short int Version, char Rating) +void cFilterEEPG::WriteToSchedule (cSchedule * ps, cSchedules* pSchedules, unsigned int EventId, unsigned int StartTime, unsigned int Duration, char *Text, char *SummText, unsigned short int ThemeId, unsigned short int TableId, unsigned short int Version, char Rating) { bool WrittenTitle = false; bool WrittenSummary = false; - for (int eq = 0; eq < NumberOfEquivalences; eq++) { - if (ps[eq]) { +// for (int eq = 0; eq < NumberOfEquivalences; eq++) { +// if (ps[eq]) { cEvent *Event = NULL; - Event = (cEvent *) ps[eq]->GetEvent (EventId); //since Nagra uses consistent EventIds, try this first + Event = (cEvent *) ps->GetEvent (EventId); //since Nagra uses consistent EventIds, try this first bool TableIdMatches = false; if (Event) TableIdMatches = (Event->TableID() == TableId); if (!Event || !TableIdMatches || abs(Event->StartTime() - (time_t) StartTime) > Duration * 60) //if EventId does not match, or it matched with wrong TableId, then try with StartTime - Event = (cEvent *) ps[eq]->GetEvent (EventId, StartTime); + Event = (cEvent *) ps->GetEvent (EventId, StartTime); cEvent *newEvent = NULL; if (!Event) { //event is new @@ -1602,7 +1694,10 @@ void cFilterEEPG::WriteToSchedule (cSchedule * ps[MAX_EQUIVALENCES], unsigned sh } free (tmp); if (newEvent) - ps[eq]->AddEvent (newEvent); + ps->AddEvent (newEvent); + + updateEquivalent(pSchedules,ps->channelID, Event); + //newEvent->FixEpgBugs (); causes segfault } /* else @@ -1616,8 +1711,8 @@ void cFilterEEPG::WriteToSchedule (cSchedule * ps[MAX_EQUIVALENCES], unsigned sh isyslog ("D %s\n", SummText); isyslog ("e\nc\n.\n"); } - } //if ps[eq] - } //for eq +// } //if ps[eq] +// } //for eq if (WrittenTitle) TitleCounter++; if (WrittenSummary) @@ -1663,7 +1758,7 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor p += 4; //skip Title number sChannel *C = &sChannels[ChannelSeq[ChannelId]]; //find channel - cSchedule *ps[MAX_EQUIVALENCES]; + cSchedule *ps;//[MAX_EQUIVALENCES]; PrepareToWriteToSchedule (C, s, ps); for (int i = 0; i < NumberOfTitles; i++) { //process each title within block @@ -1714,7 +1809,8 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor if (Themes[Title->ThemeId][0] == 0x00) //if detailed themeid is not known, get global themeid Title->ThemeId &= 0xf0; - WriteToSchedule (ps, C->NumberOfEquivalences, EventId, StartTime, Title->Duration, Text, SummText, + + WriteToSchedule (ps, s, EventId, StartTime, Title->Duration, Text, SummText, Title->ThemeId, NAGRA_TABLE_ID, Version); if (Text != NULL) @@ -1752,7 +1848,8 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor p += 30; //next title } //end for titles - FinishWriteToSchedule (C, s, ps); + //FinishWriteToSchedule (C, s, ps); + sortSchedules(s, tChannelID (C->Src, C->Nid, C->Tid, C->Sid)); p = next_p; } while (p < DataEnd); //end of TitleBlock } @@ -1869,17 +1966,17 @@ int cFilterEEPG::GetChannelsNagra (const u_char * Data, int Length) C->ChannelId = j + 1; //Nagra starts numbering at 1 ChannelSeq[C->ChannelId] = j; //fill lookup table to go from channel-id to sequence nr in table; lookup table starts with 0 C->SkyNumber = 0; - C->NumberOfEquivalences = 1; //there is always an original channel. every equivalence adds 1 - C->Src[0] = Source(); //assume all EPG channels are on same satellite, if not, manage this via equivalents!!! - C->Nid[0] = HILO16 (Channel->NetworkId); - C->Tid[0] = HILO16 (Channel->TransportId); - C->Sid[0] = HILO16 (Channel->ServiceId); - tChannelID channelID = tChannelID(C->Src[0], C->Nid[0], C->Tid[0], C->Sid[0]); + //C->NumberOfEquivalences = 1; //there is always an original channel. every equivalence adds 1 + C->Src = Source(); //assume all EPG channels are on same satellite, if not, manage this via equivalents!!! + C->Nid = HILO16 (Channel->NetworkId); + C->Tid = HILO16 (Channel->TransportId); + C->Sid = HILO16 (Channel->ServiceId); + tChannelID channelID = tChannelID(C->Src, C->Nid, C->Tid, C->Sid); cChannel *VC = GetChannelByID(channelID, true); bool IsFound = (VC); if(IsFound) { strncpy((char*)(C->Name), VC->Name (), 64); - C->Src[0] = VC->Source(); + C->Src = VC->Source(); CleanString (C->Name); } else @@ -1937,7 +2034,8 @@ int cFilterEEPG::GetChannelsNagra (const u_char * Data, int Length) } if (p != DataEnd) LogE(0, prep("Warning, possible problem at end of channel table; p = %p, DataEnd = %p"), p, DataEnd); - LoadEquivalentChannels (); + //LoadEquivalentChannels (); + loadEquivalentChannelMap(); return 2; //obviously, when you get here, channels are read succesfully, but since all channels are sent at once, you can stop now } @@ -2412,7 +2510,8 @@ int cFilterEEPG::GetChannelsSKYBOX (const u_char * Data, int Length) { if (memcmp (InitialChannel, Data, 8) == 0) { //data is the same as initial title - LoadEquivalentChannels (); + //LoadEquivalentChannels (); + loadEquivalentChannelMap(); return 2; } else { if (nChannels == 0) @@ -2459,13 +2558,13 @@ int cFilterEEPG::GetChannelsSKYBOX (const u_char * Data, int Length) if (ChannelSeq.count (ChannelId) == 0) { //not found C = &sChannels[nChannels]; C->ChannelId = ChannelId; - C->NumberOfEquivalences = 1; //there is always an original channel. every equivalence adds 1 - C->Src[0] = Source (); //assume all EPG channels are on same satellite, if not, manage this via equivalents!!! - C->Nid[0] = Nid; - C->Tid[0] = Tid; - C->Sid[0] = Sid; + //C->NumberOfEquivalences = 1; //there is always an original channel. every equivalence adds 1 + C->Src = Source (); //assume all EPG channels are on same satellite, if not, manage this via equivalents!!! + C->Nid = Nid; + C->Tid = Tid; + C->Sid = Sid; C->SkyNumber = SkyNumber; - tChannelID channelID = tChannelID (C->Src[0], C->Nid[0], C->Tid[0], C->Sid[0]); + tChannelID channelID = tChannelID (C->Src, C->Nid, C->Tid, C->Sid); cChannel *VC = Channels.GetByChannelID (channelID, true); bool IsFound = (VC); if (IsFound) @@ -2769,7 +2868,7 @@ void cFilterEEPG::LoadIntoSchedule (void) //channelids are sequentially numbered and sent in MHW1 and MHW2, but not in SKY, so we need to lookup the table index sChannel *C = &sChannels[ChannelSeq[ChannelId]]; //find channel - cSchedule *p[MAX_EQUIVALENCES]; + cSchedule *p;//[MAX_EQUIVALENCES]; PrepareToWriteToSchedule (C, s, p); char rating = 0x00; @@ -2781,10 +2880,11 @@ void cFilterEEPG::LoadIntoSchedule (void) TableId = T->TableId; } - WriteToSchedule (p, C->NumberOfEquivalences, T->EventId, StartTime, T->Duration / 60, (char *) T->Text, + WriteToSchedule (p, s, T->EventId, StartTime, T->Duration / 60, (char *) T->Text, (char *) S->Text, T->ThemeId, TableId, 0, rating); + sortSchedules(s, p->channelID); - FinishWriteToSchedule (C, s, p); + //FinishWriteToSchedule (C, s, p); //Replays--; //if ((S->NumReplays != 0) && (Replays > 0)) { //when replays are used, all summaries of the replays are stored consecutively; currently only CSAT //j++; //move to next summary @@ -2817,15 +2917,16 @@ void cFilterEEPG::LoadIntoSchedule (void) /* write Title info to schedule */ sChannel *C = &sChannels[ChannelSeq[T->ChannelId]]; //find channel - cSchedule *p[MAX_EQUIVALENCES]; + cSchedule *p;//[MAX_EQUIVALENCES]; PrepareToWriteToSchedule (C, s, p); char rating = 0x00; if ((Format == SKY_IT || Format == SKY_UK) && T->Rating) { //TODO only works on OTV for now rating = T->Rating; } - WriteToSchedule (p, C->NumberOfEquivalences, T->EventId, T->StartTime, T->Duration / 60, (char *) T->Text, + WriteToSchedule (p, s, T->EventId, T->StartTime, T->Duration / 60, (char *) T->Text, NULL, T->ThemeId, DEFAULT_TABLE_ID, 0, rating); - FinishWriteToSchedule (C, s, p); + //FinishWriteToSchedule (C, s, p); + sortSchedules(s, p->channelID); SummariesNotFound++; i++; //move to next title, for this one no summary can be found @@ -2896,74 +2997,10 @@ class cEIT2:public SI::EIT { public: cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool isEITPid = false, bool OnlyRunningStatus = false); -protected: - void updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent); +//protected: +// void updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent); }; -void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent){ - multimap::iterator it; - pair::iterator,multimap::iterator> ret; - - LogD(3, prep("Start updateEquivalent %s"), *channelID.ToString()); - - ret = equiChanMap.equal_range(*channelID.ToString()); - for (it=ret.first; it!=ret.second; ++it) { - LogD(1, prep("equivalent channel exists")); - tChannelID equChannelID (tChannelID::FromString((*it).second.c_str())); - cChannel *equChannel = GetChannelByID (equChannelID, false); - if (equChannel) { - LogD(3, prep("found Equivalent channel %s"), *equChannelID.ToString()); - cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (equChannel, true); - cEvent *pEqvEvent = (cEvent *) pSchedule->GetEvent (pEvent->EventID(), pEvent->StartTime()); - if (pEqvEvent) { - LogD(1, prep("equivalent event exists")); - if (pEqvEvent == pEvent) { - LogD(1, prep("equal event exists")); - - } else { - LogD(1, prep("remove equivalent")); - pSchedule->DelEvent(pEqvEvent); - cEvent* newEvent = new cEvent (pEvent->EventID()); - newEvent->SetTableID (pEvent->TableID()); - newEvent->SetStartTime (pEvent->StartTime()); - newEvent->SetDuration (pEvent->Duration()); - newEvent->SetVersion (pEvent->Version()); -// newEvent->SetContents(pEvent->Contents()); - newEvent->SetParentalRating(pEvent->ParentalRating()); - newEvent->SetVps (pEvent->Vps()); - newEvent->SetTitle (pEvent->Title ()); - newEvent->SetShortText (pEvent->ShortText ()); - newEvent->SetDescription (pEvent->Description ()); -// newEvent->SetComponents (pEvent->Components()); - newEvent->FixEpgBugs (); - - pSchedule->AddEvent(newEvent); - pSchedule->Sort (); - - } - - } else { - LogD(1, prep("equivalent event does not exist")); - cEvent* newEvent = new cEvent (pEvent->EventID()); - newEvent->SetTableID (pEvent->TableID()); - newEvent->SetStartTime (pEvent->StartTime()); - newEvent->SetDuration (pEvent->Duration()); - newEvent->SetVersion (pEvent->Version()); -// newEvent->SetContents(pEvent->Contents()); - newEvent->SetParentalRating(pEvent->ParentalRating()); - newEvent->SetVps (pEvent->Vps()); - newEvent->SetTitle (pEvent->Title ()); - newEvent->SetShortText (pEvent->ShortText ()); - newEvent->SetDescription (pEvent->Description ()); -// newEvent->SetComponents (pEvent->Components()); - newEvent->FixEpgBugs (); - - pSchedule->AddEvent(newEvent); - pSchedule->Sort (); - } - } - } -} cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool isEITPid, bool OnlyRunningStatus) : SI::EIT (Data, false) @@ -3556,10 +3593,9 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat return; } if (Modified) { - pSchedule->Sort (); if (!HasExternalData) pSchedule->DropOutdated (SegmentStart, SegmentEnd, Tid, getVersionNumber ()); - Schedules->SetModified (pSchedule); + sortSchedules(Schedules, channel->GetChannelID()); } LogD(4, prep("end of cEIT2")); diff --git a/eepg.h b/eepg.h index d306ca0..b661809 100644 --- a/eepg.h +++ b/eepg.h @@ -7,7 +7,7 @@ #define MAX_CHANNELS 2048 #define MAX_TITLES 262144 -#define MAX_EQUIVALENCES 8 //the number of equivalences one channel can have +//#define MAX_EQUIVALENCES 8 //the number of equivalences one channel can have //Formats (need to be consecutively numbered): //#define PREMIERE 0 @@ -53,11 +53,11 @@ typedef struct { unsigned short int ChannelId; unsigned short int SkyNumber; - unsigned short int NumberOfEquivalences;//original channel sets this value to 1, every equivalent channel adds 1 - unsigned int Src[MAX_EQUIVALENCES]; - unsigned short int Nid[MAX_EQUIVALENCES]; - unsigned short int Tid[MAX_EQUIVALENCES]; - unsigned short int Sid[MAX_EQUIVALENCES]; + //unsigned short int NumberOfEquivalences;//original channel sets this value to 1, every equivalent channel adds 1 + unsigned int Src;//[MAX_EQUIVALENCES]; + unsigned short int Nid;//[MAX_EQUIVALENCES]; + unsigned short int Tid;//[MAX_EQUIVALENCES]; + unsigned short int Sid;//[MAX_EQUIVALENCES]; unsigned char Name[64]; } sChannel; -- cgit v1.2.3 From 4bdb21f818f96e05ad51d3f2996609226903eade Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Fri, 18 May 2012 18:01:45 +0200 Subject: use correct get channelID --- eepg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eepg.c b/eepg.c index d5de0d8..29e0b9e 100644 --- a/eepg.c +++ b/eepg.c @@ -1696,7 +1696,7 @@ void cFilterEEPG::WriteToSchedule (cSchedule * ps, cSchedules* pSchedules, unsig if (newEvent) ps->AddEvent (newEvent); - updateEquivalent(pSchedules,ps->channelID, Event); + updateEquivalent(pSchedules,ps->ChannelID(), Event); //newEvent->FixEpgBugs (); causes segfault } @@ -1758,7 +1758,7 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor p += 4; //skip Title number sChannel *C = &sChannels[ChannelSeq[ChannelId]]; //find channel - cSchedule *ps;//[MAX_EQUIVALENCES]; + cSchedule *ps = NULL;//[MAX_EQUIVALENCES]; PrepareToWriteToSchedule (C, s, ps); for (int i = 0; i < NumberOfTitles; i++) { //process each title within block @@ -2882,7 +2882,7 @@ void cFilterEEPG::LoadIntoSchedule (void) WriteToSchedule (p, s, T->EventId, StartTime, T->Duration / 60, (char *) T->Text, (char *) S->Text, T->ThemeId, TableId, 0, rating); - sortSchedules(s, p->channelID); + sortSchedules(s, p->ChannelID()); //FinishWriteToSchedule (C, s, p); //Replays--; @@ -2926,7 +2926,7 @@ void cFilterEEPG::LoadIntoSchedule (void) WriteToSchedule (p, s, T->EventId, T->StartTime, T->Duration / 60, (char *) T->Text, NULL, T->ThemeId, DEFAULT_TABLE_ID, 0, rating); //FinishWriteToSchedule (C, s, p); - sortSchedules(s, p->channelID); + sortSchedules(s, p->ChannelID()); SummariesNotFound++; i++; //move to next title, for this one no summary can be found -- cgit v1.2.3 From f5e42588e52a407c71dc8b933592864908e3a67b Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 19 May 2012 11:04:31 +0200 Subject: remove preparetowritetoschetule --- eepg.c | 176 +++++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 95 insertions(+), 81 deletions(-) diff --git a/eepg.c b/eepg.c index 29e0b9e..fb48110 100644 --- a/eepg.c +++ b/eepg.c @@ -261,9 +261,9 @@ protected: virtual int GetSummariesMHW2 (const u_char * Data, int Length); virtual void FreeSummaries (void); virtual void FreeTitles (void); - virtual void PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps/*[MAX_EQUIVALENCES]*/); //gets a channel and returns an array of schedules that WriteToSchedule can write to. Call this routine before a batch of titles with the same ChannelId will be WriteToScheduled; batchsize can be 1 + //virtual void PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps/*[MAX_EQUIVALENCES]*/); //gets a channel and returns an array of schedules that WriteToSchedule can write to. Call this routine before a batch of titles with the same ChannelId will be WriteToScheduled; batchsize can be 1 //virtual void FinishWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]); - virtual void WriteToSchedule (cSchedule * ps, cSchedules* s, unsigned int EventId, unsigned int StartTime, + virtual void WriteToSchedule (tChannelID channelID, cSchedules* s, unsigned int EventId, unsigned int StartTime, unsigned int Duration, char *Text, char *SummText, unsigned short int ThemeId, unsigned short int TableId, unsigned short int Version, char Rating = 0x00); virtual void LoadIntoSchedule (void); @@ -1610,23 +1610,23 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse * \param s VDR epg schedules * \param ps pointer to the schedules that WriteToSchedule can write to */ -void cFilterEEPG::PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps/*[MAX_EQUIVALENCES]*/) -{ - //for (int eq = 0; eq < C->NumberOfEquivalences; eq++) { - tChannelID channelID = tChannelID (C->Src/*[eq]*/, C->Nid/*[eq]*/, C->Tid/*[eq]*/, C->Sid/*[eq]*/); -#ifdef USE_NOEPG - if (allowedEPG (channelID) && (channelID.Valid ())) -#else - if (channelID.Valid ()) //only add channels that are known to vdr -#endif /* NOEPG */ - ps/*[eq]*/ = s->AddSchedule (channelID); //open a a schedule for each equivalent channel - else { - ps/*[eq]*/ = NULL; -// LogE(5, prep("ERROR: Title block has invalid (equivalent) channel ID: Equivalence: %i, Source:%x, C->Nid:%x,C->Tid:%x,C->Sid:%x."), -// eq, C->Src[eq], C->Nid[eq], C->Tid[eq], C->Sid[eq]); - } - //} -} +//void cFilterEEPG::PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps/*[MAX_EQUIVALENCES]*/) +//{ +// //for (int eq = 0; eq < C->NumberOfEquivalences; eq++) { +// tChannelID channelID = tChannelID (C->Src/*[eq]*/, C->Nid/*[eq]*/, C->Tid/*[eq]*/, C->Sid/*[eq]*/); +//#ifdef USE_NOEPG +// if (allowedEPG (channelID) && (channelID.Valid ())) +//#else +// if (channelID.Valid ()) //only add channels that are known to vdr +//#endif /* NOEPG */ +// ps/*[eq]*/ = s->AddSchedule (channelID); //open a a schedule for each equivalent channel +// else { +// ps/*[eq]*/ = NULL; +//// LogE(5, prep("ERROR: Title block has invalid (equivalent) channel ID: Equivalence: %i, Source:%x, C->Nid:%x,C->Tid:%x,C->Sid:%x."), +//// eq, C->Src[eq], C->Nid[eq], C->Tid[eq], C->Sid[eq]); +// } +// //} +//} //void cFilterEEPG::FinishWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]) //{ @@ -1643,13 +1643,20 @@ void cFilterEEPG::PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSched * \param Duration the Duration of the event in minutes * \param ps points to array of schedules ps[eq], where eq is equivalence number of the channel. If channelId is invalid then ps[eq]=NULL */ -void cFilterEEPG::WriteToSchedule (cSchedule * ps, cSchedules* pSchedules, unsigned int EventId, unsigned int StartTime, unsigned int Duration, char *Text, char *SummText, unsigned short int ThemeId, unsigned short int TableId, unsigned short int Version, char Rating) +void cFilterEEPG::WriteToSchedule (tChannelID channelID, cSchedules* pSchedules, unsigned int EventId, unsigned int StartTime, unsigned int Duration, char *Text, char *SummText, unsigned short int ThemeId, unsigned short int TableId, unsigned short int Version, char Rating) { bool WrittenTitle = false; bool WrittenSummary = false; // for (int eq = 0; eq < NumberOfEquivalences; eq++) { -// if (ps[eq]) { - cEvent *Event = NULL; + cSchedule* ps; + if (channelID.Valid ()) //only add channels that are known to VDR + ps = pSchedules->AddSchedule (channelID); //open or create new schedule + else { + ps = NULL; + } + + cEvent *Event = NULL; + if (ps/*[eq]*/) { Event = (cEvent *) ps->GetEvent (EventId); //since Nagra uses consistent EventIds, try this first bool TableIdMatches = false; @@ -1657,60 +1664,65 @@ void cFilterEEPG::WriteToSchedule (cSchedule * ps, cSchedules* pSchedules, unsig TableIdMatches = (Event->TableID() == TableId); if (!Event || !TableIdMatches || abs(Event->StartTime() - (time_t) StartTime) > Duration * 60) //if EventId does not match, or it matched with wrong TableId, then try with StartTime Event = (cEvent *) ps->GetEvent (EventId, StartTime); + } + cEvent *newEvent = NULL; + if (!Event) { //event is new + Event = newEvent = new cEvent (EventId); + Event->SetSeen (); + } else if (Event->TableID() < TableId) { //existing table may not be overwritten + RejectTableId++; + //esyslog ("EEPGDEBUG: Rejecting Event, existing TableID:%x, new TableID:%x.", Event->TableID (), + // TableId); + Event = NULL; + } - cEvent *newEvent = NULL; - if (!Event) { //event is new - Event = newEvent = new cEvent (EventId); - Event->SetSeen (); - } else if (Event->TableID() < TableId) { //existing table may not be overwritten - RejectTableId++; - //esyslog ("EEPGDEBUG: Rejecting Event, existing TableID:%x, new TableID:%x.", Event->TableID (), - // TableId); - Event = NULL; - } - - if (Event) { - Event->SetEventID (EventId); //otherwise the summary cannot be added later - Event->SetTableID (TableId); //TableID 0 is reserved for external epg, will not be overwritten; the lower the TableID, the more actual it is - Event->SetVersion (Version); //TODO use version and tableID to decide whether to update; TODO add language code - Event->SetStartTime (StartTime); - Event->SetDuration (Duration * 60); - if (Rating) { - Event->SetParentalRating(Rating); - } - char *tmp; - if (Text != 0x00) { - WrittenTitle = true; - CleanString ((uchar *) Text); - Event->SetTitle (Text); - } - Asprintf (&tmp, "%s - %d\'", Themes[ThemeId], Duration); - Event->SetShortText (tmp); - //strreplace(t, '|', '\n'); - if (SummText != 0x00) { - WrittenSummary = true; - CleanString ((uchar *) SummText); - Event->SetDescription (SummText); - } - free (tmp); - if (newEvent) - ps->AddEvent (newEvent); + if (Event) { + Event->SetEventID (EventId); //otherwise the summary cannot be added later + Event->SetTableID (TableId); //TableID 0 is reserved for external epg, will not be overwritten; the lower the TableID, the more actual it is + Event->SetVersion (Version); //TODO use version and tableID to decide whether to update; TODO add language code + Event->SetStartTime (StartTime); + Event->SetDuration (Duration * 60); + if (Rating) { + Event->SetParentalRating(Rating); + } + char *tmp; + if (Text != 0x00) { + WrittenTitle = true; + CleanString ((uchar *) Text); + Event->SetTitle (Text); + } + Asprintf (&tmp, "%s - %d\'", Themes[ThemeId], Duration); + Event->SetShortText (tmp); + //strreplace(t, '|', '\n'); + if (SummText != 0x00) { + WrittenSummary = true; + CleanString ((uchar *) SummText); + Event->SetDescription (SummText); + } + free (tmp); + if (ps && newEvent) + ps->AddEvent (newEvent); - updateEquivalent(pSchedules,ps->ChannelID(), Event); + updateEquivalent(pSchedules, channelID, Event); + if (!ps) { + //the event is not send to VDR so it has to be deleted. + delete Event; + Event = NULL; + } //newEvent->FixEpgBugs (); causes segfault - } + } /* else esyslog ("EEPG: ERROR, somehow not able to add/update event.");*///at this moment only reports RejectTableId events - if (CheckLevel(4)) { - isyslog ("EEPG: Title:%i, Summary:%i I would put into schedule:", TitleCounter, SummaryCounter); - //isyslog ("C %s-%i-%i-%i\n", *cSource::ToString (C->Src[eq]), C->Nid[eq], C->Tid[eq], C->Sid[eq]); - isyslog ("E %u %u %u 01 FF\n", EventId, StartTime, Duration * 60); - isyslog ("T %s\n", Text); - isyslog ("S %s - %d\'\n", Themes[ThemeId], Duration); - isyslog ("D %s\n", SummText); - isyslog ("e\nc\n.\n"); - } + if (CheckLevel(4)) { + isyslog ("EEPG: Title:%i, Summary:%i I would put into schedule:", TitleCounter, SummaryCounter); + //isyslog ("C %s-%i-%i-%i\n", *cSource::ToString (C->Src[eq]), C->Nid[eq], C->Tid[eq], C->Sid[eq]); + isyslog ("E %u %u %u 01 FF\n", EventId, StartTime, Duration * 60); + isyslog ("T %s\n", Text); + isyslog ("S %s - %d\'\n", Themes[ThemeId], Duration); + isyslog ("D %s\n", SummText); + isyslog ("e\nc\n.\n"); + } // } //if ps[eq] // } //for eq if (WrittenTitle) @@ -1758,8 +1770,8 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor p += 4; //skip Title number sChannel *C = &sChannels[ChannelSeq[ChannelId]]; //find channel - cSchedule *ps = NULL;//[MAX_EQUIVALENCES]; - PrepareToWriteToSchedule (C, s, ps); + //cSchedule *ps = NULL;//[MAX_EQUIVALENCES]; + //PrepareToWriteToSchedule (C, s, ps); for (int i = 0; i < NumberOfTitles; i++) { //process each title within block sTitleNagraGuide *Title = (sTitleNagraGuide *) p; @@ -1810,7 +1822,7 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor if (Themes[Title->ThemeId][0] == 0x00) //if detailed themeid is not known, get global themeid Title->ThemeId &= 0xf0; - WriteToSchedule (ps, s, EventId, StartTime, Title->Duration, Text, SummText, + WriteToSchedule (tChannelID (C->Src, C->Nid, C->Tid, C->Sid), s, EventId, StartTime, Title->Duration, Text, SummText, Title->ThemeId, NAGRA_TABLE_ID, Version); if (Text != NULL) @@ -2868,8 +2880,9 @@ void cFilterEEPG::LoadIntoSchedule (void) //channelids are sequentially numbered and sent in MHW1 and MHW2, but not in SKY, so we need to lookup the table index sChannel *C = &sChannels[ChannelSeq[ChannelId]]; //find channel - cSchedule *p;//[MAX_EQUIVALENCES]; - PrepareToWriteToSchedule (C, s, p); + //cSchedule *p;//[MAX_EQUIVALENCES]; + //PrepareToWriteToSchedule (C, s, p); + tChannelID chanID = tChannelID (C->Src, C->Nid, C->Tid, C->Sid); char rating = 0x00; if ((Format == SKY_IT || Format == SKY_UK) && T->Rating) { //TODO only works on OTV for now @@ -2880,9 +2893,9 @@ void cFilterEEPG::LoadIntoSchedule (void) TableId = T->TableId; } - WriteToSchedule (p, s, T->EventId, StartTime, T->Duration / 60, (char *) T->Text, + WriteToSchedule (chanID, s, T->EventId, StartTime, T->Duration / 60, (char *) T->Text, (char *) S->Text, T->ThemeId, TableId, 0, rating); - sortSchedules(s, p->ChannelID()); + sortSchedules(s, chanID); //FinishWriteToSchedule (C, s, p); //Replays--; @@ -2917,16 +2930,17 @@ void cFilterEEPG::LoadIntoSchedule (void) /* write Title info to schedule */ sChannel *C = &sChannels[ChannelSeq[T->ChannelId]]; //find channel - cSchedule *p;//[MAX_EQUIVALENCES]; - PrepareToWriteToSchedule (C, s, p); + //cSchedule *p;//[MAX_EQUIVALENCES]; + tChannelID chanID = tChannelID (C->Src, C->Nid, C->Tid, C->Sid); + //PrepareToWriteToSchedule (C, s, p); char rating = 0x00; if ((Format == SKY_IT || Format == SKY_UK) && T->Rating) { //TODO only works on OTV for now rating = T->Rating; } - WriteToSchedule (p, s, T->EventId, T->StartTime, T->Duration / 60, (char *) T->Text, + WriteToSchedule (chanID, s, T->EventId, T->StartTime, T->Duration / 60, (char *) T->Text, NULL, T->ThemeId, DEFAULT_TABLE_ID, 0, rating); //FinishWriteToSchedule (C, s, p); - sortSchedules(s, p->ChannelID()); + sortSchedules(s, chanID); SummariesNotFound++; i++; //move to next title, for this one no summary can be found -- cgit v1.2.3 From ec0e8f0f77a63956f09165ce562b98d0c5088245 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 19 May 2012 16:38:19 +0200 Subject: check if channel valid before sort --- eepg.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/eepg.c b/eepg.c index fb48110..7ad3743 100644 --- a/eepg.c +++ b/eepg.c @@ -1155,9 +1155,12 @@ void sortSchedules(cSchedules * Schedules, tChannelID channelID){ LogD(3, prep("Start sortEquivalent %s"), *channelID.ToString()); cChannel *pChannel = GetChannelByID (channelID, false); - cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (pChannel, true); - pSchedule->Sort (); - Schedules->SetModified (pSchedule); + cSchedule *pSchedule; + if (pChannel) { + pSchedule = (cSchedule *) Schedules->GetSchedule (pChannel, true); + pSchedule->Sort (); + Schedules->SetModified (pSchedule); + } ret = equiChanMap.equal_range(*channelID.ToString()); for (it=ret.first; it!=ret.second; ++it) { -- cgit v1.2.3 From feee46aeed74157e104335918741f266fd576f29 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 19 May 2012 18:41:02 +0200 Subject: remove commented code reload equivalent file if modified --- eepg.c | 119 +++++++---------------------------------------------------------- 1 file changed, 13 insertions(+), 106 deletions(-) diff --git a/eepg.c b/eepg.c index 7ad3743..9be57c5 100644 --- a/eepg.c +++ b/eepg.c @@ -56,20 +56,6 @@ #define trNOOP(s) (s) #endif -//#define DEBUG -//#define DEBUG2 - -/*#ifdef DEBUG -#define d(x) { (x); } -#else -#define d(x) ; -#endif -#ifdef DEBUG2 -#define d2(x) { (x); } -#else -#define d2(x) ; -#endif*/ - #define PMT_SCAN_TIMEOUT 10 // seconds #define PMT_SCAN_IDLE 3600 // seconds @@ -186,6 +172,7 @@ static int NumberOfAvailableSources = 0; static int LastVersionNagra = -1; //currently only used for Nagra, should be stored per transponder, per system static multimap equiChanMap; +static long equiChanFileTime = 0; #ifdef USE_NOEPG @@ -1009,9 +996,17 @@ void loadEquivalentChannelMap (void) multimap::iterator it,it2; pair::iterator,multimap::iterator> ret; - //TODO DPE add code to reload if file is changed - if (equiChanMap.size() > 0) + //Test if file is changed and reload + struct stat st; + if (stat(FileName.c_str(), &st)) { + LogE(0, prep("Error obtaining stats for '%s' "), FileName.c_str()); + return; + } + + if (equiChanMap.size() > 0 && equiChanFileTime == st.st_mtim.tv_nsec) return; + else + equiChanMap.clear(); File = fopen (FileName.c_str(), "r"); @@ -1078,6 +1073,7 @@ void loadEquivalentChannelMap (void) } //if isempty } //while fclose (File); + equiChanFileTime = st.st_mtim.tv_nsec; LogD(3, prep("Loaded %i equivalents."), equiChanMap.size()); for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); @@ -1178,94 +1174,6 @@ void sortSchedules(cSchedules * Schedules, tChannelID channelID){ } -//void cFilterEEPG::LoadEquivalentChannels (void) -//{ -// char Buffer[1024]; -// char *Line; -// FILE *File; -// string FileName = string(ConfDir) + "/" + EEPG_FILE_EQUIV; -// -// File = fopen (FileName.c_str(), "r"); -// if (File) { -// memset (Buffer, 0, sizeof (Buffer)); -// char origChanID[256]; -// char equiChanID[256]; -// char source[256]; -// int nid; -// int tid; -// int sid; -// int rid; -// while ((Line = fgets (Buffer, sizeof (Buffer), File)) != NULL) { -// Line = compactspace (skipspace (stripspace (Line))); -// if (!isempty (Line)) { -// if (sscanf (Line, "%[^ ] %[^ ] %[^\n]\n", origChanID, equiChanID, source) == 3) { -// if (origChanID[0] != '#' && origChanID[0] != ';') { -// nid = 0; -// tid = 0; -// sid = 0; -// rid = 0; -// if (sscanf (origChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) -// if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { -// if (sscanf (origChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) != 5) { -// rid = 0; -// } -// tChannelID OriginalChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); -// bool found = false; -// int i = 0; -// sChannel *C = NULL; -// while (i < nChannels && (!found)) { -// C = &sChannels[i]; -// if (C->Src[0] == (unsigned int)cSource::FromString (source) && C->Nid[0] == nid -// && C->Tid[0] == tid && C->Sid[0] == sid) -// found = true; -// else -// i++; -// } -// if (!found) { -// LogI(2, prep("Warning: in equivalence file, cannot find original channel %s. Perhaps you are tuned to another transponder right now."), -// origChanID); -// } else { -// cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); -// if (!OriginalChannel) -// LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalence is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? -// if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { -// if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) -// != 5) { -// rid = 0; -// } -// tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); -// cChannel *EquivChannel = Channels.GetByChannelID (EquivChID, false); //TODO use valid function? -// if (EquivChannel) { -// if (C->NumberOfEquivalences < MAX_EQUIVALENCES) { -// C->Src[C->NumberOfEquivalences] = EquivChannel->Source (); -// C->Nid[C->NumberOfEquivalences] = EquivChannel->Nid (); -// C->Tid[C->NumberOfEquivalences] = EquivChannel->Tid (); -// C->Sid[C->NumberOfEquivalences] = EquivChannel->Sid (); -// C->NumberOfEquivalences++; -// nEquivChannels++; -// LogI(3, prep("Added equivalent nr %i with Channel Id %s-%i-%i-%i to channel with id %i."), -// C->NumberOfEquivalences, *cSource::ToString (C->Src[C->NumberOfEquivalences - 1]), -// C->Nid[C->NumberOfEquivalences - 1], C->Tid[C->NumberOfEquivalences - 1], -// C->Sid[C->NumberOfEquivalences - 1], i); -// } else -// LogE(0, prep("Error, channel with id %i has more than %i equivalences. Increase MAX_EQUIVALENCES."), -// i, MAX_EQUIVALENCES); -// } else -// LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); -// } -// } //else !found -// } //if scanf string1 -// } //if string1 -// } //if scanf -// } //if isempty -// } //while -// fclose (File); -// } //if file -//} //end of loadequiv - -//end of loadequiv - - /** * \brief Get MHW channels * @@ -4166,8 +4074,6 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len } //closes SOURCE() } //end of closing -// --- cPluginEEPG ------------------------------------------------------ - void cFilterEEPG::ProcessPremiere(const u_char *& Data) { @@ -4443,6 +4349,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) } +// --- cPluginEEPG ------------------------------------------------------ class cPluginEEPG:public cPlugin { -- cgit v1.2.3 From 48b12080740aee4e035d3b7412c4da4bf301315d Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Mon, 21 May 2012 19:44:32 +0200 Subject: disable EIT scan for NA so that the titles/descriptions are not erased, until the proper solution is made --- epghandler.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/epghandler.c b/epghandler.c index 29f092b..2e50c33 100644 --- a/epghandler.c +++ b/epghandler.c @@ -8,20 +8,24 @@ #include "epghandler.h" #if APIVERSNUM > 10725 #include "log.h" +#include cEEpgHandler::cEEpgHandler() { - // TODO Auto-generated constructor stub LogD(4, prep("cEEpgHandler()")); } cEEpgHandler::~cEEpgHandler() { - // TODO Auto-generated destructor stub } bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, const SI::EIT::Event* EitEvent, uchar TableID, uchar Version) { //LogD(1, prep("HandleEitEvent")); + //DISH NID 0x1001 to 0x100B BEV 0x100 and 0x101 + //TODO move the eit handling code at least for NA providers here instead of discarding. + int nid = Schedule->ChannelID().Nid(); + if ((nid >= 0x1001 && nid <= 0x100B) || nid == 0x101 || nid == 0x100) + return true; return false; // return true; } -- cgit v1.2.3 From d4733f1594ee1531693f5bd2bb759fa64d3cee73 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 23 May 2012 00:13:49 +0200 Subject: fix BEV eepg transponder --- eepg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eepg.c b/eepg.c index 1b7c0a2..f9e0daf 100644 --- a/eepg.c +++ b/eepg.c @@ -3854,7 +3854,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len if (((Source() == cSource::FromString("S119.0W") && Transponder() == cChannel::Transponder(12472,'H')) || (Source() == cSource::FromString("S91.0W") - && Transponder() == cChannel::Transponder(12224,'R'))) + && Transponder() == cChannel::Transponder(12224,'V'))) && !UnprocessedFormat[DISH_BEV]) { UnprocessedFormat[DISH_BEV] = stream.getPid (); } -- cgit v1.2.3 From 61eded224bc4660b41f6754e83b91a262af3f8ce Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 23 May 2012 21:36:14 +0200 Subject: move equivalence to separate file/class --- eepg.c | 247 ++++++++++--------------------------------------------- eepg.h | 2 - epghandler.c | 31 ++++++- epghandler.h | 3 + equivhandler.cpp | 207 ++++++++++++++++++++++++++++++++++++++++++++++ equivhandler.h | 37 +++++++++ setupeepg.c | 7 +- setupeepg.h | 13 +++ 8 files changed, 334 insertions(+), 213 deletions(-) create mode 100644 equivhandler.cpp create mode 100644 equivhandler.h diff --git a/eepg.c b/eepg.c index 9be57c5..91a08c0 100644 --- a/eepg.c +++ b/eepg.c @@ -43,6 +43,7 @@ #endif #include "log.h" #include "setupeepg.h" +#include "equivhandler.h" #include #include @@ -97,7 +98,7 @@ char *cs_hexdump (int m, const uchar * buf, int n) } cSetupEEPG* SetupPE = cSetupEEPG::getInstance(); - +cEquivHandler* EquivHandler; // --- cMenuSetupPremiereEpg ------------------------------------------------------------ @@ -171,8 +172,6 @@ static int AvailableSources[32]; static int NumberOfAvailableSources = 0; static int LastVersionNagra = -1; //currently only used for Nagra, should be stored per transponder, per system -static multimap equiChanMap; -static long equiChanFileTime = 0; #ifdef USE_NOEPG @@ -200,7 +199,7 @@ class cFilterEEPG:public cFilter private: int pmtpid, pmtsid, pmtidx, pmtnext; int UnprocessedFormat[HIGHEST_FORMAT + 1]; //stores the pid when a format is detected on this transponder, and that are not processed yet - int nEquivChannels, nChannels, nThemes, nTitles, nSummaries, NumberOfTables, Version; + int nChannels, nThemes, nTitles, nSummaries, NumberOfTables, Version; int TitleCounter, SummaryCounter, NoSummaryCounter, RejectTableId; bool EndChannels, EndThemes; //only used for ?? int MHWStartTime; //only used for MHW1 @@ -347,8 +346,8 @@ struct hufftab { int freesat_decode_error = 0; /* If set an error has occurred during decoding */ -static struct hufftab *tables[2][256]; -static int table_size[2][256]; +static struct hufftab *tables[2][128]; +static int table_size[2][128]; static sNodeH* sky_tables[2]; /** \brief Convert a textual character description into a value @@ -429,6 +428,9 @@ static bool load_freesat_file (int tableid, const char *filename) tables[tableid][from_char][i].value = bin; tables[tableid][from_char][i].next = to_char; tables[tableid][from_char][i].bits = bin_len; + /* char from; unsigned int value; short bits; char next; */ + LogI(2, prep("%02x;%08x;%04x;%02x"), from_char, bin, bin_len, to_char); + free (from); free (to); free (binary); @@ -766,7 +768,7 @@ nextloop1: //here all declarations for global variables over all devices -char *ConfDir; +//char *ConfDir; //unsigned char DecodeErrorText[4096]; //TODO only used for debugging? @@ -879,7 +881,7 @@ cChannel *GetChannelByID(tChannelID & channelID, bool searchOtherPos) bool cFilterEEPG::GetThemesSKYBOX (void) //TODO can't we read this from the DVB stream? { - string FileName = ConfDir; + string FileName = cSetupEEPG::getInstance()->getConfDir(); FILE *FileThemes; char *Line; char Buffer[256]; @@ -927,7 +929,7 @@ bool cFilterEEPG::GetThemesSKYBOX (void) //TODO can't we read this from the DVB */ bool cFilterEEPG::InitDictionary (void) { - string FileName = ConfDir; + string FileName = cSetupEEPG::getInstance()->getConfDir(); switch (Format) { case SKY_IT: if (sky_tables[0] == NULL) { @@ -951,7 +953,7 @@ bool cFilterEEPG::InitDictionary (void) FileName += "/freesat.t1"; if (!load_freesat_file (1, FileName.c_str())) return false; - FileName = ConfDir; + FileName = cSetupEEPG::getInstance()->getConfDir(); FileName += "/freesat.t2"; return load_freesat_file (2, FileName.c_str()); } else @@ -987,190 +989,18 @@ void decodeText2 (const unsigned char *from, int len, char *buffer, int buffsize //LogE(5, prep("decodeText2 buffer %s - buffsize %d"), buffer, buffsize); } -void loadEquivalentChannelMap (void) -{ - char Buffer[1024]; - char *Line; - FILE *File; - string FileName = string(ConfDir) + "/" + EEPG_FILE_EQUIV; - multimap::iterator it,it2; - pair::iterator,multimap::iterator> ret; - - //Test if file is changed and reload - struct stat st; - if (stat(FileName.c_str(), &st)) { - LogE(0, prep("Error obtaining stats for '%s' "), FileName.c_str()); - return; - } - - if (equiChanMap.size() > 0 && equiChanFileTime == st.st_mtim.tv_nsec) - return; - else - equiChanMap.clear(); - - - File = fopen (FileName.c_str(), "r"); - if (File) { - memset (Buffer, 0, sizeof (Buffer)); - char origChanID[256]; - char equiChanID[256]; - char source[256]; - int nid = 0; - int tid = 0; - int sid = 0; - int rid = 0; - while ((Line = fgets (Buffer, sizeof (Buffer), File)) != NULL) { - Line = compactspace (skipspace (stripspace (Line))); - if (!isempty (Line)) { - if (sscanf (Line, "%[^ ] %[^ ] %[^\n]\n", origChanID, equiChanID, source) == 3) { - if (origChanID[0] != '#' && origChanID[0] != ';') { - nid = 0; - tid = 0; - sid = 0; - rid = 0; - if (sscanf (origChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) - if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { - if (sscanf (origChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) != 5) { - rid = 0; - } - tChannelID OriginalChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); - bool found = false; - //int i = 0; - cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); - if (!OriginalChannel) { - LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalency is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? - continue; - } - if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { - if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) - != 5) { - rid = 0; - } - tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); - cChannel *EquivChannel = Channels.GetByChannelID (EquivChID, false); //TODO use valid function? - if (EquivChannel) { - ret = equiChanMap.equal_range(*OriginalChID.ToString()); - for (it=ret.first; it!=ret.second; ++it) - if ((*it).second == *OriginalChID.ToString()) { - found = true; - break; - } - - if (!found) { - string origCh(*OriginalChID.ToString()); - string equiCh(*EquivChID.ToString()); - equiChanMap.insert(pair(origCh.c_str(),equiCh.c_str())); - LogD(4, prep("Found %s equivalent to %s. origCh %s"), *EquivChID.ToString(), *OriginalChID.ToString(), origCh.c_str()); - for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) - LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); - } - } else - LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); - } - } //if scanf string1 - } //if string1 - } //if scanf - } //if isempty - } //while - fclose (File); - equiChanFileTime = st.st_mtim.tv_nsec; - LogD(3, prep("Loaded %i equivalents."), equiChanMap.size()); - for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) - LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); - } //if file -} - -void updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent){ - multimap::iterator it; - pair::iterator,multimap::iterator> ret; - - LogD(3, prep("Start updateEquivalent %s"), *channelID.ToString()); - - ret = equiChanMap.equal_range(*channelID.ToString()); - for (it=ret.first; it!=ret.second; ++it) { - LogD(1, prep("equivalent channel exists")); - tChannelID equChannelID (tChannelID::FromString((*it).second.c_str())); - cChannel *equChannel = GetChannelByID (equChannelID, false); - if (equChannel) { - LogD(3, prep("found Equivalent channel %s"), *equChannelID.ToString()); - cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (equChannel, true); - cEvent *pEqvEvent = (cEvent *) pSchedule->GetEvent (pEvent->EventID(), pEvent->StartTime()); - if (pEqvEvent) { - LogD(1, prep("equivalent event exists")); - if (pEqvEvent == pEvent) { - LogD(1, prep("equal event exists")); - - } else { - LogD(1, prep("remove equivalent")); - pSchedule->DelEvent(pEqvEvent); - cEvent* newEvent = new cEvent (pEvent->EventID()); - newEvent->SetTableID (pEvent->TableID()); - newEvent->SetStartTime (pEvent->StartTime()); - newEvent->SetDuration (pEvent->Duration()); - newEvent->SetVersion (pEvent->Version()); -// newEvent->SetContents(pEvent->Contents()); - newEvent->SetParentalRating(pEvent->ParentalRating()); - newEvent->SetVps (pEvent->Vps()); - newEvent->SetTitle (pEvent->Title ()); - newEvent->SetShortText (pEvent->ShortText ()); - newEvent->SetDescription (pEvent->Description ()); -// newEvent->SetComponents (pEvent->Components()); - newEvent->FixEpgBugs (); - - pSchedule->AddEvent(newEvent); - - } - - } else { - LogD(1, prep("equivalent event does not exist")); - cEvent* newEvent = new cEvent (pEvent->EventID()); - newEvent->SetTableID (pEvent->TableID()); - newEvent->SetStartTime (pEvent->StartTime()); - newEvent->SetDuration (pEvent->Duration()); - newEvent->SetVersion (pEvent->Version()); -// newEvent->SetContents(pEvent->Contents()); - newEvent->SetParentalRating(pEvent->ParentalRating()); - newEvent->SetVps (pEvent->Vps()); - newEvent->SetTitle (pEvent->Title ()); - newEvent->SetShortText (pEvent->ShortText ()); - newEvent->SetDescription (pEvent->Description ()); -// newEvent->SetComponents (pEvent->Components()); - newEvent->FixEpgBugs (); - - pSchedule->AddEvent(newEvent); - - } - } - } -} - void sortSchedules(cSchedules * Schedules, tChannelID channelID){ - multimap::iterator it; - pair::iterator,multimap::iterator> ret; LogD(3, prep("Start sortEquivalent %s"), *channelID.ToString()); cChannel *pChannel = GetChannelByID (channelID, false); cSchedule *pSchedule; if (pChannel) { - pSchedule = (cSchedule *) Schedules->GetSchedule (pChannel, true); - pSchedule->Sort (); - Schedules->SetModified (pSchedule); - } - - ret = equiChanMap.equal_range(*channelID.ToString()); - for (it=ret.first; it!=ret.second; ++it) { - LogD(3, prep("equivalent channel exists")); - tChannelID equChannelID (tChannelID::FromString((*it).second.c_str())); - pChannel = GetChannelByID (equChannelID, false); - if (pChannel) { - LogD(3, prep("found Equivalent channel %s"), *equChannelID.ToString()); - pSchedule = (cSchedule *) Schedules->GetSchedule (pChannel, true); - - pSchedule->Sort (); - Schedules->SetModified (pSchedule); + pSchedule = (cSchedule *) (Schedules->GetSchedule(pChannel, true)); + pSchedule->Sort(); + Schedules->SetModified(pSchedule); } - } + EquivHandler->sortEquivalents(channelID, Schedules); } @@ -1254,7 +1084,7 @@ int cFilterEEPG::GetChannelsMHW (const u_char * Data, int Length, int MHW) } //for loop } //else nChannels > MAX_CHANNELS //LoadEquivalentChannels (); - loadEquivalentChannelMap(); + EquivHandler->loadEquivalentChannelMap(); GetLocalTimeOffset (); //reread timing variables, only used for MHW return 2; //obviously, when you get here, channels are read successfully, but since all channels are sent at once, you can stop now } //if nChannels == 0 @@ -1614,7 +1444,7 @@ void cFilterEEPG::WriteToSchedule (tChannelID channelID, cSchedules* pSchedules, if (ps && newEvent) ps->AddEvent (newEvent); - updateEquivalent(pSchedules, channelID, Event); + EquivHandler->updateEquivalent(pSchedules, channelID, Event); if (!ps) { //the event is not send to VDR so it has to be deleted. @@ -1958,7 +1788,7 @@ int cFilterEEPG::GetChannelsNagra (const u_char * Data, int Length) if (p != DataEnd) LogE(0, prep("Warning, possible problem at end of channel table; p = %p, DataEnd = %p"), p, DataEnd); //LoadEquivalentChannels (); - loadEquivalentChannelMap(); + EquivHandler->loadEquivalentChannelMap(); return 2; //obviously, when you get here, channels are read succesfully, but since all channels are sent at once, you can stop now } @@ -2434,7 +2264,7 @@ int cFilterEEPG::GetChannelsSKYBOX (const u_char * Data, int Length) if (memcmp (InitialChannel, Data, 8) == 0) { //data is the same as initial title //LoadEquivalentChannels (); - loadEquivalentChannelMap(); + EquivHandler->loadEquivalentChannelMap(); return 2; } else { if (nChannels == 0) @@ -2865,11 +2695,11 @@ void cFilterEEPG::LoadIntoSchedule (void) } //while title } // if s else - esyslog ("EEPG Error: could not lock schedules."); + LogE (0, prep("Error: could not lock schedules.")); cSchedules::Cleanup (true); //deletes all past events - isyslog ("EEPG: found %i equivalents channels", nEquivChannels); + //isyslog ("EEPG: found %i equivalents channels", nEquivChannels); isyslog ("EEPG: found %i themes", nThemes); isyslog ("EEPG: found %i channels", nChannels); isyslog ("EEPG: found %i titles", nTitles); @@ -3506,7 +3336,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat } } #endif /* DDEPGENTRY */ - updateEquivalent(Schedules, channel->GetChannelID(), pEvent); + EquivHandler->updateEquivalent(Schedules, channel->GetChannelID(), pEvent); } if (Empty && Tid == 0x4E && getSectionNumber () == 0) // ETR 211: an empty entry in section 0 of table 0x4E means there is currently no event running @@ -3535,7 +3365,7 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) esyslog ("EEPGDEBUG: Format %i on pid %x", i, UnprocessedFormat[i]); */ if (!FirstTime) { - isyslog ("EEPG: found %i equivalents channels", nEquivChannels); + //isyslog ("EEPG: found %i equivalents channels", equiChanMap.size()); isyslog ("EEPG: found %i themes", nThemes); isyslog ("EEPG: found %i channels", nChannels); isyslog ("EEPG: found %i titles", nTitles); @@ -3577,7 +3407,7 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) if (SetupPE->ProcessEIT && !UnprocessedFormat[EIT] && !UnprocessedFormat[FREEVIEW] && !UnprocessedFormat[DISH_BEV]) { UnprocessedFormat[EIT] = EIT_PID; - loadEquivalentChannelMap(); + EquivHandler->loadEquivalentChannelMap(); } //now start looking for next format to process @@ -3604,7 +3434,6 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) memset (&InitialSummary, 0, 64); NagraCounter = 0; Version = -1; //because 0 can be a valid version number... - nEquivChannels = 0; nChannels = 0; nThemes = 0; EndChannels = false; @@ -4383,7 +4212,7 @@ cPluginEEPG::cPluginEEPG (void) void cPluginEEPG::CheckCreateFile(const char* Name, const char *fileContent[]) { FILE *File; - string FileName = string(ConfDir) + "/" + Name; + string FileName = string(cSetupEEPG::getInstance()->getConfDir()) + "/" + Name; File = fopen(FileName.c_str(), "r"); if (File == NULL) { LogE (0, prep("Error opening file '%s', %s"), FileName.c_str(), strerror (errno)); @@ -4417,12 +4246,12 @@ bool cPluginEEPG::Start (void) isyslog ("Attached EEPG filter to device %d", i); } } - ConfDir = NULL; + char *ConfDir = NULL; // Initialize any background activities the plugin shall perform. DIR *ConfigDir; - if (ConfDir == NULL) { - Asprintf (&ConfDir, "%s/eepg", cPlugin::ConfigDirectory ()); - } + //if (ConfDir == NULL) { + Asprintf (&ConfDir, "%s/eepg", cPlugin::ConfigDirectory ()); + //} ConfigDir = opendir (ConfDir); if (ConfigDir == NULL) { esyslog ("EEPG: Error opening directory '%s', %s", ConfDir, strerror (errno)); @@ -4432,6 +4261,8 @@ bool cPluginEEPG::Start (void) isyslog ("EEPG: Success creating directory '%s'", ConfDir); } } + cSetupEEPG::getInstance()->setConfDir(ConfDir); + CheckCreateFile(EEPG_FILE_EQUIV, FileEquivalences); CheckCreateFile("sky_it.dict", SkyItDictionary); CheckCreateFile("sky_uk.dict", SkyUkDictionary); @@ -4462,7 +4293,11 @@ bool cPluginEEPG::Start (void) #if APIVERSNUM > 10725 new cEEpgHandler(); #endif + EquivHandler = new cEquivHandler(); + if (ConfDir) { + free (ConfDir); + } closedir(ConfigDir); return true; } @@ -4479,15 +4314,19 @@ void cPluginEEPG::Stop (void) } // Clean up after yourself! - if (ConfDir) { - free (ConfDir); - } +// if (ConfDir) { +// free (ConfDir); +// } if (sky_tables[0]) { free(sky_tables[0]); } if (sky_tables[1]) { free(sky_tables[1]); } + if (EquivHandler) { + delete EquivHandler; + } + } cMenuSetupPage *cPluginEEPG::SetupMenu (void) diff --git a/eepg.h b/eepg.h index b661809..18690de 100644 --- a/eepg.h +++ b/eepg.h @@ -1,8 +1,6 @@ //#define DEBUG false //#define DEBUG_STARTTIME false -#define EEPG_FILE_EQUIV "eepg.equiv" - #define MAX_THEMES 2046 //this should always be >=256, or Nagra will go wrong!! #define MAX_CHANNELS 2048 #define MAX_TITLES 262144 diff --git a/epghandler.c b/epghandler.c index 29f092b..426958d 100644 --- a/epghandler.c +++ b/epghandler.c @@ -8,20 +8,28 @@ #include "epghandler.h" #if APIVERSNUM > 10725 #include "log.h" +#include "equivhandler.h" +#include cEEpgHandler::cEEpgHandler() { - // TODO Auto-generated constructor stub LogD(4, prep("cEEpgHandler()")); - + equivHandler = new cEquivHandler(); } cEEpgHandler::~cEEpgHandler() { - // TODO Auto-generated destructor stub + delete equivHandler; + equivHandler = NULL; } bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, const SI::EIT::Event* EitEvent, uchar TableID, uchar Version) { //LogD(1, prep("HandleEitEvent")); + //DISH NID 0x1001 to 0x100B BEV 0x100 and 0x101 + //TODO move the eit handling code at least for NA providers here instead of discarding. + int nid = Schedule->ChannelID().Nid(); + if ((nid >= 0x1001 && nid <= 0x100B) || nid == 0x101 || nid == 0x100) + return true; + return false; // return true; } @@ -103,6 +111,14 @@ bool cEEpgHandler::HandleEvent(cEvent* Event) { if (!Event->Description() && !origDescription.empty()) { Event->SetDescription(origDescription.c_str()); } + + cSchedulesLock SchedulesLock (true); + cSchedules *s = (cSchedules *) cSchedules::Schedules (SchedulesLock); + if (s) { + equivHandler->updateEquivalent(s, Event->ChannelID(), Event); + } else + LogE (0, prep("Error: could not lock schedules.")); + //TODO just to see the difference //else if (!origDescription.empty() && !origDescription.compare(Event->Description())) { // origDescription.append(" | EIT: "); @@ -114,7 +130,16 @@ bool cEEpgHandler::HandleEvent(cEvent* Event) { } bool cEEpgHandler::SortSchedule(cSchedule* Schedule) { + Schedule->Sort(); + + cSchedulesLock SchedulesLock (true); + cSchedules *s = (cSchedules *) cSchedules::Schedules (SchedulesLock); + if (s) { + equivHandler->sortEquivalents(Schedule->ChannelID(), s); + } else + LogE (0, prep("Error: could not lock schedules.")); + return true; } diff --git a/epghandler.h b/epghandler.h index 61f295b..e1c6915 100644 --- a/epghandler.h +++ b/epghandler.h @@ -12,6 +12,8 @@ #include #include +class cEquivHandler; + class cEEpgHandler : public cEpgHandler { public: cEEpgHandler(); @@ -35,6 +37,7 @@ public: private: std::string origShortText; std::string origDescription; + cEquivHandler* equivHandler; }; #endif /*APIVERSNUM > 10725*/ diff --git a/equivhandler.cpp b/equivhandler.cpp new file mode 100644 index 0000000..4868f88 --- /dev/null +++ b/equivhandler.cpp @@ -0,0 +1,207 @@ +/* + * equivhandler.cpp + * + * Created on: 19.5.2012 + * Author: d.petrovski + */ + +#include "equivhandler.h" +#include "setupeepg.h" +#include "log.h" + +#include + + +static multimap cEquivHandler::equiChanMap; +static long cEquivHandler::equiChanFileTime = 0; + +cEquivHandler::cEquivHandler() +{ + loadEquivalentChannelMap(); +} + +cEquivHandler::~cEquivHandler() +{ + // TODO Auto-generated destructor stub +} + +void cEquivHandler::loadEquivalentChannelMap (void) +{ + char Buffer[1024]; + char *Line; + FILE *File; + string FileName = string(cSetupEEPG::getInstance()->getConfDir()) + "/" + EEPG_FILE_EQUIV; + multimap::iterator it,it2; + pair::iterator,multimap::iterator> ret; + + //Test if file is changed and reload + struct stat st; + if (stat(FileName.c_str(), &st)) { + LogE(0, prep("Error obtaining stats for '%s' "), FileName.c_str()); + return; + } + + if (equiChanMap.size() > 0 && equiChanFileTime == st.st_mtim.tv_nsec) + return; + else + equiChanMap.clear(); + + + File = fopen (FileName.c_str(), "r"); + if (File) { + memset (Buffer, 0, sizeof (Buffer)); + char origChanID[256]; + char equiChanID[256]; + char source[256]; + int nid = 0; + int tid = 0; + int sid = 0; + int rid = 0; + while ((Line = fgets (Buffer, sizeof (Buffer), File)) != NULL) { + Line = compactspace (skipspace (stripspace (Line))); + if (!isempty (Line)) { + if (sscanf (Line, "%[^ ] %[^ ] %[^\n]\n", origChanID, equiChanID, source) == 3) { + if (origChanID[0] != '#' && origChanID[0] != ';') { + nid = 0; + tid = 0; + sid = 0; + rid = 0; + if (sscanf (origChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) + if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { + if (sscanf (origChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) != 5) { + rid = 0; + } + tChannelID OriginalChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); + bool found = false; + //int i = 0; + cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); + if (!OriginalChannel) { + LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalency is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? + continue; + } + if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { + if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) + != 5) { + rid = 0; + } + tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); + cChannel *EquivChannel = Channels.GetByChannelID (EquivChID, false); //TODO use valid function? + if (EquivChannel) { + ret = equiChanMap.equal_range(*OriginalChID.ToString()); + for (it=ret.first; it!=ret.second; ++it) + if ((*it).second == *OriginalChID.ToString()) { + found = true; + break; + } + + if (!found) { + string origCh(*OriginalChID.ToString()); + string equiCh(*EquivChID.ToString()); + equiChanMap.insert(pair(origCh.c_str(),equiCh.c_str())); + LogD(4, prep("Found %s equivalent to %s. origCh %s"), *EquivChID.ToString(), *OriginalChID.ToString(), origCh.c_str()); + for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) + LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); + } + } else + LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); + } + } //if scanf string1 + } //if string1 + } //if scanf + } //if isempty + } //while + fclose (File); + equiChanFileTime = st.st_mtim.tv_nsec; + LogD(3, prep("Loaded %i equivalents."), equiChanMap.size()); + for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) + LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); + } //if file +} + +void cEquivHandler::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent){ + multimap::iterator it; + pair::iterator,multimap::iterator> ret; + + LogD(3, prep("Start updateEquivalent %s"), *channelID.ToString()); + + ret = equiChanMap.equal_range(*channelID.ToString()); + for (it=ret.first; it!=ret.second; ++it) { + LogD(1, prep("equivalent channel exists")); + tChannelID equChannelID (tChannelID::FromString((*it).second.c_str())); + cChannel *equChannel = GetChannelByID (equChannelID, false); + if (equChannel) { + LogD(3, prep("found Equivalent channel %s"), *equChannelID.ToString()); + cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (equChannel, true); + cEvent *pEqvEvent = (cEvent *) pSchedule->GetEvent (pEvent->EventID(), pEvent->StartTime()); + if (pEqvEvent) { + LogD(1, prep("equivalent event exists")); + if (pEqvEvent == pEvent) { + LogD(1, prep("equal event exists")); + + } else { + LogD(1, prep("remove equivalent")); + pSchedule->DelEvent(pEqvEvent); + cEvent* newEvent = new cEvent (pEvent->EventID()); + newEvent->SetTableID (pEvent->TableID()); + newEvent->SetStartTime (pEvent->StartTime()); + newEvent->SetDuration (pEvent->Duration()); + newEvent->SetVersion (pEvent->Version()); +// newEvent->SetContents(pEvent->Contents()); + newEvent->SetParentalRating(pEvent->ParentalRating()); + newEvent->SetVps (pEvent->Vps()); + newEvent->SetTitle (pEvent->Title ()); + newEvent->SetShortText (pEvent->ShortText ()); + newEvent->SetDescription (pEvent->Description ()); +// newEvent->SetComponents (pEvent->Components()); + newEvent->FixEpgBugs (); + + pSchedule->AddEvent(newEvent); + + } + + } else { + LogD(1, prep("equivalent event does not exist")); + cEvent* newEvent = new cEvent (pEvent->EventID()); + newEvent->SetTableID (pEvent->TableID()); + newEvent->SetStartTime (pEvent->StartTime()); + newEvent->SetDuration (pEvent->Duration()); + newEvent->SetVersion (pEvent->Version()); +// newEvent->SetContents(pEvent->Contents()); + newEvent->SetParentalRating(pEvent->ParentalRating()); + newEvent->SetVps (pEvent->Vps()); + newEvent->SetTitle (pEvent->Title ()); + newEvent->SetShortText (pEvent->ShortText ()); + newEvent->SetDescription (pEvent->Description ()); +// newEvent->SetComponents (pEvent->Components()); + newEvent->FixEpgBugs (); + + pSchedule->AddEvent(newEvent); + + } + } + } +} + +void cEquivHandler::sortEquivalents(tChannelID channelID, cSchedules* Schedules) +{ + multimap::iterator it; + pair < multimap < string, string > ::iterator, multimap < string, string + > ::iterator > ret; + ret = cEquivHandler::getEquiChanMap().equal_range(*channelID.ToString()); + for (it = ret.first; it != ret.second; ++it) + { + LogD(3, prep("equivalent channel exists")); + tChannelID equChannelID(tChannelID::FromString((*it).second.c_str())); + cChannel* pChannel = GetChannelByID(equChannelID, false); + if (pChannel) + { + LogD(3, prep("found Equivalent channel %s"), + *equChannelID.ToString()); + cSchedule* pSchedule = (cSchedule *) Schedules->GetSchedule(pChannel, + true); + + pSchedule->Sort(); + Schedules->SetModified(pSchedule); + } + } +} diff --git a/equivhandler.h b/equivhandler.h new file mode 100644 index 0000000..da2d7d9 --- /dev/null +++ b/equivhandler.h @@ -0,0 +1,37 @@ +/* + * equivhandler.h + * + * Created on: 19.5.2012 + * Author: d.petrovski + */ + +#ifndef EQUIVHANDLER_H_ +#define EQUIVHANDLER_H_ + +#include +#include +#include + +#define EEPG_FILE_EQUIV "eepg.equiv" + +using namespace std; + +class cEquivHandler +{ +public: + cEquivHandler(); + virtual ~cEquivHandler(); + + void loadEquivalentChannelMap (void); + void updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent); + void sortEquivalents(tChannelID channelID, cSchedules* Schedules); + + static multimap getEquiChanMap() { return cEquivHandler::equiChanMap; }; + +private: + static multimap equiChanMap; + static long equiChanFileTime; + +}; + +#endif /* EQUIVHANDLER_H_ */ diff --git a/setupeepg.c b/setupeepg.c index 3738227..54f8243 100644 --- a/setupeepg.c +++ b/setupeepg.c @@ -23,14 +23,13 @@ cSetupEEPG::cSetupEEPG (void) #ifdef DEBUG LogLevel = 0; #endif - } cSetupEEPG* cSetupEEPG::getInstance() { - if (!_setupEEPG) - _setupEEPG = new cSetupEEPG(); + if (!_setupEEPG) + _setupEEPG = new cSetupEEPG(); - return _setupEEPG; + return _setupEEPG; } diff --git a/setupeepg.h b/setupeepg.h index f5e342a..ffd9eb8 100644 --- a/setupeepg.h +++ b/setupeepg.h @@ -24,12 +24,25 @@ public: public: static cSetupEEPG* getInstance(); + char* getConfDir() const + { + return ConfDir; + } + + void setConfDir(char* confDir) + { + ConfDir = confDir; + } + private: cSetupEEPG (void); cSetupEEPG(cSetupEEPG const&); // copy constructor is private cSetupEEPG& operator=(cSetupEEPG const&); // assignment operator is private static cSetupEEPG* _setupEEPG; +private: + char *ConfDir; + }; #endif /* SETUPEEPG_H_ */ -- cgit v1.2.3 From 07e0eccce3b565fb13f2d675f6eddc38c4917b89 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 23 May 2012 21:50:41 +0200 Subject: partial compile fix --- Makefile | 2 +- equivhandler.c | 207 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ equivhandler.cpp | 207 ------------------------------------------------------- equivhandler.h | 1 + 4 files changed, 209 insertions(+), 208 deletions(-) create mode 100644 equivhandler.c delete mode 100644 equivhandler.cpp diff --git a/Makefile b/Makefile index a2d413e..b020216 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"' ### The object files (add further files here): -OBJS = $(PLUGIN).o dish.o epghandler.o setupeepg.o +OBJS = $(PLUGIN).o dish.o epghandler.o setupeepg.o equivhandler.o ifdef DBG CXXFLAGS += -g diff --git a/equivhandler.c b/equivhandler.c new file mode 100644 index 0000000..3088027 --- /dev/null +++ b/equivhandler.c @@ -0,0 +1,207 @@ +/* + * equivhandler.cpp + * + * Created on: 19.5.2012 + * Author: d.petrovski + */ + +#include "equivhandler.h" +#include "setupeepg.h" +#include "log.h" + +#include + + +multimap cEquivHandler::equiChanMap; +long cEquivHandler::equiChanFileTime = 0; + +cEquivHandler::cEquivHandler() +{ + loadEquivalentChannelMap(); +} + +cEquivHandler::~cEquivHandler() +{ + // TODO Auto-generated destructor stub +} + +void cEquivHandler::loadEquivalentChannelMap (void) +{ + char Buffer[1024]; + char *Line; + FILE *File; + string FileName = string(cSetupEEPG::getInstance()->getConfDir()) + "/" + EEPG_FILE_EQUIV; + multimap::iterator it,it2; + pair::iterator,multimap::iterator> ret; + + //Test if file is changed and reload + struct stat st; + if (stat(FileName.c_str(), &st)) { + LogE(0, prep("Error obtaining stats for '%s' "), FileName.c_str()); + return; + } + + if (equiChanMap.size() > 0 && equiChanFileTime == st.st_mtim.tv_nsec) + return; + else + equiChanMap.clear(); + + + File = fopen (FileName.c_str(), "r"); + if (File) { + memset (Buffer, 0, sizeof (Buffer)); + char origChanID[256]; + char equiChanID[256]; + char source[256]; + int nid = 0; + int tid = 0; + int sid = 0; + int rid = 0; + while ((Line = fgets (Buffer, sizeof (Buffer), File)) != NULL) { + Line = compactspace (skipspace (stripspace (Line))); + if (!isempty (Line)) { + if (sscanf (Line, "%[^ ] %[^ ] %[^\n]\n", origChanID, equiChanID, source) == 3) { + if (origChanID[0] != '#' && origChanID[0] != ';') { + nid = 0; + tid = 0; + sid = 0; + rid = 0; + if (sscanf (origChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) + if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { + if (sscanf (origChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) != 5) { + rid = 0; + } + tChannelID OriginalChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); + bool found = false; + //int i = 0; + cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); + if (!OriginalChannel) { + LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalency is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? + continue; + } + if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { + if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) + != 5) { + rid = 0; + } + tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); + cChannel *EquivChannel = Channels.GetByChannelID (EquivChID, false); //TODO use valid function? + if (EquivChannel) { + ret = equiChanMap.equal_range(*OriginalChID.ToString()); + for (it=ret.first; it!=ret.second; ++it) + if ((*it).second == *OriginalChID.ToString()) { + found = true; + break; + } + + if (!found) { + string origCh(*OriginalChID.ToString()); + string equiCh(*EquivChID.ToString()); + equiChanMap.insert(pair(origCh.c_str(),equiCh.c_str())); + LogD(4, prep("Found %s equivalent to %s. origCh %s"), *EquivChID.ToString(), *OriginalChID.ToString(), origCh.c_str()); + for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) + LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); + } + } else + LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); + } + } //if scanf string1 + } //if string1 + } //if scanf + } //if isempty + } //while + fclose (File); + equiChanFileTime = st.st_mtim.tv_nsec; + LogD(3, prep("Loaded %i equivalents."), equiChanMap.size()); + for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) + LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); + } //if file +} + +void cEquivHandler::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent){ + multimap::iterator it; + pair::iterator,multimap::iterator> ret; + + LogD(3, prep("Start updateEquivalent %s"), *channelID.ToString()); + + ret = equiChanMap.equal_range(*channelID.ToString()); + for (it=ret.first; it!=ret.second; ++it) { + LogD(1, prep("equivalent channel exists")); + tChannelID equChannelID (tChannelID::FromString((*it).second.c_str())); + cChannel *equChannel = GetChannelByID (equChannelID, false); + if (equChannel) { + LogD(3, prep("found Equivalent channel %s"), *equChannelID.ToString()); + cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (equChannel, true); + cEvent *pEqvEvent = (cEvent *) pSchedule->GetEvent (pEvent->EventID(), pEvent->StartTime()); + if (pEqvEvent) { + LogD(1, prep("equivalent event exists")); + if (pEqvEvent == pEvent) { + LogD(1, prep("equal event exists")); + + } else { + LogD(1, prep("remove equivalent")); + pSchedule->DelEvent(pEqvEvent); + cEvent* newEvent = new cEvent (pEvent->EventID()); + newEvent->SetTableID (pEvent->TableID()); + newEvent->SetStartTime (pEvent->StartTime()); + newEvent->SetDuration (pEvent->Duration()); + newEvent->SetVersion (pEvent->Version()); +// newEvent->SetContents(pEvent->Contents()); + newEvent->SetParentalRating(pEvent->ParentalRating()); + newEvent->SetVps (pEvent->Vps()); + newEvent->SetTitle (pEvent->Title ()); + newEvent->SetShortText (pEvent->ShortText ()); + newEvent->SetDescription (pEvent->Description ()); +// newEvent->SetComponents (pEvent->Components()); + newEvent->FixEpgBugs (); + + pSchedule->AddEvent(newEvent); + + } + + } else { + LogD(1, prep("equivalent event does not exist")); + cEvent* newEvent = new cEvent (pEvent->EventID()); + newEvent->SetTableID (pEvent->TableID()); + newEvent->SetStartTime (pEvent->StartTime()); + newEvent->SetDuration (pEvent->Duration()); + newEvent->SetVersion (pEvent->Version()); +// newEvent->SetContents(pEvent->Contents()); + newEvent->SetParentalRating(pEvent->ParentalRating()); + newEvent->SetVps (pEvent->Vps()); + newEvent->SetTitle (pEvent->Title ()); + newEvent->SetShortText (pEvent->ShortText ()); + newEvent->SetDescription (pEvent->Description ()); +// newEvent->SetComponents (pEvent->Components()); + newEvent->FixEpgBugs (); + + pSchedule->AddEvent(newEvent); + + } + } + } +} + +void cEquivHandler::sortEquivalents(tChannelID channelID, cSchedules* Schedules) +{ + multimap::iterator it; + pair < multimap < string, string > ::iterator, multimap < string, string + > ::iterator > ret; + ret = cEquivHandler::getEquiChanMap().equal_range(*channelID.ToString()); + for (it = ret.first; it != ret.second; ++it) + { + LogD(3, prep("equivalent channel exists")); + tChannelID equChannelID(tChannelID::FromString((*it).second.c_str())); + cChannel* pChannel = GetChannelByID(equChannelID, false); + if (pChannel) + { + LogD(3, prep("found Equivalent channel %s"), + *equChannelID.ToString()); + cSchedule* pSchedule = (cSchedule *) Schedules->GetSchedule(pChannel, + true); + + pSchedule->Sort(); + Schedules->SetModified(pSchedule); + } + } +} diff --git a/equivhandler.cpp b/equivhandler.cpp deleted file mode 100644 index 4868f88..0000000 --- a/equivhandler.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* - * equivhandler.cpp - * - * Created on: 19.5.2012 - * Author: d.petrovski - */ - -#include "equivhandler.h" -#include "setupeepg.h" -#include "log.h" - -#include - - -static multimap cEquivHandler::equiChanMap; -static long cEquivHandler::equiChanFileTime = 0; - -cEquivHandler::cEquivHandler() -{ - loadEquivalentChannelMap(); -} - -cEquivHandler::~cEquivHandler() -{ - // TODO Auto-generated destructor stub -} - -void cEquivHandler::loadEquivalentChannelMap (void) -{ - char Buffer[1024]; - char *Line; - FILE *File; - string FileName = string(cSetupEEPG::getInstance()->getConfDir()) + "/" + EEPG_FILE_EQUIV; - multimap::iterator it,it2; - pair::iterator,multimap::iterator> ret; - - //Test if file is changed and reload - struct stat st; - if (stat(FileName.c_str(), &st)) { - LogE(0, prep("Error obtaining stats for '%s' "), FileName.c_str()); - return; - } - - if (equiChanMap.size() > 0 && equiChanFileTime == st.st_mtim.tv_nsec) - return; - else - equiChanMap.clear(); - - - File = fopen (FileName.c_str(), "r"); - if (File) { - memset (Buffer, 0, sizeof (Buffer)); - char origChanID[256]; - char equiChanID[256]; - char source[256]; - int nid = 0; - int tid = 0; - int sid = 0; - int rid = 0; - while ((Line = fgets (Buffer, sizeof (Buffer), File)) != NULL) { - Line = compactspace (skipspace (stripspace (Line))); - if (!isempty (Line)) { - if (sscanf (Line, "%[^ ] %[^ ] %[^\n]\n", origChanID, equiChanID, source) == 3) { - if (origChanID[0] != '#' && origChanID[0] != ';') { - nid = 0; - tid = 0; - sid = 0; - rid = 0; - if (sscanf (origChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) - if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { - if (sscanf (origChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) != 5) { - rid = 0; - } - tChannelID OriginalChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); - bool found = false; - //int i = 0; - cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false); - if (!OriginalChannel) { - LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalency is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing? - continue; - } - if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) { - if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid) - != 5) { - rid = 0; - } - tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid); - cChannel *EquivChannel = Channels.GetByChannelID (EquivChID, false); //TODO use valid function? - if (EquivChannel) { - ret = equiChanMap.equal_range(*OriginalChID.ToString()); - for (it=ret.first; it!=ret.second; ++it) - if ((*it).second == *OriginalChID.ToString()) { - found = true; - break; - } - - if (!found) { - string origCh(*OriginalChID.ToString()); - string equiCh(*EquivChID.ToString()); - equiChanMap.insert(pair(origCh.c_str(),equiCh.c_str())); - LogD(4, prep("Found %s equivalent to %s. origCh %s"), *EquivChID.ToString(), *OriginalChID.ToString(), origCh.c_str()); - for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) - LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); - } - } else - LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID); - } - } //if scanf string1 - } //if string1 - } //if scanf - } //if isempty - } //while - fclose (File); - equiChanFileTime = st.st_mtim.tv_nsec; - LogD(3, prep("Loaded %i equivalents."), equiChanMap.size()); - for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) - LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); - } //if file -} - -void cEquivHandler::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent){ - multimap::iterator it; - pair::iterator,multimap::iterator> ret; - - LogD(3, prep("Start updateEquivalent %s"), *channelID.ToString()); - - ret = equiChanMap.equal_range(*channelID.ToString()); - for (it=ret.first; it!=ret.second; ++it) { - LogD(1, prep("equivalent channel exists")); - tChannelID equChannelID (tChannelID::FromString((*it).second.c_str())); - cChannel *equChannel = GetChannelByID (equChannelID, false); - if (equChannel) { - LogD(3, prep("found Equivalent channel %s"), *equChannelID.ToString()); - cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (equChannel, true); - cEvent *pEqvEvent = (cEvent *) pSchedule->GetEvent (pEvent->EventID(), pEvent->StartTime()); - if (pEqvEvent) { - LogD(1, prep("equivalent event exists")); - if (pEqvEvent == pEvent) { - LogD(1, prep("equal event exists")); - - } else { - LogD(1, prep("remove equivalent")); - pSchedule->DelEvent(pEqvEvent); - cEvent* newEvent = new cEvent (pEvent->EventID()); - newEvent->SetTableID (pEvent->TableID()); - newEvent->SetStartTime (pEvent->StartTime()); - newEvent->SetDuration (pEvent->Duration()); - newEvent->SetVersion (pEvent->Version()); -// newEvent->SetContents(pEvent->Contents()); - newEvent->SetParentalRating(pEvent->ParentalRating()); - newEvent->SetVps (pEvent->Vps()); - newEvent->SetTitle (pEvent->Title ()); - newEvent->SetShortText (pEvent->ShortText ()); - newEvent->SetDescription (pEvent->Description ()); -// newEvent->SetComponents (pEvent->Components()); - newEvent->FixEpgBugs (); - - pSchedule->AddEvent(newEvent); - - } - - } else { - LogD(1, prep("equivalent event does not exist")); - cEvent* newEvent = new cEvent (pEvent->EventID()); - newEvent->SetTableID (pEvent->TableID()); - newEvent->SetStartTime (pEvent->StartTime()); - newEvent->SetDuration (pEvent->Duration()); - newEvent->SetVersion (pEvent->Version()); -// newEvent->SetContents(pEvent->Contents()); - newEvent->SetParentalRating(pEvent->ParentalRating()); - newEvent->SetVps (pEvent->Vps()); - newEvent->SetTitle (pEvent->Title ()); - newEvent->SetShortText (pEvent->ShortText ()); - newEvent->SetDescription (pEvent->Description ()); -// newEvent->SetComponents (pEvent->Components()); - newEvent->FixEpgBugs (); - - pSchedule->AddEvent(newEvent); - - } - } - } -} - -void cEquivHandler::sortEquivalents(tChannelID channelID, cSchedules* Schedules) -{ - multimap::iterator it; - pair < multimap < string, string > ::iterator, multimap < string, string - > ::iterator > ret; - ret = cEquivHandler::getEquiChanMap().equal_range(*channelID.ToString()); - for (it = ret.first; it != ret.second; ++it) - { - LogD(3, prep("equivalent channel exists")); - tChannelID equChannelID(tChannelID::FromString((*it).second.c_str())); - cChannel* pChannel = GetChannelByID(equChannelID, false); - if (pChannel) - { - LogD(3, prep("found Equivalent channel %s"), - *equChannelID.ToString()); - cSchedule* pSchedule = (cSchedule *) Schedules->GetSchedule(pChannel, - true); - - pSchedule->Sort(); - Schedules->SetModified(pSchedule); - } - } -} diff --git a/equivhandler.h b/equivhandler.h index da2d7d9..fdfd343 100644 --- a/equivhandler.h +++ b/equivhandler.h @@ -11,6 +11,7 @@ #include #include #include +#include #define EEPG_FILE_EQUIV "eepg.equiv" -- cgit v1.2.3 From 7089617d8186143cfe946596dfafd650cb3028f9 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 23 May 2012 22:07:47 +0200 Subject: move utilities to separate files --- Makefile | 2 +- eepg.c | 110 +------------------------------------------------------ equivhandler.c | 1 + util.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ util.h | 24 ++++++++++++ 5 files changed, 140 insertions(+), 110 deletions(-) create mode 100644 util.c create mode 100644 util.h diff --git a/Makefile b/Makefile index b020216..b63221f 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"' ### The object files (add further files here): -OBJS = $(PLUGIN).o dish.o epghandler.o setupeepg.o equivhandler.o +OBJS = $(PLUGIN).o dish.o epghandler.o setupeepg.o equivhandler.o util.o ifdef DBG CXXFLAGS += -g diff --git a/eepg.c b/eepg.c index 91a08c0..337e93a 100644 --- a/eepg.c +++ b/eepg.c @@ -44,6 +44,7 @@ #include "log.h" #include "setupeepg.h" #include "equivhandler.h" +#include "util.h" #include #include @@ -168,8 +169,6 @@ unsigned int crc16 (unsigned int crc, unsigned char const *p, int len) #define STARTTIME_BIAS (20*60) -static int AvailableSources[32]; -static int NumberOfAvailableSources = 0; static int LastVersionNagra = -1; //currently only used for Nagra, should be stored per transponder, per system @@ -772,113 +771,6 @@ nextloop1: //unsigned char DecodeErrorText[4096]; //TODO only used for debugging? -int Yesterday; -int YesterdayEpoch; -int YesterdayEpochUTC; - -/* - * Convert local time to UTC - */ -time_t LocalTime2UTC (time_t t) -{ - struct tm *temp; - - temp = gmtime (&t); - temp->tm_isdst = -1; - return mktime (temp); -} - -/* - * Convert UTC to local time - */ -time_t UTC2LocalTime (time_t t) -{ - return 2 * t - LocalTime2UTC (t); -} - -void GetLocalTimeOffset (void) -{ - time_t timeLocal; - struct tm *tmCurrent; - - timeLocal = time (NULL); - timeLocal -= 86400; - tmCurrent = gmtime (&timeLocal); - Yesterday = tmCurrent->tm_wday; - tmCurrent->tm_hour = 0; - tmCurrent->tm_min = 0; - tmCurrent->tm_sec = 0; - tmCurrent->tm_isdst = -1; - YesterdayEpoch = mktime (tmCurrent); - YesterdayEpochUTC = UTC2LocalTime (mktime (tmCurrent)); -} - -void CleanString (unsigned char *String) -{ - -// LogD (1, prep("Unclean: %s"), String); - unsigned char *Src; - unsigned char *Dst; - int Spaces; - int pC; - Src = String; - Dst = String; - Spaces = 0; - pC = 0; - while (*Src) { - // corrections - if (*Src == 0x8c) { // iso-8859-2 LATIN CAPITAL LETTER S WITH ACUTE - *Src = 0xa6; - } - if (*Src == 0x8f) { // iso-8859-2 LATIN CAPITAL LETTER Z WITH ACUTE - *Src = 0xac; - } - - if (*Src!=0x0A && *Src < 0x20) { //don't remove newline - *Src = 0x20; - } - if (*Src == 0x20) { - Spaces++; - if (pC == 0) { - Spaces++; - } - } else { - Spaces = 0; - } - if (Spaces < 2) { - *Dst = *Src; - Dst++; - pC++; - } - Src++; - } - if (Spaces > 0) { - Dst--; - *Dst = 0; - } else { - *Dst = 0; - } -// LogD (1, prep("Clean: %s"), String); -} - -cChannel *GetChannelByID(tChannelID & channelID, bool searchOtherPos) -{ - cChannel *VC = Channels.GetByChannelID(channelID, true); - if(!VC && searchOtherPos){ - //look on other satpositions - for(int i = 0;i < NumberOfAvailableSources;i++){ - channelID = tChannelID(AvailableSources[i], channelID.Nid(), channelID.Tid(), channelID.Sid()); - VC = Channels.GetByChannelID(channelID, true); - if(VC){ - //found this actually on satellite nextdoor... - break; - } - } - } - - return VC; -} - bool cFilterEEPG::GetThemesSKYBOX (void) //TODO can't we read this from the DVB stream? { string FileName = cSetupEEPG::getInstance()->getConfDir(); diff --git a/equivhandler.c b/equivhandler.c index 3088027..3c99534 100644 --- a/equivhandler.c +++ b/equivhandler.c @@ -8,6 +8,7 @@ #include "equivhandler.h" #include "setupeepg.h" #include "log.h" +#include "util.h" #include diff --git a/util.c b/util.c new file mode 100644 index 0000000..68708d7 --- /dev/null +++ b/util.c @@ -0,0 +1,113 @@ +/* + * util.c + * + * Created on: 23.5.2012 + * Author: d.petrovski + */ + +int NumberOfAvailableSources = 0; + +cChannel *GetChannelByID(tChannelID & channelID, bool searchOtherPos) +{ + cChannel *VC = Channels.GetByChannelID(channelID, true); + if(!VC && searchOtherPos){ + //look on other satpositions + for(int i = 0;i < NumberOfAvailableSources;i++){ + channelID = tChannelID(AvailableSources[i], channelID.Nid(), channelID.Tid(), channelID.Sid()); + VC = Channels.GetByChannelID(channelID, true); + if(VC){ + //found this actually on satellite nextdoor... + break; + } + } + } + + return VC; +} + +/* + * Convert local time to UTC + */ +time_t LocalTime2UTC (time_t t) +{ + struct tm *temp; + + temp = gmtime (&t); + temp->tm_isdst = -1; + return mktime (temp); +} + +/* + * Convert UTC to local time + */ +time_t UTC2LocalTime (time_t t) +{ + return 2 * t - LocalTime2UTC (t); +} + +void GetLocalTimeOffset (void) +{ + time_t timeLocal; + struct tm *tmCurrent; + + timeLocal = time (NULL); + timeLocal -= 86400; + tmCurrent = gmtime (&timeLocal); + Yesterday = tmCurrent->tm_wday; + tmCurrent->tm_hour = 0; + tmCurrent->tm_min = 0; + tmCurrent->tm_sec = 0; + tmCurrent->tm_isdst = -1; + YesterdayEpoch = mktime (tmCurrent); + YesterdayEpochUTC = UTC2LocalTime (mktime (tmCurrent)); +} + +void CleanString (unsigned char *String) +{ + +// LogD (1, prep("Unclean: %s"), String); + unsigned char *Src; + unsigned char *Dst; + int Spaces; + int pC; + Src = String; + Dst = String; + Spaces = 0; + pC = 0; + while (*Src) { + // corrections + if (*Src == 0x8c) { // iso-8859-2 LATIN CAPITAL LETTER S WITH ACUTE + *Src = 0xa6; + } + if (*Src == 0x8f) { // iso-8859-2 LATIN CAPITAL LETTER Z WITH ACUTE + *Src = 0xac; + } + + if (*Src!=0x0A && *Src < 0x20) { //don't remove newline + *Src = 0x20; + } + if (*Src == 0x20) { + Spaces++; + if (pC == 0) { + Spaces++; + } + } else { + Spaces = 0; + } + if (Spaces < 2) { + *Dst = *Src; + Dst++; + pC++; + } + Src++; + } + if (Spaces > 0) { + Dst--; + *Dst = 0; + } else { + *Dst = 0; + } +// LogD (1, prep("Clean: %s"), String); +} + + diff --git a/util.h b/util.h new file mode 100644 index 0000000..a94390a --- /dev/null +++ b/util.h @@ -0,0 +1,24 @@ +/* + * util.h + * + * Created on: 23.5.2012 + * Author: d.petrovski + */ + +#ifndef UTIL_H_ +#define UTIL_H_ + +int AvailableSources[32]; +int NumberOfAvailableSources; + +int Yesterday; +int YesterdayEpoch; +int YesterdayEpochUTC; + +cChannel *GetChannelByID(tChannelID & channelID, bool searchOtherPos); +time_t LocalTime2UTC (time_t t); +time_t UTC2LocalTime (time_t t); +void GetLocalTimeOffset (void); +void CleanString (unsigned char *String); + +#endif /* UTIL_H_ */ -- cgit v1.2.3 From 80c9c7fa84f17dbe2779c2a27dac82a001e33101 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Thu, 24 May 2012 10:49:55 +0200 Subject: add namespace util --- eepg.c | 1 + equivhandler.c | 1 + util.c | 7 +++++-- util.h | 9 +++++++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/eepg.c b/eepg.c index 337e93a..563c2f4 100644 --- a/eepg.c +++ b/eepg.c @@ -73,6 +73,7 @@ template T REALLOC(T Var, size_t Size) } using namespace std; +using namespace util; const char *optPats[] = { "%s", diff --git a/equivhandler.c b/equivhandler.c index 3c99534..9b0e989 100644 --- a/equivhandler.c +++ b/equivhandler.c @@ -12,6 +12,7 @@ #include +using namespace util; multimap cEquivHandler::equiChanMap; long cEquivHandler::equiChanFileTime = 0; diff --git a/util.c b/util.c index 68708d7..b60547d 100644 --- a/util.c +++ b/util.c @@ -4,8 +4,11 @@ * Created on: 23.5.2012 * Author: d.petrovski */ +#include "util.h" +#include -int NumberOfAvailableSources = 0; +namespace util +{ cChannel *GetChannelByID(tChannelID & channelID, bool searchOtherPos) { @@ -110,4 +113,4 @@ void CleanString (unsigned char *String) // LogD (1, prep("Clean: %s"), String); } - +} diff --git a/util.h b/util.h index a94390a..8c12184 100644 --- a/util.h +++ b/util.h @@ -7,9 +7,14 @@ #ifndef UTIL_H_ #define UTIL_H_ +#include +class cChannel; +struct tChannelID; +namespace util +{ int AvailableSources[32]; -int NumberOfAvailableSources; +int NumberOfAvailableSources = 0; int Yesterday; int YesterdayEpoch; @@ -20,5 +25,5 @@ time_t LocalTime2UTC (time_t t); time_t UTC2LocalTime (time_t t); void GetLocalTimeOffset (void); void CleanString (unsigned char *String); - +} #endif /* UTIL_H_ */ -- cgit v1.2.3 From f16623ebfdab035c9baea1f20041fc63a0f98ef3 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 30 May 2012 17:39:22 +0200 Subject: add category and genere to the description usable with epgsearch move dish category and theme to the description change MHW2 delimiter --- eepg.c | 62 +++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/eepg.c b/eepg.c index f9e0daf..255a7fb 100644 --- a/eepg.c +++ b/eepg.c @@ -1343,7 +1343,7 @@ int cFilterEEPG::GetThemesMHW2 (const u_char * Data, int Length) if (Length >= (pSubThemeName + lenSubThemeName)) if (lenSubThemeName > 0) if ((lenThemeName + lenSubThemeName + 2) < 256) { - Themes[pThemeId][lenThemeName] = ' '; + Themes[pThemeId][lenThemeName] = '-'; decodeText2(&Data[pSubThemeName],lenSubThemeName,(char*)&Themes[pThemeId][lenThemeName + 1],256); //memcpy (&Themes[pThemeId][lenThemeName + 1], &Data[pSubThemeName], lenSubThemeName); } @@ -1594,13 +1594,44 @@ void cFilterEEPG::WriteToSchedule (cSchedule * ps[MAX_EQUIVALENCES], unsigned sh } Asprintf (&tmp, "%s - %d\'", Themes[ThemeId], Duration); Event->SetShortText (tmp); + free(tmp); //strreplace(t, '|', '\n'); if (SummText != 0x00) { WrittenSummary = true; CleanString ((uchar *) SummText); + + //Add themes and categories epgsearch style + char *theme; + Asprintf (&theme, "%s", Themes[ThemeId]); + if (theme && 0 != strcmp(theme,"")) { + char *category, *genre; + category = NULL; + genre = NULL; + char *split = strchr(theme, '-'); // Look for '-' delim to separate category from genre + if (split){ + *split = 0; + category = theme; + genre = (split[1] == 0x20) ? split + 2 : split + 1; + }else{ + category = theme; + } + string fmt; + fmt = "%s"; + if (stripspace(category)) { + fmt += "\nCategory: %s"; + } + if (genre) { + fmt += "\nGenre: %s"; + } + Asprintf (&tmp, fmt.c_str(), SummText, category, stripspace (genre)); + + Event->SetDescription (tmp); + free(tmp); + free(theme); + } + else Event->SetDescription (SummText); } - free (tmp); if (newEvent) ps[eq]->AddEvent (newEvent); //newEvent->FixEpgBugs (); causes segfault @@ -3415,26 +3446,20 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat pEvent->SetTitle(DishEventDescriptor->getName()); //LogD(2, prep("channelID: %s DishTitle: %s"), *channel->GetChannelID().ToString(), DishShortEventDescriptor->getText()); // pEvent->SetDescription(DishExtendedEventDescriptor->getText()); + pEvent->SetShortText(DishEventDescriptor->getShortText()); char *tmp; string fmt; + fmt = "%s"; - if (0 != strcmp(DishEventDescriptor->getShortText(),"") && DishEventDescriptor->hasTheme()) { - fmt += " - "; + if (DishEventDescriptor->hasTheme()) { + fmt += "\nTheme: "; } fmt += "%s"; - if (DishEventDescriptor->hasTheme() && DishEventDescriptor->hasCategory()) { - fmt += " ~ "; + if (DishEventDescriptor->hasCategory()) { + fmt += "\nCategory: "; } fmt += "%s"; - Asprintf (&tmp, fmt.c_str(), DishEventDescriptor->getShortText() - , DishEventDescriptor->getTheme() - , DishEventDescriptor->getCategory()); - pEvent->SetShortText(tmp); - //LogD(2, prep("EEPGDEBUG:DishTheme:%x-DishCategory:%x)"), DishTheme, DishCategory); - free(tmp); - - fmt = "%s"; if (0 != strcmp(DishEventDescriptor->getDescription(),"") && (0 != strcmp(DishEventDescriptor->getRating(),"") || 0 != strcmp(DishEventDescriptor->getStarRating(),""))) { @@ -3453,11 +3478,10 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat } Asprintf (&tmp, fmt.c_str(), DishEventDescriptor->getDescription() - , DishEventDescriptor->getRating() - , DishEventDescriptor->getStarRating() - , DishEventDescriptor->getProgramId() - , DishEventDescriptor->getSeriesId() - , orgAirDate == 0 || !dateok ? "" : datestr); + , DishEventDescriptor->getTheme(), DishEventDescriptor->getCategory() + , DishEventDescriptor->getRating(), DishEventDescriptor->getStarRating() + , DishEventDescriptor->getProgramId(), DishEventDescriptor->getSeriesId() + , orgAirDate == 0 || !dateok ? "" : datestr); pEvent->SetDescription(tmp); free(tmp); -- cgit v1.2.3 From 15fee6896cb3cc24c0ae14106efdbc328a07ff79 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Fri, 1 Jun 2012 01:17:44 +0200 Subject: fix compile, but can not lock schedule --- epghandler.c | 14 ++++++++++---- util.c | 7 +++++++ util.h | 10 +++++----- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/epghandler.c b/epghandler.c index 426958d..64bb208 100644 --- a/epghandler.c +++ b/epghandler.c @@ -112,12 +112,15 @@ bool cEEpgHandler::HandleEvent(cEvent* Event) { Event->SetDescription(origDescription.c_str()); } - cSchedulesLock SchedulesLock (true); + if (equivHandler->getEquiChanMap().count(*Event->ChannelID().ToString()) <= 0) + return true; + + cSchedulesLock SchedulesLock (false); cSchedules *s = (cSchedules *) cSchedules::Schedules (SchedulesLock); if (s) { equivHandler->updateEquivalent(s, Event->ChannelID(), Event); } else - LogE (0, prep("Error: could not lock schedules.")); + LogD (0, prep("Error: could not lock schedules.")); //TODO just to see the difference //else if (!origDescription.empty() && !origDescription.compare(Event->Description())) { @@ -133,12 +136,15 @@ bool cEEpgHandler::SortSchedule(cSchedule* Schedule) { Schedule->Sort(); - cSchedulesLock SchedulesLock (true); + if (equivHandler->getEquiChanMap().count(*Schedule->ChannelID().ToString()) <= 0) + return true; + + cSchedulesLock SchedulesLock (false); cSchedules *s = (cSchedules *) cSchedules::Schedules (SchedulesLock); if (s) { equivHandler->sortEquivalents(Schedule->ChannelID(), s); } else - LogE (0, prep("Error: could not lock schedules.")); + LogD (0, prep("Error: could not lock schedules.")); return true; } diff --git a/util.c b/util.c index b60547d..069753f 100644 --- a/util.c +++ b/util.c @@ -10,6 +10,13 @@ namespace util { +int AvailableSources[32]; +int NumberOfAvailableSources = 0; + +int Yesterday; +int YesterdayEpoch; +int YesterdayEpochUTC; + cChannel *GetChannelByID(tChannelID & channelID, bool searchOtherPos) { cChannel *VC = Channels.GetByChannelID(channelID, true); diff --git a/util.h b/util.h index 8c12184..a32bce2 100644 --- a/util.h +++ b/util.h @@ -13,12 +13,12 @@ struct tChannelID; namespace util { -int AvailableSources[32]; -int NumberOfAvailableSources = 0; +extern int AvailableSources[32]; +extern int NumberOfAvailableSources; -int Yesterday; -int YesterdayEpoch; -int YesterdayEpochUTC; +extern int Yesterday; +extern int YesterdayEpoch; +extern int YesterdayEpochUTC; cChannel *GetChannelByID(tChannelID & channelID, bool searchOtherPos); time_t LocalTime2UTC (time_t t); -- cgit v1.2.3 From 1992a450ccd4780a36f8d4e1a2433aa84de1baab Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Fri, 1 Jun 2012 15:36:47 +0200 Subject: fix BEV description --- eepg.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/eepg.c b/eepg.c index 255a7fb..ae358e9 100644 --- a/eepg.c +++ b/eepg.c @@ -3444,12 +3444,17 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat if (DishEventDescriptor) { if (DishEventDescriptor->getName()) pEvent->SetTitle(DishEventDescriptor->getName()); - //LogD(2, prep("channelID: %s DishTitle: %s"), *channel->GetChannelID().ToString(), DishShortEventDescriptor->getText()); - // pEvent->SetDescription(DishExtendedEventDescriptor->getText()); + //LogD(2, prep("channelID: %s DishTitle: %s"), *channel->GetChannelID().ToString(), DishEventDescriptor->getName()); pEvent->SetShortText(DishEventDescriptor->getShortText()); char *tmp; string fmt; + const char * description = DishEventDescriptor->getDescription(); + //BEV sets the description previously with ExtendedEventDescriptor + if (0 == strcmp(DishEventDescriptor->getDescription(),"") && pEvent->Description()) + description = pEvent->Description(); + + fmt = "%s"; if (DishEventDescriptor->hasTheme()) { fmt += "\nTheme: "; @@ -3460,8 +3465,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat } fmt += "%s"; - if (0 != strcmp(DishEventDescriptor->getDescription(),"") - && (0 != strcmp(DishEventDescriptor->getRating(),"") + if ((0 != strcmp(DishEventDescriptor->getRating(),"") || 0 != strcmp(DishEventDescriptor->getStarRating(),""))) { fmt += "\n\nRating: "; } @@ -3477,7 +3481,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat dateok = strftime (datestr,80," Original Air Date: %a %b %d %Y",gmtime(&orgAirDate)) > 0; } - Asprintf (&tmp, fmt.c_str(), DishEventDescriptor->getDescription() + Asprintf (&tmp, fmt.c_str(), description , DishEventDescriptor->getTheme(), DishEventDescriptor->getCategory() , DishEventDescriptor->getRating(), DishEventDescriptor->getStarRating() , DishEventDescriptor->getProgramId(), DishEventDescriptor->getSeriesId() @@ -3486,8 +3490,8 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat free(tmp); - //LogD(2, prep("DishDescription: %s"), DishExtendedEventDescriptor->getText()); - //LogD(2, prep("DishShortText: %s"), DishExtendedEventDescriptor->getShortText()); + //LogD(2, prep("DishDescription: %s"), DishEventDescriptor->getDescription()); + //LogD(2, prep("DishShortText: %s"), DishEventDescriptor->getShortText()); } } -- cgit v1.2.3 From 2505269770dafd11394db3443a2a165a353d73c4 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Fri, 1 Jun 2012 16:00:14 +0200 Subject: added cAddEventThread from VDR EPGFixer Plug-in to update equivalent channels in separate thread --- epghandler.c | 30 ++++++++++++--------- equivhandler.c | 56 ++++++++++++++++++++++++++++++++++++++ equivhandler.h | 1 + util.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ util.h | 2 ++ 5 files changed, 162 insertions(+), 12 deletions(-) diff --git a/epghandler.c b/epghandler.c index 426958d..4f1c786 100644 --- a/epghandler.c +++ b/epghandler.c @@ -112,12 +112,17 @@ bool cEEpgHandler::HandleEvent(cEvent* Event) { Event->SetDescription(origDescription.c_str()); } - cSchedulesLock SchedulesLock (true); - cSchedules *s = (cSchedules *) cSchedules::Schedules (SchedulesLock); - if (s) { - equivHandler->updateEquivalent(s, Event->ChannelID(), Event); - } else - LogE (0, prep("Error: could not lock schedules.")); + if (equivHandler->getEquiChanMap().count(*Event->ChannelID().ToString()) <= 0) + return true; + + equivHandler->updateEquivalent(Event->ChannelID(), Event); + +// cSchedulesLock SchedulesLock (true); +// cSchedules *s = (cSchedules *) cSchedules::Schedules (SchedulesLock); +// if (s) { +// equivHandler->updateEquivalent(s, Event->ChannelID(), Event); +// } else +// LogE (0, prep("Error: could not lock schedules.")); //TODO just to see the difference //else if (!origDescription.empty() && !origDescription.compare(Event->Description())) { @@ -133,12 +138,13 @@ bool cEEpgHandler::SortSchedule(cSchedule* Schedule) { Schedule->Sort(); - cSchedulesLock SchedulesLock (true); - cSchedules *s = (cSchedules *) cSchedules::Schedules (SchedulesLock); - if (s) { - equivHandler->sortEquivalents(Schedule->ChannelID(), s); - } else - LogE (0, prep("Error: could not lock schedules.")); + //NOK +// cSchedulesLock SchedulesLock (true); +// cSchedules *s = (cSchedules *) cSchedules::Schedules (SchedulesLock); +// if (s) { +// equivHandler->sortEquivalents(Schedule->ChannelID(), s); +// } else +// LogE (0, prep("Error: could not lock schedules.")); return true; } diff --git a/equivhandler.c b/equivhandler.c index 9b0e989..c2846f7 100644 --- a/equivhandler.c +++ b/equivhandler.c @@ -184,6 +184,62 @@ void cEquivHandler::updateEquivalent(cSchedules * Schedules, tChannelID channelI } } +void cEquivHandler::updateEquivalent(tChannelID channelID, cEvent *pEvent){ + multimap::iterator it; + pair::iterator,multimap::iterator> ret; + + LogD(3, prep("Start updateEquivalent %s"), *channelID.ToString()); + + ret = equiChanMap.equal_range(*channelID.ToString()); + for (it=ret.first; it!=ret.second; ++it) { + LogD(1, prep("equivalent channel exists")); + tChannelID equChannelID (tChannelID::FromString((*it).second.c_str())); + cEvent* newEvent = new cEvent (pEvent->EventID()); + newEvent->SetTableID (pEvent->TableID()); + newEvent->SetStartTime (pEvent->StartTime()); + newEvent->SetDuration (pEvent->Duration()); + newEvent->SetVersion (pEvent->Version()); +// newEvent->SetContents(pEvent->Contents()); + newEvent->SetParentalRating(pEvent->ParentalRating()); + newEvent->SetVps (pEvent->Vps()); + newEvent->SetTitle (pEvent->Title ()); + newEvent->SetShortText (pEvent->ShortText ()); + newEvent->SetDescription (pEvent->Description ()); +// newEvent->SetComponents (pEvent->Components()); + AddEvent(newEvent, equChannelID); + } +} + + +//cSchedule * findFisrtSchedule (cSchedule * Schedule) { +// if (Schedule->Prev()) +// return findFisrtSchedule((cSchedule *)Schedule->Prev()); +// else +// return Schedule; +//} +// +//cSchedule * findSchedule (cSchedule * Schedule, tChannelID channelID) { +// if (Schedule->ChannelID() == channelID) +// return Schedule; +// +// if (Schedule->Next()) +// return findSchedule((cSchedule *)Schedule->Next(), channelID); +// else +// return NULL; +//} +// +//cSchedule * findEqvSchedule (cSchedule * Schedule, tChannelID channelID) { +// cSchedule* foundSchedule = findSchedule(findFisrtSchedule(Schedule),channelID); +// +// if (foundSchedule) +// return foundSchedule; +// +// cSchedule* sch = new cSchedule(channelID); +// Schedule->Insert(sch); +// return sch; +//} + + void cEquivHandler::sortEquivalents(tChannelID channelID, cSchedules* Schedules) { multimap::iterator it; diff --git a/equivhandler.h b/equivhandler.h index fdfd343..7e7cad7 100644 --- a/equivhandler.h +++ b/equivhandler.h @@ -25,6 +25,7 @@ public: void loadEquivalentChannelMap (void); void updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent); + void updateEquivalent(tChannelID channelID, cEvent *pEvent); void sortEquivalents(tChannelID channelID, cSchedules* Schedules); static multimap getEquiChanMap() { return cEquivHandler::equiChanMap; }; diff --git a/util.c b/util.c index b60547d..d2a5c36 100644 --- a/util.c +++ b/util.c @@ -6,6 +6,7 @@ */ #include "util.h" #include +#include namespace util { @@ -113,4 +114,88 @@ void CleanString (unsigned char *String) // LogD (1, prep("Clean: %s"), String); } +// --- cAddEventThread ---------------------------------------- +// Taken from VDR EPGFixer Plug-in +// http://projects.vdr-developer.org/projects/plg-epgfixer +// by Matti Lehtimaki + +class cAddEventListItem : public cListObject +{ +protected: + cEvent *event; + tChannelID channelID; +public: + cAddEventListItem(cEvent *Event, tChannelID ChannelID) { event = Event; channelID = ChannelID; } + tChannelID GetChannelID() { return channelID; } + cEvent *GetEvent() { return event; } + ~cAddEventListItem() { } +}; + +class cAddEventThread : public cThread +{ +private: + cTimeMs LastHandleEvent; + cList *list; + enum { INSERT_TIMEOUT_IN_MS = 10000 }; +protected: + virtual void Action(void); +public: + cAddEventThread(void); + ~cAddEventThread(void); + void AddEvent(cEvent *Event, tChannelID ChannelID); +}; + +cAddEventThread::cAddEventThread(void) +:cThread("cAddEventThread"), LastHandleEvent() +{ + list = new cList; +} + +cAddEventThread::~cAddEventThread(void) +{ + LOCK_THREAD; + list->cList::Clear(); + Cancel(3); +} + +void cAddEventThread::Action(void) +{ + SetPriority(19); + while (Running() && !LastHandleEvent.TimedOut()) { + cAddEventListItem *e = NULL; + cSchedulesLock SchedulesLock(true, 10); + cSchedules *schedules = (cSchedules *)cSchedules::Schedules(SchedulesLock); + Lock(); + while (schedules && (e = list->First()) != NULL) { + cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID(e->GetChannelID()), true); + schedule->AddEvent(e->GetEvent()); + EpgHandlers.SortSchedule(schedule); + EpgHandlers.DropOutdated(schedule, e->GetEvent()->StartTime(), e->GetEvent()->EndTime(), e->GetEvent()->TableID(), e->GetEvent()->Version()); + list->Del(e); + } + Unlock(); + cCondWait::SleepMs(10); + } } + +void cAddEventThread::AddEvent(cEvent *Event, tChannelID ChannelID) +{ + LOCK_THREAD; + list->Add(new cAddEventListItem(Event, ChannelID)); + LastHandleEvent.Set(INSERT_TIMEOUT_IN_MS); +} + +static cAddEventThread AddEventThread; + +// --- + +void AddEvent(cEvent *Event, tChannelID ChannelID) +{ + AddEventThread.AddEvent(Event, ChannelID); + if (!AddEventThread.Active()) + AddEventThread.Start(); +} + + +} + diff --git a/util.h b/util.h index 8c12184..41a8204 100644 --- a/util.h +++ b/util.h @@ -20,6 +20,8 @@ int Yesterday; int YesterdayEpoch; int YesterdayEpochUTC; +void AddEvent(cEvent *event, tChannelID ChannelID); + cChannel *GetChannelByID(tChannelID & channelID, bool searchOtherPos); time_t LocalTime2UTC (time_t t); time_t UTC2LocalTime (time_t t); -- cgit v1.2.3 From eb44800641ed5e60e23d173e027688f67c1981cc Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 2 Jun 2012 11:52:32 +0200 Subject: fix compile fix sortEquivalents modify loging --- equivhandler.c | 48 ++++++++++++++++++++++++------------------------ setupeepg.h | 6 +++++- util.c | 1 + util.h | 1 + 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/equivhandler.c b/equivhandler.c index c2846f7..b10c004 100644 --- a/equivhandler.c +++ b/equivhandler.c @@ -114,9 +114,9 @@ void cEquivHandler::loadEquivalentChannelMap (void) } //while fclose (File); equiChanFileTime = st.st_mtim.tv_nsec; - LogD(3, prep("Loaded %i equivalents."), equiChanMap.size()); + LogD(2, prep("Loaded %i equivalents."), equiChanMap.size()); for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ ) - LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); + LogD(2, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str()); } //if file } @@ -124,24 +124,24 @@ void cEquivHandler::updateEquivalent(cSchedules * Schedules, tChannelID channelI multimap::iterator it; pair::iterator,multimap::iterator> ret; - LogD(3, prep("Start updateEquivalent %s"), *channelID.ToString()); + LogD(2, prep("Start updateEquivalent %s"), *channelID.ToString()); ret = equiChanMap.equal_range(*channelID.ToString()); for (it=ret.first; it!=ret.second; ++it) { - LogD(1, prep("equivalent channel exists")); + LogD(2, prep("equivalent channel exists")); tChannelID equChannelID (tChannelID::FromString((*it).second.c_str())); cChannel *equChannel = GetChannelByID (equChannelID, false); if (equChannel) { - LogD(3, prep("found Equivalent channel %s"), *equChannelID.ToString()); + LogD(2, prep("found Equivalent channel %s"), *equChannelID.ToString()); cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (equChannel, true); cEvent *pEqvEvent = (cEvent *) pSchedule->GetEvent (pEvent->EventID(), pEvent->StartTime()); if (pEqvEvent) { - LogD(1, prep("equivalent event exists")); + LogD(3, prep("equivalent event exists")); if (pEqvEvent == pEvent) { - LogD(1, prep("equal event exists")); + LogD(3, prep("equal event exists")); } else { - LogD(1, prep("remove equivalent")); + LogD(2, prep("remove equivalent")); pSchedule->DelEvent(pEqvEvent); cEvent* newEvent = new cEvent (pEvent->EventID()); newEvent->SetTableID (pEvent->TableID()); @@ -162,7 +162,7 @@ void cEquivHandler::updateEquivalent(cSchedules * Schedules, tChannelID channelI } } else { - LogD(1, prep("equivalent event does not exist")); + LogD(3, prep("equivalent event does not exist")); cEvent* newEvent = new cEvent (pEvent->EventID()); newEvent->SetTableID (pEvent->TableID()); newEvent->SetStartTime (pEvent->StartTime()); @@ -188,11 +188,11 @@ void cEquivHandler::updateEquivalent(tChannelID channelID, cEvent *pEvent){ multimap::iterator it; pair::iterator,multimap::iterator> ret; - LogD(3, prep("Start updateEquivalent %s"), *channelID.ToString()); + LogD(2, prep("Start updateEquivalent %s"), *channelID.ToString()); ret = equiChanMap.equal_range(*channelID.ToString()); for (it=ret.first; it!=ret.second; ++it) { - LogD(1, prep("equivalent channel exists")); + LogD(2, prep("equivalent channel exists")); tChannelID equChannelID (tChannelID::FromString((*it).second.c_str())); cEvent* newEvent = new cEvent (pEvent->EventID()); newEvent->SetTableID (pEvent->TableID()); @@ -245,21 +245,21 @@ void cEquivHandler::sortEquivalents(tChannelID channelID, cSchedules* Schedules) multimap::iterator it; pair < multimap < string, string > ::iterator, multimap < string, string > ::iterator > ret; - ret = cEquivHandler::getEquiChanMap().equal_range(*channelID.ToString()); + LogD(2, prep("sortEquivalents for channel %s count: %d"), *channelID.ToString(), cEquivHandler::getEquiChanMap().count(*channelID.ToString())); + + ret = equiChanMap.equal_range(*channelID.ToString()); for (it = ret.first; it != ret.second; ++it) + { + LogD(3, prep("equivalent channel exists")); + tChannelID equChannelID(tChannelID::FromString((*it).second.c_str())); + cChannel* pChannel = GetChannelByID(equChannelID, false); + if (pChannel) { - LogD(3, prep("equivalent channel exists")); - tChannelID equChannelID(tChannelID::FromString((*it).second.c_str())); - cChannel* pChannel = GetChannelByID(equChannelID, false); - if (pChannel) - { - LogD(3, prep("found Equivalent channel %s"), - *equChannelID.ToString()); - cSchedule* pSchedule = (cSchedule *) Schedules->GetSchedule(pChannel, - true); + LogD(2, prep("found Equivalent channel %s"), *equChannelID.ToString()); + cSchedule* pSchedule = (cSchedule *) Schedules->GetSchedule(pChannel, true); - pSchedule->Sort(); - Schedules->SetModified(pSchedule); - } + pSchedule->Sort(); + Schedules->SetModified(pSchedule); } + } } diff --git a/setupeepg.h b/setupeepg.h index ffd9eb8..4c30ede 100644 --- a/setupeepg.h +++ b/setupeepg.h @@ -7,6 +7,7 @@ #ifndef SETUPEEPG_H_ #define SETUPEEPG_H_ +#include class cSetupEEPG { @@ -31,7 +32,10 @@ public: void setConfDir(char* confDir) { - ConfDir = confDir; + if (ConfDir) + delete ConfDir; + ConfDir = new char[strlen(confDir)+1]; + strcpy(ConfDir, confDir); } private: diff --git a/util.c b/util.c index bbfffb2..3d92dda 100644 --- a/util.c +++ b/util.c @@ -7,6 +7,7 @@ #include "util.h" #include #include +#include namespace util { diff --git a/util.h b/util.h index be2c3d0..230f44c 100644 --- a/util.h +++ b/util.h @@ -10,6 +10,7 @@ #include class cChannel; struct tChannelID; +class cEvent; namespace util { -- cgit v1.2.3 From 2b607ae7ed801583172ee17df6b335abea495442 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 2 Jun 2012 16:22:37 +0200 Subject: Try to discard very long events that override more than one existing event Move event clone code to a separate method --- epghandler.c | 17 +++++------ epghandler.h | 1 + equivhandler.c | 96 ++++++++++++++++++++-------------------------------------- equivhandler.h | 1 + 4 files changed, 42 insertions(+), 73 deletions(-) diff --git a/epghandler.c b/epghandler.c index ecf5de9..e323ed1 100644 --- a/epghandler.c +++ b/epghandler.c @@ -30,17 +30,16 @@ bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, if ((nid >= 0x1001 && nid <= 0x100B) || nid == 0x101 || nid == 0x100) return true; - //TODO!!! not for commit upsteram - if (EitEvent->getDurationHour() > 10) { - LogD(3, prep("Event longer than 10h Duration:%d DurationHour:%d StartTimeHour:%d"), EitEvent->getDuration(), EitEvent->getDurationHour(), EitEvent->getStartTimeHour()); - const cEvent* exEvent = Schedule->GetEventAround(EitEvent->getStartTime()+EitEvent->getDuration()/2); - if (exEvent) { - LogD(3, prep("10h Existing event %s startTime %d"), exEvent->Title(), exEvent->StartTime()); + //TODO Should it be added in setup? + if (EitEvent->getDurationHour() > _LONG_EVENT_HOURS) { + LogD(4, prep("Event longer than 10h Duration:%d DurationHour:%d StartTimeHour:%d"), EitEvent->getDuration(), EitEvent->getDurationHour(), EitEvent->getStartTimeHour()); + const cEvent* exEvent = Schedule->GetEventAround(EitEvent->getStartTime()+EitEvent->getDuration()/3); + const cEvent* exEvent2 = (const cEvent*)exEvent->Next(); + if (exEvent && exEvent2 && difftime (exEvent2->EndTime(),EitEvent->getStartTime()+EitEvent->getDuration()) <= 0 ) { + LogD(3, prep("EitEvent overrides existing events '%s', '%s' ... Skipping"), exEvent->Title(), exEvent2->Title()); return true; } } - //if (EitEvent->getDurationHour() > 3) -// return true; return false; // return true; @@ -54,7 +53,7 @@ bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) { bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { LogD(3, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title); - if (!Event->Title() || Title && (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title)))) + if (!Event->Title() || (Title && (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title))))) Event->SetTitle(Title); return true; } diff --git a/epghandler.h b/epghandler.h index e1c6915..3219f58 100644 --- a/epghandler.h +++ b/epghandler.h @@ -38,6 +38,7 @@ private: std::string origShortText; std::string origDescription; cEquivHandler* equivHandler; + static const int _LONG_EVENT_HOURS = 10; }; #endif /*APIVERSNUM > 10725*/ diff --git a/equivhandler.c b/equivhandler.c index b10c004..e449b1f 100644 --- a/equivhandler.c +++ b/equivhandler.c @@ -144,18 +144,7 @@ void cEquivHandler::updateEquivalent(cSchedules * Schedules, tChannelID channelI LogD(2, prep("remove equivalent")); pSchedule->DelEvent(pEqvEvent); cEvent* newEvent = new cEvent (pEvent->EventID()); - newEvent->SetTableID (pEvent->TableID()); - newEvent->SetStartTime (pEvent->StartTime()); - newEvent->SetDuration (pEvent->Duration()); - newEvent->SetVersion (pEvent->Version()); -// newEvent->SetContents(pEvent->Contents()); - newEvent->SetParentalRating(pEvent->ParentalRating()); - newEvent->SetVps (pEvent->Vps()); - newEvent->SetTitle (pEvent->Title ()); - newEvent->SetShortText (pEvent->ShortText ()); - newEvent->SetDescription (pEvent->Description ()); -// newEvent->SetComponents (pEvent->Components()); - newEvent->FixEpgBugs (); + cloneEvent(newEvent, pEvent); pSchedule->AddEvent(newEvent); @@ -164,18 +153,7 @@ void cEquivHandler::updateEquivalent(cSchedules * Schedules, tChannelID channelI } else { LogD(3, prep("equivalent event does not exist")); cEvent* newEvent = new cEvent (pEvent->EventID()); - newEvent->SetTableID (pEvent->TableID()); - newEvent->SetStartTime (pEvent->StartTime()); - newEvent->SetDuration (pEvent->Duration()); - newEvent->SetVersion (pEvent->Version()); -// newEvent->SetContents(pEvent->Contents()); - newEvent->SetParentalRating(pEvent->ParentalRating()); - newEvent->SetVps (pEvent->Vps()); - newEvent->SetTitle (pEvent->Title ()); - newEvent->SetShortText (pEvent->ShortText ()); - newEvent->SetDescription (pEvent->Description ()); -// newEvent->SetComponents (pEvent->Components()); - newEvent->FixEpgBugs (); + cloneEvent(newEvent, pEvent); pSchedule->AddEvent(newEvent); @@ -195,51 +173,13 @@ void cEquivHandler::updateEquivalent(tChannelID channelID, cEvent *pEvent){ LogD(2, prep("equivalent channel exists")); tChannelID equChannelID (tChannelID::FromString((*it).second.c_str())); cEvent* newEvent = new cEvent (pEvent->EventID()); - newEvent->SetTableID (pEvent->TableID()); - newEvent->SetStartTime (pEvent->StartTime()); - newEvent->SetDuration (pEvent->Duration()); - newEvent->SetVersion (pEvent->Version()); -// newEvent->SetContents(pEvent->Contents()); - newEvent->SetParentalRating(pEvent->ParentalRating()); - newEvent->SetVps (pEvent->Vps()); - newEvent->SetTitle (pEvent->Title ()); - newEvent->SetShortText (pEvent->ShortText ()); - newEvent->SetDescription (pEvent->Description ()); -// newEvent->SetComponents (pEvent->Components()); + cloneEvent(newEvent, pEvent); + AddEvent(newEvent, equChannelID); } } -//cSchedule * findFisrtSchedule (cSchedule * Schedule) { -// if (Schedule->Prev()) -// return findFisrtSchedule((cSchedule *)Schedule->Prev()); -// else -// return Schedule; -//} -// -//cSchedule * findSchedule (cSchedule * Schedule, tChannelID channelID) { -// if (Schedule->ChannelID() == channelID) -// return Schedule; -// -// if (Schedule->Next()) -// return findSchedule((cSchedule *)Schedule->Next(), channelID); -// else -// return NULL; -//} -// -//cSchedule * findEqvSchedule (cSchedule * Schedule, tChannelID channelID) { -// cSchedule* foundSchedule = findSchedule(findFisrtSchedule(Schedule),channelID); -// -// if (foundSchedule) -// return foundSchedule; -// -// cSchedule* sch = new cSchedule(channelID); -// Schedule->Insert(sch); -// return sch; -//} - - void cEquivHandler::sortEquivalents(tChannelID channelID, cSchedules* Schedules) { multimap::iterator it; @@ -263,3 +203,31 @@ void cEquivHandler::sortEquivalents(tChannelID channelID, cSchedules* Schedules) } } } + +void cEquivHandler::cloneEvent(cEvent *Source, cEvent *Dest) { + + Dest->SetEventID(Source->EventID()); + Dest->SetTableID(Source->TableID()); + Dest->SetVersion(Source->Version()); + Dest->SetRunningStatus(Source->RunningStatus()); + Dest->SetTitle(Source->Title()); + Dest->SetShortText(Source->ShortText()); + Dest->SetDescription(Source->Description()); + cComponents *components = new cComponents(); + if (Source->Components()) { + for (int i = 0; i < Source->Components()->NumComponents(); ++i) + components->SetComponent(i, Source->Components()->Component(i)->ToString()); + } + Dest->SetComponents(components); + uchar contents[MaxEventContents]; + for (int i = 0; i < MaxEventContents; ++i) + contents[i] = Source->Contents(i); + Dest->SetContents(contents); + Dest->SetParentalRating(Source->ParentalRating()); + Dest->SetStartTime(Source->StartTime()); + Dest->SetDuration(Source->Duration()); + Dest->SetVps(Source->Vps()); + if (Source->Seen()) + Dest->SetSeen(); +} + diff --git a/equivhandler.h b/equivhandler.h index 7e7cad7..25e6f37 100644 --- a/equivhandler.h +++ b/equivhandler.h @@ -27,6 +27,7 @@ public: void updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent); void updateEquivalent(tChannelID channelID, cEvent *pEvent); void sortEquivalents(tChannelID channelID, cSchedules* Schedules); + void cloneEvent(cEvent *Source, cEvent *Dest) static multimap getEquiChanMap() { return cEquivHandler::equiChanMap; }; -- cgit v1.2.3 From 786d8d3a6194141ef78f309e22aca6c3b4d16491 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 2 Jun 2012 17:20:45 +0200 Subject: use map instead of list in cAddEventThread to reduce sorting --- util.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 23 deletions(-) diff --git a/util.c b/util.c index 3d92dda..38e5074 100644 --- a/util.c +++ b/util.c @@ -9,6 +9,8 @@ #include #include +#include + namespace util { @@ -127,23 +129,24 @@ void CleanString (unsigned char *String) // http://projects.vdr-developer.org/projects/plg-epgfixer // by Matti Lehtimaki -class cAddEventListItem : public cListObject -{ -protected: - cEvent *event; - tChannelID channelID; -public: - cAddEventListItem(cEvent *Event, tChannelID ChannelID) { event = Event; channelID = ChannelID; } - tChannelID GetChannelID() { return channelID; } - cEvent *GetEvent() { return event; } - ~cAddEventListItem() { } -}; +//class cAddEventListItem : public cListObject +//{ +//protected: +// cEvent *event; +// tChannelID channelID; +//public: +// cAddEventListItem(cEvent *Event, tChannelID ChannelID) { event = Event; channelID = ChannelID; } +// tChannelID GetChannelID() { return channelID; } +// cEvent *GetEvent() { return event; } +// ~cAddEventListItem() { } +//}; class cAddEventThread : public cThread { private: cTimeMs LastHandleEvent; - cList *list; +// cList *list; + std::map*> *map_list; enum { INSERT_TIMEOUT_IN_MS = 10000 }; protected: virtual void Action(void); @@ -156,13 +159,17 @@ public: cAddEventThread::cAddEventThread(void) :cThread("cAddEventThread"), LastHandleEvent() { - list = new cList; +// list = new cList; + map_list = new std::map*>; } cAddEventThread::~cAddEventThread(void) { LOCK_THREAD; - list->cList::Clear(); +// list->cList::Clear(); + std::map*>::iterator it; + for ( it=map_list->begin() ; it != map_list->end(); it++ ) + (*it).second->cList::Clear(); Cancel(3); } @@ -170,17 +177,36 @@ void cAddEventThread::Action(void) { SetPriority(19); while (Running() && !LastHandleEvent.TimedOut()) { - cAddEventListItem *e = NULL; +// cAddEventListItem *e = NULL; cSchedulesLock SchedulesLock(true, 10); cSchedules *schedules = (cSchedules *)cSchedules::Schedules(SchedulesLock); Lock(); - while (schedules && (e = list->First()) != NULL) { - cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID(e->GetChannelID()), true); - schedule->AddEvent(e->GetEvent()); - EpgHandlers.SortSchedule(schedule); - EpgHandlers.DropOutdated(schedule, e->GetEvent()->StartTime(), e->GetEvent()->EndTime(), e->GetEvent()->TableID(), e->GetEvent()->Version()); - list->Del(e); - } +// while (schedules && (e = list->First()) != NULL) { +// cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID(e->GetChannelID()), true); +// schedule->AddEvent(e->GetEvent()); +// EpgHandlers.SortSchedule(schedule); +// EpgHandlers.DropOutdated(schedule, e->GetEvent()->StartTime(), e->GetEvent()->EndTime(), e->GetEvent()->TableID(), e->GetEvent()->Version()); +// list->Del(e); +// } + std::map*>::iterator it; + if (schedules) { + for ( it=map_list->begin() ; it != map_list->end(); it++ ) { + (*it).second->cList::Clear(); + cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID((*it).first), true); + while (schedules && ((*it).second->First()) != NULL) { + cEvent* event = (*it).second->First(); + + cEvent *pEqvEvent = (cEvent *) schedule->GetEvent (event->EventID(), event->StartTime()); + if (pEqvEvent) + schedule->DelEvent(pEqvEvent); + + schedule->AddEvent(event); + (*it).second->Del(event); + } + EpgHandlers.SortSchedule(schedule); + + } + } Unlock(); cCondWait::SleepMs(10); } @@ -189,7 +215,14 @@ void cAddEventThread::Action(void) void cAddEventThread::AddEvent(cEvent *Event, tChannelID ChannelID) { LOCK_THREAD; - list->Add(new cAddEventListItem(Event, ChannelID)); + if (map_list->empty() || map_list->count(ChannelID) == 0) { + cList* list = new cList; + list->Add(Event); + map_list->insert(std::pair*>(ChannelID, list)); + } else { + (*map_list->find(ChannelID)).second->Add(Event); + } +// list->Add(new cAddEventListItem(Event, ChannelID)); LastHandleEvent.Set(INSERT_TIMEOUT_IN_MS); } -- cgit v1.2.3 From 87ddc3f78a2b525fa28c468f82f84572abe55a40 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 2 Jun 2012 17:21:11 +0200 Subject: fix compile --- equivhandler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/equivhandler.h b/equivhandler.h index 25e6f37..f60dbfc 100644 --- a/equivhandler.h +++ b/equivhandler.h @@ -27,7 +27,7 @@ public: void updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent); void updateEquivalent(tChannelID channelID, cEvent *pEvent); void sortEquivalents(tChannelID channelID, cSchedules* Schedules); - void cloneEvent(cEvent *Source, cEvent *Dest) + void cloneEvent(cEvent *Source, cEvent *Dest); static multimap getEquiChanMap() { return cEquivHandler::equiChanMap; }; -- cgit v1.2.3 From 1e5c78ae3b461343f87d49210116c20d5203ca7a Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 2 Jun 2012 18:02:38 +0200 Subject: add tChannelIDCompare --- util.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/util.c b/util.c index 38e5074..08514bf 100644 --- a/util.c +++ b/util.c @@ -141,12 +141,21 @@ void CleanString (unsigned char *String) // ~cAddEventListItem() { } //}; +struct tChannelIDCompare +{ + bool operator() (const tChannelID& lhs, const tChannelID& rhs) + { + return lhs.ToString() < rhs.ToString(); + } +}; + + class cAddEventThread : public cThread { private: cTimeMs LastHandleEvent; // cList *list; - std::map*> *map_list; + std::map*,tChannelIDCompare> *map_list; enum { INSERT_TIMEOUT_IN_MS = 10000 }; protected: virtual void Action(void); @@ -194,7 +203,7 @@ void cAddEventThread::Action(void) (*it).second->cList::Clear(); cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID((*it).first), true); while (schedules && ((*it).second->First()) != NULL) { - cEvent* event = (*it).second->First(); + cEvent* event = *(*it).second->First(); cEvent *pEqvEvent = (cEvent *) schedule->GetEvent (event->EventID(), event->StartTime()); if (pEqvEvent) @@ -218,7 +227,7 @@ void cAddEventThread::AddEvent(cEvent *Event, tChannelID ChannelID) if (map_list->empty() || map_list->count(ChannelID) == 0) { cList* list = new cList; list->Add(Event); - map_list->insert(std::pair*>(ChannelID, list)); + map_list->insert(std::make_pair(ChannelID, list)); } else { (*map_list->find(ChannelID)).second->Add(Event); } -- cgit v1.2.3 From 0a2aad0200af8d7fd43e72600eaeea043fb1d37a Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 2 Jun 2012 19:13:11 +0200 Subject: fix compile but crashes --- util.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/util.c b/util.c index 08514bf..a508525 100644 --- a/util.c +++ b/util.c @@ -143,9 +143,9 @@ void CleanString (unsigned char *String) struct tChannelIDCompare { - bool operator() (const tChannelID& lhs, const tChannelID& rhs) + bool operator() (const tChannelID& lhs, const tChannelID& rhs) const { - return lhs.ToString() < rhs.ToString(); + return *lhs.ToString() < *rhs.ToString(); } }; @@ -169,14 +169,14 @@ cAddEventThread::cAddEventThread(void) :cThread("cAddEventThread"), LastHandleEvent() { // list = new cList; - map_list = new std::map*>; + map_list = new std::map*,tChannelIDCompare>; } cAddEventThread::~cAddEventThread(void) { LOCK_THREAD; // list->cList::Clear(); - std::map*>::iterator it; + std::map*,tChannelIDCompare>::iterator it; for ( it=map_list->begin() ; it != map_list->end(); it++ ) (*it).second->cList::Clear(); Cancel(3); @@ -197,7 +197,7 @@ void cAddEventThread::Action(void) // EpgHandlers.DropOutdated(schedule, e->GetEvent()->StartTime(), e->GetEvent()->EndTime(), e->GetEvent()->TableID(), e->GetEvent()->Version()); // list->Del(e); // } - std::map*>::iterator it; + std::map*,tChannelIDCompare>::iterator it; if (schedules) { for ( it=map_list->begin() ; it != map_list->end(); it++ ) { (*it).second->cList::Clear(); -- cgit v1.2.3 From f99c11b6335c28204d0e3dbf8ebfd287279d2939 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sun, 3 Jun 2012 22:24:00 +0200 Subject: fix wrong conflict resolution modify the long events dispose logic --- eepg.c | 9 +++++++++ epghandler.c | 11 +++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/eepg.c b/eepg.c index 3fce100..1361b72 100644 --- a/eepg.c +++ b/eepg.c @@ -1368,6 +1368,15 @@ void cFilterEEPG::WriteToSchedule (tChannelID channelID, cSchedules* pSchedules, } if (ps && newEvent) ps->AddEvent (newEvent); + + EquivHandler->updateEquivalent(pSchedules, channelID, Event); + + if (!ps) { + //the event is not send to VDR so it has to be deleted. + delete Event; + Event = NULL; + } + //newEvent->FixEpgBugs (); causes segfault } /* else diff --git a/epghandler.c b/epghandler.c index e323ed1..44ee909 100644 --- a/epghandler.c +++ b/epghandler.c @@ -34,13 +34,16 @@ bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, if (EitEvent->getDurationHour() > _LONG_EVENT_HOURS) { LogD(4, prep("Event longer than 10h Duration:%d DurationHour:%d StartTimeHour:%d"), EitEvent->getDuration(), EitEvent->getDurationHour(), EitEvent->getStartTimeHour()); const cEvent* exEvent = Schedule->GetEventAround(EitEvent->getStartTime()+EitEvent->getDuration()/3); - const cEvent* exEvent2 = (const cEvent*)exEvent->Next(); - if (exEvent && exEvent2 && difftime (exEvent2->EndTime(),EitEvent->getStartTime()+EitEvent->getDuration()) <= 0 ) { - LogD(3, prep("EitEvent overrides existing events '%s', '%s' ... Skipping"), exEvent->Title(), exEvent2->Title()); - return true; + if (exEvent) { + const cEvent* exEvent2 = Schedule->GetEventAround(EitEvent->getStartTime()+EitEvent->getDuration()/3*2); + if (exEvent2 && exEvent != exEvent2) { + LogD(2, prep("EitEvent overrides existing events '%s', '%s' ... Skipping"), *exEvent->Title(), *exEvent2->Title()); + return true; + } } } + return false; // return true; } -- cgit v1.2.3 From a443439bbf37cf77a349aa7d848536505ab9fafa Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sun, 3 Jun 2012 22:44:02 +0200 Subject: revert util.c and moved to separate branch --- util.c | 84 +++++++++++++++++------------------------------------------------- 1 file changed, 21 insertions(+), 63 deletions(-) diff --git a/util.c b/util.c index a508525..3d92dda 100644 --- a/util.c +++ b/util.c @@ -9,8 +9,6 @@ #include #include -#include - namespace util { @@ -129,33 +127,23 @@ void CleanString (unsigned char *String) // http://projects.vdr-developer.org/projects/plg-epgfixer // by Matti Lehtimaki -//class cAddEventListItem : public cListObject -//{ -//protected: -// cEvent *event; -// tChannelID channelID; -//public: -// cAddEventListItem(cEvent *Event, tChannelID ChannelID) { event = Event; channelID = ChannelID; } -// tChannelID GetChannelID() { return channelID; } -// cEvent *GetEvent() { return event; } -// ~cAddEventListItem() { } -//}; - -struct tChannelIDCompare +class cAddEventListItem : public cListObject { - bool operator() (const tChannelID& lhs, const tChannelID& rhs) const - { - return *lhs.ToString() < *rhs.ToString(); - } +protected: + cEvent *event; + tChannelID channelID; +public: + cAddEventListItem(cEvent *Event, tChannelID ChannelID) { event = Event; channelID = ChannelID; } + tChannelID GetChannelID() { return channelID; } + cEvent *GetEvent() { return event; } + ~cAddEventListItem() { } }; - class cAddEventThread : public cThread { private: cTimeMs LastHandleEvent; -// cList *list; - std::map*,tChannelIDCompare> *map_list; + cList *list; enum { INSERT_TIMEOUT_IN_MS = 10000 }; protected: virtual void Action(void); @@ -168,17 +156,13 @@ public: cAddEventThread::cAddEventThread(void) :cThread("cAddEventThread"), LastHandleEvent() { -// list = new cList; - map_list = new std::map*,tChannelIDCompare>; + list = new cList; } cAddEventThread::~cAddEventThread(void) { LOCK_THREAD; -// list->cList::Clear(); - std::map*,tChannelIDCompare>::iterator it; - for ( it=map_list->begin() ; it != map_list->end(); it++ ) - (*it).second->cList::Clear(); + list->cList::Clear(); Cancel(3); } @@ -186,36 +170,17 @@ void cAddEventThread::Action(void) { SetPriority(19); while (Running() && !LastHandleEvent.TimedOut()) { -// cAddEventListItem *e = NULL; + cAddEventListItem *e = NULL; cSchedulesLock SchedulesLock(true, 10); cSchedules *schedules = (cSchedules *)cSchedules::Schedules(SchedulesLock); Lock(); -// while (schedules && (e = list->First()) != NULL) { -// cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID(e->GetChannelID()), true); -// schedule->AddEvent(e->GetEvent()); -// EpgHandlers.SortSchedule(schedule); -// EpgHandlers.DropOutdated(schedule, e->GetEvent()->StartTime(), e->GetEvent()->EndTime(), e->GetEvent()->TableID(), e->GetEvent()->Version()); -// list->Del(e); -// } - std::map*,tChannelIDCompare>::iterator it; - if (schedules) { - for ( it=map_list->begin() ; it != map_list->end(); it++ ) { - (*it).second->cList::Clear(); - cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID((*it).first), true); - while (schedules && ((*it).second->First()) != NULL) { - cEvent* event = *(*it).second->First(); - - cEvent *pEqvEvent = (cEvent *) schedule->GetEvent (event->EventID(), event->StartTime()); - if (pEqvEvent) - schedule->DelEvent(pEqvEvent); - - schedule->AddEvent(event); - (*it).second->Del(event); - } - EpgHandlers.SortSchedule(schedule); - - } - } + while (schedules && (e = list->First()) != NULL) { + cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID(e->GetChannelID()), true); + schedule->AddEvent(e->GetEvent()); + EpgHandlers.SortSchedule(schedule); + EpgHandlers.DropOutdated(schedule, e->GetEvent()->StartTime(), e->GetEvent()->EndTime(), e->GetEvent()->TableID(), e->GetEvent()->Version()); + list->Del(e); + } Unlock(); cCondWait::SleepMs(10); } @@ -224,14 +189,7 @@ void cAddEventThread::Action(void) void cAddEventThread::AddEvent(cEvent *Event, tChannelID ChannelID) { LOCK_THREAD; - if (map_list->empty() || map_list->count(ChannelID) == 0) { - cList* list = new cList; - list->Add(Event); - map_list->insert(std::make_pair(ChannelID, list)); - } else { - (*map_list->find(ChannelID)).second->Add(Event); - } -// list->Add(new cAddEventListItem(Event, ChannelID)); + list->Add(new cAddEventListItem(Event, ChannelID)); LastHandleEvent.Set(INSERT_TIMEOUT_IN_MS); } -- cgit v1.2.3 From 93a36a988052d5712ecde87fd28f94518f80801f Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sun, 3 Jun 2012 23:32:38 +0200 Subject: error in source <> destination --- equivhandler.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/equivhandler.c b/equivhandler.c index e449b1f..2c1b424 100644 --- a/equivhandler.c +++ b/equivhandler.c @@ -144,7 +144,7 @@ void cEquivHandler::updateEquivalent(cSchedules * Schedules, tChannelID channelI LogD(2, prep("remove equivalent")); pSchedule->DelEvent(pEqvEvent); cEvent* newEvent = new cEvent (pEvent->EventID()); - cloneEvent(newEvent, pEvent); + cloneEvent(pEvent, newEvent); pSchedule->AddEvent(newEvent); @@ -153,7 +153,7 @@ void cEquivHandler::updateEquivalent(cSchedules * Schedules, tChannelID channelI } else { LogD(3, prep("equivalent event does not exist")); cEvent* newEvent = new cEvent (pEvent->EventID()); - cloneEvent(newEvent, pEvent); + cloneEvent(pEvent, newEvent); pSchedule->AddEvent(newEvent); @@ -173,7 +173,7 @@ void cEquivHandler::updateEquivalent(tChannelID channelID, cEvent *pEvent){ LogD(2, prep("equivalent channel exists")); tChannelID equChannelID (tChannelID::FromString((*it).second.c_str())); cEvent* newEvent = new cEvent (pEvent->EventID()); - cloneEvent(newEvent, pEvent); + cloneEvent(pEvent, newEvent); AddEvent(newEvent, equChannelID); } -- cgit v1.2.3 From 5e7d26da37cee78f6cb943ba10bae6455ee1e73b Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sun, 3 Jun 2012 23:56:44 +0200 Subject: removed list clear --- util.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 62 insertions(+), 21 deletions(-) diff --git a/util.c b/util.c index 3d92dda..e398eca 100644 --- a/util.c +++ b/util.c @@ -9,6 +9,8 @@ #include #include +#include + namespace util { @@ -127,23 +129,33 @@ void CleanString (unsigned char *String) // http://projects.vdr-developer.org/projects/plg-epgfixer // by Matti Lehtimaki -class cAddEventListItem : public cListObject +//class cAddEventListItem : public cListObject +//{ +//protected: +// cEvent *event; +// tChannelID channelID; +//public: +// cAddEventListItem(cEvent *Event, tChannelID ChannelID) { event = Event; channelID = ChannelID; } +// tChannelID GetChannelID() { return channelID; } +// cEvent *GetEvent() { return event; } +// ~cAddEventListItem() { } +//}; + +struct tChannelIDCompare { -protected: - cEvent *event; - tChannelID channelID; -public: - cAddEventListItem(cEvent *Event, tChannelID ChannelID) { event = Event; channelID = ChannelID; } - tChannelID GetChannelID() { return channelID; } - cEvent *GetEvent() { return event; } - ~cAddEventListItem() { } + bool operator() (const tChannelID& lhs, const tChannelID& rhs) const + { + return *lhs.ToString() < *rhs.ToString(); + } }; + class cAddEventThread : public cThread { private: cTimeMs LastHandleEvent; - cList *list; +// cList *list; + std::map*,tChannelIDCompare> *map_list; enum { INSERT_TIMEOUT_IN_MS = 10000 }; protected: virtual void Action(void); @@ -156,13 +168,17 @@ public: cAddEventThread::cAddEventThread(void) :cThread("cAddEventThread"), LastHandleEvent() { - list = new cList; +// list = new cList; + map_list = new std::map*,tChannelIDCompare>; } cAddEventThread::~cAddEventThread(void) { LOCK_THREAD; - list->cList::Clear(); +// list->cList::Clear(); + std::map*,tChannelIDCompare>::iterator it; + for ( it=map_list->begin() ; it != map_list->end(); it++ ) + (*it).second->cList::Clear(); Cancel(3); } @@ -170,17 +186,35 @@ void cAddEventThread::Action(void) { SetPriority(19); while (Running() && !LastHandleEvent.TimedOut()) { - cAddEventListItem *e = NULL; +// cAddEventListItem *e = NULL; cSchedulesLock SchedulesLock(true, 10); cSchedules *schedules = (cSchedules *)cSchedules::Schedules(SchedulesLock); Lock(); - while (schedules && (e = list->First()) != NULL) { - cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID(e->GetChannelID()), true); - schedule->AddEvent(e->GetEvent()); - EpgHandlers.SortSchedule(schedule); - EpgHandlers.DropOutdated(schedule, e->GetEvent()->StartTime(), e->GetEvent()->EndTime(), e->GetEvent()->TableID(), e->GetEvent()->Version()); - list->Del(e); - } +// while (schedules && (e = list->First()) != NULL) { +// cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID(e->GetChannelID()), true); +// schedule->AddEvent(e->GetEvent()); +// EpgHandlers.SortSchedule(schedule); +// EpgHandlers.DropOutdated(schedule, e->GetEvent()->StartTime(), e->GetEvent()->EndTime(), e->GetEvent()->TableID(), e->GetEvent()->Version()); +// list->Del(e); +// } + std::map*,tChannelIDCompare>::iterator it; + if (schedules) { + for ( it=map_list->begin() ; it != map_list->end(); it++ ) { + cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID((*it).first), true); + while (schedules && ((*it).second->First()) != NULL) { + cEvent* event = *(*it).second->First(); + + cEvent *pEqvEvent = (cEvent *) schedule->GetEvent (event->EventID(), event->StartTime()); + if (pEqvEvent) + schedule->DelEvent(pEqvEvent); + + schedule->AddEvent(event); + (*it).second->Del(event); + } + EpgHandlers.SortSchedule(schedule); + + } + } Unlock(); cCondWait::SleepMs(10); } @@ -189,7 +223,14 @@ void cAddEventThread::Action(void) void cAddEventThread::AddEvent(cEvent *Event, tChannelID ChannelID) { LOCK_THREAD; - list->Add(new cAddEventListItem(Event, ChannelID)); + if (map_list->empty() || map_list->count(ChannelID) == 0) { + cList* list = new cList; + list->Add(Event); + map_list->insert(std::make_pair(ChannelID, list)); + } else { + (*map_list->find(ChannelID)).second->Add(Event); + } +// list->Add(new cAddEventListItem(Event, ChannelID)); LastHandleEvent.Set(INSERT_TIMEOUT_IN_MS); } -- cgit v1.2.3 From 7335a91779b6bef557cef1a4697f27b85a0627c0 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Mon, 4 Jun 2012 00:15:36 +0200 Subject: remove empty list from map --- equivhandler.c | 4 ++-- util.c | 31 ++++++++++++++++--------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/equivhandler.c b/equivhandler.c index 2c1b424..a742150 100644 --- a/equivhandler.c +++ b/equivhandler.c @@ -166,11 +166,11 @@ void cEquivHandler::updateEquivalent(tChannelID channelID, cEvent *pEvent){ multimap::iterator it; pair::iterator,multimap::iterator> ret; - LogD(2, prep("Start updateEquivalent %s"), *channelID.ToString()); + LogD(3, prep("Start updateEquivalent %s"), *channelID.ToString()); ret = equiChanMap.equal_range(*channelID.ToString()); for (it=ret.first; it!=ret.second; ++it) { - LogD(2, prep("equivalent channel exists")); + LogD(3, prep("equivalent channel exists")); tChannelID equChannelID (tChannelID::FromString((*it).second.c_str())); cEvent* newEvent = new cEvent (pEvent->EventID()); cloneEvent(pEvent, newEvent); diff --git a/util.c b/util.c index e398eca..076401f 100644 --- a/util.c +++ b/util.c @@ -198,22 +198,23 @@ void cAddEventThread::Action(void) // list->Del(e); // } std::map*,tChannelIDCompare>::iterator it; - if (schedules) { - for ( it=map_list->begin() ; it != map_list->end(); it++ ) { - cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID((*it).first), true); - while (schedules && ((*it).second->First()) != NULL) { - cEvent* event = *(*it).second->First(); - - cEvent *pEqvEvent = (cEvent *) schedule->GetEvent (event->EventID(), event->StartTime()); - if (pEqvEvent) - schedule->DelEvent(pEqvEvent); - - schedule->AddEvent(event); - (*it).second->Del(event); - } - EpgHandlers.SortSchedule(schedule); - + it=map_list->begin(); + while (schedules && it != map_list->end()) { + cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID((*it).first), true); + while (((*it).second->First()) != NULL) { + cEvent* event = *(*it).second->First(); + + cEvent *pEqvEvent = (cEvent *) schedule->GetEvent (event->EventID(), event->StartTime()); + if (pEqvEvent) + schedule->DelEvent(pEqvEvent); + + schedule->AddEvent(event); + (*it).second->Del(event); } + EpgHandlers.SortSchedule(schedule); + delete (*it).second; + map_list->erase(it++); + } Unlock(); cCondWait::SleepMs(10); -- cgit v1.2.3 From 14dbadc6e5865cf25440468727059febd06af212 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 5 Jun 2012 09:47:12 +0200 Subject: reduced logging --- equivhandler.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/equivhandler.c b/equivhandler.c index 2c1b424..a742150 100644 --- a/equivhandler.c +++ b/equivhandler.c @@ -166,11 +166,11 @@ void cEquivHandler::updateEquivalent(tChannelID channelID, cEvent *pEvent){ multimap::iterator it; pair::iterator,multimap::iterator> ret; - LogD(2, prep("Start updateEquivalent %s"), *channelID.ToString()); + LogD(3, prep("Start updateEquivalent %s"), *channelID.ToString()); ret = equiChanMap.equal_range(*channelID.ToString()); for (it=ret.first; it!=ret.second; ++it) { - LogD(2, prep("equivalent channel exists")); + LogD(3, prep("equivalent channel exists")); tChannelID equChannelID (tChannelID::FromString((*it).second.c_str())); cEvent* newEvent = new cEvent (pEvent->EventID()); cloneEvent(pEvent, newEvent); -- cgit v1.2.3 From d207fd0a5873a4a60488a8dc2eb0cf62c172069b Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 16 Oct 2012 12:37:32 +0200 Subject: delete the event if it already exist. this should be rewritten --- epghandler.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/epghandler.c b/epghandler.c index 44ee909..f8a6636 100644 --- a/epghandler.c +++ b/epghandler.c @@ -43,6 +43,25 @@ bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, } } + //VDR creates new event if the EitEvent StartTime is different than EEPG time so + //the EEPG event has to be deleted but the data should be kept + const cEvent* ev = Schedule->GetEvent(EitEvent->getEventId(),EitEvent->getStartTime()); + if (!ev){ + ev = Schedule->GetEvent(EitEvent->getEventId()); + if (ev && ((ev->StartTime()>EitEvent->getStartTime() && ev->StartTime()<=EitEvent->getStartTime()+EitEvent->getDuration()) + || (EitEvent->getStartTime() > ev->StartTime() && EitEvent->getStartTime() <= ev->EndTime()))) { + LogD(0, prep("!!!Deleting Event id:%d title:%s start_time:%d new_start_time:%d duration:%d new_duration:%d"), ev->EventID(), ev->Title(), ev->StartTime(), EitEvent->getStartTime(), ev->Duration(), EitEvent->getDuration()); + + if (ev->Description() && strcmp(ev->Description(),"") != 0) + origDescription = ev->Description(); + if (ev->ShortText() && strcmp(ev->ShortText(),"") != 0) + origShortText = ev->ShortText(); + Schedule->DropOutdated(ev->StartTime()-1,ev->EndTime()+1,ev->TableID()-1,ev->Version()); + LogD(0, prep("!!!End Deleting Event")); + } + } + + return false; // return true; -- cgit v1.2.3 From 7de1003a14fb4b41920896c550db4e58f53aea8d Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 16 Oct 2012 19:40:59 +0200 Subject: Drop unmanaged Disable Double EPG entry. EEPG tries to handle this anyway Drop unmanaged NOEPG support, there is a separate plugin for that Move cEIT2 in a separate file and try to use it in epghandler also --- Makefile | 2 +- eepg.c | 645 +---------------------------------------------------------- eit2.c | 640 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ eit2.h | 49 +++++ epghandler.c | 7 +- epghandler.h | 2 + util.h | 3 + 7 files changed, 702 insertions(+), 646 deletions(-) create mode 100644 eit2.c create mode 100644 eit2.h diff --git a/Makefile b/Makefile index b63221f..49e8770 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"' ### The object files (add further files here): -OBJS = $(PLUGIN).o dish.o epghandler.o setupeepg.o equivhandler.o util.o +OBJS = $(PLUGIN).o dish.o epghandler.o setupeepg.o equivhandler.o util.o eit2.o ifdef DBG CXXFLAGS += -g diff --git a/eepg.c b/eepg.c index 1361b72..1174681 100644 --- a/eepg.c +++ b/eepg.c @@ -150,7 +150,7 @@ void cMenuSetupPremiereEpg::Store (void) #endif } -#define Asprintf(a, b, c...) void( asprintf(a, b, c) < 0 ? esyslog("memory allocation error - %s", b) : void() ) +//#define Asprintf(a, b, c...) void( asprintf(a, b, c) < 0 ? esyslog("memory allocation error - %s", b) : void() ) // --- CRC16 ------------------------------------------------------------------- @@ -173,27 +173,6 @@ unsigned int crc16 (unsigned int crc, unsigned char const *p, int len) static int LastVersionNagra = -1; //currently only used for Nagra, should be stored per transponder, per system - -#ifdef USE_NOEPG -bool allowedEPG (tChannelID kanalID) -{ - bool rc; - - if (Setup.noEPGMode == 1) { - rc = false; - if (strstr (::Setup.noEPGList, kanalID.ToString ()) != NULL) - rc = true; - } else { - rc = true; - if (strstr (::Setup.noEPGList, kanalID.ToString ()) != NULL) - rc = false; - } - - return rc; -} -#endif /* NOEPG */ - - class cFilterEEPG:public cFilter { private: @@ -2662,628 +2641,6 @@ void cFilterEEPG::AddFilter (u_short Pid, u_char Tid, unsigned char Mask) } } -namespace SI -{ - enum DescriptorTagExt { - DishRatingDescriptorTag = 0x89, - DishShortEventDescriptorTag = 0x91, - DishExtendedEventDescriptorTag = 0x92, - DishSeriesDescriptorTag = 0x96, - }; - -// typedef InheritEnum< DescriptorTagExt, SI::DescriptorTag > ExtendedDescriptorTag; - -/*extern const char *getCharacterTable(const unsigned char *&buffer, int &length, bool *isSingleByte = NULL); -extern bool convertCharacterTable(const char *from, size_t fromLength, char *to, size_t toLength, const char *fromCode); -extern bool SystemCharacterTableIsSingleByte;*/ -class cEIT2:public SI::EIT -{ -public: - cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool isEITPid = false, bool OnlyRunningStatus = false); -//protected: -// void updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent); -}; - - -cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool isEITPid, bool OnlyRunningStatus) -: SI::EIT (Data, false) -{ - //LogD(2, prep("cEIT2::cEIT2")); - if (Tid > 0 && (Format == DISH_BEV || (SetupPE->ProcessEIT && isEITPid))) Tid--; - - if (!CheckCRCAndParse ()) { - LogD(2, prep("!CheckCRCAndParse ()")); - return; - } - - bool searchOtherSatPositions = Format == DISH_BEV; - - tChannelID channelID (Source, getOriginalNetworkId (), getTransportStreamId (), getServiceId ()); - cChannel *channel = GetChannelByID (channelID, searchOtherSatPositions); - if (!channel) { - LogD(3, prep("!channel channelID: %s"), *channelID.ToString()); - return; // only collect data for known channels - } - - //LogD(5, prep("channelID: %s format:%d"), *channel->GetChannelID().ToString(), Format); - -#ifdef USE_NOEPG - // only use epg from channels not blocked by noEPG-patch - tChannelID kanalID; - kanalID = channel->GetChannelID (); - if (!allowedEPG (kanalID)) - return; -#endif /* NOEPG */ - - cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (channel, true); - - bool Empty = true; - bool Modified = false; - bool HasExternalData = false; - time_t SegmentStart = 0; - time_t SegmentEnd = 0; - - SI::EIT::Event SiEitEvent; - for (SI::Loop::Iterator it; eventLoop.getNext (SiEitEvent, it);) { - bool ExternalData = false; - // Drop bogus events - but keep NVOD reference events, where all bits of the start time field are set to 1, resulting in a negative number. - if (SiEitEvent.getStartTime () == 0 || (SiEitEvent.getStartTime () > 0 && SiEitEvent.getDuration () == 0)) - continue; - Empty = false; - if (!SegmentStart) - SegmentStart = SiEitEvent.getStartTime (); - SegmentEnd = SiEitEvent.getStartTime () + SiEitEvent.getDuration (); - int versionNumber = getVersionNumber(); - - cEvent *newEvent = NULL; - cEvent *rEvent = NULL; - cEvent *pEvent = (cEvent *) pSchedule->GetEvent (SiEitEvent.getEventId (), SiEitEvent.getStartTime ()); - if (!pEvent) { - if (OnlyRunningStatus) - continue; - // If we don't have that event yet, we create a new one. - // Otherwise we copy the information into the existing event anyway, because the data might have changed. - pEvent = newEvent = new cEvent (SiEitEvent.getEventId ()); - if (!pEvent) - continue; - } else { - //LogD(3, prep("existing event channelID: %s Title: %s TableID 0x%02X new TID 0x%02X Version %i, new version %i"), *channel->GetChannelID().ToString(), pEvent->Title(), pEvent->TableID(), Tid, pEvent->Version(), versionNumber); - // We have found an existing event, either through its event ID or its start time. - pEvent->SetSeen (); - - // If the existing event has a zero table ID it was defined externally and shall - // not be overwritten. - if (pEvent->TableID () == 0x00) { -#ifdef USE_DDEPGENTRY - if (pEvent->Version () == getVersionNumber ()) { - if (Setup.MixEpgAction == 0) - continue; - //printf("in"); - //printf("%s", pEvent->GetTimeString()); - // to use the info of the original epg, update the extern one, - // if it has less info - SI::Descriptor * d; - SI::ExtendedEventDescriptors * ExtendedEventDescriptors = NULL; - //SI::ExtendedEventDescriptor *eed = NULL; - SI::ShortEventDescriptor * ShortEventDescriptor = NULL; - //SI::ShortEventDescriptor *sed = NULL; - //SI::TimeShiftedEventDescriptor *tsed = NULL; - //cLinkChannels *LinkChannels = NULL; - for (SI::Loop::Iterator it2; (d = SiEitEvent.eventDescriptors.getNext (it2));) { - if (d->getDescriptorTag () == SI::ShortEventDescriptorTag) { - int LanguagePreferenceShort = -1; - SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d; - if (I18nIsPreferredLanguage (Setup.EPGLanguages, sed->languageCode, LanguagePreferenceShort) - || !ShortEventDescriptor) { - delete ShortEventDescriptor; - ShortEventDescriptor = sed; - d = NULL; // so that it is not deleted - } - } else if (d->getDescriptorTag () == SI::ExtendedEventDescriptorTag) { - int LanguagePreferenceExt = -1; - bool UseExtendedEventDescriptor = false; - SI::ExtendedEventDescriptor * eed = (SI::ExtendedEventDescriptor *) d; - if (I18nIsPreferredLanguage (Setup.EPGLanguages, eed->languageCode, LanguagePreferenceExt) - || !ExtendedEventDescriptors) { - delete ExtendedEventDescriptors; - ExtendedEventDescriptors = new SI::ExtendedEventDescriptors; - UseExtendedEventDescriptor = true; - } - if (UseExtendedEventDescriptor) { - ExtendedEventDescriptors->Add (eed); - d = NULL; // so that it is not deleted - } - if (eed->getDescriptorNumber () == eed->getLastDescriptorNumber ()) - UseExtendedEventDescriptor = false; - } - delete d; - } - if (pEvent) { - if (ShortEventDescriptor) { - char buffer[256]; - if (ShortEventDescriptor->text.getText (buffer, sizeof (buffer)) && pEvent->ShortText () - && (strlen (ShortEventDescriptor->text.getText (buffer, sizeof (buffer))) > - strlen (pEvent->ShortText ()))) { - pEvent->SetShortText (ShortEventDescriptor->text.getText (buffer, sizeof (buffer))); - pEvent->FixEpgBugs (); - } - } - if (ExtendedEventDescriptors) { - char buffer[ExtendedEventDescriptors->getMaximumTextLength (": ") + 1]; - //pEvent->SetDescription(ExtendedEventDescriptors->getText(buffer, sizeof(buffer), ": ")); - if (ExtendedEventDescriptors->getText (buffer, sizeof (buffer), ": ") - && pEvent->Description () - && (strlen (ExtendedEventDescriptors->getText (buffer, sizeof (buffer), ": ")) > - strlen (pEvent->Description ()))) { - pEvent->SetDescription (ExtendedEventDescriptors->getText (buffer, sizeof (buffer), ": ")); - pEvent->FixEpgBugs (); - } - } - } - delete ExtendedEventDescriptors; - delete ShortEventDescriptor; - continue; - } -#else - if (pEvent->Version () == versionNumber) - continue; -#endif /* DDEPGENTRY */ - HasExternalData = ExternalData = true; - } - // If the new event has a higher table ID, let's skip it. - // The lower the table ID, the more "current" the information. - else if (Tid > pEvent->TableID()) - continue; - // If the new event comes from the same table and has the same version number - // as the existing one, let's skip it to avoid unnecessary work. - // Unfortunately some stations (like, e.g. "Premiere") broadcast their EPG data on several transponders (like - // the actual Premiere transponder and the Sat.1/Pro7 transponder), but use different version numbers on - // each of them :-( So if one DVB card is tuned to the Premiere transponder, while an other one is tuned - // to the Sat.1/Pro7 transponder, events will keep toggling because of the bogus version numbers. - else if (Tid == pEvent->TableID() && pEvent->Version() == versionNumber) - continue; - } - if (!ExternalData) { - pEvent->SetEventID (SiEitEvent.getEventId ()); // unfortunately some stations use different event ids for the same event in different tables :-( - pEvent->SetTableID (Tid); - pEvent->SetStartTime (SiEitEvent.getStartTime ()); - pEvent->SetDuration (SiEitEvent.getDuration ()); - } - if (newEvent) - pSchedule->AddEvent (newEvent); - if (Tid == 0x4E) { // we trust only the present/following info on the actual TS -#ifdef USE_DDEPGENTRY - if (Setup.DisableVPS == 0 && SiEitEvent.getRunningStatus () >= SI::RunningStatusNotRunning) -#else - if (SiEitEvent.getRunningStatus () >= SI::RunningStatusNotRunning) -#endif /* DDEPGENTRY */ - pSchedule->SetRunningStatus (pEvent, SiEitEvent.getRunningStatus (), channel); - } - if (OnlyRunningStatus) - continue; // do this before setting the version, so that the full update can be done later - pEvent->SetVersion (versionNumber); - - int LanguagePreferenceShort = -1; - int LanguagePreferenceExt = -1; - unsigned char nDescriptorTag; - bool UseExtendedEventDescriptor = false; - SI::Descriptor * d; - SI::ExtendedEventDescriptors * ExtendedEventDescriptors = NULL; - SI::ShortEventDescriptor * ShortEventDescriptor = NULL; - //SI::DishDescriptor *DishExtendedEventDescriptor = NULL; - SI::DishDescriptor *DishEventDescriptor = NULL; - //uchar DishTheme = 0, DishCategory = 0; - - - cLinkChannels *LinkChannels = NULL; - cComponents *Components = NULL; - for (SI::Loop::Iterator it2; (d = SiEitEvent.eventDescriptors.getNext (it2));) { - if (ExternalData && d->getDescriptorTag () != SI::ComponentDescriptorTag) { - delete d; - LogD(2, prep("continue:d->getDescriptorTAG():%x)"), d->getDescriptorTag ()); - continue; - } - - //LogD(2, prep("EEPGDEBUG:d->getDescriptorTAG():%x)"), d->getDescriptorTag ()); - nDescriptorTag = d->getDescriptorTag (); - switch (nDescriptorTag) { - case SI::ExtendedEventDescriptorTag: { - SI::ExtendedEventDescriptor * eed = (SI::ExtendedEventDescriptor *) d; - if (I18nIsPreferredLanguage (Setup.EPGLanguages, eed->languageCode, LanguagePreferenceExt) - || !ExtendedEventDescriptors) { - delete ExtendedEventDescriptors; - ExtendedEventDescriptors = new SI::ExtendedEventDescriptors; - UseExtendedEventDescriptor = true; - } - if (UseExtendedEventDescriptor) { - ExtendedEventDescriptors->Add (eed); - d = NULL; // so that it is not deleted - } - if (eed->getDescriptorNumber () == eed->getLastDescriptorNumber ()) - UseExtendedEventDescriptor = false; - } - break; - case SI::ShortEventDescriptorTag: { - SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d; - if (I18nIsPreferredLanguage (Setup.EPGLanguages, sed->languageCode, LanguagePreferenceShort) - || !ShortEventDescriptor) { - delete ShortEventDescriptor; - ShortEventDescriptor = sed; - d = NULL; // so that it is not deleted - } - } - break; -#if APIVERSNUM > 10711 - case SI::ContentDescriptorTag: { - SI::ContentDescriptor *cd = (SI::ContentDescriptor *)d; - SI::ContentDescriptor::Nibble Nibble; - int NumContents = 0; - uchar Contents[MaxEventContents] = { 0 }; - for (SI::Loop::Iterator it3; cd->nibbleLoop.getNext(Nibble, it3); ) { - if (NumContents < MaxEventContents) { - Contents[NumContents] = ((Nibble.getContentNibbleLevel1() & 0xF) << 4) | (Nibble.getContentNibbleLevel2() & 0xF); - NumContents++; - } - if (DishEventDescriptor && NumContents == 1) { - DishEventDescriptor->setContent(Nibble); - } -// LogD(2, prep("EEPGDEBUG:Nibble:%x-%x-%x-%x)"), Nibble.getContentNibbleLevel1(),Nibble.getContentNibbleLevel2() -// , Nibble.getUserNibble1(), Nibble.getUserNibble2()); - - } - pEvent->SetContents(Contents); - } - break; -#endif - case SI::ParentalRatingDescriptorTag: { - int LanguagePreferenceRating = -1; - SI::ParentalRatingDescriptor *prd = (SI::ParentalRatingDescriptor *)d; - SI::ParentalRatingDescriptor::Rating Rating; - for (SI::Loop::Iterator it3; prd->ratingLoop.getNext(Rating, it3); ) { - if (I18nIsPreferredLanguage(Setup.EPGLanguages, Rating.languageCode, LanguagePreferenceRating)) { - int ParentalRating = (Rating.getRating() & 0xFF); - switch (ParentalRating) { - // values defined by the DVB standard (minimum age = rating + 3 years): - case 0x01 ... 0x0F: - ParentalRating += 3; - break; - // values defined by broadcaster CSAT (now why didn't they just use 0x07, 0x09 and 0x0D?): - case 0x11: - ParentalRating = 10; - break; - case 0x12: - ParentalRating = 12; - break; - case 0x13: - ParentalRating = 16; - break; - default: - ParentalRating = 0; - } - pEvent->SetParentalRating(ParentalRating); - } - } - } - break; - case SI::PDCDescriptorTag: { - SI::PDCDescriptor * pd = (SI::PDCDescriptor *) d; - 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 = pd->getMonth () - 1; - t.tm_mday = pd->getDay (); - t.tm_hour = pd->getHour (); - t.tm_min = pd->getMinute (); - 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--; - time_t vps = mktime (&t); - pEvent->SetVps (vps); - } - break; - case SI::TimeShiftedEventDescriptorTag: { - SI::TimeShiftedEventDescriptor * tsed = (SI::TimeShiftedEventDescriptor *) d; - cSchedule *rSchedule = - (cSchedule *) Schedules-> - GetSchedule (tChannelID (Source, channel->Nid (), channel->Tid (), tsed->getReferenceServiceId ())); - if (!rSchedule) - break; - rEvent = (cEvent *) rSchedule->GetEvent (tsed->getReferenceEventId ()); - if (!rEvent) - break; - pEvent->SetTitle (rEvent->Title ()); - pEvent->SetShortText (rEvent->ShortText ()); - pEvent->SetDescription (rEvent->Description ()); - } - break; - case SI::LinkageDescriptorTag: { - SI::LinkageDescriptor * ld = (SI::LinkageDescriptor *) d; - tChannelID linkID (Source, ld->getOriginalNetworkId (), ld->getTransportStreamId (), ld->getServiceId ()); - if (ld->getLinkageType () == 0xB0) { // Premiere World - time_t now = time (NULL); - bool hit = SiEitEvent.getStartTime () <= now - && now < SiEitEvent.getStartTime () + SiEitEvent.getDuration (); - if (hit) { - char linkName[ld->privateData.getLength () + 1]; - strn0cpy (linkName, (const char *) ld->privateData.getData (), sizeof (linkName)); - // TODO is there a standard way to determine the character set of this string? - cChannel *link = Channels.GetByChannelID (linkID); - if (link != channel) { // only link to other channels, not the same one - //fprintf(stderr, "Linkage %s %4d %4d %5d %5d %5d %5d %02X '%s'\n", hit ? "*" : "", channel->Number(), link ? link->Number() : -1, SiEitEvent.getEventId(), ld->getOriginalNetworkId(), ld->getTransportStreamId(), ld->getServiceId(), ld->getLinkageType(), linkName);//XXX - if (link) { - if (Setup.UpdateChannels == 1 || Setup.UpdateChannels >= 3) - link->SetName (linkName, "", ""); - } else if (Setup.UpdateChannels >= 4) { - cChannel *transponder = channel; - if (channel->Tid () != ld->getTransportStreamId ()) - transponder = Channels.GetByTransponderID (linkID); - link = - Channels.NewChannel (transponder, linkName, "", "", ld->getOriginalNetworkId (), - ld->getTransportStreamId (), ld->getServiceId ()); - } - if (link) { - if (!LinkChannels) - LinkChannels = new cLinkChannels; - LinkChannels->Add (new cLinkChannel (link)); - } - } else - channel->SetPortalName (linkName); - } - } - } - break; - case SI::ComponentDescriptorTag: { - SI::ComponentDescriptor * cd = (SI::ComponentDescriptor *) d; - uchar Stream = cd->getStreamContent (); - uchar Type = cd->getComponentType (); - //if (1 <= Stream && Stream <= 3 && Type != 0) { // 1=video, 2=audio, 3=subtitles - if (1 <= Stream && Stream <= 6 && Type != 0) { // 1=MPEG2-video, 2=MPEG1-audio, 3=subtitles, 4=AC3-audio, 5=H.264-video, 6=HEAAC-audio - if (!Components) - Components = new cComponents; - char buffer[Utf8BufSize (256)]; - Components->SetComponent (Components->NumComponents (), Stream, Type, - I18nNormalizeLanguageCode (cd->languageCode), - cd->description.getText (buffer, sizeof (buffer))); - } - } - break; - case SI::DishExtendedEventDescriptorTag: { - SI::UnimplementedDescriptor *deed = (SI::UnimplementedDescriptor *)d; - if (!DishEventDescriptor) { - DishEventDescriptor = new SI::DishDescriptor(); - } - DishEventDescriptor->setExtendedtData(Tid+1, deed->getData()); - HasExternalData = true; - } - break; - case SI::DishShortEventDescriptorTag: { - SI::UnimplementedDescriptor *dsed = (SI::UnimplementedDescriptor *)d; - if (!DishEventDescriptor) { - DishEventDescriptor = new SI::DishDescriptor(); - } - DishEventDescriptor->setShortData(Tid+1, dsed->getData()); - HasExternalData = true; - } - break; - case SI::DishRatingDescriptorTag: { - if (d->getLength() == 4) { - if (!DishEventDescriptor) { - DishEventDescriptor = new SI::DishDescriptor(); - } - uint16_t rating = d->getData().TwoBytes(2); - DishEventDescriptor->setRating(rating); - } - } - break; - case SI::DishSeriesDescriptorTag: { - if (d->getLength() == 10) { - //LogD(2, prep("DishSeriesDescriptorTag: %s)"), (const char*) d->getData().getData()); - if (!DishEventDescriptor) { - DishEventDescriptor = new SI::DishDescriptor(); - } - DishEventDescriptor->setEpisodeInfo(d->getData()); - } -// else { -// LogD(2, prep("DishSeriesDescriptorTag length: %d)"), d->getLength()); -// } - } - break; - default: - break; - } - delete d; - } - - if (!rEvent) { - if (ShortEventDescriptor) { - char buffer[Utf8BufSize (256)]; - unsigned char *f; - int l = ShortEventDescriptor->name.getLength(); - f = (unsigned char *) ShortEventDescriptor->name.getData().getData(); - decodeText2 (f, l, buffer, sizeof (buffer)); - //ShortEventDescriptor->name.getText(buffer, sizeof(buffer)); - LogD(2, prep("Title: %s Decoded: %s"), f, buffer); - pEvent->SetTitle (buffer); - LogD(3, prep("channelID: %s Title: %s"), *channel->GetChannelID().ToString(), pEvent->Title()); - l = ShortEventDescriptor->text.getLength(); - if (l > 0) { //Set the Short Text only if there is data so that we do not overwrite valid data - f = (unsigned char *) ShortEventDescriptor->text.getData().getData(); - decodeText2 (f, l, buffer, sizeof (buffer)); - //ShortEventDescriptor->text.getText(buffer, sizeof(buffer)); - pEvent->SetShortText (buffer); - } - LogD(3, prep("ShortText: %s"), pEvent->ShortText()); - LogD(2, prep("ShortText: %s Decoded: %s"), f, buffer); - } else if (!HasExternalData) { - pEvent->SetTitle (NULL); - pEvent->SetShortText (NULL); - LogD(3, prep("SetTitle (NULL)")); - } - if (ExtendedEventDescriptors) { - char buffer[Utf8BufSize (ExtendedEventDescriptors->getMaximumTextLength (": ")) + 1]; - pEvent->SetDescription (ExtendedEventDescriptors->getText (buffer, sizeof (buffer), ": ")); - LogD(3, prep("Description: %s"), pEvent->Description()); - } else if (!HasExternalData) - pEvent->SetDescription (NULL); - - if (DishEventDescriptor) { - if (DishEventDescriptor->getName()) - pEvent->SetTitle(DishEventDescriptor->getName()); - //LogD(2, prep("channelID: %s DishTitle: %s"), *channel->GetChannelID().ToString(), DishEventDescriptor->getName()); - pEvent->SetShortText(DishEventDescriptor->getShortText()); - char *tmp; - string fmt; - - const char * description = DishEventDescriptor->getDescription(); - //BEV sets the description previously with ExtendedEventDescriptor - if (0 == strcmp(DishEventDescriptor->getDescription(),"") && pEvent->Description()) - description = pEvent->Description(); - - - fmt = "%s"; - if (DishEventDescriptor->hasTheme()) { - fmt += "\nTheme: "; - } - fmt += "%s"; - if (DishEventDescriptor->hasCategory()) { - fmt += "\nCategory: "; - } - fmt += "%s"; - - if ((0 != strcmp(DishEventDescriptor->getRating(),"") - || 0 != strcmp(DishEventDescriptor->getStarRating(),""))) { - fmt += "\n\nRating: "; - } - fmt += "%s %s"; - if (0 != strcmp(DishEventDescriptor->getProgramId(),"")) { - fmt += "\n\nProgram ID: "; - } - fmt += "%s %s%s"; - time_t orgAirDate = DishEventDescriptor->getOriginalAirDate(); - char datestr [80]; - bool dateok = false; - if (orgAirDate == 0) { - dateok = strftime (datestr,80," Original Air Date: %a %b %d %Y",gmtime(&orgAirDate)) > 0; - } - - Asprintf (&tmp, fmt.c_str(), description - , DishEventDescriptor->getTheme(), DishEventDescriptor->getCategory() - , DishEventDescriptor->getRating(), DishEventDescriptor->getStarRating() - , DishEventDescriptor->getProgramId(), DishEventDescriptor->getSeriesId() - , orgAirDate == 0 || !dateok ? "" : datestr); - pEvent->SetDescription(tmp); - free(tmp); - - - //LogD(2, prep("DishDescription: %s"), DishEventDescriptor->getDescription()); - //LogD(2, prep("DishShortText: %s"), DishEventDescriptor->getShortText()); - } - - } - delete ExtendedEventDescriptors; - delete ShortEventDescriptor; - delete DishEventDescriptor; - - pEvent->SetComponents (Components); - -// LogD(2, prep("channelID: %s Title: %s"), *channel->GetChannelID().ToString(), pEvent->Title()); - -// if (pEvent->ChannelID() == tChannelID::FromString("S119.0W-4100-6-110-110")) { -// LogD(2, prep("ID: %d Title: %s Time: %d Tid: 0x%x"), pEvent->EventID(), pEvent->Title(), pEvent->StartTime(), pEvent->TableID()); -// } - - if (!HasExternalData) - pEvent->FixEpgBugs (); - if (LinkChannels) - channel->SetLinkChannels (LinkChannels); - Modified = true; -#ifdef USE_DDEPGENTRY - //to avoid double epg-entrys from ext and int epg sources :EW - if (pEvent && pEvent->TableID () != 0x00) { - cEvent *pPreviousEvent = (cEvent *) pSchedule->GetPreviousEvent (pEvent); - if (pPreviousEvent) { - if (Setup.DoubleEpgAction == 0) { - pPreviousEvent->SetStartTime (pEvent->StartTime ()); - pPreviousEvent->SetDuration (pEvent->Duration ()); - if (Setup.DisableVPS == 0) { - if (channel) - pPreviousEvent->SetRunningStatus (pEvent->RunningStatus (), channel); - else - pPreviousEvent->SetRunningStatus (pEvent->RunningStatus ()); - } - // to use the info of the original epg, update the extern one, - // if it has less info - char buffer_short_intern[256]; - char buffer_short_extern[256]; - int len_short_intern = 0; - int len_short_extern = 0; - if (pEvent->ShortText ()) - len_short_intern = - snprintf (buffer_short_intern, sizeof (buffer_short_intern) - 1, "%s", pEvent->ShortText ()); - if (pPreviousEvent->ShortText ()) - len_short_extern = - snprintf (buffer_short_extern, sizeof (buffer_short_extern) - 1, "%s", pPreviousEvent->ShortText ()); - if (len_short_intern > 0) { - if (len_short_extern < 1) - pPreviousEvent->SetShortText (buffer_short_intern); - else if (len_short_intern > len_short_extern) - pPreviousEvent->SetShortText (buffer_short_intern); - } - if (pEvent->Description ()) { - char buffer_title_intern[4096]; - char buffer_title_extern[4096]; - int len_title_intern = 0; - int len_title_extern = 0; - if (pEvent->Description ()) - len_title_intern = - snprintf (buffer_title_intern, sizeof (buffer_title_intern) - 1, "%s", pEvent->Description ()); - if (pPreviousEvent->Description ()) - len_title_extern = - snprintf (buffer_title_extern, sizeof (buffer_title_extern) - 1, "%s", - pPreviousEvent->Description ()); - if (len_title_intern > 0) { - if (len_title_extern < 1) - pPreviousEvent->SetDescription (buffer_title_intern); - else if (len_title_intern > len_title_extern) - pPreviousEvent->SetDescription (buffer_title_intern); - } - } - if (pPreviousEvent->Vps () == 0 && pEvent->Vps () != 0) - pPreviousEvent->SetVps (pEvent->Vps ()); - pSchedule->DelEvent (pEvent); - pPreviousEvent->FixEpgBugs (); - } else - pSchedule->DelEvent (pPreviousEvent); - } - } -#endif /* DDEPGENTRY */ - EquivHandler->updateEquivalent(Schedules, channel->GetChannelID(), pEvent); - } - if (Empty && Tid == 0x4E && getSectionNumber () == 0) - // ETR 211: an empty entry in section 0 of table 0x4E means there is currently no event running - pSchedule->ClrRunningStatus (channel); - if (Tid == 0x4E) - pSchedule->SetPresentSeen (); - if (OnlyRunningStatus) { - LogD(4, prep("OnlyRunningStatus")); - return; - } - if (Modified) { - if (!HasExternalData) - pSchedule->DropOutdated (SegmentStart, SegmentEnd, Tid, getVersionNumber ()); - sortSchedules(Schedules, channel->GetChannelID()); - } - LogD(4, prep("end of cEIT2")); - -} -//end of cEIT2 - -} //end namespace SI - void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) { /* for (int i = 0; i <= HIGHEST_FORMAT; i++) diff --git a/eit2.c b/eit2.c new file mode 100644 index 0000000..5bd7cc4 --- /dev/null +++ b/eit2.c @@ -0,0 +1,640 @@ +/* + * eit2.c + * + * Created on: Oct 16, 2012 + * Author: d.petrovski + */ +#include "eit2.h" + +#include +#include +#include "log.h" +#include "util.h" + +using namespace std; +using namespace util; + +namespace SI +{ + + cEvent* cEIT2::ProcessEitEvent(cSchedule* pSchedule,const SI::EIT::Event* EitEvent, + uchar Tid, uchar versionNumber) + { + bool ExternalData = false; + // Drop bogus events - but keep NVOD reference events, where all bits of the start time field are set to 1, resulting in a negative number. + if (EitEvent->getStartTime () == 0 || (EitEvent->getStartTime () > 0 && EitEvent->getDuration () == 0)) + return NULL; + Empty = false; + if (!SegmentStart) + SegmentStart = EitEvent->getStartTime (); + SegmentEnd = EitEvent->getStartTime () + EitEvent->getDuration (); +// int versionNumber = getVersionNumber(); + + cEvent *newEvent = NULL; + cEvent *pEvent = (cEvent *) pSchedule->GetEvent (EitEvent->getEventId (), EitEvent->getStartTime ()); + if (!pEvent) { + if (OnlyRunningStatus) + return NULL; + // If we don't have that event yet, we create a new one. + // Otherwise we copy the information into the existing event anyway, because the data might have changed. + pEvent = newEvent = new cEvent (EitEvent->getEventId ()); + if (!pEvent) + return NULL; + } else { + //LogD(3, prep("existing event channelID: %s Title: %s TableID 0x%02X new TID 0x%02X Version %i, new version %i"), *channel->GetChannelID().ToString(), pEvent->Title(), pEvent->TableID(), Tid, pEvent->Version(), versionNumber); + // We have found an existing event, either through its event ID or its start time. + pEvent->SetSeen (); + + // If the existing event has a zero table ID it was defined externally and shall + // not be overwritten. + if (pEvent->TableID () == 0x00) { + if (pEvent->Version () == versionNumber) + return NULL; + /*HasExternalData = */ExternalData = true; + } + // If the new event has a higher table ID, let's skip it. + // The lower the table ID, the more "current" the information. + else if (Tid > pEvent->TableID()) + return NULL; + // If the new event comes from the same table and has the same version number + // as the existing one, let's skip it to avoid unnecessary work. + // Unfortunately some stations (like, e.g. "Premiere") broadcast their EPG data on several transponders (like + // the actual Premiere transponder and the Sat.1/Pro7 transponder), but use different version numbers on + // each of them :-( So if one DVB card is tuned to the Premiere transponder, while an other one is tuned + // to the Sat.1/Pro7 transponder, events will keep toggling because of the bogus version numbers. + else if (Tid == pEvent->TableID() && pEvent->Version() == versionNumber) + return NULL; + } + if (!ExternalData) { + pEvent->SetEventID (EitEvent->getEventId ()); // unfortunately some stations use different event ids for the same event in different tables :-( + pEvent->SetTableID (Tid); + pEvent->SetStartTime (EitEvent->getStartTime ()); + pEvent->SetDuration (EitEvent->getDuration ()); + } + if (newEvent) + pSchedule->AddEvent (newEvent); + if (Tid == 0x4E) { // we trust only the present/following info on the actual TS + if (EitEvent->getRunningStatus () >= SI::RunningStatusNotRunning) + pSchedule->SetRunningStatus (pEvent, EitEvent->getRunningStatus (), channel); + } + if (OnlyRunningStatus) + return NULL; // do this before setting the version, so that the full update can be done later + pEvent->SetVersion (versionNumber); + + ProcessEventDescriptors(ExternalData, channel->Source(), Tid, EitEvent, + pEvent, Schedules, channel); + + Modified = true; + return pEvent; + } + + void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, + u_char Tid, const SI::EIT::Event* SiEitEvent, cEvent* pEvent, + cSchedules* Schedules, cChannel* channel) + { + + cEvent *rEvent = NULL; + int LanguagePreferenceShort = -1; + int LanguagePreferenceExt = -1; + unsigned char nDescriptorTag; + bool UseExtendedEventDescriptor = false; + SI::Descriptor * d; + SI::ExtendedEventDescriptors * ExtendedEventDescriptors = NULL; + SI::ShortEventDescriptor * ShortEventDescriptor = NULL; + //SI::DishDescriptor *DishExtendedEventDescriptor = NULL; + SI::DishDescriptor *DishEventDescriptor = NULL; + //uchar DishTheme = 0, DishCategory = 0; + + + cLinkChannels *LinkChannels = NULL; + cComponents *Components = NULL; + + + + for (SI::Loop::Iterator it2; (d = SiEitEvent->eventDescriptors.getNext(it2)); ) + { + if (ExternalData && d->getDescriptorTag() != SI::ComponentDescriptorTag) + { + delete d; + LogD(2, prep("continue:d->getDescriptorTAG():%x)"), d->getDescriptorTag ()); + continue; + } + + //LogD(2, prep("EEPGDEBUG:d->getDescriptorTAG():%x)"), d->getDescriptorTag ()); + nDescriptorTag = d->getDescriptorTag(); + switch (nDescriptorTag) + { + case SI::ExtendedEventDescriptorTag: + { + SI::ExtendedEventDescriptor * eed = + (SI::ExtendedEventDescriptor *) d; + if (I18nIsPreferredLanguage(Setup.EPGLanguages, eed->languageCode, + LanguagePreferenceExt) || !ExtendedEventDescriptors) + { + delete ExtendedEventDescriptors; + ExtendedEventDescriptors = new SI::ExtendedEventDescriptors; + UseExtendedEventDescriptor = true; + } + if (UseExtendedEventDescriptor) + { + ExtendedEventDescriptors->Add(eed); + d = NULL; // so that it is not deleted + } + if (eed->getDescriptorNumber() == eed->getLastDescriptorNumber()) + UseExtendedEventDescriptor = false; + } + break; + case SI::ShortEventDescriptorTag: + { + SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d; + if (I18nIsPreferredLanguage(Setup.EPGLanguages, sed->languageCode, + LanguagePreferenceShort) || !ShortEventDescriptor) + { + delete ShortEventDescriptor; + ShortEventDescriptor = sed; + d = NULL; // so that it is not deleted + } + } + break; +#if APIVERSNUM > 10711 + case SI::ContentDescriptorTag: + { + SI::ContentDescriptor *cd = (SI::ContentDescriptor *) d; + SI::ContentDescriptor::Nibble Nibble; + int NumContents = 0; + uchar Contents[MaxEventContents] = + { 0 }; + for (SI::Loop::Iterator it3; cd->nibbleLoop.getNext(Nibble, it3);) + { + if (NumContents < MaxEventContents) + { + Contents[NumContents] = ((Nibble.getContentNibbleLevel1() + & 0xF) << 4) | (Nibble.getContentNibbleLevel2() & 0xF); + NumContents++; + } + if (DishEventDescriptor && NumContents == 1) + { + DishEventDescriptor->setContent(Nibble); + } + // LogD(2, prep("EEPGDEBUG:Nibble:%x-%x-%x-%x)"), Nibble.getContentNibbleLevel1(),Nibble.getContentNibbleLevel2() + // , Nibble.getUserNibble1(), Nibble.getUserNibble2()); + + } + pEvent->SetContents(Contents); + } + break; +#endif + case SI::ParentalRatingDescriptorTag: + { + int LanguagePreferenceRating = -1; + SI::ParentalRatingDescriptor *prd = + (SI::ParentalRatingDescriptor *) d; + SI::ParentalRatingDescriptor::Rating Rating; + for (SI::Loop::Iterator it3; prd->ratingLoop.getNext(Rating, it3);) + { + if (I18nIsPreferredLanguage(Setup.EPGLanguages, + Rating.languageCode, LanguagePreferenceRating)) + { + int ParentalRating = (Rating.getRating() & 0xFF); + switch (ParentalRating) + { + // values defined by the DVB standard (minimum age = rating + 3 years): + case 0x01 ... 0x0F: + ParentalRating += 3; + break; + // values defined by broadcaster CSAT (now why didn't they just use 0x07, 0x09 and 0x0D?): + case 0x11: + ParentalRating = 10; + break; + case 0x12: + ParentalRating = 12; + break; + case 0x13: + ParentalRating = 16; + break; + default: + ParentalRating = 0; + } + pEvent->SetParentalRating(ParentalRating); + } + } + } + break; + case SI::PDCDescriptorTag: + { + SI::PDCDescriptor * pd = (SI::PDCDescriptor *) d; + 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 = pd->getMonth() - 1; + t.tm_mday = pd->getDay(); + t.tm_hour = pd->getHour(); + t.tm_min = pd->getMinute(); + 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--; + time_t vps = mktime(&t); + pEvent->SetVps(vps); + } + break; + case SI::TimeShiftedEventDescriptorTag: + { + if (Schedules) { + SI::TimeShiftedEventDescriptor * tsed = + (SI::TimeShiftedEventDescriptor *) d; + cSchedule *rSchedule = (cSchedule *) Schedules->GetSchedule( + tChannelID(Source, channel->Nid(), channel->Tid(), + tsed->getReferenceServiceId())); + if (!rSchedule) + break; + rEvent = (cEvent *) rSchedule->GetEvent( + tsed->getReferenceEventId()); + if (!rEvent) + break; + pEvent->SetTitle(rEvent->Title()); + pEvent->SetShortText(rEvent->ShortText()); + pEvent->SetDescription(rEvent->Description()); + } + } + break; + case SI::LinkageDescriptorTag: + { + SI::LinkageDescriptor * ld = (SI::LinkageDescriptor *) d; + tChannelID linkID(Source, ld->getOriginalNetworkId(), + ld->getTransportStreamId(), ld->getServiceId()); + if (ld->getLinkageType() == 0xB0) + { // Premiere World + time_t now = time(NULL); + bool hit = SiEitEvent->getStartTime() <= now + && now + < SiEitEvent->getStartTime() + SiEitEvent->getDuration(); + if (hit) + { + char linkName[ld->privateData.getLength() + 1]; + strn0cpy(linkName, (const char *) ld->privateData.getData(), + sizeof(linkName)); + // TODO is there a standard way to determine the character set of this string? + cChannel *link = Channels.GetByChannelID(linkID); + if (link != channel) + { // only link to other channels, not the same one + //fprintf(stderr, "Linkage %s %4d %4d %5d %5d %5d %5d %02X '%s'\n", hit ? "*" : "", channel->Number(), link ? link->Number() : -1, SiEitEvent.getEventId(), ld->getOriginalNetworkId(), ld->getTransportStreamId(), ld->getServiceId(), ld->getLinkageType(), linkName);//XXX + if (link) + { + if (Setup.UpdateChannels == 1 + || Setup.UpdateChannels >= 3) + link->SetName(linkName, "", ""); + } + else if (Setup.UpdateChannels >= 4) + { + cChannel *transponder = channel; + if (channel->Tid() != ld->getTransportStreamId()) + transponder = Channels.GetByTransponderID(linkID); + link = Channels.NewChannel(transponder, linkName, + "", "", ld->getOriginalNetworkId(), + ld->getTransportStreamId(), ld->getServiceId()); + } + if (link) + { + if (!LinkChannels) + LinkChannels = new cLinkChannels; + LinkChannels->Add(new cLinkChannel(link)); + } + } + else + channel->SetPortalName(linkName); + } + } + } + break; + case SI::ComponentDescriptorTag: + { + SI::ComponentDescriptor * cd = (SI::ComponentDescriptor *) d; + uchar Stream = cd->getStreamContent(); + uchar Type = cd->getComponentType(); + //if (1 <= Stream && Stream <= 3 && Type != 0) { // 1=video, 2=audio, 3=subtitles + if (1 <= Stream && Stream <= 6 && Type != 0) + { // 1=MPEG2-video, 2=MPEG1-audio, 3=subtitles, 4=AC3-audio, 5=H.264-video, 6=HEAAC-audio + if (!Components) + Components = new cComponents; + char buffer[Utf8BufSize (256)]; + Components->SetComponent(Components->NumComponents(), Stream, + Type, I18nNormalizeLanguageCode(cd->languageCode), + cd->description.getText(buffer, sizeof(buffer))); + } + } + break; + case SI::DishExtendedEventDescriptorTag: + { + SI::UnimplementedDescriptor *deed = + (SI::UnimplementedDescriptor *) d; + if (!DishEventDescriptor) + { + DishEventDescriptor = new SI::DishDescriptor(); + } + DishEventDescriptor->setExtendedtData(Tid + 1, deed->getData()); + // HasExternalData = true; + } + break; + case SI::DishShortEventDescriptorTag: + { + SI::UnimplementedDescriptor *dsed = + (SI::UnimplementedDescriptor *) d; + if (!DishEventDescriptor) + { + DishEventDescriptor = new SI::DishDescriptor(); + } + DishEventDescriptor->setShortData(Tid + 1, dsed->getData()); + // HasExternalData = true; + } + break; + case SI::DishRatingDescriptorTag: + { + if (d->getLength() == 4) + { + if (!DishEventDescriptor) + { + DishEventDescriptor = new SI::DishDescriptor(); + } + uint16_t rating = d->getData().TwoBytes(2); + DishEventDescriptor->setRating(rating); + } + } + break; + case SI::DishSeriesDescriptorTag: + { + if (d->getLength() == 10) + { + //LogD(2, prep("DishSeriesDescriptorTag: %s)"), (const char*) d->getData().getData()); + if (!DishEventDescriptor) + { + DishEventDescriptor = new SI::DishDescriptor(); + } + DishEventDescriptor->setEpisodeInfo(d->getData()); + } + // else { + // LogD(2, prep("DishSeriesDescriptorTag length: %d)"), d->getLength()); + // } + } + break; + default: + break; + } + delete d; + } + if (!rEvent) { + if (ShortEventDescriptor) { + char buffer[Utf8BufSize (256)]; + unsigned char *f; + int l = ShortEventDescriptor->name.getLength(); + f = (unsigned char *) ShortEventDescriptor->name.getData().getData(); + decodeText2 (f, l, buffer, sizeof (buffer)); + //ShortEventDescriptor->name.getText(buffer, sizeof(buffer)); + LogD(2, prep("Title: %s Decoded: %s"), f, buffer); + pEvent->SetTitle (buffer); + LogD(3, prep("channelID: %s Title: %s"), *channel->GetChannelID().ToString(), pEvent->Title()); + l = ShortEventDescriptor->text.getLength(); + if (l > 0) { //Set the Short Text only if there is data so that we do not overwrite valid data + f = (unsigned char *) ShortEventDescriptor->text.getData().getData(); + decodeText2 (f, l, buffer, sizeof (buffer)); + //ShortEventDescriptor->text.getText(buffer, sizeof(buffer)); + pEvent->SetShortText (buffer); + } + LogD(3, prep("ShortText: %s"), pEvent->ShortText()); + LogD(2, prep("ShortText: %s Decoded: %s"), f, buffer); + } else if (/*!HasExternalData*/!DishEventDescriptor) { + pEvent->SetTitle (NULL); + pEvent->SetShortText (NULL); + LogD(3, prep("SetTitle (NULL)")); + } + if (ExtendedEventDescriptors) { + char buffer[Utf8BufSize (ExtendedEventDescriptors->getMaximumTextLength (": ")) + 1]; + pEvent->SetDescription (ExtendedEventDescriptors->getText (buffer, sizeof (buffer), ": ")); + LogD(3, prep("Description: %s"), pEvent->Description()); + } else if (!/*HasExternalData*/DishEventDescriptor) + pEvent->SetDescription (NULL); + + if (DishEventDescriptor) { + if (DishEventDescriptor->getName()) + pEvent->SetTitle(DishEventDescriptor->getName()); + //LogD(2, prep("channelID: %s DishTitle: %s"), *channel->GetChannelID().ToString(), DishEventDescriptor->getName()); + pEvent->SetShortText(DishEventDescriptor->getShortText()); + char *tmp; + string fmt; + + const char * description = DishEventDescriptor->getDescription(); + //BEV sets the description previously with ExtendedEventDescriptor + if (0 == strcmp(DishEventDescriptor->getDescription(),"") && pEvent->Description()) + description = pEvent->Description(); + + + fmt = "%s"; + if (DishEventDescriptor->hasTheme()) { + fmt += "\nTheme: "; + } + fmt += "%s"; + if (DishEventDescriptor->hasCategory()) { + fmt += "\nCategory: "; + } + fmt += "%s"; + + if ((0 != strcmp(DishEventDescriptor->getRating(),"") + || 0 != strcmp(DishEventDescriptor->getStarRating(),""))) { + fmt += "\n\nRating: "; + } + fmt += "%s %s"; + if (0 != strcmp(DishEventDescriptor->getProgramId(),"")) { + fmt += "\n\nProgram ID: "; + } + fmt += "%s %s%s"; + time_t orgAirDate = DishEventDescriptor->getOriginalAirDate(); + char datestr [80]; + bool dateok = false; + if (orgAirDate == 0) { + dateok = strftime (datestr,80," Original Air Date: %a %b %d %Y",gmtime(&orgAirDate)) > 0; + } + + Asprintf (&tmp, fmt.c_str(), description + , DishEventDescriptor->getTheme(), DishEventDescriptor->getCategory() + , DishEventDescriptor->getRating(), DishEventDescriptor->getStarRating() + , DishEventDescriptor->getProgramId(), DishEventDescriptor->getSeriesId() + , orgAirDate == 0 || !dateok ? "" : datestr); + pEvent->SetDescription(tmp); + free(tmp); + + + //LogD(2, prep("DishDescription: %s"), DishEventDescriptor->getDescription()); + //LogD(2, prep("DishShortText: %s"), DishEventDescriptor->getShortText()); + } + + } + delete ExtendedEventDescriptors; + delete ShortEventDescriptor; + delete DishEventDescriptor; + + pEvent->SetComponents (Components); + +// LogD(2, prep("channelID: %s Title: %s"), *channel->GetChannelID().ToString(), pEvent->Title()); + +// if (pEvent->ChannelID() == tChannelID::FromString("S119.0W-4100-6-110-110")) { +// LogD(2, prep("ID: %d Title: %s Time: %d Tid: 0x%x"), pEvent->EventID(), pEvent->Title(), pEvent->StartTime(), pEvent->TableID()); +// } + +// if (!HasExternalData) + pEvent->FixEpgBugs (); + if (LinkChannels) + channel->SetLinkChannels (LinkChannels); + } + +cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool isEITPid, bool OnlyRunningStatus) +: SI::EIT (Data, false) +, OnlyRunningStatus(OnlyRunningStatus) +, Schedules(Schedules) +{ + //LogD(2, prep("cEIT2::cEIT2")); + if (Tid > 0 && (Format == DISH_BEV || (SetupPE->ProcessEIT && isEITPid))) Tid--; + + if (!CheckCRCAndParse ()) { + LogD(2, prep("!CheckCRCAndParse ()")); + return; + } + + bool searchOtherSatPositions = Format == DISH_BEV; + + tChannelID channelID (Source, getOriginalNetworkId (), getTransportStreamId (), getServiceId ()); + channel = GetChannelByID (channelID, searchOtherSatPositions); + if (!channel) { + LogD(3, prep("!channel channelID: %s"), *channelID.ToString()); + return; // only collect data for known channels + } + + //LogD(5, prep("channelID: %s format:%d"), *channel->GetChannelID().ToString(), Format); + + cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (channel, true); + + Empty = true; + Modified = false; +// bool HasExternalData = false; + SegmentStart = 0; + SegmentEnd = 0; + + SI::EIT::Event SiEitEvent; + for (SI::Loop::Iterator it; eventLoop.getNext (SiEitEvent, it);) { + int versionNumber = getVersionNumber(); +// bool ExternalData = false; +// // Drop bogus events - but keep NVOD reference events, where all bits of the start time field are set to 1, resulting in a negative number. +// if (SiEitEvent.getStartTime () == 0 || (SiEitEvent.getStartTime () > 0 && SiEitEvent.getDuration () == 0)) +// continue; +// Empty = false; +// if (!SegmentStart) +// SegmentStart = SiEitEvent.getStartTime (); +// SegmentEnd = SiEitEvent.getStartTime () + SiEitEvent.getDuration (); +// int versionNumber = getVersionNumber(); +// +// cEvent *newEvent = NULL; +// cEvent *pEvent = (cEvent *) pSchedule->GetEvent (SiEitEvent.getEventId (), SiEitEvent.getStartTime ()); +// if (!pEvent) { +// if (OnlyRunningStatus) +// continue; +// // If we don't have that event yet, we create a new one. +// // Otherwise we copy the information into the existing event anyway, because the data might have changed. +// pEvent = newEvent = new cEvent (SiEitEvent.getEventId ()); +// if (!pEvent) +// continue; +// } else { +// //LogD(3, prep("existing event channelID: %s Title: %s TableID 0x%02X new TID 0x%02X Version %i, new version %i"), *channel->GetChannelID().ToString(), pEvent->Title(), pEvent->TableID(), Tid, pEvent->Version(), versionNumber); +// // We have found an existing event, either through its event ID or its start time. +// pEvent->SetSeen (); +// +// // If the existing event has a zero table ID it was defined externally and shall +// // not be overwritten. +// if (pEvent->TableID () == 0x00) { +// if (pEvent->Version () == versionNumber) +// continue; +// /*HasExternalData = */ExternalData = true; +// } +// // If the new event has a higher table ID, let's skip it. +// // The lower the table ID, the more "current" the information. +// else if (Tid > pEvent->TableID()) +// continue; +// // If the new event comes from the same table and has the same version number +// // as the existing one, let's skip it to avoid unnecessary work. +// // Unfortunately some stations (like, e.g. "Premiere") broadcast their EPG data on several transponders (like +// // the actual Premiere transponder and the Sat.1/Pro7 transponder), but use different version numbers on +// // each of them :-( So if one DVB card is tuned to the Premiere transponder, while an other one is tuned +// // to the Sat.1/Pro7 transponder, events will keep toggling because of the bogus version numbers. +// else if (Tid == pEvent->TableID() && pEvent->Version() == versionNumber) +// continue; +// } +// if (!ExternalData) { +// pEvent->SetEventID (SiEitEvent.getEventId ()); // unfortunately some stations use different event ids for the same event in different tables :-( +// pEvent->SetTableID (Tid); +// pEvent->SetStartTime (SiEitEvent.getStartTime ()); +// pEvent->SetDuration (SiEitEvent.getDuration ()); +// } +// if (newEvent) +// pSchedule->AddEvent (newEvent); +// if (Tid == 0x4E) { // we trust only the present/following info on the actual TS +// if (SiEitEvent.getRunningStatus () >= SI::RunningStatusNotRunning) +// pSchedule->SetRunningStatus (pEvent, SiEitEvent.getRunningStatus (), channel); +// } +// if (OnlyRunningStatus) +// continue; // do this before setting the version, so that the full update can be done later +// pEvent->SetVersion (versionNumber); +// +// ProcessEventDescriptors(ExternalData, Source, Tid, SiEitEvent, +// pEvent, Schedules, channel); +// +// Modified = true; + cEvent *pEvent = ProcessEitEvent(pSchedule, &SiEitEvent, + Tid, versionNumber); + if (pEvent) + EquivHandler->updateEquivalent(Schedules, channel->GetChannelID(), pEvent); + } + + //// + + if (Empty && Tid == 0x4E && getSectionNumber () == 0) + // ETR 211: an empty entry in section 0 of table 0x4E means there is currently no event running + pSchedule->ClrRunningStatus (channel); + if (Tid == 0x4E) + pSchedule->SetPresentSeen (); + if (OnlyRunningStatus) { + LogD(4, prep("OnlyRunningStatus")); + return; + } + if (Modified) { +// if (!HasExternalData) + pSchedule->DropOutdated (SegmentStart, SegmentEnd, Tid, getVersionNumber ()); + sortSchedules(Schedules, channel->GetChannelID()); + } + LogD(4, prep("end of cEIT2")); + + } + //end of cEIT2 + +cEIT2::cEIT2 (cSchedule * Schedule) +: OnlyRunningStatus(false) +, Empty(true) +, Modified(false) +, SegmentStart(0) +, SegmentEnd(0) +, Schedules(NULL) +{ + //LogD(2, prep("cEIT2::cEIT2")); +// if (Tid > 0 && (Format == DISH_BEV || (SetupPE->ProcessEIT && isEITPid))) Tid--; + + bool searchOtherSatPositions = Format == DISH_BEV; + + tChannelID channelID (Schedule->channelID.Source(), getOriginalNetworkId (), getTransportStreamId (), getServiceId ()); + channel = GetChannelByID (channelID, searchOtherSatPositions); + if (!channel) { + LogD(3, prep("!channel channelID: %s"), *channelID.ToString()); + return; // only collect data for known channels + } +} +} //end namespace SI + diff --git a/eit2.h b/eit2.h new file mode 100644 index 0000000..5d2e4bb --- /dev/null +++ b/eit2.h @@ -0,0 +1,49 @@ +#ifndef CEIT2_H_ +#define CEIT2_H_ +#include +#include +#include + +namespace SI +{ + enum DescriptorTagExt { + DishRatingDescriptorTag = 0x89, + DishShortEventDescriptorTag = 0x91, + DishExtendedEventDescriptorTag = 0x92, + DishSeriesDescriptorTag = 0x96, + }; + +// typedef InheritEnum< DescriptorTagExt, SI::DescriptorTag > ExtendedDescriptorTag; + +/*extern const char *getCharacterTable(const unsigned char *&buffer, int &length, bool *isSingleByte = NULL); +extern bool convertCharacterTable(const char *from, size_t fromLength, char *to, size_t toLength, const char *fromCode); +extern bool SystemCharacterTableIsSingleByte;*/ +class cEIT2:public SI::EIT +{ +public: + cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool isEITPid = false, bool OnlyRunningStatus = false); + cEIT2 (cSchedule * Schedule); +//protected: +// void updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent); + cEvent* ProcessEitEvent(cSchedule *Schedule, const SI::EIT::Event *EitEvent, uchar TableID, uchar Version); + +private: + void + ProcessEventDescriptors(bool ExternalData, + int Source, u_char Tid, const SI::EIT::Event* SiEitEvent, cEvent* pEvent, + cSchedules* Schedules, cChannel* channel); + +private: + bool Empty; + bool Modified; +// bool HasExternalData = false; + time_t SegmentStart; + time_t SegmentEnd; + cSchedules* Schedules; + cChannel* channel; + + bool OnlyRunningStatus; + }; +} //end namespace SI + +#endif /* CEIT2_H_ */ diff --git a/epghandler.c b/epghandler.c index f8a6636..3aaec2e 100644 --- a/epghandler.c +++ b/epghandler.c @@ -9,7 +9,9 @@ #if APIVERSNUM > 10725 #include "log.h" #include "equivhandler.h" +#include "eit2.h" #include +#include cEEpgHandler::cEEpgHandler() { LogD(4, prep("cEEpgHandler()")); @@ -27,8 +29,11 @@ bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, //DISH NID 0x1001 to 0x100B BEV 0x100 and 0x101 //TODO move the eit handling code at least for NA providers here instead of discarding. int nid = Schedule->ChannelID().Nid(); - if ((nid >= 0x1001 && nid <= 0x100B) || nid == 0x101 || nid == 0x100) + if ((nid >= 0x1001 && nid <= 0x100B) || nid == 0x101 || nid == 0x100) { + SI::cEIT2 eit2(Schedule); + eit2.ProcessEitEvent(Schedule, EitEvent, TableID, Version); return true; + } //TODO Should it be added in setup? if (EitEvent->getDurationHour() > _LONG_EVENT_HOURS) { diff --git a/epghandler.h b/epghandler.h index 3219f58..4e60e57 100644 --- a/epghandler.h +++ b/epghandler.h @@ -34,6 +34,8 @@ public: virtual bool SortSchedule(cSchedule *Schedule); virtual bool DropOutdated(cSchedule *Schedule, time_t SegmentStart, time_t SegmentEnd, uchar TableID, uchar Version); +// bool ParseEitEvent(cSchedule *Schedule, const SI::EIT::Event *EitEvent, uchar TableID, uchar Version); + private: std::string origShortText; std::string origDescription; diff --git a/util.h b/util.h index 230f44c..f15bce6 100644 --- a/util.h +++ b/util.h @@ -28,5 +28,8 @@ time_t LocalTime2UTC (time_t t); time_t UTC2LocalTime (time_t t); void GetLocalTimeOffset (void); void CleanString (unsigned char *String); + +#define Asprintf(a, b, c...) void( asprintf(a, b, c) < 0 ? esyslog("memory allocation error - %s", b) : void() ) + } #endif /* UTIL_H_ */ -- cgit v1.2.3 From cee549473dacfa3e82cb13bd9bbe1c8f0e8c1a6a Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 16 Oct 2012 21:01:06 +0200 Subject: fix some includes --- eepg.c | 1 + eit2.c | 5 +-- eit2.h | 8 ++--- util.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ util.h | 26 +++++++++++++++ 5 files changed, 151 insertions(+), 6 deletions(-) diff --git a/eepg.c b/eepg.c index 1174681..c438969 100644 --- a/eepg.c +++ b/eepg.c @@ -45,6 +45,7 @@ #include "setupeepg.h" #include "equivhandler.h" #include "util.h" +#include "eit2.h" #include #include diff --git a/eit2.c b/eit2.c index 5bd7cc4..6c88594 100644 --- a/eit2.c +++ b/eit2.c @@ -10,6 +10,7 @@ #include #include "log.h" #include "util.h" +#include "dish.h" using namespace std; using namespace util; @@ -110,8 +111,8 @@ namespace SI cComponents *Components = NULL; - - for (SI::Loop::Iterator it2; (d = SiEitEvent->eventDescriptors.getNext(it2)); ) + DescriptorLoop dl = SiEitEvent->eventDescriptors; + for (SI::Loop::Iterator it2; (d = dl.getNext(it2)); ) { if (ExternalData && d->getDescriptorTag() != SI::ComponentDescriptorTag) { diff --git a/eit2.h b/eit2.h index 5d2e4bb..e052b2d 100644 --- a/eit2.h +++ b/eit2.h @@ -3,6 +3,7 @@ #include #include #include +#include namespace SI { @@ -28,10 +29,9 @@ public: cEvent* ProcessEitEvent(cSchedule *Schedule, const SI::EIT::Event *EitEvent, uchar TableID, uchar Version); private: - void - ProcessEventDescriptors(bool ExternalData, - int Source, u_char Tid, const SI::EIT::Event* SiEitEvent, cEvent* pEvent, - cSchedules* Schedules, cChannel* channel); + void ProcessEventDescriptors(bool ExternalData, + int Source, u_char Tid, const SI::EIT::Event* SiEitEvent, cEvent* pEvent, + cSchedules* Schedules, cChannel* channel); private: bool Empty; diff --git a/util.c b/util.c index 3d92dda..c1cc69d 100644 --- a/util.c +++ b/util.c @@ -204,6 +204,123 @@ void AddEvent(cEvent *Event, tChannelID ChannelID) AddEventThread.Start(); } +/** \brief Decode an EPG string as necessary + * + * \param src - Possibly encoded string + * \param size - Size of the buffer + * + * \retval NULL - Can't decode + * \return A decoded string + */ +char *freesat_huffman_decode (const unsigned char *src, size_t size) +{ + int tableid; +// freesat_decode_error = 0; + + if (src[0] == 0x1f && (src[1] == 1 || src[1] == 2)) { + int uncompressed_len = 30; + char *uncompressed = (char *) calloc (1, uncompressed_len + 1); + unsigned value = 0, byte = 2, bit = 0; + int p = 0; + unsigned char lastch = START; + + tableid = src[1] - 1; + while (byte < 6 && byte < size) { + value |= src[byte] << ((5 - byte) * 8); + byte++; + } + //freesat_table_load (); /**< Load the tables as necessary */ + + do { + bool found = false; + unsigned bitShift = 0; + if (lastch == ESCAPE) { + char nextCh = (value >> 24) & 0xff; + found = true; + // Encoded in the next 8 bits. + // Terminated by the first ASCII character. + bitShift = 8; + if ((nextCh & 0x80) == 0) + lastch = nextCh; + if (p >= uncompressed_len) { + uncompressed_len += 10; + uncompressed = (char *) REALLOC (uncompressed, uncompressed_len + 1); + } + uncompressed[p++] = nextCh; + uncompressed[p] = 0; + } else { + int j; + for (j = 0; j < table_size[tableid][lastch]; j++) { + unsigned mask = 0, maskbit = 0x80000000; + short kk; + for (kk = 0; kk < tables[tableid][lastch][j].bits; kk++) { + mask |= maskbit; + maskbit >>= 1; + } + if ((value & mask) == tables[tableid][lastch][j].value) { + char nextCh = tables[tableid][lastch][j].next; + bitShift = tables[tableid][lastch][j].bits; + if (nextCh != STOP && nextCh != ESCAPE) { + if (p >= uncompressed_len) { + uncompressed_len += 10; + uncompressed = (char *) REALLOC (uncompressed, uncompressed_len + 1); + } + uncompressed[p++] = nextCh; + uncompressed[p] = 0; + } + found = true; + lastch = nextCh; + break; + } + } + } + if (found) { + // Shift up by the number of bits. + unsigned b; + for (b = 0; b < bitShift; b++) { + value = (value << 1) & 0xfffffffe; + if (byte < size) + value |= (src[byte] >> (7 - bit)) & 1; + if (bit == 7) { + bit = 0; + byte++; + } else + bit++; + } + } else { + LogE (0, prep("Missing table %d entry: <%s>"), tableid + 1, uncompressed); + // Entry missing in table. + return uncompressed; + } + } while (lastch != STOP && value != 0); + + return uncompressed; + } + return NULL; +} + +void decodeText2 (const unsigned char *from, int len, char *buffer, int buffsize) +{ + if (from[0] == 0x1f) { + char *temp = freesat_huffman_decode (from, len); + if (temp) { + len = strlen (temp); + len = len < buffsize - 1 ? len : buffsize - 1; + strncpy (buffer, temp, len); + buffer[len] = 0; + free (temp); + return; + } + } + + SI::String convStr; + SI::CharArray charArray; + charArray.assign(from, len); + convStr.setData(charArray, len); + //LogE(5, prep("decodeText2 from %s - length %d"), from, len); + convStr.getText(buffer, buffsize); + //LogE(5, prep("decodeText2 buffer %s - buffsize %d"), buffer, buffsize); +} } diff --git a/util.h b/util.h index f15bce6..88e6c62 100644 --- a/util.h +++ b/util.h @@ -28,6 +28,32 @@ time_t LocalTime2UTC (time_t t); time_t UTC2LocalTime (time_t t); void GetLocalTimeOffset (void); void CleanString (unsigned char *String); +void decodeText2 (const unsigned char *from, int len, char *buffer, int buffsize); +char *freesat_huffman_decode (const unsigned char *src, size_t size); + +struct sNode +{ + char *Value; + struct sNode *P0; + struct sNode *P1; +}; + +typedef struct sNode sNodeH; + +struct hufftab { + unsigned int value; + short bits; + char next; +}; + +#define START '\0' +#define STOP '\0' +#define ESCAPE '\1' + +static struct hufftab *tables[2][128]; +static int table_size[2][128]; +static sNodeH* sky_tables[2]; + #define Asprintf(a, b, c...) void( asprintf(a, b, c) < 0 ? esyslog("memory allocation error - %s", b) : void() ) -- cgit v1.2.3 From 6810f79e1b5f78a0b3d2389714924738295a6497 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Thu, 18 Oct 2012 14:32:04 +0200 Subject: fix compile --- eepg.c | 95 ++---- eepg.h | 15 - eit2.c | 1110 ++++++++++++++++++++++++++++++++-------------------------------- eit2.h | 43 +-- log.h | 3 +- util.c | 23 ++ util.h | 80 +++-- 7 files changed, 693 insertions(+), 676 deletions(-) diff --git a/eepg.c b/eepg.c index c438969..6091915 100644 --- a/eepg.c +++ b/eepg.c @@ -65,14 +65,6 @@ static const char *VERSION = "0.0.6pre"; static const char *DESCRIPTION = trNOOP ("Parses Extended EPG data"); -template T REALLOC(T Var, size_t Size) -{ - T p = (T)realloc(Var, Size); - if (!p) - free(Var); - return p; -} - using namespace std; using namespace util; @@ -101,7 +93,6 @@ char *cs_hexdump (int m, const uchar * buf, int n) } cSetupEEPG* SetupPE = cSetupEEPG::getInstance(); -cEquivHandler* EquivHandler; // --- cMenuSetupPremiereEpg ------------------------------------------------------------ @@ -313,21 +304,21 @@ void syslog_with_tid (int priority, const char *format, ...) __attribute__ ((for -struct hufftab { - unsigned int value; - short bits; - char next; -}; - -#define START '\0' -#define STOP '\0' -#define ESCAPE '\1' +//struct hufftab { +// unsigned int value; +// short bits; +// char next; +//}; +// +//#define START '\0' +//#define STOP '\0' +//#define ESCAPE '\1' -int freesat_decode_error = 0; /* If set an error has occurred during decoding */ +//int freesat_decode_error = 0; /* If set an error has occurred during decoding */ -static struct hufftab *tables[2][128]; -static int table_size[2][128]; +//static struct hufftab *tables[2][128]; +//static int table_size[2][128]; static sNodeH* sky_tables[2]; /** \brief Convert a textual character description into a value @@ -569,7 +560,7 @@ static bool load_sky_file (const char *filename) char *freesat_huffman_decode (const unsigned char *src, size_t size) { int tableid; - freesat_decode_error = 0; +// freesat_decode_error = 0; if (src[0] == 0x1f && (src[1] == 1 || src[1] == 2)) { int uncompressed_len = 30; @@ -839,44 +830,28 @@ bool cFilterEEPG::InitDictionary (void) return true; } -void decodeText2 (const unsigned char *from, int len, char *buffer, int buffsize) -{ - if (from[0] == 0x1f) { - char *temp = freesat_huffman_decode (from, len); - if (temp) { - len = strlen (temp); - len = len < buffsize - 1 ? len : buffsize - 1; - strncpy (buffer, temp, len); - buffer[len] = 0; - free (temp); - return; - } - } - - SI::String convStr; - SI::CharArray charArray; - charArray.assign(from, len); - convStr.setData(charArray, len); - //LogE(5, prep("decodeText2 from %s - length %d"), from, len); - convStr.getText(buffer, buffsize); - //LogE(5, prep("decodeText2 buffer %s - buffsize %d"), buffer, buffsize); -} - -void sortSchedules(cSchedules * Schedules, tChannelID channelID){ - - LogD(3, prep("Start sortEquivalent %s"), *channelID.ToString()); - - cChannel *pChannel = GetChannelByID (channelID, false); - cSchedule *pSchedule; - if (pChannel) { - pSchedule = (cSchedule *) (Schedules->GetSchedule(pChannel, true)); - pSchedule->Sort(); - Schedules->SetModified(pSchedule); - } - if (EquivHandler->getEquiChanMap().count(*channelID.ToString()) > 0) - EquivHandler->sortEquivalents(channelID, Schedules); -} - +//void decodeText2 (const unsigned char *from, int len, char *buffer, int buffsize) +//{ +// if (from[0] == 0x1f) { +// char *temp = freesat_huffman_decode (from, len); +// if (temp) { +// len = strlen (temp); +// len = len < buffsize - 1 ? len : buffsize - 1; +// strncpy (buffer, temp, len); +// buffer[len] = 0; +// free (temp); +// return; +// } +// } +// +// SI::String convStr; +// SI::CharArray charArray; +// charArray.assign(from, len); +// convStr.setData(charArray, len); +// //LogE(5, prep("decodeText2 from %s - length %d"), from, len); +// convStr.getText(buffer, buffsize); +// //LogE(5, prep("decodeText2 buffer %s - buffsize %d"), buffer, buffsize); +//} /** * \brief Get MHW channels diff --git a/eepg.h b/eepg.h index 18690de..7e1cc74 100644 --- a/eepg.h +++ b/eepg.h @@ -17,21 +17,6 @@ //#define NAGRA 6 //#define HIGHEST_FORMAT 6 -enum EFormat { -//First all batchmode, load ONCE protocols: - MHW1 = 0, - MHW2 , - SKY_IT , - SKY_UK , - NAGRA , -//Than all CONTinuous protocols, so they will be processed LAST: - PREMIERE , - FREEVIEW , - DISH_BEV , - EIT , -//the highest number of EPG-formats that is supported by this plugin - HIGHEST_FORMAT = EIT -} Format; #define NAGRA_TABLE_ID 0x55 //the lower the table Id, the more "current" it is; table_id 0x00 never gets overwritten, now/next are at 0x4e or 0x4f! #define DEFAULT_TABLE_ID 0x30 diff --git a/eit2.c b/eit2.c index 6c88594..12a7a95 100644 --- a/eit2.c +++ b/eit2.c @@ -11,6 +11,7 @@ #include "log.h" #include "util.h" #include "dish.h" +#include "equivhandler.h" using namespace std; using namespace util; @@ -18,624 +19,625 @@ using namespace util; namespace SI { - cEvent* cEIT2::ProcessEitEvent(cSchedule* pSchedule,const SI::EIT::Event* EitEvent, - uchar Tid, uchar versionNumber) - { - bool ExternalData = false; - // Drop bogus events - but keep NVOD reference events, where all bits of the start time field are set to 1, resulting in a negative number. - if (EitEvent->getStartTime () == 0 || (EitEvent->getStartTime () > 0 && EitEvent->getDuration () == 0)) +cEvent* cEIT2::ProcessEitEvent(cSchedule* pSchedule,const SI::EIT::Event* EitEvent, + uchar Tid, uchar versionNumber) +{ + bool ExternalData = false; + // Drop bogus events - but keep NVOD reference events, where all bits of the start time field are set to 1, resulting in a negative number. + if (EitEvent->getStartTime () == 0 || (EitEvent->getStartTime () > 0 && EitEvent->getDuration () == 0)) + return NULL; + Empty = false; + if (!SegmentStart) + SegmentStart = EitEvent->getStartTime (); + SegmentEnd = EitEvent->getStartTime () + EitEvent->getDuration (); + // int versionNumber = getVersionNumber(); + + cEvent *newEvent = NULL; + cEvent *pEvent = (cEvent *) pSchedule->GetEvent (EitEvent->getEventId (), EitEvent->getStartTime ()); + if (!pEvent) { + if (OnlyRunningStatus) return NULL; - Empty = false; - if (!SegmentStart) - SegmentStart = EitEvent->getStartTime (); - SegmentEnd = EitEvent->getStartTime () + EitEvent->getDuration (); -// int versionNumber = getVersionNumber(); - - cEvent *newEvent = NULL; - cEvent *pEvent = (cEvent *) pSchedule->GetEvent (EitEvent->getEventId (), EitEvent->getStartTime ()); - if (!pEvent) { - if (OnlyRunningStatus) - return NULL; - // If we don't have that event yet, we create a new one. - // Otherwise we copy the information into the existing event anyway, because the data might have changed. - pEvent = newEvent = new cEvent (EitEvent->getEventId ()); - if (!pEvent) - return NULL; - } else { - //LogD(3, prep("existing event channelID: %s Title: %s TableID 0x%02X new TID 0x%02X Version %i, new version %i"), *channel->GetChannelID().ToString(), pEvent->Title(), pEvent->TableID(), Tid, pEvent->Version(), versionNumber); - // We have found an existing event, either through its event ID or its start time. - pEvent->SetSeen (); - - // If the existing event has a zero table ID it was defined externally and shall - // not be overwritten. - if (pEvent->TableID () == 0x00) { - if (pEvent->Version () == versionNumber) - return NULL; - /*HasExternalData = */ExternalData = true; - } - // If the new event has a higher table ID, let's skip it. - // The lower the table ID, the more "current" the information. - else if (Tid > pEvent->TableID()) - return NULL; - // If the new event comes from the same table and has the same version number - // as the existing one, let's skip it to avoid unnecessary work. - // Unfortunately some stations (like, e.g. "Premiere") broadcast their EPG data on several transponders (like - // the actual Premiere transponder and the Sat.1/Pro7 transponder), but use different version numbers on - // each of them :-( So if one DVB card is tuned to the Premiere transponder, while an other one is tuned - // to the Sat.1/Pro7 transponder, events will keep toggling because of the bogus version numbers. - else if (Tid == pEvent->TableID() && pEvent->Version() == versionNumber) + // If we don't have that event yet, we create a new one. + // Otherwise we copy the information into the existing event anyway, because the data might have changed. + pEvent = newEvent = new cEvent (EitEvent->getEventId ()); + if (!pEvent) + return NULL; + } else { + //LogD(3, prep("existing event channelID: %s Title: %s TableID 0x%02X new TID 0x%02X Version %i, new version %i"), *channel->GetChannelID().ToString(), pEvent->Title(), pEvent->TableID(), Tid, pEvent->Version(), versionNumber); + // We have found an existing event, either through its event ID or its start time. + pEvent->SetSeen (); + + // If the existing event has a zero table ID it was defined externally and shall + // not be overwritten. + if (pEvent->TableID () == 0x00) { + if (pEvent->Version () == versionNumber) return NULL; + /*HasExternalData = */ExternalData = true; } - if (!ExternalData) { - pEvent->SetEventID (EitEvent->getEventId ()); // unfortunately some stations use different event ids for the same event in different tables :-( - pEvent->SetTableID (Tid); - pEvent->SetStartTime (EitEvent->getStartTime ()); - pEvent->SetDuration (EitEvent->getDuration ()); - } - if (newEvent) - pSchedule->AddEvent (newEvent); - if (Tid == 0x4E) { // we trust only the present/following info on the actual TS - if (EitEvent->getRunningStatus () >= SI::RunningStatusNotRunning) - pSchedule->SetRunningStatus (pEvent, EitEvent->getRunningStatus (), channel); - } - if (OnlyRunningStatus) - return NULL; // do this before setting the version, so that the full update can be done later - pEvent->SetVersion (versionNumber); + // If the new event has a higher table ID, let's skip it. + // The lower the table ID, the more "current" the information. + else if (Tid > pEvent->TableID()) + return NULL; + // If the new event comes from the same table and has the same version number + // as the existing one, let's skip it to avoid unnecessary work. + // Unfortunately some stations (like, e.g. "Premiere") broadcast their EPG data on several transponders (like + // the actual Premiere transponder and the Sat.1/Pro7 transponder), but use different version numbers on + // each of them :-( So if one DVB card is tuned to the Premiere transponder, while an other one is tuned + // to the Sat.1/Pro7 transponder, events will keep toggling because of the bogus version numbers. + else if (Tid == pEvent->TableID() && pEvent->Version() == versionNumber) + return NULL; + } + if (!ExternalData) { + pEvent->SetEventID (EitEvent->getEventId ()); // unfortunately some stations use different event ids for the same event in different tables :-( + pEvent->SetTableID (Tid); + pEvent->SetStartTime (EitEvent->getStartTime ()); + pEvent->SetDuration (EitEvent->getDuration ()); + } + if (newEvent) + pSchedule->AddEvent (newEvent); + if (Tid == 0x4E) { // we trust only the present/following info on the actual TS + if (EitEvent->getRunningStatus () >= SI::RunningStatusNotRunning) + pSchedule->SetRunningStatus (pEvent, EitEvent->getRunningStatus (), channel); + } + if (OnlyRunningStatus) + return NULL; // do this before setting the version, so that the full update can be done later + pEvent->SetVersion (versionNumber); - ProcessEventDescriptors(ExternalData, channel->Source(), Tid, EitEvent, - pEvent, Schedules, channel); + ProcessEventDescriptors(ExternalData, channel->Source(), Tid, EitEvent, + pEvent, Schedules, channel); - Modified = true; - return pEvent; - } + Modified = true; + return pEvent; +} - void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, - u_char Tid, const SI::EIT::Event* SiEitEvent, cEvent* pEvent, - cSchedules* Schedules, cChannel* channel) - { +void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, + u_char Tid, const SI::EIT::Event* SiEitEvent, cEvent* pEvent, + cSchedules* Schedules, cChannel* channel) +{ - cEvent *rEvent = NULL; - int LanguagePreferenceShort = -1; - int LanguagePreferenceExt = -1; - unsigned char nDescriptorTag; - bool UseExtendedEventDescriptor = false; - SI::Descriptor * d; - SI::ExtendedEventDescriptors * ExtendedEventDescriptors = NULL; - SI::ShortEventDescriptor * ShortEventDescriptor = NULL; - //SI::DishDescriptor *DishExtendedEventDescriptor = NULL; - SI::DishDescriptor *DishEventDescriptor = NULL; - //uchar DishTheme = 0, DishCategory = 0; + cEvent *rEvent = NULL; + int LanguagePreferenceShort = -1; + int LanguagePreferenceExt = -1; + unsigned char nDescriptorTag; + bool UseExtendedEventDescriptor = false; + SI::Descriptor * d; + SI::ExtendedEventDescriptors * ExtendedEventDescriptors = NULL; + SI::ShortEventDescriptor * ShortEventDescriptor = NULL; + //SI::DishDescriptor *DishExtendedEventDescriptor = NULL; + SI::DishDescriptor *DishEventDescriptor = NULL; + //uchar DishTheme = 0, DishCategory = 0; - cLinkChannels *LinkChannels = NULL; - cComponents *Components = NULL; + cLinkChannels *LinkChannels = NULL; + cComponents *Components = NULL; - DescriptorLoop dl = SiEitEvent->eventDescriptors; - for (SI::Loop::Iterator it2; (d = dl.getNext(it2)); ) + DescriptorLoop dl = SiEitEvent->eventDescriptors; + for (SI::Loop::Iterator it2; (d = dl.getNext(it2)); ) + { + if (ExternalData && d->getDescriptorTag() != SI::ComponentDescriptorTag) { - if (ExternalData && d->getDescriptorTag() != SI::ComponentDescriptorTag) + delete d; + LogD(2, prep("continue:d->getDescriptorTAG():%x)"), d->getDescriptorTag ()); + continue; + } + + //LogD(2, prep("EEPGDEBUG:d->getDescriptorTAG():%x)"), d->getDescriptorTag ()); + nDescriptorTag = d->getDescriptorTag(); + switch (nDescriptorTag) + { + case SI::ExtendedEventDescriptorTag: + { + SI::ExtendedEventDescriptor * eed = + (SI::ExtendedEventDescriptor *) d; + if (I18nIsPreferredLanguage(Setup.EPGLanguages, eed->languageCode, + LanguagePreferenceExt) || !ExtendedEventDescriptors) { - delete d; - LogD(2, prep("continue:d->getDescriptorTAG():%x)"), d->getDescriptorTag ()); - continue; + delete ExtendedEventDescriptors; + ExtendedEventDescriptors = new SI::ExtendedEventDescriptors; + UseExtendedEventDescriptor = true; } - - //LogD(2, prep("EEPGDEBUG:d->getDescriptorTAG():%x)"), d->getDescriptorTag ()); - nDescriptorTag = d->getDescriptorTag(); - switch (nDescriptorTag) - { - case SI::ExtendedEventDescriptorTag: - { - SI::ExtendedEventDescriptor * eed = - (SI::ExtendedEventDescriptor *) d; - if (I18nIsPreferredLanguage(Setup.EPGLanguages, eed->languageCode, - LanguagePreferenceExt) || !ExtendedEventDescriptors) - { - delete ExtendedEventDescriptors; - ExtendedEventDescriptors = new SI::ExtendedEventDescriptors; - UseExtendedEventDescriptor = true; - } - if (UseExtendedEventDescriptor) - { - ExtendedEventDescriptors->Add(eed); - d = NULL; // so that it is not deleted - } - if (eed->getDescriptorNumber() == eed->getLastDescriptorNumber()) - UseExtendedEventDescriptor = false; - } - break; - case SI::ShortEventDescriptorTag: - { - SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d; - if (I18nIsPreferredLanguage(Setup.EPGLanguages, sed->languageCode, - LanguagePreferenceShort) || !ShortEventDescriptor) - { - delete ShortEventDescriptor; - ShortEventDescriptor = sed; - d = NULL; // so that it is not deleted - } - } - break; + if (UseExtendedEventDescriptor) + { + ExtendedEventDescriptors->Add(eed); + d = NULL; // so that it is not deleted + } + if (eed->getDescriptorNumber() == eed->getLastDescriptorNumber()) + UseExtendedEventDescriptor = false; + } + break; + case SI::ShortEventDescriptorTag: + { + SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d; + if (I18nIsPreferredLanguage(Setup.EPGLanguages, sed->languageCode, + LanguagePreferenceShort) || !ShortEventDescriptor) + { + delete ShortEventDescriptor; + ShortEventDescriptor = sed; + d = NULL; // so that it is not deleted + } + } + break; #if APIVERSNUM > 10711 - case SI::ContentDescriptorTag: - { - SI::ContentDescriptor *cd = (SI::ContentDescriptor *) d; - SI::ContentDescriptor::Nibble Nibble; - int NumContents = 0; - uchar Contents[MaxEventContents] = - { 0 }; - for (SI::Loop::Iterator it3; cd->nibbleLoop.getNext(Nibble, it3);) - { - if (NumContents < MaxEventContents) - { - Contents[NumContents] = ((Nibble.getContentNibbleLevel1() - & 0xF) << 4) | (Nibble.getContentNibbleLevel2() & 0xF); - NumContents++; - } - if (DishEventDescriptor && NumContents == 1) - { - DishEventDescriptor->setContent(Nibble); - } - // LogD(2, prep("EEPGDEBUG:Nibble:%x-%x-%x-%x)"), Nibble.getContentNibbleLevel1(),Nibble.getContentNibbleLevel2() - // , Nibble.getUserNibble1(), Nibble.getUserNibble2()); - - } - pEvent->SetContents(Contents); - } - break; + case SI::ContentDescriptorTag: + { + SI::ContentDescriptor *cd = (SI::ContentDescriptor *) d; + SI::ContentDescriptor::Nibble Nibble; + int NumContents = 0; + uchar Contents[MaxEventContents] = + { 0 }; + for (SI::Loop::Iterator it3; cd->nibbleLoop.getNext(Nibble, it3);) + { + if (NumContents < MaxEventContents) + { + Contents[NumContents] = ((Nibble.getContentNibbleLevel1() + & 0xF) << 4) | (Nibble.getContentNibbleLevel2() & 0xF); + NumContents++; + } + if (DishEventDescriptor && NumContents == 1) + { + DishEventDescriptor->setContent(Nibble); + } + // LogD(2, prep("EEPGDEBUG:Nibble:%x-%x-%x-%x)"), Nibble.getContentNibbleLevel1(),Nibble.getContentNibbleLevel2() + // , Nibble.getUserNibble1(), Nibble.getUserNibble2()); + + } + pEvent->SetContents(Contents); + } + break; #endif - case SI::ParentalRatingDescriptorTag: - { - int LanguagePreferenceRating = -1; - SI::ParentalRatingDescriptor *prd = - (SI::ParentalRatingDescriptor *) d; - SI::ParentalRatingDescriptor::Rating Rating; - for (SI::Loop::Iterator it3; prd->ratingLoop.getNext(Rating, it3);) - { - if (I18nIsPreferredLanguage(Setup.EPGLanguages, - Rating.languageCode, LanguagePreferenceRating)) - { - int ParentalRating = (Rating.getRating() & 0xFF); - switch (ParentalRating) - { - // values defined by the DVB standard (minimum age = rating + 3 years): - case 0x01 ... 0x0F: - ParentalRating += 3; - break; - // values defined by broadcaster CSAT (now why didn't they just use 0x07, 0x09 and 0x0D?): - case 0x11: - ParentalRating = 10; - break; - case 0x12: - ParentalRating = 12; - break; - case 0x13: - ParentalRating = 16; - break; - default: - ParentalRating = 0; - } - pEvent->SetParentalRating(ParentalRating); - } - } - } - break; - case SI::PDCDescriptorTag: - { - SI::PDCDescriptor * pd = (SI::PDCDescriptor *) d; - 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 = pd->getMonth() - 1; - t.tm_mday = pd->getDay(); - t.tm_hour = pd->getHour(); - t.tm_min = pd->getMinute(); - 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--; - time_t vps = mktime(&t); - pEvent->SetVps(vps); - } - break; - case SI::TimeShiftedEventDescriptorTag: - { - if (Schedules) { - SI::TimeShiftedEventDescriptor * tsed = - (SI::TimeShiftedEventDescriptor *) d; - cSchedule *rSchedule = (cSchedule *) Schedules->GetSchedule( - tChannelID(Source, channel->Nid(), channel->Tid(), - tsed->getReferenceServiceId())); - if (!rSchedule) - break; - rEvent = (cEvent *) rSchedule->GetEvent( - tsed->getReferenceEventId()); - if (!rEvent) - break; - pEvent->SetTitle(rEvent->Title()); - pEvent->SetShortText(rEvent->ShortText()); - pEvent->SetDescription(rEvent->Description()); - } - } - break; - case SI::LinkageDescriptorTag: + case SI::ParentalRatingDescriptorTag: + { + int LanguagePreferenceRating = -1; + SI::ParentalRatingDescriptor *prd = + (SI::ParentalRatingDescriptor *) d; + SI::ParentalRatingDescriptor::Rating Rating; + for (SI::Loop::Iterator it3; prd->ratingLoop.getNext(Rating, it3);) + { + if (I18nIsPreferredLanguage(Setup.EPGLanguages, + Rating.languageCode, LanguagePreferenceRating)) + { + int ParentalRating = (Rating.getRating() & 0xFF); + switch (ParentalRating) { - SI::LinkageDescriptor * ld = (SI::LinkageDescriptor *) d; - tChannelID linkID(Source, ld->getOriginalNetworkId(), - ld->getTransportStreamId(), ld->getServiceId()); - if (ld->getLinkageType() == 0xB0) - { // Premiere World - time_t now = time(NULL); - bool hit = SiEitEvent->getStartTime() <= now - && now - < SiEitEvent->getStartTime() + SiEitEvent->getDuration(); - if (hit) - { - char linkName[ld->privateData.getLength() + 1]; - strn0cpy(linkName, (const char *) ld->privateData.getData(), - sizeof(linkName)); - // TODO is there a standard way to determine the character set of this string? - cChannel *link = Channels.GetByChannelID(linkID); - if (link != channel) - { // only link to other channels, not the same one - //fprintf(stderr, "Linkage %s %4d %4d %5d %5d %5d %5d %02X '%s'\n", hit ? "*" : "", channel->Number(), link ? link->Number() : -1, SiEitEvent.getEventId(), ld->getOriginalNetworkId(), ld->getTransportStreamId(), ld->getServiceId(), ld->getLinkageType(), linkName);//XXX - if (link) - { - if (Setup.UpdateChannels == 1 - || Setup.UpdateChannels >= 3) - link->SetName(linkName, "", ""); - } - else if (Setup.UpdateChannels >= 4) - { - cChannel *transponder = channel; - if (channel->Tid() != ld->getTransportStreamId()) - transponder = Channels.GetByTransponderID(linkID); - link = Channels.NewChannel(transponder, linkName, - "", "", ld->getOriginalNetworkId(), - ld->getTransportStreamId(), ld->getServiceId()); - } - if (link) - { - if (!LinkChannels) - LinkChannels = new cLinkChannels; - LinkChannels->Add(new cLinkChannel(link)); - } - } - else - channel->SetPortalName(linkName); - } - } - } + // values defined by the DVB standard (minimum age = rating + 3 years): + case 0x01 ... 0x0F: + ParentalRating += 3; break; - case SI::ComponentDescriptorTag: - { - SI::ComponentDescriptor * cd = (SI::ComponentDescriptor *) d; - uchar Stream = cd->getStreamContent(); - uchar Type = cd->getComponentType(); - //if (1 <= Stream && Stream <= 3 && Type != 0) { // 1=video, 2=audio, 3=subtitles - if (1 <= Stream && Stream <= 6 && Type != 0) - { // 1=MPEG2-video, 2=MPEG1-audio, 3=subtitles, 4=AC3-audio, 5=H.264-video, 6=HEAAC-audio - if (!Components) - Components = new cComponents; - char buffer[Utf8BufSize (256)]; - Components->SetComponent(Components->NumComponents(), Stream, - Type, I18nNormalizeLanguageCode(cd->languageCode), - cd->description.getText(buffer, sizeof(buffer))); - } + // values defined by broadcaster CSAT (now why didn't they just use 0x07, 0x09 and 0x0D?): + case 0x11: + ParentalRating = 10; + break; + case 0x12: + ParentalRating = 12; + break; + case 0x13: + ParentalRating = 16; + break; + default: + ParentalRating = 0; } + pEvent->SetParentalRating(ParentalRating); + } + } + } + break; + case SI::PDCDescriptorTag: + { + SI::PDCDescriptor * pd = (SI::PDCDescriptor *) d; + 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 = pd->getMonth() - 1; + t.tm_mday = pd->getDay(); + t.tm_hour = pd->getHour(); + t.tm_min = pd->getMinute(); + 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--; + time_t vps = mktime(&t); + pEvent->SetVps(vps); + } + break; + case SI::TimeShiftedEventDescriptorTag: + { + if (Schedules) { + SI::TimeShiftedEventDescriptor * tsed = + (SI::TimeShiftedEventDescriptor *) d; + cSchedule *rSchedule = (cSchedule *) Schedules->GetSchedule( + tChannelID(Source, channel->Nid(), channel->Tid(), + tsed->getReferenceServiceId())); + if (!rSchedule) break; - case SI::DishExtendedEventDescriptorTag: - { - SI::UnimplementedDescriptor *deed = - (SI::UnimplementedDescriptor *) d; - if (!DishEventDescriptor) - { - DishEventDescriptor = new SI::DishDescriptor(); - } - DishEventDescriptor->setExtendedtData(Tid + 1, deed->getData()); - // HasExternalData = true; - } + rEvent = (cEvent *) rSchedule->GetEvent( + tsed->getReferenceEventId()); + if (!rEvent) break; - case SI::DishShortEventDescriptorTag: + pEvent->SetTitle(rEvent->Title()); + pEvent->SetShortText(rEvent->ShortText()); + pEvent->SetDescription(rEvent->Description()); + } + } + break; + case SI::LinkageDescriptorTag: + { + SI::LinkageDescriptor * ld = (SI::LinkageDescriptor *) d; + tChannelID linkID(Source, ld->getOriginalNetworkId(), + ld->getTransportStreamId(), ld->getServiceId()); + if (ld->getLinkageType() == 0xB0) + { // Premiere World + time_t now = time(NULL); + bool hit = SiEitEvent->getStartTime() <= now + && now + < SiEitEvent->getStartTime() + SiEitEvent->getDuration(); + if (hit) + { + char linkName[ld->privateData.getLength() + 1]; + strn0cpy(linkName, (const char *) ld->privateData.getData(), + sizeof(linkName)); + // TODO is there a standard way to determine the character set of this string? + cChannel *link = Channels.GetByChannelID(linkID); + if (link != channel) + { // only link to other channels, not the same one + //fprintf(stderr, "Linkage %s %4d %4d %5d %5d %5d %5d %02X '%s'\n", hit ? "*" : "", channel->Number(), link ? link->Number() : -1, SiEitEvent.getEventId(), ld->getOriginalNetworkId(), ld->getTransportStreamId(), ld->getServiceId(), ld->getLinkageType(), linkName);//XXX + if (link) { - SI::UnimplementedDescriptor *dsed = - (SI::UnimplementedDescriptor *) d; - if (!DishEventDescriptor) - { - DishEventDescriptor = new SI::DishDescriptor(); - } - DishEventDescriptor->setShortData(Tid + 1, dsed->getData()); - // HasExternalData = true; + if (Setup.UpdateChannels == 1 + || Setup.UpdateChannels >= 3) + link->SetName(linkName, "", ""); } - break; - case SI::DishRatingDescriptorTag: + else if (Setup.UpdateChannels >= 4) { - if (d->getLength() == 4) - { - if (!DishEventDescriptor) - { - DishEventDescriptor = new SI::DishDescriptor(); - } - uint16_t rating = d->getData().TwoBytes(2); - DishEventDescriptor->setRating(rating); - } + cChannel *transponder = channel; + if (channel->Tid() != ld->getTransportStreamId()) + transponder = Channels.GetByTransponderID(linkID); + link = Channels.NewChannel(transponder, linkName, + "", "", ld->getOriginalNetworkId(), + ld->getTransportStreamId(), ld->getServiceId()); } - break; - case SI::DishSeriesDescriptorTag: + if (link) { - if (d->getLength() == 10) - { - //LogD(2, prep("DishSeriesDescriptorTag: %s)"), (const char*) d->getData().getData()); - if (!DishEventDescriptor) - { - DishEventDescriptor = new SI::DishDescriptor(); - } - DishEventDescriptor->setEpisodeInfo(d->getData()); - } - // else { - // LogD(2, prep("DishSeriesDescriptorTag length: %d)"), d->getLength()); - // } + if (!LinkChannels) + LinkChannels = new cLinkChannels; + LinkChannels->Add(new cLinkChannel(link)); } - break; - default: - break; - } - delete d; + } + else + channel->SetPortalName(linkName); } - if (!rEvent) { - if (ShortEventDescriptor) { + } + } + break; + case SI::ComponentDescriptorTag: + { + SI::ComponentDescriptor * cd = (SI::ComponentDescriptor *) d; + uchar Stream = cd->getStreamContent(); + uchar Type = cd->getComponentType(); + //if (1 <= Stream && Stream <= 3 && Type != 0) { // 1=video, 2=audio, 3=subtitles + if (1 <= Stream && Stream <= 6 && Type != 0) + { // 1=MPEG2-video, 2=MPEG1-audio, 3=subtitles, 4=AC3-audio, 5=H.264-video, 6=HEAAC-audio + if (!Components) + Components = new cComponents; char buffer[Utf8BufSize (256)]; - unsigned char *f; - int l = ShortEventDescriptor->name.getLength(); - f = (unsigned char *) ShortEventDescriptor->name.getData().getData(); - decodeText2 (f, l, buffer, sizeof (buffer)); - //ShortEventDescriptor->name.getText(buffer, sizeof(buffer)); - LogD(2, prep("Title: %s Decoded: %s"), f, buffer); - pEvent->SetTitle (buffer); - LogD(3, prep("channelID: %s Title: %s"), *channel->GetChannelID().ToString(), pEvent->Title()); - l = ShortEventDescriptor->text.getLength(); - if (l > 0) { //Set the Short Text only if there is data so that we do not overwrite valid data - f = (unsigned char *) ShortEventDescriptor->text.getData().getData(); - decodeText2 (f, l, buffer, sizeof (buffer)); - //ShortEventDescriptor->text.getText(buffer, sizeof(buffer)); - pEvent->SetShortText (buffer); - } - LogD(3, prep("ShortText: %s"), pEvent->ShortText()); - LogD(2, prep("ShortText: %s Decoded: %s"), f, buffer); - } else if (/*!HasExternalData*/!DishEventDescriptor) { - pEvent->SetTitle (NULL); - pEvent->SetShortText (NULL); - LogD(3, prep("SetTitle (NULL)")); + Components->SetComponent(Components->NumComponents(), Stream, + Type, I18nNormalizeLanguageCode(cd->languageCode), + cd->description.getText(buffer, sizeof(buffer))); } - if (ExtendedEventDescriptors) { - char buffer[Utf8BufSize (ExtendedEventDescriptors->getMaximumTextLength (": ")) + 1]; - pEvent->SetDescription (ExtendedEventDescriptors->getText (buffer, sizeof (buffer), ": ")); - LogD(3, prep("Description: %s"), pEvent->Description()); - } else if (!/*HasExternalData*/DishEventDescriptor) - pEvent->SetDescription (NULL); - - if (DishEventDescriptor) { - if (DishEventDescriptor->getName()) - pEvent->SetTitle(DishEventDescriptor->getName()); - //LogD(2, prep("channelID: %s DishTitle: %s"), *channel->GetChannelID().ToString(), DishEventDescriptor->getName()); - pEvent->SetShortText(DishEventDescriptor->getShortText()); - char *tmp; - string fmt; - - const char * description = DishEventDescriptor->getDescription(); - //BEV sets the description previously with ExtendedEventDescriptor - if (0 == strcmp(DishEventDescriptor->getDescription(),"") && pEvent->Description()) - description = pEvent->Description(); - - - fmt = "%s"; - if (DishEventDescriptor->hasTheme()) { - fmt += "\nTheme: "; - } - fmt += "%s"; - if (DishEventDescriptor->hasCategory()) { - fmt += "\nCategory: "; - } - fmt += "%s"; - - if ((0 != strcmp(DishEventDescriptor->getRating(),"") - || 0 != strcmp(DishEventDescriptor->getStarRating(),""))) { - fmt += "\n\nRating: "; - } - fmt += "%s %s"; - if (0 != strcmp(DishEventDescriptor->getProgramId(),"")) { - fmt += "\n\nProgram ID: "; + } + break; + case SI::DishExtendedEventDescriptorTag: + { + SI::UnimplementedDescriptor *deed = + (SI::UnimplementedDescriptor *) d; + if (!DishEventDescriptor) + { + DishEventDescriptor = new SI::DishDescriptor(); + } + DishEventDescriptor->setExtendedtData(Tid + 1, deed->getData()); + // HasExternalData = true; + } + break; + case SI::DishShortEventDescriptorTag: + { + SI::UnimplementedDescriptor *dsed = + (SI::UnimplementedDescriptor *) d; + if (!DishEventDescriptor) + { + DishEventDescriptor = new SI::DishDescriptor(); + } + DishEventDescriptor->setShortData(Tid + 1, dsed->getData()); + // HasExternalData = true; + } + break; + case SI::DishRatingDescriptorTag: + { + if (d->getLength() == 4) + { + if (!DishEventDescriptor) + { + DishEventDescriptor = new SI::DishDescriptor(); } - fmt += "%s %s%s"; - time_t orgAirDate = DishEventDescriptor->getOriginalAirDate(); - char datestr [80]; - bool dateok = false; - if (orgAirDate == 0) { - dateok = strftime (datestr,80," Original Air Date: %a %b %d %Y",gmtime(&orgAirDate)) > 0; + uint16_t rating = d->getData().TwoBytes(2); + DishEventDescriptor->setRating(rating); + } + } + break; + case SI::DishSeriesDescriptorTag: + { + if (d->getLength() == 10) + { + //LogD(2, prep("DishSeriesDescriptorTag: %s)"), (const char*) d->getData().getData()); + if (!DishEventDescriptor) + { + DishEventDescriptor = new SI::DishDescriptor(); } + DishEventDescriptor->setEpisodeInfo(d->getData()); + } + // else { + // LogD(2, prep("DishSeriesDescriptorTag length: %d)"), d->getLength()); + // } + } + break; + default: + break; + } + delete d; + } + if (!rEvent) { + if (ShortEventDescriptor) { + char buffer[Utf8BufSize (256)]; + unsigned char *f; + int l = ShortEventDescriptor->name.getLength(); + f = (unsigned char *) ShortEventDescriptor->name.getData().getData(); + decodeText2 (f, l, buffer, sizeof (buffer)); + //ShortEventDescriptor->name.getText(buffer, sizeof(buffer)); + LogD(2, prep("Title: %s Decoded: %s"), f, buffer); + pEvent->SetTitle (buffer); + LogD(3, prep("channelID: %s Title: %s"), *channel->GetChannelID().ToString(), pEvent->Title()); + l = ShortEventDescriptor->text.getLength(); + if (l > 0) { //Set the Short Text only if there is data so that we do not overwrite valid data + f = (unsigned char *) ShortEventDescriptor->text.getData().getData(); + decodeText2 (f, l, buffer, sizeof (buffer)); + //ShortEventDescriptor->text.getText(buffer, sizeof(buffer)); + pEvent->SetShortText (buffer); + } + LogD(3, prep("ShortText: %s"), pEvent->ShortText()); + LogD(2, prep("ShortText: %s Decoded: %s"), f, buffer); + } else if (/*!HasExternalData*/!DishEventDescriptor) { + pEvent->SetTitle (NULL); + pEvent->SetShortText (NULL); + LogD(3, prep("SetTitle (NULL)")); + } + if (ExtendedEventDescriptors) { + char buffer[Utf8BufSize (ExtendedEventDescriptors->getMaximumTextLength (": ")) + 1]; + pEvent->SetDescription (ExtendedEventDescriptors->getText (buffer, sizeof (buffer), ": ")); + LogD(3, prep("Description: %s"), pEvent->Description()); + } else if (!/*HasExternalData*/DishEventDescriptor) + pEvent->SetDescription (NULL); + + if (DishEventDescriptor) { + if (DishEventDescriptor->getName()) + pEvent->SetTitle(DishEventDescriptor->getName()); + //LogD(2, prep("channelID: %s DishTitle: %s"), *channel->GetChannelID().ToString(), DishEventDescriptor->getName()); + pEvent->SetShortText(DishEventDescriptor->getShortText()); + char *tmp; + string fmt; + + const char * description = DishEventDescriptor->getDescription(); + //BEV sets the description previously with ExtendedEventDescriptor + if (0 == strcmp(DishEventDescriptor->getDescription(),"") && pEvent->Description()) + description = pEvent->Description(); + + + fmt = "%s"; + if (DishEventDescriptor->hasTheme()) { + fmt += "\nTheme: "; + } + fmt += "%s"; + if (DishEventDescriptor->hasCategory()) { + fmt += "\nCategory: "; + } + fmt += "%s"; - Asprintf (&tmp, fmt.c_str(), description - , DishEventDescriptor->getTheme(), DishEventDescriptor->getCategory() - , DishEventDescriptor->getRating(), DishEventDescriptor->getStarRating() - , DishEventDescriptor->getProgramId(), DishEventDescriptor->getSeriesId() - , orgAirDate == 0 || !dateok ? "" : datestr); - pEvent->SetDescription(tmp); - free(tmp); + if ((0 != strcmp(DishEventDescriptor->getRating(),"") + || 0 != strcmp(DishEventDescriptor->getStarRating(),""))) { + fmt += "\n\nRating: "; + } + fmt += "%s %s"; + if (0 != strcmp(DishEventDescriptor->getProgramId(),"")) { + fmt += "\n\nProgram ID: "; + } + fmt += "%s %s%s"; + time_t orgAirDate = DishEventDescriptor->getOriginalAirDate(); + char datestr [80]; + bool dateok = false; + if (orgAirDate == 0) { + dateok = strftime (datestr,80," Original Air Date: %a %b %d %Y",gmtime(&orgAirDate)) > 0; + } + Asprintf (&tmp, fmt.c_str(), description + , DishEventDescriptor->getTheme(), DishEventDescriptor->getCategory() + , DishEventDescriptor->getRating(), DishEventDescriptor->getStarRating() + , DishEventDescriptor->getProgramId(), DishEventDescriptor->getSeriesId() + , orgAirDate == 0 || !dateok ? "" : datestr); + pEvent->SetDescription(tmp); + free(tmp); - //LogD(2, prep("DishDescription: %s"), DishEventDescriptor->getDescription()); - //LogD(2, prep("DishShortText: %s"), DishEventDescriptor->getShortText()); - } + //LogD(2, prep("DishDescription: %s"), DishEventDescriptor->getDescription()); + //LogD(2, prep("DishShortText: %s"), DishEventDescriptor->getShortText()); } - delete ExtendedEventDescriptors; - delete ShortEventDescriptor; - delete DishEventDescriptor; - pEvent->SetComponents (Components); + } + delete ExtendedEventDescriptors; + delete ShortEventDescriptor; + delete DishEventDescriptor; -// LogD(2, prep("channelID: %s Title: %s"), *channel->GetChannelID().ToString(), pEvent->Title()); + pEvent->SetComponents (Components); -// if (pEvent->ChannelID() == tChannelID::FromString("S119.0W-4100-6-110-110")) { -// LogD(2, prep("ID: %d Title: %s Time: %d Tid: 0x%x"), pEvent->EventID(), pEvent->Title(), pEvent->StartTime(), pEvent->TableID()); -// } + // LogD(2, prep("channelID: %s Title: %s"), *channel->GetChannelID().ToString(), pEvent->Title()); -// if (!HasExternalData) - pEvent->FixEpgBugs (); - if (LinkChannels) - channel->SetLinkChannels (LinkChannels); - } + // if (pEvent->ChannelID() == tChannelID::FromString("S119.0W-4100-6-110-110")) { + // LogD(2, prep("ID: %d Title: %s Time: %d Tid: 0x%x"), pEvent->EventID(), pEvent->Title(), pEvent->StartTime(), pEvent->TableID()); + // } + + // if (!HasExternalData) + pEvent->FixEpgBugs (); + if (LinkChannels) + channel->SetLinkChannels (LinkChannels); +} cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool isEITPid, bool OnlyRunningStatus) : SI::EIT (Data, false) , OnlyRunningStatus(OnlyRunningStatus) , Schedules(Schedules) { - //LogD(2, prep("cEIT2::cEIT2")); - if (Tid > 0 && (Format == DISH_BEV || (SetupPE->ProcessEIT && isEITPid))) Tid--; - if (!CheckCRCAndParse ()) { - LogD(2, prep("!CheckCRCAndParse ()")); - return; - } + //LogD(2, prep("cEIT2::cEIT2")); + if (Tid > 0 && (Format == DISH_BEV || (cSetupEEPG::getInstance()->ProcessEIT && isEITPid))) Tid--; - bool searchOtherSatPositions = Format == DISH_BEV; + if (!CheckCRCAndParse ()) { + LogD(2, prep("!CheckCRCAndParse ()")); + return; + } - tChannelID channelID (Source, getOriginalNetworkId (), getTransportStreamId (), getServiceId ()); - channel = GetChannelByID (channelID, searchOtherSatPositions); - if (!channel) { - LogD(3, prep("!channel channelID: %s"), *channelID.ToString()); - return; // only collect data for known channels - } + bool searchOtherSatPositions = Format == DISH_BEV; - //LogD(5, prep("channelID: %s format:%d"), *channel->GetChannelID().ToString(), Format); - - cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (channel, true); - - Empty = true; - Modified = false; -// bool HasExternalData = false; - SegmentStart = 0; - SegmentEnd = 0; - - SI::EIT::Event SiEitEvent; - for (SI::Loop::Iterator it; eventLoop.getNext (SiEitEvent, it);) { - int versionNumber = getVersionNumber(); -// bool ExternalData = false; -// // Drop bogus events - but keep NVOD reference events, where all bits of the start time field are set to 1, resulting in a negative number. -// if (SiEitEvent.getStartTime () == 0 || (SiEitEvent.getStartTime () > 0 && SiEitEvent.getDuration () == 0)) -// continue; -// Empty = false; -// if (!SegmentStart) -// SegmentStart = SiEitEvent.getStartTime (); -// SegmentEnd = SiEitEvent.getStartTime () + SiEitEvent.getDuration (); -// int versionNumber = getVersionNumber(); -// -// cEvent *newEvent = NULL; -// cEvent *pEvent = (cEvent *) pSchedule->GetEvent (SiEitEvent.getEventId (), SiEitEvent.getStartTime ()); -// if (!pEvent) { -// if (OnlyRunningStatus) -// continue; -// // If we don't have that event yet, we create a new one. -// // Otherwise we copy the information into the existing event anyway, because the data might have changed. -// pEvent = newEvent = new cEvent (SiEitEvent.getEventId ()); -// if (!pEvent) -// continue; -// } else { -// //LogD(3, prep("existing event channelID: %s Title: %s TableID 0x%02X new TID 0x%02X Version %i, new version %i"), *channel->GetChannelID().ToString(), pEvent->Title(), pEvent->TableID(), Tid, pEvent->Version(), versionNumber); -// // We have found an existing event, either through its event ID or its start time. -// pEvent->SetSeen (); -// -// // If the existing event has a zero table ID it was defined externally and shall -// // not be overwritten. -// if (pEvent->TableID () == 0x00) { -// if (pEvent->Version () == versionNumber) -// continue; -// /*HasExternalData = */ExternalData = true; -// } -// // If the new event has a higher table ID, let's skip it. -// // The lower the table ID, the more "current" the information. -// else if (Tid > pEvent->TableID()) -// continue; -// // If the new event comes from the same table and has the same version number -// // as the existing one, let's skip it to avoid unnecessary work. -// // Unfortunately some stations (like, e.g. "Premiere") broadcast their EPG data on several transponders (like -// // the actual Premiere transponder and the Sat.1/Pro7 transponder), but use different version numbers on -// // each of them :-( So if one DVB card is tuned to the Premiere transponder, while an other one is tuned -// // to the Sat.1/Pro7 transponder, events will keep toggling because of the bogus version numbers. -// else if (Tid == pEvent->TableID() && pEvent->Version() == versionNumber) -// continue; -// } -// if (!ExternalData) { -// pEvent->SetEventID (SiEitEvent.getEventId ()); // unfortunately some stations use different event ids for the same event in different tables :-( -// pEvent->SetTableID (Tid); -// pEvent->SetStartTime (SiEitEvent.getStartTime ()); -// pEvent->SetDuration (SiEitEvent.getDuration ()); -// } -// if (newEvent) -// pSchedule->AddEvent (newEvent); -// if (Tid == 0x4E) { // we trust only the present/following info on the actual TS -// if (SiEitEvent.getRunningStatus () >= SI::RunningStatusNotRunning) -// pSchedule->SetRunningStatus (pEvent, SiEitEvent.getRunningStatus (), channel); -// } -// if (OnlyRunningStatus) -// continue; // do this before setting the version, so that the full update can be done later -// pEvent->SetVersion (versionNumber); -// -// ProcessEventDescriptors(ExternalData, Source, Tid, SiEitEvent, -// pEvent, Schedules, channel); -// -// Modified = true; - cEvent *pEvent = ProcessEitEvent(pSchedule, &SiEitEvent, - Tid, versionNumber); - if (pEvent) - EquivHandler->updateEquivalent(Schedules, channel->GetChannelID(), pEvent); - } + tChannelID channelID (Source, getOriginalNetworkId (), getTransportStreamId (), getServiceId ()); + channel = GetChannelByID (channelID, searchOtherSatPositions); + if (!channel) { + LogD(3, prep("!channel channelID: %s"), *channelID.ToString()); + return; // only collect data for known channels + } - //// + //LogD(5, prep("channelID: %s format:%d"), *channel->GetChannelID().ToString(), Format); + + cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (channel, true); + + Empty = true; + Modified = false; + // bool HasExternalData = false; + SegmentStart = 0; + SegmentEnd = 0; + + SI::EIT::Event SiEitEvent; + for (SI::Loop::Iterator it; eventLoop.getNext (SiEitEvent, it);) { + int versionNumber = getVersionNumber(); + // bool ExternalData = false; + // // Drop bogus events - but keep NVOD reference events, where all bits of the start time field are set to 1, resulting in a negative number. + // if (SiEitEvent.getStartTime () == 0 || (SiEitEvent.getStartTime () > 0 && SiEitEvent.getDuration () == 0)) + // continue; + // Empty = false; + // if (!SegmentStart) + // SegmentStart = SiEitEvent.getStartTime (); + // SegmentEnd = SiEitEvent.getStartTime () + SiEitEvent.getDuration (); + // int versionNumber = getVersionNumber(); + // + // cEvent *newEvent = NULL; + // cEvent *pEvent = (cEvent *) pSchedule->GetEvent (SiEitEvent.getEventId (), SiEitEvent.getStartTime ()); + // if (!pEvent) { + // if (OnlyRunningStatus) + // continue; + // // If we don't have that event yet, we create a new one. + // // Otherwise we copy the information into the existing event anyway, because the data might have changed. + // pEvent = newEvent = new cEvent (SiEitEvent.getEventId ()); + // if (!pEvent) + // continue; + // } else { + // //LogD(3, prep("existing event channelID: %s Title: %s TableID 0x%02X new TID 0x%02X Version %i, new version %i"), *channel->GetChannelID().ToString(), pEvent->Title(), pEvent->TableID(), Tid, pEvent->Version(), versionNumber); + // // We have found an existing event, either through its event ID or its start time. + // pEvent->SetSeen (); + // + // // If the existing event has a zero table ID it was defined externally and shall + // // not be overwritten. + // if (pEvent->TableID () == 0x00) { + // if (pEvent->Version () == versionNumber) + // continue; + // /*HasExternalData = */ExternalData = true; + // } + // // If the new event has a higher table ID, let's skip it. + // // The lower the table ID, the more "current" the information. + // else if (Tid > pEvent->TableID()) + // continue; + // // If the new event comes from the same table and has the same version number + // // as the existing one, let's skip it to avoid unnecessary work. + // // Unfortunately some stations (like, e.g. "Premiere") broadcast their EPG data on several transponders (like + // // the actual Premiere transponder and the Sat.1/Pro7 transponder), but use different version numbers on + // // each of them :-( So if one DVB card is tuned to the Premiere transponder, while an other one is tuned + // // to the Sat.1/Pro7 transponder, events will keep toggling because of the bogus version numbers. + // else if (Tid == pEvent->TableID() && pEvent->Version() == versionNumber) + // continue; + // } + // if (!ExternalData) { + // pEvent->SetEventID (SiEitEvent.getEventId ()); // unfortunately some stations use different event ids for the same event in different tables :-( + // pEvent->SetTableID (Tid); + // pEvent->SetStartTime (SiEitEvent.getStartTime ()); + // pEvent->SetDuration (SiEitEvent.getDuration ()); + // } + // if (newEvent) + // pSchedule->AddEvent (newEvent); + // if (Tid == 0x4E) { // we trust only the present/following info on the actual TS + // if (SiEitEvent.getRunningStatus () >= SI::RunningStatusNotRunning) + // pSchedule->SetRunningStatus (pEvent, SiEitEvent.getRunningStatus (), channel); + // } + // if (OnlyRunningStatus) + // continue; // do this before setting the version, so that the full update can be done later + // pEvent->SetVersion (versionNumber); + // + // ProcessEventDescriptors(ExternalData, Source, Tid, SiEitEvent, + // pEvent, Schedules, channel); + // + // Modified = true; + cEvent *pEvent = ProcessEitEvent(pSchedule, &SiEitEvent, + Tid, versionNumber); + if (pEvent) + EquivHandler->updateEquivalent(Schedules, channel->GetChannelID(), pEvent); + } - if (Empty && Tid == 0x4E && getSectionNumber () == 0) - // ETR 211: an empty entry in section 0 of table 0x4E means there is currently no event running - pSchedule->ClrRunningStatus (channel); - if (Tid == 0x4E) - pSchedule->SetPresentSeen (); - if (OnlyRunningStatus) { - LogD(4, prep("OnlyRunningStatus")); - return; - } - if (Modified) { -// if (!HasExternalData) - pSchedule->DropOutdated (SegmentStart, SegmentEnd, Tid, getVersionNumber ()); - sortSchedules(Schedules, channel->GetChannelID()); - } - LogD(4, prep("end of cEIT2")); + //// + if (Empty && Tid == 0x4E && getSectionNumber () == 0) + // ETR 211: an empty entry in section 0 of table 0x4E means there is currently no event running + pSchedule->ClrRunningStatus (channel); + if (Tid == 0x4E) + pSchedule->SetPresentSeen (); + if (OnlyRunningStatus) { + LogD(4, prep("OnlyRunningStatus")); + return; + } + if (Modified) { + // if (!HasExternalData) + pSchedule->DropOutdated (SegmentStart, SegmentEnd, Tid, getVersionNumber ()); + sortSchedules(Schedules, channel->GetChannelID()); } - //end of cEIT2 + LogD(4, prep("end of cEIT2")); + +} +//end of cEIT2 cEIT2::cEIT2 (cSchedule * Schedule) -: OnlyRunningStatus(false) -, Empty(true) +: Empty(true) , Modified(false) +, OnlyRunningStatus(false) , SegmentStart(0) , SegmentEnd(0) , Schedules(NULL) { - //LogD(2, prep("cEIT2::cEIT2")); -// if (Tid > 0 && (Format == DISH_BEV || (SetupPE->ProcessEIT && isEITPid))) Tid--; + //LogD(2, prep("cEIT2::cEIT2")); + // if (Tid > 0 && (Format == DISH_BEV || (SetupPE->ProcessEIT && isEITPid))) Tid--; - bool searchOtherSatPositions = Format == DISH_BEV; + bool searchOtherSatPositions = Format == DISH_BEV; - tChannelID channelID (Schedule->channelID.Source(), getOriginalNetworkId (), getTransportStreamId (), getServiceId ()); - channel = GetChannelByID (channelID, searchOtherSatPositions); - if (!channel) { - LogD(3, prep("!channel channelID: %s"), *channelID.ToString()); - return; // only collect data for known channels - } + tChannelID channelID (Schedule->ChannelID().Source(), getOriginalNetworkId (), getTransportStreamId (), getServiceId ()); + channel = GetChannelByID (channelID, searchOtherSatPositions); + if (!channel) { + LogD(3, prep("!channel channelID: %s"), *channelID.ToString()); + return; // only collect data for known channels + } } } //end namespace SI diff --git a/eit2.h b/eit2.h index e052b2d..7686672 100644 --- a/eit2.h +++ b/eit2.h @@ -7,12 +7,12 @@ namespace SI { - enum DescriptorTagExt { - DishRatingDescriptorTag = 0x89, - DishShortEventDescriptorTag = 0x91, - DishExtendedEventDescriptorTag = 0x92, - DishSeriesDescriptorTag = 0x96, - }; +enum DescriptorTagExt { + DishRatingDescriptorTag = 0x89, + DishShortEventDescriptorTag = 0x91, + DishExtendedEventDescriptorTag = 0x92, + DishSeriesDescriptorTag = 0x96, +}; // typedef InheritEnum< DescriptorTagExt, SI::DescriptorTag > ExtendedDescriptorTag; @@ -22,28 +22,29 @@ extern bool SystemCharacterTableIsSingleByte;*/ class cEIT2:public SI::EIT { public: - cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool isEITPid = false, bool OnlyRunningStatus = false); + cEIT2(cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool isEITPid = false, + bool OnlyRunningStatus = false); cEIT2 (cSchedule * Schedule); -//protected: -// void updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent); + //protected: + // void updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent); cEvent* ProcessEitEvent(cSchedule *Schedule, const SI::EIT::Event *EitEvent, uchar TableID, uchar Version); private: - void ProcessEventDescriptors(bool ExternalData, - int Source, u_char Tid, const SI::EIT::Event* SiEitEvent, cEvent* pEvent, - cSchedules* Schedules, cChannel* channel); + void ProcessEventDescriptors(bool ExternalData, int Source, u_char Tid, + const SI::EIT::Event* SiEitEvent, cEvent* pEvent, + cSchedules* Schedules, cChannel* channel); private: - bool Empty; - bool Modified; -// bool HasExternalData = false; - time_t SegmentStart; - time_t SegmentEnd; - cSchedules* Schedules; - cChannel* channel; + bool Empty; + bool Modified; + // bool HasExternalData = false; + bool OnlyRunningStatus; + time_t SegmentStart; + time_t SegmentEnd; + cSchedules* Schedules; + cChannel* channel; - bool OnlyRunningStatus; - }; +}; } //end namespace SI #endif /* CEIT2_H_ */ diff --git a/log.h b/log.h index 35942d3..b743763 100644 --- a/log.h +++ b/log.h @@ -9,7 +9,8 @@ #define LOG_H_ #include -#include +#include +#include #include "setupeepg.h" #define VERBOSE 1 diff --git a/util.c b/util.c index c1cc69d..2683131 100644 --- a/util.c +++ b/util.c @@ -5,6 +5,8 @@ * Author: d.petrovski */ #include "util.h" +#include "log.h" +#include "equivhandler.h" #include #include #include @@ -19,6 +21,12 @@ int Yesterday; int YesterdayEpoch; int YesterdayEpochUTC; +struct hufftab *tables[2][128]; +int table_size[2][128]; + +EFormat Format; +cEquivHandler* EquivHandler; + cChannel *GetChannelByID(tChannelID & channelID, bool searchOtherPos) { cChannel *VC = Channels.GetByChannelID(channelID, true); @@ -322,5 +330,20 @@ void decodeText2 (const unsigned char *from, int len, char *buffer, int buffsize //LogE(5, prep("decodeText2 buffer %s - buffsize %d"), buffer, buffsize); } +void sortSchedules(cSchedules * Schedules, tChannelID channelID){ + + LogD(3, prep("Start sortEquivalent %s"), *channelID.ToString()); + + cChannel *pChannel = GetChannelByID (channelID, false); + cSchedule *pSchedule; + if (pChannel) { + pSchedule = (cSchedule *) (Schedules->GetSchedule(pChannel, true)); + pSchedule->Sort(); + Schedules->SetModified(pSchedule); + } + if (EquivHandler->getEquiChanMap().count(*channelID.ToString()) > 0) + EquivHandler->sortEquivalents(channelID, Schedules); +} + } diff --git a/util.h b/util.h index 88e6c62..69c0717 100644 --- a/util.h +++ b/util.h @@ -11,9 +11,18 @@ class cChannel; struct tChannelID; class cEvent; +class cEquivHandler; +class cSchedules; + +#define START '\0' +#define STOP '\0' +#define ESCAPE '\1' + +#define Asprintf(a, b, c...) void( asprintf(a, b, c) < 0 ? esyslog("memory allocation error - %s", b) : void() ) namespace util { + extern int AvailableSources[32]; extern int NumberOfAvailableSources; @@ -21,41 +30,62 @@ extern int Yesterday; extern int YesterdayEpoch; extern int YesterdayEpochUTC; +extern enum EFormat +{ +//First all batchmode, load ONCE protocols: + MHW1 = 0, + MHW2, + SKY_IT, + SKY_UK, + NAGRA, +//Than all CONTinuous protocols, so they will be processed LAST: + PREMIERE, + FREEVIEW, + DISH_BEV, + EIT, +//the highest number of EPG-formats that is supported by this plugin + HIGHEST_FORMAT = EIT +} Format; + +extern cEquivHandler* EquivHandler; + void AddEvent(cEvent *event, tChannelID ChannelID); cChannel *GetChannelByID(tChannelID & channelID, bool searchOtherPos); -time_t LocalTime2UTC (time_t t); -time_t UTC2LocalTime (time_t t); -void GetLocalTimeOffset (void); -void CleanString (unsigned char *String); -void decodeText2 (const unsigned char *from, int len, char *buffer, int buffsize); -char *freesat_huffman_decode (const unsigned char *src, size_t size); - -struct sNode -{ - char *Value; - struct sNode *P0; - struct sNode *P1; -}; +time_t LocalTime2UTC(time_t t); +time_t UTC2LocalTime(time_t t); +void GetLocalTimeOffset(void); +void CleanString(unsigned char *String); +void decodeText2(const unsigned char *from, int len, char *buffer, int buffsize); +char *freesat_huffman_decode(const unsigned char *src, size_t size); +void sortSchedules(cSchedules * Schedules, tChannelID channelID); -typedef struct sNode sNodeH; +//struct sNode +//{ +// char *Value; +// struct sNode *P0; +// struct sNode *P1; +//}; +// +//typedef struct sNode sNodeH; -struct hufftab { +template T REALLOC(T Var, size_t Size) +{ + T p = (T) realloc(Var, Size); + if (!p) free(Var); + return p; +} + +struct hufftab +{ unsigned int value; short bits; char next; }; -#define START '\0' -#define STOP '\0' -#define ESCAPE '\1' - -static struct hufftab *tables[2][128]; -static int table_size[2][128]; -static sNodeH* sky_tables[2]; - - -#define Asprintf(a, b, c...) void( asprintf(a, b, c) < 0 ? esyslog("memory allocation error - %s", b) : void() ) +extern struct hufftab *tables[2][128]; +extern int table_size[2][128]; +//static sNodeH* sky_tables[2]; } #endif /* UTIL_H_ */ -- cgit v1.2.3 From ee3d6a70f2a8ed41acd1d2f7f68843d90679737a Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Fri, 19 Oct 2012 10:42:13 +0200 Subject: modify logging --- equivhandler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/equivhandler.c b/equivhandler.c index a742150..281d2f3 100644 --- a/equivhandler.c +++ b/equivhandler.c @@ -170,8 +170,8 @@ void cEquivHandler::updateEquivalent(tChannelID channelID, cEvent *pEvent){ ret = equiChanMap.equal_range(*channelID.ToString()); for (it=ret.first; it!=ret.second; ++it) { - LogD(3, prep("equivalent channel exists")); tChannelID equChannelID (tChannelID::FromString((*it).second.c_str())); + LogD(3, prep("equivalent channel '%s' exists"), *equChannelID.ToString()); cEvent* newEvent = new cEvent (pEvent->EventID()); cloneEvent(pEvent, newEvent); -- cgit v1.2.3 From 0e805561c58f3a63448b99b71b23a02caa9641e3 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Fri, 19 Oct 2012 11:13:06 +0200 Subject: modified iterator increment --- util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util.c b/util.c index 076401f..6df6137 100644 --- a/util.c +++ b/util.c @@ -213,7 +213,8 @@ void cAddEventThread::Action(void) } EpgHandlers.SortSchedule(schedule); delete (*it).second; - map_list->erase(it++); + map_list->erase(it); + it=map_list->begin(); } Unlock(); -- cgit v1.2.3 From 296fe61d7cf2f10dabd762ba29fe1cbf5a3368c5 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 20 Oct 2012 12:46:13 +0200 Subject: removed some valgrind warinigs try: optimize the sort schedule in add event thread optimize updating of equivalent channels fix deletion of theme and category on eit update --- eepg.c | 2 ++ epghandler.c | 17 ++++++++++++++--- epghandler.h | 1 + util.c | 10 ++++++++-- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/eepg.c b/eepg.c index 6091915..2ba6008 100644 --- a/eepg.c +++ b/eepg.c @@ -238,6 +238,8 @@ public: cFilterEEPG::cFilterEEPG (void) { + nSummaries = 0; + nTitles = 0; Trigger (); //Set (0x00, 0x00); } diff --git a/epghandler.c b/epghandler.c index 3aaec2e..eea1f09 100644 --- a/epghandler.c +++ b/epghandler.c @@ -16,6 +16,7 @@ cEEpgHandler::cEEpgHandler() { LogD(4, prep("cEEpgHandler()")); equivHandler = new cEquivHandler(); + modified = false; } cEEpgHandler::~cEEpgHandler() { @@ -48,6 +49,7 @@ bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, } } + modified = false; //VDR creates new event if the EitEvent StartTime is different than EEPG time so //the EEPG event has to be deleted but the data should be kept const cEvent* ev = Schedule->GetEvent(EitEvent->getEventId(),EitEvent->getStartTime()); @@ -63,6 +65,7 @@ bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, origShortText = ev->ShortText(); Schedule->DropOutdated(ev->StartTime()-1,ev->EndTime()+1,ev->TableID()-1,ev->Version()); LogD(0, prep("!!!End Deleting Event")); + //TODO equivalent channels !!! } } @@ -80,8 +83,11 @@ bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) { bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { LogD(3, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title); - if (!Event->Title() || (Title && (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title))))) + if (!Event->Title() || (Title && (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title))))) { + //LogD(0, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title); + modified = true; Event->SetTitle(Title); + } return true; } @@ -107,6 +113,10 @@ bool cEEpgHandler::SetDescription(cEvent* Event, const char* Description) { origDescription = Event->Description(); else origDescription.clear(); + + //Based on asumption that SetDescription is always called after SetTitle + if (!modified && Description && (!Event->Description() || strcmp(Event->Description(),Description) )) + modified = true; //if (!Event->Description() || Description && (!strcmp(Event->Description(),"") || (strcmp(Description,"") && strcmp(Event->Description(),Description)))) Event->SetDescription(Description); @@ -146,14 +156,15 @@ bool cEEpgHandler::HandleEvent(cEvent* Event) { if (!Event->ShortText() || !strcmp(Event->ShortText(),"")) Event->SetShortText(origShortText.c_str()); - if (!Event->Description() && !origDescription.empty()) { + if ((!Event->Description() && !origDescription.empty()) || (Event->Description() && !origDescription.empty() && origDescription.find(Event->Description()) != string::npos) ) { Event->SetDescription(origDescription.c_str()); } if (equivHandler->getEquiChanMap().count(*Event->ChannelID().ToString()) <= 0) return true; - equivHandler->updateEquivalent(Event->ChannelID(), Event); + if (modified) + equivHandler->updateEquivalent(Event->ChannelID(), Event); // cSchedulesLock SchedulesLock (true); // cSchedules *s = (cSchedules *) cSchedules::Schedules (SchedulesLock); diff --git a/epghandler.h b/epghandler.h index 4e60e57..003fd32 100644 --- a/epghandler.h +++ b/epghandler.h @@ -41,6 +41,7 @@ private: std::string origDescription; cEquivHandler* equivHandler; static const int _LONG_EVENT_HOURS = 10; + bool modified; }; #endif /*APIVERSNUM > 10725*/ diff --git a/util.c b/util.c index 2683131..92164a6 100644 --- a/util.c +++ b/util.c @@ -183,11 +183,17 @@ void cAddEventThread::Action(void) cSchedules *schedules = (cSchedules *)cSchedules::Schedules(SchedulesLock); Lock(); while (schedules && (e = list->First()) != NULL) { + tChannelID chID = e->GetChannelID(); cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID(e->GetChannelID()), true); + while (schedules && (e = list->First()) != NULL) { + + if (chID == e->GetChannelID()) { schedule->AddEvent(e->GetEvent()); - EpgHandlers.SortSchedule(schedule); - EpgHandlers.DropOutdated(schedule, e->GetEvent()->StartTime(), e->GetEvent()->EndTime(), e->GetEvent()->TableID(), e->GetEvent()->Version()); list->Del(e); + } + } + EpgHandlers.SortSchedule(schedule); +// EpgHandlers.DropOutdated(schedule, e->GetEvent()->StartTime(), e->GetEvent()->EndTime(), e->GetEvent()->TableID(), e->GetEvent()->Version()); } Unlock(); cCondWait::SleepMs(10); -- cgit v1.2.3 From c048d5c85ebb94afb8543be5aca1f8a57c36525b Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 20 Oct 2012 17:25:43 +0200 Subject: fix valgrind warinigs --- setupeepg.c | 1 + util.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/setupeepg.c b/setupeepg.c index 54f8243..38f5b90 100644 --- a/setupeepg.c +++ b/setupeepg.c @@ -13,6 +13,7 @@ cSetupEEPG* cSetupEEPG::_setupEEPG = NULL; cSetupEEPG::cSetupEEPG (void) +:ConfDir(NULL) { OptPat = 1; OrderInfo = 1; diff --git a/util.c b/util.c index 92164a6..428aeb8 100644 --- a/util.c +++ b/util.c @@ -121,7 +121,7 @@ void CleanString (unsigned char *String) } Src++; } - if (Spaces > 0) { + if (Spaces > 0 && String > Dst) { Dst--; *Dst = 0; } else { -- cgit v1.2.3 From 28d4e67c2a4bcb355f8e525890a9acf515a70f70 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 20 Oct 2012 17:36:32 +0200 Subject: wrong sign --- util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util.c b/util.c index 428aeb8..640775a 100644 --- a/util.c +++ b/util.c @@ -121,7 +121,7 @@ void CleanString (unsigned char *String) } Src++; } - if (Spaces > 0 && String > Dst) { + if (Spaces > 0 && String < Dst) { Dst--; *Dst = 0; } else { -- cgit v1.2.3 From b08c994f7e1876b024902f59eea990c906850255 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sun, 21 Oct 2012 19:05:22 +0200 Subject: format same as vdr for easier compare --- eit2.c | 214 ++++++++++++++++++++++++----------------------------------------- 1 file changed, 78 insertions(+), 136 deletions(-) diff --git a/eit2.c b/eit2.c index 12a7a95..039172c 100644 --- a/eit2.c +++ b/eit2.c @@ -124,21 +124,16 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, //LogD(2, prep("EEPGDEBUG:d->getDescriptorTAG():%x)"), d->getDescriptorTag ()); nDescriptorTag = d->getDescriptorTag(); - switch (nDescriptorTag) - { - case SI::ExtendedEventDescriptorTag: - { - SI::ExtendedEventDescriptor * eed = - (SI::ExtendedEventDescriptor *) d; - if (I18nIsPreferredLanguage(Setup.EPGLanguages, eed->languageCode, - LanguagePreferenceExt) || !ExtendedEventDescriptors) - { + switch (nDescriptorTag) { + case SI::ExtendedEventDescriptorTag: { + SI::ExtendedEventDescriptor * eed = (SI::ExtendedEventDescriptor *) d; + if (I18nIsPreferredLanguage(Setup.EPGLanguages, eed->languageCode, LanguagePreferenceExt) + || !ExtendedEventDescriptors) { delete ExtendedEventDescriptors; ExtendedEventDescriptors = new SI::ExtendedEventDescriptors; UseExtendedEventDescriptor = true; } - if (UseExtendedEventDescriptor) - { + if (UseExtendedEventDescriptor) { ExtendedEventDescriptors->Add(eed); d = NULL; // so that it is not deleted } @@ -146,12 +141,10 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, UseExtendedEventDescriptor = false; } break; - case SI::ShortEventDescriptorTag: - { + case SI::ShortEventDescriptorTag: { SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d; - if (I18nIsPreferredLanguage(Setup.EPGLanguages, sed->languageCode, - LanguagePreferenceShort) || !ShortEventDescriptor) - { + if (I18nIsPreferredLanguage(Setup.EPGLanguages, sed->languageCode, LanguagePreferenceShort) + || !ShortEventDescriptor) { delete ShortEventDescriptor; ShortEventDescriptor = sed; d = NULL; // so that it is not deleted @@ -159,71 +152,51 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, } break; #if APIVERSNUM > 10711 - case SI::ContentDescriptorTag: - { + case SI::ContentDescriptorTag: { SI::ContentDescriptor *cd = (SI::ContentDescriptor *) d; SI::ContentDescriptor::Nibble Nibble; int NumContents = 0; - uchar Contents[MaxEventContents] = - { 0 }; - for (SI::Loop::Iterator it3; cd->nibbleLoop.getNext(Nibble, it3);) - { - if (NumContents < MaxEventContents) - { - Contents[NumContents] = ((Nibble.getContentNibbleLevel1() - & 0xF) << 4) | (Nibble.getContentNibbleLevel2() & 0xF); + uchar Contents[MaxEventContents] = { 0 }; + for (SI::Loop::Iterator it3; cd->nibbleLoop.getNext(Nibble, it3);) { + if (NumContents < MaxEventContents) { + Contents[NumContents] = ((Nibble.getContentNibbleLevel1() & 0xF) << 4) + | (Nibble.getContentNibbleLevel2() & 0xF); NumContents++; } - if (DishEventDescriptor && NumContents == 1) - { + if (DishEventDescriptor && NumContents == 1) { DishEventDescriptor->setContent(Nibble); } // LogD(2, prep("EEPGDEBUG:Nibble:%x-%x-%x-%x)"), Nibble.getContentNibbleLevel1(),Nibble.getContentNibbleLevel2() - // , Nibble.getUserNibble1(), Nibble.getUserNibble2()); + // , Nibble.getUserNibble1(), Nibble.getUserNibble2()); } pEvent->SetContents(Contents); } break; #endif - case SI::ParentalRatingDescriptorTag: - { + case SI::ParentalRatingDescriptorTag: { int LanguagePreferenceRating = -1; - SI::ParentalRatingDescriptor *prd = - (SI::ParentalRatingDescriptor *) d; + SI::ParentalRatingDescriptor *prd = (SI::ParentalRatingDescriptor *) d; SI::ParentalRatingDescriptor::Rating Rating; - for (SI::Loop::Iterator it3; prd->ratingLoop.getNext(Rating, it3);) - { - if (I18nIsPreferredLanguage(Setup.EPGLanguages, - Rating.languageCode, LanguagePreferenceRating)) - { + for (SI::Loop::Iterator it3; prd->ratingLoop.getNext(Rating, it3);) { + if (I18nIsPreferredLanguage(Setup.EPGLanguages, Rating.languageCode, + LanguagePreferenceRating)) { int ParentalRating = (Rating.getRating() & 0xFF); - switch (ParentalRating) - { + switch (ParentalRating) { // values defined by the DVB standard (minimum age = rating + 3 years): - case 0x01 ... 0x0F: - ParentalRating += 3; - break; + case 0x01 ... 0x0F: ParentalRating += 3; break; // values defined by broadcaster CSAT (now why didn't they just use 0x07, 0x09 and 0x0D?): - case 0x11: - ParentalRating = 10; - break; - case 0x12: - ParentalRating = 12; - break; - case 0x13: - ParentalRating = 16; - break; - default: - ParentalRating = 0; + case 0x11: ParentalRating = 10; break; + case 0x12: ParentalRating = 12; break; + case 0x13: ParentalRating = 16; break; + default: ParentalRating = 0; } pEvent->SetParentalRating(ParentalRating); } } } break; - case SI::PDCDescriptorTag: - { + case SI::PDCDescriptorTag: { SI::PDCDescriptor * pd = (SI::PDCDescriptor *) d; time_t now = time(NULL); struct tm tm_r; @@ -238,23 +211,19 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, 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--; + t.tm_year--; time_t vps = mktime(&t); pEvent->SetVps(vps); } break; - case SI::TimeShiftedEventDescriptorTag: - { + case SI::TimeShiftedEventDescriptorTag: { if (Schedules) { - SI::TimeShiftedEventDescriptor * tsed = - (SI::TimeShiftedEventDescriptor *) d; + SI::TimeShiftedEventDescriptor * tsed = (SI::TimeShiftedEventDescriptor *) d; cSchedule *rSchedule = (cSchedule *) Schedules->GetSchedule( - tChannelID(Source, channel->Nid(), channel->Tid(), - tsed->getReferenceServiceId())); + tChannelID(Source, channel->Nid(), channel->Tid(), tsed->getReferenceServiceId())); if (!rSchedule) break; - rEvent = (cEvent *) rSchedule->GetEvent( - tsed->getReferenceEventId()); + rEvent = (cEvent *) rSchedule->GetEvent(tsed->getReferenceEventId()); if (!rEvent) break; pEvent->SetTitle(rEvent->Title()); @@ -263,63 +232,49 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, } } break; - case SI::LinkageDescriptorTag: - { + case SI::LinkageDescriptorTag: { SI::LinkageDescriptor * ld = (SI::LinkageDescriptor *) d; - tChannelID linkID(Source, ld->getOriginalNetworkId(), - ld->getTransportStreamId(), ld->getServiceId()); - if (ld->getLinkageType() == 0xB0) - { // Premiere World + tChannelID linkID(Source, ld->getOriginalNetworkId(), ld->getTransportStreamId(), + ld->getServiceId()); + if (ld->getLinkageType() == 0xB0) { // Premiere World time_t now = time(NULL); - bool hit = SiEitEvent->getStartTime() <= now - && now - < SiEitEvent->getStartTime() + SiEitEvent->getDuration(); - if (hit) - { - char linkName[ld->privateData.getLength() + 1]; - strn0cpy(linkName, (const char *) ld->privateData.getData(), - sizeof(linkName)); - // TODO is there a standard way to determine the character set of this string? - cChannel *link = Channels.GetByChannelID(linkID); - if (link != channel) - { // only link to other channels, not the same one - //fprintf(stderr, "Linkage %s %4d %4d %5d %5d %5d %5d %02X '%s'\n", hit ? "*" : "", channel->Number(), link ? link->Number() : -1, SiEitEvent.getEventId(), ld->getOriginalNetworkId(), ld->getTransportStreamId(), ld->getServiceId(), ld->getLinkageType(), linkName);//XXX - if (link) - { - if (Setup.UpdateChannels == 1 - || Setup.UpdateChannels >= 3) - link->SetName(linkName, "", ""); - } - else if (Setup.UpdateChannels >= 4) - { - cChannel *transponder = channel; - if (channel->Tid() != ld->getTransportStreamId()) - transponder = Channels.GetByTransponderID(linkID); - link = Channels.NewChannel(transponder, linkName, - "", "", ld->getOriginalNetworkId(), - ld->getTransportStreamId(), ld->getServiceId()); - } - if (link) - { - if (!LinkChannels) - LinkChannels = new cLinkChannels; - LinkChannels->Add(new cLinkChannel(link)); + bool hit = SiEitEvent->getStartTime() <= now + && now < SiEitEvent->getStartTime() + SiEitEvent->getDuration(); + if (hit) { + char linkName[ld->privateData.getLength() + 1]; + strn0cpy(linkName, (const char *) ld->privateData.getData(), sizeof(linkName)); + // TODO is there a standard way to determine the character set of this string? + cChannel *link = Channels.GetByChannelID(linkID); + if (link != channel) { // only link to other channels, not the same one + //fprintf(stderr, "Linkage %s %4d %4d %5d %5d %5d %5d %02X '%s'\n", hit ? "*" : "", channel->Number(), link ? link->Number() : -1, SiEitEvent.getEventId(), ld->getOriginalNetworkId(), ld->getTransportStreamId(), ld->getServiceId(), ld->getLinkageType(), linkName);//XXX + if (link) { + if (Setup.UpdateChannels == 1 || Setup.UpdateChannels >= 3) + link->SetName(linkName, "", ""); + } + else if (Setup.UpdateChannels >= 4) { + cChannel *transponder = channel; + if (channel->Tid() != ld->getTransportStreamId()) + transponder = Channels.GetByTransponderID(linkID); + link = Channels.NewChannel(transponder, linkName, "", "", ld->getOriginalNetworkId(), + ld->getTransportStreamId(), ld->getServiceId()); + } + if (link) { + if (!LinkChannels) LinkChannels = new cLinkChannels; + LinkChannels->Add(new cLinkChannel(link)); + } } + else + channel->SetPortalName(linkName); } - else - channel->SetPortalName(linkName); - } } } break; - case SI::ComponentDescriptorTag: - { + case SI::ComponentDescriptorTag: { SI::ComponentDescriptor * cd = (SI::ComponentDescriptor *) d; uchar Stream = cd->getStreamContent(); uchar Type = cd->getComponentType(); //if (1 <= Stream && Stream <= 3 && Type != 0) { // 1=video, 2=audio, 3=subtitles - if (1 <= Stream && Stream <= 6 && Type != 0) - { // 1=MPEG2-video, 2=MPEG1-audio, 3=subtitles, 4=AC3-audio, 5=H.264-video, 6=HEAAC-audio + if (1 <= Stream && Stream <= 6 && Type != 0) { // 1=MPEG2-video, 2=MPEG1-audio, 3=subtitles, 4=AC3-audio, 5=H.264-video, 6=HEAAC-audio if (!Components) Components = new cComponents; char buffer[Utf8BufSize (256)]; @@ -329,36 +284,27 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, } } break; - case SI::DishExtendedEventDescriptorTag: - { - SI::UnimplementedDescriptor *deed = - (SI::UnimplementedDescriptor *) d; - if (!DishEventDescriptor) - { + case SI::DishExtendedEventDescriptorTag: { + SI::UnimplementedDescriptor *deed = (SI::UnimplementedDescriptor *) d; + if (!DishEventDescriptor) { DishEventDescriptor = new SI::DishDescriptor(); } DishEventDescriptor->setExtendedtData(Tid + 1, deed->getData()); // HasExternalData = true; } break; - case SI::DishShortEventDescriptorTag: - { - SI::UnimplementedDescriptor *dsed = - (SI::UnimplementedDescriptor *) d; - if (!DishEventDescriptor) - { + case SI::DishShortEventDescriptorTag: { + SI::UnimplementedDescriptor *dsed = (SI::UnimplementedDescriptor *) d; + if (!DishEventDescriptor) { DishEventDescriptor = new SI::DishDescriptor(); } DishEventDescriptor->setShortData(Tid + 1, dsed->getData()); // HasExternalData = true; } break; - case SI::DishRatingDescriptorTag: - { - if (d->getLength() == 4) - { - if (!DishEventDescriptor) - { + case SI::DishRatingDescriptorTag: { + if (d->getLength() == 4) { + if (!DishEventDescriptor) { DishEventDescriptor = new SI::DishDescriptor(); } uint16_t rating = d->getData().TwoBytes(2); @@ -366,13 +312,10 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, } } break; - case SI::DishSeriesDescriptorTag: - { - if (d->getLength() == 10) - { + case SI::DishSeriesDescriptorTag: { + if (d->getLength() == 10) { //LogD(2, prep("DishSeriesDescriptorTag: %s)"), (const char*) d->getData().getData()); - if (!DishEventDescriptor) - { + if (!DishEventDescriptor) { DishEventDescriptor = new SI::DishDescriptor(); } DishEventDescriptor->setEpisodeInfo(d->getData()); @@ -467,7 +410,6 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, pEvent->SetDescription(tmp); free(tmp); - //LogD(2, prep("DishDescription: %s"), DishEventDescriptor->getDescription()); //LogD(2, prep("DishShortText: %s"), DishEventDescriptor->getShortText()); } -- cgit v1.2.3 From a09e46d0dbeb29954f6ae72b95e00063455de0a2 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sun, 21 Oct 2012 19:08:07 +0200 Subject: fix compile with some compiler null check revert some changes --- eit2.c | 2 +- util.c | 23 ++++++++++++++++------- util.h | 2 ++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/eit2.c b/eit2.c index 12a7a95..ca6c759 100644 --- a/eit2.c +++ b/eit2.c @@ -632,7 +632,7 @@ cEIT2::cEIT2 (cSchedule * Schedule) bool searchOtherSatPositions = Format == DISH_BEV; - tChannelID channelID (Schedule->ChannelID().Source(), getOriginalNetworkId (), getTransportStreamId (), getServiceId ()); + tChannelID channelID = Schedule->ChannelID(); channel = GetChannelByID (channelID, searchOtherSatPositions); if (!channel) { LogD(3, prep("!channel channelID: %s"), *channelID.ToString()); diff --git a/util.c b/util.c index 640775a..9ca9484 100644 --- a/util.c +++ b/util.c @@ -121,7 +121,7 @@ void CleanString (unsigned char *String) } Src++; } - if (Spaces > 0 && String < Dst) { + if (Spaces > 0 && String && String < Dst) { Dst--; *Dst = 0; } else { @@ -176,25 +176,32 @@ cAddEventThread::~cAddEventThread(void) void cAddEventThread::Action(void) { + LogD (0, prep("Action")); SetPriority(19); while (Running() && !LastHandleEvent.TimedOut()) { +// LogD (0, prep("Running")); cAddEventListItem *e = NULL; cSchedulesLock SchedulesLock(true, 10); cSchedules *schedules = (cSchedules *)cSchedules::Schedules(SchedulesLock); Lock(); while (schedules && (e = list->First()) != NULL) { - tChannelID chID = e->GetChannelID(); +// tChannelID chID = e->GetChannelID(); cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID(e->GetChannelID()), true); - while (schedules && (e = list->First()) != NULL) { +// while (schedules && (e = list->First()) != NULL) { - if (chID == e->GetChannelID()) { +// if (chID == e->GetChannelID()) { +// LogD (0, prep("AddEvent")); schedule->AddEvent(e->GetEvent()); +// LogD (0, prep("Del")); list->Del(e); - } - } +// } +// } + LogD (0, prep("Sort")); EpgHandlers.SortSchedule(schedule); -// EpgHandlers.DropOutdated(schedule, e->GetEvent()->StartTime(), e->GetEvent()->EndTime(), e->GetEvent()->TableID(), e->GetEvent()->Version()); + EpgHandlers.DropOutdated(schedule, e->GetEvent()->StartTime(), e->GetEvent()->EndTime(), e->GetEvent()->TableID(), e->GetEvent()->Version()); +// LogD (0, prep("Sorted")); } +// LogD (0, prep("Unlock")); Unlock(); cCondWait::SleepMs(10); } @@ -203,6 +210,7 @@ void cAddEventThread::Action(void) void cAddEventThread::AddEvent(cEvent *Event, tChannelID ChannelID) { LOCK_THREAD; +// LogD (0, prep("AddEventT %s channel: <%s>"), Event->Title(), *ChannelID.ToString()); list->Add(new cAddEventListItem(Event, ChannelID)); LastHandleEvent.Set(INSERT_TIMEOUT_IN_MS); } @@ -213,6 +221,7 @@ static cAddEventThread AddEventThread; void AddEvent(cEvent *Event, tChannelID ChannelID) { + LogD (0, prep("AddEvent %s channel: <%s>"), Event->Title(), *ChannelID.ToString()); AddEventThread.AddEvent(Event, ChannelID); if (!AddEventThread.Active()) AddEventThread.Start(); diff --git a/util.h b/util.h index 69c0717..dec5b70 100644 --- a/util.h +++ b/util.h @@ -8,6 +8,8 @@ #ifndef UTIL_H_ #define UTIL_H_ #include +#include + class cChannel; struct tChannelID; class cEvent; -- cgit v1.2.3 From 384796b93d7f28a291fad50a3143d65176037af1 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sun, 21 Oct 2012 19:35:01 +0200 Subject: delete event from local list befora adding it to schedule. this fixes all problems with sorting since correct events are in previous / next --- util.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/util.c b/util.c index ae8c869..fb45360 100644 --- a/util.c +++ b/util.c @@ -213,17 +213,16 @@ void cAddEventThread::Action(void) while (((*it).second->First()) != NULL) { cEvent* event = (*it).second->First(); - cEvent *pEqvEvent = (cEvent *) schedule->GetEvent (event->EventID(), event->StartTime()); +/* cEvent *pEqvEvent = (cEvent *) schedule->GetEvent (event->EventID(), event->StartTime()); if (pEqvEvent){ LogD (0, prep("schedule->DelEvent(event)")); schedule->DelEvent(pEqvEvent); } - +*/ LogD (0, prep("schedule->AddEvent(event)")); //cCondWait::SleepMs(10); - if (event) - schedule->AddEvent(event); - (*it).second->Del(event); + (*it).second->Del(event, false); + schedule->AddEvent(event); } EpgHandlers.SortSchedule(schedule); //sortSchedules(schedules, (*it).first); -- cgit v1.2.3 From c28712e0563dd36638e9f6ad7c73a9dc6566abb1 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sun, 21 Oct 2012 20:50:19 +0200 Subject: remove commented code --- util.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/util.c b/util.c index fb45360..04993f0 100644 --- a/util.c +++ b/util.c @@ -132,23 +132,6 @@ void CleanString (unsigned char *String) // LogD (1, prep("Clean: %s"), String); } -// --- cAddEventThread ---------------------------------------- -// Taken from VDR EPGFixer Plug-in -// http://projects.vdr-developer.org/projects/plg-epgfixer -// by Matti Lehtimaki - -//class cAddEventListItem : public cListObject -//{ -//protected: -// cEvent *event; -// tChannelID channelID; -//public: -// cAddEventListItem(cEvent *Event, tChannelID ChannelID) { event = Event; channelID = ChannelID; } -// tChannelID GetChannelID() { return channelID; } -// cEvent *GetEvent() { return event; } -// ~cAddEventListItem() { } -//}; - struct tChannelIDCompare { bool operator() (const tChannelID& lhs, const tChannelID& rhs) const @@ -162,7 +145,6 @@ class cAddEventThread : public cThread { private: cTimeMs LastHandleEvent; -// cList *list; std::map*,tChannelIDCompare> *map_list; enum { INSERT_TIMEOUT_IN_MS = 10000 }; protected: @@ -176,14 +158,12 @@ public: cAddEventThread::cAddEventThread(void) :cThread("cAddEventThread"), LastHandleEvent() { -// list = new cList; map_list = new std::map*,tChannelIDCompare>; } cAddEventThread::~cAddEventThread(void) { LOCK_THREAD; -// list->cList::Clear(); std::map*,tChannelIDCompare>::iterator it; for ( it=map_list->begin() ; it != map_list->end(); it++ ) (*it).second->cList::Clear(); @@ -195,8 +175,8 @@ void cAddEventThread::Action(void) LogD (0, prep("Action")); SetPriority(19); while (Running() && !LastHandleEvent.TimedOut()) { -// cAddEventListItem *e = NULL; - cSchedulesLock SchedulesLock(true, 10); + + cSchedulesLock SchedulesLock(true, 10); cSchedules *schedules = (cSchedules *)cSchedules::Schedules(SchedulesLock); Lock(); // while (schedules && (e = list->First()) != NULL) { @@ -219,9 +199,9 @@ void cAddEventThread::Action(void) schedule->DelEvent(pEqvEvent); } */ - LogD (0, prep("schedule->AddEvent(event)")); //cCondWait::SleepMs(10); (*it).second->Del(event, false); + EpgHandlers.DropOutdated(schedule, event->StartTime(), event->EndTime(), event->TableID(), event->Version()); schedule->AddEvent(event); } EpgHandlers.SortSchedule(schedule); @@ -239,9 +219,7 @@ void cAddEventThread::Action(void) void cAddEventThread::AddEvent(cEvent *Event, tChannelID ChannelID) { - LogD (0, prep("AddEventT start")); LOCK_THREAD; - LogD (0, prep("AddEventT lock ")); if (map_list->empty() || map_list->count(ChannelID) == 0) { LogD (0, prep("AddEventT if")); cList* list = new cList; -- cgit v1.2.3 From 26555852b2a8a840d2ccc1e91bbdbed1c46e838e Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sun, 21 Oct 2012 20:55:53 +0200 Subject: remove logging --- util.c | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/util.c b/util.c index 04993f0..3d65f04 100644 --- a/util.c +++ b/util.c @@ -172,13 +172,13 @@ cAddEventThread::~cAddEventThread(void) void cAddEventThread::Action(void) { - LogD (0, prep("Action")); + //LogD (0, prep("Action")); SetPriority(19); while (Running() && !LastHandleEvent.TimedOut()) { cSchedulesLock SchedulesLock(true, 10); - cSchedules *schedules = (cSchedules *)cSchedules::Schedules(SchedulesLock); - Lock(); + cSchedules *schedules = (cSchedules *) cSchedules::Schedules(SchedulesLock); + Lock(); // while (schedules && (e = list->First()) != NULL) { // cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID(e->GetChannelID()), true); // schedule->AddEvent(e->GetEvent()); @@ -186,12 +186,13 @@ void cAddEventThread::Action(void) // EpgHandlers.DropOutdated(schedule, e->GetEvent()->StartTime(), e->GetEvent()->EndTime(), e->GetEvent()->TableID(), e->GetEvent()->Version()); // list->Del(e); // } - std::map*,tChannelIDCompare>::iterator it; - it=map_list->begin(); - while (schedules && it != map_list->end()) { - cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID((*it).first), true); - while (((*it).second->First()) != NULL) { - cEvent* event = (*it).second->First(); + std::map*, tChannelIDCompare>::iterator it; + it = map_list->begin(); + while (schedules && it != map_list->end()) { + cSchedule *schedule = (cSchedule *) schedules->GetSchedule( + Channels.GetByChannelID((*it).first), true); + while (((*it).second->First()) != NULL) { + cEvent* event = (*it).second->First(); /* cEvent *pEqvEvent = (cEvent *) schedule->GetEvent (event->EventID(), event->StartTime()); if (pEqvEvent){ @@ -200,38 +201,36 @@ void cAddEventThread::Action(void) } */ //cCondWait::SleepMs(10); - (*it).second->Del(event, false); - EpgHandlers.DropOutdated(schedule, event->StartTime(), event->EndTime(), event->TableID(), event->Version()); - schedule->AddEvent(event); - } - EpgHandlers.SortSchedule(schedule); + (*it).second->Del(event, false); + EpgHandlers.DropOutdated(schedule, event->StartTime(), event->EndTime(), event->TableID(), + event->Version()); + schedule->AddEvent(event); + } + EpgHandlers.SortSchedule(schedule); //sortSchedules(schedules, (*it).first); //schedule->Sort(); - delete (*it).second; - map_list->erase(it); - it=map_list->begin(); - - } - Unlock(); - cCondWait::SleepMs(10); - } + delete (*it).second; + map_list->erase(it); + it = map_list->begin(); + + } + Unlock(); + cCondWait::SleepMs(10); + } } void cAddEventThread::AddEvent(cEvent *Event, tChannelID ChannelID) { LOCK_THREAD; if (map_list->empty() || map_list->count(ChannelID) == 0) { - LogD (0, prep("AddEventT if")); cList* list = new cList; list->Add(Event); map_list->insert(std::make_pair(ChannelID, list)); } else { - LogD (0, prep("AddEventT else")); (*map_list->find(ChannelID)).second->Add(Event); } // LogD (0, prep("AddEventT %s channel: <%s>"), Event->Title(), *ChannelID.ToString()); LastHandleEvent.Set(INSERT_TIMEOUT_IN_MS); - LogD (0, prep("AddEventT end")); } static cAddEventThread AddEventThread; -- cgit v1.2.3 From 16803744f86b3580ce8b80595a361ee3ba2ea3b3 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sun, 21 Oct 2012 21:52:20 +0200 Subject: removed commented code change the way the duplicate event is deleted --- epghandler.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/epghandler.c b/epghandler.c index 5f10a3c..924b4df 100644 --- a/epghandler.c +++ b/epghandler.c @@ -63,7 +63,8 @@ bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, origDescription = ev->Description(); if (ev->ShortText() && strcmp(ev->ShortText(),"") != 0) origShortText = ev->ShortText(); - Schedule->DropOutdated(ev->StartTime()-1,ev->EndTime()+1,ev->TableID()-1,ev->Version()); + Schedule->DelEvent((cEvent *) ev); +// Schedule->DropOutdated(ev->StartTime()-1,ev->EndTime()+1,ev->TableID()-1,ev->Version()); LogD(0, prep("!!!End Deleting Event")); //TODO equivalent channels !!! } @@ -166,13 +167,6 @@ bool cEEpgHandler::HandleEvent(cEvent* Event) { if (modified) equivHandler->updateEquivalent(Event->ChannelID(), Event); -// cSchedulesLock SchedulesLock (true); -// cSchedules *s = (cSchedules *) cSchedules::Schedules (SchedulesLock); -// if (s) { -// equivHandler->updateEquivalent(s, Event->ChannelID(), Event); -// } else -// LogE (0, prep("Error: could not lock schedules.")); - //TODO just to see the difference //else if (!origDescription.empty() && !origDescription.compare(Event->Description())) { // origDescription.append(" | EIT: "); @@ -188,14 +182,6 @@ bool cEEpgHandler::SortSchedule(cSchedule* Schedule) { Schedule->Sort(); - //NOK -// cSchedulesLock SchedulesLock (true); -// cSchedules *s = (cSchedules *) cSchedules::Schedules (SchedulesLock); -// if (s) { -// equivHandler->sortEquivalents(Schedule->ChannelID(), s); -// } else -// LogE (0, prep("Error: could not lock schedules.")); - return true; } -- cgit v1.2.3 From bf45a222e707b0f778bc39abb171813bc39dd194 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sun, 28 Oct 2012 16:47:07 +0100 Subject: fixed tChannelIDCompare which fixes the event map. try to change the activation of the thread. should be workged some more fix the Original Air Date for NA epg --- eit2.c | 4 ++-- epghandler.c | 3 +-- util.c | 66 ++++++++++++++++++++++++++++++++++-------------------------- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/eit2.c b/eit2.c index 8d04486..87064c5 100644 --- a/eit2.c +++ b/eit2.c @@ -398,8 +398,8 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, time_t orgAirDate = DishEventDescriptor->getOriginalAirDate(); char datestr [80]; bool dateok = false; - if (orgAirDate == 0) { - dateok = strftime (datestr,80," Original Air Date: %a %b %d %Y",gmtime(&orgAirDate)) > 0; + if (orgAirDate != 0) { + dateok = strftime (datestr,80," \nOriginal Air Date: %a %b %d %Y",gmtime(&orgAirDate)) > 0; } Asprintf (&tmp, fmt.c_str(), description diff --git a/epghandler.c b/epghandler.c index 924b4df..a1b92c3 100644 --- a/epghandler.c +++ b/epghandler.c @@ -28,7 +28,6 @@ bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, const SI::EIT::Event* EitEvent, uchar TableID, uchar Version) { //LogD(1, prep("HandleEitEvent")); //DISH NID 0x1001 to 0x100B BEV 0x100 and 0x101 - //TODO move the eit handling code at least for NA providers here instead of discarding. int nid = Schedule->ChannelID().Nid(); if ((nid >= 0x1001 && nid <= 0x100B) || nid == 0x101 || nid == 0x100) { SI::cEIT2 eit2(Schedule); @@ -164,7 +163,7 @@ bool cEEpgHandler::HandleEvent(cEvent* Event) { if (equivHandler->getEquiChanMap().count(*Event->ChannelID().ToString()) <= 0) return true; - if (modified) + //if (modified) equivHandler->updateEquivalent(Event->ChannelID(), Event); //TODO just to see the difference diff --git a/util.c b/util.c index 3d65f04..88de2b6 100644 --- a/util.c +++ b/util.c @@ -136,17 +136,28 @@ struct tChannelIDCompare { bool operator() (const tChannelID& lhs, const tChannelID& rhs) const { - return *lhs.ToString() < *rhs.ToString(); + if (lhs.Source() < rhs.Source()) return true; + bool eq = lhs.Source() == rhs.Source(); + if (eq && lhs.Nid() < rhs.Nid()) return true; + eq &= lhs.Nid() == rhs.Nid(); + if (eq && lhs.Tid() < rhs.Tid()) return true; + eq &= lhs.Tid() == rhs.Tid(); + if (eq && lhs.Sid() < rhs.Sid()) return true; + eq &= lhs.Sid() == rhs.Sid(); + if (eq && lhs.Rid() < rhs.Rid()) return true; + return false; } }; +cTimeMs LastAddEventThread; +enum { INSERT_TIMEOUT_IN_MS = 10000 }; class cAddEventThread : public cThread { private: cTimeMs LastHandleEvent; std::map*,tChannelIDCompare> *map_list; - enum { INSERT_TIMEOUT_IN_MS = 10000 }; +// enum { INSERT_TIMEOUT_IN_MS = 10000 }; protected: virtual void Action(void); public: @@ -163,11 +174,11 @@ cAddEventThread::cAddEventThread(void) cAddEventThread::~cAddEventThread(void) { - LOCK_THREAD; +// LOCK_THREAD; + Cancel(3); std::map*,tChannelIDCompare>::iterator it; for ( it=map_list->begin() ; it != map_list->end(); it++ ) (*it).second->cList::Clear(); - Cancel(3); } void cAddEventThread::Action(void) @@ -175,18 +186,12 @@ void cAddEventThread::Action(void) //LogD (0, prep("Action")); SetPriority(19); while (Running() && !LastHandleEvent.TimedOut()) { + std::map*, tChannelIDCompare>::iterator it; cSchedulesLock SchedulesLock(true, 10); cSchedules *schedules = (cSchedules *) cSchedules::Schedules(SchedulesLock); Lock(); -// while (schedules && (e = list->First()) != NULL) { -// cSchedule *schedule = (cSchedule *)schedules->GetSchedule(Channels.GetByChannelID(e->GetChannelID()), true); -// schedule->AddEvent(e->GetEvent()); -// EpgHandlers.SortSchedule(schedule); -// EpgHandlers.DropOutdated(schedule, e->GetEvent()->StartTime(), e->GetEvent()->EndTime(), e->GetEvent()->TableID(), e->GetEvent()->Version()); -// list->Del(e); -// } - std::map*, tChannelIDCompare>::iterator it; + it = map_list->begin(); while (schedules && it != map_list->end()) { cSchedule *schedule = (cSchedule *) schedules->GetSchedule( @@ -194,17 +199,18 @@ void cAddEventThread::Action(void) while (((*it).second->First()) != NULL) { cEvent* event = (*it).second->First(); -/* cEvent *pEqvEvent = (cEvent *) schedule->GetEvent (event->EventID(), event->StartTime()); + cEvent *pEqvEvent = (cEvent *) schedule->GetEvent (event->EventID(), event->StartTime()); if (pEqvEvent){ - LogD (0, prep("schedule->DelEvent(event)")); - schedule->DelEvent(pEqvEvent); - } -*/ - //cCondWait::SleepMs(10); - (*it).second->Del(event, false); - EpgHandlers.DropOutdated(schedule, event->StartTime(), event->EndTime(), event->TableID(), - event->Version()); - schedule->AddEvent(event); +// LogD (0, prep("schedule->DelEvent(event) size:%d"), (*it).second->Count()); + (*it).second->Del(event); +// schedule->DelEvent(pEqvEvent); + } else { + + (*it).second->Del(event, false); + EpgHandlers.DropOutdated(schedule, event->StartTime(), event->EndTime(), event->TableID(), + event->Version()); + schedule->AddEvent(event); + } } EpgHandlers.SortSchedule(schedule); //sortSchedules(schedules, (*it).first); @@ -222,14 +228,14 @@ void cAddEventThread::Action(void) void cAddEventThread::AddEvent(cEvent *Event, tChannelID ChannelID) { LOCK_THREAD; - if (map_list->empty() || map_list->count(ChannelID) == 0) { + if (map_list->count(ChannelID) == 0) { cList* list = new cList; list->Add(Event); map_list->insert(std::make_pair(ChannelID, list)); } else { - (*map_list->find(ChannelID)).second->Add(Event); + map_list->find(ChannelID)->second->Add(Event); } -// LogD (0, prep("AddEventT %s channel: <%s>"), Event->Title(), *ChannelID.ToString()); +// LogD (0, prep("AddEventT %s channel: <%s> map size:%d"), Event->Title(), *ChannelID.ToString(), map_list->size()); LastHandleEvent.Set(INSERT_TIMEOUT_IN_MS); } @@ -241,8 +247,13 @@ void AddEvent(cEvent *Event, tChannelID ChannelID) { // LogD (0, prep("AddEvent %s channel: <%s>"), Event->Title(), *ChannelID.ToString()); AddEventThread.AddEvent(Event, ChannelID); - if (!AddEventThread.Active()) - AddEventThread.Start(); +// if (!AddEventThread.Active()) +// AddEventThread.Start(); + if (!AddEventThread.Active() && LastAddEventThread.TimedOut()){ + LastAddEventThread.Set(INSERT_TIMEOUT_IN_MS * 2); + AddEventThread.Start(); + } + } /** \brief Decode an EPG string as necessary @@ -256,7 +267,6 @@ void AddEvent(cEvent *Event, tChannelID ChannelID) char *freesat_huffman_decode (const unsigned char *src, size_t size) { int tableid; -// freesat_decode_error = 0; if (src[0] == 0x1f && (src[1] == 1 || src[1] == 2)) { int uncompressed_len = 30; -- cgit v1.2.3 From 8362f9f9780e3804463484d67120fef296fc1dfa Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Mon, 29 Oct 2012 11:07:06 +0100 Subject: alocated length was not enough for some events --- eepg.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/eepg.c b/eepg.c index 2ba6008..52af9df 100644 --- a/eepg.c +++ b/eepg.c @@ -1865,7 +1865,7 @@ int cFilterEEPG::GetTitlesMHW1 (const u_char * Data, int Length) LogE(0, prep("Titles memory allocation error.")); return 0; } - T->Text[46] = '\0'; //end string with NULL character + //T->Text[46] = '\0'; //end string with NULL character //memcpy (T->Text, &Title->Title, 23); decodeText2((unsigned char *)&Title->Title, 23, (char*)T->Text, 47); CleanString (T->Text); @@ -1941,13 +1941,13 @@ int cFilterEEPG::GetTitlesMHW2 (const u_char * Data, int Length) T->Duration = (((Data[Pos + 5] << 8) | Data[Pos + 6]) >> 4) * 60; Len = Data[Pos + 7] & 0x3f; //isyslog ("EEPGDebug: Len:%d", Len); - T->Text = (unsigned char *) malloc (Len + 2); + T->Text = (unsigned char *) malloc (2 * Len + 1); if (T->Text == NULL) { LogE(0, prep("Titles memory allocation error.")); return 0; //fatal error } - T->Text[Len] = '\0'; //end string with NULL character - decodeText2(&Data[Pos + 8],Len,(char*)T->Text,Len+1); + decodeText2(&Data[Pos + 8],Len,(char*)T->Text,2 * Len + 1); + //T->Text[Len] = '\0'; //end string with NULL character //memcpy (T->Text, &Data[Pos + 8], Len); CleanString (T->Text); Pos += Len + 8; // Sub Theme starts here @@ -2108,7 +2108,7 @@ int cFilterEEPG::GetSummariesMHW2 (const u_char * Data, int Length) memcpy (&tmp[SummaryLength], &Data[Pos], lenText); SummaryLength += lenText; if (Loop > 1) { - tmp[SummaryLength] = '\n'; + tmp[SummaryLength] = ' ';// This is considered as an EPG bug in VDR '\n'; SummaryLength += 1; } } else @@ -2117,14 +2117,14 @@ int cFilterEEPG::GetSummariesMHW2 (const u_char * Data, int Length) Loop--; } } - S->Text = (unsigned char *) malloc (SummaryLength + 2); - S->Text[SummaryLength] = '\0'; //end string with NULL character + S->Text = (unsigned char *) malloc (2 * SummaryLength + 1); if (S->Text == NULL) { LogE(0, prep("Summaries memory allocation error.")); return 0; //fatal error } //memcpy (S->Text, tmp, SummaryLength); - decodeText2(tmp,SummaryLength,(char*)S->Text,SummaryLength + 1); + //S->Text[SummaryLength] = '\0'; //end string with NULL character + decodeText2(tmp,SummaryLength,(char*)S->Text,2 * SummaryLength + 1); CleanString (S->Text); LogI(3, prep("EventId %08x Summnr %d:%.30s."), S->EventId, nSummaries, S->Text); nSummaries++; @@ -2588,7 +2588,8 @@ void cFilterEEPG::LoadIntoSchedule (void) isyslog ("EEPG: found %i themes", nThemes); isyslog ("EEPG: found %i channels", nChannels); isyslog ("EEPG: found %i titles", nTitles); - isyslog ("EEPG: of which %i reported to have no summary available; skipping these BIENTOT titles", NoSummary); + if (NoSummary != 0) + isyslog ("EEPG: of which %i reported to have no summary available; skipping these BIENTOT titles", NoSummary); isyslog ("EEPG: found %i summaries", nSummaries); if (SummariesNotFound != 0) esyslog ("EEPG: %i summaries not found", SummariesNotFound); -- cgit v1.2.3 From d723bdc772b60190af39a256bffc33c27cfb9575 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Mon, 29 Oct 2012 16:01:13 +0100 Subject: renamed thread so that it is different from EPGFixer plugin --- util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util.c b/util.c index 88de2b6..415f213 100644 --- a/util.c +++ b/util.c @@ -167,7 +167,7 @@ public: }; cAddEventThread::cAddEventThread(void) -:cThread("cAddEventThread"), LastHandleEvent() +:cThread("cAddEEPGEventThread"), LastHandleEvent() { map_list = new std::map*,tChannelIDCompare>; } @@ -178,7 +178,7 @@ cAddEventThread::~cAddEventThread(void) Cancel(3); std::map*,tChannelIDCompare>::iterator it; for ( it=map_list->begin() ; it != map_list->end(); it++ ) - (*it).second->cList::Clear(); + (*it).second->Clear(); } void cAddEventThread::Action(void) -- cgit v1.2.3 From f1717857da8db98772c7a807befe2426ff2ed133 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 30 Oct 2012 11:40:27 +0100 Subject: added helper scripts for generation of eepg.equiv updated documentation --- HISTORY | 15 ++++++++- README | 74 ++++++++++++++++++++++++++--------------- TODO | 2 +- scripts/README | 28 ++++++++++++++++ scripts/extract_vdr_chan_ids.pl | 38 +++++++++++++++++++++ scripts/makeequiv.sh | 56 +++++++++++++++++++++++++++++++ 6 files changed, 185 insertions(+), 28 deletions(-) create mode 100644 scripts/README create mode 100755 scripts/extract_vdr_chan_ids.pl create mode 100755 scripts/makeequiv.sh diff --git a/HISTORY b/HISTORY index a7b7626..f3ccd4d 100644 --- a/HISTORY +++ b/HISTORY @@ -15,7 +15,20 @@ Release 0.0.6pre: - Added setup option to display message after finish of writing epg - Added Dish Network and Bell ExpressVU support, thanks to the VDR patch, Mrgandalf and VDR User - Applied patch to Load Huffman dictionaries only on first use, thanks to Torsten Lang - +- Fixed update of equivalents for Freesat +- Add category and genere to the description usable with epgsearch +- Added EpgHandler for manipulation of the EPG for VDR > 1.7.26 +- Try to discard very long events that override more than one existing event +- Equivalents stored in map for all equivalents for better handling +- Move equivalence to separate file/class +- Move utilities to separate files +- Added cAddEventThread from VDR EPGFixer Plug-in to update equivalent channels in separate thread +- Try to discard very long events that override more than one existing event +- Use map instead of list in cAddEventThread to reduce sorting +- Move cEIT2 in a separate file and try to use it in epghandler also +- Drop unmanaged NOEPG support, there is a separate plugin for that +- Drop unmanaged Disable Double EPG entry. EEPG tries to handle this anyway +- Aditional fixes logged at http://projects.vdr-developer.org/git/vdr-plugin-eepg.git/ Release 0.0.5: -changed TableId's so that Now/Next overwrites Nagra which overwrites MHW diff --git a/README b/README index 328ad04..20a9f89 100644 --- a/README +++ b/README @@ -1,23 +1,40 @@ -This is the Extended EPG (EEPG) plugin for VDR. +This is the Extended EPG (EEPG) "plugin" for the Video Disk Recorder (VDR). +Written by: Dingo35 -See the file COPYING for license information. +Mainnained by: Dimitar Petrovski + +Project's homepage: http://projects.vdr-developer.org/projects/plg-eepg + +Latest stable version available at: + http://projects.vdr-developer.org/git/vdr-plugin-eepg.git/snapshot/vdr-plugin-eepg-master.tar.bz2 +Latest experimental version available at: + http://projects.vdr-developer.org/git/vdr-plugin-eepg.git/snapshot/vdr-plugin-eepg-experimental.tar.bz2 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. +See the file COPYING for more information. ---------------------------------------------------------------------- +Description: + This plugin parses the extended (2 to 10 day) EPG data which is send by providers on their portal channels. This EEPG data is transmitted in a non-standard format on a non-standard PID. Currently the following EEPG formats are supported: --Mediahighway 1 (CanaalDigitaalNL, CSat, Cyfra+) --Mediahighway 2 (Digital+) --Sky Italy --Sky UK --Freesat --Premiere --NagraGuide (CanaalDigitaalNL, only in test) +* Mediahighway 1 (CanaalDigitaalNL, CSat, Cyfra+) +* Mediahighway 2 (Digital+) +* Sky Italy +* Sky UK +* Freesat +* Premiere +* NagraGuide (CanaalDigitaalNL, only in test) +* NA Dish and BEV INSTALL Unpack, make and make plugins like any other plugin. Call like any other @@ -29,6 +46,10 @@ E.g., CanaalDigitaalNL still sends Dorcel EEPG data on S19.2E, which can be used for Dorcel on S13.0E. Some sample eepg.equiv files are included. +Scripts +The provided scripts in the package can also help generate the eepg.equiv file. +For more information see README in scripts/ + USE The plugin has no mainmenu entry, and only a few settings for Premiere. When one of VDR's devices is tuned to a transponder (by tuning, a recording or @@ -36,7 +57,7 @@ an EPG scan triggered by VDR), the plugin scans all channels on the transponder for the supported EEPG formats. When all of the supported formats are detected, all available EEPG data is loaded into the schedule of VDR. Additionally, the EEPG data is loaded into additional channels if they are specified -in the eepg.equiv file (not for Premiere or Freesat). +in the eepg.equiv file (not for Premiere). Everything is done automatically and transparently, all is done concurrently with recordings and live viewings. Freesat and Premiere are loading their EEPG info continuously. @@ -54,15 +75,15 @@ New, unknown EEPG transponders will be detected automatically (MHW1, MHW2, Frees have to be added (Sky uses different huffman decoding tables for every country). Currently known transponders that send EEPG data: --Sky Italia S13.0E:11881V (OpenTV) --Sky UK S28.2E:11778V (OpenTV) --Cyfra+ S13.0E:10719V (Mediahighway 1) --CSat S19.2E:12363V (Mediahighway 1) --Canal DigitaalNL S19.2E:12515H (Mediahighway 1, NagraGuide) --Digital+ S19.2E:10847V (Mediahighway 2) --Premiere Sport Portal, Premiere Direkt Portal --Freesat all freesat channels --Dish and BEV S119.0W:12472H S91.0W12224R +* Sky Italia S13.0E:11881V (OpenTV) +* Sky UK S28.2E:11778V (OpenTV) +* Cyfra+ S13.0E:10719V (Mediahighway 1) +* CSat S19.2E:12363V (Mediahighway 1) +* Canal DigitaalNL S19.2E:12515H (Mediahighway 1, NagraGuide) +* Digital+ S19.2E:10847V (Mediahighway 2) +* Premiere Sport Portal, Premiere Direkt Portal +* Freesat all freesat channels +* Dish and BEV S119.0W:12472H S91.0W12224R Please note that the NagraGuide broadcasts of Canal DigitaalNL are stil in betatest; therefore its information is not always reliable. It seems that sometimes, when no summaries @@ -84,13 +105,14 @@ The plugin setup menu is only for Premiere protocol! THANKS This code is based on: - -Premiere plugin (C) 2005-2007 Stefan Huelswitt - -mhwepg program (C) 2002, 2003 Jean-Claude Repetto - -LoadEpg plugin written by Luca De Pieri - -Freesat patch written by dom /at/ suborbital.org.uk - -Dish/BEV patch written by +* Premiere plugin (C) 2005-2007 Stefan Huelswitt +* mhwepg program (C) 2002, 2003 Jean-Claude Repetto +* LoadEpg plugin written by Luca De Pieri +* Freesat patch written by dom /at/ suborbital.org.uk +* Dish/BEV patch written by +* cAddEventThread from EPGFixer plugin by Matti Lehtimaki matti.lehtimaki /at/ gmail.com Thanks to mrgandalf, and the others who helped map NA eit. -Thanks to VDR User for testing. +Thanks to VDR User for testing and providing <> script. We wish to thank all authors for the great work they have been doing, decoding this EEPG data; this plugin tries to combine the best of all worlds. @@ -106,7 +128,7 @@ information. KNOWN BUGS --Equivalents file is not used for Freesat, Premiere. +-Equivalents file is not used for Premiere. -On Sky Italy and Sky UK, a lot of "summaries not found" are reported. This is because it is not (yet) known where the "summary available" flag is coded in the OpenTV protocol used, so all titles are assumed to have a summary available. diff --git a/TODO b/TODO index 888e3f2..50c9f51 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,5 @@ TODO/WISH: +-Missing support for Freesat DVB-T -extend equivalents file with transponder SKIP (do not retrieve EEPG info) or transponder ONCE (retrieve once a day, first possiblity after midnight). TUNE (retrieve every time transponder gets tuned to) transponder CONT (retrieve continuously) @@ -9,6 +10,5 @@ TODO/WISH: -stop premiere after having read all titles (from CONT to ONCE) -check version info for all providers -decode summary-available bit for OpenTV --include DDEPG functionality -parallellize when not on FF card -NAGRA 2nd textstring is not used right now, find out when it is relevant... diff --git a/scripts/README b/scripts/README new file mode 100644 index 0000000..22e2835 --- /dev/null +++ b/scripts/README @@ -0,0 +1,28 @@ +extract_vdr_chan_ids.pl +The script extract_vdr_chan_ids.pl can be used along with grep to extract the IDs +of required channel i.e.: + +USAGE: + extract_vdr_chan_ids.pl [/path/to/channels.conf] + +EXAMPES: + extract_vdr_chan_ids.pl /path/to/channels.conf | grep -i Chanel Name + +makeequiv.sh thanks to VDR User +The makeequiv.sh bash script can be used to generate an eepg.equiv +file based on SID matching. You may optionally require channel name +matching as well. + +USAGE: + makeequiv.sh [channels.conf] [listsources|source to map epg from] + +EXAMPES: + makequiv.sh /video/channels.conf listsources + * shows a list of all available sources in channels.conf + + makeequiv.sh /video/channels.conf S72.7W + * map epg from S72.7W channels based on SID match + + makeequiv.sh /video/channels.conf S72.7W matchname + * map epg from S72.7W channels based on SID and channel name match + diff --git a/scripts/extract_vdr_chan_ids.pl b/scripts/extract_vdr_chan_ids.pl new file mode 100755 index 0000000..e40bbb9 --- /dev/null +++ b/scripts/extract_vdr_chan_ids.pl @@ -0,0 +1,38 @@ +#!/usr/bin/perl -w +# +# extract VDR channel ID's from channels conf +# + +use strict; +use File::Path; + +my $channelsConf = "../channels.conf"; +my $Usage = qq{ +Usage: $0 (default: ../channels.conf) + $0 /path/to/channels.conf +}; + +$channelsConf = "@ARGV" if @ARGV; + +#my $file; +open(MYINPUTFILE, "<$channelsConf") or die("Could not open $channelsConf" . $Usage); + +foreach () +{ + chomp; + if ( /^:.*/ ) + { + print $_ . "\n"; + next; + } + + my($line) = $_; + + my(@tokens) = split(":"); + + my($chanID) = "$tokens[3]-$tokens[10]-$tokens[11]-$tokens[9] $tokens[0]"; + + print $chanID . "\n" + +} + diff --git a/scripts/makeequiv.sh b/scripts/makeequiv.sh new file mode 100755 index 0000000..1be3e80 --- /dev/null +++ b/scripts/makeequiv.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +equiv_file="eepg.equiv" + +usage() { + echo + [[ "$@" ]] && echo -e "ABORTED! $@\n" + echo -e "usage: ${0##*/} [channels.conf] [listsources|source to map epg from] " + echo -e " * the 3rd argument is optional. if its \"matchname\", channel name matching is required for a positive match.\n" + exit +} + +getsources() { awk -F: '{print $4}' "$1" |sort -V |uniq; } +listsources() { getsources "$1"; exit; } + +(($# < 2)) && usage +[[ -e "$1" ]] || usage "$1 not found" +[[ "$2" == "listsources" ]] && listsources "$1" +[[ $(getsources "$1" |grep "$2$") ]] || usage "$2 is not a source in $1" +[[ "$3" == "matchname" ]] && match_name=1 || match_name=0 +[[ -e "$equiv_file" ]] && rm "$equiv_file" +echo +tput sc +OLDIFS=$IFS; IFS=$'\n' +for i in $(awk -F: -v var="$2" '$4==var' "$1"); do + matched=0 + mapto_name=" ${i%%:*}" + mapto_sid=$(awk -F: '{print $10}' <<<"$i") + mapto_line=$(awk -F: '{print $4"-"$11"-"$12"-"$10"-"$13}' <<<"$i") + mapto_source=$(awk -F: '{print $4}' <<<"$i") + for j in $(awk -F: -v var1="$2" -v var2="$mapto_sid" '$4!=var1 && $10==var2' "$1"); do + mapfrom_source=$(awk -F: '{print $4}' <<<"$j") + mapfrom_line=$(awk -F: '{print $4"-"$11"-"$12"-"$10"-"$13}' <<<"$j") + matched=1 + (($match_name)) && { + [[ " ${j%%:*}" == "$mapto_name" ]] || matched=0 + } || unset mapto_name + done + (($matched)) && { + ((matchcount++)) + outline="$mapfrom_line $mapto_line$mapto_name" + echo "$outline" >>"$equiv_file" + } || { + ((unmatchcount++)) + array+=( "$i" ) + unset outline + } + tput rc + tput el + echo "$outline" + echo -n "matched: $matchcount - unmatched: $unmatchcount" +done +IFS=$OLDIFS +echo -e "\n" +((${#array[@]} > 0)) && for i in "${array[@]}"; do echo "NO MATCH: $i"; done +echo "wrote $equiv_file ($matchcount entries)." -- cgit v1.2.3 From fabd731b78f9c221cb6f6090308005835d09d67d Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 30 Oct 2012 18:40:41 +0100 Subject: fixed documentation removed forgotten noepg ifdef fixed cppcheck errors --- README | 4 ++-- dish.c | 5 ++++- dish.h | 1 + eepg.c | 5 ----- setupeepg.h | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README b/README index 20a9f89..edde5b7 100644 --- a/README +++ b/README @@ -83,7 +83,7 @@ Currently known transponders that send EEPG data: * Digital+ S19.2E:10847V (Mediahighway 2) * Premiere Sport Portal, Premiere Direkt Portal * Freesat all freesat channels -* Dish and BEV S119.0W:12472H S91.0W12224R +* Dish and BEV S119.0W:12472H S91.0W12224R Please note that the NagraGuide broadcasts of Canal DigitaalNL are stil in betatest; therefore its information is not always reliable. It seems that sometimes, when no summaries @@ -112,7 +112,7 @@ This code is based on: * Dish/BEV patch written by * cAddEventThread from EPGFixer plugin by Matti Lehtimaki matti.lehtimaki /at/ gmail.com Thanks to mrgandalf, and the others who helped map NA eit. -Thanks to VDR User for testing and providing <> script. +Thanks to VDR User for testing and providing makequiv.sh script for S72.7W channels. We wish to thank all authors for the great work they have been doing, decoding this EEPG data; this plugin tries to combine the best of all worlds. diff --git a/dish.c b/dish.c index 662e170..d257d91 100644 --- a/dish.c +++ b/dish.c @@ -56,6 +56,7 @@ namespace SI originalAirDate = 0; programId = NULL; seriesId = NULL; + ratingStr = NULL; } DishDescriptor::~DishDescriptor() @@ -418,7 +419,9 @@ namespace SI str += "]"; } - return str.c_str(); + if (!ratingStr) ratingStr = new char[19]; + if (ratingStr) strcpy(ratingStr,str.c_str()); + return ratingStr; // return isempty(buffer) ? "" : buffer; } diff --git a/dish.h b/dish.h index 369a4fd..f891d7b 100644 --- a/dish.h +++ b/dish.h @@ -284,6 +284,7 @@ protected: time_t originalAirDate; char* seriesId; char* programId; + char* ratingStr; struct HuffmanTable { diff --git a/eepg.c b/eepg.c index 52af9df..fc7a5b0 100644 --- a/eepg.c +++ b/eepg.c @@ -3316,11 +3316,6 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) } tChannelID channelID (Source (), nid, tid, sid); cChannel *channel = Channels.GetByChannelID (channelID, true); -#ifdef USE_NOEPG - // only use epg from channels not blocked by noEPG-patch - if (!allowedEPG (channelID)) - continue; -#endif /* NOEPG */ if (!channel) continue; diff --git a/setupeepg.h b/setupeepg.h index 4c30ede..0db20d1 100644 --- a/setupeepg.h +++ b/setupeepg.h @@ -33,7 +33,7 @@ public: void setConfDir(char* confDir) { if (ConfDir) - delete ConfDir; + delete [] ConfDir; ConfDir = new char[strlen(confDir)+1]; strcpy(ConfDir, confDir); } -- cgit v1.2.3 From 250c584c8b52ca6fadc75acc1f8f9e6c2830c014 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 31 Oct 2012 00:35:45 +0100 Subject: prevend FixEpgBugs for NA channels to keep formating --- eit2.c | 6 ++++-- epghandler.c | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/eit2.c b/eit2.c index 87064c5..3980dba 100644 --- a/eit2.c +++ b/eit2.c @@ -427,8 +427,10 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, // LogD(2, prep("ID: %d Title: %s Time: %d Tid: 0x%x"), pEvent->EventID(), pEvent->Title(), pEvent->StartTime(), pEvent->TableID()); // } - // if (!HasExternalData) - pEvent->FixEpgBugs (); + //FixEpgBugs removes newlines from description which is not wanted especially for DISH/BEV + if (Format != DISH_BEV) + pEvent->FixEpgBugs(); + if (LinkChannels) channel->SetLinkChannels (LinkChannels); } diff --git a/epghandler.c b/epghandler.c index a1b92c3..49c89e4 100644 --- a/epghandler.c +++ b/epghandler.c @@ -10,9 +10,12 @@ #include "log.h" #include "equivhandler.h" #include "eit2.h" +#include "util.h" #include #include +using namespace util; + cEEpgHandler::cEEpgHandler() { LogD(4, prep("cEEpgHandler()")); equivHandler = new cEquivHandler(); @@ -30,6 +33,9 @@ bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, //DISH NID 0x1001 to 0x100B BEV 0x100 and 0x101 int nid = Schedule->ChannelID().Nid(); if ((nid >= 0x1001 && nid <= 0x100B) || nid == 0x101 || nid == 0x100) { + //Set the Format for Eit events so that the new lines are not erased with FixEpgBugs + if (Format != DISH_BEV) Format = DISH_BEV; + SI::cEIT2 eit2(Schedule); eit2.ProcessEitEvent(Schedule, EitEvent, TableID, Version); return true; -- cgit v1.2.3