Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- a/B25Decoder.h Thu Jan 1 00:00:00 1970
- +++ b/B25Decoder.h Thu Jul 9 18:21:33 2015
- @@ -0,0 +1,89 @@
- +#pragma once
- +#include <arib25/arib_std_b25.h>
- +
- +class B25Decoder
- +{
- +public:
- + B25Decoder()
- + : _bcas(NULL),
- + _b25(NULL)
- + {
- + }
- +
- + ~B25Decoder()
- + {
- + release();
- + }
- +
- + void init()
- + {
- + if (_bcas)
- + return;
- + _bcas = create_b_cas_card();
- + if (_bcas)
- + {
- + if (_bcas->init(_bcas) >= 0)
- + {
- + _b25 = create_arib_std_b25();
- + if (_b25)
- + {
- + if (_b25->set_b_cas_card(_b25, _bcas) >= 0)
- + {
- + _b25->set_strip(_b25, strip);
- + _b25->set_emm_proc(_b25, emm_proc);
- + _b25->set_multi2_round(_b25, multi2_round);
- + return;
- + }
- + }
- + }
- + release();
- + }
- + }
- +
- + void release()
- + {
- + if (_b25)
- + {
- + _b25->release(_b25);
- + _b25 = NULL;
- + }
- + if (_bcas)
- + {
- + _bcas->release(_bcas);
- + _bcas = NULL;
- + }
- + }
- +
- + BOOL isValid()
- + {
- + return _b25 != NULL;
- + }
- +
- + void decode(BYTE **ppDst, DWORD *pdwSize)
- + {
- + if (_b25)
- + {
- + ARIB_STD_B25_BUFFER buf;
- + buf.data = *ppDst;
- + buf.size = *pdwSize;
- + const int rc = _b25->put(_b25, &buf);
- + if (rc < 0) {
- + if (rc == -9) // Path through (ARIB_STD_B25_ERROR_ECM_PROC_FAILURE)
- + release();
- + return;
- + }
- + _b25->get(_b25, &buf);
- + *ppDst = buf.data;
- + *pdwSize = buf.size;
- + }
- + }
- +
- + // initialize parameter
- + static int strip;
- + static int emm_proc;
- + static int multi2_round;
- +
- +private:
- + B_CAS_CARD *_bcas;
- + ARIB_STD_B25 *_b25;
- +};
- --- a/BonDriver_DVB.conf Mon Jul 6 03:22:14 2015
- +++ b/BonDriver_DVB.conf Tue Jul 7 13:36:35 2015
- @@ -2,6 +2,10 @@
- #GETCNRMODE=0
- #USELNB=0
- #USESERVICEID=0
- +;#B25=1
- +;#STRIP=1
- +;#EMM=1
- +;#MULTI2ROUND=4
- ; 名称, BonDriverとしてのチャンネル番号, 周波数テーブル番号, TSID
- ; 記述はタブ区切り
- #ISDB_S
- --- a/BonDriver_DVB.cpp Mon Jul 6 03:22:14 2015
- +++ b/BonDriver_DVB.cpp Tue Jul 7 13:44:58 2015
- @@ -1,4 +1,7 @@
- #include "BonDriver_DVB.h"
- +#ifdef HAVE_LIBARIB25
- +#include "B25Decoder.h"
- +#endif
- namespace BonDriver_DVB {
- @@ -13,6 +16,10 @@
- static BOOL g_ModPMT;
- static BOOL g_TsSync;
- static DWORD g_dwDelFlag;
- +#ifdef HAVE_LIBARIB25
- +static int g_b25_enable = 0;
- +static B25Decoder g_b25;
- +#endif
- static int Convert(char *src, char *dst, size_t dstsize)
- {
- @@ -98,6 +105,17 @@
- BOOL bmFlag = FALSE;
- BOOL btFlag = FALSE;
- BOOL bdFlag = FALSE;
- +#ifdef HAVE_LIBARIB25
- + struct {
- + unsigned b25:1;
- + unsigned strip:1;
- + unsigned emm:1;
- + unsigned multi2round:1;
- + } b25flags = {0};
- + B25Decoder::strip = 0;
- + B25Decoder::emm_proc = 0;
- + B25Decoder::multi2_round = 4;
- +#endif
- while (::fgets(buf, sizeof(buf), fp))
- {
- if (buf[0] == ';')
- @@ -187,6 +205,28 @@
- delete[] pp;
- bdFlag = TRUE;
- }
- +#ifdef HAVE_LIBARIB25
- + else if (!b25flags.b25 && IsTagMatch(buf, "#B25", &p))
- + {
- + g_b25_enable = ::atoi(p);
- + b25flags.b25 = 1;
- + }
- + else if (!b25flags.strip && IsTagMatch(buf, "#STRIP", &p))
- + {
- + B25Decoder::strip = ::atoi(p);
- + b25flags.strip = 1;
- + }
- + else if (!b25flags.emm && IsTagMatch(buf, "#EMM", &p))
- + {
- + B25Decoder::emm_proc = ::atoi(p);
- + b25flags.emm = 1;
- + }
- + else if (!b25flags.multi2round && IsTagMatch(buf, "#MULTI2ROUND", &p))
- + {
- + B25Decoder::multi2_round = ::atoi(p);
- + b25flags.multi2round = 1;
- + }
- +#endif
- else
- {
- int n = 0;
- @@ -448,6 +488,10 @@
- }
- m_bTuner = TRUE;
- +#ifdef HAVE_LIBARIB25
- + if (g_b25_enable)
- + g_b25.init();
- +#endif
- return TRUE;
- err0:
- @@ -488,6 +532,9 @@
- ::close(m_fefd);
- m_fefd = m_dmxfd = m_dvrfd = -1;
- m_bTuner = FALSE;
- +#ifdef HAVE_LIBARIB25
- + g_b25.release();
- +#endif
- }
- }
- @@ -552,6 +599,10 @@
- *pdwSize = m_LastBuf->dwSize;
- *pdwRemain = (DWORD)m_fifoTS.Size();
- b = TRUE;
- +#ifdef HAVE_LIBARIB25
- + if (g_b25.isValid())
- + g_b25.decode(ppDst, pdwSize);
- +#endif
- }
- else
- {
- --- a/BonDriver_DVB_UseServiceID.conf Mon Jul 6 03:22:14 2015
- +++ b/BonDriver_DVB_UseServiceID.conf Tue Jul 7 13:36:35 2015
- @@ -11,6 +11,10 @@
- ; 更に、TYPEDを指定するとISO/IEC 13818-6 type DのPIDストリーム(データ放送で使用されている)が削除される
- ; DEL=CAT,EIT,SDTT,BIT,CDT,TYPEDの様に指定する(なお、ECMを削除するとスクランブルが解除できなくなるので注意)
- #DEL=TYPED
- +;#B25=1
- +;#STRIP=1
- +;#EMM=1
- +;#MULTI2ROUND=4
- ; 名称, BonDriverとしてのチャンネル番号, 周波数テーブル番号, TSID, 対象サービスID
- ; 記述はタブ区切り
- #ISDB_S
- --- a/BonDriver_LinuxPT.conf Mon Jul 6 03:22:14 2015
- +++ b/BonDriver_LinuxPT.conf Tue Jul 7 13:36:35 2015
- @@ -1,6 +1,10 @@
- #DEVICE=/dev/pt3video0
- #USELNB=0
- #USESERVICEID=0
- +;#B25=1
- +;#STRIP=1
- +;#EMM=1
- +;#MULTI2ROUND=4
- ; 名称, BonDriverとしてのチャンネル番号, 周波数テーブル番号, スロット番号/加算する周波数
- ; 記述はタブ区切り
- #ISDB_S
- --- a/BonDriver_LinuxPT.cpp Mon Jul 6 03:22:14 2015
- +++ b/BonDriver_LinuxPT.cpp Tue Jul 7 13:45:05 2015
- @@ -1,5 +1,8 @@
- #include "BonDriver_LinuxPT.h"
- #include "plex.cpp"
- +#ifdef HAVE_LIBARIB25
- +#include "B25Decoder.h"
- +#endif
- namespace BonDriver_LinuxPT {
- @@ -13,6 +16,10 @@
- static DWORD g_Crc32Table[256];
- static BOOL g_ModPMT;
- static DWORD g_dwDelFlag;
- +#ifdef HAVE_LIBARIB25
- +static int g_b25_enable = 0;
- +static B25Decoder g_b25;
- +#endif
- static int Convert(char *src, char *dst, size_t dstsize)
- {
- @@ -96,6 +103,17 @@
- BOOL bsFlag = FALSE;
- BOOL bmFlag = FALSE;
- BOOL bdelFlag = FALSE;
- +#ifdef HAVE_LIBARIB25
- + struct {
- + unsigned b25:1;
- + unsigned strip:1;
- + unsigned emm:1;
- + unsigned multi2round:1;
- + } b25flags = {0};
- + B25Decoder::strip = 0;
- + B25Decoder::emm_proc = 0;
- + B25Decoder::multi2_round = 4;
- +#endif
- while (::fgets(buf, sizeof(buf), fp))
- {
- if (buf[0] == ';')
- @@ -206,6 +224,28 @@
- delete[] pp;
- bdelFlag = TRUE;
- }
- +#ifdef HAVE_LIBARIB25
- + else if (!b25flags.b25 && IsTagMatch(buf, "#B25", &p))
- + {
- + g_b25_enable = ::atoi(p);
- + b25flags.b25 = 1;
- + }
- + else if (!b25flags.strip && IsTagMatch(buf, "#STRIP", &p))
- + {
- + B25Decoder::strip = ::atoi(p);
- + b25flags.strip = 1;
- + }
- + else if (!b25flags.emm && IsTagMatch(buf, "#EMM", &p))
- + {
- + B25Decoder::emm_proc = ::atoi(p);
- + b25flags.emm = 1;
- + }
- + else if (!b25flags.multi2round && IsTagMatch(buf, "#MULTI2ROUND", &p))
- + {
- + B25Decoder::multi2_round = ::atoi(p);
- + b25flags.multi2round = 1;
- + }
- +#endif
- else
- {
- int n = 0;
- @@ -363,6 +403,10 @@
- if (g_UseLNB && (g_Type == 0) && (::ioctl(m_fd, LNB_ENABLE, 2) < 0))
- ::fprintf(stderr, "LNB ON failed: %s\n", g_Device);
- m_bTuner = TRUE;
- +#ifdef HAVE_LIBARIB25
- + if (g_b25_enable)
- + g_b25.init();
- +#endif
- return TRUE;
- }
- @@ -382,6 +426,9 @@
- ::close(m_fd);
- m_bTuner = FALSE;
- m_fd = -1;
- +#ifdef HAVE_LIBARIB25
- + g_b25.release();
- +#endif
- }
- }
- @@ -446,6 +493,10 @@
- *pdwSize = m_LastBuf->dwSize;
- *pdwRemain = (DWORD)m_fifoTS.Size();
- b = TRUE;
- +#ifdef HAVE_LIBARIB25
- + if (g_b25.isValid())
- + g_b25.decode(ppDst, pdwSize);
- +#endif
- }
- else
- {
- --- a/BonDriver_LinuxPT_UseServiceID.conf Mon Jul 6 03:22:14 2015
- +++ b/BonDriver_LinuxPT_UseServiceID.conf Tue Jul 7 13:36:35 2015
- @@ -8,6 +8,10 @@
- ; 更に、TYPEDを指定するとISO/IEC 13818-6 type DのPIDストリーム(データ放送で使用されている)が削除される
- ; DEL=CAT,EIT,SDTT,BIT,CDT,TYPEDの様に指定する(なお、ECMを削除するとスクランブルが解除できなくなるので注意)
- #DEL=TYPED
- +;#B25=1
- +;#STRIP=1
- +;#EMM=1
- +;#MULTI2ROUND=4
- ; 名称, BonDriverとしてのチャンネル番号, 周波数テーブル番号, スロット番号/加算する周波数, 対象サービスID
- ; 記述はタブ区切り
- #ISDB_S
- --- a/BonDriverProxy.cpp Mon Jul 6 03:22:14 2015
- +++ b/BonDriverProxy.cpp Tue Jul 7 13:36:35 2015
- @@ -1,5 +1,13 @@
- #include "BonDriverProxy.h"
- +#ifdef HAVE_LIBARIB25
- +#include <getopt.h>
- +static int g_b25_enable = 0;
- +int B25Decoder::strip = 0;
- +int B25Decoder::emm_proc = 0;
- +int B25Decoder::multi2_round = 4;
- +#endif
- +
- namespace BonDriverProxy {
- #define STRICT_LOCK
- @@ -29,6 +37,40 @@
- static int Init(int ac, char *av[])
- {
- +#ifdef HAVE_LIBARIB25
- + static const struct option options[] = {
- + {"b25", no_argument, &g_b25_enable, 1},
- + {"strip", no_argument, &B25Decoder::strip, 1},
- + {"EMM", no_argument, &B25Decoder::emm_proc, 1},
- + {"round", required_argument, NULL, 'r'},
- + {0}
- + };
- +
- + int opt;
- +
- + while ((opt = getopt_long(ac, av, "", options, NULL)) != -1)
- + {
- + switch (opt)
- + {
- + case 0: // long options
- + break;
- + case 'r': // multi2 round
- + B25Decoder::multi2_round = strtoul(optarg, NULL, 10);
- + break;
- + default:
- + return -1;
- + }
- + }
- +
- + if (optind > 1)
- + {
- + int i = optind, j = 1;
- + while (i < ac)
- + av[j++] = av[i++];
- + ac -= optind - 1;
- + }
- +#endif
- +
- if (ac < 3)
- return -1;
- ::strncpy(g_Host, av[1], sizeof(g_Host) - 1);
- @@ -558,6 +600,10 @@
- m_pTsReaderArg = new stTsReaderArg();
- m_pTsReaderArg->TsReceiversList.push_back(this);
- m_pTsReaderArg->pIBon = m_pIBon;
- +#ifdef HAVE_LIBARIB25
- + if (g_b25_enable)
- + m_pTsReaderArg->b25.init();
- +#endif
- if (::pthread_create(&m_hTsRead, NULL, cProxyServer::TsReader, m_pTsReaderArg))
- {
- m_hTsRead = 0;
- @@ -834,6 +880,10 @@
- }
- if (pIBon->GetTsStream(&pBuf, &dwSize, &dwRemain) && (dwSize != 0))
- {
- +#ifdef HAVE_LIBARIB25
- + if (pArg->b25.isValid())
- + pArg->b25.decode(&pBuf, &dwSize);
- +#endif
- if ((pos + dwSize) < TsPacketBufSize)
- {
- ::memcpy(&pTsBuf[pos], pBuf, dwSize);
- @@ -1086,7 +1136,12 @@
- {
- if (BonDriverProxy::Init(argc, argv) != 0)
- {
- +#ifdef HAVE_LIBARIB25
- + fprintf(stderr, "usage: %s [--b25 [--round N] [--strip] [--EMM]] "
- + "address port (packet_fifo_size tspacket_bufsize)\ne.g. $ %s 192.168.0.100 1192\n", argv[0],argv[0]);
- +#else
- fprintf(stderr, "usage: %s address port (packet_fifo_size tspacket_bufsize)\ne.g. $ %s 192.168.0.100 1192\n", argv[0],argv[0]);
- +#endif
- return 0;
- }
- --- a/BonDriverProxy.h Mon Jul 6 03:22:14 2015
- +++ b/BonDriverProxy.h Tue Jul 7 13:36:35 2015
- @@ -23,6 +23,9 @@
- #include <queue>
- #include "typedef.h"
- #include "IBonDriver3.h"
- +#ifdef HAVE_LIBARIB25
- +#include "B25Decoder.h"
- +#endif
- #if __APPLE__
- #undef daemon
- @@ -66,6 +69,9 @@
- DWORD pos;
- std::list<cProxyServer *> TsReceiversList;
- cCriticalSection TsLock;
- +#ifdef HAVE_LIBARIB25
- + B25Decoder b25;
- +#endif
- stTsReaderArg()
- {
- StopTsRead = FALSE;
- --- a/BonDriverProxyEx.cpp Mon Jul 6 03:22:14 2015
- +++ b/BonDriverProxyEx.cpp Tue Jul 7 13:36:35 2015
- @@ -1,5 +1,13 @@
- #include "BonDriverProxyEx.h"
- +#ifdef HAVE_LIBARIB25
- +#include <getopt.h>
- +static int g_b25_enable = 0;
- +int B25Decoder::strip = 0;
- +int B25Decoder::emm_proc = 0;
- +int B25Decoder::multi2_round = 4;
- +#endif
- +
- namespace BonDriverProxyEx {
- #ifdef DEBUG
- @@ -53,6 +61,40 @@
- static int Init(int ac, char *av[])
- {
- +#ifdef HAVE_LIBARIB25
- + static const struct option options[] = {
- + {"b25", no_argument, &g_b25_enable, 1},
- + {"strip", no_argument, &B25Decoder::strip, 1},
- + {"EMM", no_argument, &B25Decoder::emm_proc, 1},
- + {"round", required_argument, NULL, 'r'},
- + {0}
- + };
- +
- + int opt;
- +
- + while ((opt = getopt_long(ac, av, "", options, NULL)) != -1)
- + {
- + switch (opt)
- + {
- + case 0: // long options
- + break;
- + case 'r': // multi2 round
- + B25Decoder::multi2_round = strtoul(optarg, NULL, 10);
- + break;
- + default:
- + return -1;
- + }
- + }
- +
- + if (optind > 1)
- + {
- + int i = optind, j = 1;
- + while (i < ac)
- + av[j++] = av[i++];
- + ac -= optind - 1;
- + }
- +#endif
- +
- if (ac < 3)
- return -1;
- ::strncpy(g_Host, av[1], sizeof(g_Host) - 1);
- @@ -740,6 +782,10 @@
- m_pTsReaderArg = new stTsReaderArg();
- m_pTsReaderArg->TsReceiversList.push_back(this);
- m_pTsReaderArg->pIBon = m_pIBon;
- +#ifdef HAVE_LIBARIB25
- + if (g_b25_enable)
- + m_pTsReaderArg->b25.init();
- +#endif
- if (::pthread_create(&m_hTsRead, NULL, cProxyServerEx::TsReader, m_pTsReaderArg))
- {
- m_hTsRead = 0;
- @@ -1042,6 +1088,10 @@
- }
- if (pIBon->GetTsStream(&pBuf, &dwSize, &dwRemain) && (dwSize != 0))
- {
- +#ifdef HAVE_LIBARIB25
- + if (pArg->b25.isValid())
- + pArg->b25.decode(&pBuf, &dwSize);
- +#endif
- if ((pos + dwSize) < TsPacketBufSize)
- {
- ::memcpy(&pTsBuf[pos], pBuf, dwSize);
- @@ -1489,7 +1539,12 @@
- {
- if (BonDriverProxyEx::Init(argc, argv) != 0)
- {
- +#ifdef HAVE_LIBARIB25
- + fprintf(stderr, "usage: %s [--b25 [--round N] [--strip] [--EMM]] "
- + "address port (opentuner_return_delay_time packet_fifo_size tspacket_bufsize)\ne.g. $ %s 192.168.0.100 1192\n", argv[0],argv[0]);
- +#else
- 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]);
- +#endif
- return 0;
- }
- --- a/BonDriverProxyEx.h Mon Jul 6 03:22:14 2015
- +++ b/BonDriverProxyEx.h Tue Jul 7 13:36:35 2015
- @@ -26,6 +26,9 @@
- #include <map>
- #include "typedef.h"
- #include "IBonDriver3.h"
- +#ifdef HAVE_LIBARIB25
- +#include "B25Decoder.h"
- +#endif
- #if __APPLE__
- #undef daemon
- @@ -73,6 +76,9 @@
- DWORD pos;
- std::list<cProxyServerEx *> TsReceiversList;
- cCriticalSection TsLock;
- +#ifdef HAVE_LIBARIB25
- + B25Decoder b25;
- +#endif
- stTsReaderArg()
- {
- StopTsRead = FALSE;
- --- a/Makefile Mon Jul 6 03:22:14 2015
- +++ b/Makefile Tue Jul 7 13:36:35 2015
- @@ -3,8 +3,9 @@
- include Makefile.in
- SRCDIR = .
- +CPPFLAGS += -DHAVE_LIBARIB25
- LDFLAGS =
- -LIBS = -ldl
- +LIBS = -ldl -larib25
- SRCS = BonDriverProxy.cpp BonDriverProxyEx.cpp sample.cpp
- SOSRCS = BonDriver_Proxy.cpp
- ifneq ($(UNAME), Darwin)
- --- a/sample.cpp Mon Jul 6 03:22:14 2015
- +++ b/sample.cpp Tue Jul 7 13:36:35 2015
- @@ -1,5 +1,5 @@
- /*
- -$ g++ -O2 -Wall -rdynamic -o sample sample.cpp -ldl
- +$ g++ -O2 -Wall -rdynamic -o sample sample.cpp -ldl -larib25 -DHAVE_LIBARIB25
- */
- #define _FILE_OFFSET_BITS 64
- #include <unistd.h>
- @@ -15,6 +15,14 @@
- #include "typedef.h"
- #include "IBonDriver2.h"
- +#ifdef HAVE_LIBARIB25
- +#include <getopt.h>
- +#include "B25Decoder.h"
- +int B25Decoder::strip = 0;
- +int B25Decoder::emm_proc = 0;
- +int B25Decoder::multi2_round = 4;
- +#endif
- +
- static volatile BOOL bStop = FALSE;
- static void handler(int sig)
- {
- @@ -23,7 +31,12 @@
- void usage(char *p)
- {
- +#ifdef HAVE_LIBARIB25
- + fprintf(stderr, "usage: %s [--b25 [--round N] [--strip] [--EMM]] "
- + "[-b bondriver] [-s space_no] [-c channel_no] ( [-t sec] [-o filename] )\n", p);
- +#else
- fprintf(stderr, "usage: %s [-b bondriver] [-s space_no] [-c channel_no] ( [-t sec] [-o filename] )\n", p);
- +#endif
- exit(0);
- }
- @@ -32,16 +45,38 @@
- int opt, bfind, sfind, cfind, ofind, wfd;
- char *bon, *output;
- DWORD sec, dwSpace, dwChannel;
- +#ifdef HAVE_LIBARIB25
- + B25Decoder b25;
- + int b25_enable = 0;
- +#endif
- // パラメータ処理
- sec = 0xffffffff;
- bon = output = NULL;
- bfind = sfind = cfind = ofind = 0;
- dwSpace = dwChannel = 0;
- +#ifdef HAVE_LIBARIB25
- + static const struct option options[] = {
- + {"b25", no_argument, &b25_enable, 1},
- + {"strip", no_argument, &B25Decoder::strip, 1},
- + {"EMM", no_argument, &B25Decoder::emm_proc, 1},
- + {"round", required_argument, NULL, 'r'},
- + {0}
- + };
- + while ((opt = getopt_long(argc, argv, "b:s:c:t:o:", options, NULL)) != -1)
- +#else
- while ((opt = getopt(argc, argv, "b:s:c:t:o:")) != -1)
- +#endif
- {
- switch (opt)
- {
- +#ifdef HAVE_LIBARIB25
- + case 0: // long options
- + break;
- + case 'r': // multi2 round
- + b25.multi2_round = strtoul(optarg, NULL, 10);
- + break;
- +#endif
- case 'b': // BonDriver指定
- bon = optarg;
- bfind = 1;
- @@ -127,6 +162,10 @@
- close(wfd);
- return -3;
- }
- +#ifdef HAVE_LIBARIB25
- + if (b25_enable)
- + b25.init();
- +#endif
- // 指定チャンネルにセット
- pIBon2->SetChannel(dwSpace, dwChannel);
- @@ -158,6 +197,10 @@
- {
- // この時点でpBufに長さdwSize分のTSストリームを取得した状態なので、それを書き出し
- // (もしバッファリングやデスクランブルやTS分離処理を入れるならこの辺で)
- +#ifdef HAVE_LIBARIB25
- + if (b25.isValid())
- + b25.decode(&pBuf, &dwSize);
- +#endif
- int len, left = (int)dwSize;
- do
- {
- @@ -178,6 +221,11 @@
- // チューナクローズ
- pIBon->CloseTuner();
- +#ifdef HAVE_LIBARIB25
- + if (b25_enable)
- + b25.release();
- +#endif
- +
- // 現在のBonDriver_LinuxPT/DVB/Proxyの実装では無意味なのに気付いたので削除(;´Д`)失礼しました
- #if 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement