diff options
author | Dimitar Petrovski <dimeptr@gmail.com> | 2012-02-27 23:24:36 +0100 |
---|---|---|
committer | Dimitar Petrovski <dimeptr@gmail.com> | 2012-02-27 23:24:36 +0100 |
commit | 265e2aa196fbf15cb9fb729ea5611d2556a9172f (patch) | |
tree | dd085f523665786ade114df5e1e1f12ca0c8eb09 /eepg.c | |
parent | fe74fa75423e7a63a295a4913a4650bb48cd0267 (diff) | |
parent | 2d604677001ef55384d3cf236e03e0cf24c7a46a (diff) | |
download | vdr-plugin-eepg-265e2aa196fbf15cb9fb729ea5611d2556a9172f.tar.gz vdr-plugin-eepg-265e2aa196fbf15cb9fb729ea5611d2556a9172f.tar.bz2 |
Merge branch 'experimental' into eit_test
Conflicts:
eepg.c
Diffstat (limited to 'eepg.c')
-rw-r--r-- | eepg.c | 579 |
1 files changed, 297 insertions, 282 deletions
@@ -43,7 +43,7 @@ #include <string> #include <stdarg.h> -#define VERBOSE 3 +#define VERBOSE 1 /* 0 = only print errors, 1 = print channels and themes, 2 = print channels, themes, titles, summaries 3 = debug mode */ /* all is logged into /var/log/syslog */ @@ -348,6 +348,8 @@ protected: unsigned short int Version, char Rating = 0x00); virtual void LoadIntoSchedule (void); virtual void LoadEquivalentChannels (void); + + void ProcessPremiere(const u_char *& Data); public: cFilterEEPG (void); virtual void SetStatus (bool On); @@ -546,7 +548,7 @@ char *freesat_huffman_decode (const unsigned char *src, size_t size) char *uncompressed = (char *) calloc (1, uncompressed_len + 1); unsigned value = 0, byte = 2, bit = 0; int p = 0; - int lastch = START; + unsigned char lastch = START; tableid = src[1] - 1; while (byte < 6 && byte < size) { @@ -556,11 +558,11 @@ char *freesat_huffman_decode (const unsigned char *src, size_t size) //freesat_table_load (); /**< Load the tables as necessary */ do { - int found = 0; + bool found = false; unsigned bitShift = 0; if (lastch == ESCAPE) { char nextCh = (value >> 24) & 0xff; - found = 1; + found = true; // Encoded in the next 8 bits. // Terminated by the first ASCII character. bitShift = 8; @@ -592,7 +594,7 @@ char *freesat_huffman_decode (const unsigned char *src, size_t size) uncompressed[p++] = nextCh; uncompressed[p] = 0; } - found = 1; + found = true; lastch = nextCh; break; } @@ -1708,8 +1710,8 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor LogE(0, prep("ERROR, Title Text out of range: t:%p, DataEnd:%p, Data:%p, Length:%i."), t, DataEnd, Data, Length); else { - Asprintf (&Text, "%.*s", *t, t + 1); //FIXME second text string is not processed right now - //asprintf (&Text, "%.*s %.*s", *t, t + 1, *t2, t2 + 1); + Asprintf (&Text, "%.*s", *t, t + 1); + //asprintf (&Text, "%.*s %.*s", *t, t + 1, *t2, t2 + 1); //FIXME second text string is not processed right now //now get summary texts u_char *DataStartSummaries = buffer[TableIdExtension] + 4; @@ -2100,7 +2102,7 @@ int cFilterEEPG::GetTitlesMHW1 (const u_char * Data, int Length) sTitleMHW1 *Title = (sTitleMHW1 *) Data; if (Title->ChannelId == 0xff) { //FF is separator packet if (memcmp (InitialTitle, Data, 46) == 0) { //data is the same as initial title //TODO use easier notation - LogD(1, prep("End procesing titles")); + LogD(2, prep("End procesing titles")); return 2; } if (nTitles == 0) @@ -3366,6 +3368,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat f = (unsigned char *) ShortEventDescriptor->name.getData().getData(); decodeText2 (f, l, buffer, sizeof (buffer)); //ShortEventDescriptor->name.getText(buffer, sizeof(buffer)); + LogD(2, prep("Title: %s Decoded: %s"), f, buffer); pEvent->SetTitle (buffer); LogD(3, prep("channelID: %s Title: %s"), *channel->GetChannelID().ToString(), pEvent->Title()); l = ShortEventDescriptor->text.getLength(); @@ -3376,6 +3379,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat pEvent->SetShortText (buffer); } LogD(3, prep("ShortText: %s"), pEvent->ShortText()); + LogD(2, prep("ShortText: %s Decoded: %s"), f, buffer); } else if (!HasExternalData) { pEvent->SetTitle (NULL); pEvent->SetShortText (NULL); @@ -3529,7 +3533,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat if (Tid == 0x4E) pSchedule->SetPresentSeen (); if (OnlyRunningStatus) { - LogD(2, prep("OnlyRunningStatus")); + LogD(4, prep("OnlyRunningStatus")); return; } if (Modified) { @@ -3538,7 +3542,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat pSchedule->DropOutdated (SegmentStart, SegmentEnd, Tid, getVersionNumber ()); Schedules->SetModified (pSchedule); } - LogD(2, prep("end of cEIT2")); + LogD(4, prep("end of cEIT2")); } //end of cEIT2 @@ -3739,7 +3743,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len if (pmt.CheckCRCAndParse () && pmt.getServiceId () == pmtsid) { SI::PMT::Stream stream; for (SI::Loop::Iterator it; pmt.streamLoop.getNext (stream, it);) { - LogD(2, prep("StreamType: 0x%02x"), stream.getStreamType ()); + LogD(4, prep("StreamType: 0x%02x"), stream.getStreamType ()); if (stream.getStreamType () == 0x05 || stream.getStreamType () == 0xc1) { //0x05 = Premiere, SKY, Freeview, Nagra 0xc1 = MHW1,MHW2; SI::CharArray data = stream.getData (); if ((data[1] & 0xE0) == 0xE0 && (data[3] & 0xF0) == 0xF0) { @@ -3749,12 +3753,12 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len if (data[2]==0x39) {//TODO Test This prvFRV = true; usrFRV = 1; - LogD(1, prep("if (data[2]==0x39) {//TODO Test This")); + 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; for (SI::Loop::Iterator it; (d = stream.streamDescriptors.getNext (it));) { - LogD(2, prep("EEPGDEBUG:d->getDescriptorTAG():%x,SI::PrivateTag:%x\n"), d->getDescriptorTag (), SI::PrivateDataSpecifierDescriptorTag); + LogD(4, prep("EEPGDEBUG:d->getDescriptorTAG():%x,SI::PrivateTag:%x\n"), d->getDescriptorTag (), SI::PrivateDataSpecifierDescriptorTag); switch (d->getDescriptorTag ()) { case SI::PrivateDataSpecifierDescriptorTag: //esyslog ("prv: %d %08x\n", d->getLength (), d->getData ().FourBytes (2)); @@ -3795,7 +3799,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len } break; case 0xd1: //Freeview - LogD(1, prep("case 0xd1: //Freeview")); + LogD(4, prep("case 0xd1: //Freeview")); if (d->getLength () == 3 && ((d->getData ().TwoBytes (2) & 0xff00) == 0x0100)) usrFRV = 0x01; //01 = EIT pid 3842 @@ -3822,7 +3826,8 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len UnprocessedFormat[FREEVIEW] = stream.getPid (); if (prvData && usrData) UnprocessedFormat[PREMIERE] = stream.getPid (); - //TODO DPE this is not good since the DISH/BEV filters are always on, but have to test somehow. + //TODO DPE DISH/BEV filters are always ON on provided transponders, + // but there is no knowledge for the loop of the data at the moment. //EEPG:12472:H:S119.0W:20000:0:0:0:0:36862:4100:18:36862 if (((Source() == cSource::FromString("S119.0W") && Transponder() == cChannel::Transponder(12472,'H')) @@ -3834,10 +3839,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len } //if data[1] && data [3] } //if streamtype - /*if (Format != PREMIERE) //any format found - break; //break out for loop */ } //for loop that walks through streams -// if (Format == PREMIERE) { //FIXME for Premiere you should also stop scanning when found... NextPmt (); pmtnext = 0; /* } @@ -3861,271 +3863,8 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len switch (Tid) { case 0xA0: //TODO DPE test this missing break but it seems a bug if ((Pid < 0x30) || (Pid > 0x37)) { - SI::PremiereCIT cit (Data, false); - if (cit.CheckCRCAndParse ()) { - cSchedulesLock SchedulesLock (true, 10); - cSchedules *Schedules = (cSchedules *) cSchedules::Schedules (SchedulesLock); - if (Schedules) { - int nCount = 0; - int nRating = 0; - SI::ExtendedEventDescriptors * ExtendedEventDescriptors = 0; - SI::ShortEventDescriptor * ShortEventDescriptor = 0; - char *order = 0, *rating = 0; - { - time_t firstTime = 0; - SI::Descriptor * d; - bool UseExtendedEventDescriptor = false; - int LanguagePreferenceShort = -1; - int LanguagePreferenceExt = -1; - for (SI::Loop::Iterator it; (d = cit.eventDescriptors.getNext (it));) { - switch (d->getDescriptorTag ()) { - case 0xF0: // order information - if (SetupPE.OrderInfo) { - static const char *text[] = { - trNOOP ("Ordernumber"), - trNOOP ("Price"), - trNOOP ("Ordering"), - trNOOP ("SMS"), - trNOOP ("WWW") - }; - char buff[512]; - int p = 0; - const unsigned char *data = d->getData ().getData () + 2; - for (int i = 0; i < 5; i++) { - int l = data[0]; - if (l > 0) - p += snprintf (&buff[p], sizeof (buff) - p, "\n%s: %.*s", tr (text[i]), l, &data[1]); - data += l + 1; - } - if (p > 0) - order = strdup (buff); - } - break; - case 0xF1: // parental rating - if (SetupPE.RatingInfo) { - char buff[512]; - int p = 0; - const unsigned char *data = d->getData ().getData () + 2; - nRating = data[0] + 3; - p += snprintf (&buff[p], sizeof (buff) - p, "\n%s: %d %s", tr ("Rating"), nRating, tr ("years")); - data += 7; - int l = data[0]; - if (l > 0) - p += snprintf (&buff[p], sizeof (buff) - p, " (%.*s)", l, &data[1]); - if (p > 0) - rating = strdup (buff); - } - break; - case SI::PremiereContentTransmissionDescriptorTag: - if (nCount >= 0) { - SI::PremiereContentTransmissionDescriptor * pct = (SI::PremiereContentTransmissionDescriptor *) d; - nCount++; - SI::PremiereContentTransmissionDescriptor::StartDayEntry sd; - SI::Loop::Iterator it; - if (pct->startDayLoop.getNext (sd, it)) { - SI::PremiereContentTransmissionDescriptor::StartDayEntry::StartTimeEntry st; - SI::Loop::Iterator it2; - if (sd.startTimeLoop.getNext (st, it2)) { - time_t StartTime = st.getStartTime (sd.getMJD ()); - if (nCount == 1) - firstTime = StartTime; - else if (firstTime < StartTime - 5 * 50 || firstTime > StartTime + 5 * 60) - nCount = -1; - } - } - } - break; - case SI::ExtendedEventDescriptorTag: { - SI::ExtendedEventDescriptor * eed = (SI::ExtendedEventDescriptor *) d; - if (I18nIsPreferredLanguage (Setup.EPGLanguages, eed->languageCode, LanguagePreferenceExt) - || !ExtendedEventDescriptors) { - delete ExtendedEventDescriptors; - ExtendedEventDescriptors = new SI::ExtendedEventDescriptors; - UseExtendedEventDescriptor = true; - } - if (UseExtendedEventDescriptor) { - ExtendedEventDescriptors->Add (eed); - d = NULL; // so that it is not deleted - } - if (eed->getDescriptorNumber () == eed->getLastDescriptorNumber ()) - UseExtendedEventDescriptor = false; - } - break; - case SI::ShortEventDescriptorTag: { - SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d; - if (I18nIsPreferredLanguage (Setup.EPGLanguages, sed->languageCode, LanguagePreferenceShort) - || !ShortEventDescriptor) { - delete ShortEventDescriptor; - ShortEventDescriptor = sed; - d = NULL; // so that it is not deleted - } - } - break; - default: - break; - } - delete d; - } - } - - { - bool Modified = false; - int optCount = 0; - unsigned int crc[3]; - crc[0] = cit.getContentId (); - SI::PremiereContentTransmissionDescriptor * pct; - for (SI::Loop::Iterator it; - (pct = - (SI::PremiereContentTransmissionDescriptor *) cit.eventDescriptors.getNext (it, - SI:: - PremiereContentTransmissionDescriptorTag));) { - int nid = pct->getOriginalNetworkId (); - int tid = pct->getTransportStreamId (); - int sid = pct->getServiceId (); - if (SetupPE.FixEpg) { - if (nid == 133) { - if (tid == 0x03 && sid == 0xf0) { - tid = 0x02; - sid = 0xe0; - } else if (tid == 0x03 && sid == 0xf1) { - tid = 0x02; - sid = 0xe1; - } else if (tid == 0x03 && sid == 0xf5) { - tid = 0x03; - sid = 0xdc; - } else if (tid == 0x04 && sid == 0xd2) { - tid = 0x11; - sid = 0xe2; - } else if (tid == 0x11 && sid == 0xd3) { - tid = 0x11; - sid = 0xe3; - } - } - } - tChannelID channelID (Source (), nid, tid, sid); - cChannel *channel = Channels.GetByChannelID (channelID, true); -#ifdef USE_NOEPG - // only use epg from channels not blocked by noEPG-patch - if (!allowedEPG (channelID)) - continue; -#endif /* NOEPG */ - if (!channel) - continue; - - cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (channelID); - if (!pSchedule) { - pSchedule = new cSchedule (channelID); - Schedules->Add (pSchedule); - } - - optCount++; - SI::PremiereContentTransmissionDescriptor::StartDayEntry sd; - int index = 0; - for (SI::Loop::Iterator it; pct->startDayLoop.getNext (sd, it);) { - int mjd = sd.getMJD (); - SI::PremiereContentTransmissionDescriptor::StartDayEntry::StartTimeEntry st; - for (SI::Loop::Iterator it2; sd.startTimeLoop.getNext (st, it2);) { - time_t StartTime = st.getStartTime (mjd); - time_t EndTime = StartTime + cit.getDuration (); - int runningStatus = (StartTime < now - && now < EndTime) ? SI::RunningStatusRunning : ((StartTime - 30 < now - && now < - StartTime) ? SI:: - RunningStatusStartsInAFewSeconds - : SI::RunningStatusNotRunning); - bool isOpt = false; - if (index++ == 0 && nCount > 1) - isOpt = true; - crc[1] = isOpt ? optCount : 0; - crc[2] = StartTime / STARTTIME_BIAS; - tEventID EventId = ((('P' << 8) | 'W') << 16) | crc16 (0, (unsigned char *) crc, sizeof (crc)); - LogI(2, "%s R%d %04x/%.4x %d %d/%d %s +%d ", *channelID.ToString (), runningStatus, - EventId & 0xFFFF, cit.getContentId (), index, isOpt, optCount, - stripspace (ctime (&StartTime)), (int) cit.getDuration () / 60); - if (EndTime + Setup.EPGLinger * 60 < now) { - LogI(2, "(old)\n"); - continue; - } - - bool newEvent = false; - cEvent *pEvent = (cEvent *) pSchedule->GetEvent (EventId, -1); - if (!pEvent) { - LogI(2, "(new)\n"); - pEvent = new cEvent (EventId); - if (!pEvent) - continue; - newEvent = true; - } else { - LogI(2, "(upd)\n"); - pEvent->SetSeen (); - if (pEvent->TableID () == 0x00 || pEvent->Version () == cit.getVersionNumber ()) { - if (pEvent->RunningStatus () != runningStatus) - pSchedule->SetRunningStatus (pEvent, runningStatus, channel); - continue; - } - } - pEvent->SetEventID (EventId); - pEvent->SetTableID (Tid); - pEvent->SetVersion (cit.getVersionNumber ()); - pEvent->SetStartTime (StartTime); - pEvent->SetDuration (cit.getDuration ()); - - if (ShortEventDescriptor) { - char buffer[256]; - ShortEventDescriptor->name.getText (buffer, sizeof (buffer)); - if (isOpt) { - char buffer2[sizeof (buffer) + 32]; - snprintf (buffer2, sizeof (buffer2), optPats[SetupPE.OptPat], buffer, optCount); - pEvent->SetTitle (buffer2); - } else - pEvent->SetTitle (buffer); - LogI(2, "title: %s\n", pEvent->Title ()); - pEvent->SetShortText (ShortEventDescriptor->text.getText (buffer, sizeof (buffer))); - } - if (ExtendedEventDescriptors) { - char buffer[ExtendedEventDescriptors->getMaximumTextLength (": ") + 1]; - pEvent->SetDescription (ExtendedEventDescriptors->getText (buffer, sizeof (buffer), ": ")); - } - if (order || rating) { - int len = (pEvent->Description ()? strlen (pEvent->Description ()) : 0) + - (order ? strlen (order) : 0) + (rating ? strlen (rating) : 0); - char buffer[len + 32]; - buffer[0] = 0; - if (pEvent->Description ()) - strcat (buffer, pEvent->Description ()); - if (rating) { - strcat (buffer, rating); - pEvent->SetParentalRating(nRating); - } - if (order) - strcat (buffer, order); - pEvent->SetDescription (buffer); - } - - if (newEvent) - pSchedule->AddEvent (pEvent); - - pEvent->FixEpgBugs (); - if (pEvent->RunningStatus () != runningStatus) - pSchedule->SetRunningStatus (pEvent, runningStatus, channel); - pSchedule->DropOutdated (StartTime, EndTime, Tid, cit.getVersionNumber ()); - Modified = true; - } - } - if (Modified) { - pSchedule->Sort (); - Schedules->SetModified (pSchedule); - } - delete pct; - } - } - delete ExtendedEventDescriptors; - delete ShortEventDescriptor; - free (order); - free (rating); - } - } //if checkcrcandpars + ProcessPremiere(Data); break; } //if citpid == 0xb11 Premiere case 0xa1: @@ -4353,6 +4092,282 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len // --- cPluginEEPG ------------------------------------------------------ +void cFilterEEPG::ProcessPremiere(const u_char *& Data) + +{ + + SI::PremiereCIT cit(Data, false); + + if (cit.CheckCRCAndParse ()) { + cSchedulesLock SchedulesLock (true, 10); + cSchedules *Schedules = (cSchedules *) cSchedules::Schedules (SchedulesLock); + if (Schedules) { + int now = time (0); + int nCount = 0; + int nRating = 0; + unsigned char Tid = 0xa0; // TODO maybe default TableID + SI::ExtendedEventDescriptors * ExtendedEventDescriptors = 0; + SI::ShortEventDescriptor * ShortEventDescriptor = 0; + char *order = 0, *rating = 0; + { + time_t firstTime = 0; + SI::Descriptor * d; + bool UseExtendedEventDescriptor = false; + int LanguagePreferenceShort = -1; + int LanguagePreferenceExt = -1; + for (SI::Loop::Iterator it; (d = cit.eventDescriptors.getNext (it));) { + switch (d->getDescriptorTag ()) { + case 0xF0: // order information + if (SetupPE.OrderInfo) { + static const char *text[] = { + trNOOP ("Ordernumber"), + trNOOP ("Price"), + trNOOP ("Ordering"), + trNOOP ("SMS"), + trNOOP ("WWW") + }; + char buff[512]; + int p = 0; + const unsigned char *data = d->getData ().getData () + 2; + for (int i = 0; i < 5; i++) { + int l = data[0]; + if (l > 0) + p += snprintf (&buff[p], sizeof (buff) - p, "\n%s: %.*s", tr (text[i]), l, &data[1]); + data += l + 1; + } + if (p > 0) + order = strdup (buff); + } + break; + case 0xF1: // parental rating + if (SetupPE.RatingInfo) { + char buff[512]; + int p = 0; + const unsigned char *data = d->getData ().getData () + 2; + nRating = data[0] + 3; + p += snprintf (&buff[p], sizeof (buff) - p, "\n%s: %d %s", tr ("Rating"), nRating, tr ("years")); + data += 7; + int l = data[0]; + if (l > 0) + p += snprintf (&buff[p], sizeof (buff) - p, " (%.*s)", l, &data[1]); + if (p > 0) + rating = strdup (buff); + } + break; + case SI::PremiereContentTransmissionDescriptorTag: + if (nCount >= 0) { + SI::PremiereContentTransmissionDescriptor * pct = (SI::PremiereContentTransmissionDescriptor *) d; + nCount++; + SI::PremiereContentTransmissionDescriptor::StartDayEntry sd; + SI::Loop::Iterator it; + if (pct->startDayLoop.getNext (sd, it)) { + SI::PremiereContentTransmissionDescriptor::StartDayEntry::StartTimeEntry st; + SI::Loop::Iterator it2; + if (sd.startTimeLoop.getNext (st, it2)) { + time_t StartTime = st.getStartTime (sd.getMJD ()); + if (nCount == 1) + firstTime = StartTime; + else if (firstTime < StartTime - 5 * 50 || firstTime > StartTime + 5 * 60) + nCount = -1; + } + } + } + break; + case SI::ExtendedEventDescriptorTag: { + SI::ExtendedEventDescriptor * eed = (SI::ExtendedEventDescriptor *) d; + if (I18nIsPreferredLanguage (Setup.EPGLanguages, eed->languageCode, LanguagePreferenceExt) + || !ExtendedEventDescriptors) { + delete ExtendedEventDescriptors; + ExtendedEventDescriptors = new SI::ExtendedEventDescriptors; + UseExtendedEventDescriptor = true; + } + if (UseExtendedEventDescriptor) { + ExtendedEventDescriptors->Add (eed); + d = NULL; // so that it is not deleted + } + if (eed->getDescriptorNumber () == eed->getLastDescriptorNumber ()) + UseExtendedEventDescriptor = false; + } + break; + case SI::ShortEventDescriptorTag: { + SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d; + if (I18nIsPreferredLanguage (Setup.EPGLanguages, sed->languageCode, LanguagePreferenceShort) + || !ShortEventDescriptor) { + delete ShortEventDescriptor; + ShortEventDescriptor = sed; + d = NULL; // so that it is not deleted + } + } + break; + default: + break; + } + delete d; + } + } + + { + bool Modified = false; + int optCount = 0; + unsigned int crc[3]; + crc[0] = cit.getContentId (); + SI::PremiereContentTransmissionDescriptor * pct; + for (SI::Loop::Iterator it; + (pct = + (SI::PremiereContentTransmissionDescriptor *) cit.eventDescriptors.getNext (it, + SI:: + PremiereContentTransmissionDescriptorTag));) { + int nid = pct->getOriginalNetworkId (); + int tid = pct->getTransportStreamId (); + int sid = pct->getServiceId (); + if (SetupPE.FixEpg) { + if (nid == 133) { + if (tid == 0x03 && sid == 0xf0) { + tid = 0x02; + sid = 0xe0; + } else if (tid == 0x03 && sid == 0xf1) { + tid = 0x02; + sid = 0xe1; + } else if (tid == 0x03 && sid == 0xf5) { + tid = 0x03; + sid = 0xdc; + } else if (tid == 0x04 && sid == 0xd2) { + tid = 0x11; + sid = 0xe2; + } else if (tid == 0x11 && sid == 0xd3) { + tid = 0x11; + sid = 0xe3; + } + } + } + tChannelID channelID (Source (), nid, tid, sid); + cChannel *channel = Channels.GetByChannelID (channelID, true); +#ifdef USE_NOEPG + // only use epg from channels not blocked by noEPG-patch + if (!allowedEPG (channelID)) + continue; +#endif /* NOEPG */ + + if (!channel) + continue; + + cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (channelID); + if (!pSchedule) { + pSchedule = new cSchedule (channelID); + Schedules->Add (pSchedule); + } + + optCount++; + SI::PremiereContentTransmissionDescriptor::StartDayEntry sd; + int index = 0; + for (SI::Loop::Iterator it; pct->startDayLoop.getNext (sd, it);) { + int mjd = sd.getMJD (); + SI::PremiereContentTransmissionDescriptor::StartDayEntry::StartTimeEntry st; + for (SI::Loop::Iterator it2; sd.startTimeLoop.getNext (st, it2);) { + time_t StartTime = st.getStartTime (mjd); + time_t EndTime = StartTime + cit.getDuration (); + int runningStatus = (StartTime < now + && now < EndTime) ? SI::RunningStatusRunning : ((StartTime - 30 < now + && now < + StartTime) ? SI:: + RunningStatusStartsInAFewSeconds + : SI::RunningStatusNotRunning); + bool isOpt = false; + if (index++ == 0 && nCount > 1) + isOpt = true; + crc[1] = isOpt ? optCount : 0; + crc[2] = StartTime / STARTTIME_BIAS; + tEventID EventId = ((('P' << 8) | 'W') << 16) | crc16 (0, (unsigned char *) crc, sizeof (crc)); + LogI(2, "%s R%d %04x/%.4x %d %d/%d %s +%d ", *channelID.ToString (), runningStatus, + EventId & 0xFFFF, cit.getContentId (), index, isOpt, optCount, + stripspace (ctime (&StartTime)), (int) cit.getDuration () / 60); + if (EndTime + Setup.EPGLinger * 60 < now) { + LogI(2, "(old)\n"); + continue; + } + + bool newEvent = false; + cEvent *pEvent = (cEvent *) pSchedule->GetEvent (EventId, -1); + if (!pEvent) { + LogI(2, "(new)\n"); + pEvent = new cEvent (EventId); + if (!pEvent) + continue; + newEvent = true; + } else { + LogI(2, "(upd)\n"); + pEvent->SetSeen (); + if (pEvent->TableID () == 0x00 || pEvent->Version () == cit.getVersionNumber ()) { + if (pEvent->RunningStatus () != runningStatus) + pSchedule->SetRunningStatus (pEvent, runningStatus, channel); + continue; + } + } + pEvent->SetEventID (EventId); + pEvent->SetTableID (Tid); + pEvent->SetVersion (cit.getVersionNumber ()); + pEvent->SetStartTime (StartTime); + pEvent->SetDuration (cit.getDuration ()); + + if (ShortEventDescriptor) { + char buffer[256]; + ShortEventDescriptor->name.getText (buffer, sizeof (buffer)); + if (isOpt) { + char buffer2[sizeof (buffer) + 32]; + snprintf (buffer2, sizeof (buffer2), optPats[SetupPE.OptPat], buffer, optCount); + pEvent->SetTitle (buffer2); + } else + pEvent->SetTitle (buffer); + LogI(2, "title: %s\n", pEvent->Title ()); + pEvent->SetShortText (ShortEventDescriptor->text.getText (buffer, sizeof (buffer))); + } + if (ExtendedEventDescriptors) { + char buffer[ExtendedEventDescriptors->getMaximumTextLength (": ") + 1]; + pEvent->SetDescription (ExtendedEventDescriptors->getText (buffer, sizeof (buffer), ": ")); + } + if (order || rating) { + int len = (pEvent->Description ()? strlen (pEvent->Description ()) : 0) + + (order ? strlen (order) : 0) + (rating ? strlen (rating) : 0); + char buffer[len + 32]; + buffer[0] = 0; + if (pEvent->Description ()) + strcat (buffer, pEvent->Description ()); + if (rating) { + strcat (buffer, rating); + pEvent->SetParentalRating(nRating); + } + if (order) + strcat (buffer, order); + pEvent->SetDescription (buffer); + } + + if (newEvent) + pSchedule->AddEvent (pEvent); + + pEvent->FixEpgBugs (); + if (pEvent->RunningStatus () != runningStatus) + pSchedule->SetRunningStatus (pEvent, runningStatus, channel); + pSchedule->DropOutdated (StartTime, EndTime, Tid, cit.getVersionNumber ()); + Modified = true; + } + } + if (Modified) { + pSchedule->Sort (); + Schedules->SetModified (pSchedule); + } + delete pct; + } + } + delete ExtendedEventDescriptors; + delete ShortEventDescriptor; + free (order); + free (rating); + } + } + +} + + class cPluginEEPG:public cPlugin { private: |