From 33d670f7d7ce79d4c2996af0c86375edc881df75 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Mon, 21 Apr 2003 13:22:06 +0200 Subject: [PATCH] Now also taking providerId and caPid into account when handling CA descriptors --- eit.c | 66 +++++++++++++++++++++++++---------------------------------- eit.h | 7 +++---- 2 files changed, 31 insertions(+), 42 deletions(-) diff --git a/eit.c b/eit.c index f4075df6..2bab1a51 100644 --- a/eit.c +++ b/eit.c @@ -16,7 +16,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: eit.c 1.71 2003/04/18 11:30:42 kls Exp $ + * $Id: eit.c 1.72 2003/04/21 13:21:54 kls Exp $ ***************************************************************************/ #include "eit.h" @@ -1002,27 +1002,31 @@ bool cEIT::IsPresentFollowing() // --- cCaDescriptor --------------------------------------------------------- class cCaDescriptor : public cListObject { - friend class cCaDescriptors; + friend class cSIProcessor; private: int source; int transponder; int serviceId; int caSystem; + unsigned int providerId; + int caPid; int length; uchar *data; public: - cCaDescriptor(int Source, int Transponder, int ServiceId, int CaSystem, int CaPid, int Length, uchar *Data); + cCaDescriptor(int Source, int Transponder, int ServiceId, int CaSystem, unsigned int ProviderId, int CaPid, int Length, uchar *Data); virtual ~cCaDescriptor(); int Length(void) const { return length; } const uchar *Data(void) const { return data; } }; -cCaDescriptor::cCaDescriptor(int Source, int Transponder, int ServiceId, int CaSystem, int CaPid, int Length, uchar *Data) +cCaDescriptor::cCaDescriptor(int Source, int Transponder, int ServiceId, int CaSystem, unsigned int ProviderId, int CaPid, int Length, uchar *Data) { source = Source; transponder = Transponder; serviceId = ServiceId; caSystem = CaSystem; + providerId = ProviderId; + caPid = CaPid; length = Length + 6; data = MALLOC(uchar, length); data[0] = DESCR_CA; @@ -1037,7 +1041,7 @@ cCaDescriptor::cCaDescriptor(int Source, int Transponder, int ServiceId, int CaS #ifdef DEBUG_CA_DESCRIPTORS char buffer[1024]; char *q = buffer; - q += sprintf(q, "CAM: %04X %5d %4d", source, transponder, serviceId); + q += sprintf(q, "CAM: %04X %5d %5d %04X %6X %04X -", source, transponder, serviceId, caSystem, providerId, caPid); for (int i = 0; i < length; i++) q += sprintf(q, " %02X", data[i]); dsyslog(buffer); @@ -1049,22 +1053,6 @@ cCaDescriptor::~cCaDescriptor() free(data); } -// --- cCaDescriptors -------------------------------------------------------- - -class cCaDescriptors : public cList { -public: - const cCaDescriptor *Get(int Source, int Transponder, int ServiceId, int CaSystem); - }; - -const cCaDescriptor *cCaDescriptors::Get(int Source, int Transponder, int ServiceId, int CaSystem) -{ - for (cCaDescriptor *ca = First(); ca; ca = Next(ca)) { - if (ca->source == Source && ca->transponder == Transponder && ca->serviceId == ServiceId && ca->caSystem == CaSystem) - return ca; - } - return NULL; -} - // --- cSIProcessor ---------------------------------------------------------- #define MAX_FILTERS 20 @@ -1073,7 +1061,7 @@ const cCaDescriptor *cCaDescriptors::Get(int Source, int Transponder, int Servic int cSIProcessor::numSIProcessors = 0; cSchedules *cSIProcessor::schedules = NULL; cMutex cSIProcessor::schedulesMutex; -cCaDescriptors *cSIProcessor::caDescriptors = NULL; +cList cSIProcessor::caDescriptors; cMutex cSIProcessor::caDescriptorsMutex; const char *cSIProcessor::epgDataFileName = EPGDATAFILENAME; time_t cSIProcessor::lastDump = time(NULL); @@ -1090,7 +1078,6 @@ cSIProcessor::cSIProcessor(const char *FileName) filters = NULL; if (!numSIProcessors++) { // the first one creates them schedules = new cSchedules; - caDescriptors = new cCaDescriptors; } filters = (SIP_FILTER *)calloc(MAX_FILTERS, sizeof(SIP_FILTER)); SetStatus(true); @@ -1107,7 +1094,6 @@ cSIProcessor::~cSIProcessor() free(filters); if (!--numSIProcessors) { // the last one deletes them delete schedules; - delete caDescriptors; } free(fileName); } @@ -1436,14 +1422,17 @@ void cSIProcessor::TriggerDump(void) lastDump = 0; } -void cSIProcessor::NewCaDescriptor(struct Descriptor *d, int ProgramID) +void cSIProcessor::NewCaDescriptor(struct Descriptor *d, int ServiceId) { if (DescriptorTag(d) == DESCR_CA) { struct CaDescriptor *cd = (struct CaDescriptor *)d; - if (!caDescriptors->Get(currentSource, currentTransponder, ProgramID, cd->CA_type)) { - cMutexLock MutexLock(&caDescriptorsMutex); - caDescriptors->Add(new cCaDescriptor(currentSource, currentTransponder, ProgramID, cd->CA_type, cd->CA_PID, cd->DataLength, cd->Data)); - } + cMutexLock MutexLock(&caDescriptorsMutex); + + for (cCaDescriptor *ca = caDescriptors.First(); ca; ca = caDescriptors.Next(ca)) { + if (ca->source == currentSource && ca->transponder == currentTransponder && ca->serviceId == ServiceId && ca->caSystem == cd->CA_type && ca->providerId == cd->ProviderID && ca->caPid == cd->CA_PID) + return; + } + caDescriptors.Add(new cCaDescriptor(currentSource, currentTransponder, ServiceId, cd->CA_type, cd->ProviderID, cd->CA_PID, cd->DataLength, cd->Data)); //XXX update??? } } @@ -1456,15 +1445,16 @@ int cSIProcessor::GetCaDescriptors(int Source, int Transponder, int ServiceId, c cMutexLock MutexLock(&caDescriptorsMutex); int length = 0; do { - const cCaDescriptor *d = caDescriptors->Get(Source, Transponder, ServiceId, *CaSystemIds); - if (d) { - if (length + d->Length() <= BufSize) { - memcpy(Data + length, d->Data(), d->Length()); - length += d->Length(); - } - else - return -1; - } + for (cCaDescriptor *d = caDescriptors.First(); d; d = caDescriptors.Next(d)) { + if (d->source == Source && d->transponder == Transponder && d->serviceId == ServiceId && d->caSystem == *CaSystemIds) { + if (length + d->Length() <= BufSize) { + memcpy(Data + length, d->Data(), d->Length()); + length += d->Length(); + } + else + return -1; + } + } } while (*++CaSystemIds); return length; } diff --git a/eit.h b/eit.h index 0adf4816..37733340 100644 --- a/eit.h +++ b/eit.h @@ -16,7 +16,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: eit.h 1.27 2003/04/18 11:30:42 kls Exp $ + * $Id: eit.h 1.28 2003/04/21 13:22:06 kls Exp $ ***************************************************************************/ #ifndef __EIT_H @@ -135,14 +135,13 @@ typedef struct sip_filter { }SIP_FILTER; class cCaDescriptor; -class cCaDescriptors; class cSIProcessor : public cThread { private: static int numSIProcessors; static cSchedules *schedules; static cMutex schedulesMutex; - static cCaDescriptors *caDescriptors; + static cList caDescriptors; static cMutex caDescriptorsMutex; static const char *epgDataFileName; static time_t lastDump; @@ -158,7 +157,7 @@ private: bool AddFilter(unsigned short pid, u_char tid, u_char mask = 0xFF); bool DelFilter(unsigned short pid, u_char tid); bool ShutDownFilters(void); - void NewCaDescriptor(struct Descriptor *d, int ProgramID); + void NewCaDescriptor(struct Descriptor *d, int ServiceId); public: cSIProcessor(const char *FileName); ~cSIProcessor();