summaryrefslogtreecommitdiff
path: root/eit.c
diff options
context:
space:
mode:
Diffstat (limited to 'eit.c')
-rw-r--r--eit.c61
1 files changed, 34 insertions, 27 deletions
diff --git a/eit.c b/eit.c
index c24a3d0..85f051e 100644
--- a/eit.c
+++ b/eit.c
@@ -8,7 +8,7 @@
* Robert Schneider <Robert.Schneider@web.de> and Rolf Hakenes <hakenes@hippomi.de>.
* Adapted to 'libsi' for VDR 1.3.0 by Marcel Wiesweg <marcel.wiesweg@gmx.de>.
*
- * $Id: eit.c 1.86 2004/02/08 10:26:54 kls Exp $
+ * $Id: eit.c 1.89 2004/02/22 13:17:52 kls Exp kls $
*/
#include "eit.h"
@@ -43,18 +43,19 @@ cEIT::cEIT(cSchedules *Schedules, int Source, u_char Tid, const u_char *Data)
Schedules->Add(pSchedule);
}
+ bool Modified = false;
+
SI::EIT::Event SiEitEvent;
for (SI::Loop::Iterator it; eventLoop.hasNext(it); ) {
SiEitEvent = eventLoop.getNext(it);
cEvent *pEvent = (cEvent *)pSchedule->GetEvent(SiEitEvent.getEventId(), SiEitEvent.getStartTime());
if (!pEvent) {
- // If we don't have that event ID yet, we create a new one.
+ // If we don't have that event yet, we create a new one.
// Otherwise we copy the information into the existing event anyway, because the data might have changed.
pEvent = pSchedule->AddEvent(new cEvent(channelID, SiEitEvent.getEventId()));
if (!pEvent)
continue;
- pEvent->SetTableID(Tid);
}
else {
// We have found an existing event, either through its event ID or its start time.
@@ -62,19 +63,9 @@ cEIT::cEIT(cSchedules *Schedules, int Source, u_char Tid, const u_char *Data)
// not be overwritten.
if (pEvent->TableID() == 0x00)
continue;
- // If the new event comes from a table that belongs to an "other TS" and the existing
- // one comes from an "actual TS" table, let's skip it.
- #define ISACTUALTS(tid) (tid == 0x4E || (tid & 0x50) == 0x50)
- if (!ISACTUALTS(Tid) && ISACTUALTS(pEvent->TableID()))
- continue;
- // If the new event comes from a "schedule" table and the existing one comes from
- // a "present/following" table, let's skip it (the p/f table usually contains more
- // information, like e.g. a description).
- if ((Tid & 0x50) == 0x50 && pEvent->TableID() == 0x4E || (Tid & 0x60) == 0x60 && pEvent->TableID() == 0x4F)
- continue;
- // If both events come from the same "schedule" table and the new event's table id is larger than the
- // existing one's, let's skip it (higher tids mean "farther in the future" and usually have less information).
- if (((Tid & 0x50) == 0x50 || (Tid & 0x60) == 0x60) && (pEvent->TableID() & 0xF0) == (Tid & 0xF0) && (Tid > pEvent->TableID()))
+ // If the new event has a higher table ID, let's skip it.
+ // The lower the table ID, the more "current" the information.
+ if (Tid > pEvent->TableID())
continue;
// If the new event comes from the same table and has the same version number
// as the existing one, let's skip it to avoid unnecessary work.
@@ -85,9 +76,16 @@ cEIT::cEIT(cSchedules *Schedules, int Source, u_char Tid, const u_char *Data)
if (Tid == pEvent->TableID() && pEvent->Version() == getVersionNumber())
continue;
}
- pEvent->SetVersion(getVersionNumber());
- pEvent->SetTableID(Tid);
+ // XXX TODO log different (non-zero) event IDs for the same event???
pEvent->SetEventID(SiEitEvent.getEventId()); // unfortunately some stations use different event ids for the same event in different tables :-(
+ pEvent->SetTableID(Tid);
+ pEvent->SetVersion(getVersionNumber());
+ pEvent->SetStartTime(SiEitEvent.getStartTime());
+ pEvent->SetDuration(SiEitEvent.getDuration());
+ if (isPresentFollowing()) {
+ if (SiEitEvent.getRunningStatus() > SI::RunningStatusNotRunning)
+ pSchedule->SetRunningStatus(pEvent, SiEitEvent.getRunningStatus());
+ }
int LanguagePreferenceShort = -1;
int LanguagePreferenceExt = -1;
@@ -126,6 +124,21 @@ cEIT::cEIT(cSchedules *Schedules, int Source, u_char Tid, const u_char *Data)
break;
case SI::ParentalRatingDescriptorTag:
break;
+ case SI::PDCDescriptorTag: {
+ SI::PDCDescriptor *pd = (SI::PDCDescriptor *)d;
+ time_t now = time(NULL);
+ struct tm tm_r;
+ struct tm t = *localtime_r(&now, &tm_r); // this initializes the time zone in 't'
+ t.tm_isdst = -1; // makes sure mktime() will determine the correct DST setting
+ t.tm_mon = pd->getMonth() - 1;
+ t.tm_mday = pd->getDay();
+ t.tm_hour = pd->getHour();
+ t.tm_min = pd->getMinute();
+ t.tm_sec = 0;
+ time_t vps = mktime(&t);
+ pEvent->SetVps(vps);
+ }
+ break;
case SI::TimeShiftedEventDescriptorTag: {
SI::TimeShiftedEventDescriptor *tsed = (SI::TimeShiftedEventDescriptor *)d;
cSchedule *rSchedule = (cSchedule *)Schedules->GetSchedule(tChannelID(Source, 0, 0, tsed->getReferenceServiceId()));
@@ -188,20 +201,14 @@ cEIT::cEIT(cSchedules *Schedules, int Source, u_char Tid, const u_char *Data)
delete ExtendedEventDescriptors;
delete ShortEventDescriptor;
- pEvent->SetStartTime(SiEitEvent.getStartTime());
- pEvent->SetDuration(SiEitEvent.getDuration());
pEvent->FixEpgBugs();
- if (isPresentFollowing()) {
- if (SiEitEvent.getRunningStatus() == SI::RunningStatusPausing || SiEitEvent.getRunningStatus() == SI::RunningStatusRunning)
- pSchedule->SetPresentEvent(pEvent);
- else if (SiEitEvent.getRunningStatus() == SI::RunningStatusStartsInAFewSeconds)
- pSchedule->SetFollowingEvent(pEvent);
- }
-
if (LinkChannels)
channel->SetLinkChannels(LinkChannels);
+ Modified = true;
}
+ if (Modified)
+ pSchedule->Sort();
}
// --- cTDT ------------------------------------------------------------------