diff options
-rw-r--r-- | eit2.c | 216 | ||||
-rw-r--r-- | epghandler.c | 17 | ||||
-rw-r--r-- | epghandler.h | 1 | ||||
-rw-r--r-- | setupeepg.c | 1 | ||||
-rw-r--r-- | util.c | 7 | ||||
-rw-r--r-- | util.h | 2 |
6 files changed, 101 insertions, 143 deletions
@@ -124,21 +124,16 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, //LogD(2, prep("EEPGDEBUG:d->getDescriptorTAG():%x)"), d->getDescriptorTag ()); nDescriptorTag = d->getDescriptorTag(); - switch (nDescriptorTag) - { - case SI::ExtendedEventDescriptorTag: - { - SI::ExtendedEventDescriptor * eed = - (SI::ExtendedEventDescriptor *) d; - if (I18nIsPreferredLanguage(Setup.EPGLanguages, eed->languageCode, - LanguagePreferenceExt) || !ExtendedEventDescriptors) - { + switch (nDescriptorTag) { + case SI::ExtendedEventDescriptorTag: { + SI::ExtendedEventDescriptor * eed = (SI::ExtendedEventDescriptor *) d; + if (I18nIsPreferredLanguage(Setup.EPGLanguages, eed->languageCode, LanguagePreferenceExt) + || !ExtendedEventDescriptors) { delete ExtendedEventDescriptors; ExtendedEventDescriptors = new SI::ExtendedEventDescriptors; UseExtendedEventDescriptor = true; } - if (UseExtendedEventDescriptor) - { + if (UseExtendedEventDescriptor) { ExtendedEventDescriptors->Add(eed); d = NULL; // so that it is not deleted } @@ -146,12 +141,10 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, UseExtendedEventDescriptor = false; } break; - case SI::ShortEventDescriptorTag: - { + case SI::ShortEventDescriptorTag: { SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d; - if (I18nIsPreferredLanguage(Setup.EPGLanguages, sed->languageCode, - LanguagePreferenceShort) || !ShortEventDescriptor) - { + if (I18nIsPreferredLanguage(Setup.EPGLanguages, sed->languageCode, LanguagePreferenceShort) + || !ShortEventDescriptor) { delete ShortEventDescriptor; ShortEventDescriptor = sed; d = NULL; // so that it is not deleted @@ -159,71 +152,51 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, } break; #if APIVERSNUM > 10711 - case SI::ContentDescriptorTag: - { + case SI::ContentDescriptorTag: { SI::ContentDescriptor *cd = (SI::ContentDescriptor *) d; SI::ContentDescriptor::Nibble Nibble; int NumContents = 0; - uchar Contents[MaxEventContents] = - { 0 }; - for (SI::Loop::Iterator it3; cd->nibbleLoop.getNext(Nibble, it3);) - { - if (NumContents < MaxEventContents) - { - Contents[NumContents] = ((Nibble.getContentNibbleLevel1() - & 0xF) << 4) | (Nibble.getContentNibbleLevel2() & 0xF); + uchar Contents[MaxEventContents] = { 0 }; + for (SI::Loop::Iterator it3; cd->nibbleLoop.getNext(Nibble, it3);) { + if (NumContents < MaxEventContents) { + Contents[NumContents] = ((Nibble.getContentNibbleLevel1() & 0xF) << 4) + | (Nibble.getContentNibbleLevel2() & 0xF); NumContents++; } - if (DishEventDescriptor && NumContents == 1) - { + if (DishEventDescriptor && NumContents == 1) { DishEventDescriptor->setContent(Nibble); } // LogD(2, prep("EEPGDEBUG:Nibble:%x-%x-%x-%x)"), Nibble.getContentNibbleLevel1(),Nibble.getContentNibbleLevel2() - // , Nibble.getUserNibble1(), Nibble.getUserNibble2()); + // , Nibble.getUserNibble1(), Nibble.getUserNibble2()); } pEvent->SetContents(Contents); } break; #endif - case SI::ParentalRatingDescriptorTag: - { + case SI::ParentalRatingDescriptorTag: { int LanguagePreferenceRating = -1; - SI::ParentalRatingDescriptor *prd = - (SI::ParentalRatingDescriptor *) d; + SI::ParentalRatingDescriptor *prd = (SI::ParentalRatingDescriptor *) d; SI::ParentalRatingDescriptor::Rating Rating; - for (SI::Loop::Iterator it3; prd->ratingLoop.getNext(Rating, it3);) - { - if (I18nIsPreferredLanguage(Setup.EPGLanguages, - Rating.languageCode, LanguagePreferenceRating)) - { + for (SI::Loop::Iterator it3; prd->ratingLoop.getNext(Rating, it3);) { + if (I18nIsPreferredLanguage(Setup.EPGLanguages, Rating.languageCode, + LanguagePreferenceRating)) { int ParentalRating = (Rating.getRating() & 0xFF); - switch (ParentalRating) - { + switch (ParentalRating) { // values defined by the DVB standard (minimum age = rating + 3 years): - case 0x01 ... 0x0F: - ParentalRating += 3; - break; + case 0x01 ... 0x0F: ParentalRating += 3; break; // values defined by broadcaster CSAT (now why didn't they just use 0x07, 0x09 and 0x0D?): - case 0x11: - ParentalRating = 10; - break; - case 0x12: - ParentalRating = 12; - break; - case 0x13: - ParentalRating = 16; - break; - default: - ParentalRating = 0; + case 0x11: ParentalRating = 10; break; + case 0x12: ParentalRating = 12; break; + case 0x13: ParentalRating = 16; break; + default: ParentalRating = 0; } pEvent->SetParentalRating(ParentalRating); } } } break; - case SI::PDCDescriptorTag: - { + case SI::PDCDescriptorTag: { SI::PDCDescriptor * pd = (SI::PDCDescriptor *) d; time_t now = time(NULL); struct tm tm_r; @@ -238,23 +211,19 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, if (month == 11 && t.tm_mon == 0) // current month is dec, but event is in jan t.tm_year++; else if (month == 0 && t.tm_mon == 11) // current month is jan, but event is in dec - t.tm_year--; + t.tm_year--; time_t vps = mktime(&t); pEvent->SetVps(vps); } break; - case SI::TimeShiftedEventDescriptorTag: - { + case SI::TimeShiftedEventDescriptorTag: { if (Schedules) { - SI::TimeShiftedEventDescriptor * tsed = - (SI::TimeShiftedEventDescriptor *) d; + SI::TimeShiftedEventDescriptor * tsed = (SI::TimeShiftedEventDescriptor *) d; cSchedule *rSchedule = (cSchedule *) Schedules->GetSchedule( - tChannelID(Source, channel->Nid(), channel->Tid(), - tsed->getReferenceServiceId())); + tChannelID(Source, channel->Nid(), channel->Tid(), tsed->getReferenceServiceId())); if (!rSchedule) break; - rEvent = (cEvent *) rSchedule->GetEvent( - tsed->getReferenceEventId()); + rEvent = (cEvent *) rSchedule->GetEvent(tsed->getReferenceEventId()); if (!rEvent) break; pEvent->SetTitle(rEvent->Title()); @@ -263,63 +232,49 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, } } break; - case SI::LinkageDescriptorTag: - { + case SI::LinkageDescriptorTag: { SI::LinkageDescriptor * ld = (SI::LinkageDescriptor *) d; - tChannelID linkID(Source, ld->getOriginalNetworkId(), - ld->getTransportStreamId(), ld->getServiceId()); - if (ld->getLinkageType() == 0xB0) - { // Premiere World + tChannelID linkID(Source, ld->getOriginalNetworkId(), ld->getTransportStreamId(), + ld->getServiceId()); + if (ld->getLinkageType() == 0xB0) { // Premiere World time_t now = time(NULL); - bool hit = SiEitEvent->getStartTime() <= now - && now - < SiEitEvent->getStartTime() + SiEitEvent->getDuration(); - if (hit) - { - char linkName[ld->privateData.getLength() + 1]; - strn0cpy(linkName, (const char *) ld->privateData.getData(), - sizeof(linkName)); - // TODO is there a standard way to determine the character set of this string? - cChannel *link = Channels.GetByChannelID(linkID); - if (link != channel) - { // only link to other channels, not the same one - //fprintf(stderr, "Linkage %s %4d %4d %5d %5d %5d %5d %02X '%s'\n", hit ? "*" : "", channel->Number(), link ? link->Number() : -1, SiEitEvent.getEventId(), ld->getOriginalNetworkId(), ld->getTransportStreamId(), ld->getServiceId(), ld->getLinkageType(), linkName);//XXX - if (link) - { - if (Setup.UpdateChannels == 1 - || Setup.UpdateChannels >= 3) - link->SetName(linkName, "", ""); - } - else if (Setup.UpdateChannels >= 4) - { - cChannel *transponder = channel; - if (channel->Tid() != ld->getTransportStreamId()) - transponder = Channels.GetByTransponderID(linkID); - link = Channels.NewChannel(transponder, linkName, - "", "", ld->getOriginalNetworkId(), - ld->getTransportStreamId(), ld->getServiceId()); - } - if (link) - { - if (!LinkChannels) - LinkChannels = new cLinkChannels; - LinkChannels->Add(new cLinkChannel(link)); + bool hit = SiEitEvent->getStartTime() <= now + && now < SiEitEvent->getStartTime() + SiEitEvent->getDuration(); + if (hit) { + char linkName[ld->privateData.getLength() + 1]; + strn0cpy(linkName, (const char *) ld->privateData.getData(), sizeof(linkName)); + // TODO is there a standard way to determine the character set of this string? + cChannel *link = Channels.GetByChannelID(linkID); + if (link != channel) { // only link to other channels, not the same one + //fprintf(stderr, "Linkage %s %4d %4d %5d %5d %5d %5d %02X '%s'\n", hit ? "*" : "", channel->Number(), link ? link->Number() : -1, SiEitEvent.getEventId(), ld->getOriginalNetworkId(), ld->getTransportStreamId(), ld->getServiceId(), ld->getLinkageType(), linkName);//XXX + if (link) { + if (Setup.UpdateChannels == 1 || Setup.UpdateChannels >= 3) + link->SetName(linkName, "", ""); + } + else if (Setup.UpdateChannels >= 4) { + cChannel *transponder = channel; + if (channel->Tid() != ld->getTransportStreamId()) + transponder = Channels.GetByTransponderID(linkID); + link = Channels.NewChannel(transponder, linkName, "", "", ld->getOriginalNetworkId(), + ld->getTransportStreamId(), ld->getServiceId()); + } + if (link) { + if (!LinkChannels) LinkChannels = new cLinkChannels; + LinkChannels->Add(new cLinkChannel(link)); + } } + else + channel->SetPortalName(linkName); } - else - channel->SetPortalName(linkName); - } } } break; - case SI::ComponentDescriptorTag: - { + case SI::ComponentDescriptorTag: { SI::ComponentDescriptor * cd = (SI::ComponentDescriptor *) d; uchar Stream = cd->getStreamContent(); uchar Type = cd->getComponentType(); //if (1 <= Stream && Stream <= 3 && Type != 0) { // 1=video, 2=audio, 3=subtitles - if (1 <= Stream && Stream <= 6 && Type != 0) - { // 1=MPEG2-video, 2=MPEG1-audio, 3=subtitles, 4=AC3-audio, 5=H.264-video, 6=HEAAC-audio + if (1 <= Stream && Stream <= 6 && Type != 0) { // 1=MPEG2-video, 2=MPEG1-audio, 3=subtitles, 4=AC3-audio, 5=H.264-video, 6=HEAAC-audio if (!Components) Components = new cComponents; char buffer[Utf8BufSize (256)]; @@ -329,36 +284,27 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, } } break; - case SI::DishExtendedEventDescriptorTag: - { - SI::UnimplementedDescriptor *deed = - (SI::UnimplementedDescriptor *) d; - if (!DishEventDescriptor) - { + case SI::DishExtendedEventDescriptorTag: { + SI::UnimplementedDescriptor *deed = (SI::UnimplementedDescriptor *) d; + if (!DishEventDescriptor) { DishEventDescriptor = new SI::DishDescriptor(); } DishEventDescriptor->setExtendedtData(Tid + 1, deed->getData()); // HasExternalData = true; } break; - case SI::DishShortEventDescriptorTag: - { - SI::UnimplementedDescriptor *dsed = - (SI::UnimplementedDescriptor *) d; - if (!DishEventDescriptor) - { + case SI::DishShortEventDescriptorTag: { + SI::UnimplementedDescriptor *dsed = (SI::UnimplementedDescriptor *) d; + if (!DishEventDescriptor) { DishEventDescriptor = new SI::DishDescriptor(); } DishEventDescriptor->setShortData(Tid + 1, dsed->getData()); // HasExternalData = true; } break; - case SI::DishRatingDescriptorTag: - { - if (d->getLength() == 4) - { - if (!DishEventDescriptor) - { + case SI::DishRatingDescriptorTag: { + if (d->getLength() == 4) { + if (!DishEventDescriptor) { DishEventDescriptor = new SI::DishDescriptor(); } uint16_t rating = d->getData().TwoBytes(2); @@ -366,13 +312,10 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, } } break; - case SI::DishSeriesDescriptorTag: - { - if (d->getLength() == 10) - { + case SI::DishSeriesDescriptorTag: { + if (d->getLength() == 10) { //LogD(2, prep("DishSeriesDescriptorTag: %s)"), (const char*) d->getData().getData()); - if (!DishEventDescriptor) - { + if (!DishEventDescriptor) { DishEventDescriptor = new SI::DishDescriptor(); } DishEventDescriptor->setEpisodeInfo(d->getData()); @@ -467,7 +410,6 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, pEvent->SetDescription(tmp); free(tmp); - //LogD(2, prep("DishDescription: %s"), DishEventDescriptor->getDescription()); //LogD(2, prep("DishShortText: %s"), DishEventDescriptor->getShortText()); } @@ -632,7 +574,7 @@ cEIT2::cEIT2 (cSchedule * Schedule) bool searchOtherSatPositions = Format == DISH_BEV; - tChannelID channelID (Schedule->ChannelID().Source(), getOriginalNetworkId (), getTransportStreamId (), getServiceId ()); + tChannelID channelID = Schedule->ChannelID(); channel = GetChannelByID (channelID, searchOtherSatPositions); if (!channel) { LogD(3, prep("!channel channelID: %s"), *channelID.ToString()); diff --git a/epghandler.c b/epghandler.c index 0262d75..5f10a3c 100644 --- a/epghandler.c +++ b/epghandler.c @@ -16,6 +16,7 @@ cEEpgHandler::cEEpgHandler() { LogD(4, prep("cEEpgHandler()")); equivHandler = new cEquivHandler(); + modified = false; } cEEpgHandler::~cEEpgHandler() { @@ -48,6 +49,7 @@ bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, } } + modified = false; //VDR creates new event if the EitEvent StartTime is different than EEPG time so //the EEPG event has to be deleted but the data should be kept const cEvent* ev = Schedule->GetEvent(EitEvent->getEventId(),EitEvent->getStartTime()); @@ -63,6 +65,7 @@ bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule, origShortText = ev->ShortText(); Schedule->DropOutdated(ev->StartTime()-1,ev->EndTime()+1,ev->TableID()-1,ev->Version()); LogD(0, prep("!!!End Deleting Event")); + //TODO equivalent channels !!! } } @@ -80,8 +83,11 @@ bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) { bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) { LogD(3, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title); - if (!Event->Title() || (Title && (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title))))) + if (!Event->Title() || (Title && (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title))))) { + //LogD(0, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title); + modified = true; Event->SetTitle(Title); + } return true; } @@ -107,6 +113,10 @@ bool cEEpgHandler::SetDescription(cEvent* Event, const char* Description) { origDescription = Event->Description(); else origDescription.clear(); + + //Based on asumption that SetDescription is always called after SetTitle + if (!modified && Description && (!Event->Description() || strcmp(Event->Description(),Description) )) + modified = true; //if (!Event->Description() || Description && (!strcmp(Event->Description(),"") || (strcmp(Description,"") && strcmp(Event->Description(),Description)))) Event->SetDescription(Description); @@ -146,14 +156,15 @@ bool cEEpgHandler::HandleEvent(cEvent* Event) { if (!Event->ShortText() || !strcmp(Event->ShortText(),"")) Event->SetShortText(origShortText.c_str()); - if (!Event->Description() && !origDescription.empty()) { + if ((!Event->Description() && !origDescription.empty()) || (Event->Description() && !origDescription.empty() && origDescription.find(Event->Description()) != string::npos) ) { Event->SetDescription(origDescription.c_str()); } if (equivHandler->getEquiChanMap().count(*Event->ChannelID().ToString()) <= 0) return true; - equivHandler->updateEquivalent(Event->ChannelID(), Event); + if (modified) + equivHandler->updateEquivalent(Event->ChannelID(), Event); // cSchedulesLock SchedulesLock (true); // cSchedules *s = (cSchedules *) cSchedules::Schedules (SchedulesLock); diff --git a/epghandler.h b/epghandler.h index 4e60e57..003fd32 100644 --- a/epghandler.h +++ b/epghandler.h @@ -41,6 +41,7 @@ private: std::string origDescription; cEquivHandler* equivHandler; static const int _LONG_EVENT_HOURS = 10; + bool modified; }; #endif /*APIVERSNUM > 10725*/ diff --git a/setupeepg.c b/setupeepg.c index ee2565e..c0dff6a 100644 --- a/setupeepg.c +++ b/setupeepg.c @@ -13,6 +13,7 @@ cSetupEEPG* cSetupEEPG::_setupEEPG = NULL; cSetupEEPG::cSetupEEPG (void) +:ConfDir(NULL) { ConfDir = NULL; OptPat = 1; @@ -123,7 +123,7 @@ void CleanString (unsigned char *String) } Src++; } - if (Spaces > 0) { + if (Spaces > 0 && String && String < Dst) { Dst--; *Dst = 0; } else { @@ -192,6 +192,7 @@ cAddEventThread::~cAddEventThread(void) void cAddEventThread::Action(void) { + LogD (0, prep("Action")); SetPriority(19); while (Running() && !LastHandleEvent.TimedOut()) { // cAddEventListItem *e = NULL; @@ -251,7 +252,7 @@ void cAddEventThread::AddEvent(cEvent *Event, tChannelID ChannelID) LogD (0, prep("AddEventT else")); (*map_list->find(ChannelID)).second->Add(Event); } -// list->Add(new cAddEventListItem(Event, ChannelID)); +// LogD (0, prep("AddEventT %s channel: <%s>"), Event->Title(), *ChannelID.ToString()); LastHandleEvent.Set(INSERT_TIMEOUT_IN_MS); LogD (0, prep("AddEventT end")); } @@ -262,7 +263,7 @@ static cAddEventThread AddEventThread; void AddEvent(cEvent *Event, tChannelID ChannelID) { - LogD (0, prep("AddEvent")); +// LogD (0, prep("AddEvent %s channel: <%s>"), Event->Title(), *ChannelID.ToString()); AddEventThread.AddEvent(Event, ChannelID); if (!AddEventThread.Active()) AddEventThread.Start(); @@ -8,6 +8,8 @@ #ifndef UTIL_H_ #define UTIL_H_ #include <time.h> +#include <stdlib.h> + class cChannel; struct tChannelID; class cEvent; |