2003-12-22 13:29:24 +01:00
|
|
|
/*
|
|
|
|
* eit.c: EIT section filter
|
|
|
|
*
|
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
|
|
* how to reach the author.
|
|
|
|
*
|
|
|
|
* Original version (as used in VDR before 1.3.0) written by
|
|
|
|
* 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>.
|
|
|
|
*
|
2008-04-13 11:44:48 +02:00
|
|
|
* $Id: eit.c 2.1 2008/04/13 11:27:06 kls Exp $
|
2003-12-22 13:29:24 +01:00
|
|
|
*/
|
2000-09-03 11:40:00 +02:00
|
|
|
|
|
|
|
#include "eit.h"
|
2003-12-22 13:29:24 +01:00
|
|
|
#include "epg.h"
|
2004-01-09 15:53:59 +01:00
|
|
|
#include "i18n.h"
|
2003-12-22 13:29:24 +01:00
|
|
|
#include "libsi/section.h"
|
|
|
|
#include "libsi/descriptor.h"
|
2001-03-31 15:04:37 +02:00
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
// --- cEIT ------------------------------------------------------------------
|
2000-09-03 11:40:00 +02:00
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
class cEIT : public SI::EIT {
|
2001-03-31 15:04:37 +02:00
|
|
|
public:
|
2006-05-25 14:53:15 +02:00
|
|
|
cEIT(cSchedules *Schedules, int Source, u_char Tid, const u_char *Data, bool OnlyRunningStatus = false);
|
2003-12-22 13:29:24 +01:00
|
|
|
};
|
2001-03-31 15:04:37 +02:00
|
|
|
|
2006-05-25 14:53:15 +02:00
|
|
|
cEIT::cEIT(cSchedules *Schedules, int Source, u_char Tid, const u_char *Data, bool OnlyRunningStatus)
|
2003-12-22 13:29:24 +01:00
|
|
|
:SI::EIT(Data, false)
|
2000-10-29 13:17:22 +01:00
|
|
|
{
|
2003-12-22 13:29:24 +01:00
|
|
|
if (!CheckCRCAndParse())
|
|
|
|
return;
|
2000-10-29 13:17:22 +01:00
|
|
|
|
2004-01-04 12:30:00 +01:00
|
|
|
tChannelID channelID(Source, getOriginalNetworkId(), getTransportStreamId(), getServiceId());
|
|
|
|
cChannel *channel = Channels.GetByChannelID(channelID, true);
|
2003-12-22 13:29:24 +01:00
|
|
|
if (!channel)
|
|
|
|
return; // only collect data for known channels
|
2000-10-29 13:17:22 +01:00
|
|
|
|
2006-01-14 15:52:40 +01:00
|
|
|
cSchedule *pSchedule = (cSchedule *)Schedules->GetSchedule(channel, true);
|
2002-02-02 12:13:35 +01:00
|
|
|
|
2004-03-13 15:01:05 +01:00
|
|
|
bool Empty = true;
|
2004-02-21 13:56:20 +01:00
|
|
|
bool Modified = false;
|
2006-02-19 09:51:02 +01:00
|
|
|
bool HasExternalData = false;
|
2005-12-26 14:44:28 +01:00
|
|
|
time_t SegmentStart = 0;
|
|
|
|
time_t SegmentEnd = 0;
|
2004-02-21 13:56:20 +01:00
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
SI::EIT::Event SiEitEvent;
|
2004-10-16 10:14:19 +02:00
|
|
|
for (SI::Loop::Iterator it; eventLoop.getNext(SiEitEvent, it); ) {
|
2006-02-19 09:51:02 +01:00
|
|
|
bool ExternalData = false;
|
2005-06-11 16:05:11 +02:00
|
|
|
// Drop bogus events - but keep NVOD reference events, where all bits of the start time field are set to 1, resulting in a negative number.
|
|
|
|
if (SiEitEvent.getStartTime() == 0 || SiEitEvent.getStartTime() > 0 && SiEitEvent.getDuration() == 0)
|
2005-05-26 10:27:06 +02:00
|
|
|
continue;
|
2004-03-13 15:01:05 +01:00
|
|
|
Empty = false;
|
2005-12-26 14:44:28 +01:00
|
|
|
if (!SegmentStart)
|
|
|
|
SegmentStart = SiEitEvent.getStartTime();
|
|
|
|
SegmentEnd = SiEitEvent.getStartTime() + SiEitEvent.getDuration();
|
2005-05-28 13:17:20 +02:00
|
|
|
cEvent *newEvent = NULL;
|
2005-08-13 13:30:04 +02:00
|
|
|
cEvent *rEvent = NULL;
|
2003-12-22 13:29:24 +01:00
|
|
|
cEvent *pEvent = (cEvent *)pSchedule->GetEvent(SiEitEvent.getEventId(), SiEitEvent.getStartTime());
|
|
|
|
if (!pEvent) {
|
2006-05-25 14:53:15 +02:00
|
|
|
if (OnlyRunningStatus)
|
|
|
|
continue;
|
2004-02-21 12:28:17 +01:00
|
|
|
// If we don't have that event yet, we create a new one.
|
2003-12-22 13:29:24 +01:00
|
|
|
// Otherwise we copy the information into the existing event anyway, because the data might have changed.
|
2005-05-28 13:17:20 +02:00
|
|
|
pEvent = newEvent = new cEvent(SiEitEvent.getEventId());
|
2003-12-22 13:29:24 +01:00
|
|
|
if (!pEvent)
|
|
|
|
continue;
|
2002-02-02 12:13:35 +01:00
|
|
|
}
|
2003-12-22 13:29:24 +01:00
|
|
|
else {
|
|
|
|
// We have found an existing event, either through its event ID or its start time.
|
2004-10-24 15:01:50 +02:00
|
|
|
pEvent->SetSeen();
|
2003-12-22 13:29:24 +01:00
|
|
|
// If the existing event has a zero table ID it was defined externally and shall
|
|
|
|
// not be overwritten.
|
2006-02-19 09:51:02 +01:00
|
|
|
if (pEvent->TableID() == 0x00) {
|
|
|
|
if (pEvent->Version() == getVersionNumber())
|
|
|
|
continue;
|
|
|
|
HasExternalData = ExternalData = true;
|
|
|
|
}
|
2004-02-21 12:28:17 +01:00
|
|
|
// If the new event has a higher table ID, let's skip it.
|
|
|
|
// The lower the table ID, the more "current" the information.
|
2006-02-19 09:51:02 +01:00
|
|
|
else if (Tid > pEvent->TableID())
|
2003-12-25 12:50:22 +01:00
|
|
|
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.
|
|
|
|
// Unfortunately some stations (like, e.g. "Premiere") broadcast their EPG data on several transponders (like
|
|
|
|
// the actual Premiere transponder and the Sat.1/Pro7 transponder), but use different version numbers on
|
|
|
|
// each of them :-( So if one DVB card is tuned to the Premiere transponder, while an other one is tuned
|
2004-01-04 12:30:00 +01:00
|
|
|
// to the Sat.1/Pro7 transponder, events will keep toggling because of the bogus version numbers.
|
2006-02-19 09:51:02 +01:00
|
|
|
else if (Tid == pEvent->TableID() && pEvent->Version() == getVersionNumber())
|
2003-12-22 13:29:24 +01:00
|
|
|
continue;
|
2002-02-02 12:13:35 +01:00
|
|
|
}
|
2006-02-19 09:51:02 +01:00
|
|
|
if (!ExternalData) {
|
|
|
|
pEvent->SetEventID(SiEitEvent.getEventId()); // unfortunately some stations use different event ids for the same event in different tables :-(
|
|
|
|
pEvent->SetTableID(Tid);
|
|
|
|
pEvent->SetStartTime(SiEitEvent.getStartTime());
|
|
|
|
pEvent->SetDuration(SiEitEvent.getDuration());
|
|
|
|
}
|
2006-08-05 10:15:34 +02:00
|
|
|
if (newEvent)
|
|
|
|
pSchedule->AddEvent(newEvent);
|
2006-05-25 14:53:15 +02:00
|
|
|
if (Tid == 0x4E) { // we trust only the present/following info on the actual TS
|
|
|
|
if (SiEitEvent.getRunningStatus() >= SI::RunningStatusNotRunning)
|
|
|
|
pSchedule->SetRunningStatus(pEvent, SiEitEvent.getRunningStatus(), channel);
|
|
|
|
}
|
|
|
|
if (OnlyRunningStatus)
|
|
|
|
continue; // do this before setting the version, so that the full update can be done later
|
2004-02-21 12:28:17 +01:00
|
|
|
pEvent->SetVersion(getVersionNumber());
|
2001-08-17 13:19:10 +02:00
|
|
|
|
2004-01-09 15:53:59 +01:00
|
|
|
int LanguagePreferenceShort = -1;
|
|
|
|
int LanguagePreferenceExt = -1;
|
|
|
|
bool UseExtendedEventDescriptor = false;
|
2003-12-22 13:29:24 +01:00
|
|
|
SI::Descriptor *d;
|
2004-01-09 15:53:59 +01:00
|
|
|
SI::ExtendedEventDescriptors *ExtendedEventDescriptors = NULL;
|
|
|
|
SI::ShortEventDescriptor *ShortEventDescriptor = NULL;
|
2004-02-08 11:05:22 +01:00
|
|
|
cLinkChannels *LinkChannels = NULL;
|
2005-05-16 14:45:11 +02:00
|
|
|
cComponents *Components = NULL;
|
2003-12-22 13:29:24 +01:00
|
|
|
for (SI::Loop::Iterator it2; (d = SiEitEvent.eventDescriptors.getNext(it2)); ) {
|
2006-04-29 11:40:37 +02:00
|
|
|
if (ExternalData && d->getDescriptorTag() != SI::ComponentDescriptorTag) {
|
|
|
|
delete d;
|
2006-02-19 09:51:02 +01:00
|
|
|
continue;
|
2006-04-29 11:40:37 +02:00
|
|
|
}
|
2003-12-22 13:29:24 +01:00
|
|
|
switch (d->getDescriptorTag()) {
|
2004-01-09 15:53:59 +01:00
|
|
|
case SI::ExtendedEventDescriptorTag: {
|
|
|
|
SI::ExtendedEventDescriptor *eed = (SI::ExtendedEventDescriptor *)d;
|
2005-09-04 14:48:39 +02:00
|
|
|
if (I18nIsPreferredLanguage(Setup.EPGLanguages, eed->languageCode, LanguagePreferenceExt) || !ExtendedEventDescriptors) {
|
2004-01-09 15:53:59 +01:00
|
|
|
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;
|
|
|
|
}
|
2003-12-22 13:29:24 +01:00
|
|
|
break;
|
|
|
|
case SI::ShortEventDescriptorTag: {
|
|
|
|
SI::ShortEventDescriptor *sed = (SI::ShortEventDescriptor *)d;
|
2005-09-04 14:48:39 +02:00
|
|
|
if (I18nIsPreferredLanguage(Setup.EPGLanguages, sed->languageCode, LanguagePreferenceShort) || !ShortEventDescriptor) {
|
2004-01-09 15:53:59 +01:00
|
|
|
delete ShortEventDescriptor;
|
|
|
|
ShortEventDescriptor = sed;
|
|
|
|
d = NULL; // so that it is not deleted
|
|
|
|
}
|
2002-09-15 14:35:32 +02:00
|
|
|
}
|
2003-12-22 13:29:24 +01:00
|
|
|
break;
|
|
|
|
case SI::ContentDescriptorTag:
|
|
|
|
break;
|
|
|
|
case SI::ParentalRatingDescriptorTag:
|
|
|
|
break;
|
2004-02-22 13:33:20 +01:00
|
|
|
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
|
2004-03-07 11:53:43 +01:00
|
|
|
int month = t.tm_mon;
|
2004-02-22 13:33:20 +01:00
|
|
|
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;
|
2004-03-07 11:53:43 +01:00
|
|
|
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--;
|
2004-02-22 13:33:20 +01:00
|
|
|
time_t vps = mktime(&t);
|
|
|
|
pEvent->SetVps(vps);
|
|
|
|
}
|
|
|
|
break;
|
2003-12-22 13:29:24 +01:00
|
|
|
case SI::TimeShiftedEventDescriptorTag: {
|
|
|
|
SI::TimeShiftedEventDescriptor *tsed = (SI::TimeShiftedEventDescriptor *)d;
|
2004-07-18 11:02:50 +02:00
|
|
|
cSchedule *rSchedule = (cSchedule *)Schedules->GetSchedule(tChannelID(Source, channel->Nid(), channel->Tid(), tsed->getReferenceServiceId()));
|
2003-12-22 13:29:24 +01:00
|
|
|
if (!rSchedule)
|
|
|
|
break;
|
|
|
|
rEvent = (cEvent *)rSchedule->GetEvent(tsed->getReferenceEventId());
|
|
|
|
if (!rEvent)
|
|
|
|
break;
|
|
|
|
pEvent->SetTitle(rEvent->Title());
|
|
|
|
pEvent->SetShortText(rEvent->ShortText());
|
|
|
|
pEvent->SetDescription(rEvent->Description());
|
2001-08-17 13:19:10 +02:00
|
|
|
}
|
2003-12-22 13:29:24 +01:00
|
|
|
break;
|
2004-02-08 11:05:22 +01:00
|
|
|
case SI::LinkageDescriptorTag: {
|
|
|
|
SI::LinkageDescriptor *ld = (SI::LinkageDescriptor *)d;
|
|
|
|
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) {
|
2004-10-31 13:01:35 +01:00
|
|
|
char linkName[ld->privateData.getLength() + 1];
|
|
|
|
strn0cpy(linkName, (const char *)ld->privateData.getData(), sizeof(linkName));
|
2007-06-10 13:02:43 +02:00
|
|
|
// TODO is there a standard way to determine the character set of this string?
|
2004-02-08 11:05:22 +01:00
|
|
|
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) {
|
2006-04-15 14:18:25 +02:00
|
|
|
if (Setup.UpdateChannels == 1 || Setup.UpdateChannels >= 3)
|
2004-10-31 12:53:00 +01:00
|
|
|
link->SetName(linkName, "", "");
|
2004-02-08 11:05:22 +01:00
|
|
|
}
|
2006-04-15 14:18:25 +02:00
|
|
|
else if (Setup.UpdateChannels >= 4) {
|
2007-07-21 15:05:20 +02:00
|
|
|
cChannel *transponder = channel;
|
|
|
|
if (channel->Tid() != ld->getTransportStreamId())
|
2007-07-28 13:23:37 +02:00
|
|
|
transponder = Channels.GetByTransponderID(linkID);
|
2007-07-21 15:05:20 +02:00
|
|
|
link = Channels.NewChannel(transponder, linkName, "", "", ld->getOriginalNetworkId(), ld->getTransportStreamId(), ld->getServiceId());
|
2004-02-08 11:05:22 +01:00
|
|
|
//XXX patFilter->Trigger();
|
|
|
|
}
|
|
|
|
if (link) {
|
|
|
|
if (!LinkChannels)
|
|
|
|
LinkChannels = new cLinkChannels;
|
|
|
|
LinkChannels->Add(new cLinkChannel(link));
|
|
|
|
}
|
|
|
|
}
|
2004-10-31 13:01:35 +01:00
|
|
|
else
|
|
|
|
channel->SetPortalName(linkName);
|
2004-02-08 11:05:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2005-01-02 15:11:44 +01:00
|
|
|
case SI::ComponentDescriptorTag: {
|
|
|
|
SI::ComponentDescriptor *cd = (SI::ComponentDescriptor *)d;
|
|
|
|
uchar Stream = cd->getStreamContent();
|
|
|
|
uchar Type = cd->getComponentType();
|
2007-10-12 14:52:30 +02:00
|
|
|
if (1 <= Stream && Stream <= 3 && Type != 0) { // 1=video, 2=audio, 3=subtitles
|
2005-05-16 14:45:11 +02:00
|
|
|
if (!Components)
|
|
|
|
Components = new cComponents;
|
2007-06-10 13:02:43 +02:00
|
|
|
char buffer[Utf8BufSize(256)];
|
2007-10-12 14:52:30 +02:00
|
|
|
Components->SetComponent(Components->NumComponents(), Stream, Type, I18nNormalizeLanguageCode(cd->languageCode), cd->description.getText(buffer, sizeof(buffer)));
|
2005-01-02 15:11:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2003-12-22 13:29:24 +01:00
|
|
|
default: ;
|
|
|
|
}
|
|
|
|
delete d;
|
|
|
|
}
|
2002-10-07 16:24:04 +02:00
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
if (!rEvent) {
|
2004-01-09 15:53:59 +01:00
|
|
|
if (ShortEventDescriptor) {
|
2007-06-10 13:02:43 +02:00
|
|
|
char buffer[Utf8BufSize(256)];
|
2004-06-06 14:53:21 +02:00
|
|
|
pEvent->SetTitle(ShortEventDescriptor->name.getText(buffer, sizeof(buffer)));
|
|
|
|
pEvent->SetShortText(ShortEventDescriptor->text.getText(buffer, sizeof(buffer)));
|
2004-01-09 15:53:59 +01:00
|
|
|
}
|
2006-10-09 16:22:07 +02:00
|
|
|
else if (!HasExternalData) {
|
2006-10-07 12:37:59 +02:00
|
|
|
pEvent->SetTitle(NULL);
|
|
|
|
pEvent->SetShortText(NULL);
|
|
|
|
}
|
2004-01-09 15:53:59 +01:00
|
|
|
if (ExtendedEventDescriptors) {
|
2007-06-10 13:02:43 +02:00
|
|
|
char buffer[Utf8BufSize(ExtendedEventDescriptors->getMaximumTextLength(": ")) + 1];
|
2004-06-06 14:53:21 +02:00
|
|
|
pEvent->SetDescription(ExtendedEventDescriptors->getText(buffer, sizeof(buffer), ": "));
|
2004-01-09 15:53:59 +01:00
|
|
|
}
|
2006-10-09 16:22:07 +02:00
|
|
|
else if (!HasExternalData)
|
2006-10-07 12:37:59 +02:00
|
|
|
pEvent->SetDescription(NULL);
|
2000-11-01 15:53:00 +01:00
|
|
|
}
|
2004-01-09 15:53:59 +01:00
|
|
|
delete ExtendedEventDescriptors;
|
|
|
|
delete ShortEventDescriptor;
|
2002-10-07 16:24:04 +02:00
|
|
|
|
2005-05-16 14:45:11 +02:00
|
|
|
pEvent->SetComponents(Components);
|
2001-03-31 15:04:37 +02:00
|
|
|
|
2006-10-09 16:22:07 +02:00
|
|
|
if (!HasExternalData)
|
|
|
|
pEvent->FixEpgBugs();
|
2004-02-08 11:05:22 +01:00
|
|
|
if (LinkChannels)
|
|
|
|
channel->SetLinkChannels(LinkChannels);
|
2004-02-21 13:56:20 +01:00
|
|
|
Modified = true;
|
2002-10-07 16:24:04 +02:00
|
|
|
}
|
2004-03-13 15:01:05 +01:00
|
|
|
if (Empty && Tid == 0x4E && getSectionNumber() == 0)
|
|
|
|
// ETR 211: an empty entry in section 0 of table 0x4E means there is currently no event running
|
|
|
|
pSchedule->ClrRunningStatus(channel);
|
2005-03-20 13:12:07 +01:00
|
|
|
if (Tid == 0x4E)
|
|
|
|
pSchedule->SetPresentSeen();
|
2006-07-22 09:25:11 +02:00
|
|
|
if (OnlyRunningStatus)
|
|
|
|
return;
|
2004-10-24 15:01:50 +02:00
|
|
|
if (Modified) {
|
2004-02-21 13:56:20 +01:00
|
|
|
pSchedule->Sort();
|
2006-02-19 09:51:02 +01:00
|
|
|
if (!HasExternalData)
|
|
|
|
pSchedule->DropOutdated(SegmentStart, SegmentEnd, Tid, getVersionNumber());
|
2004-10-24 15:01:50 +02:00
|
|
|
Schedules->SetModified(pSchedule);
|
|
|
|
}
|
2000-09-03 11:40:00 +02:00
|
|
|
}
|
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
// --- cTDT ------------------------------------------------------------------
|
2003-01-06 14:44:27 +01:00
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
class cTDT : public SI::TDT {
|
2003-01-06 14:44:27 +01:00
|
|
|
private:
|
2003-12-22 13:29:24 +01:00
|
|
|
static cMutex mutex;
|
2005-08-07 13:52:29 +02:00
|
|
|
static int lastDiff;
|
2003-01-06 14:44:27 +01:00
|
|
|
public:
|
2003-12-22 13:29:24 +01:00
|
|
|
cTDT(const u_char *Data);
|
2003-01-06 14:44:27 +01:00
|
|
|
};
|
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
cMutex cTDT::mutex;
|
2005-08-07 13:52:29 +02:00
|
|
|
int cTDT::lastDiff = 0;
|
2003-01-06 14:44:27 +01:00
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
cTDT::cTDT(const u_char *Data)
|
|
|
|
:SI::TDT(Data, false)
|
2003-01-06 14:44:27 +01:00
|
|
|
{
|
2003-12-22 13:29:24 +01:00
|
|
|
CheckParse();
|
2000-10-29 13:17:22 +01:00
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
time_t sattim = getTime();
|
|
|
|
time_t loctim = time(NULL);
|
2000-10-29 13:17:22 +01:00
|
|
|
|
2005-08-07 13:52:29 +02:00
|
|
|
int diff = abs(sattim - loctim);
|
|
|
|
if (diff > 2) {
|
2003-12-22 13:29:24 +01:00
|
|
|
mutex.Lock();
|
2005-08-07 13:52:29 +02:00
|
|
|
if (abs(diff - lastDiff) < 3) {
|
2008-04-13 11:44:48 +02:00
|
|
|
if (stime(&sattim) == 0)
|
|
|
|
isyslog("system time changed from %s (%ld) to %s (%ld)", *TimeToString(loctim), loctim, *TimeToString(sattim), sattim);
|
|
|
|
else
|
2005-08-07 13:52:29 +02:00
|
|
|
esyslog("ERROR while setting system time: %m");
|
|
|
|
}
|
|
|
|
lastDiff = diff;
|
2003-12-22 13:29:24 +01:00
|
|
|
mutex.Unlock();
|
2002-02-23 17:11:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
// --- cEitFilter ------------------------------------------------------------
|
2002-08-25 10:49:02 +02:00
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
cEitFilter::cEitFilter(void)
|
2001-08-11 09:38:12 +02:00
|
|
|
{
|
2003-12-22 13:29:24 +01:00
|
|
|
Set(0x12, 0x4E, 0xFE); // event info, actual(0x4E)/other(0x4F) TS, present/following
|
2003-12-25 12:50:22 +01:00
|
|
|
Set(0x12, 0x50, 0xF0); // event info, actual TS, schedule(0x50)/schedule for future days(0x5X)
|
|
|
|
Set(0x12, 0x60, 0xF0); // event info, other TS, schedule(0x60)/schedule for future days(0x6X)
|
2003-12-22 13:29:24 +01:00
|
|
|
Set(0x14, 0x70); // TDT
|
2001-08-11 09:38:12 +02:00
|
|
|
}
|
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
void cEitFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length)
|
2001-08-11 09:38:12 +02:00
|
|
|
{
|
2003-12-22 13:29:24 +01:00
|
|
|
switch (Pid) {
|
|
|
|
case 0x12: {
|
|
|
|
cSchedulesLock SchedulesLock(true, 10);
|
|
|
|
cSchedules *Schedules = (cSchedules *)cSchedules::Schedules(SchedulesLock);
|
|
|
|
if (Schedules)
|
|
|
|
cEIT EIT(Schedules, Source(), Tid, Data);
|
2006-05-25 14:53:15 +02:00
|
|
|
else {
|
|
|
|
// If we don't get a write lock, let's at least get a read lock, so
|
|
|
|
// that we can set the running status and 'seen' timestamp (well, actually
|
|
|
|
// with a read lock we shouldn't be doing that, but it's only integers that
|
|
|
|
// get changed, so it should be ok)
|
|
|
|
cSchedulesLock SchedulesLock;
|
|
|
|
cSchedules *Schedules = (cSchedules *)cSchedules::Schedules(SchedulesLock);
|
|
|
|
if (Schedules)
|
|
|
|
cEIT EIT(Schedules, Source(), Tid, Data, true);
|
|
|
|
}
|
2000-11-26 15:23:39 +01:00
|
|
|
}
|
2003-12-22 13:29:24 +01:00
|
|
|
break;
|
|
|
|
case 0x14: {
|
|
|
|
if (Setup.SetSystemTime && Setup.TimeTransponder && ISTRANSPONDER(Transponder(), Setup.TimeTransponder))
|
|
|
|
cTDT TDT(Data);
|
2003-04-25 14:46:22 +02:00
|
|
|
}
|
2003-12-22 13:29:24 +01:00
|
|
|
break;
|
|
|
|
}
|
2003-01-06 14:44:27 +01:00
|
|
|
}
|