]> www.vanbest.org Git - sasc-ng.git/commitdiff
fix sasc-ng compile
authorleslie <unknown>
Fri, 19 Aug 2011 16:26:33 +0000 (18:26 +0200)
committerleslie <unknown>
Fri, 19 Aug 2011 16:26:33 +0000 (18:26 +0200)
cam.c
cam.h
contrib/sasc-ng/sc/dvbdevice.cpp
contrib/sasc-ng/sc/include/vdr/device.h
contrib/sasc-ng/sc/include/vdr/dvbdevice.h
contrib/sasc-ng/sc/sasccam.cpp
device-tmpl.c
device.c
device.h

diff --git a/cam.c b/cam.c
index 2bd5ad8c2d45feb526cf587cab433441d7d35afa..bce464978d4fb6593b7c33138101af455dcddf91 100644 (file)
--- 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<cPrgPid> 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 de6b1e413fa80c0d92013611a6f4731497dc5bdb..85137f29975777f4ca13f1bb5d3071bac5efa8a5 100644 (file)
--- 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<cPrgPid> 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
index 2232d290a9d66b8512938ffc98a7ca62f202b382..f5bfa0000527d1744095d6f3cf009223dbf23d9a 100644 (file)
 #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;
index 22d50d5344105fd41682dd28f178ddc59c654115..a5a520520a557cd0709fad995cd980350508a84c 100644 (file)
@@ -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);
index 72d6a2c1c357f7904527fd5c9d4eae152a61902a..96c55a7f8f0181e3d93b5088745e43fbc650e7ce 100644 (file)
@@ -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:
 
index 914d1a3529ce6b9b77a128b1121f4d773cf81651..4d04258aa7d89c17b9e9e69579f47e0aeeba0484 100644 (file)
 #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;
index 8bf65beb9bc3c0b03108df0a5736ba2982a9caaa..1bb8f5117bf3bbed9a1a12680a4482fde9c064b2 100644 (file)
 
 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
index fb10406ebb70f4cf2c1485aba15b816c5460a518..0efe2a096e9987f0063abfc00dc9ebd40642f6a4 100644 (file)
--- a/device.c
+++ b/device.c
 #include <vdr/ci.h>
 #include <vdr/dvbdevice.h>
 #include <vdr/thread.h>
+
 #ifndef SASC
 #include <vdr/dvbci.h>
-
 #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<<n));
 }
 
-#else //SASC
+#else //!SASC
 
 void cScDevices::OnPluginLoad(void) {}
 void cScDevices::OnPluginUnload(void) {}
@@ -380,4 +384,4 @@ void cScDevices::Shutdown(void) {}
 void cScDevices::SetForceBudget(int n) {}
 bool cScDevices::ForceBudget(int n) { return true; }
 
-#endif //SASC
+#endif //!SASC
index 78371844e77b8b1c4c17ae6b68f41be59d0d8fb4..79a052d2e393641d6a6b2223d1ae1c212258af3e 100644 (file)
--- a/device.h
+++ b/device.h
@@ -43,6 +43,7 @@ class cDeCSA;
 
 // ----------------------------------------------------------------
 
+#ifndef SASC
 class cDeCsaTSBuffer : public cThread {
 private:
   int f;
@@ -60,6 +61,7 @@ public:
   uchar *Get(void);
   void SetActive(bool ScActive);
   };
+#endif
 
 // ----------------------------------------------------------------
 
@@ -85,6 +87,7 @@ public:
 
 // ----------------------------------------------------------------
 
+#ifndef SASC
 class cScDevicePlugin : public cSimpleItem {
 public:
   cScDevicePlugin(void);
@@ -93,5 +96,6 @@ public:
   virtual bool LateInit(cDevice *dev)=0;
   virtual bool EarlyShutdown(cDevice *dev)=0;
   };
+#endif //!SASC
 
 #endif // ___DEVICE_H