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 27fd448d11b6eda6b72d294b73d42a54e1891ad9 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 | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/eepg.c b/eepg.c index cdfe90b..8b68ab8 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; // --- cSetupEEPG ------------------------------------------------------- @@ -508,7 +516,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; @@ -699,7 +707,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; @@ -718,7 +726,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; @@ -1431,7 +1439,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 @@ -1442,7 +1450,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); @@ -1998,7 +2006,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) { @@ -4376,7 +4384,7 @@ bool cPluginEEPG::Start (void) for (int i = 0; i < NumberOfAvailableSources; i++) isyslog ("EEPG: Available sources:%s.", *cSource::ToString (AvailableSources[i])); - + closedir(ConfigDir); return true; } -- 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