diff options
Diffstat (limited to 'pat.c')
-rw-r--r-- | pat.c | 35 |
1 files changed, 21 insertions, 14 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: pat.c 1.1 2003/12/21 15:28:28 kls Exp $ + * $Id: pat.c 1.2 2003/12/24 10:23:33 kls Exp $ */ #include "pat.h" @@ -25,16 +25,17 @@ private: int caSystem; int providerId; int caPid; + bool stream; int length; uchar *data; public: - cCaDescriptor(int Source, int Transponder, int ServiceId, int CaSystem, int ProviderId, int CaPid, int Length, const uchar *Data); + cCaDescriptor(int Source, int Transponder, int ServiceId, int CaSystem, int ProviderId, int CaPid, bool Stream, int Length, const 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 ProviderId, int CaPid, int Length, const uchar *Data) +cCaDescriptor::cCaDescriptor(int Source, int Transponder, int ServiceId, int CaSystem, int ProviderId, int CaPid, bool Stream, int Length, const uchar *Data) { source = Source; transponder = Transponder; @@ -42,6 +43,7 @@ cCaDescriptor::cCaDescriptor(int Source, int Transponder, int ServiceId, int CaS caSystem = CaSystem; providerId = ProviderId; caPid = CaPid; + stream = Stream; length = Length + 6; data = MALLOC(uchar, length); data[0] = SI::CaDescriptorTag; @@ -56,7 +58,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 %5d %04X %6X %04X -", source, transponder, serviceId, caSystem, providerId, caPid); + q += sprintf(q, "CAM: %04X %5d %5d %04X %6X %04X %d -", source, transponder, serviceId, caSystem, providerId, caPid, stream); for (int i = 0; i < length; i++) q += sprintf(q, " %02X", data[i]); dsyslog(buffer); @@ -74,11 +76,11 @@ class cCaDescriptors : public cList<cCaDescriptor> { private: cMutex mutex; public: - void NewCaDescriptor(int Source, int Transponder, int ServiceId, SI::CaDescriptor *d); - int GetCaDescriptors(int Source, int Transponder, int ServiceId, const unsigned short *CaSystemIds, int BufSize, uchar *Data); + void NewCaDescriptor(int Source, int Transponder, int ServiceId, SI::CaDescriptor *d, bool Stream); + int GetCaDescriptors(int Source, int Transponder, int ServiceId, const unsigned short *CaSystemIds, int BufSize, uchar *Data, bool &StreamFlag); }; -void cCaDescriptors::NewCaDescriptor(int Source, int Transponder, int ServiceId, SI::CaDescriptor *d) +void cCaDescriptors::NewCaDescriptor(int Source, int Transponder, int ServiceId, SI::CaDescriptor *d, bool Stream) { // The code for determining the ProviderID was taken from 'libdtv' // written by Rolf Hakenes <hakenes@hippomi.de>. @@ -108,23 +110,27 @@ void cCaDescriptors::NewCaDescriptor(int Source, int Transponder, int ServiceId, if (ca->source == Source && ca->transponder == Transponder && ca->serviceId == ServiceId && ca->caSystem == d->getCaType() && ca->providerId == ProviderID && ca->caPid == d->getCaPid()) return; } - Add(new cCaDescriptor(Source, Transponder, ServiceId, d->getCaType(), ProviderID, d->getCaPid(), Length, Data)); + Add(new cCaDescriptor(Source, Transponder, ServiceId, d->getCaType(), ProviderID, d->getCaPid(), Stream, Length, Data)); //XXX update??? } -int cCaDescriptors::GetCaDescriptors(int Source, int Transponder, int ServiceId, const unsigned short *CaSystemIds, int BufSize, uchar *Data) +int cCaDescriptors::GetCaDescriptors(int Source, int Transponder, int ServiceId, const unsigned short *CaSystemIds, int BufSize, uchar *Data, bool &StreamFlag) { if (!CaSystemIds || !*CaSystemIds) return 0; if (BufSize > 0 && Data) { cMutexLock MutexLock(&mutex); int length = 0; + int IsStream = -1; for (cCaDescriptor *d = First(); d; d = Next(d)) { if (d->source == Source && d->transponder == Transponder && d->serviceId == ServiceId) { const unsigned short *caids = CaSystemIds; do { if (d->caSystem == *caids) { if (length + d->Length() <= BufSize) { + if (IsStream >= 0 && IsStream != d->stream) + dsyslog("CAM: different stream flag in CA descriptors"); + IsStream = d->stream; memcpy(Data + length, d->Data(), d->Length()); length += d->Length(); } @@ -134,6 +140,7 @@ int cCaDescriptors::GetCaDescriptors(int Source, int Transponder, int ServiceId, } while (*++caids); } } + StreamFlag = IsStream == 1; return length; } return -1; @@ -141,9 +148,9 @@ int cCaDescriptors::GetCaDescriptors(int Source, int Transponder, int ServiceId, cCaDescriptors CaDescriptors; -int GetCaDescriptors(int Source, int Transponder, int ServiceId, const unsigned short *CaSystemIds, int BufSize, uchar *Data) +int GetCaDescriptors(int Source, int Transponder, int ServiceId, const unsigned short *CaSystemIds, int BufSize, uchar *Data, bool &StreamFlag) { - return CaDescriptors.GetCaDescriptors(Source, Transponder, ServiceId, CaSystemIds, BufSize, Data); + return CaDescriptors.GetCaDescriptors(Source, Transponder, ServiceId, CaSystemIds, BufSize, Data, StreamFlag); } // --- cPatFilter ------------------------------------------------------------ @@ -202,7 +209,7 @@ void cPatFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length SI::CaDescriptor *d; // Scan the common loop: for (SI::Loop::Iterator it; (d = (SI::CaDescriptor*)pmt.commonDescriptors.getNext(it, SI::CaDescriptorTag)); ) { - CaDescriptors.NewCaDescriptor(Source(), Transponder(), pmt.getServiceId(), d); + CaDescriptors.NewCaDescriptor(Source(), Transponder(), pmt.getServiceId(), d, false); delete d; } // Scan the stream-specific loop: @@ -210,9 +217,9 @@ void cPatFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length for (SI::Loop::Iterator it; pmt.streamLoop.hasNext(it); ) { stream = pmt.streamLoop.getNext(it); for (SI::Loop::Iterator it; (d = (SI::CaDescriptor*)stream.streamDescriptors.getNext(it, SI::CaDescriptorTag)); ) { - CaDescriptors.NewCaDescriptor(Source(), Transponder(), pmt.getServiceId(), d); + CaDescriptors.NewCaDescriptor(Source(), Transponder(), pmt.getServiceId(), d, true); delete d; - } + } } lastPmtScan = 0; // this triggers the next scan } |