Advertisement
Guest User

mcli-sc_20100614.diff

a guest
Dec 18th, 2012
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.82 KB | None | 0 0
  1. diff -Nrubw -x '*.pot' -x '*.po' -x .svn -x '*.o' -x .dependencies -x '*.so' -x '*~' sc-1cc3497be31c/device.c sc-1cc3497be31c.mcli/device.c
  2. --- sc-1cc3497be31c/device.c 2010-04-13 02:55:20.000000000 +0100
  3. +++ sc-1cc3497be31c.mcli/device.c 2010-06-14 09:47:03.275991610 +0100
  4. @@ -30,7 +30,9 @@
  5. #include <vdr/dvbdevice.h>
  6. #include <vdr/thread.h>
  7. #ifndef SASC
  8. +#if APIVERSNUM >= 10500
  9. #include <vdr/dvbci.h>
  10. +#endif
  11.  
  12. #include "FFdecsa/FFdecsa.h"
  13. #endif //SASC
  14. @@ -49,7 +51,7 @@
  15. #ifdef VDR_MAXCAID
  16. #define MAX_CI_SLOT_CAIDS VDR_MAXCAID
  17. #else
  18. -#define MAX_CI_SLOT_CAIDS 16
  19. +#define MAX_CI_SLOT_CAIDS 64
  20. #endif
  21.  
  22. // -- cCaDescr -----------------------------------------------------------------
  23. @@ -196,7 +198,7 @@
  24. // --- cChannelCaids -----------------------------------------------------------
  25.  
  26. #ifndef SASC
  27. -
  28. +#if APIVERSNUM >= 10500
  29. class cChannelCaids : public cSimpleItem {
  30. private:
  31. int prg, source, transponder;
  32. @@ -496,7 +498,7 @@
  33. int version[MAX_CI_SLOTS];
  34. caid_t caids[MAX_CI_SLOTS][MAX_CI_SLOT_CAIDS+1];
  35. int tcid;
  36. - bool rebuildcaids;
  37. + bool rebuildcaids, firstTime;
  38. //
  39. cTimeMs readTimer, writeTimer;
  40. //
  41. @@ -765,6 +767,11 @@
  42. }
  43. */
  44. BuildCaids(true);
  45. +#ifdef MCLI_ENABLED
  46. + firstTime=true; // First time GetCaids() is called rebuild the cache
  47. +#else
  48. + firstTime=false;
  49. +#endif
  50. slots[0]=new cScCamSlot(this,cardIndex,0);
  51. Start();
  52. }
  53. @@ -796,7 +803,8 @@
  54.  
  55. int cScCiAdapter::GetCaids(int slot, unsigned short *Caids, int max)
  56. {
  57. - BuildCaids(false);
  58. + BuildCaids(firstTime ? true :false);
  59. + firstTime=false;
  60. cMutexLock lock(&ciMutex);
  61. if(Caids) {
  62. int i;
  63. @@ -973,6 +981,7 @@
  64. {
  65. return Device ? (Device==device) : true;
  66. }
  67. +#endif //APIVERSNUM >= 10500
  68.  
  69. // -- cDeCSA -------------------------------------------------------------------
  70.  
  71. @@ -1326,7 +1335,7 @@
  72. bool cScDeviceProbe::Probe(int Adapter, int Frontend)
  73. {
  74. PRINTF(L_GEN_DEBUG,"capturing device %d/%d",Adapter,Frontend);
  75. - new cScDevice(Adapter,Frontend,cScDevices::DvbOpen(DEV_DVB_CA,Adapter,Frontend,O_RDWR));
  76. + new cScDvbDevice(Adapter,Frontend,cScDevices::DvbOpen(DEV_DVB_CA,Adapter,Frontend,O_RDWR));
  77. return true;
  78. }
  79. #endif
  80. @@ -1413,7 +1422,7 @@
  81. if(f>=0) {
  82. close(f);
  83. PRINTF(L_GEN_DEBUG,"capturing device %d",i);
  84. - new cScDevice(i,0,cScDevices::DvbOpen(DEV_DVB_CA,i,0,O_RDWR));
  85. + new cScDvbDevice(i,0,cScDevices::DvbOpen(DEV_DVB_CA,i,0,O_RDWR));
  86. found++;
  87. }
  88. else {
  89. @@ -1483,7 +1492,7 @@
  90. #define DVB_DEV_SPEC CardIndex(),0
  91. #endif
  92.  
  93. -cScDevice::cScDevice(int Adapter, int Frontend, int cafd)
  94. +cScDvbDevice::cScDvbDevice(int Adapter, int Frontend, int cafd)
  95. #if APIVERSNUM >= 10711
  96. :cDvbDevice(Adapter,Frontend)
  97. #else
  98. @@ -1492,7 +1501,11 @@
  99. {
  100. #ifndef SASC
  101. decsa=0; tsBuffer=0; cam=0; fullts=false;
  102. +#if APIVERSNUM >= 10500
  103. ciadapter=0; hwciadapter=0;
  104. +#else
  105. + memset(lrucaid,0,sizeof(lrucaid));
  106. +#endif
  107. fd_ca=cafd; fd_ca2=dup(fd_ca); fd_dvr=-1;
  108. softcsa=(fd_ca<0);
  109. #else
  110. @@ -1501,7 +1514,7 @@
  111. #endif // !SASC
  112. }
  113.  
  114. -cScDevice::~cScDevice()
  115. +cScDvbDevice::~cScDvbDevice()
  116. {
  117. #ifndef SASC
  118. DetachAllReceivers();
  119. @@ -1509,7 +1522,9 @@
  120. EarlyShutdown();
  121. delete decsa;
  122. if(fd_ca>=0) close(fd_ca);
  123. +#if APIVERSNUM >= 10500
  124. if(fd_ca2>=0) close(fd_ca2);
  125. +#endif
  126. #else
  127. delete cam;
  128. #endif // !SASC
  129. @@ -1517,16 +1532,18 @@
  130.  
  131. #ifndef SASC
  132.  
  133. -void cScDevice::EarlyShutdown(void)
  134. +void cScDvbDevice::EarlyShutdown(void)
  135. {
  136. +#if APIVERSNUM >= 10500
  137. SetCamSlot(0);
  138. delete ciadapter; ciadapter=0;
  139. delete hwciadapter; hwciadapter=0;
  140. +#endif
  141. if(cam) cam->Stop();
  142. delete cam; cam=0;
  143. }
  144.  
  145. -void cScDevice::LateInit(void)
  146. +void cScDvbDevice::LateInit(void)
  147. {
  148. int n=CardIndex();
  149. if(DeviceNumber()!=n)
  150. @@ -1539,9 +1556,18 @@
  151. softcsa=true;
  152. }
  153.  
  154. +#if APIVERSNUM >= 10500
  155. if(fd_ca2>=0) hwciadapter=cDvbCiAdapter::CreateCiAdapter(this,fd_ca2);
  156. cam=new cCam(this,n);
  157. ciadapter=new cScCiAdapter(this,n,cam);
  158. +#else
  159. + if(fd_ca2>=0) {
  160. + ciHandler=cCiHandler::CreateCiHandler(fd_ca2);
  161. + if(!ciHandler) close(fd_ca2);
  162. + }
  163. + cam=ScSetup.CapCheck(n) ? new cCam(this,n):0;
  164. +#endif
  165. +
  166. if(softcsa) {
  167. decsa=new cDeCSA(n);
  168. if(IsPrimaryDevice() && HasDecoder()) {
  169. @@ -1552,18 +1578,22 @@
  170. }
  171. }
  172.  
  173. -bool cScDevice::HasCi(void)
  174. +#if APIVERSNUM >= 10501
  175. +bool cScDvbDevice::HasCi(void)
  176. {
  177. return ciadapter || hwciadapter;
  178. }
  179. +#endif
  180.  
  181. -bool cScDevice::Ready(void)
  182. +#if APIVERSNUM >= 10500
  183. +bool cScDvbDevice::Ready(void)
  184. {
  185. return (ciadapter ? ciadapter->Ready():true) &&
  186. (hwciadapter ? hwciadapter->Ready():true);
  187. }
  188. +#endif
  189.  
  190. -bool cScDevice::SetPid(cPidHandle *Handle, int Type, bool On)
  191. +bool cScDvbDevice::SetPid(cPidHandle *Handle, int Type, bool On)
  192. {
  193. if(cam) cam->SetPid(Type,Handle->pid,On);
  194. tsMutex.Lock();
  195. @@ -1572,20 +1602,119 @@
  196. return cDvbDevice::SetPid(Handle,Type,On);
  197. }
  198.  
  199. -bool cScDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
  200. +bool cScDvbDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
  201. {
  202. +#if APIVERSNUM < 10500
  203. + SetChannelLRU(Channel);
  204. +#endif
  205. if(cam) cam->Tune(Channel);
  206. bool ret=cDvbDevice::SetChannelDevice(Channel,LiveView);
  207. if(ret && cam) cam->PostTune();
  208. return ret;
  209. }
  210.  
  211. -bool cScDevice::ScActive(void)
  212. +#if APIVERSNUM < 10500
  213. +int cScDvbDevice::ProvidesCa(const cChannel *Channel) const
  214. +{
  215. + if(cam && Channel->Ca()>=CA_ENCRYPTED_MIN) {
  216. + int caid;
  217. + for(int j=0; (caid=Channel->Ca(j)); j++)
  218. + if(!overrides.Ignore(Channel->Source(),Channel->Transponder(),caid)) {
  219. + int n=cSystems::CanHandle(caid,!softcsa);
  220. + if(n<0) break;
  221. + if(n>0) return 2;
  222. + }
  223. + }
  224. + return cDvbDevice::ProvidesCa(Channel);
  225. +}
  226. +
  227. +bool cScDvbDevice::CiAllowConcurrent(void) const
  228. +{
  229. + return softcsa || ScSetup.ConcurrentFF>0;
  230. +}
  231. +
  232. +bool cScDvbDevice::GetPrgCaids(int source, int transponder, int prg, caid_t *c)
  233. +{
  234. + cMutexLock lock(&lruMutex);
  235. + int i=FindLRUPrg(source,transponder,prg);
  236. + if(i>=0) {
  237. + for(int j=0; j<MAXCAIDS && lrucaid[i].caids[j]; j++) *c++=lrucaid[i].caids[j];
  238. + *c=0;
  239. + return true;
  240. + }
  241. + return false;
  242. +}
  243. +
  244. +int cScDvbDevice::FindLRUPrg(int source, int transponder, int prg)
  245. +{
  246. + for(int i=0; i<MAX_LRU_CAID; i++)
  247. + if(lrucaid[i].src==source && lrucaid[i].tr==transponder && lrucaid[i].prg==prg) return i;
  248. + return -1;
  249. +}
  250. +
  251. +void cScDvbDevice::SetChannelLRU(const cChannel *Channel)
  252. +{
  253. + lruMutex.Lock();
  254. + int i=FindLRUPrg(Channel->Source(),Channel->Transponder(),Channel->Sid());
  255. + if(i<0) i=MAX_LRU_CAID-1;
  256. + if(i>0) memmove(&lrucaid[1],&lrucaid[0],sizeof(struct LruCaid)*i);
  257. + for(i=0; i<=MAXCAIDS; i++) if((lrucaid[0].caids[i]=Channel->Ca(i))==0) break;
  258. + lrucaid[0].src=Channel->Source();
  259. + lrucaid[0].tr=Channel->Transponder();
  260. + lrucaid[0].prg=Channel->Sid();
  261. + lruMutex.Unlock();
  262. +}
  263. +
  264. +void cScDvbDevice::CiStartDecrypting(void)
  265. {
  266. + if(cam) {
  267. + cSimpleList<cPrg> prgList;
  268. + for(cCiCaProgramData *p=ciProgramList.First(); p; p=ciProgramList.Next(p)) {
  269. + if(p->modified) {
  270. + cPrg *prg=new cPrg(p->programNumber,cam->HasPrg(p->programNumber));
  271. + if(prg) {
  272. + bool haspid=false;
  273. + for(cCiCaPidData *q=p->pidList.First(); q; q=p->pidList.Next(q)) {
  274. + if(q->active) {
  275. + prg->pids.Add(new cPrgPid(q->streamType,q->pid));
  276. + haspid=true;
  277. + }
  278. + }
  279. + if(haspid) {
  280. + caid_t casys[MAXCAIDS+1];
  281. + if(GetPrgCaids(ciSource,ciTransponder,p->programNumber,casys)) {
  282. + unsigned char buff[2048];
  283. + bool streamflag;
  284. + int len=GetCaDescriptors(ciSource,ciTransponder,p->programNumber,casys,sizeof(buff),buff,streamflag);
  285. + if(len>0) prg->caDescr.Set(buff,len);
  286. + }
  287. + }
  288. + prgList.Add(prg);
  289. + }
  290. + p->modified=false;
  291. + }
  292. + }
  293. + for(int loop=1; loop<=2; loop++) // first delete, then add
  294. + for(cPrg *prg=prgList.First(); prg; prg=prgList.Next(prg))
  295. + if((loop==1)!=(prg->pids.Count()>0))
  296. + cam->AddPrg(prg);
  297. + }
  298. + cDvbDevice::CiStartDecrypting();
  299. +}
  300. +#endif //APIVERSNUM < 10500
  301. +
  302. +
  303. +bool cScDvbDevice::ScActive(void)
  304. +{
  305. +#if APIVERSNUM >= 10500
  306. return dynamic_cast<cScCamSlot *>(CamSlot())!=0;
  307. +#else
  308. + return cam && softcsa;
  309. +#endif
  310. +
  311. }
  312.  
  313. -bool cScDevice::OpenDvr(void)
  314. +bool cScDvbDevice::OpenDvr(void)
  315. {
  316. CloseDvr();
  317. fd_dvr=cScDevices::DvbOpen(DEV_DVB_DVR,DVB_DEV_SPEC,O_RDONLY|O_NONBLOCK,true);
  318. @@ -1597,7 +1726,7 @@
  319. return fd_dvr>=0;
  320. }
  321.  
  322. -void cScDevice::CloseDvr(void)
  323. +void cScDvbDevice::CloseDvr(void)
  324. {
  325. tsMutex.Lock();
  326. delete tsBuffer; tsBuffer=0;
  327. @@ -1605,7 +1734,7 @@
  328. if(fd_dvr>=0) { close(fd_dvr); fd_dvr=-1; }
  329. }
  330.  
  331. -bool cScDevice::GetTSPacket(uchar *&Data)
  332. +bool cScDvbDevice::GetTSPacket(uchar *&Data)
  333. {
  334. if(tsBuffer) { Data=tsBuffer->Get(); return true; }
  335. return false;
  336. @@ -1613,20 +1742,22 @@
  337.  
  338. #endif // !SASC
  339.  
  340. -bool cScDevice::SoftCSA(bool live)
  341. +bool cScDvbDevice::SoftCSA(bool live)
  342. {
  343. return softcsa && (!fullts || !live);
  344. }
  345.  
  346. -void cScDevice::CaidsChanged(void)
  347. +void cScDvbDevice::CaidsChanged(void)
  348. {
  349. #ifndef SASC
  350. +#if APIVERSNUM >= 10500
  351. if(ciadapter) ciadapter->CaidsChanged();
  352. PRINTF(L_CORE_CAIDS,"caid list rebuild triggered");
  353. +#endif
  354. #endif // !SASC
  355. }
  356.  
  357. -bool cScDevice::SetCaDescr(ca_descr_t *ca_descr, bool initial)
  358. +bool cScDvbDevice::SetCaDescr(ca_descr_t *ca_descr, bool initial)
  359. {
  360. #ifndef SASC
  361. if(!softcsa || (fullts && ca_descr->index==0)) {
  362. @@ -1638,7 +1769,7 @@
  363. return false;
  364. }
  365.  
  366. -bool cScDevice::SetCaPid(ca_pid_t *ca_pid)
  367. +bool cScDvbDevice::SetCaPid(ca_pid_t *ca_pid)
  368. {
  369. #ifndef SASC
  370. if(!softcsa || (fullts && ca_pid->index==0)) {
  371. @@ -1650,7 +1781,7 @@
  372. return false;
  373. }
  374.  
  375. -int cScDevice::FilterHandle(void)
  376. +int cScDvbDevice::FilterHandle(void)
  377. {
  378. return cScDevices::DvbOpen(DEV_DVB_DEMUX,DVB_DEV_SPEC,O_RDWR|O_NONBLOCK);
  379. }
  380. @@ -1675,7 +1806,7 @@
  381. }
  382. #endif
  383.  
  384. -void cScDevice::DumpAV7110(void)
  385. +void cScDvbDevice::DumpAV7110(void)
  386. {
  387. #ifndef SASC
  388. if(LOG(L_CORE_AV7110)) {
  389. @@ -1735,3 +1866,8 @@
  390. }
  391. #endif // !SASC
  392. }
  393. +
  394. +
  395. +#ifdef MCLI_ENABLED
  396. +#include "mclidevice.c"
  397. +#endif
  398. diff -Nrubw -x '*.pot' -x '*.po' -x .svn -x '*.o' -x .dependencies -x '*.so' -x '*~' sc-1cc3497be31c/device.h sc-1cc3497be31c.mcli/device.h
  399. --- sc-1cc3497be31c/device.h 2010-04-13 02:55:20.000000000 +0100
  400. +++ sc-1cc3497be31c.mcli/device.h 2010-04-25 22:56:46.188184810 +0100
  401. @@ -23,9 +23,17 @@
  402. #include <linux/dvb/ca.h>
  403. #include <vdr/dvbdevice.h>
  404. #include <vdr/thread.h>
  405. +#ifdef MCLI_ENABLED
  406. +#include "../mcli/filter.h"
  407. +#include "../mcli/device.h"
  408. +#endif
  409. #include "misc.h"
  410.  
  411. +#if APIVERSNUM >= 10500
  412. typedef int caid_t;
  413. +#else
  414. +typedef unsigned short caid_t;
  415. +#endif
  416.  
  417. class cCam;
  418. class cDeCSA;
  419. @@ -110,19 +118,42 @@
  420.  
  421. // ----------------------------------------------------------------
  422.  
  423. -class cScDevice : public cDvbDevice {
  424. +class cScDevice {
  425. +public:
  426. +#ifndef SASC
  427. + virtual void LateInit(void) {};
  428. + virtual void EarlyShutdown(void) {};
  429. + virtual bool ScActive(void) { return false; };
  430. +#endif //SASC
  431. + virtual cCam *Cam(void) { return 0; };
  432. + virtual bool SetCaDescr(ca_descr_t *ca_descr, bool initial) { return false; };
  433. + virtual bool SetCaPid(ca_pid_t *ca_pid) { return false; };
  434. + virtual bool SoftCSA(bool live) { return false; }
  435. + virtual void CaidsChanged(void) {};
  436. + virtual void DumpAV7110(void) {};
  437. + virtual int FilterHandle(void) { return -1; };
  438. + cScDevice() {};
  439. + virtual ~cScDevice() {};
  440. +};
  441. +
  442. +
  443. +class cScDvbDevice : public cDvbDevice, cScDevice {
  444. friend class cScDevices;
  445. private:
  446. cDeCSA *decsa;
  447. cDeCsaTSBuffer *tsBuffer;
  448. cMutex tsMutex;
  449. +#if APIVERSNUM >= 10500
  450. cScCiAdapter *ciadapter;
  451. cCiAdapter *hwciadapter;
  452. +#endif
  453. cCam *cam;
  454. int fd_dvr, fd_ca, fd_ca2;
  455. bool softcsa, fullts;
  456. cMutex cafdMutex;
  457. cTimeMs lastDump;
  458. +
  459. +
  460. //
  461. #ifndef SASC
  462. void LateInit(void);
  463. @@ -130,28 +161,137 @@
  464. bool ScActive(void);
  465. #endif //SASC
  466. //
  467. +#if APIVERSNUM < 10500
  468. +#define MAX_LRU_CAID 10
  469. + struct LruCaid {
  470. + int src, tr, prg;
  471. + caid_t caids[MAXCAIDS+1];
  472. + } lrucaid[MAX_LRU_CAID];
  473. + cMutex lruMutex;
  474. + //
  475. + int FindLRUPrg(int source, int transponder, int prg);
  476. + bool GetPrgCaids(int source, int transponder, int prg, caid_t *c);
  477. + void SetChannelLRU(const cChannel *Channel);
  478. +#endif
  479. +
  480. +
  481. +
  482. protected:
  483. #ifndef SASC
  484. +#if APIVERSNUM >= 10500
  485. virtual bool Ready(void);
  486. +#else
  487. + virtual void CiStartDecrypting(void);
  488. + virtual bool CiAllowConcurrent(void) const;
  489. +#endif
  490. virtual bool SetPid(cPidHandle *Handle, int Type, bool On);
  491. virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
  492. virtual bool OpenDvr(void);
  493. virtual void CloseDvr(void);
  494. virtual bool GetTSPacket(uchar *&Data);
  495. +#ifdef GET_TS_PACKETS
  496. + virtual int GetTSPackets (uchar *, int);
  497. +#endif
  498. #endif //SASC
  499. public:
  500. - cScDevice(int Adapter, int Frontend, int cafd);
  501. - ~cScDevice();
  502. + cScDvbDevice(int Adapter, int Frontend, int cafd);
  503. + ~cScDvbDevice();
  504. #ifndef SASC
  505. +#if APIVERSNUM >= 10501
  506. virtual bool HasCi(void);
  507. +#endif
  508. +#if APIVERSNUM < 10500
  509. + virtual int ProvidesCa(const cChannel *Channel) const;
  510. +#endif
  511. #endif //SASC
  512. virtual bool SetCaDescr(ca_descr_t *ca_descr, bool initial);
  513. virtual bool SetCaPid(ca_pid_t *ca_pid);
  514. - int FilterHandle(void);
  515. + virtual int FilterHandle(void);
  516. void DumpAV7110(void);
  517. cCam *Cam(void) { return cam; }
  518. bool SoftCSA(bool live);
  519. void CaidsChanged(void);
  520. };
  521.  
  522. +#ifdef MCLI_ENABLED
  523. +class cScMcliDevice : public cScDevice, public cMcliDevice {
  524. +private:
  525. + cRingBufferLinear *ringBuffer;
  526. + cDeCSA *decsa;
  527. + cDeCsaTSBuffer *tsBuffer;
  528. + cMutex tsMutex;
  529. +#if APIVERSNUM >= 10500
  530. + cScCiAdapter *ciadapter;
  531. +#endif
  532. + cCam *cam;
  533. + bool softcsa;
  534. + cTimeMs lastDump;
  535. + bool delivered;
  536. + bool scActive;
  537. +#ifdef HW_MINI
  538. + static int rbm_fd;
  539. + rbm_dmx_pids dmx_pids;
  540. +#endif
  541. + //
  542. +#ifndef SASC
  543. + virtual void EarlyShutdown(void);
  544. + virtual bool ScActive(void);
  545. +#endif //SASC
  546. + //
  547. +#if APIVERSNUM < 10500
  548. +#define MAX_LRU_CAID 10
  549. + struct LruCaid {
  550. + int src, tr, prg;
  551. + caid_t caids[MAXCAIDS+1];
  552. + } lrucaid[MAX_LRU_CAID];
  553. + cMutex lruMutex;
  554. + //
  555. + int FindLRUPrg(int source, int transponder, int prg);
  556. + bool GetPrgCaids(int source, int transponder, int prg, caid_t *c);
  557. +#endif
  558. +protected:
  559. +#ifndef SASC
  560. +#if APIVERSNUM >= 10500
  561. + virtual bool Ready(void);
  562. +#else
  563. + virtual void CiStartDecrypting(void);
  564. + virtual bool CiAllowConcurrent(void) const;
  565. +#endif
  566. + virtual bool SetPid(cPidHandle *Handle, int Type, bool On);
  567. + virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
  568. + virtual bool GetTSPacket(uchar *&Data);
  569. +#ifdef GET_TS_PACKETS
  570. + virtual int GetTSPackets (uchar *, int);
  571. +#endif
  572. +
  573. +#endif //SASC
  574. +public:
  575. + cScMcliDevice();
  576. + ~cScMcliDevice();
  577. +#ifndef SASC
  578. +#if APIVERSNUM >= 10501
  579. + virtual bool HasCi(void);
  580. +#endif
  581. +#if APIVERSNUM < 10500
  582. + virtual int ProvidesCa(const cChannel *Channel) const;
  583. +#endif
  584. +#endif //SASC
  585. + static void Shutdown(void);
  586. + virtual bool SetCaDescr(ca_descr_t *ca_descr, bool initial);
  587. + virtual bool SetCaPid(ca_pid_t *ca_pid);
  588. + virtual void DumpAV7110(void);
  589. + virtual cCam *Cam(void) { return cam; }
  590. + virtual bool SoftCSA(bool live);
  591. + virtual void CaidsChanged(void);
  592. +
  593. + // Override from pi-mcli
  594. + virtual int HandleTsData (unsigned char *buffer, size_t len);
  595. +
  596. + virtual bool HasInternalCam (void) { return false; }
  597. +
  598. + };
  599. +#endif
  600. +
  601. +
  602. +
  603. #endif // ___DEVICE_H
  604. diff -Nrubw -x '*.pot' -x '*.po' -x .svn -x '*.o' -x .dependencies -x '*.so' -x '*~' sc-1cc3497be31c/FFdecsa/FFdecsa.c sc-1cc3497be31c.mcli/FFdecsa/FFdecsa.c
  605. --- sc-1cc3497be31c/FFdecsa/FFdecsa.c 2010-04-13 02:55:20.000000000 +0100
  606. +++ sc-1cc3497be31c.mcli/FFdecsa/FFdecsa.c 2010-04-25 22:34:39.963185678 +0100
  607. @@ -839,7 +839,12 @@
  608. // alive packets: decrypt data
  609. for(g=0;g<alive[iter];g++){
  610. DBG(dump_mem("before_ib_decrypt_data ",encp[g],8,8));
  611. +#ifdef RBMINI
  612. + XOR_4_BY(encp[g],ib+8*g,block_out+8*g);
  613. + XOR_4_BY(encp[g]+4,ib+8*g+4,block_out+8*g+4);
  614. +#else
  615. XOR_8_BY(encp[g],ib+8*g,block_out+8*g);
  616. +#endif
  617. DBG(dump_mem("after_ib_decrypt_data ",encp[g],8,8));
  618. }
  619. // just dead packets: write decrypted data
  620. diff -Nrubw -x '*.pot' -x '*.po' -x .svn -x '*.o' -x .dependencies -x '*.so' -x '*~' sc-1cc3497be31c/FFdecsa/parallel_generic.h sc-1cc3497be31c.mcli/FFdecsa/parallel_generic.h
  621. --- sc-1cc3497be31c/FFdecsa/parallel_generic.h 2010-04-13 02:55:20.000000000 +0100
  622. +++ sc-1cc3497be31c.mcli/FFdecsa/parallel_generic.h 2010-04-25 22:34:39.975186102 +0100
  623. @@ -90,8 +90,12 @@
  624. *pd ^= *ps; }while(0)
  625. #define COPY_4_BY(d,s) do{ int *pd=(int *)(d), *ps=(int *)(s); \
  626. *pd = *ps; }while(0)
  627. +#ifdef RBMINI
  628. +#define COPY_8_BY(d,s) memcpy(d,s,8)
  629. +#else
  630. #define COPY_8_BY(d,s) do{ long long int *pd=(long long int *)(d), *ps=(long long int *)(s); \
  631. *pd = *ps; }while(0)
  632. +#endif
  633.  
  634. #define BEST_SPAN 8
  635. #define XOR_BEST_BY(d,s1,s2) do{ XOR_8_BY(d,s1,s2); }while(0);
  636. diff -Nrubw -x '*.pot' -x '*.po' -x .svn -x '*.o' -x .dependencies -x '*.so' -x '*~' sc-1cc3497be31c/filter.c sc-1cc3497be31c.mcli/filter.c
  637. --- sc-1cc3497be31c/filter.c 2010-04-13 02:55:20.000000000 +0100
  638. +++ sc-1cc3497be31c.mcli/filter.c 2010-06-13 22:40:11.641522705 +0100
  639. @@ -1,3 +1,4 @@
  640. +
  641. /*
  642. * Softcam plugin to VDR (C++)
  643. *
  644. @@ -27,6 +28,7 @@
  645.  
  646. #include <linux/dvb/dmx.h>
  647.  
  648. +#include <vdr/device.h>
  649. #include <vdr/tools.h>
  650.  
  651. #include "filter.h"
  652. @@ -38,6 +40,20 @@
  653.  
  654. cPidFilter::cPidFilter(const char *Id, int Num, int DvbNum, unsigned int IdleTime)
  655. {
  656. + device = 0;
  657. +#ifdef MCLI_ENABLED
  658. + for ( int i = 0; i < MAXDEVICES; i++ ) {
  659. + cDevice *d = cDevice::GetDevice(i);
  660. + if ( d && d->CardIndex() == DvbNum ) {
  661. + cScMcliDevice *scd = dynamic_cast<cScMcliDevice *>(d);
  662. + if ( scd ) {
  663. + device = d;
  664. + break;
  665. + }
  666. + }
  667. + }
  668. +#endif
  669. +
  670. dvbNum=DvbNum;
  671. idleTime=IdleTime;
  672. id=0; fd=-1; active=false; forceRun=false; userData=0;
  673. @@ -48,9 +64,9 @@
  674. cPidFilter::~cPidFilter()
  675. {
  676. cMutexLock lock(this);
  677. - if(fd>=0) {
  678. + if(fd>=0 || device) {
  679. Stop();
  680. - close(fd);
  681. + if (device==0) close(fd);
  682. }
  683. PRINTF(L_CORE_ACTION,"filter '%s' on card %d removed",id,dvbNum);
  684. free(id);
  685. @@ -62,6 +78,7 @@
  686. if(fd<0) {
  687. fd=cSoftCAM::FilterHandle(dvbNum);
  688. if(fd>=0) return true;
  689. + if (device) return true; // We'll set up the filter later...
  690. }
  691. return false;
  692. }
  693. @@ -78,8 +95,9 @@
  694. void cPidFilter::Start(int Pid, int Section, int Mask, int Mode, bool Crc)
  695. {
  696. cMutexLock lock(this);
  697. - if(fd>=0) {
  698. + if(fd>=0 || device) {
  699. Stop();
  700. + if (device==0) {
  701. struct dmx_sct_filter_params FilterParams;
  702. memset(&FilterParams,0,sizeof(FilterParams));
  703. FilterParams.filter.filter[0]=Section;
  704. @@ -92,6 +110,14 @@
  705. PRINTF(L_GEN_ERROR,"filter '%s': DMX_SET_FILTER failed: %s",id,strerror(errno));
  706. return;
  707. }
  708. + }else{
  709. + fd = device->OpenFilter(Pid, Section, Mask);
  710. + if ( fd < 0 ){
  711. + PRINTF(L_GEN_ERROR,"filter '%s': Can't open filter on ScMcliDevice", id);
  712. + return;
  713. + }
  714. + }
  715. +
  716. pid=Pid;
  717. active=true;
  718.  
  719. @@ -113,7 +139,12 @@
  720. {
  721. cMutexLock lock(this);
  722. if(fd>=0) {
  723. + if (device) {
  724. + device->CloseFilter(fd);
  725. + fd = -1;
  726. + } else {
  727. CHECK(ioctl(fd,DMX_STOP));
  728. + }
  729. active=false;
  730. }
  731. }
  732. @@ -123,10 +154,12 @@
  733. cMutexLock lock(this);
  734. if(fd>=0) {
  735. Stop();
  736. + if(device==0) {
  737. int s=max(BuffSize,8192);
  738. CHECK(ioctl(fd,DMX_SET_BUFFER_SIZE,s));
  739. }
  740. }
  741. +}
  742.  
  743. int cPidFilter::SetIdleTime(unsigned int IdleTime)
  744. {
  745. @@ -264,7 +297,7 @@
  746. if(errno==EOVERFLOW) PRINTF(L_GEN_ERROR,"action %s read: Buffer overflow",filter->id);
  747. else PRINTF(L_GEN_ERROR,"action %s read: %s",filter->id,strerror(errno));
  748. }
  749. - if(n>0) {
  750. + if(n>0 && n > 3) {
  751. filter->lastTime.Set(); filter->forceRun=false;
  752. Process(filter,buff,n);
  753. // don't make any assumption about data-structs here
  754. diff -Nrubw -x '*.pot' -x '*.po' -x .svn -x '*.o' -x .dependencies -x '*.so' -x '*~' sc-1cc3497be31c/filter.h sc-1cc3497be31c.mcli/filter.h
  755. --- sc-1cc3497be31c/filter.h 2010-04-13 02:55:20.000000000 +0100
  756. +++ sc-1cc3497be31c.mcli/filter.h 2010-04-25 22:34:40.503189752 +0100
  757. @@ -21,6 +21,7 @@
  758. #define ___FILTER_H
  759.  
  760. #include <vdr/thread.h>
  761. +#include "device.h"
  762. #include "misc.h"
  763.  
  764. class cPidFilter;
  765. @@ -61,6 +62,7 @@
  766. //
  767. bool Open(void);
  768. protected:
  769. + cDevice *device;
  770. char *id;
  771. int fd;
  772. int pid;
  773. diff -Nrubw -x '*.pot' -x '*.po' -x .svn -x '*.o' -x .dependencies -x '*.so' -x '*~' sc-1cc3497be31c/Make.config sc-1cc3497be31c.mcli/Make.config
  774. --- sc-1cc3497be31c/Make.config 1970-01-01 01:00:00.000000000 +0100
  775. +++ sc-1cc3497be31c.mcli/Make.config 2010-04-26 21:42:05.383860812 +0100
  776. @@ -0,0 +1,30 @@
  777. +
  778. +APIVERSION := $(shell sed -ne '/define APIVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
  779. +
  780. +# Magic for libvdr-mcli and ReelVDR configuration
  781. +# If we're running with Reelvdr then we do want the mcli compatibility
  782. +# enabled (unless it's explicitly disabled)
  783. +ifneq ($(REELVDR),)
  784. + DEFINES += -DREELVDR
  785. + MCLI_ENABLED ?= 1
  786. +endif
  787. +
  788. +ifeq ($(MCLI_ENABLED),1)
  789. + MCLI_LIBRARY= $(PLUGINLIBDIR)/libvdr-mcli.so.$(APIVERSION)
  790. + ifeq ($(shell ls $(MCLI_LIBRARY) 2> /dev/null | wc -l ),1)
  791. + ifeq ($(shell ls ../mcli/device.h 2> /dev/null | wc -l ),1)
  792. + LIBS += $(MCLI_LIBRARY)
  793. + DEFINES += -DMCLI_ENABLED
  794. + INCLUDES += -I../mcli/ `xml2-config --cflags`
  795. + else
  796. + $(error The source code for the mcli plugin must be present at the same directory level as the sc plugin)
  797. + endif
  798. + else
  799. + $(error mcli support requested, but can't find $(MCLI_LIBRARY) - you may need to install the plugins before building sc)
  800. + endif
  801. +endif
  802. +
  803. +
  804. +ifdef RBMINI
  805. +CXXFLAGS += -DHW_MINI
  806. +endif
  807. diff -Nrubw -x '*.pot' -x '*.po' -x .svn -x '*.o' -x .dependencies -x '*.so' -x '*~' sc-1cc3497be31c/mclidevice.c sc-1cc3497be31c.mcli/mclidevice.c
  808. --- sc-1cc3497be31c/mclidevice.c 1970-01-01 01:00:00.000000000 +0100
  809. +++ sc-1cc3497be31c.mcli/mclidevice.c 2010-04-26 21:00:54.164861079 +0100
  810. @@ -0,0 +1,361 @@
  811. +
  812. +
  813. +
  814. +
  815. +
  816. +cScMcliDevice::cScMcliDevice()
  817. +{
  818. + //SetCaOverride(true);
  819. + decsa=0; tsBuffer=0; cam=0;
  820. +#if APIVERSNUM >= 10500
  821. + ciadapter=0;
  822. +#else
  823. + memset(lrucaid,0,sizeof(lrucaid));
  824. +#endif
  825. + softcsa=true;
  826. + int n=CardIndex();
  827. + scActive=true;
  828. +#ifdef HW_MINI
  829. + if ( rbm_fd == -1 ) {
  830. + rbm_fd = open("/dev/rbm1", O_RDWR|O_NDELAY);
  831. + rbm_dmx_mode mode = RBM_DMX_MODE_TS;
  832. + int ret = ioctl(rbm_fd, RBMIO_SET_DMX_MODE, &mode);
  833. + printf("Set dmx mode %d\n",ret);
  834. +
  835. + }
  836. + dmx_pids.pid_count = 0;
  837. + printf("RBM fd is %d\n",rbm_fd);
  838. +#endif
  839. + ringBuffer=new cRingBufferLinear(MEGABYTE(2),TS_SIZE,true,"FFdecsa-TS");
  840. + ringBuffer->SetTimeouts(100,100);
  841. + softcsa=true;
  842. + delivered = false;
  843. +#ifndef HW_MINI
  844. + decsa=new cDeCSA(CardIndex());
  845. +#else
  846. + decsa = 0;
  847. +#endif
  848. +#if APIVERSNUM >= 10500
  849. + printf("Creating ci adapter\n");
  850. + cam=new cCam(this,n);
  851. + ciadapter=new cScCiAdapter(this,n,cam);
  852. +#else
  853. + //cam=ScSetup.CapCheck(n) ? new cCam(this,n):0;
  854. + cam=new cCam(this,n);
  855. +#endif
  856. + PRINTF(L_GEN_INFO,"Using software decryption on card %d",n);
  857. +}
  858. +
  859. +cScMcliDevice::~cScMcliDevice()
  860. +{
  861. + DetachAllReceivers();
  862. + Cancel(3);
  863. + EarlyShutdown();
  864. + delete decsa;
  865. +}
  866. +
  867. +void cScMcliDevice::EarlyShutdown(void)
  868. +{
  869. +#if APIVERSNUM >= 10500
  870. + SetCamSlot(0);
  871. + delete ciadapter; ciadapter=0;
  872. +#endif
  873. + if (ringBuffer) { delete ringBuffer; ringBuffer = 0; }
  874. + if(cam) cam->Stop();
  875. + delete cam; cam=0;
  876. +}
  877. +
  878. +void cScMcliDevice::Shutdown(void)
  879. +{
  880. + for(int n=cDevice::NumDevices(); --n>=0;) {
  881. + cScMcliDevice *dev=dynamic_cast<cScMcliDevice *>(cDevice::GetDevice(n));
  882. + if(dev) dev->EarlyShutdown();
  883. + }
  884. +}
  885. +
  886. +
  887. +#if APIVERSNUM >= 10501
  888. +bool cScMcliDevice::HasCi(void)
  889. +{
  890. + return ciadapter;
  891. +}
  892. +#endif
  893. +
  894. +#if APIVERSNUM >= 10500
  895. +bool cScMcliDevice::Ready(void)
  896. +{
  897. + bool ret = (ciadapter ? ciadapter->Ready():true);
  898. + printf("Ready %d\n",ret);
  899. + return ret;
  900. +}
  901. +#endif
  902. +
  903. +bool cScMcliDevice::SetPid(cPidHandle *Handle, int Type, bool On)
  904. +{
  905. + if (cMcliDevice::HasInput() == false )
  906. + return false;
  907. +
  908. +#ifdef HW_MINI
  909. + unsigned int i;
  910. + for ( i = 0; i < dmx_pids.pid_count; i++ ) {
  911. + if ( dmx_pids.pid[i] == Handle->pid ) {
  912. + break;
  913. + }
  914. + }
  915. + if ( i == dmx_pids.pid_count ) {
  916. + printf("Setting pid %d at position %d",Handle->pid, dmx_pids.pid_count);
  917. + dmx_pids.pid[dmx_pids.pid_count++] = Handle->pid;
  918. + int ret = ioctl(rbm_fd, RBMIO_SET_DMX_PIDS,&dmx_pids);
  919. + printf("SET_DMX_PIDS = %d",ret);
  920. + }
  921. +#endif
  922. +
  923. + if(cam) cam->SetPid(Type,Handle->pid,On);
  924. + //tsMutex.Lock();
  925. + scActive = true;
  926. + if (decsa) {
  927. + decsa->SetActive(true);
  928. + }
  929. + //tsMutex.Unlock();
  930. + return cMcliDevice::SetPid(Handle,Type,On);
  931. +}
  932. +
  933. +bool cScMcliDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
  934. +{
  935. + if (cMcliDevice::HasInput() == false )
  936. + return false;
  937. +#if APIVERSNUM < 10500
  938. + lruMutex.Lock();
  939. + int i=FindLRUPrg(Channel->Source(),Channel->Transponder(),Channel->Sid());
  940. + if(i<0) i=MAX_LRU_CAID-1;
  941. + if(i>0) memmove(&lrucaid[1],&lrucaid[0],sizeof(struct LruCaid)*i);
  942. + for(i=0; i<=MAXCAIDS; i++) if((lrucaid[0].caids[i]=Channel->Ca(i))==0) break;
  943. + lrucaid[0].src=Channel->Source();
  944. + lrucaid[0].tr=Channel->Transponder();
  945. + lrucaid[0].prg=Channel->Sid();
  946. + lruMutex.Unlock();
  947. +#endif
  948. +
  949. +#ifdef HW_MINI
  950. + rbm_av_flush flush;
  951. + memset(&flush, 0, sizeof(flush));
  952. + flush.mode = RBMIO_FLUSH_CLEAR;
  953. + int res = ioctl(rbm_fd, RBMIO_FLUSH, &flush);
  954. + dmx_pids.pid_count = 0;
  955. +#endif
  956. +
  957. +#if APIVERSNUM < 10500
  958. + SetCaOverride(cam ? ProvidesCa(Channel) : false);
  959. +#else
  960. + SetCaOverride(true);
  961. +#endif
  962. +
  963. + if(cam) cam->Tune(Channel);
  964. + bool ret=cMcliDevice::SetChannelDevice(Channel,LiveView);
  965. + if(ret && cam) cam->PostTune();
  966. + return ret;
  967. +}
  968. +
  969. +#if APIVERSNUM < 10500
  970. +int cScMcliDevice::ProvidesCa(const cChannel *Channel) const
  971. +{
  972. + if(cam && Channel->Ca()>=CA_ENCRYPTED_MIN) {
  973. + int caid;
  974. + for(int j=0; (caid=Channel->Ca(j)); j++)
  975. + if(!overrides.Ignore(Channel->Source(),Channel->Transponder(),caid)) {
  976. + int n=cSystems::CanHandle(caid,!softcsa);
  977. + if(n<0) break;
  978. + if(n>0) return 2;
  979. + }
  980. + }
  981. + return 0;
  982. +}
  983. +
  984. +bool cScMcliDevice::CiAllowConcurrent(void) const
  985. +{
  986. + return true;
  987. +}
  988. +
  989. +bool cScMcliDevice::GetPrgCaids(int source, int transponder, int prg, caid_t *c)
  990. +{
  991. + cMutexLock lock(&lruMutex);
  992. + int i=FindLRUPrg(source,transponder,prg);
  993. + if(i>=0) {
  994. + for(int j=0; j<MAXCAIDS && lrucaid[i].caids[j]; j++) *c++=lrucaid[i].caids[j];
  995. + *c=0;
  996. + return true;
  997. + }
  998. + return false;
  999. +}
  1000. +
  1001. +int cScMcliDevice::FindLRUPrg(int source, int transponder, int prg)
  1002. +{
  1003. + for(int i=0; i<MAX_LRU_CAID; i++)
  1004. + if(lrucaid[i].src==source && lrucaid[i].tr==transponder && lrucaid[i].prg==prg) return i;
  1005. + return -1;
  1006. +}
  1007. +
  1008. +void cScMcliDevice::CiStartDecrypting(void)
  1009. +{
  1010. + if(cam) {
  1011. + cSimpleList<cPrg> prgList;
  1012. + for(cCiCaProgramData *p=ciProgramList.First(); p; p=ciProgramList.Next(p)) {
  1013. + if(p->modified) {
  1014. + cPrg *prg=new cPrg(p->programNumber,cam->HasPrg(p->programNumber));
  1015. + if(prg) {
  1016. + bool haspid=false;
  1017. + for(cCiCaPidData *q=p->pidList.First(); q; q=p->pidList.Next(q)) {
  1018. + if(q->active) {
  1019. + prg->pids.Add(new cPrgPid(q->streamType,q->pid));
  1020. + haspid=true;
  1021. + }
  1022. + }
  1023. + if(haspid) {
  1024. + caid_t casys[MAXCAIDS+1];
  1025. + if(GetPrgCaids(ciSource,ciTransponder,p->programNumber,casys)) {
  1026. + unsigned char buff[2048];
  1027. + bool streamflag;
  1028. + int len=GetCaDescriptors(ciSource,ciTransponder,p->programNumber,casys,sizeof(buff),buff,streamflag);
  1029. + if(len>0) prg->caDescr.Set(buff,len);
  1030. + }
  1031. + }
  1032. + prgList.Add(prg);
  1033. + }
  1034. + p->modified=false;
  1035. + }
  1036. + }
  1037. + for(int loop=1; loop<=2; loop++) // first delete, then add
  1038. + for(cPrg *prg=prgList.First(); prg; prg=prgList.Next(prg))
  1039. + if((loop==1)!=(prg->pids.Count()>0))
  1040. + cam->AddPrg(prg);
  1041. + }
  1042. + cDevice::CiStartDecrypting();
  1043. +}
  1044. +#endif //APIVERSNUM < 10500
  1045. +
  1046. +bool cScMcliDevice::ScActive(void)
  1047. +{
  1048. +#if APIVERSNUM >= 10500
  1049. + return dynamic_cast<cScCamSlot *>(CamSlot())!=0;
  1050. +#else
  1051. + return cam && softcsa;
  1052. +#endif
  1053. +}
  1054. +
  1055. +bool cScMcliDevice::GetTSPacket(uchar *&Data)
  1056. +{
  1057. + int Count=0;
  1058. + if(delivered) { ringBuffer->Del(TS_SIZE); delivered=false; }
  1059. + uchar *p=ringBuffer->Get(Count);
  1060. + if(p && Count>=TS_SIZE) {
  1061. + if(*p!=TS_SYNC_BYTE) {
  1062. + for(int i=1; i<Count; i++)
  1063. + if(p[i]==TS_SYNC_BYTE &&
  1064. + (i+TS_SIZE==Count || (i+TS_SIZE>Count && p[i+TS_SIZE]==TS_SYNC_BYTE)) ) { Count=i; break; }
  1065. + ringBuffer->Del(Count);
  1066. + esyslog("ERROR: skipped %d bytes to sync on TS packet on device %d",Count,CardIndex());
  1067. + return false;
  1068. + }
  1069. + if(scActive && (p[3]&0xC0)) {
  1070. + if(decsa) {
  1071. + if(!decsa->Decrypt(p,Count,false)) {
  1072. + cCondWait::SleepMs(20);
  1073. + return true;
  1074. + }
  1075. + }
  1076. + }
  1077. +
  1078. + delivered=true;
  1079. + Data = p;
  1080. + return true;
  1081. + }
  1082. + return true;
  1083. +}
  1084. +
  1085. +#ifdef GET_TS_PACKETS
  1086. +int cScMcliDevice::GetTSPackets (uchar *Data, int count)
  1087. +{
  1088. + int done = 0;
  1089. + count=1;
  1090. + while ( done < count ) {
  1091. + uchar *temp = 0;
  1092. +
  1093. + GetTSPacket(temp);
  1094. +
  1095. + if (temp != 0 ) {
  1096. + memcpy(Data + (done * TS_SIZE), temp, TS_SIZE);
  1097. + done++;
  1098. + } else break;
  1099. + }
  1100. + return done * TS_SIZE;
  1101. +}
  1102. +#endif
  1103. +
  1104. +
  1105. +bool cScMcliDevice::SoftCSA(bool live)
  1106. +{
  1107. + return true;
  1108. +}
  1109. +
  1110. +void cScMcliDevice::CaidsChanged(void)
  1111. +{
  1112. +#if APIVERSNUM >= 10500
  1113. + if(ciadapter) ciadapter->CaidsChanged();
  1114. + PRINTF(L_CORE_CAIDS,"caid list rebuild triggered");
  1115. +#endif
  1116. +}
  1117. +
  1118. +bool cScMcliDevice::SetCaDescr(ca_descr_t *ca_descr, bool initial)
  1119. +{
  1120. +#ifdef HW_MINI
  1121. + bool ret = ioctl(rbm_fd,CA_SET_DESCR,ca_descr)>=0;
  1122. + return ret;
  1123. +#endif
  1124. +
  1125. + if(decsa) return decsa->SetDescr(ca_descr,initial);
  1126. + return false;
  1127. +}
  1128. +
  1129. +bool cScMcliDevice::SetCaPid(ca_pid_t *ca_pid)
  1130. +{
  1131. +#ifdef HW_MINI
  1132. + bool ret = ioctl(rbm_fd,CA_SET_DESCR,ca_descr)>=0;
  1133. + return ret;
  1134. +#endif
  1135. +
  1136. + if(decsa) return decsa->SetCaPid(ca_pid);
  1137. + return false;
  1138. +}
  1139. +
  1140. +void cScMcliDevice::DumpAV7110(void)
  1141. +{
  1142. +}
  1143. +
  1144. +int cScMcliDevice::HandleTsData (unsigned char *buffer, size_t len)
  1145. +{
  1146. + int olen=len;
  1147. + if (cMcliDevice::HasInput() == false )
  1148. + return len;
  1149. + cMcliDevice::HandleTsData(buffer,len);
  1150. + tsMutex.Lock();
  1151. +#ifdef HW_MINI
  1152. + if ( scActive ) {
  1153. + WriteAllOrNothing(rbm_fd, buffer, len);
  1154. + tsMutex.Unlock();
  1155. + return len;
  1156. + }
  1157. +#endif
  1158. + if ( ringBuffer ) {
  1159. + size_t avail = ringBuffer->Free();
  1160. + if ( avail < len ) {
  1161. + len = avail;
  1162. + }
  1163. + if ( len ) {
  1164. + ringBuffer->Put(buffer, len);
  1165. + }
  1166. + }
  1167. + tsMutex.Unlock();
  1168. + return olen;
  1169. +}
  1170. +
  1171. +
  1172. diff -Nrubw -x '*.pot' -x '*.po' -x .svn -x '*.o' -x .dependencies -x '*.so' -x '*~' sc-1cc3497be31c/sc.c sc-1cc3497be31c.mcli/sc.c
  1173. --- sc-1cc3497be31c/sc.c 2010-04-13 02:55:20.000000000 +0100
  1174. +++ sc-1cc3497be31c.mcli/sc.c 2010-06-13 22:39:39.833522982 +0100
  1175. @@ -52,11 +52,23 @@
  1176. #include "i18n.h"
  1177. #include "log-core.h"
  1178. #include "version.h"
  1179. +#ifdef MCLI_ENABLED
  1180. +#include "../mcli/mcli.h"
  1181. +#endif
  1182.  
  1183. +#ifndef REELVDR
  1184. #define MIN_VERS 1 // required VDR version
  1185. #define MIN_MAJOR 6
  1186. #define MIN_MINOR 0
  1187. #define MINAPIVERSNUM 10600
  1188. +#else
  1189. +#define MIN_VERS 1 // required VDR version
  1190. +#define MIN_MAJOR 4
  1191. +#define MIN_MINOR 5
  1192. +#define MINAPIVERSNUM 10405
  1193. +#endif
  1194. +
  1195. +
  1196.  
  1197. // some sanity checks
  1198. #ifdef HAVE_SOFTCSA
  1199. @@ -1240,6 +1252,9 @@
  1200. virtual bool SetupParse(const char *Name, const char *Value);
  1201. virtual const char **SVDRPHelpPages(void);
  1202. virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode);
  1203. +#ifdef MCLI_ENABLED
  1204. + virtual bool Service(const char *Id, void *data);
  1205. +#endif
  1206. };
  1207.  
  1208. cScPlugin::cScPlugin(void)
  1209. @@ -1282,8 +1297,15 @@
  1210.  
  1211. bool cScPlugin::Initialize(void)
  1212. {
  1213. + bool succ = false;
  1214. PRINTF(L_GEN_INFO,"SC version %s initializing (VDR %s)",ScVersion,VDRVERSION);
  1215. - return dllSuccess && cScDevices::Initialize();
  1216. + if (dllSuccess) {
  1217. + succ=cScDevices::Initialize();
  1218. +#ifdef MCLI_ENABLED
  1219. + succ=true;
  1220. +#endif
  1221. + }
  1222. + return dllSuccess && succ;
  1223. }
  1224.  
  1225. bool cScPlugin::Start(void)
  1226. @@ -1512,4 +1534,28 @@
  1227. return NULL;
  1228. }
  1229.  
  1230. +#ifdef MCLI_ENABLED
  1231. +bool cScPlugin::Service(const char *Id, void *data)
  1232. +{
  1233. + if ( Id && strcmp(Id, "OnNewMcliDevice-" MCLI_DEVICE_VERSION) == 0 ) {
  1234. + cMcliDevice **dev_ptr = (cMcliDevice **) data;
  1235. + cMcliDevice *dev = *dev_ptr;
  1236. + if ( dev ) {
  1237. + dev->SetEnable(false);
  1238. + delete dev;
  1239. + }
  1240. + // Wait till sc has truly started
  1241. + while ( keeper == 0 ) {
  1242. + cCondWait::SleepMs(200);
  1243. + }
  1244. + cScMcliDevice *newdev = new cScMcliDevice();
  1245. + *dev_ptr = newdev;
  1246. + return true;
  1247. + }
  1248. + return false;
  1249. +}
  1250. +#endif
  1251. +
  1252. +
  1253. +
  1254. VDRPLUGINCREATOR(cScPlugin); // Don't touch this!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement