From 4d7e0c630156a7491b6284e1c23363cfa4e1858d Mon Sep 17 00:00:00 2001 From: leslie Date: Fri, 19 Aug 2011 18:26:33 +0200 Subject: [PATCH] fix sasc-ng compile --- cam.c | 87 ++++++---------------- cam.h | 72 +++++++++++++++++- contrib/sasc-ng/sc/dvbdevice.cpp | 49 ++++++++---- contrib/sasc-ng/sc/include/vdr/device.h | 5 ++ contrib/sasc-ng/sc/include/vdr/dvbdevice.h | 1 + contrib/sasc-ng/sc/sasccam.cpp | 9 +++ device-tmpl.c | 29 +++++--- device.c | 12 ++- device.h | 4 + 9 files changed, 173 insertions(+), 95 deletions(-) diff --git a/cam.c b/cam.c index 2bd5ad8..bce4649 100644 --- a/cam.c +++ b/cam.c @@ -37,7 +37,9 @@ #include "override.h" #include "misc.h" #include "log-core.h" +#ifndef SASC #include "FFdecsa/FFdecsa.h" +#endif #define IDLE_SLEEP 0 // idleTime when sleeping #define IDLE_GETCA 200 // idleTime when waiting for ca descriptors @@ -723,23 +725,6 @@ bool cEcmCache::ParseLinePlain(const char *line) // -- cCaDescr ----------------------------------------------------------------- -class cCaDescr { -private: - unsigned char *descr; - int len; -public: - cCaDescr(void); - cCaDescr(const cCaDescr &arg); - ~cCaDescr(); - const unsigned char *Get(int &l) const; - void Set(const cCaDescr *d); - void Set(const unsigned char *de, int l); - void Clear(void); - bool operator== (const cCaDescr &arg) const; - void Join(const cCaDescr *cd, bool rev=false); - cString ToString(void); - }; - cCaDescr::cCaDescr(void) { descr=0; len=0; @@ -818,41 +803,8 @@ cString cCaDescr::ToString(void) return str; } -// -- cPrgPid ------------------------------------------------------------------ - -class cPrgPid : public cSimpleItem { -private: - bool proc; -public: - int type, pid; - cCaDescr caDescr; - // - cPrgPid(int Type, int Pid) { type=Type; pid=Pid; proc=false; } - bool Proc(void) const { return proc; } - void Proc(bool is) { proc=is; }; - }; - // -- cPrg --------------------------------------------------------------------- -class cPrg : public cSimpleItem { -private: - bool isUpdate, pidCaDescr; - // - void Setup(void); -public: - int sid, source, transponder; - cSimpleList pids; - cCaDescr caDescr; - // - cPrg(void); - cPrg(int Sid, bool IsUpdate); - bool IsUpdate(void) const { return isUpdate; } - bool HasPidCaDescr(void) const { return pidCaDescr; } - void SetPidCaDescr(bool val) { pidCaDescr=val; } - bool SimplifyCaDescr(void); - void DumpCaDescr(int c); - }; - cPrg::cPrg(void) { Setup(); @@ -879,11 +831,6 @@ void cPrg::DumpCaDescr(int c) bool cPrg::SimplifyCaDescr(void) { -//XXX -PRINTF(L_CORE_PIDS,"SimplyCa entry pidCa=%d",HasPidCaDescr()); -DumpCaDescr(L_CORE_PIDS); -//XXX - if(HasPidCaDescr()) { bool equal=true; if(pids.Count()>1) { @@ -904,10 +851,8 @@ DumpCaDescr(L_CORE_PIDS); caDescr.Clear(); } -//XXX -PRINTF(L_CORE_PIDS,"SimplyCa exit pidCa=%d",HasPidCaDescr()); -DumpCaDescr(L_CORE_PIDS); -//XXX + PRINTF(L_CORE_PIDS,"Ca descriptors after simplify (pidCa=%d)",HasPidCaDescr()); + DumpCaDescr(L_CORE_PIDS); return HasPidCaDescr(); } @@ -2016,7 +1961,7 @@ void cScCamSlot::Process(const unsigned char *data, int len) } } -#endif //SASC +#endif //!SASC // -- cCams -------------------------------------------------------------------- @@ -2079,6 +2024,7 @@ void cGlobal::CaidsChanged(void) // -- cCam --------------------------------------------------------------- +#ifndef SASC struct TPDU { unsigned char slot; unsigned char tcid; @@ -2086,6 +2032,7 @@ struct TPDU { unsigned char len; unsigned char data[1]; }; +#endif cCam::cCam(cDevice *Device, int Adapter, int Frontend, const char *DevId, int Cafd, bool SoftCSA, bool FullTS) { @@ -2093,6 +2040,7 @@ cCam::cCam(cDevice *Device, int Adapter, int Frontend, const char *DevId, int Ca softcsa=SoftCSA; fullts=FullTS; tcid=0; rebuildcaids=false; memset(version,0,sizeof(version)); +#ifndef SASC memset(slots,0,sizeof(slots)); SetDescription("SC-CI adapter on device %s",devId); rb=new cRingBufferLinear(KILOBYTE(8),6+LEN_OFF,false,"SC-CI adapter read"); @@ -2106,6 +2054,7 @@ cCam::cCam(cDevice *Device, int Adapter, int Frontend, const char *DevId, int Ca else PRINTF(L_GEN_ERROR,"failed to create ringbuffer for SC-CI adapter %s.",devId); decsa=softcsa ? new cDeCSA(devId) : 0; +#endif //!SASC source=transponder=-1; liveVpid=liveApid=0; logger=0; hookman=0; memset(lastCW,0,sizeof(lastCW)); @@ -2120,13 +2069,16 @@ cCam::~cCam() handlerList.Clear(); delete hookman; delete logger; +#ifndef SASC Cancel(3); ciMutex.Lock(); delete rb; rb=0; ciMutex.Unlock(); delete decsa; decsa=0; +#endif //!SASC } +#ifndef SASC bool cCam::OwnSlot(const cCamSlot *slot) const { if(slots[0]==slot) return true; @@ -2145,12 +2097,14 @@ int cCam::GetCaids(int slot, unsigned short *Caids, int max) } return version[slot]; } +#endif //!SASC void cCam::CaidsChanged(void) { rebuildcaids=true; } +#ifndef SASC void cCam::BuildCaids(bool force) { if(caidTimer.TimedOut() || force || (rebuildcaids && triggerTimer.TimedOut())) { @@ -2313,6 +2267,7 @@ bool cCam::Assign(cDevice *Device, bool Query) { return Device ? (Device==device) : true; } +#endif //!SASC bool cCam::IsSoftCSA(bool live) { @@ -2611,7 +2566,7 @@ bool cCam::SetCaDescr(ca_descr_t *ca_descr, bool initial) return ioctl(cafd,CA_SET_DESCR,ca_descr)>=0; } else if(decsa) return decsa->SetDescr(ca_descr,initial); -#endif // !SASC +#endif //!SASC return false; } @@ -2623,7 +2578,7 @@ bool cCam::SetCaPid(ca_pid_t *ca_pid) return ioctl(cafd,CA_SET_PID,ca_pid)>=0; } else if(decsa) return decsa->SetCaPid(ca_pid); -#endif // !SASC +#endif //!SASC return false; } @@ -2635,7 +2590,7 @@ static unsigned int av7110_read(int fd, unsigned int addr) ioctl(fd,CA_GET_MSG,&arg); return arg.index; } -#endif // !SASC +#endif //!SASC #if 0 static void av7110_write(int fd, unsigned int addr, unsigned int val) @@ -2705,7 +2660,7 @@ void cCam::DumpAV7110(void) } } } -#endif // !SASC +#endif //!SASC } int cCam::GetFreeIndex(void) @@ -2828,6 +2783,8 @@ void cCam::RemHandler(cEcmHandler *handler) // -- cDeCSA ------------------------------------------------------------------- +#ifndef SASC + #define MAX_STALL_MS 70 #define MAX_REL_WAIT 100 // time to wait if key in used on set @@ -3022,3 +2979,5 @@ bool cDeCSA::Decrypt(unsigned char *data, int len, bool force) } return false; } + +#endif //!SASC diff --git a/cam.h b/cam.h index de6b1e4..85137f2 100644 --- a/cam.h +++ b/cam.h @@ -36,7 +36,6 @@ class cLogger; class cHookManager; class cLogHook; class cScCamSlot; -class cCiFrame; class cDeCSA; class cPrg; @@ -59,6 +58,7 @@ extern cEcmCache ecmcache; // ---------------------------------------------------------------- +#ifndef SASC class cCiFrame { private: cRingBufferLinear *rb; @@ -74,6 +74,61 @@ public: void Del(void); int Avail(void); }; +#endif //!SASC + +// ---------------------------------------------------------------- + +class cCaDescr { +private: + unsigned char *descr; + int len; +public: + cCaDescr(void); + cCaDescr(const cCaDescr &arg); + ~cCaDescr(); + const unsigned char *Get(int &l) const; + void Set(const cCaDescr *d); + void Set(const unsigned char *de, int l); + void Clear(void); + bool operator== (const cCaDescr &arg) const; + void Join(const cCaDescr *cd, bool rev=false); + cString ToString(void); + }; + +// ---------------------------------------------------------------- + +class cPrgPid : public cSimpleItem { +private: + bool proc; +public: + int type, pid; + cCaDescr caDescr; + // + cPrgPid(int Type, int Pid) { type=Type; pid=Pid; proc=false; } + bool Proc(void) const { return proc; } + void Proc(bool is) { proc=is; }; + }; + +// ---------------------------------------------------------------- + +class cPrg : public cSimpleItem { +private: + bool isUpdate, pidCaDescr; + // + void Setup(void); +public: + int sid, source, transponder; + cSimpleList pids; + cCaDescr caDescr; + // + cPrg(void); + cPrg(int Sid, bool IsUpdate); + bool IsUpdate(void) const { return isUpdate; } + bool HasPidCaDescr(void) const { return pidCaDescr; } + void SetPidCaDescr(bool val) { pidCaDescr=val; } + bool SimplifyCaDescr(void); + void DumpCaDescr(int c); + }; // ---------------------------------------------------------------- @@ -89,17 +144,23 @@ typedef int caid_t; #define MAX_CW_IDX 16 #define MAX_SPLIT_SID 16 +#ifndef SASC class cCam : public cCiAdapter, public cSimpleItem { +#else +class cCam : public cSimpleItem { +#endif private: cDevice *device; - cMutex ciMutex; const char *devId; int adapter, frontend; +#ifndef SASC + cMutex ciMutex; cRingBufferLinear *rb; cScCamSlot *slots[MAX_CI_SLOTS]; cCiFrame frame; // cDeCSA *decsa; +#endif int cafd; cMutex cafdMutex; bool softcsa, fullts; @@ -127,11 +188,13 @@ private: int GetFreeIndex(void); void LogStartup(void); protected: +#ifndef SASC virtual int Read(unsigned char *Buffer, int MaxLength); virtual void Write(const unsigned char *Buffer, int Length); virtual bool Reset(int Slot); virtual eModuleStatus ModuleStatus(int Slot); virtual bool Assign(cDevice *Device, bool Query=false); +#endif public: cCam(cDevice *Device, int Adapter, int Frontend, const char *DevId, int Cafd, bool SoftCSA, bool FullTS); virtual ~cCam(); @@ -161,14 +224,18 @@ public: void PostTune(void); void SetPid(int type, int pid, bool on); char *CurrentKeyStr(int num, const char **id); +#ifndef SASC bool OwnSlot(const cCamSlot *slot) const; cDeCSA *DeCSA(void) const { return decsa; } +#endif }; void LogStatsDown(void); // ---------------------------------------------------------------- +#ifndef SASC + #define MAX_CSA_PIDS 8192 #define MAX_CSA_IDX 16 @@ -195,5 +262,6 @@ public: bool SetCaPid(ca_pid_t *ca_pid); void SetActive(bool on); }; +#endif //!SASC #endif // ___CAM_H diff --git a/contrib/sasc-ng/sc/dvbdevice.cpp b/contrib/sasc-ng/sc/dvbdevice.cpp index 2232d29..f5bfa00 100644 --- a/contrib/sasc-ng/sc/dvbdevice.cpp +++ b/contrib/sasc-ng/sc/dvbdevice.cpp @@ -32,6 +32,16 @@ #define DEV_DVB_AUDIO "audio" #define DEV_DVB_CA "ca" +class cDvbName { +private: + char buffer[PATH_MAX]; +public: + cDvbName(const char *Name, int n) { + snprintf(buffer, sizeof(buffer), "%s%d/%s%d", DEV_DVB_ADAPTER, n, Name, 0); + } + const char *operator*() { return buffer; } + }; + // --- cDvbDevice ------------------------------------------------------------ int cDvbDevice::devVideoOffset = -1; @@ -76,21 +86,6 @@ bool cDvbDevice::HasDecoder(void) const return fd_video; } -#include "include/vdr/plugin.h" -#define SC_NAME "sc" -#define SC_MAGIC { 0,'S','C',0xc4,0x5e,0xa1 } -#define OP_PROVIDES 0 -#define OP_IGNORE 1 - -struct ScLink { - char magic[6]; - short op; - const cDevice *dev; - unsigned short *caids; - const cChannel *channel; - int num; - }; - cSpuDecoder *cDvbDevice::GetSpuDecoder(void) { return NULL; @@ -115,9 +110,33 @@ bool cDvbDevice::SetPid(cPidHandle *Handle, int Type, bool On) int cDvbDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask) { + const char *FileName = *cDvbName(DEV_DVB_DEMUX, CardIndex()); + int f = open(FileName, O_RDWR | O_NONBLOCK); + if (f >= 0) { + dmx_sct_filter_params sctFilterParams; + memset(&sctFilterParams, 0, sizeof(sctFilterParams)); + sctFilterParams.pid = Pid; + sctFilterParams.timeout = 0; + sctFilterParams.flags = DMX_IMMEDIATE_START; + sctFilterParams.filter.filter[0] = Tid; + sctFilterParams.filter.mask[0] = Mask; + if (ioctl(f, DMX_SET_FILTER, &sctFilterParams) >= 0) + return f; + else { + esyslog("ERROR: can't set filter (pid=%d, tid=%02X, mask=%02X): %m", Pid, Tid, Mask); + close(f); + } + } + else + esyslog("ERROR: can't open filter handle on '%s'", FileName); return -1; } +void cDvbDevice::CloseFilter(int Handle) +{ + close(Handle); +} + bool cDvbDevice::ProvidesSource(int Source) const { return true; diff --git a/contrib/sasc-ng/sc/include/vdr/device.h b/contrib/sasc-ng/sc/include/vdr/device.h index 22d50d5..a5a5205 100644 --- a/contrib/sasc-ng/sc/include/vdr/device.h +++ b/contrib/sasc-ng/sc/include/vdr/device.h @@ -306,6 +306,11 @@ public: ///< Opens a file handle for the given filter data. ///< A derived device that provides section data must ///< implement this function. + virtual void CloseFilter(int Handle); + ///< Closes a file handle that has previously been opened + ///< by OpenFilter(). If this is as simple as calling close(Handle), + ///< a derived class need not implement this function, because this + ///< is done by the default implementation. void AttachFilter(cFilter *Filter); ///< Attaches the given filter to this device. void Detach(cFilter *Filter); diff --git a/contrib/sasc-ng/sc/include/vdr/dvbdevice.h b/contrib/sasc-ng/sc/include/vdr/dvbdevice.h index 72d6a2c..96c55a7 100644 --- a/contrib/sasc-ng/sc/include/vdr/dvbdevice.h +++ b/contrib/sasc-ng/sc/include/vdr/dvbdevice.h @@ -83,6 +83,7 @@ protected: protected: virtual int OpenFilter(u_short Pid, u_char Tid, u_char Mask); + virtual void CloseFilter(int Handle); // Common Interface facilities: diff --git a/contrib/sasc-ng/sc/sasccam.cpp b/contrib/sasc-ng/sc/sasccam.cpp index 914d1a3..4d04258 100644 --- a/contrib/sasc-ng/sc/sasccam.cpp +++ b/contrib/sasc-ng/sc/sasccam.cpp @@ -29,7 +29,16 @@ #include "sasccam.h" #include "scsetup.h" +// -- cScDevice ------------------------------------------------------------- + +#define SCDEVICE cScDevice +#define DVBDEVICE cDvbDevice +#include "device-tmpl.c" +#undef SCDEVICE +#undef DVBDEVICE + // -- cSascDvbDevice ------------------------------------------------------------- + class cSascDvbDevice : public cScDevice { private: int cardidx; diff --git a/device-tmpl.c b/device-tmpl.c index 8bf65be..1bb8f51 100644 --- a/device-tmpl.c +++ b/device-tmpl.c @@ -21,17 +21,21 @@ class SCDEVICE : public DVBDEVICE { private: +#ifndef SASC cDeCsaTSBuffer *tsBuffer; cMutex tsMutex; +#endif //!SASC cCam *cam; +#ifndef SASC cCiAdapter *hwciadapter; +#endif //!SASC int fd_dvr, fd_ca, fd_ca2; bool softcsa, fullts; char devId[8]; // #ifndef SASC bool ScActive(void); -#endif //SASC +#endif //!SASC protected: #ifndef SASC virtual bool Ready(void); @@ -40,7 +44,7 @@ protected: virtual bool OpenDvr(void); virtual void CloseDvr(void); virtual bool GetTSPacket(uchar *&Data); -#endif //SASC +#endif //!SASC public: SCDEVICE(int Adapter, int Frontend, int cafd); ~SCDEVICE(); @@ -48,7 +52,9 @@ public: virtual bool HasCi(void); void LateInit(void); void EarlyShutdown(void); -#endif //SASC +#else + cCam *Cam(void) { return cam; } +#endif //!SASC }; SCDEVICE::SCDEVICE(int Adapter, int Frontend, int cafd) @@ -58,17 +64,19 @@ SCDEVICE::SCDEVICE(int Adapter, int Frontend, int cafd) :DVBDEVICE(Adapter) #endif { - tsBuffer=0; softcsa=fullts=false; - cam=0; hwciadapter=0; +#ifndef SASC + tsBuffer=0; hwciadapter=0; +#endif + cam=0; softcsa=fullts=false; fd_ca=cafd; fd_ca2=dup(fd_ca); fd_dvr=-1; -#ifdef SASC - cam=new cCam(this,Adapter); -#endif // !SASC #if APIVERSNUM >= 10711 snprintf(devId,sizeof(devId),"%d/%d",Adapter,Frontend); #else snprintf(devId,sizeof(devId),"%d",Adapter); #endif +#ifdef SASC + cam=new cCam(this,Adapter,0,devId,fd_ca,softcsa,fullts); +#endif // !SASC } SCDEVICE::~SCDEVICE() @@ -77,11 +85,12 @@ SCDEVICE::~SCDEVICE() DetachAllReceivers(); Cancel(3); EarlyShutdown(); +#endif if(fd_ca>=0) close(fd_ca); if(fd_ca2>=0) close(fd_ca2); -#else +#ifdef SASC delete cam; -#endif // !SASC +#endif } #ifndef SASC diff --git a/device.c b/device.c index fb10406..0efe2a0 100644 --- a/device.c +++ b/device.c @@ -28,11 +28,11 @@ #include #include #include + #ifndef SASC #include - #include "FFdecsa/FFdecsa.h" -#endif //SASC +#endif //!SASC #include "device.h" #include "cam.h" @@ -45,6 +45,8 @@ // -- cDeCsaTSBuffer ----------------------------------------------------------- +#ifndef SASC + cDeCsaTSBuffer::cDeCsaTSBuffer(int File, int Size, int CardIndex, cDeCSA *DeCsa, bool ScActive) { SetDescription("TS buffer on device %d", CardIndex); @@ -232,6 +234,8 @@ uint32_t cScDeviceProbe::GetSubsystemId(int Adapter, int Frontend) #endif //APIVERSNUM >= 10711 +#endif //!SASC + // -- cScDevices --------------------------------------------------------------- int cScDevices::budget=0; @@ -370,7 +374,7 @@ bool cScDevices::ForceBudget(int n) return budget && (budget&(1<