Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #b25 patch for version 1.1.4.11
- --- BonDriverProxyEx/BonDriverProxyEx.cpp Wed Jan 28 12:51:38 2015
- +++ BonDriverProxyEx/BonDriverProxyEx.cpp Thu Jan 29 09:04:18 2015
- @@ -6,6 +6,8 @@
- #define DETAILLOG2 1
- #endif
- +static int g_b25_enable = false;
- +
- static int Init(HMODULE hModule)
- {
- char szIniPath[MAX_PATH + 16] = { '\0' };
- @@ -25,6 +27,7 @@
- GetPrivateProfileStringA("OPTION", "PORT", "1192", g_Port, sizeof(g_Port), szIniPath);
- g_OpenTunerRetDelay = GetPrivateProfileIntA("OPTION", "OPENTUNER_RETURN_DELAY", 0, szIniPath);
- g_SandBoxedRelease = GetPrivateProfileIntA("OPTION", "SANDBOXED_RELEASE", 0, szIniPath);
- + g_b25_enable = GetPrivateProfileIntA("OPTION", "B25_DECODE", 0, szIniPath);
- g_PacketFifoSize = GetPrivateProfileIntA("SYSTEM", "PACKET_FIFO_SIZE", 64, szIniPath);
- g_TsPacketBufSize = GetPrivateProfileIntA("SYSTEM", "TSPACKET_BUFSIZE", (188 * 1024), szIniPath);
- @@ -124,6 +127,7 @@
- m_pStopTsRead = NULL;
- m_pTsLock = NULL;
- m_ppos = NULL;
- + m_b25 = NULL;
- m_dwSpace = m_dwChannel = 0x7fffffff; // INT_MAX
- m_pDriversMapKey = NULL;
- m_iDriverNo = -1;
- @@ -157,6 +161,7 @@
- delete m_pStopTsRead;
- delete m_pTsLock;
- delete m_ppos;
- + delete m_b25;
- }
- Release();
- @@ -376,6 +381,7 @@
- delete m_pStopTsRead;
- delete m_pTsLock;
- delete m_ppos;
- + delete m_b25;
- }
- CloseTuner();
- }
- @@ -389,6 +395,7 @@
- m_pStopTsRead = NULL;
- m_pTsLock = NULL;
- m_ppos = NULL;
- + m_b25 = NULL;
- m_bTunerOpen = FALSE;
- break;
- }
- @@ -521,6 +528,8 @@
- //m_pTsLock = NULL;
- delete m_ppos;
- //m_ppos = NULL;
- + delete m_b25;
- + //m_b25 = NULL;
- }
- CloseTuner();
- //m_bTunerOpen = FALSE;
- @@ -560,6 +569,7 @@
- m_pStopTsRead = (*it)->m_pStopTsRead;
- m_pTsLock = (*it)->m_pTsLock;
- m_ppos = (*it)->m_ppos;
- + m_b25 = (*it)->m_b25;
- if (m_hTsRead)
- {
- m_pTsLock->Enter();
- @@ -666,12 +676,18 @@
- m_pStopTsRead = new BOOL(FALSE);
- m_pTsLock = new cCriticalSection();
- m_ppos = new DWORD(0);
- - LPVOID *ppv = new LPVOID[5];
- + if (g_b25_enable)
- + {
- + m_b25 = new B25Decoder();
- + m_b25->init();
- + }
- + LPVOID *ppv = new LPVOID[6];
- ppv[0] = m_pIBon;
- ppv[1] = m_pTsReceiversList;
- ppv[2] = m_pStopTsRead;
- ppv[3] = m_pTsLock;
- ppv[4] = m_ppos;
- + ppv[5] = m_b25;
- m_hTsRead = ::CreateThread(NULL, 0, cProxyServerEx::TsReader, ppv, 0, NULL);
- if (m_hTsRead == NULL)
- {
- @@ -684,6 +700,8 @@
- m_pTsLock = NULL;
- delete m_ppos;
- m_ppos = NULL;
- + delete m_b25;
- + m_b25 = NULL;
- m_Error.Set();
- }
- }
- @@ -717,6 +735,7 @@
- (*it)->m_pStopTsRead = m_pStopTsRead;
- (*it)->m_pTsLock = m_pTsLock;
- (*it)->m_ppos = m_ppos;
- + (*it)->m_b25 = m_b25;
- if (m_hTsRead)
- {
- m_pTsLock->Enter();
- @@ -966,6 +985,7 @@
- volatile BOOL &StopTsRead = *(static_cast<BOOL *>(ppv[2]));
- cCriticalSection &TsLock = *(static_cast<cCriticalSection *>(ppv[3]));
- DWORD &pos = *(static_cast<DWORD *>(ppv[4]));
- + B25Decoder *b25 = static_cast<B25Decoder *>(ppv[5]);
- delete[] ppv;
- DWORD dwSize, dwRemain, now, before = 0;
- float fSignalLevel = 0;
- @@ -991,6 +1011,17 @@
- LOCK(TsLock);
- if (pIBon->GetTsStream(&pBuf, &dwSize, &dwRemain) && (dwSize != 0))
- {
- + if (b25)
- + {
- + ARIB_STD_B25_BUFFER buf;
- + buf.data = pBuf;
- + buf.size = dwSize;
- + b25->decode(&buf);
- + if (buf.size == 0)
- + goto next;
- + pBuf = buf.data;
- + dwSize = buf.size;
- + }
- if ((pos + dwSize) < TsPacketBufSize)
- {
- ::memcpy(&pTsBuf[pos], pBuf, dwSize);
- @@ -1044,6 +1075,7 @@
- }
- }
- }
- + next:
- if (dwRemain == 0)
- ::Sleep(WAIT_TIME);
- }
- @@ -1084,6 +1116,8 @@
- m_pTsLock = NULL;
- delete m_ppos;
- m_ppos = NULL;
- + delete m_b25;
- + m_b25 = NULL;
- }
- }
- @@ -1144,6 +1178,7 @@
- m_pStopTsRead = NULL;
- m_pTsLock = NULL;
- m_ppos = NULL;
- + m_b25 = NULL;
- return TRUE;
- }
- next:
- @@ -1265,6 +1300,7 @@
- m_pStopTsRead = pCandidate->m_pStopTsRead;
- m_pTsLock = pCandidate->m_pTsLock;
- m_ppos = pCandidate->m_ppos;
- + m_b25 = pCandidate->m_b25;
- }
- // 選択したインスタンスが既にTSストリーム配信中なら、その配信対象リストに自身を追加
- diff -u -d -r -N BonDriverProxyEx/BonDriverProxyEx.h BonDriverProxyEx/BonDriverProxyEx.h
- --- BonDriverProxyEx/BonDriverProxyEx.h Wed Jan 28 12:51:38 2015
- +++ BonDriverProxyEx/BonDriverProxyEx.h Thu Jan 29 09:04:32 2015
- @@ -9,6 +9,7 @@
- #include <map>
- #include "Common.h"
- #include "IBonDriver3.h"
- +#include "decoder.h"
- #if _DEBUG
- #define _CRTDBG_MAP_ALLOC
- @@ -53,6 +54,7 @@
- BOOL * volatile m_pStopTsRead;
- cCriticalSection *m_pTsLock;
- DWORD *m_ppos;
- + class B25Decoder *m_b25;
- BOOL m_bChannelLock;
- #if _DEBUG
- public:
- --- BonDriverProxyEx/BonDriverProxyEx.vcxproj Wed Jan 28 12:51:38 2015
- +++ BonDriverProxyEx/BonDriverProxyEx.vcxproj Thu Jan 29 09:06:30 2015
- @@ -91,7 +91,7 @@
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- - <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- + <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;winscard.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- @@ -107,7 +107,7 @@
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- - <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- + <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;winscard.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- @@ -128,7 +128,7 @@
- <GenerateDebugInformation>false</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- - <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- + <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;winscard.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- @@ -149,11 +149,16 @@
- <GenerateDebugInformation>false</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- - <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- + <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;winscard.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- + <ClCompile Include="arib25\arib_std_b25.c" />
- + <ClCompile Include="arib25\b_cas_card.c" />
- + <ClCompile Include="arib25\multi2.c" />
- + <ClCompile Include="arib25\ts_section_parser.c" />
- <ClCompile Include="BonDriverProxyEx.cpp" />
- + <ClCompile Include="decoder.cpp" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="BonDriverProxyEx.rc" />
- @@ -164,7 +169,18 @@
- <ClInclude Include="..\inc\IBonDriver.h" />
- <ClInclude Include="..\inc\IBonDriver2.h" />
- <ClInclude Include="..\inc\IBonDriver3.h" />
- + <ClInclude Include="arib25\arib_std_b25.h" />
- + <ClInclude Include="arib25\arib_std_b25_error_code.h" />
- + <ClInclude Include="arib25\b_cas_card.h" />
- + <ClInclude Include="arib25\b_cas_card_error_code.h" />
- + <ClInclude Include="arib25\multi2.h" />
- + <ClInclude Include="arib25\multi2_error_code.h" />
- + <ClInclude Include="arib25\portable.h" />
- + <ClInclude Include="arib25\ts_common_types.h" />
- + <ClInclude Include="arib25\ts_section_parser.h" />
- + <ClInclude Include="arib25\ts_section_parser_error_code.h" />
- <ClInclude Include="BonDriverProxyEx.h" />
- + <ClInclude Include="decoder.h" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- --- BonDriverProxyEx/decoder.cpp Thu Jan 1 00:00:00 1970
- +++ BonDriverProxyEx/decoder.cpp Thu Jan 29 23:14:12 2015
- @@ -0,0 +1,127 @@
- +// -*- coding: utf-8 -*-
- +#include <cstddef>
- +#include <cassert>
- +#include "decoder.h"
- +
- +int B25Decoder::multi2_round = 4;
- +int B25Decoder::strip = 0;
- +int B25Decoder::emm_proc = 0;
- +
- +B25Decoder::B25Decoder()
- + : _bcas(NULL)
- + , _b25(NULL)
- + , _init_called(false)
- + , _pass_through_bytes(0)
- +{
- +}
- +
- +B25Decoder::~B25Decoder()
- +{
- + release();
- +}
- +
- +int B25Decoder::init()
- +{
- + _init_called = true;
- +
- + int rc;
- +
- + assert(_bcas == NULL);
- + assert(_b25 == NULL);
- +
- + _bcas = create_b_cas_card(), rc = 0;
- + if (!_bcas) goto err;
- +
- + rc = _bcas->init(_bcas);
- + if (rc < 0) goto err;
- +
- + _b25 = create_arib_std_b25(), rc = 0;
- + if (!_b25) goto err;
- +
- + rc = _b25->set_b_cas_card(_b25, _bcas);
- + if (rc < 0) goto err;
- +
- + rc = _b25->set_strip(_b25, strip);
- + if (rc < 0) goto err;
- +
- + rc = _b25->set_emm_proc(_b25, emm_proc);
- + if (rc < 0) goto err;
- +
- + rc = _b25->set_multi2_round(_b25, multi2_round);
- + if (rc < 0) goto err;
- +
- + return rc;
- +
- +err:
- +
- + release();
- +
- + return rc;
- +}
- +
- +void B25Decoder::release()
- +{
- + if (_b25)
- + {
- + _b25->release(_b25);
- + _b25 = NULL;
- + }
- +
- + if (_bcas)
- + {
- + _bcas->release(_bcas);
- + _bcas = NULL;
- + }
- +}
- +
- +int B25Decoder::put(ARIB_STD_B25_BUFFER *buf)
- +{
- + if (isPassThrough())
- + {
- + _pass_through_buf = *buf;
- +
- + if (!_init_called)
- + return 0;
- +
- + // 一定間隔でinitを試みる
- +
- + _pass_through_bytes += buf->size;
- + if (_pass_through_bytes > 1024*1024*8)
- + {
- + if (init() >= 0)
- + goto ready;
- + _pass_through_bytes = 0;
- + }
- +
- + return 0;
- + }
- +
- +ready:
- +
- + const int rc = _b25->put(_b25, buf);
- + if (rc < 0)
- + {
- + // 乱暴だけどエラーコードに関係なくB-CASカードが抜かれたと判断。
- + // 以降、パススルー動作。
- + // ※カードを抜くとARIB_STD_B25_ERROR_ECM_PROC_FAILURE(-9)
- +
- + release();
- + _pass_through_buf = *buf;
- + _pass_through_bytes = buf->size;
- + }
- +
- + return rc;
- +}
- +
- +int B25Decoder::get(ARIB_STD_B25_BUFFER *buf)
- +{
- + if (isPassThrough())
- + {
- + *buf = _pass_through_buf;
- + return 0;
- + }
- +
- + const int rc = _b25->get(_b25, buf);
- +
- + return rc;
- +}
- diff -u -d -r -N BonDriverProxyEx/decoder.h BonDriverProxyEx/decoder.h
- --- BonDriverProxyEx/decoder.h Thu Jan 1 00:00:00 1970
- +++ BonDriverProxyEx/decoder.h Thu Jan 29 23:14:28 2015
- @@ -0,0 +1,48 @@
- +// -*- coding: utf-8 -*-
- +#pragma once
- +
- +#include "arib25/arib_std_b25.h"
- +
- +class B25Decoder
- +{
- + B_CAS_CARD *_bcas;
- + ARIB_STD_B25 *_b25;
- +
- + bool _init_called;
- + ARIB_STD_B25_BUFFER _pass_through_buf;
- + uint32_t _pass_through_bytes;
- +
- +public:
- + B25Decoder();
- +
- + ~B25Decoder();
- +
- + int init();
- +
- + void release();
- +
- + int put(ARIB_STD_B25_BUFFER *buf);
- +
- + int get(ARIB_STD_B25_BUFFER *buf);
- +
- + void decode(ARIB_STD_B25_BUFFER *buf)
- + {
- + (void) put(buf); // putは常に成功する
- + (void) get(buf); // getもlibarib25を読む限り常に成功する
- + }
- +
- + bool isValid() const { return _b25 != 0; }
- +
- + bool isPassThrough() const { return _b25 == 0; }
- +
- + // initialize parameter
- +
- + static int multi2_round;
- + static int strip;
- + static int emm_proc;
- +
- +private:
- +
- + B25Decoder(const B25Decoder &); // undef
- + B25Decoder &operator=(const B25Decoder &); // undef
- +};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement