diff options
Diffstat (limited to 'eit.c')
-rw-r--r-- | eit.c | 91 |
1 files changed, 37 insertions, 54 deletions
@@ -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.68 2003/04/12 11:27:31 kls Exp $ + * $Id: eit.c 1.72 2003/04/21 13:21:54 kls Exp $ ***************************************************************************/ #include "eit.h" @@ -1002,34 +1002,38 @@ 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; data[1] = length - 2; data[2] = (caSystem >> 8) & 0xFF; data[3] = caSystem & 0xFF; - data[4] = ((CaPid >> 8) & 0xFF) | 0xE0; + data[4] = ((CaPid >> 8) & 0x1F) | 0xE0; data[5] = CaPid & 0xFF; if (Length) memcpy(&data[6], Data, Length); @@ -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,26 +1053,6 @@ cCaDescriptor::~cCaDescriptor() free(data); } -// --- cCaDescriptors -------------------------------------------------------- - -class cCaDescriptors : public cList<cCaDescriptor> { -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) { - if (CaSystem == -1 || ca->caSystem == CaSystem) - return ca; - if (CaSystem < 0) - CaSystem++; - } - } - return NULL; -} - // --- cSIProcessor ---------------------------------------------------------- #define MAX_FILTERS 20 @@ -1077,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<cCaDescriptor> cSIProcessor::caDescriptors; cMutex cSIProcessor::caDescriptorsMutex; const char *cSIProcessor::epgDataFileName = EPGDATAFILENAME; time_t cSIProcessor::lastDump = time(NULL); @@ -1094,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); @@ -1111,7 +1094,6 @@ cSIProcessor::~cSIProcessor() free(filters); if (!--numSIProcessors) { // the last one deletes them delete schedules; - delete caDescriptors; } free(fileName); } @@ -1176,12 +1158,9 @@ void cSIProcessor::SetStatus(bool On) AddFilter(0x00, 0x00); // PAT AddFilter(0x14, 0x70); // TDT AddFilter(0x14, 0x73); // TOT - AddFilter(0x12, 0x4e); // event info, actual TS, present/following - AddFilter(0x12, 0x4f); // event info, other TS, present/following - AddFilter(0x12, 0x50); // event info, actual TS, schedule - AddFilter(0x12, 0x60); // event info, other TS, schedule - AddFilter(0x12, 0x51); // event info, actual TS, schedule for another 4 days - AddFilter(0x12, 0x61); // event info, other TS, schedule for another 4 days + AddFilter(0x12, 0x4e, 0xfe); // event info, actual(0x4e)/other(0x4f) TS, present/following + AddFilter(0x12, 0x50, 0xfe); // event info, actual TS, schedule(0x50)/schedule for another 4 days(0x51) + AddFilter(0x12, 0x60, 0xfe); // event info, other TS, schedule(0x60)/schedule for another 4 days(0x61) } } @@ -1351,7 +1330,7 @@ void cSIProcessor::Action() /** Add a filter with packet identifier pid and table identifer tid */ -bool cSIProcessor::AddFilter(unsigned short pid, u_char tid) +bool cSIProcessor::AddFilter(unsigned short pid, u_char tid, u_char mask) { dmx_sct_filter_params sctFilterParams; memset(&sctFilterParams, 0, sizeof(sctFilterParams)); @@ -1359,7 +1338,7 @@ bool cSIProcessor::AddFilter(unsigned short pid, u_char tid) sctFilterParams.timeout = 0; sctFilterParams.flags = DMX_IMMEDIATE_START; sctFilterParams.filter.filter[0] = tid; - sctFilterParams.filter.mask[0] = 0xFF; + sctFilterParams.filter.mask[0] = mask; for (int a = 0; a < MAX_FILTERS; a++) { @@ -1443,36 +1422,40 @@ 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??? } } -int cSIProcessor::GetCaDescriptors(int Source, int Transponder, int ServiceId, int BufSize, uchar *Data) +int cSIProcessor::GetCaDescriptors(int Source, int Transponder, int ServiceId, const unsigned short *CaSystemIds, int BufSize, uchar *Data) { + if (!CaSystemIds || !*CaSystemIds) + return 0; if (BufSize > 0 && Data) { cMutexLock MutexLock(&caDescriptorsMutex); int length = 0; - for (int i = -1; ; i--) { - const cCaDescriptor *d = caDescriptors->Get(Source, Transponder, ServiceId, i); - if (d) { - if (length + d->Length() <= BufSize) { - memcpy(Data + length, d->Data(), d->Length()); - length += d->Length(); + do { + 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; } - else - return -1; } - else - break; - } + } while (*++CaSystemIds); return length; } return -1; |