From 374e84f7de05d8ba00442fada7d1f948325f4131 Mon Sep 17 00:00:00 2001 From: leslie Date: Mon, 27 Jul 2009 15:20:33 +0800 Subject: [PATCH] fix vdr 1.4.7 operation --- cam.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- cam.h | 14 +++++++++++++- sc.c | 1 + 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/cam.c b/cam.c index 76eb6d0..5907de2 100644 --- a/cam.c +++ b/cam.c @@ -2731,6 +2731,8 @@ cScDvbDevice::cScDvbDevice(int n, int cafd) decsa=0; tsBuffer=0; cam=0; fullts=false; #if APIVERSNUM >= 10500 ciadapter=0; hwciadapter=0; +#else + memset(lrucaid,0,sizeof(lrucaid)); #endif fd_ca=cafd; fd_ca2=dup(fd_ca); fd_dvr=-1; softcsa=(fd_ca<0); @@ -2914,6 +2916,17 @@ bool cScDvbDevice::SetPid(cPidHandle *Handle, int Type, bool On) bool cScDvbDevice::SetChannelDevice(const cChannel *Channel, bool LiveView) { +#if APIVERSNUM < 10500 + lruMutex.Lock(); + int i=FindLRUPrg(Channel->Source(),Channel->Transponder(),Channel->Sid()); + if(i<0) i=MAX_LRU_CAID-1; + if(i>0) memmove(&lrucaid[1],&lrucaid[0],sizeof(struct LruCaid)*i); + for(i=0; i<=MAXCAIDS; i++) if((lrucaid[0].caids[i]=Channel->Ca(i))==0) break; + lrucaid[0].src=Channel->Source(); + lrucaid[0].tr=Channel->Transponder(); + lrucaid[0].prg=Channel->Sid(); + lruMutex.Unlock(); +#endif if(cam) cam->Tune(Channel); bool ret=cDvbDevice::SetChannelDevice(Channel,LiveView); if(ret && cam) cam->PostTune(); @@ -2937,6 +2950,25 @@ bool cScDvbDevice::CiAllowConcurrent(void) const return softcsa || ScSetup.ConcurrentFF>0; } +bool cScDvbDevice::GetPrgCaids(int source, int transponder, int prg, caid_t *c) +{ + cMutexLock lock(&lruMutex); + int i=FindLRUPrg(source,transponder,prg); + if(i>=0) { + for(int j=0; jmodified) { cPrg *prg=new cPrg(p->programNumber,cam->HasPrg(p->programNumber)); if(prg) { + bool haspid=false; for(cCiCaPidData *q=p->pidList.First(); q; q=p->pidList.Next(q)) { - if(q->active) + if(q->active) { prg->pids.Add(new cPrgPid(q->streamType,q->pid)); + haspid=true; + } + } + if(haspid) { + caid_t casys[MAXCAIDS+1]; + if(GetPrgCaids(ciSource,ciTransponder,p->programNumber,casys)) { + unsigned char buff[2048]; + bool streamflag; + int len=GetCaDescriptors(ciSource,ciTransponder,p->programNumber,casys,sizeof(buff),buff,streamflag); + if(len>0) prg->caDescr.Set(buff,len); + } } prgList.Add(prg); } diff --git a/cam.h b/cam.h index ed828e3..df2f5c9 100644 --- a/cam.h +++ b/cam.h @@ -90,7 +90,7 @@ public: // ---------------------------------------------------------------- -class cPrg { +class cPrg : public cSimpleItem { private: bool isUpdate, pidCaDescr; // @@ -187,6 +187,18 @@ private: void EarlyShutdown(void); bool ScActive(void); #endif //SASC + // +#if APIVERSNUM < 10500 +#define MAX_LRU_CAID 10 + struct LruCaid { + int src, tr, prg; + caid_t caids[MAXCAIDS+1]; + } lrucaid[MAX_LRU_CAID]; + cMutex lruMutex; + // + int FindLRUPrg(int source, int transponder, int prg); + bool GetPrgCaids(int source, int transponder, int prg, caid_t *c); +#endif protected: #ifndef SASC #if APIVERSNUM >= 10500 diff --git a/sc.c b/sc.c index 0c3f7dd..fc74767 100644 --- a/sc.c +++ b/sc.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #ifndef STATICBUILD -- 2.39.5