From 2897776ceea4177e110b22e7efefd5dce50304a8 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sun, 28 Oct 2012 16:53:08 +0100 Subject: Extract the the Short Text from the Extended description for MHW2 and Sky --- eepg.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 7 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index 2ba6008..a53d823 100644 --- a/eepg.c +++ b/eepg.c @@ -222,7 +222,7 @@ protected: //virtual void FinishWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]); virtual void WriteToSchedule (tChannelID channelID, cSchedules* s, unsigned int EventId, unsigned int StartTime, unsigned int Duration, char *Text, char *SummText, unsigned short int ThemeId, - unsigned short int TableId, unsigned short int Version, char Rating = 0x00); + unsigned short int TableId, unsigned short int Version, char Rating = 0x00, unsigned char ShortTextLenght = 0); virtual void LoadIntoSchedule (void); //virtual void LoadEquivalentChannels (void); @@ -1235,7 +1235,11 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse * \param Duration the Duration of the event in minutes * \param ps points to array of schedules ps[eq], where eq is equivalence number of the channel. If channelId is invalid then ps[eq]=NULL */ -void cFilterEEPG::WriteToSchedule (tChannelID channelID, cSchedules* pSchedules, unsigned int EventId, unsigned int StartTime, unsigned int Duration, char *Text, char *SummText, unsigned short int ThemeId, unsigned short int TableId, unsigned short int Version, char Rating) +void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, + unsigned int EventId, unsigned int StartTime, unsigned int Duration, + char *Text, char *SummText, unsigned short int ThemeId, + unsigned short int TableId, unsigned short int Version, char Rating, + unsigned char ShTxtLen) { bool WrittenTitle = false; bool WrittenSummary = false; @@ -1277,21 +1281,53 @@ void cFilterEEPG::WriteToSchedule (tChannelID channelID, cSchedules* pSchedules, if (Rating) { Event->SetParentalRating(Rating); } - char *tmp; if (Text != 0x00) { WrittenTitle = true; CleanString ((uchar *) Text); Event->SetTitle (Text); } - Asprintf (&tmp, "%s - %d\'", Themes[ThemeId], Duration); + + char *tmp = NULL; + if (SummText && ShTxtLen) { + + //TODO DPE template + tmp = (char *) malloc(2*ShTxtLen); + if (!tmp) { + LogE(0, prep("tmp memory allocation error.")); + return; + } +// decodeText2((unsigned char *)SummText, ShTxtLen, tmp, ShTxtLen + 1); + memcpy(tmp, SummText, ShTxtLen); + tmp[ShTxtLen] = '\0'; + + //Do not use Subtitle if it is substring of Title + if (strncmp(Text, tmp, ShTxtLen) == 0) { + free(tmp); + tmp = NULL; + } + + } + if (!tmp) + Asprintf (&tmp, "%s - %d\'", Themes[ThemeId], Duration); Event->SetShortText (tmp); free(tmp); + +/* + char *tmp; + if (!ShortText || strcmp(ShortText, Text) == 0) { + Asprintf (&tmp, "%s - %d\'", Themes[ThemeId], Duration); + Event->SetShortText (tmp); + free(tmp); + } else + Event->SetShortText (ShortText); +*/ //strreplace(t, '|', '\n'); if (SummText != 0x00) { WrittenSummary = true; CleanString ((uchar *) SummText); //Add themes and categories epgsearch style + //TODO DPE move this char *theme; Asprintf (&theme, "%s", Themes[ThemeId]); if (theme && 0 != strcmp(theme,"")) { @@ -2008,6 +2044,7 @@ int cFilterEEPG::GetSummariesMHW1 (const u_char * Data, int Length) S->NumReplays = Summary->NumReplays; S->EventId = HILO32 (Summary->ProgramId); S->Text = Text; + S->ShortTextLength = 0; //TODO find for MHW1 int i = 0; do { S->Replays[i].MjdTime = 0; //only used for SKY @@ -2118,14 +2155,18 @@ int cFilterEEPG::GetSummariesMHW2 (const u_char * Data, int Length) } } S->Text = (unsigned char *) malloc (SummaryLength + 2); - S->Text[SummaryLength] = '\0'; //end string with NULL character if (S->Text == NULL) { LogE(0, prep("Summaries memory allocation error.")); return 0; //fatal error } + S->Text[SummaryLength] = '\0'; //end string with NULL character + //memcpy (S->Text, tmp, SummaryLength); decodeText2(tmp,SummaryLength,(char*)S->Text,SummaryLength + 1); CleanString (S->Text); + char * delim = strchr ( (char *)S->Text, '\n' ); + S->ShortTextLength = delim == NULL ? 0 : delim - (char *)S->Text; + LogI(3, prep("EventId %08x Summnr %d:%.30s."), S->EventId, nSummaries, S->Text); nSummaries++; } else { @@ -2349,6 +2390,7 @@ int cFilterEEPG::GetSummariesSKYBOX (const u_char * Data, int Length) unsigned short int MjdTime; int Len1; int Len2; + const char* STxtDelim = Format == SKY_UK?": ":" - "; if (Length < 20) { return 1; //non fatal error I assume @@ -2372,6 +2414,7 @@ int cFilterEEPG::GetSummariesSKYBOX (const u_char * Data, int Length) S->Replays[0].MjdTime = MjdTime; S->NumReplays = 0; //not used S->EventId = (Data[p] << 8) | Data[p + 1]; + S->ShortTextLength = 0; Len1 = ((Data[p + 2] & 0x0f) << 8) | Data[p + 3]; if (Data[p + 4] != 0xb9) { LogD(5, prep("Data error signature for title - Data[p + 4] != 0xb5")); @@ -2397,6 +2440,8 @@ int cFilterEEPG::GetSummariesSKYBOX (const u_char * Data, int Length) memcpy (S->Text, tmp, Len2); S->Text[Len2] = '\0'; //end string with NULL character CleanString (S->Text); + char * delim = strstr ( (char *)S->Text, STxtDelim ); + S->ShortTextLength = delim == NULL ? 0 : delim - (char *)S->Text; LogI(3, prep("EventId %08x Summnr %d:%.30s."), S->EventId, nSummaries, S->Text); p += Len1; nSummaries++; @@ -2518,9 +2563,13 @@ void cFilterEEPG::LoadIntoSchedule (void) TableId = T->TableId; } +// LogD (0, prep("EventId %08x Titlenr %d:SummAv:%x,Un1:%x,Un2:%x,Un3:%x,Name:%s,STxtLn:%dSummary:%s."), +// T->EventId, i, T->SummaryAvailable, T->Unknown1, T->Unknown2, T->Unknown3, T->Text, S->ShortTextLength, S->Text); + WriteToSchedule (chanID, s, T->EventId, StartTime, T->Duration / 60, (char *) T->Text, - (char *) S->Text, T->ThemeId, TableId, 0, rating); + (char *) S->Text, T->ThemeId, TableId, 0, rating, S->ShortTextLength); sortSchedules(s, chanID); + //if (shortText != NULL) delete [] shortText; //FinishWriteToSchedule (C, s, p); //Replays--; @@ -2563,7 +2612,7 @@ void cFilterEEPG::LoadIntoSchedule (void) rating = T->Rating; } WriteToSchedule (chanID, s, T->EventId, T->StartTime, T->Duration / 60, (char *) T->Text, - NULL, T->ThemeId, DEFAULT_TABLE_ID, 0, rating); + NULL, T->ThemeId, DEFAULT_TABLE_ID, 0, rating, S->ShortTextLength); //FinishWriteToSchedule (C, s, p); sortSchedules(s, chanID); -- cgit v1.2.3 From 023c24e88bae40f472cb0c37fc02ea67d4a5b5bc Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Mon, 29 Oct 2012 11:18:28 +0100 Subject: use std string for manipulation of Short Text from description --- eepg.c | 55 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 18 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index c740f8e..0afecc7 100644 --- a/eepg.c +++ b/eepg.c @@ -266,6 +266,13 @@ void cFilterEEPG::SetStatus (bool On) for (int i = 0; i <= HIGHEST_FORMAT; i++) UnprocessedFormat[i] = 0; //pid 0 is assumed to be nonvalid for EEPG transfers AddFilter (0, 0); + if (Channel()->Nid() == 0x01) { + setenv("VDR_CHARSET_OVERRIDE", "ISO-8859-9", true); + LogD(0, prep("setenv VDR_CHARSET_OVERRIDE ISO-8859-9")); + } else { + unsetenv("VDR_CHARSET_OVERRIDE"); + LogD(0, prep("clear VDR_CHARSET_OVERRIDE")); + } } cFilter::SetStatus (On); Trigger (); @@ -1288,30 +1295,43 @@ void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, } char *tmp = NULL; + string shText; if (SummText && ShTxtLen) { - //TODO DPE template - tmp = (char *) malloc(2*ShTxtLen); - if (!tmp) { - LogE(0, prep("tmp memory allocation error.")); - return; + shText.assign(SummText,ShTxtLen); + + string tmpTitle(Text); + if (Format == MHW2 && !shText.empty()) { + //TODO (HD) channels + size_t found = tmpTitle.find(" (HD)"); + if (found != string::npos) + tmpTitle.erase(found, 5); + found = shText.compare(0, tmpTitle.size() + 2, string(tmpTitle + ": ")); + if (shText.compare(0, tmpTitle.size() + 2, string(tmpTitle + ": "))==0) + shText.erase(0, tmpTitle.size() + 2); } -// decodeText2((unsigned char *)SummText, ShTxtLen, tmp, ShTxtLen + 1); - memcpy(tmp, SummText, ShTxtLen); - tmp[ShTxtLen] = '\0'; - //Do not use Subtitle if it is substring of Title - if (strncmp(Text, tmp, ShTxtLen) == 0) { - free(tmp); - tmp = NULL; - } + //Do not use Subtitle if it is substring of Title + if (tmpTitle.compare(0, shText.size(), shText) == 0) + shText.clear(); + +#define MAX_USEFUL_EPISODE_LENGTH 40 + // From VDR FixEPG Bugs + // Some channels put a whole lot of information in the ShortText and leave + // the Description totally empty. So if the ShortText length exceeds + // MAX_USEFUL_EPISODE_LENGTH, let's put this into the Description + // instead: + if (!shText.empty() && shText.size() > MAX_USEFUL_EPISODE_LENGTH) + shText.clear(); } - if (!tmp) + if (!shText.empty()) + Event->SetShortText (shText.c_str()); + else { Asprintf (&tmp, "%s - %d\'", Themes[ThemeId], Duration); - Event->SetShortText (tmp); - free(tmp); - + Event->SetShortText (tmp); + free(tmp); + } /* char *tmp; if (!ShortText || strcmp(ShortText, Text) == 0) { @@ -2159,7 +2179,6 @@ int cFilterEEPG::GetSummariesMHW2 (const u_char * Data, int Length) LogE(0, prep("Summaries memory allocation error.")); return 0; //fatal error } - //memcpy (S->Text, tmp, SummaryLength); //S->Text[SummaryLength] = '\0'; //end string with NULL character decodeText2(tmp,SummaryLength,(char*)S->Text,2 * SummaryLength + 1); -- cgit v1.2.3 From 89602f07f60672d0d7ab1dbf8f06be9e8f6566d1 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Mon, 29 Oct 2012 11:33:53 +0100 Subject: Try to fix the charset override by setting the envioronment variable Add option to setup not to set Category and Genere to empty short texts --- eepg.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index 0afecc7..5bcd1d4 100644 --- a/eepg.c +++ b/eepg.c @@ -121,7 +121,9 @@ cMenuSetupPremiereEpg::cMenuSetupPremiereEpg (void) 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)); + SetSection (tr ("General")); Add (new cMenuEditBoolItem (tr ("Display summary message"), &data->DisplayMessage)); + Add (new cMenuEditBoolItem (tr ("Replace Empty Short Text with Category - Genre"), &data->ReplaceEmptyShText)); #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)); @@ -136,6 +138,7 @@ void cMenuSetupPremiereEpg::Store (void) SetupStore ("RatingInfo", SetupPE->RatingInfo); SetupStore ("FixEpg", SetupPE->FixEpg); SetupStore ("DisplayMessage", SetupPE->DisplayMessage); + SetupStore ("ReplaceEmptyShText", SetupPE->ReplaceEmptyShText); #ifdef DEBUG SetupStore ("LogLevel", SetupPE->LogLevel); SetupStore ("ProcessEIT", SetupPE->ProcessEIT); @@ -1294,7 +1297,8 @@ void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, Event->SetTitle (Text); } - char *tmp = NULL; + char* tmp = NULL; + string shText; string shText; if (SummText && ShTxtLen) { @@ -1327,7 +1331,7 @@ void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, } if (!shText.empty()) Event->SetShortText (shText.c_str()); - else { + else if (SetupPE->ReplaceEmptyShText) { Asprintf (&tmp, "%s - %d\'", Themes[ThemeId], Duration); Event->SetShortText (tmp); free(tmp); @@ -2842,6 +2846,14 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len // LogD(2, prep("Pid: 0x%02x Tid: %d Length: %d PMT pid: 0x%04x"), Pid, Tid, Length, pmtpid); // LogD(2, prep("Source: %d Transponder: %d"), Source () , Transponder ()); + if (Channel()->Nid() == 0x01) { + setenv("VDR_CHARSET_OVERRIDE", "ISO-8859-9", true); + LogD(0, prep("setenv VDR_CHARSET_OVERRIDE ISO-8859-9")); + } + else { + unsetenv("VDR_CHARSET_OVERRIDE"); + LogD(0, prep("clear VDR_CHARSET_OVERRIDE")); + } if (Pid == 0 && Tid == SI::TableIdPAT) { if (!pmtnext || now > pmtnext) { if (pmtpid) @@ -3687,6 +3699,8 @@ bool cPluginEEPG::SetupParse (const char *Name, const char *Value) SetupPE->FixEpg = atoi (Value); else if (!strcasecmp (Name, "DisplayMessage")) SetupPE->DisplayMessage = atoi (Value); + else if (!strcasecmp (Name, "ReplaceEmptyShText")) + SetupPE->ReplaceEmptyShText = atoi (Value); #ifdef DEBUG else if (!strcasecmp (Name, "LogLevel")) SetupPE->LogLevel = atoi (Value); -- cgit v1.2.3 From 168f5d7c0b3b2b543ece04ccf09616c8a6b302b2 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Mon, 29 Oct 2012 11:38:01 +0100 Subject: error in merge --- eepg.c | 1 - 1 file changed, 1 deletion(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index 5bcd1d4..370c848 100644 --- a/eepg.c +++ b/eepg.c @@ -1299,7 +1299,6 @@ void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, char* tmp = NULL; string shText; - string shText; if (SummText && ShTxtLen) { shText.assign(SummText,ShTxtLen); -- cgit v1.2.3 From e6817415cfb958010c64f22b98f4536817223098 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 30 Oct 2012 11:24:18 +0100 Subject: add separators in setup menu change charset export logic change thread times --- eepg.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index 370c848..7239c23 100644 --- a/eepg.c +++ b/eepg.c @@ -111,7 +111,13 @@ public: cMenuSetupPremiereEpg::cMenuSetupPremiereEpg (void) { data = cSetupEEPG::getInstance(); - SetSection (tr ("PremiereEPG")); + cOsdItem *item = new cOsdItem(tr ("PremiereEPG")); + + if (item) { + item->SetSelectable(false); + Add(item); + } +// AddCategory (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); @@ -121,7 +127,12 @@ cMenuSetupPremiereEpg::cMenuSetupPremiereEpg (void) 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)); - SetSection (tr ("General")); + item = new cOsdItem(tr ("General")); + if (item) { + item->SetSelectable(false); + Add(item); + } +// AddCategory (tr ("General")); Add (new cMenuEditBoolItem (tr ("Display summary message"), &data->DisplayMessage)); Add (new cMenuEditBoolItem (tr ("Replace Empty Short Text with Category - Genre"), &data->ReplaceEmptyShText)); #ifdef DEBUG @@ -178,6 +189,7 @@ private: bool EndChannels, EndThemes; //only used for ?? int MHWStartTime; //only used for MHW1 bool ChannelsOk; + int prevNid; //int Format; //the format that this filter currently is processing std::map < int, int >ChannelSeq; // ChannelSeq[ChannelId] returns the recordnumber of the channel @@ -243,6 +255,7 @@ cFilterEEPG::cFilterEEPG (void) { nSummaries = 0; nTitles = 0; + prevNid = 0; Trigger (); //Set (0x00, 0x00); } @@ -269,12 +282,16 @@ void cFilterEEPG::SetStatus (bool On) for (int i = 0; i <= HIGHEST_FORMAT; i++) UnprocessedFormat[i] = 0; //pid 0 is assumed to be nonvalid for EEPG transfers AddFilter (0, 0); - if (Channel()->Nid() == 0x01) { - setenv("VDR_CHARSET_OVERRIDE", "ISO-8859-9", true); - LogD(0, prep("setenv VDR_CHARSET_OVERRIDE ISO-8859-9")); - } else { - unsetenv("VDR_CHARSET_OVERRIDE"); - LogD(0, prep("clear VDR_CHARSET_OVERRIDE")); + int nid = Channel()->Nid(); + if (nid != prevNid) { + if (nid == 0x01 && prevNid != 0x01) { + setenv("VDR_CHARSET_OVERRIDE", "ISO-8859-9", true); + LogD(0, prep("setenv VDR_CHARSET_OVERRIDE ISO-8859-9")); + } else if (nid != 0x01 && (prevNid == 0x01 || prevNid == 0)){ + unsetenv("VDR_CHARSET_OVERRIDE"); + LogD(0, prep("clear VDR_CHARSET_OVERRIDE")); + } + prevNid = nid; } } cFilter::SetStatus (On); @@ -2845,14 +2862,6 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len // LogD(2, prep("Pid: 0x%02x Tid: %d Length: %d PMT pid: 0x%04x"), Pid, Tid, Length, pmtpid); // LogD(2, prep("Source: %d Transponder: %d"), Source () , Transponder ()); - if (Channel()->Nid() == 0x01) { - setenv("VDR_CHARSET_OVERRIDE", "ISO-8859-9", true); - LogD(0, prep("setenv VDR_CHARSET_OVERRIDE ISO-8859-9")); - } - else { - unsetenv("VDR_CHARSET_OVERRIDE"); - LogD(0, prep("clear VDR_CHARSET_OVERRIDE")); - } if (Pid == 0 && Tid == SI::TableIdPAT) { if (!pmtnext || now > pmtnext) { if (pmtpid) -- cgit v1.2.3 From fddfe7581dc85bf74bae1aa7d12304acd941f351 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 20 Nov 2012 18:58:11 +0100 Subject: new way of fixing of charset without patching VDR, unfortunately this makes two more conversions handle some more duplicate events in the event handler extract category and genre when needed --- eepg.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index 7060168..0c4608c 100644 --- a/eepg.c +++ b/eepg.c @@ -189,7 +189,6 @@ private: bool EndChannels, EndThemes; //only used for ?? int MHWStartTime; //only used for MHW1 bool ChannelsOk; - int prevNid; //int Format; //the format that this filter currently is processing std::map < int, int >ChannelSeq; // ChannelSeq[ChannelId] returns the recordnumber of the channel @@ -255,7 +254,6 @@ cFilterEEPG::cFilterEEPG (void) { nSummaries = 0; nTitles = 0; - prevNid = 0; Trigger (); //Set (0x00, 0x00); } @@ -282,7 +280,7 @@ void cFilterEEPG::SetStatus (bool On) for (int i = 0; i <= HIGHEST_FORMAT; i++) UnprocessedFormat[i] = 0; //pid 0 is assumed to be nonvalid for EEPG transfers AddFilter (0, 0); - int nid = Channel()->Nid(); +/* int nid = Channel()->Nid(); if (nid != prevNid) { if (nid == 0x01 && prevNid != 0x01) { setenv("VDR_CHARSET_OVERRIDE", "ISO-8859-9", true); @@ -293,6 +291,7 @@ void cFilterEEPG::SetStatus (bool On) } prevNid = nid; } + */ } cFilter::SetStatus (On); Trigger (); @@ -1322,7 +1321,6 @@ void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, string tmpTitle(Text); if (Format == MHW2 && !shText.empty()) { - //TODO (HD) channels size_t found = tmpTitle.find(" (HD)"); if (found != string::npos) tmpTitle.erase(found, 5); @@ -1331,10 +1329,15 @@ void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, shText.erase(0, tmpTitle.size() + 2); } - //Do not use Subtitle if it is substring of Title + //Do not use Subtitle if it is substring of Title if (tmpTitle.compare(0, shText.size(), shText) == 0) shText.clear(); + //The subtitle is wrong if contains '.' + if (Format == SKY_UK && !shText.empty() && shText.find('.') != string::npos) { + shText.clear(); + } + #define MAX_USEFUL_EPISODE_LENGTH 40 // From VDR FixEPG Bugs // Some channels put a whole lot of information in the ShortText and leave @@ -1366,6 +1369,18 @@ void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, WrittenSummary = true; CleanString ((uchar *) SummText); + //Fix MHW1 formating + if (Format == MHW1) { + char * pch; + pch=strchr(SummText,'s'); + while (pch!=NULL) + { + if (*(pch-1) != ' ' && *(pch-1) != '\n') + *pch = ' '; + pch=strchr(pch+1,'s'); + } + } + //Add themes and categories epgsearch style //TODO DPE move this char *theme; @@ -2070,7 +2085,7 @@ int cFilterEEPG::GetSummariesMHW1 (const u_char * Data, int Length) LogE(0, prep("Summaries memory allocation error.")); return 0; } - Text[SummaryLength+1] = '\0'; //end string with NULL character + //Text[SummaryLength+1] = '\0'; //end string with NULL character //memcpy (Text, &Data[SummaryOffset], SummaryLength); decodeText2(&Data[SummaryOffset], SummaryLength, (char*)Text, 2*SummaryLength + 1); // CleanString (Text); @@ -2083,6 +2098,8 @@ int cFilterEEPG::GetSummariesMHW1 (const u_char * Data, int Length) Summaries[nSummaries] = S; S->NumReplays = Summary->NumReplays; S->EventId = HILO32 (Summary->ProgramId); +// unsigned short SectionLength = ((Summary->SectionLengthHigh & 0x0f) << 8) | Summary->SectionLengthLow; +// Asprintf((char **)&Text, "%s \n\n SecLength:%d SLHigh:%d SLLow:%d", Text, SectionLength, Summary->SectionLengthHigh, Summary->SectionLengthLow); S->Text = Text; S->ShortTextLength = 0; //TODO find for MHW1 int i = 0; -- cgit v1.2.3 From a6207b35db9e524fef7243faab839c4d98e318f1 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 20 Nov 2012 21:56:56 +0100 Subject: code cleanup and refactoring --- eepg.c | 149 +++++------------------------------------------------------------ 1 file changed, 11 insertions(+), 138 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index 0c4608c..8a65609 100644 --- a/eepg.c +++ b/eepg.c @@ -280,18 +280,6 @@ void cFilterEEPG::SetStatus (bool On) for (int i = 0; i <= HIGHEST_FORMAT; i++) UnprocessedFormat[i] = 0; //pid 0 is assumed to be nonvalid for EEPG transfers AddFilter (0, 0); -/* int nid = Channel()->Nid(); - if (nid != prevNid) { - if (nid == 0x01 && prevNid != 0x01) { - setenv("VDR_CHARSET_OVERRIDE", "ISO-8859-9", true); - LogD(0, prep("setenv VDR_CHARSET_OVERRIDE ISO-8859-9")); - } else if (nid != 0x01 && (prevNid == 0x01 || prevNid == 0)){ - unsetenv("VDR_CHARSET_OVERRIDE"); - LogD(0, prep("clear VDR_CHARSET_OVERRIDE")); - } - prevNid = nid; - } - */ } cFilter::SetStatus (On); Trigger (); @@ -330,23 +318,6 @@ void syslog_with_tid (int priority, const char *format, ...) __attribute__ ((for #define isyslog(a...) fprintf(stderr,a) #endif - - -//struct hufftab { -// unsigned int value; -// short bits; -// char next; -//}; -// -//#define START '\0' -//#define STOP '\0' -//#define ESCAPE '\1' - - -//int freesat_decode_error = 0; /* If set an error has occurred during decoding */ - -//static struct hufftab *tables[2][128]; -//static int table_size[2][128]; static sNodeH* sky_tables[2]; /** \brief Convert a textual character description into a value @@ -765,11 +736,6 @@ nextloop1: return p; } -//here all declarations for global variables over all devices - -//char *ConfDir; - -//unsigned char DecodeErrorText[4096]; //TODO only used for debugging? bool cFilterEEPG::GetThemesSKYBOX (void) //TODO can't we read this from the DVB stream? { @@ -858,29 +824,6 @@ bool cFilterEEPG::InitDictionary (void) return true; } -//void decodeText2 (const unsigned char *from, int len, char *buffer, int buffsize) -//{ -// if (from[0] == 0x1f) { -// char *temp = freesat_huffman_decode (from, len); -// if (temp) { -// len = strlen (temp); -// len = len < buffsize - 1 ? len : buffsize - 1; -// strncpy (buffer, temp, len); -// buffer[len] = 0; -// free (temp); -// return; -// } -// } -// -// SI::String convStr; -// SI::CharArray charArray; -// charArray.assign(from, len); -// convStr.setData(charArray, len); -// //LogE(5, prep("decodeText2 from %s - length %d"), from, len); -// convStr.getText(buffer, buffsize); -// //LogE(5, prep("decodeText2 buffer %s - buffsize %d"), buffer, buffsize); -//} - /** * \brief Get MHW channels * @@ -1218,42 +1161,6 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse return (char *) Text; } -/** - * \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]*/); -//#ifdef USE_NOEPG -// if (allowedEPG (channelID) && (channelID.Valid ())) -//#else -// if (channelID.Valid ()) //only add channels that are known to vdr -//#endif /* NOEPG */ -// ps/*[eq]*/ = s->AddSchedule (channelID); //open a a schedule for each equivalent channel -// else { -// ps/*[eq]*/ = NULL; -//// LogE(5, prep("ERROR: Title block has invalid (equivalent) channel ID: Equivalence: %i, Source:%x, C->Nid:%x,C->Tid:%x,C->Sid:%x."), -//// eq, C->Src[eq], C->Nid[eq], C->Tid[eq], C->Sid[eq]); -// } -// //} -//} - -//void cFilterEEPG::FinishWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]) -//{ -// for (int eq = 0; eq < C->NumberOfEquivalences; eq++) -// if (ps[eq]) { -// ps[eq]->Sort (); -// s->SetModified (ps[eq]); -// } -//} /** * \brief write event to schedule @@ -1355,17 +1262,8 @@ void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, Event->SetShortText (tmp); free(tmp); } -/* - char *tmp; - if (!ShortText || strcmp(ShortText, Text) == 0) { - Asprintf (&tmp, "%s - %d\'", Themes[ThemeId], Duration); - Event->SetShortText (tmp); - free(tmp); - } else - Event->SetShortText (ShortText); -*/ - //strreplace(t, '|', '\n'); - if (SummText != 0x00) { + + if (SummText) { WrittenSummary = true; CleanString ((uchar *) SummText); @@ -1397,6 +1295,7 @@ void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, }else{ category = theme; } + /* string fmt; fmt = "%s"; if (stripspace(category)) { @@ -1409,6 +1308,13 @@ void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, Event->SetDescription (tmp); free(tmp); + */ + string desc = SummText; + if (stripspace(category)) desc.append("\n").append(CATEGORY).append(category); + //if (stripspace(category)) desc += '\n' << CATEGORY << category; + if (stripspace(genre)) desc += '\n' + string(GENRE) + genre; + Event->SetDescription (desc.c_str()); + free(theme); } else @@ -1988,29 +1894,7 @@ int cFilterEEPG::GetTitlesMHW2 (const u_char * Data, int Length) if (Length > 18) { int Pos = 18; int Len = 0; - /*bool Check = false; - while (Pos < Length) { - Check = false; - Pos += 7; - if (Pos < Length) { - Pos += 3; - if (Pos < Length) - if (Data[Pos] > 0xc0) { - Pos += (Data[Pos] - 0xc0); - Pos += 4; - if (Pos < Length) { - if (Data[Pos] == 0xff) { - Pos += 1; - Check = true; - } - } - } - } - if (Check == false){ - isyslog ("EEPGDebug: Check==false"); - return 1; // I assume nonfatal error or success - } - }*/ + if (memcmp (InitialTitle, Data, 16) == 0) { //data is the same as initial title return 2; //last item processed } else { @@ -3697,17 +3581,6 @@ cMenuSetupPage *cPluginEEPG::SetupMenu (void) bool cPluginEEPG::SetupParse (const char *Name, const char *Value) { -// LogF(0, "!!!! Dime test LogF"); -// LogF(0, "!!!! Dime test LogF %d", 2); -// LogI(0, "!!!! Dime test LogI"); -// LogI(0, "!!!! Dime test LogI %d", 2); -// LogI(0, prep2("!!!! Dime test prep")); -// LogI(0, prep2("!!!! Dime test prep %d"), 2); -// LogD(0, "!!!! Dime test LogD"); -// LogD(0, "!!!! Dime test LogD %d", 2); -// LogE(0, "!!!! Dime test LogE"); -// LogE(0, "!!!! Dime test LogE %d", 2); - if (!strcasecmp (Name, "OptionPattern")) SetupPE->OptPat = atoi (Value); -- cgit v1.2.3 From c72251596c42864a959aedd7d916e834aac276e9 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 21 Nov 2012 09:11:04 +0100 Subject: Moved charset fixing code to a separate class Added setup option to enable/dissable charset fixing --- eepg.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index 8a65609..29bd4d4 100644 --- a/eepg.c +++ b/eepg.c @@ -134,7 +134,8 @@ cMenuSetupPremiereEpg::cMenuSetupPremiereEpg (void) } // AddCategory (tr ("General")); Add (new cMenuEditBoolItem (tr ("Display summary message"), &data->DisplayMessage)); - Add (new cMenuEditBoolItem (tr ("Replace Empty Short Text with Category - Genre"), &data->ReplaceEmptyShText)); + Add (new cMenuEditBoolItem (tr ("Replace empty Short Text with Category - Genre"), &data->ReplaceEmptyShText)); + Add (new cMenuEditBoolItem (tr ("Try to fix CharSet for events"), &data->FixCharset)); #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)); @@ -150,6 +151,7 @@ void cMenuSetupPremiereEpg::Store (void) SetupStore ("FixEpg", SetupPE->FixEpg); SetupStore ("DisplayMessage", SetupPE->DisplayMessage); SetupStore ("ReplaceEmptyShText", SetupPE->ReplaceEmptyShText); + SetupStore ("FixCharset", SetupPE->FixCharset); #ifdef DEBUG SetupStore ("LogLevel", SetupPE->LogLevel); SetupStore ("ProcessEIT", SetupPE->ProcessEIT); @@ -3594,6 +3596,8 @@ bool cPluginEEPG::SetupParse (const char *Name, const char *Value) SetupPE->DisplayMessage = atoi (Value); else if (!strcasecmp (Name, "ReplaceEmptyShText")) SetupPE->ReplaceEmptyShText = atoi (Value); + else if (!strcasecmp (Name, "FixCharset")) + SetupPE->FixCharset = atoi (Value); #ifdef DEBUG else if (!strcasecmp (Name, "LogLevel")) SetupPE->LogLevel = atoi (Value); -- cgit v1.2.3 From e806e6ac89fa61fc6683bb14ac73d3173450226a Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Wed, 21 Nov 2012 15:38:48 +0100 Subject: change table ID numbers to enums vdr or extended --- eepg.c | 163 +++++++++++++++++++++++++---------------------------------------- 1 file changed, 63 insertions(+), 100 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index 29bd4d4..d20c1f5 100644 --- a/eepg.c +++ b/eepg.c @@ -289,7 +289,7 @@ void cFilterEEPG::SetStatus (bool On) void cFilterEEPG::NextPmt (void) { - Del (pmtpid, 0x02); + Del (pmtpid, SI::TableIdPMT); pmtpid = 0; pmtidx++; LogE(3, prep("PMT next\n")); @@ -2692,28 +2692,28 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) EndThemes = false; switch (Format) { case PREMIERE: - AddFilter (pid, 0xA0); + AddFilter (pid, SI::TableIdPremiereCIT); break; case MHW1: - AddFilter (0xd3, 0x92); //ThemesMHW1//TODO: all filters are serialized, strictly speaking Themes is non-fatal... + AddFilter (0xd3, SI::TableIdMHW1Themes); //ThemesMHW1//TODO: all filters are serialized, strictly speaking Themes is non-fatal... break; case MHW2: - AddFilter (0x231, 0xc8); //MHW2 Channels & Themes + AddFilter (0x231, SI::TableIdMHW2ChannelsThemes); //MHW2 Channels & Themes break; case SKY_IT: case SKY_UK: - AddFilter (0x11, 0x4a); //Sky Channels + AddFilter (0x11, SI::TableIdSKYChannels); //Sky Channels break; case FREEVIEW: //Freeview, CONT mode //TODO streamline this for other modes InitDictionary (); - AddFilter (pid, 0x4e, 0xfe); //event info, actual(0x4e)/other(0x4f) TS, present/following - AddFilter (pid, 0x50, 0xf0); //event info, actual TS, schedule(0x50)/schedule for future days(0x5X) - AddFilter (pid, 0x60, 0xf0); //event info, other TS, schedule(0x60)/schedule for future days(0x6X) - AddFilter (0x39, 0x50, 0xf0); //event info, actual TS, Viasat - AddFilter (0x39, 0x60, 0xf0); //event info, other TS, Viasat + AddFilter (pid, SI::TableIdEIT_presentFollowing, 0xfe); //event info, actual(0x4e)/other(0x4f) TS, present/following + AddFilter (pid, SI::TableIdEIT_schedule_first, 0xf0); //event info, actual TS, schedule(0x50)/schedule for future days(0x5X) + AddFilter (pid, SI::TableIdEIT_schedule_Other_first, 0xf0); //event info, other TS, schedule(0x60)/schedule for future days(0x6X) + AddFilter (0x39, SI::TableIdEIT_schedule_first, 0xf0); //event info, actual TS, Viasat + AddFilter (0x39, SI::TableIdEIT_schedule_Other_first, 0xf0); //event info, other TS, Viasat break; case NAGRA: - AddFilter (pid, 0xb0); //perhaps TID is equal to first data byte? + AddFilter (pid, SI::TableIdNagraCIT); //perhaps TID is equal to first data byte? break; case DISH_BEV: #if APIVERSNUM < 10726 @@ -2725,9 +2725,9 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) // AddFilter (0x0441, 0x60, 0xf0); // Bell ExpressVU EEPG break; case EIT: - AddFilter (pid, 0x4e, 0xfe); //event info, actual(0x4e)/other(0x4f) TS, present/following - AddFilter (pid, 0x50, 0xf0); //event info, actual TS, schedule(0x50)/schedule for future days(0x5X) - AddFilter (pid, 0x60, 0xf0); //event info, other TS, schedule(0x60)/schedule for future days(0x6X) + AddFilter (pid, SI::TableIdEIT_presentFollowing, 0xfe); //event info, actual(0x4e)/other(0x4f) TS, present/following + AddFilter (pid, SI::TableIdEIT_schedule_first, 0xf0); //event info, actual TS, schedule(0x50)/schedule for future days(0x5X) + AddFilter (pid, SI::TableIdEIT_schedule_Other_first, 0xf0); //event info, other TS, schedule(0x60)/schedule for future days(0x6X) break; default: break; @@ -2780,7 +2780,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len if (idx++ == pmtidx) { pmtpid = assoc.getPid (); pmtsid = assoc.getServiceId (); - Add (pmtpid, 0x02); + Add (pmtpid, SI::TableIdPMT); pmtnext = now + PMT_SCAN_TIMEOUT; LogI(3, prep("PMT pid now 0x%04x (idx=%d)\n"), pmtpid, pmtidx); break; @@ -2833,12 +2833,12 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len if (d->getLength () == 6 && d->getData ().FourBytes (2) == 0x46534154) //Freeview prvFRV = true; break; - case 0x52: + case SI::StreamIdentifierDescriptorTag: //if (d->getLength () == 3 && d->getData ().FourBytes (2) == 0xb07ea882) { if (d->getLength () == 3 && ((d->getData ().TwoBytes (2) & 0xff00) == 0xb000)) UnprocessedFormat[NAGRA] = stream.getPid (); break; - case 0x90: + case SI::SkyOTVDescriptorTag: //esyslog ("usr: %d %08x\n", d->getLength (), d->getData ().FourBytes (2)); if (d->getLength () == 6 && d->getData ().FourBytes (2) == 0x0000ffff) usrData = true; @@ -2850,19 +2850,19 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len usrOTV = SKY_UK; //Format = SKY_UK; break; - case 0xc1: //MHW1, MHW2 + case SI::MHW1DescriptorTag: //MHW1, MHW2 // esyslog("EEPGDEBUG:d->getDescriptorTAG:%d %08x\n",d->getLength(),d->getData().FourBytes(2)); if (d->getLength () == 10 && d->getData ().FourBytes (2) == 0x50555348) //MHw1 Cyfra UnprocessedFormat[MHW1] = stream.getPid (); break; - case 0xc2: //MHW1, MHW2 + case SI::MHW1_2DescriptorTag: //MHW1, MHW2 if (d->getLength () == 10 && d->getData ().FourBytes (2) == 0x45504700) //MHw1 CanDigNL and CSat UnprocessedFormat[MHW1] = stream.getPid (); else if (d->getLength () == 10 && d->getData ().FourBytes (2) == 0x46494348) { //MHW2 UnprocessedFormat[MHW2] = stream.getPid (); } break; - case 0xd1: //Freeview + case SI::FreeviewDescriptorTag: //Freeview LogD(4, prep("case 0xd1: //Freeview")); if (d->getLength () == 3 && ((d->getData ().TwoBytes (2) & 0xff00) == 0x0100)) usrFRV = 0x01; @@ -2919,39 +2919,34 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len else if (Source ()) { if ( Pid == EIT_PID || Pid == 0x0300 || Pid == 0x0441 ) { - if (Tid >= 0x4E) + if (Tid >= SI::TableIdEIT_presentFollowing) ProccessContinuous(Pid, Tid, Length, Data); return; } int Result; switch (Tid) { - case 0xA0: + case SI::TableIdPremiereCIT: if ((Pid < 0x30) || (Pid > 0x37)) { ProcessPremiere(Data); break; } //if citpid == 0xb11 Premiere /* no break - used for sky also*/ - case 0xa1: - case 0xa2: - case 0xa3: + case SI::TableIdSKYTitles_first ... SI::TableIdSKYTitles_last: Result = GetTitlesSKYBOX (Data, Length - 4); if (Result != 1) //when fatal error or finished - Del (Pid, 0xa0, 0xfc); //kill filter + Del (Pid, SI::TableIdSKYTitlesA0, 0xfc); //kill filter if (Result == 0) { //fatal error esyslog ("EEPG: Fatal error reading titles."); ProcessNextFormat (); //and go process other formats } if (Result == 2) - AddFilter (Pid + 0x10, 0xa8, 0xfc); //Set filter that processes summaries of this batch + AddFilter (Pid + 0x10, SI::TableIdSKYSummaries_first, 0xfc); //Set filter that processes summaries of this batch break; - case 0xa8: - case 0xa9: - case 0xaa: - case 0xab: + case SI::TableIdSKYSummaries_first ... SI::TableIdSKYSummaries_last: Result = GetSummariesSKYBOX (Data, Length - 4); if (Result != 1) //when fatal error or finished - Del (Pid, 0xa8, 0xfc); //kill filter + Del (Pid, SI::TableIdSKYSummaries_first, 0xfc); //kill filter if (Result == 0) { esyslog ("EEPG: Fatal error reading summaries."); ProcessNextFormat (); @@ -2959,12 +2954,12 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len if (Result == 2) { LoadIntoSchedule (); if (Pid < 0x47) //this is not the last batch//FIXME chaining is easy on the PIDs and the CPU, but error when Pid,Tid is not used at the moment... - AddFilter (Pid - 0x0F, 0xa0, 0xfc); //next pid, first tid + AddFilter (Pid - 0x0F, SI::TableIdSKYTitlesA0, 0xfc); //next pid, first tid else //last pid was processed ProcessNextFormat (); } break; - case 0x90: + case SI::TableIdMHW1TitlesSummaries: if (Pid == 0xd2) { Result = GetTitlesMHW1 (Data, Length); if (Result != 1) //fatal error or last processed @@ -2974,7 +2969,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len ProcessNextFormat (); } if (Result == 2) - AddFilter (0xd3, 0x90); //SummariesMHW1 + AddFilter (0xd3, SI::TableIdMHW1TitlesSummaries); //SummariesMHW1 } else if (Pid == 0xd3) { Result = GetSummariesMHW1 (Data, Length); if (Result != 1) //fatal error or last processed @@ -2990,24 +2985,24 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len } } break; - case 0xc8: //GetChannelsMHW2 or GetThemesMHW2 + case SI::TableIdMHW2ChannelsThemes: //GetChannelsMHW2 or GetThemesMHW2 if (Pid == 0x231) { if (Data[3] == 0x01) { //Themes it will be - Result = GetThemesMHW2 (Data, Length); //return code 0 = fatal error, code 1 = sucess, code 2 = last item processed + Result = GetThemesMHW2 (Data, Length); //return code 0 = fatal error, code 1 = success, code 2 = last item processed //break; if (Result != 1) EndThemes = true; //also set Endthemes on true on fatal error } //if Data else if (Data[3] == 0x00) { //Channels it will be - Result = GetChannelsMHW (Data, Length, 2); //return code 0 = fatal error, code 1 = sucess, code 2 = last item processed + Result = GetChannelsMHW (Data, Length, 2); //return code 0 = fatal error, code 1 = success, code 2 = last item processed if (Result != 1) EndChannels = true; //always remove filter, code 1 should never be returned since MHW2 always reads all channels.. ChannelsOk = (Result == 2); } - if (EndChannels && EndThemes) { //those are only set withing MHW2 - Del (0x231, 0xc8); //stop reading MHW2 themes and channels - if (ChannelsOk) //No channels = fatal, no themes = nonfatal - AddFilter (0x234, 0xe6); //start reading MHW2 titles + if (EndChannels && EndThemes) { //those are only set within MHW2 + Del (0x231, SI::TableIdMHW2ChannelsThemes); //stop reading MHW2 themes and channels + if (ChannelsOk) //No channels = fatal, no themes = non fatal + AddFilter (0x234, SI::TableIdMHW2Titles); //start reading MHW2 titles else { esyslog ("EEPG: Fatal error reading channels."); ProcessNextFormat (); @@ -3015,30 +3010,30 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len } } //if Pid == 0x231 break; - case 0x91: - Result = GetChannelsMHW (Data, Length, 1); //return code 0 = fatal error, code 1 = sucess, code 2 = last item processed + case SI::TableIdMHW1Channels: + Result = GetChannelsMHW (Data, Length, 1); //return code 0 = fatal error, code 1 = success, code 2 = last item processed Del (Pid, Tid); //always remove filter, code 1 should never be returned since MHW1 always reads all channels... if (Result == 2) - AddFilter (0xd2, 0x90); //TitlesMHW1 + AddFilter (0xd2, SI::TableIdMHW1TitlesSummaries); //TitlesMHW1 else { esyslog ("EEPG: Fatal error reading channels."); ProcessNextFormat (); } break; - case 0x92: - Result = GetThemesMHW1 (Data, Length); //return code 0 = fatal error, code 1 = sucess, code 2 = last item processed + case SI::TableIdMHW1Themes: + Result = GetThemesMHW1 (Data, Length); //return code 0 = fatal error, code 1 = success, code 2 = last item processed if (Result != 1) Del (Pid, Tid); if (Result == 2) - AddFilter (0xd3, 0x91); //ChannelsMHW1 + AddFilter (0xd3, SI::TableIdMHW1Channels); //ChannelsMHW1 else { - esyslog ("EEPG: Fatal error reading themes."); //doesnt have to be fatal... + esyslog ("EEPG: Fatal error reading themes."); //Doesn't have to be fatal... ProcessNextFormat (); } break; - case 0xe6: //TitlesMHW2 + case SI::TableIdMHW2Titles: //TitlesMHW2 if (Pid == 0x234) { - Result = GetTitlesMHW2 (Data, Length); //return code 0 = fatal error, code 1 = sucess, code 2 = last item processed + Result = GetTitlesMHW2 (Data, Length); //return code 0 = fatal error, code 1 = success, code 2 = last item processed if (Result != 1) Del (Pid, Tid); if (Result == 0) { @@ -3046,10 +3041,10 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len ProcessNextFormat (); } if (Result == 2) - AddFilter (0x236, 0x96); //start reading MHW2 summaries.... + AddFilter (0x236, SI::TableIdMHW2Summaries); //start reading MHW2 summaries.... } break; - case 0x96: //Summaries MHW2 + case SI::TableIdMHW2Summaries: //Summaries MHW2 if (Pid == 0x236) { Result = GetSummariesMHW2 (Data, Length); //return code 0 = fatal error, code 1 = sucess, code 2 = last item processed if (Result != 1) @@ -3064,7 +3059,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len } } //if pid break; - case 0x4a: //Sky channels + case SI::TableIdSKYChannels: //Sky channels if (Pid == 0x11) { Result = GetChannelsSKYBOX (Data, Length - 4); if (Result != 1) //only breakoff on completion or error; do NOT clean up after success, because then not all bouquets will be read @@ -3072,7 +3067,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len if (Result == 2) { GetThemesSKYBOX (); //Sky Themes from file; must be called AFTER first channels to have lThemes initialized FIXME if (InitDictionary ()) - AddFilter (0x30, 0xa0, 0xfc); //SKY Titles batch 0 of 7 + AddFilter (0x30, SI::TableIdSKYTitlesA0, 0xfc); //SKY Titles batch 0 of 7 else { esyslog ("EEPG: Fatal error reading huffman table."); ProcessNextFormat (); @@ -3081,7 +3076,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len } //if Pid == 0x11 break; - case 0xb0: //NagraGuide + case SI::TableIdNagraCIT: //NagraGuide if (Pid == 0xc8) { Result = GetNagra (Data, Length); if (Result != 1) @@ -3100,40 +3095,9 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len } break; - case 0x4E: - case 0x4F: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - case 0x58: - case 0x59: - case 0x5A: - case 0x5B: - case 0x5C: - case 0x5D: - case 0x5E: - case 0x5F: - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: + case SI::TableIdEIT_presentFollowing: + case SI::TableIdEIT_presentFollowing_other: + case SI::TableIdEIT_schedule_first ... SI::TableIdEIT_schedule_Other_last: // Freesat: // Set(3842, 0x4E, 0xFE); // event info, actual(0x4E)/other(0x4F) TS, present/following // Set(3842, 0x50, 0xF0); // event info, actual TS, schedule(0x50)/schedule for future days(0x5X) @@ -3168,7 +3132,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) int now = time (0); int nCount = 0; int nRating = 0; - unsigned char Tid = 0xa0; // TODO maybe default TableID + unsigned char Tid = SI::TableIdPremiereCIT; // TODO maybe default TableID SI::ExtendedEventDescriptors * ExtendedEventDescriptors = 0; SI::ShortEventDescriptor * ShortEventDescriptor = 0; char *order = 0, *rating = 0; @@ -3182,7 +3146,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) for (SI::Loop::Iterator it; (d = cit.eventDescriptors.getNext (it));) { nDescriptorTag = d->getDescriptorTag (); switch (nDescriptorTag) { - case 0xF0: // order information + case SI::PremiereOrderInfoDescriptorTag: // order information if (SetupPE->OrderInfo) { static const char *text[] = { trNOOP ("Ordernumber"), @@ -3204,7 +3168,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) order = strdup (buff); } break; - case 0xF1: // parental rating + case SI::PremiereRatingInfoDescriptorTag: // parental rating if (SetupPE->RatingInfo) { char buff[512]; int p = 0; @@ -3287,14 +3251,13 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) int sid = pct->getServiceId (); if (SetupPE->FixEpg) { if (nid == 133) { - if (tid == 0x03 && sid == 0xf0) { - tid = 0x02; + if (tid == SI::TableIdTSDT && sid == 0xf0) { + tid = SI::TableIdPMT; sid = 0xe0; - } else if (tid == 0x03 && sid == 0xf1) { - tid = 0x02; + } else if (tid == SI::TableIdTSDT && sid == 0xf1) { + tid = SI::TableIdPMT; sid = 0xe1; - } else if (tid == 0x03 && sid == 0xf5) { - tid = 0x03; + } else if (tid == SI::TableIdTSDT && sid == 0xf5) { sid = 0xdc; } else if (tid == 0x04 && sid == 0xd2) { tid = 0x11; @@ -3355,7 +3318,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) } else { LogI(2, "(upd)\n"); pEvent->SetSeen (); - if (pEvent->TableID () == 0x00 || pEvent->Version () == cit.getVersionNumber ()) { + if (pEvent->TableID () == SI::TableIdPAT || pEvent->Version () == cit.getVersionNumber ()) { if (pEvent->RunningStatus () != runningStatus) pSchedule->SetRunningStatus (pEvent, runningStatus, channel); continue; -- cgit v1.2.3 From 021190e605d10424986c616793829a7e99b3e720 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Fri, 23 Nov 2012 16:24:15 +0100 Subject: change MjdToEpochTime macro to function and use it on more locations extract SKY qualitiy info from stream. Should be added to the event description do not send already expired events to VDR so that no cleanup is required after. changed the logic of summary handling for SKY so that no SummaryAvailable bit is required, since it can not be located from the stream implement some TODOs remove commented code --- eepg.c | 251 +++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 127 insertions(+), 124 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index d20c1f5..0c6e606 100644 --- a/eepg.c +++ b/eepg.c @@ -1297,23 +1297,9 @@ void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, }else{ category = theme; } - /* - string fmt; - fmt = "%s"; - if (stripspace(category)) { - fmt += "\nCategory: %s"; - } - if (genre) { - fmt += "\nGenre: %s"; - } - Asprintf (&tmp, fmt.c_str(), SummText, category, stripspace (genre)); - Event->SetDescription (tmp); - free(tmp); - */ string desc = SummText; if (stripspace(category)) desc.append("\n").append(CATEGORY).append(category); - //if (stripspace(category)) desc += '\n' << CATEGORY << category; if (stripspace(genre)) desc += '\n' + string(GENRE) + genre; Event->SetDescription (desc.c_str()); @@ -1910,11 +1896,8 @@ int cFilterEEPG::GetTitlesMHW2 (const u_char * Data, int Length) T->ChannelId = Data[Pos]; Pos+=11;//The date time starts here //isyslog ("EEPGDebug: ChannelID:%d", T->ChannelId); - unsigned int MjdTime = (Data[Pos] << 8) | Data[Pos + 1]; - T->MjdTime = 0; //not used for matching MHW2 - T->StartTime = ((MjdTime - 40587) * 86400) - + (((((Data[Pos + 2] & 0xf0) >> 4) * 10) + (Data[Pos + 2] & 0x0f)) * 3600) - + (((((Data[Pos + 3] & 0xf0) >> 4) * 10) + (Data[Pos + 3] & 0x0f)) * 60); + T->MjdTime = 0; //(Data[Pos] << 8) | Data[Pos + 1] not used for matching MHW2 + T->StartTime = MjdToEpochTime(Data[Pos], Data[Pos + 1], Data[Pos + 2], Data[Pos + 3]); T->Duration = (((Data[Pos + 5] << 8) | Data[Pos + 6]) >> 4) * 60; Len = Data[Pos + 7] & 0x3f; //isyslog ("EEPGDebug: Len:%d", Len); @@ -1987,7 +1970,7 @@ int cFilterEEPG::GetSummariesMHW1 (const u_char * Data, int Length) // unsigned short SectionLength = ((Summary->SectionLengthHigh & 0x0f) << 8) | Summary->SectionLengthLow; // Asprintf((char **)&Text, "%s \n\n SecLength:%d SLHigh:%d SLLow:%d", Text, SectionLength, Summary->SectionLengthHigh, Summary->SectionLengthLow); S->Text = Text; - S->ShortTextLength = 0; //TODO find for MHW1 + S->ShortTextLength = 0; //TODO DPE find for MHW1 int i = 0; do { S->Replays[i].MjdTime = 0; //only used for SKY @@ -2008,11 +1991,7 @@ int cFilterEEPG::GetSummariesMHW1 (const u_char * Data, int Length) S->EventId, S->Replays[i].ChannelId, sChannels[ChannelSeq[S->Replays[i].ChannelId]].Name, Hour, Minute, Sec); - S->Replays[i].StartTime = MjdToEpochTime (Date) + (((((Hour & 0xf0) >> 4) * 10) + (Hour & 0x0f)) * 3600) - + (((((Minute & 0xf0) >> 4) * 10) + (Minute & 0x0f)) * 60) - + ((((Sec & 0xf0) >> 4) * 10) + (Sec & 0x0f)); -// summary -> time[i] = ProviderLocalTime2UTC (summary -> time[i]); - S->Replays[i].StartTime = LocalTime2UTC (S->Replays[i].StartTime); + S->Replays[i].StartTime = LocalTime2UTC (MjdToEpochTime (Date_hi, Date_lo, Hour, Minute, Sec)); //} i++; } while (i < Summary->NumReplays); @@ -2155,67 +2134,64 @@ int cFilterEEPG::GetChannelsSKYBOX (const u_char * Data, int Length) while (TransportDescriptorsLength > 0) { unsigned char DescriptorTag = Data[p2]; int DescriptorLength = Data[p2 + 1]; - int p3 = (p2 + 2); + int p3 = (p2 + 4); p2 += (DescriptorLength + 2); TransportDescriptorsLength -= (DescriptorLength + 2); - switch (DescriptorTag) { //TODO switch with only 1 case??? replace this by template - case 0xb1: - p3 += 2; - DescriptorLength -= 2; - while (DescriptorLength > 0) { - // 0x01 = Video Channel - // 0x02 = Audio Channel - // 0x05 = Other Channel - //if( Data[p3+2] == 0x01 || Data[p3+2] == 0x02 || Data[p3+2] == 0x05 ) - //{ - unsigned short int Sid = (Data[p3] << 8) | Data[p3 + 1]; - unsigned short int ChannelId = (Data[p3 + 3] << 8) | Data[p3 + 4]; - unsigned short int SkyNumber = (Data[p3 + 5] << 8) | Data[p3 + 6]; - if (SkyNumber > 100 && SkyNumber < 1000) { - if (ChannelId > 0) { - sChannel *C; - if (ChannelSeq.count (ChannelId) == 0) { //not found - C = &sChannels[nChannels]; - C->ChannelId = ChannelId; - //C->NumberOfEquivalences = 1; //there is always an original channel. every equivalence adds 1 - C->Src = Source (); //assume all EPG channels are on same satellite, if not, manage this via equivalents!!! - C->Nid = Nid; - C->Tid = Tid; - C->Sid = Sid; - C->SkyNumber = SkyNumber; - tChannelID channelID = tChannelID (C->Src, C->Nid, C->Tid, C->Sid); - cChannel *VC = Channels.GetByChannelID (channelID, true); - bool IsFound = (VC); - if (IsFound) - strncpy ((char *) C->Name, VC->Name (), 64); - else - C->Name[0] = '\0'; //empty string - - LogI(1, "|% 5d | %-26.26s | %-22.22s | %-3.3s | % 6d |\n", C->ChannelId - , *channelID.ToString(), C->Name, IsFound ? "YES" : "NO", C->SkyNumber); - - ChannelSeq[C->ChannelId] = nChannels; //fill lookup table to go from channel-id to sequence nr in table - nChannels++; - if (nChannels >= MAX_CHANNELS) { - LogE(0, prep("Error, %i channels found more than %i"), nChannels, MAX_CHANNELS); - return 0; - } + if (DescriptorTag != 0xB1) + continue; + + DescriptorLength -= 2; + while (DescriptorLength > 0) { + // 0x01 = Video Channel + // 0x02 = Audio Channel + // 0x05 = Other Channel + //if( Data[p3+2] == 0x01 || Data[p3+2] == 0x02 || Data[p3+2] == 0x05 ) + //{ + unsigned short int Sid = (Data[p3] << 8) | Data[p3 + 1]; + unsigned short int ChannelId = (Data[p3 + 3] << 8) | Data[p3 + 4]; + unsigned short int SkyNumber = (Data[p3 + 5] << 8) | Data[p3 + 6]; + if (SkyNumber > 100 && SkyNumber < 1000) { + if (ChannelId > 0) { + sChannel *C; + if (ChannelSeq.count (ChannelId) == 0) { //not found + C = &sChannels[nChannels]; + C->ChannelId = ChannelId; + //C->NumberOfEquivalences = 1; //there is always an original channel. every equivalence adds 1 + C->Src = Source (); //assume all EPG channels are on same satellite, if not, manage this via equivalents!!! + C->Nid = Nid; + C->Tid = Tid; + C->Sid = Sid; + C->SkyNumber = SkyNumber; + tChannelID channelID = tChannelID (C->Src, C->Nid, C->Tid, C->Sid); + cChannel *VC = Channels.GetByChannelID (channelID, true); + bool IsFound = (VC); + if (IsFound) + strncpy ((char *) C->Name, VC->Name (), 64); + else + C->Name[0] = '\0'; //empty string + + LogI(1, "|% 5d | %-26.26s | %-22.22s | %-3.3s | % 6d |\n", C->ChannelId + , *channelID.ToString(), C->Name, IsFound ? "YES" : "NO", C->SkyNumber); + + ChannelSeq[C->ChannelId] = nChannels; //fill lookup table to go from channel-id to sequence nr in table + nChannels++; + if (nChannels >= MAX_CHANNELS) { + LogE(0, prep("Error, %i channels found more than %i"), nChannels, MAX_CHANNELS); + return 0; } } } - p3 += 9; - DescriptorLength -= 9; } - break; - default: - break; - } //switch descriptortag + p3 += 9; + DescriptorLength -= 9; + } } } //while return 1; } //else part of memcmp } + /** * \brief Get SKYBOX Titles * @@ -2237,7 +2213,7 @@ int cFilterEEPG::GetTitlesSKYBOX (const u_char * Data, int Length) if (nTitles == 0) memcpy (InitialTitle, Data, 20); //copy data into initial title ChannelId = (Data[3] << 8) | Data[4]; - MjdTime = ((Data[8] << 8) | Data[9]); + MjdTime = (Data[8] << 8) | Data[9]; if (ChannelId > 0) { if (MjdTime > 0) { p = 10; @@ -2259,12 +2235,12 @@ int cFilterEEPG::GetTitlesSKYBOX (const u_char * Data, int Length) } p += 4; Len2 = Data[p + 1] - 7; - T->StartTime = ((MjdTime - 40587) * 86400) + ((Data[p + 2] << 9) | (Data[p + 3] << 1)); + T->StartTime = MjdToEpochTime(MjdTime) + ((Data[p + 2] << 9) | (Data[p + 3] << 1)); T->Duration = ((Data[p + 4] << 9) | (Data[p + 5] << 1)); T->ThemeId = Data[p + 6]; T->TableId = DEFAULT_TABLE_ID; //TODO locate the actual table id //TODO Data[p + 7] is Quality value add it to description - //int quality = Data[p + 7]; + T->Quality = Data[p + 7]; switch (Data[p + 8] & 0x0F) { case 0x01: T->Rating = 0x00; //"U" @@ -2285,9 +2261,9 @@ int cFilterEEPG::GetTitlesSKYBOX (const u_char * Data, int Length) T->Rating = 0x00; //"-" break; } - T->Unknown1 = Data[p + 4 - 13]; //FIXME - T->Unknown2 = Data[p + 4 - 12]; //FIXME - T->Unknown3 = Data[p + 4 - 11]; //FIXME + T->Unknown1 = Data[5]; //Bound to Channel/Date + T->Unknown2 = Data[6]; //Bound to Channel/Date + T->Unknown3 = Data[7]; //Bound to Channel/Date unsigned char tmp[4096]; //TODO smarter Len2 = sky_huffman_decode (&Data[p + 9], Len2, tmp); if (Len2 == 0) { @@ -2304,8 +2280,8 @@ int cFilterEEPG::GetTitlesSKYBOX (const u_char * Data, int Length) CleanString (T->Text); T->SummaryAvailable = 1; //TODO I assume this is true? - LogI(3, prep("EventId %08x Titlenr %d,Unknown1:%x,Unknown2:%x,Un3:%x,Name:%s."), - T->EventId, nTitles, T->Unknown1, T->Unknown2, T->Unknown3, T->Text); + LogI(3, prep("EventId %08x Titlenr %d,Un1:%x,Un2:%x,Un3:%x,Quality:%x,Name:%s."), + T->EventId, nTitles, T->Unknown1, T->Unknown2, T->Unknown3, T->Quality, T->Text); p += Len1; nTitles++; @@ -2384,7 +2360,7 @@ int cFilterEEPG::GetSummariesSKYBOX (const u_char * Data, int Length) CleanString (S->Text); char * delim = strstr ( (char *)S->Text, STxtDelim ); S->ShortTextLength = delim == NULL ? 0 : delim - (char *)S->Text; - LogI(3, prep("EventId %08x Summnr %d:%.30s."), S->EventId, nSummaries, S->Text); + LogI(4, prep("EventId %08x Summnr %d:%.30s."), S->EventId, nSummaries, S->Text); p += Len1; nSummaries++; if (nSummaries >= MAX_TITLES) { @@ -2407,7 +2383,9 @@ 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 text block; needed in case NumReplays > 1, multiple pointers to same textblock + //this is the last summary that points to this text block; + // needed in case NumReplays > 1, multiple pointers to same textblock + if (S->Text != S2->Text && S->Text != 0x00) free (S->Text); } else if (S->Text != 0x00) free (S->Text); @@ -2439,13 +2417,15 @@ void cFilterEEPG::LoadIntoSchedule (void) foundtitle = false; Title_t *T; Summary_t *S; - int remembersummary; + int remembersummary = -1; //keep statistics int SummariesNotFound = 0; int NoSummary = 0; int NotMatching = 0; int LostSync = 0; - remembersummary = -1; + int OldEvents = 0; + int SummIndex = -1; + bool isOTV = Format == SKY_IT || Format == SKY_UK; { cSchedulesLock SchedulesLock (true); @@ -2453,7 +2433,6 @@ void cFilterEEPG::LoadIntoSchedule (void) if (s) { while (i < nTitles) { - T = Titles[i]; S = Summaries[j]; foundtitle = false; @@ -2470,13 +2449,16 @@ 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... + time_t too_old = time(NULL) - (Setup.EPGLinger * 60 + 3600); + if ((T->EventId == S->EventId && T->MjdTime == S->Replays[0].MjdTime) && + ((T->ChannelId == S->Replays[0].ChannelId) || !isOTV)) { //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 remembersummary = -1; //reset summary searcher //int Replays = S->NumReplays; + if (isOTV) + SummIndex = j; int index = 0; do { @@ -2490,6 +2472,13 @@ void cFilterEEPG::LoadIntoSchedule (void) StartTime = S->Replays[index].StartTime; } + index++; + if ((StartTime + T->Duration) < too_old) { + LogD(3, prep("Skipping old event '%s', start time:%s"), T->Text, ctime (&StartTime)); + OldEvents++; + continue; + } + //channelids are sequentially numbered and sent in MHW1 and MHW2, but not in SKY, so we need to lookup the table index sChannel *C = &sChannels[ChannelSeq[ChannelId]]; //find channel //cSchedule *p;//[MAX_EQUIVALENCES]; @@ -2497,7 +2486,7 @@ void cFilterEEPG::LoadIntoSchedule (void) tChannelID chanID = tChannelID (C->Src, C->Nid, C->Tid, C->Sid); char rating = 0x00; - if ((Format == SKY_IT || Format == SKY_UK) && T->Rating) { //TODO only works on OTV for now + if (isOTV && T->Rating) { //TODO only works on OTV for now rating = T->Rating; } unsigned short int TableId = DEFAULT_TABLE_ID; @@ -2505,8 +2494,8 @@ void cFilterEEPG::LoadIntoSchedule (void) TableId = T->TableId; } -// LogD (0, prep("EventId %08x Titlenr %d:SummAv:%x,Un1:%x,Un2:%x,Un3:%x,Name:%s,STxtLn:%dSummary:%s."), -// T->EventId, i, T->SummaryAvailable, T->Unknown1, T->Unknown2, T->Unknown3, T->Text, S->ShortTextLength, S->Text); +// LogD (0, prep("EventId %08x Titlenr:%d,SummNr:%d,SummAv:%x,Un1:%x,Un2:%x,Un3:%x,Name:%s,STxtLn:%d,Summary:%s."), +// T->EventId, i, j, T->SummaryAvailable, T->Unknown1, T->Unknown2, T->Unknown3, T->Text, S->ShortTextLength, S->Text); WriteToSchedule (chanID, s, T->EventId, StartTime, T->Duration / 60, (char *) T->Text, (char *) S->Text, T->ThemeId, TableId, 0, rating, S->ShortTextLength); @@ -2521,11 +2510,9 @@ void cFilterEEPG::LoadIntoSchedule (void) //j = 0; //S = Summaries[j]; //next summary within replay range //} - index++; } //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 i++; //move to next title } //if T->EventId == S->EventId @@ -2538,31 +2525,42 @@ void cFilterEEPG::LoadIntoSchedule (void) remembersummary = nSummaries; //or next test will never be succesfull for remembersummary = 0 LostSync++; // esyslog("EEPG Error: lost sync at title %d, summary %d.",i,j); - } else if (j == (remembersummary - 1)) { //the last summary to be checked has failed also + } else if (j == (remembersummary - 1) || SummIndex !=-1) { //the last summary to be checked has failed also //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); + if ((T->StartTime + T->Duration) < too_old) { + LogD(3, prep("Skipping old event '%s' without summary, start time:%s"), T->Text, ctime ((time_t*)&T->StartTime)); + OldEvents++; + } else { - /* write Title info to schedule */ - sChannel *C = &sChannels[ChannelSeq[T->ChannelId]]; //find channel - //cSchedule *p;//[MAX_EQUIVALENCES]; - tChannelID chanID = tChannelID (C->Src, C->Nid, C->Tid, C->Sid); - //PrepareToWriteToSchedule (C, s, p); - char rating = 0x00; - if ((Format == SKY_IT || Format == SKY_UK) && T->Rating) { //TODO only works on OTV for now - rating = T->Rating; - } - WriteToSchedule (chanID, s, T->EventId, T->StartTime, T->Duration / 60, (char *) T->Text, - NULL, T->ThemeId, DEFAULT_TABLE_ID, 0, rating, S->ShortTextLength); - //FinishWriteToSchedule (C, s, p); - sortSchedules(s, chanID); + if (!isOTV) //No sense of logging for SKY when SummaryAvailable bit is not known + esyslog("EEPG: Error, summary not found for EventId %08x Titlenr %d:SummAv:%x,Un1:%x,Un2:%x,Un3:%x,Name:%s.", + 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 + //cSchedule *p;//[MAX_EQUIVALENCES]; + tChannelID chanID = tChannelID (C->Src, C->Nid, C->Tid, C->Sid); + //PrepareToWriteToSchedule (C, s, p); + char rating = 0x00; + if (!isOTV && T->Rating) { //TODO only works on OTV for now + rating = T->Rating; + } + WriteToSchedule (chanID, s, T->EventId, T->StartTime, T->Duration / 60, (char *) T->Text, + NULL, T->ThemeId, DEFAULT_TABLE_ID, 0, rating, S->ShortTextLength); + //FinishWriteToSchedule (C, s, p); + sortSchedules(s, chanID); - SummariesNotFound++; + SummariesNotFound++; + } i++; //move to next title, for this one no summary can be found } -// esyslog("Trying again for this title %d, remember summary %d, but advancing one Summary to %d.",i,remembersummary,j); + if (SummIndex != -1 && isOTV){ + j--; + } + +// if (SummIndex != -1) +// esyslog("Trying again for this title %d, remember summary %d, but advancing one Summary to %d.",i,remembersummary,j+1); } j++; //move to next summary if (j >= nSummaries) //do not forget to look in beginning of (ring)buffer @@ -2573,24 +2571,32 @@ void cFilterEEPG::LoadIntoSchedule (void) LogE (0, prep("Error: could not lock schedules.")); }//release ScheduleLock - cSchedules::Cleanup (true); //deletes all past events + //TODO: Test if cleanup is needed now that old events are no more + //one thing it Cleanup (true) does is write the epg.data immediately + //cSchedules::Cleanup (true); //deletes all past events + cSchedules::Cleanup (); //deletes all past events - //isyslog ("EEPG: found %i equivalents channels", nEquivChannels); isyslog ("EEPG: found %i themes", nThemes); isyslog ("EEPG: found %i channels", nChannels); isyslog ("EEPG: found %i titles", nTitles); - if (NoSummary != 0) + if (NoSummary) isyslog ("EEPG: of which %i reported to have no summary available; skipping these BIENTOT titles", NoSummary); isyslog ("EEPG: found %i summaries", nSummaries); - if (SummariesNotFound != 0) - esyslog ("EEPG: %i summaries not found", SummariesNotFound); + if (SummariesNotFound) + if (nTitles-nSummaries!=SummariesNotFound) { + esyslog ("EEPG: %i summaries not found", SummariesNotFound); + esyslog ("EEPG: %i difference between no of summaries and summaries not found", nTitles-nSummaries-SummariesNotFound); + } else + isyslog ("EEPG: %i titles without summaries", SummariesNotFound); + if (OldEvents) + isyslog ("EEPG: Skipped %i old events", OldEvents); if (NotMatching > nSummaries) - LogI (0, prep("Warning: lost sync %i times, summary did not match %i times."), - LostSync, NotMatching); + LogI (0, prep("Warning: lost sync %i times, summary did not match %i times."), LostSync, NotMatching); + FreeSummaries (); //do NOT free channels, themes and bouquets here because they will be reused in SKY! FreeTitles (); - if (!((Format == SKY_IT) || (Format == SKY_UK))) { //everything but SKY; SKY is the only protocol where LoadIntoSchedule is called repeatedly + if (!isOTV) { //everything but SKY; SKY is the only protocol where LoadIntoSchedule is called repeatedly ChannelSeq.clear (); } } @@ -2633,8 +2639,6 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) free(mesg); } - TitleCounter = 0; - SummaryCounter = 0; /*if (SummariesNotFound != 0) esyslog ("EEPG: %i summaries not found", SummariesNotFound); else if (VERBOSE >= 1) @@ -2843,7 +2847,6 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len if (d->getLength () == 6 && d->getData ().FourBytes (2) == 0x0000ffff) usrData = true; if (d->getLength () == 3 && ((d->getData ().TwoBytes (2) & 0xff00) == 0xb600)) //SKY IT //TODO ugly! - //if (d->getLength () == 3 && (d->getData ().TwoBytes (2) == 0xb6a5)) //SKY IT //TODO ugly! usrOTV = SKY_IT; //Format = SKY_IT; if (d->getLength () == 3 && d->getData ().FourBytes (2) == 0xc004e288) //SKY UK -- cgit v1.2.3 From 4c2a7908ce569eb868863d07775b5f36dbea206e Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Fri, 23 Nov 2012 21:30:36 +0100 Subject: implement some more TODOs --- eepg.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index 0c6e606..01257fa 100644 --- a/eepg.c +++ b/eepg.c @@ -219,7 +219,7 @@ protected: virtual bool GetThemesSKYBOX (void); virtual int GetTitlesSKYBOX (const u_char * Data, int Length); virtual int GetSummariesSKYBOX (const u_char * Data, int Length); - virtual int GetChannelsMHW (const u_char * Data, int Length, int MHW); //TODO replace MHW by Format? + virtual int GetChannelsMHW (const u_char * Data, int Length); virtual int GetThemesMHW1 (const u_char * Data, int Length); virtual int GetNagra (const u_char * Data, int Length); virtual void ProcessNagra (void); @@ -831,18 +831,20 @@ bool cFilterEEPG::InitDictionary (void) * * \return 0 = fatal error, code 1 = success, code 2 = last item processed */ -int cFilterEEPG::GetChannelsMHW (const u_char * Data, int Length, int MHW) +int cFilterEEPG::GetChannelsMHW (const u_char * Data, int Length) { - if ((MHW == 1) || (nChannels == 0)) { //prevents MHW2 from reading channels twice while waiting for themes on same filter + if (Format != MHW1 && Format != MHW2) return 0; + + if ((Format == MHW1) || (nChannels == 0)) { //prevents MHW2 from reading channels twice while waiting for themes on same filter sChannelMHW1 *Channel; int Size, Off; Size = sizeof (sChannelMHW1); Off = 4; - if (MHW == 1) { + if (Format == MHW1) { //Channel = (sChannelMHW1 *) (Data + 4); nChannels = (Length - Off) / sizeof (sChannelMHW1); } - if (MHW == 2) { + if (Format == MHW2) { if (Length > 120) nChannels = Data[120]; else { @@ -874,7 +876,7 @@ int cFilterEEPG::GetChannelsMHW (const u_char * Data, int Length, int MHW) C->ChannelId = i; ChannelSeq[C->ChannelId] = i; //fill lookup table to go from channel-id to sequence nr in table C->SkyNumber = 0; - if (MHW == 1) + if (Format == MHW1) memcpy (C->Name, &Channel->Name, 16); //MHW1 else { //MHW2 int lenName = Data[pName] & 0x0f; @@ -935,13 +937,15 @@ int cFilterEEPG::GetThemesMHW1 (const u_char * Data, int Length) const u_char *ThemesIndex = (Data + 3); for (int i = 0; i < nThemes; i++) { if (ThemesIndex[ThemeId] == i) { - Offset = (Offset + 15) & 0xf0; //TODO do not understand this + //The index of the Themes in MHW1 is not incremented by 1 but with offset calculated like this + Offset = (Offset + 15) & 0xf0; ThemeId++; } memcpy (&Themes[Offset][0], &Theme->Name, 15); Themes[Offset][15] = '\0'; //trailing null CleanString (Themes[Offset]); - LogI(1, prep("%.15s"), Themes[Offset]); +// LogI(1, prep("%.15s"), Themes[Offset]); + LogI(1, prep("%.15s|Offset:%06d"), Themes[Offset],Offset); Offset++; Theme++; } @@ -2585,7 +2589,7 @@ void cFilterEEPG::LoadIntoSchedule (void) if (SummariesNotFound) if (nTitles-nSummaries!=SummariesNotFound) { esyslog ("EEPG: %i summaries not found", SummariesNotFound); - esyslog ("EEPG: %i difference between no of summaries and summaries not found", nTitles-nSummaries-SummariesNotFound); + esyslog ("EEPG: %i difference between No. of summaries and summaries not found", nTitles-nSummaries-SummariesNotFound); } else isyslog ("EEPG: %i titles without summaries", SummariesNotFound); if (OldEvents) @@ -2706,6 +2710,7 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false) break; case SKY_IT: case SKY_UK: + GetThemesSKYBOX (); //Sky Themes from file AddFilter (0x11, SI::TableIdSKYChannels); //Sky Channels break; case FREEVIEW: //Freeview, CONT mode //TODO streamline this for other modes @@ -2997,7 +3002,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len EndThemes = true; //also set Endthemes on true on fatal error } //if Data else if (Data[3] == 0x00) { //Channels it will be - Result = GetChannelsMHW (Data, Length, 2); //return code 0 = fatal error, code 1 = success, code 2 = last item processed + Result = GetChannelsMHW (Data, Length); //return code 0 = fatal error, code 1 = success, code 2 = last item processed if (Result != 1) EndChannels = true; //always remove filter, code 1 should never be returned since MHW2 always reads all channels.. ChannelsOk = (Result == 2); @@ -3014,7 +3019,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len } //if Pid == 0x231 break; case SI::TableIdMHW1Channels: - Result = GetChannelsMHW (Data, Length, 1); //return code 0 = fatal error, code 1 = success, code 2 = last item processed + Result = GetChannelsMHW (Data, Length); //return code 0 = fatal error, code 1 = success, code 2 = last item processed Del (Pid, Tid); //always remove filter, code 1 should never be returned since MHW1 always reads all channels... if (Result == 2) AddFilter (0xd2, SI::TableIdMHW1TitlesSummaries); //TitlesMHW1 @@ -3068,7 +3073,6 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len if (Result != 1) //only breakoff on completion or error; do NOT clean up after success, because then not all bouquets will be read Del (Pid, Tid); //Read all channels, clean up filter if (Result == 2) { - GetThemesSKYBOX (); //Sky Themes from file; must be called AFTER first channels to have lThemes initialized FIXME if (InitDictionary ()) AddFilter (0x30, SI::TableIdSKYTitlesA0, 0xfc); //SKY Titles batch 0 of 7 else { -- cgit v1.2.3 From 3a636554f2bab014d79898dc10b8ca7ea7c8f52e Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Fri, 30 Nov 2012 13:36:55 +0100 Subject: reformated MHW1 themes modified logging added hanlding for duplicate events on equivalent channels --- eepg.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 13 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index 01257fa..5ae992d 100644 --- a/eepg.c +++ b/eepg.c @@ -944,8 +944,30 @@ int cFilterEEPG::GetThemesMHW1 (const u_char * Data, int Length) memcpy (&Themes[Offset][0], &Theme->Name, 15); Themes[Offset][15] = '\0'; //trailing null CleanString (Themes[Offset]); -// LogI(1, prep("%.15s"), Themes[Offset]); - LogI(1, prep("%.15s|Offset:%06d"), Themes[Offset],Offset); + + //reformat themes + if (Offset & 0x0f) { + char* theme; + char* cat; + Asprintf (&theme, "%s", Themes[Offset]); + Asprintf (&cat, "%s", Themes[Offset& 0xf0]); + theme = strreplace(theme,"DOC","DOCUMENTAIRE"); + theme = strreplace(theme,"DOCUMENTAIRE.","DOCUMENTAIRE"); + theme = strreplace(theme,"MAG","MAGAZINE"); + //Remove category from genre. TODO Maybe they should be separated in the future + theme = strreplace(theme,cat,""); + theme = skipspace(theme); + if (theme[0] == '-') { + memmove(theme, theme+1, strlen(theme)); + theme = skipspace(theme); + } + char* buf; + Asprintf(&buf,"%s - %s",cat,theme); + memcpy(Themes[Offset],buf,strlen(buf)+1); + } + + LogI(1, prep("%-33.33s|Offset:0x%02x"), Themes[Offset],Offset); + Offset++; Theme++; } @@ -1007,7 +1029,7 @@ int cFilterEEPG::GetThemesMHW2 (const u_char * Data, int Length) //memcpy (&Themes[pThemeId][lenThemeName + 1], &Data[pSubThemeName], lenSubThemeName); } CleanString (Themes[pThemeId]); - LogI(1, prep("%.*s"), lenThemeName + 1 + lenSubThemeName, Themes[pThemeId]); + LogI(1, prep("%.40s|id:%d"), Themes[pThemeId],pThemeId); //isyslog ("%.15s", (lThemes + pThemeId)->Name); nThemes++; if (nThemes > MAX_THEMES) { @@ -1277,8 +1299,7 @@ void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, if (Format == MHW1) { char * pch; pch=strchr(SummText,'s'); - while (pch!=NULL) - { + while (pch!=NULL) { if (*(pch-1) != ' ' && *(pch-1) != '\n') *pch = ' '; pch=strchr(pch+1,'s'); @@ -1303,14 +1324,29 @@ void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, } string desc = SummText; +// if (stripspace(category)) desc.append("\n").append(CATEGORY).append(tr(category)); +// if (stripspace(genre)) desc += '\n' + string(GENRE) + tr(genre); if (stripspace(category)) desc.append("\n").append(CATEGORY).append(category); if (stripspace(genre)) desc += '\n' + string(GENRE) + genre; Event->SetDescription (desc.c_str()); free(theme); - } - else - Event->SetDescription (SummText); + } + else { +#ifdef DEBUG + string desc = SummText; + if (ThemeId) { + char *theme; + Asprintf (&theme, "0x%x", ThemeId); + LogD(0, prep("DEBUG: missing theme ID 0x%x"), ThemeId); + desc += '\n' + string(GENRE) + theme; + free(theme); + } + Event->SetDescription (desc.c_str()); +#else + Event->SetDescription (SummText); +#endif + } } if (ps && newEvent) ps->AddEvent (newEvent); @@ -2586,12 +2622,13 @@ void cFilterEEPG::LoadIntoSchedule (void) if (NoSummary) isyslog ("EEPG: of which %i reported to have no summary available; skipping these BIENTOT titles", NoSummary); isyslog ("EEPG: found %i summaries", nSummaries); - if (SummariesNotFound) + if (SummariesNotFound) { if (nTitles-nSummaries!=SummariesNotFound) { esyslog ("EEPG: %i summaries not found", SummariesNotFound); esyslog ("EEPG: %i difference between No. of summaries and summaries not found", nTitles-nSummaries-SummariesNotFound); } else isyslog ("EEPG: %i titles without summaries", SummariesNotFound); + } if (OldEvents) isyslog ("EEPG: Skipped %i old events", OldEvents); if (NotMatching > nSummaries) @@ -2609,7 +2646,7 @@ void cFilterEEPG::AddFilter (u_short Pid, u_char Tid) { if (!Matches (Pid, Tid)) { Add (Pid, Tid); - esyslog (prep("Filter Pid:%x,Tid:%x added."), Pid, Tid); + esyslog (prep("Filter Pid:0x%x,Tid:0x%x added."), Pid, Tid); } } @@ -2617,7 +2654,7 @@ void cFilterEEPG::AddFilter (u_short Pid, u_char Tid, unsigned char Mask) { if (!Matches (Pid, Tid)) { Add (Pid, Tid, Mask); - esyslog (prep("Filter Pid:%x,Tid:%x,Mask:%x added."), Pid, Tid, Mask); + esyslog (prep("Filter Pid:0x%x,Tid:0x%x,Mask:0x%x added."), Pid, Tid, Mask); } } @@ -2826,7 +2863,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len usrFRV = 1; LogD(4, prep("if (data[2]==0x39) {//TODO Test This")); } - //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; for (SI::Loop::Iterator it; (d = stream.streamDescriptors.getNext (it));) { @@ -3487,7 +3524,6 @@ bool cPluginEEPG::Start (void) CheckCreateFile("sky_uk.themes", SkyUkThemes); CheckCreateFile("freesat.t1", FreesatT1); CheckCreateFile("freesat.t2", FreesatT2); - CheckCreateFile("sky_uk.themes", SkyUkThemes); sky_tables[0] = NULL; sky_tables[1] = NULL; -- cgit v1.2.3 From 692ebcf6a83df32c78a61faf64741b1f4efed233 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Thu, 3 Jan 2013 10:15:17 +0100 Subject: modified Makefile according to the new VDR version 1.7.35 style --- eepg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index 5ae992d..70a1134 100644 --- a/eepg.c +++ b/eepg.c @@ -52,7 +52,7 @@ #include -#if APIVERSNUM < 10401 +#if defined(APIVERSNUM) && APIVERSNUM < 10401 #error You need at least VDR API version 1.4.1 for this plugin #endif #if APIVERSNUM < 10507 -- cgit v1.2.3 From 2eb5f7d939dd8dbcb560d03bf608e341924b0c2b Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Thu, 31 Jan 2013 14:15:37 +0100 Subject: fix creating of new theme file if missing in eepg dir --- eepg.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index 70a1134..7a7272c 100644 --- a/eepg.c +++ b/eepg.c @@ -3466,6 +3466,7 @@ cPluginEEPG::cPluginEEPG (void) void cPluginEEPG::CheckCreateFile(const char* Name, const char *fileContent[]) { FILE *File; + bool isSkyTheme = fileContent == SkyItThemes || fileContent == SkyUkThemes; string FileName = string(cSetupEEPG::getInstance()->getConfDir()) + "/" + Name; File = fopen(FileName.c_str(), "r"); if (File == NULL) { @@ -3474,11 +3475,23 @@ void cPluginEEPG::CheckCreateFile(const char* Name, const char *fileContent[]) if (File == NULL) { LogE (0, prep("Error creating file '%s', %s"), FileName.c_str(), strerror (errno)); } else { - int i = 0; - while (fileContent[i] != NULL) { - fprintf (File, "%s\n", fileContent[i]); - i++; + if (!isSkyTheme) { + int i = 0; + while (fileContent[i] != NULL) { + fprintf (File, "%s\n", fileContent[i]); + i++; + } + } else { + for (int i = 0; i < 256; i++) { + if (fileContent[i]) { + fprintf (File, "0x%02x=%s\n", i, fileContent[i]); + } + else { + fprintf (File, "0x%02x=\n", i); + } + } } + LogI (0, prep("Success creating file '%s'"), FileName.c_str()); fclose (File); } -- cgit v1.2.3 From c9a302eff85ad0d6c337743b7373b4ee0c7bded3 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Thu, 31 Jan 2013 14:51:27 +0100 Subject: Update the sky_*.themes file if a theme is added in the source Count only nonempty themes as found themes for sky --- eepg.c | 57 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 14 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index 7a7272c..ea5fd8c 100644 --- a/eepg.c +++ b/eepg.c @@ -745,10 +745,16 @@ bool cFilterEEPG::GetThemesSKYBOX (void) //TODO can't we read this from the DVB FILE *FileThemes; char *Line; char Buffer[256]; - if (Format == SKY_IT) + const char **SkyThemes; + bool updateFile = false; + if (Format == SKY_IT) { FileName += "/sky_it.themes"; - else if (Format == SKY_UK) + SkyThemes = SkyItThemes; + } + else if (Format == SKY_UK) { FileName += "/sky_uk.themes"; + SkyThemes = SkyUkThemes; + } else { LogE (0, prep("Error, wrong format detected in GetThemesSKYBOX. Format = %i."), Format); return false; @@ -759,26 +765,49 @@ bool cFilterEEPG::GetThemesSKYBOX (void) //TODO can't we read this from the DVB LogE (0, prep("Error opening file '%s'. %s"), FileName.c_str(), strerror (errno)); return false; } else { - //int id = 0; + int id = 0; nThemes = 0; - char string1[256]; - char string2[256]; - //sTheme *T; + char thId[256]; + char theme[256]; + while ((Line = fgets (Buffer, sizeof (Buffer), FileThemes)) != NULL) { - memset (string1, 0, sizeof (string1)); - memset (string2, 0, sizeof (string2)); + memset (thId, 0, sizeof (thId)); + memset (theme, 0, sizeof (theme)); if (!isempty (Line)) { - //T = &Themes[nThemes]; - if (sscanf (Line, "%[^=] =%[^\n] ", string1, string2) == 2) { - snprintf ((char *) Themes[nThemes], 255, "%s", string2); + if (sscanf (Line, "%[^=] =%[^\n] ", thId, theme) == 2 && !isempty (theme)) { + snprintf ((char *) Themes[id], 255, "%s", theme); + nThemes++; } else { - Themes[nThemes][0] = '\0'; + if (SkyThemes[id]) { + updateFile = true; + snprintf ((char *) Themes[id], 255, "%s", SkyThemes[id]); + LogD (1, prep("Theme '%s' missing in theme file '%s'"), SkyThemes[id], FileName.c_str()); + } else + Themes[id][0] = '\0'; } - //id ++; - nThemes++; + id ++; } } fclose (FileThemes); + + if (updateFile) { + FileThemes = fopen (FileName.c_str(), "w"); + if (FileThemes == NULL) { + LogE (0, prep("Error re-creating file '%s', %s"), FileName.c_str(), strerror (errno)); + } else { + for (int i = 0; i < 256; i++) { + if (Themes[nThemes]) { + fprintf (FileThemes, "0x%02x=%s\n", i, (char *) Themes[nThemes]); + } + else { + fprintf (FileThemes, "0x%02x=\n", i); + } + } + + LogI (0, prep("Success updating file '%s'"), FileName.c_str()); + fclose (FileThemes); + } + } } return true; } -- cgit v1.2.3 From 60376c4c1f0a4b65cb07b89d5c095015ec3b1215 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Fri, 22 Feb 2013 09:52:10 +0100 Subject: Added ability to translate themes. Examples added Fixed handling of duplicate epg entries Added new SKY themes Added checking/updating of themes files on load --- eepg.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 100 insertions(+), 15 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index ea5fd8c..a970479 100644 --- a/eepg.c +++ b/eepg.c @@ -49,7 +49,9 @@ #include #include +#include #include +#include #if defined(APIVERSNUM) && APIVERSNUM < 10401 @@ -416,7 +418,7 @@ static bool load_freesat_file (int tableid, const char *filename) return true; } -/** \brief Load an individual freesat data file +/** \brief Load an individual sky data file * * \param filename - Filename to load * \return Success of operation @@ -550,6 +552,75 @@ static bool load_sky_file (const char *filename) return true; } +#define THEME_TR ".tr" + +void load_theme_dictionaries (void) +{ + char Buffer[1024]; + char *Line; + FILE *File; + + DIR *dp = opendir(cSetupEEPG::getInstance()->getConfDir()); + struct dirent *dirp; + if(!dp) { + LogE (0, prep("Can't read configuration folder '%s'"), cSetupEEPG::getInstance()->getConfDir()); + return ; + } + + if (tableDict.size() > 0) + tableDict.clear(); + + + while ((dirp = readdir(dp)) != NULL) { + + string fname = dirp->d_name; // filename + if (dirp->d_type == DT_DIR || // if entry is a directory + fname.find(THEME_TR, (fname.length() - strlen(THEME_TR))) == string::npos){ + continue; + } + + fname = string(cSetupEEPG::getInstance()->getConfDir()) + "/" + fname; + + //Test if file is changed and reload + struct stat st; + if (stat(fname.c_str(), &st)) { + LogE(0, prep("Error obtaining stats for '%s' "), fname.c_str()); + continue; + } + + File = fopen (fname.c_str(), "r"); + if (!File) continue; + + memset (Buffer, 0, sizeof (Buffer)); + char origThemeName[256]; + char transThemeName[256]; + while ((Line = fgets (Buffer, sizeof (Buffer), File)) != NULL) { + Line = compactspace (skipspace (stripspace (Line))); + //Skip empty and commented lines + if (isempty (Line) || Line[0] == '#' || Line[0] == ';') continue; + if (sscanf (Line, "%[^=]=%[^\n]\n", origThemeName, transThemeName) == 2) { + + string origTh(compactspace (skipspace (stripspace (origThemeName)))); + string transTh(compactspace (skipspace (stripspace (transThemeName)))); + if (!tableDict.count(origTh) && !transTh.empty()) { + tableDict.insert(pair(string(origThemeName),string(transThemeName))); + LogD(4, prep("Original '%s' translation to '%s'."), origTh.c_str(), transTh.c_str()); + } + } //if scanf + } //while + fclose (File); + LogD(3, prep("Loaded %i translations from %s."), tableDict.size(), fname.c_str()); + } + closedir(dp); + + LogD(2, prep("Loaded %i translations."), tableDict.size()); + LogD(2, prep("Original <-> Translation")); + map::iterator it; + for ( it=tableDict.begin() ; it != tableDict.end(); it++ ) + LogD(2, prep("%s <-> %s"), (*it).first.c_str(), it->second.c_str()); + +} + /** \brief Decode an EPG string as necessary * * \param src - Possibly encoded string @@ -796,8 +867,8 @@ bool cFilterEEPG::GetThemesSKYBOX (void) //TODO can't we read this from the DVB LogE (0, prep("Error re-creating file '%s', %s"), FileName.c_str(), strerror (errno)); } else { for (int i = 0; i < 256; i++) { - if (Themes[nThemes]) { - fprintf (FileThemes, "0x%02x=%s\n", i, (char *) Themes[nThemes]); + if (Themes[i]) { + fprintf (FileThemes, "0x%02x=%s\n", i, (char *) Themes[i]); } else { fprintf (FileThemes, "0x%02x=\n", i); @@ -899,6 +970,7 @@ int cFilterEEPG::GetChannelsMHW (const u_char * Data, int Length) LogI(1, "|------|-%-26.26s-|-%-22.22s-|-----|-%-8.8s-|\n", "------------------------------", "-----------------------------", "--------------------"); int pName = ((nChannels * 8) + 121); //TODO double ... + LogD(1, prep("Length:%d pName:%d diff:%d"), Length, pName, Length - pName); for (int i = 0; i < nChannels; i++) { Channel = (sChannelMHW1 *) (Data + Off); sChannel *C = &sChannels[i]; @@ -983,6 +1055,7 @@ int cFilterEEPG::GetThemesMHW1 (const u_char * Data, int Length) theme = strreplace(theme,"DOC","DOCUMENTAIRE"); theme = strreplace(theme,"DOCUMENTAIRE.","DOCUMENTAIRE"); theme = strreplace(theme,"MAG","MAGAZINE"); + theme = strreplace(theme,"INFO-METEO","INFO/METEO"); //Remove category from genre. TODO Maybe they should be separated in the future theme = strreplace(theme,cat,""); theme = skipspace(theme); @@ -1282,23 +1355,28 @@ void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, if (SummText && ShTxtLen) { shText.assign(SummText,ShTxtLen); - + //LogD(0, prep("DEBUG: Title '%s', Subtitle '%s'"), Text, shText.c_str()); string tmpTitle(Text); if (Format == MHW2 && !shText.empty()) { size_t found = tmpTitle.find(" (HD)"); if (found != string::npos) tmpTitle.erase(found, 5); - found = shText.compare(0, tmpTitle.size() + 2, string(tmpTitle + ": ")); + //found = shText.compare(0, tmpTitle.size() + 2, string(tmpTitle + ": ")); if (shText.compare(0, tmpTitle.size() + 2, string(tmpTitle + ": "))==0) shText.erase(0, tmpTitle.size() + 2); + + //Remove Subtitle from title it is not pretty. + //int sumLen = strlen(SummText); + //if (sumLen > ShTxtLen) + // memmove(SummText,SummText + ShTxtLen + 1, sumLen - ShTxtLen); } //Do not use Subtitle if it is substring of Title if (tmpTitle.compare(0, shText.size(), shText) == 0) shText.clear(); - //The subtitle is wrong if contains '.' - if (Format == SKY_UK && !shText.empty() && shText.find('.') != string::npos) { + //The subtitle is wrong if contains '.' after possible initial '...' + if (Format == SKY_UK && !shText.empty() && shText.find('.',3) != string::npos) { shText.clear(); } @@ -1308,7 +1386,7 @@ void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, // the Description totally empty. So if the ShortText length exceeds // MAX_USEFUL_EPISODE_LENGTH, let's put this into the Description // instead: - if (!shText.empty() && shText.size() > MAX_USEFUL_EPISODE_LENGTH) + if (Format != SKY_IT && Format != MHW2 && !shText.empty() && shText.size() > MAX_USEFUL_EPISODE_LENGTH) shText.clear(); } @@ -1353,10 +1431,11 @@ void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, } string desc = SummText; -// if (stripspace(category)) desc.append("\n").append(CATEGORY).append(tr(category)); -// if (stripspace(genre)) desc += '\n' + string(GENRE) + tr(genre); - if (stripspace(category)) desc.append("\n").append(CATEGORY).append(category); - if (stripspace(genre)) desc += '\n' + string(GENRE) + genre; + if (Format == MHW2 && ShTxtLen) { + desc.erase(0, ShTxtLen + 1); + } + if (stripspace(category)) desc.append("\n").append(CATEGORY).append(findThemeTr(category)); + if (stripspace(genre)) desc += '\n' + string(GENRE) + findThemeTr(genre); Event->SetDescription (desc.c_str()); free(theme); @@ -1367,7 +1446,7 @@ void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, if (ThemeId) { char *theme; Asprintf (&theme, "0x%x", ThemeId); - LogD(0, prep("DEBUG: missing theme ID 0x%x"), ThemeId); + LogD(0, prep("DEBUG: missing theme ID 0x%x title:'%s'"), ThemeId, Event->Title()); desc += '\n' + string(GENRE) + theme; free(theme); } @@ -2428,7 +2507,11 @@ int cFilterEEPG::GetSummariesSKYBOX (const u_char * Data, int Length) S->Text[Len2] = '\0'; //end string with NULL character CleanString (S->Text); char * delim = strstr ( (char *)S->Text, STxtDelim ); - S->ShortTextLength = delim == NULL ? 0 : delim - (char *)S->Text; + //S->ShortTextLength = delim == NULL ? 0 : delim - (char *)S->Text; + if (Format == SKY_UK && !delim && strncmp((char *)S->Text,"...",3) == 0) + delim = strstr ( (char *)(S->Text+3), "." ); + int shLen = delim - (char *)S->Text; + S->ShortTextLength = delim == NULL || shLen > numeric_limits::max() ? 0 : shLen; LogI(4, prep("EventId %08x Summnr %d:%.30s."), S->EventId, nSummaries, S->Text); p += Len1; nSummaries++; @@ -2624,7 +2707,8 @@ void cFilterEEPG::LoadIntoSchedule (void) i++; //move to next title, for this one no summary can be found } - if (SummIndex != -1 && isOTV){ + //Do not loop through summaries for OTV when sumaries and titles are in sync + if (SummIndex != -1 && isOTV && nSummaries <= nTitles){ j--; } @@ -3566,6 +3650,7 @@ bool cPluginEEPG::Start (void) CheckCreateFile("sky_uk.themes", SkyUkThemes); CheckCreateFile("freesat.t1", FreesatT1); CheckCreateFile("freesat.t2", FreesatT2); + load_theme_dictionaries(); sky_tables[0] = NULL; sky_tables[1] = NULL; -- cgit v1.2.3 From ec10b1df60b96477c8cb5e24d9833eb4bdb75f99 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Mon, 6 Jan 2014 20:42:30 +0100 Subject: fixed compile with VDR 2.1.3 --- eepg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index a970479..ac2f9fa 100644 --- a/eepg.c +++ b/eepg.c @@ -3553,7 +3553,7 @@ private: struct { cFilterEEPG *filter; cDevice *device; - } epg[MAXDVBDEVICES]; + } epg[MAXDEVICES]; void CheckCreateFile(const char* Name, const char *fileContent[]); @@ -3618,7 +3618,7 @@ bool cPluginEEPG::Start (void) #if APIVERSNUM < 10507 RegisterI18n (Phrases); #endif - for (int i = 0; i < MAXDVBDEVICES; i++) { + for (int i = 0; i < MAXDEVICES; i++) { cDevice *dev = cDevice::GetDevice (i); if (dev) { epg[i].device = dev; @@ -3684,7 +3684,7 @@ bool cPluginEEPG::Start (void) void cPluginEEPG::Stop (void) { - for (int i = 0; i < MAXDVBDEVICES; i++) { + for (int i = 0; i < MAXDEVICES; i++) { cDevice *dev = epg[i].device; if (dev) dev->Detach (epg[i].filter); -- cgit v1.2.3 From 6a6db913ac85b4144f3144ab50a7e6f89ef9640b Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Mon, 17 Mar 2014 09:07:13 +0100 Subject: Ipdated Makefile and skyuk shorttext extraction --- eepg.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index ac2f9fa..10e966e 100644 --- a/eepg.c +++ b/eepg.c @@ -2508,8 +2508,13 @@ int cFilterEEPG::GetSummariesSKYBOX (const u_char * Data, int Length) CleanString (S->Text); char * delim = strstr ( (char *)S->Text, STxtDelim ); //S->ShortTextLength = delim == NULL ? 0 : delim - (char *)S->Text; - if (Format == SKY_UK && !delim && strncmp((char *)S->Text,"...",3) == 0) - delim = strstr ( (char *)(S->Text+3), "." ); + if (Format == SKY_UK && !delim && strncmp((char *)S->Text,"..",2) == 0) { + char * tdlm = strpbrk ( (char *)(S->Text+3), ".?!" ); + if (tdlm && tdlm[0] != '.') + tdlm++; + if (tdlm) + delim = tdlm; + } int shLen = delim - (char *)S->Text; S->ShortTextLength = delim == NULL || shLen > numeric_limits::max() ? 0 : shLen; LogI(4, prep("EventId %08x Summnr %d:%.30s."), S->EventId, nSummaries, S->Text); -- cgit v1.2.3 From 7f7ec60c3654f318fc4ec918a29b8b95c8c4a25e Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Fri, 17 Jun 2016 21:04:11 +0200 Subject: vdr 2.3.1 compatibility --- eepg.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 18 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index f55f9ed..afab8bc 100644 --- a/eepg.c +++ b/eepg.c @@ -1001,7 +1001,7 @@ int cFilterEEPG::GetChannelsMHW (const u_char * Data, int Length) C->Tid = HILO16 (Channel->TransportId); C->Sid = HILO16 (Channel->ServiceId); tChannelID channelID = tChannelID (C->Src, C->Nid, C->Tid, C->Sid); - cChannel *VC = GetChannelByID(channelID, true); + const cChannel *VC = GetChannelByID(channelID, true); bool IsFound = (VC); if(IsFound) { C->Src = VC->Source(); @@ -1515,8 +1515,12 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor unsigned short int CurrentYear = tmCurrent->tm_year; unsigned short int CurrentMonth = tmCurrent->tm_mon; //esyslog("EEPGDEBUG: CurrentMonthday=%i, TableIdExtension:%04x, MonthdayTitles=%i.",CurrentMonthday,TableIdExtension, MonthdayTitles); +#if APIVERSNUM >= 20300 + LOCK_SCHEDULES_WRITE; +#else cSchedulesLock SchedulesLock (true); - cSchedules *s = (cSchedules *) cSchedules::Schedules (SchedulesLock); + cSchedules *Schedules = (cSchedules *) cSchedules::Schedules (SchedulesLock); +#endif do { //process each block of titles sTitleBlockNagraGuide *TB = (sTitleBlockNagraGuide *) p; int ChannelId = HILO16 (TB->ChannelId); @@ -1535,7 +1539,7 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor sChannel *C = &sChannels[ChannelSeq[ChannelId]]; //find channel //cSchedule *ps = NULL;//[MAX_EQUIVALENCES]; - //PrepareToWriteToSchedule (C, s, ps); + //PrepareToWriteToSchedule (C, Schedules, ps); for (int i = 0; i < NumberOfTitles; i++) { //process each title within block sTitleNagraGuide *Title = (sTitleNagraGuide *) p; @@ -1586,7 +1590,7 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor if (Themes[Title->ThemeId][0] == 0x00) //if detailed themeid is not known, get global themeid Title->ThemeId &= 0xf0; - WriteToSchedule (tChannelID (C->Src, C->Nid, C->Tid, C->Sid), s, EventId, StartTime, Title->Duration, Text, SummText, + WriteToSchedule (tChannelID (C->Src, C->Nid, C->Tid, C->Sid), Schedules, EventId, StartTime, Title->Duration, Text, SummText, Title->ThemeId, NAGRA_TABLE_ID, Version); if (Text != NULL) @@ -1625,7 +1629,7 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor } //end for titles //FinishWriteToSchedule (C, s, ps); - sortSchedules(s, tChannelID (C->Src, C->Nid, C->Tid, C->Sid)); + sortSchedules(Schedules, tChannelID (C->Src, C->Nid, C->Tid, C->Sid)); p = next_p; } while (p < DataEnd); //end of TitleBlock } @@ -1748,7 +1752,7 @@ int cFilterEEPG::GetChannelsNagra (const u_char * Data, int Length) C->Tid = HILO16 (Channel->TransportId); C->Sid = HILO16 (Channel->ServiceId); tChannelID channelID = tChannelID(C->Src, C->Nid, C->Tid, C->Sid); - cChannel *VC = GetChannelByID(channelID, true); + const cChannel *VC = GetChannelByID(channelID, true); bool IsFound = (VC); if(IsFound) { strncpy((char*)(C->Name), VC->Name (), 64); @@ -2318,7 +2322,7 @@ int cFilterEEPG::GetChannelsSKYBOX (const u_char * Data, int Length) C->Sid = Sid; C->SkyNumber = SkyNumber; tChannelID channelID = tChannelID (C->Src, C->Nid, C->Tid, C->Sid); - cChannel *VC = Channels.GetByChannelID (channelID, true); + const cChannel *VC = GetChannelByID (channelID, false); bool IsFound = (VC); if (IsFound) strncpy ((char *) C->Name, VC->Name (), 64); @@ -2592,9 +2596,13 @@ void cFilterEEPG::LoadIntoSchedule (void) bool isOTV = Format == SKY_IT || Format == SKY_UK; { +#if APIVERSNUM >= 20300 + LOCK_SCHEDULES_WRITE; +#else cSchedulesLock SchedulesLock (true); - cSchedules *s = (cSchedules *) cSchedules::Schedules (SchedulesLock); - if (s) { + cSchedules *Schedules = (cSchedules *) cSchedules::Schedules (SchedulesLock); +#endif + if (Schedules) { while (i < nTitles) { S = Summaries[j]; @@ -2646,7 +2654,7 @@ void cFilterEEPG::LoadIntoSchedule (void) //channelids are sequentially numbered and sent in MHW1 and MHW2, but not in SKY, so we need to lookup the table index sChannel *C = &sChannels[ChannelSeq[ChannelId]]; //find channel //cSchedule *p;//[MAX_EQUIVALENCES]; - //PrepareToWriteToSchedule (C, s, p); + //PrepareToWriteToSchedule (C, Schedules, p); tChannelID chanID = tChannelID (C->Src, C->Nid, C->Tid, C->Sid); char rating = 0x00; @@ -2661,12 +2669,12 @@ void cFilterEEPG::LoadIntoSchedule (void) // LogD (0, prep("EventId %08x Titlenr:%d,SummNr:%d,SummAv:%x,Un1:%x,Un2:%x,Un3:%x,Name:%s,STxtLn:%d,Summary:%s."), // T->EventId, i, j, T->SummaryAvailable, T->Unknown1, T->Unknown2, T->Unknown3, T->Text, S->ShortTextLength, S->Text); - WriteToSchedule (chanID, s, T->EventId, StartTime, T->Duration / 60, (char *) T->Text, + WriteToSchedule (chanID, Schedules, T->EventId, StartTime, T->Duration / 60, (char *) T->Text, (char *) S->Text, T->ThemeId, TableId, 0, rating, S->ShortTextLength); - sortSchedules(s, chanID); + sortSchedules(Schedules, chanID); //if (shortText != NULL) delete [] shortText; - //FinishWriteToSchedule (C, s, p); + //FinishWriteToSchedule (C, Schedules, p); //Replays--; //if ((S->NumReplays != 0) && (Replays > 0)) { //when replays are used, all summaries of the replays are stored consecutively; currently only CSAT //j++; //move to next summary @@ -2704,15 +2712,15 @@ void cFilterEEPG::LoadIntoSchedule (void) sChannel *C = &sChannels[ChannelSeq[T->ChannelId]]; //find channel //cSchedule *p;//[MAX_EQUIVALENCES]; tChannelID chanID = tChannelID (C->Src, C->Nid, C->Tid, C->Sid); - //PrepareToWriteToSchedule (C, s, p); + //PrepareToWriteToSchedule (C, Schedules, p); char rating = 0x00; if (!isOTV && T->Rating) { //TODO only works on OTV for now rating = T->Rating; } - WriteToSchedule (chanID, s, T->EventId, T->StartTime, T->Duration / 60, (char *) T->Text, + WriteToSchedule (chanID, Schedules, T->EventId, T->StartTime, T->Duration / 60, (char *) T->Text, NULL, T->ThemeId, DEFAULT_TABLE_ID, 0, rating, S->ShortTextLength); - //FinishWriteToSchedule (C, s, p); - sortSchedules(s, chanID); + //FinishWriteToSchedule (C, Schedules, p); + sortSchedules(Schedules, chanID); SummariesNotFound++; } @@ -2909,12 +2917,19 @@ void cFilterEEPG::ProccessContinuous(u_short Pid, u_char Tid, int Length, const { //0x39 Viasat, 0x0300 Dish Network EEPG, 0x0441 Bell ExpressVU EEPG LogD(4, prep("Pid: 0x%02x Tid: %d Length: %d"), Pid, Tid, Length); +#if APIVERSNUM >= 20300 + LOCK_SCHEDULES_WRITE; +// cStateKey SchedulesStateKey; +// cSchedules *Schedules = cSchedules::GetSchedulesWrite(SchedulesStateKey, 10); +#else cSchedulesLock SchedulesLock(true, 10); cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); +#endif //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, Format, Pid == EIT_PID); +#if APIVERSNUM < 20300 else//cEIT EIT (Schedules, Source (), Tid, Data); { // If we don't get a write lock, let's at least get a read lock, so @@ -2928,6 +2943,7 @@ void cFilterEEPG::ProccessContinuous(u_short Pid, u_char Tid, int Length, const //cEIT EIT (Schedules, Source (), Tid, Data, true); } +#endif } void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Length) @@ -3295,8 +3311,12 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) SI::PremiereCIT cit(Data, false); if (cit.CheckCRCAndParse ()) { +#if APIVERSNUM >= 20300 + LOCK_SCHEDULES_WRITE; +#else cSchedulesLock SchedulesLock (true, 10); cSchedules *Schedules = (cSchedules *) cSchedules::Schedules (SchedulesLock); +#endif if (Schedules) { int now = time (0); int nCount = 0; @@ -3438,7 +3458,12 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) } } tChannelID channelID (Source (), nid, tid, sid); +#if APIVERSNUM >= 20300 + LOCK_CHANNELS_READ; + const cChannel *channel = Channels->GetByChannelID (channelID, true); +#else cChannel *channel = Channels.GetByChannelID (channelID, true); +#endif if (!channel) continue; @@ -3543,7 +3568,11 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data) } if (Modified) { pSchedule->Sort (); +#if APIVERSNUM >= 20300 + pSchedule->SetModified(); +#else Schedules->SetModified (pSchedule); +#endif } delete pct; } @@ -3669,7 +3698,12 @@ bool cPluginEEPG::Start (void) tables[0][0] = NULL; //store all available sources, so when a channel is not found on current satellite, we can look for alternate sat positions. //perhaps this can be done smarter through existing VDR function??? - for (cChannel * Channel = Channels.First (); Channel; Channel = Channels.Next (Channel)) { +#if APIVERSNUM >= 20300 + LOCK_CHANNELS_READ; + for (const cChannel * Channel = Channels->First(); Channel; Channel = Channels->Next(Channel)) { +#else + for (const cChannel * Channel = Channels.First (); Channel; Channel = Channels.Next (Channel)) { +#endif if (!Channel->GroupSep ()) { bool found = false; for (int i = 0; (i < NumberOfAvailableSources) && (!found); i++) -- cgit v1.2.3 From 7e30f7b7c80d41883ec9b0187dc9c47b6765a4d1 Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 11 Aug 2018 14:27:23 +0200 Subject: fix wrong lock sequence thanks to Matthias Feistel --- eepg.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index afab8bc..b829d10 100644 --- a/eepg.c +++ b/eepg.c @@ -2918,6 +2918,7 @@ void cFilterEEPG::ProccessContinuous(u_short Pid, u_char Tid, int Length, const //0x39 Viasat, 0x0300 Dish Network EEPG, 0x0441 Bell ExpressVU EEPG LogD(4, prep("Pid: 0x%02x Tid: %d Length: %d"), Pid, Tid, Length); #if APIVERSNUM >= 20300 + LOCK_CHANNELS_WRITE; LOCK_SCHEDULES_WRITE; // cStateKey SchedulesStateKey; // cSchedules *Schedules = cSchedules::GetSchedulesWrite(SchedulesStateKey, 10); @@ -2926,8 +2927,8 @@ void cFilterEEPG::ProccessContinuous(u_short Pid, u_char Tid, int Length, const cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); #endif //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, Format, Pid == EIT_PID); + if(Channels && Schedules) + SI::cEIT2 EIT(Channels, Schedules, Source(), Tid, Data, Format, Pid == EIT_PID); #if APIVERSNUM < 20300 else//cEIT EIT (Schedules, Source (), Tid, Data); @@ -2936,10 +2937,12 @@ void cFilterEEPG::ProccessContinuous(u_short Pid, u_char Tid, int Length, const // 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) + cChannelsLock ChannelsLock; + cChannels *Channels = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); cSchedulesLock SchedulesLock; cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); - if(Schedules) - SI::cEIT2 EIT(Schedules, Source(), Tid, Data, Format, Pid == EIT_PID, true); + if(Channels && Schedules) + SI::cEIT2 EIT(Channels, Schedules, Source(), Tid, Data, Format, Pid == EIT_PID, true); //cEIT EIT (Schedules, Source (), Tid, Data, true); } -- cgit v1.2.3 From ca0c9dda448ffe0cd71e85cbc5b1f9c10203e1ad Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Sat, 11 Aug 2018 14:30:48 +0200 Subject: silence warnings --- eepg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'eepg.c') diff --git a/eepg.c b/eepg.c index b829d10..b319a46 100644 --- a/eepg.c +++ b/eepg.c @@ -2645,7 +2645,7 @@ void cFilterEEPG::LoadIntoSchedule (void) } index++; - if ((StartTime + T->Duration) < too_old) { + if ((StartTime + (int)T->Duration) < too_old) { LogD(3, prep("Skipping old event '%s', start time:%s"), T->Text, ctime (&StartTime)); OldEvents++; continue; @@ -2699,7 +2699,7 @@ void cFilterEEPG::LoadIntoSchedule (void) // esyslog("EEPG Error: lost sync at title %d, summary %d.",i,j); } else if (j == (remembersummary - 1) || SummIndex !=-1) { //the last summary to be checked has failed also //esyslog ("EEPG Error: could not find summary for summary-available Title %d.", i); - if ((T->StartTime + T->Duration) < too_old) { + if ((T->StartTime + T->Duration) < (uint)too_old) { LogD(3, prep("Skipping old event '%s' without summary, start time:%s"), T->Text, ctime ((time_t*)&T->StartTime)); OldEvents++; } else { -- cgit v1.2.3