diff options
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | filter.c | 29 | ||||
-rw-r--r-- | filter.h | 12 | ||||
-rw-r--r-- | sdt.c | 70 | ||||
-rw-r--r-- | sdt.h | 4 |
5 files changed, 68 insertions, 48 deletions
@@ -2554,3 +2554,4 @@ Video Disk Recorder Revision History Volkenandt for reporting this one). - Changed calculation of channel ids to make it work for tv stations that use the undefined NID value 0 (thanks to Teemu Rantanen for reporting this one). +- Enhanced the SDT filter to handle multi part sections. @@ -4,12 +4,39 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: filter.c 1.1 2003/12/21 15:26:16 kls Exp $ + * $Id: filter.c 1.2 2004/01/05 14:30:00 kls Exp $ */ #include "filter.h" #include "sections.h" +// --- cSectionSyncer -------------------------------------------------------- + +cSectionSyncer::cSectionSyncer(void) +{ + Reset(); +} + +void cSectionSyncer::Reset(void) +{ + lastVersion = 0xFF; + synced = false; +} + +bool cSectionSyncer::Sync(uchar Version, int Number, int LastNumber) +{ + if (Version == lastVersion) + return false; + if (!synced) { + if (Number != 0) + return false; // sync on first section + synced = true; + } + if (Number == LastNumber) + lastVersion = Version; + return synced; +} + // --- cFilterData ----------------------------------------------------------- cFilterData::cFilterData(void) @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: filter.h 1.1 2003/12/22 11:41:40 kls Exp $ + * $Id: filter.h 1.2 2004/01/05 14:29:49 kls Exp $ */ #ifndef __FILTER_H @@ -13,6 +13,16 @@ #include <sys/types.h> #include "tools.h" +class cSectionSyncer { +private: + int lastVersion; + bool synced; +public: + cSectionSyncer(void); + void Reset(void); + bool Sync(uchar Version, int Number, int LastNumber); + }; + class cFilterData : public cListObject { public: u_short pid; @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: sdt.c 1.2 2004/01/05 11:40:24 kls Exp $ + * $Id: sdt.c 1.3 2004/01/05 14:30:31 kls Exp $ */ #include "sdt.h" @@ -13,34 +13,38 @@ #include "libsi/section.h" #include "libsi/descriptor.h" -// --- cSDT ------------------------------------------------------------------ +// --- cSdtFilter ------------------------------------------------------------ -class cSDT : public SI::SDT { -public: - cSDT(int Source, int Transponder, uchar &lastSdtVersion, cPatFilter *PatFilter, const u_char *Data); - }; +cSdtFilter::cSdtFilter(cPatFilter *PatFilter) +{ + patFilter = PatFilter; + Set(0x11, 0x42); // SDT +} -cSDT::cSDT(int Source, int Transponder, uchar &lastSdtVersion, cPatFilter *PatFilter, const u_char *Data) -:SI::SDT(Data, false) +void cSdtFilter::SetStatus(bool On) { - if (!CheckCRCAndParse()) - return; + cFilter::SetStatus(On); + sectionSyncer.Reset(); +} - if (getVersionNumber() == lastSdtVersion) +void cSdtFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length) +{ + if (!(Source() && Transponder())) + return; + SI::SDT sdt(Data, false); + if (!sdt.CheckCRCAndParse()) + return; + if (!sectionSyncer.Sync(sdt.getVersionNumber(), sdt.getSectionNumber(), sdt.getLastSectionNumber())) return; - if (!Channels.Lock(true, 10)) return; - - lastSdtVersion = getVersionNumber(); - SI::SDT::Service SiSdtService; - for (SI::Loop::Iterator it; serviceLoop.hasNext(it); ) { - SiSdtService = serviceLoop.getNext(it); + for (SI::Loop::Iterator it; sdt.serviceLoop.hasNext(it); ) { + SiSdtService = sdt.serviceLoop.getNext(it); - cChannel *Channel = Channels.GetByChannelID(tChannelID(Source, getOriginalNetworkId(), getTransportStreamId(), SiSdtService.getServiceId())); + cChannel *Channel = Channels.GetByChannelID(tChannelID(Source(), sdt.getOriginalNetworkId(), sdt.getTransportStreamId(), SiSdtService.getServiceId())); if (!Channel) - Channel = Channels.GetByChannelID(tChannelID(Source, 0, Transponder, SiSdtService.getServiceId())); + Channel = Channels.GetByChannelID(tChannelID(Source(), 0, Transponder(), SiSdtService.getServiceId())); SI::Descriptor *d; for (SI::Loop::Iterator it2; (d = SiSdtService.serviceDescriptors.getNext(it2)); ) { @@ -80,7 +84,7 @@ cSDT::cSDT(int Source, int Transponder, uchar &lastSdtVersion, cPatFilter *PatFi pn = ShortNameBuf; } if (Channel) { - Channel->SetId(getOriginalNetworkId(), getTransportStreamId(), SiSdtService.getServiceId()); + Channel->SetId(sdt.getOriginalNetworkId(), sdt.getTransportStreamId(), SiSdtService.getServiceId()); if (Setup.UpdateChannels >= 1) Channel->SetName(pn); // Using SiSdtService.getFreeCaMode() is no good, because some @@ -90,8 +94,8 @@ cSDT::cSDT(int Source, int Transponder, uchar &lastSdtVersion, cPatFilter *PatFi // Channel->SetCa(SiSdtService.getFreeCaMode() ? 0xFFFF : 0); } else if (*pn && Setup.UpdateChannels >= 3) { - Channel = Channels.NewChannel(Source, Transponder, pn, getOriginalNetworkId(), getTransportStreamId(), SiSdtService.getServiceId()); - PatFilter->Trigger(); + Channel = Channels.NewChannel(Source(), Transponder(), pn, sdt.getOriginalNetworkId(), sdt.getTransportStreamId(), SiSdtService.getServiceId()); + patFilter->Trigger(); } } } @@ -124,25 +128,3 @@ cSDT::cSDT(int Source, int Transponder, uchar &lastSdtVersion, cPatFilter *PatFi } Channels.Unlock(); } - - -// --- cSdtFilter ------------------------------------------------------------ - -cSdtFilter::cSdtFilter(cPatFilter *PatFilter) -{ - lastSdtVersion = 0xFF; - patFilter = PatFilter; - Set(0x11, 0x42); // SDT -} - -void cSdtFilter::SetStatus(bool On) -{ - cFilter::SetStatus(On); - lastSdtVersion = 0xFF; -} - -void cSdtFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length) -{ - if (Source() && Transponder()) - cSDT SDT(Source(), Transponder(), lastSdtVersion, patFilter, Data); -} @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: sdt.h 1.1 2004/01/03 13:49:55 kls Exp $ + * $Id: sdt.h 1.2 2004/01/05 14:30:14 kls Exp $ */ #ifndef __SDT_H @@ -15,7 +15,7 @@ class cSdtFilter : public cFilter { private: - uchar lastSdtVersion; + cSectionSyncer sectionSyncer; cPatFilter *patFilter; protected: virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length); |