Advertisement
Guest User

B25 patch for BDPL-a4dd4dc535eed979d1752b0ad3a30e2636ba878c

a guest
Jul 7th, 2015
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.50 KB | None | 0 0
  1. --- BonDriverProxy_Linux-master/B25Decoder.h Thu Jan 1 00:00:00 1970
  2. +++ BonDriverProxy_Linux_b25/B25Decoder.h Tue Jul 7 17:40:25 2015
  3. @@ -0,0 +1,89 @@
  4. +#pragma once
  5. +#include <arib25/arib_std_b25.h>
  6. +
  7. +class B25Decoder
  8. +{
  9. +public:
  10. + B25Decoder()
  11. + : _bcas(NULL),
  12. + _b25(NULL)
  13. + {
  14. + }
  15. +
  16. + ~B25Decoder()
  17. + {
  18. + release();
  19. + }
  20. +
  21. + void init()
  22. + {
  23. + if (_bcas)
  24. + return;
  25. + _bcas = create_b_cas_card();
  26. + if (_bcas)
  27. + {
  28. + if (_bcas->init(_bcas) >= 0)
  29. + {
  30. + _b25 = create_arib_std_b25();
  31. + if (_b25)
  32. + {
  33. + if (_b25->set_b_cas_card(_b25, _bcas) >= 0)
  34. + {
  35. + _b25->set_strip(_b25, strip);
  36. + _b25->set_emm_proc(_b25, emm_proc);
  37. + _b25->set_multi2_round(_b25, multi2_round);
  38. + return;
  39. + }
  40. + }
  41. + }
  42. + release();
  43. + }
  44. + }
  45. +
  46. + void release()
  47. + {
  48. + if (_b25)
  49. + {
  50. + _b25->release(_b25);
  51. + _b25 = NULL;
  52. + }
  53. + if (_bcas)
  54. + {
  55. + _bcas->release(_bcas);
  56. + _bcas = NULL;
  57. + }
  58. + }
  59. +
  60. + BOOL isValid()
  61. + {
  62. + return _b25 != NULL;
  63. + }
  64. +
  65. + void decode(BYTE **ppDst, DWORD *pdwSize)
  66. + {
  67. + if (_b25)
  68. + {
  69. + ARIB_STD_B25_BUFFER buf;
  70. + buf.data = *ppDst;
  71. + buf.size = *pdwSize;
  72. + if (_b25->put(_b25, &buf) < 0)
  73. + {
  74. + // 以降、パススルー動作
  75. + release();
  76. + return;
  77. + }
  78. + _b25->get(_b25, &buf);
  79. + *ppDst = buf.data;
  80. + *pdwSize = buf.size;
  81. + }
  82. + }
  83. +
  84. + // initialize parameter
  85. + static int strip;
  86. + static int emm_proc;
  87. + static int multi2_round;
  88. +
  89. +private:
  90. + B_CAS_CARD *_bcas;
  91. + ARIB_STD_B25 *_b25;
  92. +};
  93. --- BonDriverProxy_Linux-master/BonDriver_DVB.conf Mon Jul 6 03:22:14 2015
  94. +++ BonDriverProxy_Linux_b25/BonDriver_DVB.conf Tue Jul 7 13:36:35 2015
  95. @@ -2,6 +2,10 @@
  96. #GETCNRMODE=0
  97. #USELNB=0
  98. #USESERVICEID=0
  99. +;#B25=1
  100. +;#STRIP=1
  101. +;#EMM=1
  102. +;#MULTI2ROUND=4
  103. ; 名称, BonDriverとしてのチャンネル番号, 周波数テーブル番号, TSID
  104. ; 記述はタブ区切り
  105. #ISDB_S
  106. --- BonDriverProxy_Linux-master/BonDriver_DVB.cpp Mon Jul 6 03:22:14 2015
  107. +++ BonDriverProxy_Linux_b25/BonDriver_DVB.cpp Tue Jul 7 13:44:58 2015
  108. @@ -1,4 +1,7 @@
  109. #include "BonDriver_DVB.h"
  110. +#ifdef HAVE_LIBARIB25
  111. +#include "B25Decoder.h"
  112. +#endif
  113.  
  114. namespace BonDriver_DVB {
  115.  
  116. @@ -13,6 +16,10 @@
  117. static BOOL g_ModPMT;
  118. static BOOL g_TsSync;
  119. static DWORD g_dwDelFlag;
  120. +#ifdef HAVE_LIBARIB25
  121. +static int g_b25_enable = 0;
  122. +static B25Decoder g_b25;
  123. +#endif
  124.  
  125. static int Convert(char *src, char *dst, size_t dstsize)
  126. {
  127. @@ -98,6 +105,17 @@
  128. BOOL bmFlag = FALSE;
  129. BOOL btFlag = FALSE;
  130. BOOL bdFlag = FALSE;
  131. +#ifdef HAVE_LIBARIB25
  132. + struct {
  133. + unsigned b25:1;
  134. + unsigned strip:1;
  135. + unsigned emm:1;
  136. + unsigned multi2round:1;
  137. + } b25flags = {0};
  138. + B25Decoder::strip = 0;
  139. + B25Decoder::emm_proc = 0;
  140. + B25Decoder::multi2_round = 4;
  141. +#endif
  142. while (::fgets(buf, sizeof(buf), fp))
  143. {
  144. if (buf[0] == ';')
  145. @@ -187,6 +205,28 @@
  146. delete[] pp;
  147. bdFlag = TRUE;
  148. }
  149. +#ifdef HAVE_LIBARIB25
  150. + else if (!b25flags.b25 && IsTagMatch(buf, "#B25", &p))
  151. + {
  152. + g_b25_enable = ::atoi(p);
  153. + b25flags.b25 = 1;
  154. + }
  155. + else if (!b25flags.strip && IsTagMatch(buf, "#STRIP", &p))
  156. + {
  157. + B25Decoder::strip = ::atoi(p);
  158. + b25flags.strip = 1;
  159. + }
  160. + else if (!b25flags.emm && IsTagMatch(buf, "#EMM", &p))
  161. + {
  162. + B25Decoder::emm_proc = ::atoi(p);
  163. + b25flags.emm = 1;
  164. + }
  165. + else if (!b25flags.multi2round && IsTagMatch(buf, "#MULTI2ROUND", &p))
  166. + {
  167. + B25Decoder::multi2_round = ::atoi(p);
  168. + b25flags.multi2round = 1;
  169. + }
  170. +#endif
  171. else
  172. {
  173. int n = 0;
  174. @@ -448,6 +488,10 @@
  175. }
  176.  
  177. m_bTuner = TRUE;
  178. +#ifdef HAVE_LIBARIB25
  179. + if (g_b25_enable)
  180. + g_b25.init();
  181. +#endif
  182. return TRUE;
  183.  
  184. err0:
  185. @@ -488,6 +532,9 @@
  186. ::close(m_fefd);
  187. m_fefd = m_dmxfd = m_dvrfd = -1;
  188. m_bTuner = FALSE;
  189. +#ifdef HAVE_LIBARIB25
  190. + g_b25.release();
  191. +#endif
  192. }
  193. }
  194.  
  195. @@ -552,6 +599,10 @@
  196. *pdwSize = m_LastBuf->dwSize;
  197. *pdwRemain = (DWORD)m_fifoTS.Size();
  198. b = TRUE;
  199. +#ifdef HAVE_LIBARIB25
  200. + if (g_b25.isValid())
  201. + g_b25.decode(ppDst, pdwSize);
  202. +#endif
  203. }
  204. else
  205. {
  206. --- BonDriverProxy_Linux-master/BonDriver_DVB_UseServiceID.conf Mon Jul 6 03:22:14 2015
  207. +++ BonDriverProxy_Linux_b25/BonDriver_DVB_UseServiceID.conf Tue Jul 7 13:36:35 2015
  208. @@ -11,6 +11,10 @@
  209. ; 更に、TYPEDを指定するとISO/IEC 13818-6 type DのPIDストリーム(データ放送で使用されている)が削除される
  210. ; DEL=CAT,EIT,SDTT,BIT,CDT,TYPEDの様に指定する(なお、ECMを削除するとスクランブルが解除できなくなるので注意)
  211. #DEL=TYPED
  212. +;#B25=1
  213. +;#STRIP=1
  214. +;#EMM=1
  215. +;#MULTI2ROUND=4
  216. ; 名称, BonDriverとしてのチャンネル番号, 周波数テーブル番号, TSID, 対象サービスID
  217. ; 記述はタブ区切り
  218. #ISDB_S
  219. --- BonDriverProxy_Linux-master/BonDriver_LinuxPT.conf Mon Jul 6 03:22:14 2015
  220. +++ BonDriverProxy_Linux_b25/BonDriver_LinuxPT.conf Tue Jul 7 13:36:35 2015
  221. @@ -1,6 +1,10 @@
  222. #DEVICE=/dev/pt3video0
  223. #USELNB=0
  224. #USESERVICEID=0
  225. +;#B25=1
  226. +;#STRIP=1
  227. +;#EMM=1
  228. +;#MULTI2ROUND=4
  229. ; 名称, BonDriverとしてのチャンネル番号, 周波数テーブル番号, スロット番号/加算する周波数
  230. ; 記述はタブ区切り
  231. #ISDB_S
  232. --- BonDriverProxy_Linux-master/BonDriver_LinuxPT.cpp Mon Jul 6 03:22:14 2015
  233. +++ BonDriverProxy_Linux_b25/BonDriver_LinuxPT.cpp Tue Jul 7 13:45:05 2015
  234. @@ -1,5 +1,8 @@
  235. #include "BonDriver_LinuxPT.h"
  236. #include "plex.cpp"
  237. +#ifdef HAVE_LIBARIB25
  238. +#include "B25Decoder.h"
  239. +#endif
  240.  
  241. namespace BonDriver_LinuxPT {
  242.  
  243. @@ -13,6 +16,10 @@
  244. static DWORD g_Crc32Table[256];
  245. static BOOL g_ModPMT;
  246. static DWORD g_dwDelFlag;
  247. +#ifdef HAVE_LIBARIB25
  248. +static int g_b25_enable = 0;
  249. +static B25Decoder g_b25;
  250. +#endif
  251.  
  252. static int Convert(char *src, char *dst, size_t dstsize)
  253. {
  254. @@ -96,6 +103,17 @@
  255. BOOL bsFlag = FALSE;
  256. BOOL bmFlag = FALSE;
  257. BOOL bdelFlag = FALSE;
  258. +#ifdef HAVE_LIBARIB25
  259. + struct {
  260. + unsigned b25:1;
  261. + unsigned strip:1;
  262. + unsigned emm:1;
  263. + unsigned multi2round:1;
  264. + } b25flags = {0};
  265. + B25Decoder::strip = 0;
  266. + B25Decoder::emm_proc = 0;
  267. + B25Decoder::multi2_round = 4;
  268. +#endif
  269. while (::fgets(buf, sizeof(buf), fp))
  270. {
  271. if (buf[0] == ';')
  272. @@ -206,6 +224,28 @@
  273. delete[] pp;
  274. bdelFlag = TRUE;
  275. }
  276. +#ifdef HAVE_LIBARIB25
  277. + else if (!b25flags.b25 && IsTagMatch(buf, "#B25", &p))
  278. + {
  279. + g_b25_enable = ::atoi(p);
  280. + b25flags.b25 = 1;
  281. + }
  282. + else if (!b25flags.strip && IsTagMatch(buf, "#STRIP", &p))
  283. + {
  284. + B25Decoder::strip = ::atoi(p);
  285. + b25flags.strip = 1;
  286. + }
  287. + else if (!b25flags.emm && IsTagMatch(buf, "#EMM", &p))
  288. + {
  289. + B25Decoder::emm_proc = ::atoi(p);
  290. + b25flags.emm = 1;
  291. + }
  292. + else if (!b25flags.multi2round && IsTagMatch(buf, "#MULTI2ROUND", &p))
  293. + {
  294. + B25Decoder::multi2_round = ::atoi(p);
  295. + b25flags.multi2round = 1;
  296. + }
  297. +#endif
  298. else
  299. {
  300. int n = 0;
  301. @@ -363,6 +403,10 @@
  302. if (g_UseLNB && (g_Type == 0) && (::ioctl(m_fd, LNB_ENABLE, 2) < 0))
  303. ::fprintf(stderr, "LNB ON failed: %s\n", g_Device);
  304. m_bTuner = TRUE;
  305. +#ifdef HAVE_LIBARIB25
  306. + if (g_b25_enable)
  307. + g_b25.init();
  308. +#endif
  309. return TRUE;
  310. }
  311.  
  312. @@ -382,6 +426,9 @@
  313. ::close(m_fd);
  314. m_bTuner = FALSE;
  315. m_fd = -1;
  316. +#ifdef HAVE_LIBARIB25
  317. + g_b25.release();
  318. +#endif
  319. }
  320. }
  321.  
  322. @@ -446,6 +493,10 @@
  323. *pdwSize = m_LastBuf->dwSize;
  324. *pdwRemain = (DWORD)m_fifoTS.Size();
  325. b = TRUE;
  326. +#ifdef HAVE_LIBARIB25
  327. + if (g_b25.isValid())
  328. + g_b25.decode(ppDst, pdwSize);
  329. +#endif
  330. }
  331. else
  332. {
  333. --- BonDriverProxy_Linux-master/BonDriver_LinuxPT_UseServiceID.conf Mon Jul 6 03:22:14 2015
  334. +++ BonDriverProxy_Linux_b25/BonDriver_LinuxPT_UseServiceID.conf Tue Jul 7 13:36:35 2015
  335. @@ -8,6 +8,10 @@
  336. ; 更に、TYPEDを指定するとISO/IEC 13818-6 type DのPIDストリーム(データ放送で使用されている)が削除される
  337. ; DEL=CAT,EIT,SDTT,BIT,CDT,TYPEDの様に指定する(なお、ECMを削除するとスクランブルが解除できなくなるので注意)
  338. #DEL=TYPED
  339. +;#B25=1
  340. +;#STRIP=1
  341. +;#EMM=1
  342. +;#MULTI2ROUND=4
  343. ; 名称, BonDriverとしてのチャンネル番号, 周波数テーブル番号, スロット番号/加算する周波数, 対象サービスID
  344. ; 記述はタブ区切り
  345. #ISDB_S
  346. --- BonDriverProxy_Linux-master/BonDriverProxy.cpp Mon Jul 6 03:22:14 2015
  347. +++ BonDriverProxy_Linux_b25/BonDriverProxy.cpp Tue Jul 7 13:36:35 2015
  348. @@ -1,5 +1,13 @@
  349. #include "BonDriverProxy.h"
  350.  
  351. +#ifdef HAVE_LIBARIB25
  352. +#include <getopt.h>
  353. +static int g_b25_enable = 0;
  354. +int B25Decoder::strip = 0;
  355. +int B25Decoder::emm_proc = 0;
  356. +int B25Decoder::multi2_round = 4;
  357. +#endif
  358. +
  359. namespace BonDriverProxy {
  360.  
  361. #define STRICT_LOCK
  362. @@ -29,6 +37,40 @@
  363.  
  364. static int Init(int ac, char *av[])
  365. {
  366. +#ifdef HAVE_LIBARIB25
  367. + static const struct option options[] = {
  368. + {"b25", no_argument, &g_b25_enable, 1},
  369. + {"strip", no_argument, &B25Decoder::strip, 1},
  370. + {"EMM", no_argument, &B25Decoder::emm_proc, 1},
  371. + {"round", required_argument, NULL, 'r'},
  372. + {0}
  373. + };
  374. +
  375. + int opt;
  376. +
  377. + while ((opt = getopt_long(ac, av, "", options, NULL)) != -1)
  378. + {
  379. + switch (opt)
  380. + {
  381. + case 0: // long options
  382. + break;
  383. + case 'r': // multi2 round
  384. + B25Decoder::multi2_round = strtoul(optarg, NULL, 10);
  385. + break;
  386. + default:
  387. + return -1;
  388. + }
  389. + }
  390. +
  391. + if (optind > 1)
  392. + {
  393. + int i = optind, j = 1;
  394. + while (i < ac)
  395. + av[j++] = av[i++];
  396. + ac -= optind - 1;
  397. + }
  398. +#endif
  399. +
  400. if (ac < 3)
  401. return -1;
  402. ::strncpy(g_Host, av[1], sizeof(g_Host) - 1);
  403. @@ -558,6 +600,10 @@
  404. m_pTsReaderArg = new stTsReaderArg();
  405. m_pTsReaderArg->TsReceiversList.push_back(this);
  406. m_pTsReaderArg->pIBon = m_pIBon;
  407. +#ifdef HAVE_LIBARIB25
  408. + if (g_b25_enable)
  409. + m_pTsReaderArg->b25.init();
  410. +#endif
  411. if (::pthread_create(&m_hTsRead, NULL, cProxyServer::TsReader, m_pTsReaderArg))
  412. {
  413. m_hTsRead = 0;
  414. @@ -834,6 +880,10 @@
  415. }
  416. if (pIBon->GetTsStream(&pBuf, &dwSize, &dwRemain) && (dwSize != 0))
  417. {
  418. +#ifdef HAVE_LIBARIB25
  419. + if (pArg->b25.isValid())
  420. + pArg->b25.decode(&pBuf, &dwSize);
  421. +#endif
  422. if ((pos + dwSize) < TsPacketBufSize)
  423. {
  424. ::memcpy(&pTsBuf[pos], pBuf, dwSize);
  425. @@ -1086,7 +1136,12 @@
  426. {
  427. if (BonDriverProxy::Init(argc, argv) != 0)
  428. {
  429. +#ifdef HAVE_LIBARIB25
  430. + fprintf(stderr, "usage: %s [--b25 [--round N] [--strip] [--EMM]] "
  431. + "address port (packet_fifo_size tspacket_bufsize)\ne.g. $ %s 192.168.0.100 1192\n", argv[0],argv[0]);
  432. +#else
  433. fprintf(stderr, "usage: %s address port (packet_fifo_size tspacket_bufsize)\ne.g. $ %s 192.168.0.100 1192\n", argv[0],argv[0]);
  434. +#endif
  435. return 0;
  436. }
  437.  
  438. --- BonDriverProxy_Linux-master/BonDriverProxy.h Mon Jul 6 03:22:14 2015
  439. +++ BonDriverProxy_Linux_b25/BonDriverProxy.h Tue Jul 7 13:36:35 2015
  440. @@ -23,6 +23,9 @@
  441. #include <queue>
  442. #include "typedef.h"
  443. #include "IBonDriver3.h"
  444. +#ifdef HAVE_LIBARIB25
  445. +#include "B25Decoder.h"
  446. +#endif
  447.  
  448. #if __APPLE__
  449. #undef daemon
  450. @@ -66,6 +69,9 @@
  451. DWORD pos;
  452. std::list<cProxyServer *> TsReceiversList;
  453. cCriticalSection TsLock;
  454. +#ifdef HAVE_LIBARIB25
  455. + B25Decoder b25;
  456. +#endif
  457. stTsReaderArg()
  458. {
  459. StopTsRead = FALSE;
  460. --- BonDriverProxy_Linux-master/BonDriverProxyEx.cpp Mon Jul 6 03:22:14 2015
  461. +++ BonDriverProxy_Linux_b25/BonDriverProxyEx.cpp Tue Jul 7 13:36:35 2015
  462. @@ -1,5 +1,13 @@
  463. #include "BonDriverProxyEx.h"
  464.  
  465. +#ifdef HAVE_LIBARIB25
  466. +#include <getopt.h>
  467. +static int g_b25_enable = 0;
  468. +int B25Decoder::strip = 0;
  469. +int B25Decoder::emm_proc = 0;
  470. +int B25Decoder::multi2_round = 4;
  471. +#endif
  472. +
  473. namespace BonDriverProxyEx {
  474.  
  475. #ifdef DEBUG
  476. @@ -53,6 +61,40 @@
  477.  
  478. static int Init(int ac, char *av[])
  479. {
  480. +#ifdef HAVE_LIBARIB25
  481. + static const struct option options[] = {
  482. + {"b25", no_argument, &g_b25_enable, 1},
  483. + {"strip", no_argument, &B25Decoder::strip, 1},
  484. + {"EMM", no_argument, &B25Decoder::emm_proc, 1},
  485. + {"round", required_argument, NULL, 'r'},
  486. + {0}
  487. + };
  488. +
  489. + int opt;
  490. +
  491. + while ((opt = getopt_long(ac, av, "", options, NULL)) != -1)
  492. + {
  493. + switch (opt)
  494. + {
  495. + case 0: // long options
  496. + break;
  497. + case 'r': // multi2 round
  498. + B25Decoder::multi2_round = strtoul(optarg, NULL, 10);
  499. + break;
  500. + default:
  501. + return -1;
  502. + }
  503. + }
  504. +
  505. + if (optind > 1)
  506. + {
  507. + int i = optind, j = 1;
  508. + while (i < ac)
  509. + av[j++] = av[i++];
  510. + ac -= optind - 1;
  511. + }
  512. +#endif
  513. +
  514. if (ac < 3)
  515. return -1;
  516. ::strncpy(g_Host, av[1], sizeof(g_Host) - 1);
  517. @@ -740,6 +782,10 @@
  518. m_pTsReaderArg = new stTsReaderArg();
  519. m_pTsReaderArg->TsReceiversList.push_back(this);
  520. m_pTsReaderArg->pIBon = m_pIBon;
  521. +#ifdef HAVE_LIBARIB25
  522. + if (g_b25_enable)
  523. + m_pTsReaderArg->b25.init();
  524. +#endif
  525. if (::pthread_create(&m_hTsRead, NULL, cProxyServerEx::TsReader, m_pTsReaderArg))
  526. {
  527. m_hTsRead = 0;
  528. @@ -1042,6 +1088,10 @@
  529. }
  530. if (pIBon->GetTsStream(&pBuf, &dwSize, &dwRemain) && (dwSize != 0))
  531. {
  532. +#ifdef HAVE_LIBARIB25
  533. + if (pArg->b25.isValid())
  534. + pArg->b25.decode(&pBuf, &dwSize);
  535. +#endif
  536. if ((pos + dwSize) < TsPacketBufSize)
  537. {
  538. ::memcpy(&pTsBuf[pos], pBuf, dwSize);
  539. @@ -1489,7 +1539,12 @@
  540. {
  541. if (BonDriverProxyEx::Init(argc, argv) != 0)
  542. {
  543. +#ifdef HAVE_LIBARIB25
  544. + fprintf(stderr, "usage: %s [--b25 [--round N] [--strip] [--EMM]] "
  545. + "address port (opentuner_return_delay_time packet_fifo_size tspacket_bufsize)\ne.g. $ %s 192.168.0.100 1192\n", argv[0],argv[0]);
  546. +#else
  547. fprintf(stderr, "usage: %s address port (opentuner_return_delay_time packet_fifo_size tspacket_bufsize)\ne.g. $ %s 192.168.0.100 1192\n", argv[0],argv[0]);
  548. +#endif
  549. return 0;
  550. }
  551.  
  552. --- BonDriverProxy_Linux-master/BonDriverProxyEx.h Mon Jul 6 03:22:14 2015
  553. +++ BonDriverProxy_Linux_b25/BonDriverProxyEx.h Tue Jul 7 13:36:35 2015
  554. @@ -26,6 +26,9 @@
  555. #include <map>
  556. #include "typedef.h"
  557. #include "IBonDriver3.h"
  558. +#ifdef HAVE_LIBARIB25
  559. +#include "B25Decoder.h"
  560. +#endif
  561.  
  562. #if __APPLE__
  563. #undef daemon
  564. @@ -73,6 +76,9 @@
  565. DWORD pos;
  566. std::list<cProxyServerEx *> TsReceiversList;
  567. cCriticalSection TsLock;
  568. +#ifdef HAVE_LIBARIB25
  569. + B25Decoder b25;
  570. +#endif
  571. stTsReaderArg()
  572. {
  573. StopTsRead = FALSE;
  574. --- BonDriverProxy_Linux-master/Makefile Mon Jul 6 03:22:14 2015
  575. +++ BonDriverProxy_Linux_b25/Makefile Tue Jul 7 13:36:35 2015
  576. @@ -3,8 +3,9 @@
  577. include Makefile.in
  578.  
  579. SRCDIR = .
  580. +CPPFLAGS += -DHAVE_LIBARIB25
  581. LDFLAGS =
  582. -LIBS = -ldl
  583. +LIBS = -ldl -larib25
  584. SRCS = BonDriverProxy.cpp BonDriverProxyEx.cpp sample.cpp
  585. SOSRCS = BonDriver_Proxy.cpp
  586. ifneq ($(UNAME), Darwin)
  587. --- BonDriverProxy_Linux-master/sample.cpp Mon Jul 6 03:22:14 2015
  588. +++ BonDriverProxy_Linux_b25/sample.cpp Tue Jul 7 13:36:35 2015
  589. @@ -1,5 +1,5 @@
  590. /*
  591. -$ g++ -O2 -Wall -rdynamic -o sample sample.cpp -ldl
  592. +$ g++ -O2 -Wall -rdynamic -o sample sample.cpp -ldl -larib25 -DHAVE_LIBARIB25
  593. */
  594. #define _FILE_OFFSET_BITS 64
  595. #include <unistd.h>
  596. @@ -15,6 +15,14 @@
  597. #include "typedef.h"
  598. #include "IBonDriver2.h"
  599.  
  600. +#ifdef HAVE_LIBARIB25
  601. +#include <getopt.h>
  602. +#include "B25Decoder.h"
  603. +int B25Decoder::strip = 0;
  604. +int B25Decoder::emm_proc = 0;
  605. +int B25Decoder::multi2_round = 4;
  606. +#endif
  607. +
  608. static volatile BOOL bStop = FALSE;
  609. static void handler(int sig)
  610. {
  611. @@ -23,7 +31,12 @@
  612.  
  613. void usage(char *p)
  614. {
  615. +#ifdef HAVE_LIBARIB25
  616. + fprintf(stderr, "usage: %s [--b25 [--round N] [--strip] [--EMM]] "
  617. + "[-b bondriver] [-s space_no] [-c channel_no] ( [-t sec] [-o filename] )\n", p);
  618. +#else
  619. fprintf(stderr, "usage: %s [-b bondriver] [-s space_no] [-c channel_no] ( [-t sec] [-o filename] )\n", p);
  620. +#endif
  621. exit(0);
  622. }
  623.  
  624. @@ -32,16 +45,38 @@
  625. int opt, bfind, sfind, cfind, ofind, wfd;
  626. char *bon, *output;
  627. DWORD sec, dwSpace, dwChannel;
  628. +#ifdef HAVE_LIBARIB25
  629. + B25Decoder b25;
  630. + int b25_enable = 0;
  631. +#endif
  632.  
  633. // パラメータ処理
  634. sec = 0xffffffff;
  635. bon = output = NULL;
  636. bfind = sfind = cfind = ofind = 0;
  637. dwSpace = dwChannel = 0;
  638. +#ifdef HAVE_LIBARIB25
  639. + static const struct option options[] = {
  640. + {"b25", no_argument, &b25_enable, 1},
  641. + {"strip", no_argument, &B25Decoder::strip, 1},
  642. + {"EMM", no_argument, &B25Decoder::emm_proc, 1},
  643. + {"round", required_argument, NULL, 'r'},
  644. + {0}
  645. + };
  646. + while ((opt = getopt_long(argc, argv, "b:s:c:t:o:", options, NULL)) != -1)
  647. +#else
  648. while ((opt = getopt(argc, argv, "b:s:c:t:o:")) != -1)
  649. +#endif
  650. {
  651. switch (opt)
  652. {
  653. +#ifdef HAVE_LIBARIB25
  654. + case 0: // long options
  655. + break;
  656. + case 'r': // multi2 round
  657. + b25.multi2_round = strtoul(optarg, NULL, 10);
  658. + break;
  659. +#endif
  660. case 'b': // BonDriver指定
  661. bon = optarg;
  662. bfind = 1;
  663. @@ -127,6 +162,10 @@
  664. close(wfd);
  665. return -3;
  666. }
  667. +#ifdef HAVE_LIBARIB25
  668. + if (b25_enable)
  669. + b25.init();
  670. +#endif
  671.  
  672. // 指定チャンネルにセット
  673. pIBon2->SetChannel(dwSpace, dwChannel);
  674. @@ -158,6 +197,10 @@
  675. {
  676. // この時点でpBufに長さdwSize分のTSストリームを取得した状態なので、それを書き出し
  677. // (もしバッファリングやデスクランブルやTS分離処理を入れるならこの辺で)
  678. +#ifdef HAVE_LIBARIB25
  679. + if (b25.isValid())
  680. + b25.decode(&pBuf, &dwSize);
  681. +#endif
  682. int len, left = (int)dwSize;
  683. do
  684. {
  685. @@ -178,6 +221,11 @@
  686.  
  687. // チューナクローズ
  688. pIBon->CloseTuner();
  689. +#ifdef HAVE_LIBARIB25
  690. + if (b25_enable)
  691. + b25.release();
  692. +#endif
  693. +
  694.  
  695. // 現在のBonDriver_LinuxPT/DVB/Proxyの実装では無意味なのに気付いたので削除(;´Д`)失礼しました
  696. #if 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement