Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/arib_std_b25.h b/EDCB-work-plus-s/BonCtrl/arib_std_b25.h
- --- a/EDCB-work-plus-s/BonCtrl/arib_std_b25.h 1970-01-01 09:00:00.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/arib_std_b25.h 2015-02-13 00:07:58.000000000 +0900
- @@ -0,0 +1,49 @@
- +#ifndef ARIB_STD_B25_H
- +#define ARIB_STD_B25_H
- +
- +#include "portable.h"
- +#include "b_cas_card.h"
- +
- +typedef struct {
- + uint8_t *data;
- + int32_t size;
- +} ARIB_STD_B25_BUFFER;
- +
- +typedef struct {
- +
- + int32_t program_number; /* channel */
- +
- + int32_t ecm_unpurchased_count;
- + int32_t last_ecm_error_code;
- +
- + int32_t padding;
- +
- + int64_t total_packet_count;
- + int64_t undecrypted_packet_count;
- +
- +} ARIB_STD_B25_PROGRAM_INFO;
- +
- +typedef struct {
- +
- + void *private_data;
- +
- + void (* release)(void *std_b25);
- +
- + int (* set_multi2_round)(void *std_b25, int32_t round);
- + int (* set_strip)(void *std_b25, int32_t strip);
- + int (* set_emm_proc)(void *std_b25, int32_t on);
- +
- + int (* set_b_cas_card)(void *std_b25, B_CAS_CARD *bcas);
- +
- + int (* reset)(void *std_b25);
- + int (* flush)(void *std_b25);
- +
- + int (* put)(void *std_b25, ARIB_STD_B25_BUFFER *buf);
- + int (* get)(void *std_b25, ARIB_STD_B25_BUFFER *buf);
- +
- + int (* get_program_count)(void *std_b25);
- + int (* get_program_info)(void *std_b25, ARIB_STD_B25_PROGRAM_INFO *info, int32_t idx);
- +
- +} ARIB_STD_B25;
- +
- +#endif /* ARIB_STD_B25_H */
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/b_cas_card.h b/EDCB-work-plus-s/BonCtrl/b_cas_card.h
- --- a/EDCB-work-plus-s/BonCtrl/b_cas_card.h 1970-01-01 09:00:00.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/b_cas_card.h 2015-02-13 00:08:58.000000000 +0900
- @@ -0,0 +1,65 @@
- +#ifndef B_CAS_CARD_H
- +#define B_CAS_CARD_H
- +
- +#include "portable.h"
- +
- +typedef struct {
- + uint8_t system_key[32];
- + uint8_t init_cbc[8];
- + int64_t bcas_card_id;
- + int32_t card_status;
- + int32_t ca_system_id;
- +} B_CAS_INIT_STATUS;
- +
- +typedef struct {
- + int64_t *data;
- + int32_t count;
- +} B_CAS_ID;
- +
- +typedef struct {
- +
- + int32_t s_yy; /* start date : year */
- + int32_t s_mm; /* start date : month */
- + int32_t s_dd; /* start date : day */
- +
- + int32_t l_yy; /* limit date : year */
- + int32_t l_mm; /* limit date : month */
- + int32_t l_dd; /* limit date : day */
- +
- + int32_t hold_time; /* in hour unit */
- +
- + int32_t broadcaster_group_id;
- +
- + int32_t network_id;
- + int32_t transport_id;
- +
- +} B_CAS_PWR_ON_CTRL;
- +
- +typedef struct {
- + B_CAS_PWR_ON_CTRL *data;
- + int32_t count;
- +} B_CAS_PWR_ON_CTRL_INFO;
- +
- +typedef struct {
- + uint8_t scramble_key[16];
- + uint32_t return_code;
- +} B_CAS_ECM_RESULT;
- +
- +typedef struct {
- +
- + void *private_data;
- +
- + void (* release)(void *bcas);
- +
- + int (* init)(void *bcas);
- +
- + int (* get_init_status)(void *bcas, B_CAS_INIT_STATUS *stat);
- + int (* get_id)(void *bcas, B_CAS_ID *dst);
- + int (* get_pwr_on_ctrl)(void *bcas, B_CAS_PWR_ON_CTRL_INFO *dst);
- +
- + int (* proc_ecm)(void *bcas, B_CAS_ECM_RESULT *dst, uint8_t *src, int len);
- + int (* proc_emm)(void *bcas, uint8_t *src, int len);
- +
- +} B_CAS_CARD;
- +
- +#endif /* B_CAS_CARD_H */
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/BonCtrl.cpp b/EDCB-work-plus-s/BonCtrl/BonCtrl.cpp
- --- a/EDCB-work-plus-s/BonCtrl/BonCtrl.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/BonCtrl.cpp 2015-04-28 19:26:09.000000000 +0900
- @@ -546,10 +546,11 @@
- {
- CBlockLock lock(&this->buffLock);
- - for( size_t i=0; i<this->TSBuff.size(); i++ ){
- - SAFE_DELETE(this->TSBuff[i]);
- + while (!this->TSBuff.empty()){
- + TS_DATA *p = this->TSBuff.front();
- + this->TSBuff.pop_front();
- + delete p;
- }
- - this->TSBuff.clear();
- this->totalTSBuffSize = 0;
- }
- this->packetInit.ClearBuff();
- @@ -570,26 +571,27 @@
- DWORD remain = 0;
- try{
- if( sys->bonUtil.GetTsStream(&data,&size,&remain) == TRUE ){
- - if( size != 0 && data != NULL){
- + if( size != 0 ){
- TS_DATA* item = new TS_DATA;
- try{
- if( sys->packetInit.GetTSData(data, size, &item->data, &item->size) == TRUE ){
- CBlockLock lock(&sys->buffLock);
- - if( sys->totalTSBuffSize / 48128 > sys->tsBuffMaxCount ){
- - while( sys->TSBuff.empty() == false && sys->totalTSBuffSize / 48128 + 1000 > sys->tsBuffMaxCount ){
- - sys->totalTSBuffSize -= sys->TSBuff.back()->size;
- - SAFE_DELETE(sys->TSBuff.back());
- + if( sys->totalTSBuffSize / (188 * 256) > sys->tsBuffMaxCount ){
- + while (!sys->TSBuff.empty() && sys->totalTSBuffSize / (188 * 256) + 1000 > sys->tsBuffMaxCount){
- + TS_DATA *p = sys->TSBuff.back();
- sys->TSBuff.pop_back();
- + sys->totalTSBuffSize -= p->size;
- + delete p;
- }
- }
- + sys->totalTSBuffSize += item->size;
- sys->TSBuff.push_back(item);
- - sys->totalTSBuffSize += sys->TSBuff.back()->size;
- }else{
- delete item;
- }
- }catch(...){
- delete item;
- - _OutputDebugString(L"★★RecvThread Exception2");
- + OutputDebugString(L"★★RecvThread Exception2");
- }
- }else{
- Sleep(10);
- @@ -598,7 +600,7 @@
- Sleep(10);
- }
- }catch(...){
- - _OutputDebugString(L"★★RecvThread Exception1");
- + OutputDebugString(L"★★RecvThread Exception1");
- }
- }
- return 0;
- @@ -618,21 +620,21 @@
- TS_DATA* data = NULL;
- {
- CBlockLock lock(&sys->buffLock);
- - if( sys->TSBuff.empty() == false ){
- + if( !sys->TSBuff.empty() ){
- data = sys->TSBuff.front();
- + sys->TSBuff.pop_front();
- sys->totalTSBuffSize -= data->size;
- - sys->TSBuff.erase(sys->TSBuff.begin());
- }
- }
- try{
- if( data != NULL ){
- sys->tsOut.AddTSBuff(data);
- - SAFE_DELETE(data);
- + delete data;
- }else{
- Sleep(5);
- }
- }catch(...){
- - _OutputDebugString(L"★★AnalyzeThread Exception2");
- + OutputDebugString(L"★★AnalyzeThread Exception2");
- }
- }
- return 0;
- @@ -1365,7 +1367,7 @@
- DWORD wait = 0;
- DWORD startTime = 0;
- DWORD chkCount = 0;
- - DWORD chkWait = 8;
- + DWORD chkWait = 5;
- BOOL chkBS = FALSE;
- BOOL chkCS1 = FALSE;
- @@ -1405,7 +1407,7 @@
- startTime = GetTickCount();
- chkNext = FALSE;
- startCap = FALSE;
- - wait = 1000;
- + wait = 1 * 1000;
- if( sys->epgCapChList[chkCount].ONID == 4 ){
- chkBS = TRUE;
- }else if( sys->epgCapChList[chkCount].ONID == 6 ){
- @@ -1418,18 +1420,18 @@
- BOOL chChgErr = FALSE;
- if( sys->tsOut.IsChChanging(&chChgErr) == TRUE ){
- if( GetTickCount() - startTime > chkWait * 1000 ){
- - //チャンネル切り替えに10秒以上かかってるので無信号と判断
- + //チャンネル切り替えにchkWait秒以上かかってるので無信号と判断
- chkNext = TRUE;
- }
- }else{
- - if( GetTickCount() - startTime > (chkWait + timeOut * 60) * 1000 || chChgErr == TRUE){
- - //15分以上かかっているなら停止
- + if( GetTickCount() - startTime > (chkWait + (timeOut * 60)) * 1000 || chChgErr == TRUE){
- + //timeOut分以上かかっているなら停止
- sys->tsOut.StopSaveEPG(saveTimeOut);
- chkNext = TRUE;
- wait = 0;
- _OutputDebugString(L"++%d分でEPG取得完了せず or Ch変更でエラー", timeOut);
- }else if( GetTickCount() - startTime > chkWait * 1000 ){
- - //切り替えから15秒以上過ぎているので取得処理
- + //切り替えからchkWait秒以上過ぎているので取得処理
- if( startCap == FALSE ){
- //取得開始
- startCap = TRUE;
- @@ -1437,7 +1439,7 @@
- sys->GetEpgDataFilePath(sys->epgCapChList[chkCount].ONID, sys->epgCapChList[chkCount].TSID, epgDataPath, BSBasic, CS1Basic, CS2Basic);
- sys->tsOut.StartSaveEPG(epgDataPath);
- sys->tsOut.ClearSectionStatus();
- - wait = 60*1000;
- + wait = 30 * 1000;
- }else{
- //蓄積状態チェック
- BOOL leitFlag = sys->chUtil.IsPartial(sys->epgCapChList[chkCount].ONID, sys->epgCapChList[chkCount].TSID, sys->epgCapChList[chkCount].SID);
- @@ -1465,7 +1467,7 @@
- sys->tsOut.StopSaveEPG(TRUE);
- wait = 0;
- }else{
- - wait = 10*1000;
- + wait = 10 * 1000;
- }
- }
- }
- @@ -1728,7 +1730,7 @@
- break;
- }else{
- if( GetTickCount() - startTime > timeOut * 60 * 1000 ){
- - //15分以上かかっているなら停止
- + //timeOut分以上かかっているなら停止
- sys->tsOut.StopSaveEPG(saveTimeOut);
- CSendCtrlCmd cmd;
- cmd.SetConnectTimeOut(1000);
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/BonCtrlDef.h b/EDCB-work-plus-s/BonCtrl/BonCtrlDef.h
- --- a/EDCB-work-plus-s/BonCtrl/BonCtrlDef.h 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/BonCtrlDef.h 2015-02-14 22:18:02.000000000 +0900
- @@ -23,7 +23,7 @@
- size = 0;
- }
- ~_TS_DATA(void){
- - SAFE_DELETE_ARRAY(data);
- + delete[] data;
- }
- } TS_DATA;
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/BonCtrl.h b/EDCB-work-plus-s/BonCtrl/BonCtrl.h
- --- a/EDCB-work-plus-s/BonCtrl/BonCtrl.h 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/BonCtrl.h 2015-02-14 02:36:32.000000000 +0900
- @@ -474,7 +474,7 @@
- HANDLE lockEvent;
- CRITICAL_SECTION buffLock;
- - vector<TS_DATA*> TSBuff;
- + deque<TS_DATA*> TSBuff;
- DWORD totalTSBuffSize;
- HANDLE recvThread;
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/CATUtil.cpp b/EDCB-work-plus-s/BonCtrl/CATUtil.cpp
- --- a/EDCB-work-plus-s/BonCtrl/CATUtil.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/CATUtil.cpp 2015-04-29 04:01:57.000000000 +0900
- @@ -19,17 +19,16 @@
- return FALSE;
- }
- if( buffUtil.Add188TS(packet) == TRUE ){
- - BYTE* section = NULL;
- - DWORD sectionSize = 0;
- + BYTE* section;
- + DWORD sectionSize;
- while( buffUtil.GetSectionBuff( §ion, §ionSize ) == TRUE ){
- if( DecodeCAT(section, sectionSize) == FALSE ){
- return FALSE;
- }
- }
- - }else{
- - return FALSE;
- + return TRUE;
- }
- - return TRUE;
- + return FALSE;
- }
- BOOL CCATUtil::DecodeCAT(BYTE* data, DWORD dataSize)
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/CreatePATPacket.cpp b/EDCB-work-plus-s/BonCtrl/CreatePATPacket.cpp
- --- a/EDCB-work-plus-s/BonCtrl/CreatePATPacket.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/CreatePATPacket.cpp 2015-05-08 10:44:59.000000000 +0900
- @@ -140,7 +140,7 @@
- SAFE_DELETE_ARRAY(this->packet);
- //TSパケットを作成
- - int iPacketNum = (this->PSISize/184) + 1;
- + int iPacketNum = ((this->PSISize-1)/184) + 1;
- this->packetSize = 188*iPacketNum;
- this->packet = new BYTE[this->packetSize];
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/CreatePMTPacket.cpp b/EDCB-work-plus-s/BonCtrl/CreatePMTPacket.cpp
- --- a/EDCB-work-plus-s/BonCtrl/CreatePMTPacket.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/CreatePMTPacket.cpp 2015-05-01 05:36:56.000000000 +0900
- @@ -64,15 +64,20 @@
- if( packet == NULL ){
- return ERR_FALSE;
- }
- - DWORD ret = ERR_NEED_NEXT_PACKET;
- - ret = buffUtil.Add188TS(packet);
- - if( ret == TRUE ){
- - this->lastPmtPID = packet->PID;
- -
- - BYTE* section = NULL;
- - DWORD sectionSize = 0;
- - while( buffUtil.GetSectionBuff( §ion, §ionSize ) == TRUE ){
- - ret = DecodePMT(section, sectionSize);
- + DWORD ret = buffUtil.Add188TS(packet);
- + if (ret != TRUE){
- + if (ret == ERR_ADD_NEXT && this->createPacket != NULL){
- + return ERR_NO_CHAGE;
- + }
- + return ERR_FALSE;
- + }
- + this->lastPmtPID = packet->PID;
- + ret = ERR_FALSE;
- + BYTE* section;
- + DWORD sectionSize;
- + while( buffUtil.GetSectionBuff( §ion, §ionSize ) == TRUE ){
- + if (DecodePMT(section, sectionSize) != ERR_FALSE){
- + ret = NO_ERR;
- }
- }
- return ret;
- @@ -80,10 +85,11 @@
- DWORD CCreatePMTPacket::DecodePMT(BYTE* data, DWORD dataSize)
- {
- +/*
- if( data == NULL ){
- return ERR_FALSE;
- }
- -
- +*/
- if( dataSize < 7 ){
- return ERR_FALSE;
- }
- @@ -100,14 +106,12 @@
- WORD program_info_length;
- DWORD crc32;
- -
- - DWORD readSize = 0;
- //////////////////////////////////////////////////////
- //解析処理
- table_id = data[0];
- section_syntax_indicator = (data[1]&0x80)>>7;
- section_length = ((WORD)data[1]&0x0F)<<8 | data[2];
- - readSize+=3;
- + DWORD readSize = 3;
- if( section_syntax_indicator != 1 ){
- //固定値がおかしい
- @@ -237,7 +241,7 @@
- CreatePMT();
- - return TRUE;
- + return NO_ERR;
- }
- void CCreatePMTPacket::CreatePMT()
- @@ -315,6 +319,10 @@
- secondSize+=secondDescBuff[i]->descBuffSize;
- }
- break;
- + case 0x24:
- + //HEVC VIDEO
- + secondSize += secondDescBuff[i]->descBuffSize;
- + break;
- case 0x06:
- //字幕
- if( this->needCaption == TRUE ){
- @@ -334,17 +342,16 @@
- this->createPSISize += secondSize;
- this->createPSI = new BYTE[this->createPSISize];
- - ZeroMemory(this->createPSI, this->createPSISize);
- +// ZeroMemory(this->createPSI, this->createPSISize);
- + this->createPSI[0] = 0;
- //最初のDescriptorループまでコピー
- memcpy( this->createPSI + 1, this->firstDescBuff, this->firstDescBuffSize );
- //SectionLength
- - this->createPSI[2] = (BYTE)(((this->createPSISize-4)&0x00000F00)>>8);
- - this->createPSI[2] |= 0xB0;
- + this->createPSI[2] = (BYTE)(((this->createPSISize-4)&0x00000F00)>>8) | 0xB0;
- this->createPSI[3] = (BYTE)((this->createPSISize-4)&0x000000FF);
- //バージョン
- - this->createPSI[6] = this->createVer<<1;
- - this->createPSI[6] |= 0xC1;
- + this->createPSI[6] = (this->createVer<<1) | 0xC1;
- DWORD writeSize = this->firstDescBuffSize+1;
- for( size_t i=0; i<secondDescBuff.size(); i++ ){
- @@ -393,6 +400,12 @@
- this->needPIDList.insert(pair<WORD,WORD>(secondDescBuff[i]->elementary_PID, secondDescBuff[i]->stream_type));
- }
- break;
- + case 0x24:
- + //HEVC VIDEO
- + memcpy(this->createPSI + writeSize, secondDescBuff[i]->descBuff, secondDescBuff[i]->descBuffSize);
- + writeSize += secondDescBuff[i]->descBuffSize;
- + this->needPIDList.insert(pair<WORD, WORD>(secondDescBuff[i]->elementary_PID, secondDescBuff[i]->stream_type));
- + break;
- case 0x06:
- //字幕
- if( this->needCaption == TRUE ){
- @@ -429,7 +442,7 @@
- SAFE_DELETE_ARRAY(this->createPacket);
- //TSパケットを作成
- - int packetNum = (this->createPSISize/184) + 1;
- + int packetNum = ((this->createPSISize-1)/184) + 1;
- this->createPacketSize = 188*packetNum;
- this->createPacket = new BYTE[this->createPacketSize];
- @@ -491,15 +504,14 @@
- BOOL incrementFlag
- )
- {
- - if( incrementFlag == TRUE ){
- - IncrementCounter();
- - }
- - if( this->createPacket != NULL ){
- - *buff = this->createPacket;
- - *size = (DWORD)this->createPacketSize;
- - }else{
- + if (this->createPacket == NULL){
- return FALSE;
- }
- + if (incrementFlag == TRUE){
- + IncrementCounter();
- + }
- + *buff = this->createPacket;
- + *size = (DWORD)this->createPacketSize;
- return TRUE;
- }
- @@ -533,10 +545,6 @@
- void CCreatePMTPacket::IncrementCounter()
- {
- - if( this->createPacket == NULL ){
- - return ;
- - }
- -
- for( int i = 0 ; i<this->createPacketSize; i+=188 ){
- this->createPacket[i+3] = (BYTE)(this->createCounter | 0x10);
- this->createCounter++;
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/decoder.cpp b/EDCB-work-plus-s/BonCtrl/decoder.cpp
- --- a/EDCB-work-plus-s/BonCtrl/decoder.cpp 1970-01-01 09:00:00.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/decoder.cpp 2015-02-13 00:40:34.000000000 +0900
- @@ -0,0 +1,188 @@
- +// -*- coding: utf-8 -*-
- +#include "StdAfx.h"
- +#include "decoder.h"
- +#include <cassert>
- +
- +#ifdef NDEBUG
- +#define report(fmt, ...) ((void) 0)
- +#else
- +#include <windows.h>
- +#define report OutputDebugStringA
- +#endif
- +
- +int B25Decoder::multi2_round = 4;
- +int B25Decoder::strip = 1;
- +int B25Decoder::emm_proc;
- +
- +B25Decoder::B25Decoder(t_create_b_cas_card f_bcas, t_create_arib_std_b25 f_b25)
- + : f_create_b_cas_card(f_bcas)
- + , f_create_arib_std_b25(f_b25)
- + , _bcas(NULL)
- + , _b25(NULL)
- + , _init_called(false)
- + , _pass_through_bytes(0)
- +{
- +}
- +
- +B25Decoder::~B25Decoder()
- +{
- + release();
- +}
- +
- +int B25Decoder::init()
- +{
- + _init_called = true;
- +
- + report("B25Decoder::init() start\n");
- +
- + const char *fn;
- + int rc;
- +
- + assert(_bcas == NULL);
- + assert(_b25 == NULL);
- +
- + _bcas = f_create_b_cas_card(),
- + fn = "create_b_cas_card", rc = 0;
- + if (!_bcas) goto err;
- +
- + rc = _bcas->init(_bcas),
- + fn = "bcas::init";
- + if (rc < 0) goto err;
- +
- + _b25 = f_create_arib_std_b25(),
- + fn = "create_arib_std_b25", rc = 0;
- + if (!_b25) goto err;
- +
- + rc = _b25->set_b_cas_card(_b25, _bcas),
- + fn = "b25::set_b_cas_card";
- + if (rc < 0) goto err;
- +
- + rc = _b25->set_strip(_b25, strip),
- + fn = "b25::set_strip";
- + if (rc < 0) goto err;
- +
- + rc = _b25->set_emm_proc(_b25, emm_proc),
- + fn = "b25::set_emm_proc";
- + if (rc < 0) goto err;
- +
- + rc = _b25->set_multi2_round(_b25, multi2_round),
- + fn = "b25::set_multi2_round";
- + if (rc < 0) goto err;
- +
- + report("B25Decoder::init() ok\n");
- +
- + return rc;
- +
- +err:
- +
- + if (_pass_through_bytes == 0) // 外部からの呼び出し時に限る
- + {
- + char tmp[64];
- + sprintf_s(tmp, "%s failed. (%d)\n", fn, rc);
- + report(tmp);
- + }
- +
- + release();
- +
- + return rc;
- +}
- +
- +void B25Decoder::release()
- +{
- + if (_b25)
- + {
- + _b25->release(_b25);
- + _b25 = NULL;
- + report("B25Decoder::release()\n");
- + }
- +
- + 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)
- + {
- + char tmp[64];
- + sprintf_s(tmp, "b25::put failed. (%d)\n", rc);
- + report(tmp);
- +
- + // 乱暴だけどエラーコードに関係なく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);
- + if (rc < 0)
- + {
- + char tmp[64];
- + sprintf_s(tmp, "b25::get failed. (%d)\n", rc);
- + report(tmp);
- + return rc;
- + }
- +
- + if (buf->size)
- + return rc;
- +
- + return rc;
- +}
- +
- +int B25Decoder::flush()
- +{
- + report("B25Decoder::flush()\n");
- +
- + if (isPassThrough())
- + return 0;
- +
- + const int rc = _b25->flush(_b25);
- + if (rc < 0)
- + {
- + char tmp[64];
- + sprintf_s(tmp, "b25::flush failed. (%d)\n", rc);
- + report(tmp);
- + }
- +
- + return rc;
- +}
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/decoder.h b/EDCB-work-plus-s/BonCtrl/decoder.h
- --- a/EDCB-work-plus-s/BonCtrl/decoder.h 1970-01-01 09:00:00.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/decoder.h 2015-02-09 19:56:28.000000000 +0900
- @@ -0,0 +1,56 @@
- +// -*- coding: utf-8 -*-
- +#pragma once
- +
- +#include "arib_std_b25.h"
- +
- +typedef B_CAS_CARD *(*t_create_b_cas_card)();
- +typedef ARIB_STD_B25 *(*t_create_arib_std_b25)();
- +
- +class B25Decoder
- +{
- + t_create_b_cas_card f_create_b_cas_card;
- + t_create_arib_std_b25 f_create_arib_std_b25;
- +
- + 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(t_create_b_cas_card f_bcas, t_create_arib_std_b25 f_b25);
- +
- + ~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を読む限り常に成功する
- + }
- +
- + int flush();
- +
- + 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
- +};
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/DropCount.cpp b/EDCB-work-plus-s/BonCtrl/DropCount.cpp
- --- a/EDCB-work-plus-s/BonCtrl/DropCount.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/DropCount.cpp 2015-05-04 20:34:50.000000000 +0900
- @@ -31,13 +31,7 @@
- map<WORD, DROP_INFO>::iterator itr;
- itr = this->infoMap.find(packet.PID);
- if( itr == this->infoMap.end() ){
- - DROP_INFO item;
- - item.PID = packet.PID;
- - item.lastCounter = packet.continuity_counter;
- - item.total++;
- - if( packet.transport_scrambling_control != 0 ){
- - item.scramble++;
- - }
- + DROP_INFO item(packet.PID, packet.continuity_counter, ((packet.transport_scrambling_control) != 0));
- this->infoMap.insert(pair<WORD, DROP_INFO>(item.PID, item));
- }else{
- CheckCounter(&packet, &(itr->second));
- @@ -96,90 +90,75 @@
- }
- info->total++;
- - if( tsPacket->PID == 0x1FFF){
- + if( tsPacket->PID == 0x1FFF ){
- return;
- }
- if( tsPacket->transport_scrambling_control != 0 ){
- info->scramble++;
- this->scramble++;
- }
- -
- - if( tsPacket->adaptation_field_control == 0x00 || tsPacket->adaptation_field_control == 0x02 ){
- +
- + if( (tsPacket->adaptation_field_control & 0x1) == 0 ){
- //ペイロードが存在しない場合は意味なし
- - info->duplicateFlag = FALSE;
- goto CHK_END;
- }
- - if( info->lastCounter == tsPacket->continuity_counter ){
- - if( tsPacket->adaptation_field_control == 0x01 || tsPacket->adaptation_field_control == 0x03 ){
- - if( tsPacket->transport_scrambling_control == 0 ){
- - if( info->duplicateFlag == FALSE ){
- - //重送?一応連続と判定
- - info->duplicateFlag = TRUE;
- - if( tsPacket->adaptation_field_control == 0x02 || tsPacket->adaptation_field_control == 0x03 ){
- - if(tsPacket->discontinuity_indicator == 1){
- - //不連続の判定だが正常
- - info->duplicateFlag = FALSE;
- - }
- - }
- - goto CHK_END;
- - }else{
- - //前回重送と判断してるので不連続
- - info->duplicateFlag = FALSE;
- - info->drop++;
- - this->drop++;
- - goto CHK_END;
- - }
- - }else{
- - goto CHK_END;
- - }
- +
- + if( ((info->lastCounter+1) & 0x0F) != tsPacket->continuity_counter ){
- + if( tsPacket->discontinuity_indicator == 1 ){
- + //discontinuity_indicatorがtrueの場合は正常として扱う
- + //3連続以上は起こり得ない事になっているが、とりあえず考慮しない
- + goto CHK_END;
- }
- - }
- - if( info->lastCounter+1 != tsPacket->continuity_counter ){
- - if( info->lastCounter != 0x0F && tsPacket->continuity_counter != 0x00 ){
- - if(tsPacket->discontinuity_indicator == 1){
- - //不連続の判定だが正常
- - goto CHK_END;
- + if( info->lastCounter == tsPacket->continuity_counter ){
- + if( info->duplicateFlag == FALSE ){
- + //重送?一応連続と判定
- + info->duplicateFlag = TRUE;
- + goto CHK_END2;
- }
- - //カウンターが飛んだので不連続
- - ULONGLONG count = 0;
- - if( tsPacket->continuity_counter <= info->lastCounter ){
- - count = (tsPacket->continuity_counter+15) - info->lastCounter;
- - }else{
- - count = tsPacket->continuity_counter - info->lastCounter;
- - }
- -
- - info->drop+= count;
- - this->drop+= count;
- - info->total+= count-1;
- + //前回重送と判断してるので不連続
- + info->drop++; //数値としてはおかしいがどのみちこの時点では既に正確な値はわからない
- + this->drop++;
- + //オリジナルではスクランブル未解除ではこの場合のドロップを検出していないが、
- + //スクランブルされていても当然ドロップの発生はあり得るので…
- goto CHK_END;
- }
- + //カウンターが飛んだので不連続
- + //同じ値の場合はここには来ないのでこれで大丈夫
- + //なおオリジナルと数値が異なる場合(lastCounter=0,continuity_counter=2の場合等)があるが
- + //ドロップ数のカウントとしてはこちらの方が正しいはず
- + int count = (((tsPacket->continuity_counter + 0x10) - info->lastCounter) & 0x0F) - 1;
- + info->drop += count;
- + this->drop += count;
- + info->total += count;
- }
- CHK_END:
- + //重送->しばらく普通->また重送の様なパターンを考慮してフラグは毎回リセットする
- + info->duplicateFlag = FALSE;
- +CHK_END2:
- info->lastCounter = tsPacket->continuity_counter;
- - if( GetTickCount() - this->lastLogTime > 5000 ){
- - if( this->lastLogDrop != this->drop ||
- - this->lastLogScramble != this->scramble
- - ){
- - wstring log;
- - SYSTEMTIME now;
- - GetLocalTime(&now);
- - Format(log, L"%04d/%02d/%02d %02d:%02d:%02d Drop:%I64d Scramble:%I64d Signal: %.02f",
- - now.wYear,
- - now.wMonth,
- - now.wDay,
- - now.wHour,
- - now.wMinute,
- - now.wSecond,
- - this->drop,
- - this->scramble,
- - this->signalLv
- - );
- - this->log.push_back(log);
- - this->lastLogDrop = this->drop;
- - this->lastLogScramble = this->scramble;
- + if( this->lastLogDrop != this->drop || this->lastLogScramble != this->scramble ){
- + DWORD t;
- + if( ((t = GetTickCount()) - this->lastLogTime) > 5000 ){
- + wstring log;
- + SYSTEMTIME now;
- + GetLocalTime(&now);
- + Format(log, L"%04d/%02d/%02d %02d:%02d:%02d Drop:%I64d Scramble:%I64d Signal: %.02f",
- + now.wYear,
- + now.wMonth,
- + now.wDay,
- + now.wHour,
- + now.wMinute,
- + now.wSecond,
- + this->drop,
- + this->scramble,
- + this->signalLv
- + );
- + this->log.push_back(log);
- + this->lastLogDrop = this->drop;
- + this->lastLogScramble = this->scramble;
- + this->lastLogTime = t;
- }
- - this->lastLogTime = GetTickCount();
- }
- }
- @@ -284,12 +263,10 @@
- }
- }
- -void CDropCount::SetPIDName(
- - map<WORD, string>* pidName
- - )
- +void CDropCount::SetPIDName(map<WORD, string>* pidName)
- {
- map<WORD, string>::iterator itrIn;
- - for(itrIn = pidName->begin(); itrIn != pidName->end(); itrIn++){
- + for( itrIn = pidName->begin(); itrIn != pidName->end(); itrIn++ ){
- map<WORD, string>::iterator itrSet;
- itrSet = this->pidName.find(itrIn->first);
- if( itrSet != this->pidName.end() ){
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/DropCount.h b/EDCB-work-plus-s/BonCtrl/DropCount.h
- --- a/EDCB-work-plus-s/BonCtrl/DropCount.h 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/DropCount.h 2015-04-28 18:52:26.000000000 +0900
- @@ -35,13 +35,13 @@
- ULONGLONG total;
- ULONGLONG drop;
- ULONGLONG scramble;
- - _DROP_INFO(){
- - PID = 0xFFFF;
- - lastCounter = 0;
- + _DROP_INFO(WORD pid, BYTE lc, BOOL bsc){
- + PID = pid;
- + lastCounter = lc;
- duplicateFlag = FALSE;
- - total = 0;
- drop = 0;
- - scramble = 0;
- + scramble = bsc ? 1 : 0;
- + total = 1;
- };
- }DROP_INFO;
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/OneServiceUtil.cpp b/EDCB-work-plus-s/BonCtrl/OneServiceUtil.cpp
- --- a/EDCB-work-plus-s/BonCtrl/OneServiceUtil.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/OneServiceUtil.cpp 2015-05-08 10:48:45.000000000 +0900
- @@ -19,6 +19,8 @@
- this->pittariStart = FALSE;
- this->pittariEndChk = FALSE;
- this->maxBuffCount = -1;
- +
- + this->buff.reserve(188*256);
- }
- @@ -111,7 +113,7 @@
- while(1){
- Format(key, L"%s%d_%d", MUTEX_UDP_PORT_NAME, (*sendList)[i].ip, (*sendList)[i].port );
- HANDLE mutex = ::OpenMutex(MUTEX_ALL_ACCESS, FALSE, key.c_str());
- -
- +
- if(mutex){
- ::CloseHandle(mutex);
- (*sendList)[i].port++;
- @@ -165,7 +167,7 @@
- while(1){
- Format(key, L"%s%d_%d", MUTEX_TCP_PORT_NAME, (*sendList)[i].ip, (*sendList)[i].port );
- HANDLE mutex = ::OpenMutex(MUTEX_ALL_ACCESS, FALSE, key.c_str());
- -
- +
- if(mutex){
- ::CloseHandle(mutex);
- (*sendList)[i].port++;
- @@ -208,7 +210,7 @@
- CTSPacketUtil packet;
- if( packet.Set188TS(data + i, 188) == TRUE ){
- if( packet.PID == this->pmtPID ){
- - DWORD err = createPmt.AddData(&packet);
- + createPmt.AddData(&packet);
- }
- }
- }
- @@ -229,21 +231,20 @@
- }
- }else if( packet.PID == this->pmtPID ){
- //PMT
- - DWORD err = createPmt.AddData(&packet);
- - if( err == NO_ERR || err == ERR_NO_CHAGE ){
- - BYTE* pmtBuff = NULL;
- - DWORD pmtBuffSize = 0;
- + if (createPmt.AddData(&packet) == ERR_FALSE){
- + OutputDebugString(L"createPmt.AddData Err");
- + //そのまま
- + //this->buff.insert(this->buff.end(), data + i, data + i + 188);
- + }else{
- + BYTE* pmtBuff;
- + DWORD pmtBuffSize;
- if( createPmt.GetPacket(&pmtBuff, &pmtBuffSize) == TRUE ){
- this->buff.insert(this->buff.end(), pmtBuff, pmtBuff + pmtBuffSize);
- }else{
- - _OutputDebugString(L"createPmt.GetPacket Err");
- + OutputDebugString(L"createPmt.GetPacket Err");
- //そのまま
- - this->buff.insert(this->buff.end(), data + i, data + i + 188);
- + //this->buff.insert(this->buff.end(), data + i, data + i + 188);
- }
- - }else if( err == FALSE ){
- - _OutputDebugString(L"createPmt.AddData Err");
- - //そのまま
- - this->buff.insert(this->buff.end(), data + i, data + i + 188);
- }
- }else{
- //その他
- @@ -338,11 +339,11 @@
- item.PMTPID = pmtPID;
- item.SID = this->SID;
- PIDMap.insert(pair<WORD, CCreatePATPacket::PROGRAM_PID_INFO>(item.PMTPID,item));
- -
- +
- item.PMTPID = 0x0010;
- item.SID = 0x00;
- PIDMap.insert(pair<WORD, CCreatePATPacket::PROGRAM_PID_INFO>(item.PMTPID,item));
- -
- +
- createPat.SetParam(TSID, &PIDMap);
- this->pmtPID = pmtPID;
- @@ -549,7 +550,6 @@
- this->dropCount.SaveLog(filePath);
- }
- -
- void COneServiceUtil::SetSignalLevel(
- float signalLv
- )
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/PacketInit.cpp b/EDCB-work-plus-s/BonCtrl/PacketInit.cpp
- --- a/EDCB-work-plus-s/BonCtrl/PacketInit.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/PacketInit.cpp 2015-05-01 05:22:07.000000000 +0900
- @@ -1,6 +1,7 @@
- #include "StdAfx.h"
- #include "PacketInit.h"
- +#ifndef USE_MOD_SYNCLOGIC
- CPacketInit::CPacketInit(void)
- {
- this->nextStartSize = 0;
- @@ -32,7 +33,7 @@
- DWORD inSize,
- BYTE** outData,
- DWORD* outSize
- -)
- + )
- {
- if( inData == NULL || inSize == 0 || outData == NULL || outSize == NULL ){
- return FALSE;
- @@ -121,3 +122,231 @@
- }
- return FALSE;
- }
- +#else
- +CPacketInit::CPacketInit(void)
- +{
- + m_dwSyncBufPos = 0;
- + m_dwUnitSize = 0;
- +}
- +
- +CPacketInit::~CPacketInit(void)
- +{
- +}
- +
- +void CPacketInit::ClearBuff()
- +{
- + m_dwSyncBufPos = 0;
- + m_dwUnitSize = 0;
- +}
- +
- +//入力バッファを188バイト単位のTSに変換し、188の倍数になるようにそろえる
- +//戻り値:
- +// TRUE(成功)、FALSE(失敗)
- +//引数:
- +// pSrc [IN]入力TSデータ
- +// dwSrc [IN]pSrcのサイズ(BYTE単位)
- +// ppDst [OUT]188バイトに整列したバッファ(呼び出し元でdeleteする必要あり)
- +// pdwDst [OUT]ppDstのサイズ(BYTE単位)
- +BOOL CPacketInit::GetTSData(
- + BYTE* pSrc,
- + DWORD dwSrc,
- + BYTE** ppDst,
- + DWORD* pdwDst
- + )
- +{
- + // 既に同期済みか?
- + if (m_dwUnitSize != 0)
- + {
- + for (DWORD pos = m_dwUnitSize - m_dwSyncBufPos; pos < dwSrc; pos += m_dwUnitSize)
- + {
- + if (pSrc[pos] != TS_SYNC_BYTE)
- + {
- + // 今回の入力バッファで同期が崩れてしまうので要再同期
- + m_dwUnitSize = 0;
- + break;
- + }
- + }
- + if (m_dwUnitSize != 0)
- + {
- + DWORD dwDst = TS_PKTSIZE * ((m_dwSyncBufPos + dwSrc) / m_dwUnitSize);
- + if (dwDst == 0)
- + {
- + // 同期用繰り越しバッファと今回の入力バッファを合わせてもユニットサイズに届かなかったので、
- + // 今回の入力バッファを同期用繰り越しバッファに追加するだけで終了
- + ::memcpy(&m_SyncBuf[m_dwSyncBufPos], pSrc, dwSrc);
- + m_dwSyncBufPos += dwSrc;
- + *ppDst = NULL; // 呼び出し側でのdelete[]を保証する
- + *pdwDst = 0;
- + return FALSE;
- + }
- + BYTE *pDst = new BYTE[dwDst];
- + if (m_dwSyncBufPos == 0)
- + ::memcpy(pDst, pSrc, TS_PKTSIZE);
- + else
- + {
- + if (m_dwSyncBufPos >= TS_PKTSIZE)
- + ::memcpy(pDst, m_SyncBuf, TS_PKTSIZE);
- + else
- + {
- + ::memcpy(pDst, m_SyncBuf, m_dwSyncBufPos);
- + ::memcpy(&pDst[m_dwSyncBufPos], pSrc, TS_PKTSIZE - m_dwSyncBufPos);
- + }
- + }
- + DWORD dwSrcPos = m_dwUnitSize - m_dwSyncBufPos;
- + if (m_dwUnitSize == TS_PKTSIZE)
- + {
- + // 普通のTSパケットの場合はそのままコピーできる
- + ::memcpy(&pDst[TS_PKTSIZE], &pSrc[dwSrcPos], (dwDst - TS_PKTSIZE));
- + dwSrcPos += (dwDst - TS_PKTSIZE);
- + }
- + else
- + {
- + // それ以外のパケットの場合は普通のTSパケットに変換
- + for (DWORD pos = TS_PKTSIZE; (dwSrcPos + m_dwUnitSize) <= dwSrc; dwSrcPos += m_dwUnitSize, pos += TS_PKTSIZE)
- + ::memcpy(&pDst[pos], &pSrc[dwSrcPos], TS_PKTSIZE);
- + }
- + if ((dwSrc - dwSrcPos) > 0)
- + {
- + // 入力バッファに余りがあるので同期用繰り越しバッファに保存
- + ::memcpy(m_SyncBuf, &pSrc[dwSrcPos], (dwSrc - dwSrcPos));
- + m_dwSyncBufPos = dwSrc - dwSrcPos;
- + }
- + else
- + m_dwSyncBufPos = 0;
- + *ppDst = pDst;
- + *pdwDst = dwDst;
- + return TRUE;
- + }
- + }
- +
- + // 同期処理開始
- + DWORD dwSyncBufPos = m_dwSyncBufPos;
- + for (DWORD off = 0; (off + TS_PKTSIZE) < (dwSyncBufPos + dwSrc); off++)
- + {
- + if (((off >= dwSyncBufPos) && (pSrc[off - dwSyncBufPos] == TS_SYNC_BYTE)) || ((off < dwSyncBufPos) && (m_SyncBuf[off] == TS_SYNC_BYTE)))
- + {
- + for (int type = 0; type < 4; type++)
- + {
- + DWORD dwUnitSize;
- + switch (type)
- + {
- + case 0:
- + dwUnitSize = TS_PKTSIZE;
- + break;
- + case 1:
- + dwUnitSize = TTS_PKTSIZE;
- + break;
- + case 2:
- + dwUnitSize = TS_FEC_PKTSIZE;
- + break;
- + default:
- + dwUnitSize = TTS_FEC_PKTSIZE;
- + break;
- + }
- + BOOL bSync = TRUE;
- + if (dwUnitSize >= dwSyncBufPos)
- + {
- + DWORD pos = off + (dwUnitSize - dwSyncBufPos);
- + if (pos >= dwSrc)
- + {
- + // bSync = FALSE;
- + // これ以降のユニットサイズではこの場所で同期成功する事は無いのでbreak
- + break;
- + }
- + else
- + {
- + // 同一ユニットサイズのバッファが8個もしくは今回の入力バッファの
- + // 最後まで並んでいるなら同期成功とみなす
- + int n = 0;
- + do
- + {
- + if (pSrc[pos] != TS_SYNC_BYTE)
- + {
- + bSync = FALSE;
- + break;
- + }
- + pos += dwUnitSize;
- + n++;
- + } while ((n < 8) && (pos < dwSrc));
- + }
- + }
- + else
- + {
- + DWORD pos = off + dwUnitSize;
- + if (pos >= (dwSyncBufPos + dwSrc))
- + {
- + // bSync = FALSE;
- + // これ以降のユニットサイズではこの場所で同期成功する事は無いのでbreak
- + break;
- + }
- + else
- + {
- + // 同一ユニットサイズのバッファが8個もしくは今回の入力バッファの
- + // 最後まで並んでいるなら同期成功とみなす
- + int n = 0;
- + do
- + {
- + if (((pos >= dwSyncBufPos) && (pSrc[pos - dwSyncBufPos] != TS_SYNC_BYTE)) || ((pos < dwSyncBufPos) && (m_SyncBuf[pos] != TS_SYNC_BYTE)))
- + {
- + bSync = FALSE;
- + break;
- + }
- + pos += dwUnitSize;
- + n++;
- + } while ((n < 8) && (pos < (dwSyncBufPos + dwSrc)));
- + }
- + }
- + if (bSync)
- + {
- + m_dwUnitSize = dwUnitSize;
- + if (off < dwSyncBufPos)
- + {
- + if (off > 0)
- + {
- + dwSyncBufPos -= off;
- + ::memmove(m_SyncBuf, &m_SyncBuf[off], dwSyncBufPos);
- + }
- + // この同期検出ロジックでは↓の状態は起こり得ないハズ
- +#if 0
- + // 同期済み時の同期用繰り越しバッファサイズはユニットサイズ以下である必要がある
- + if (dwSyncBufPos > dwUnitSize)
- + {
- + dwSyncBufPos -= dwUnitSize;
- + ::memmove(m_SyncBuf, &m_SyncBuf[dwUnitSize], dwSyncBufPos);
- + }
- +#endif
- + m_dwSyncBufPos = dwSyncBufPos;
- + return GetTSData(pSrc, dwSrc, ppDst, pdwDst);
- + }
- + else
- + {
- + m_dwSyncBufPos = 0;
- + return GetTSData(&pSrc[off - dwSyncBufPos], (dwSrc - (off - dwSyncBufPos)), ppDst, pdwDst);
- + }
- + }
- + }
- + }
- + }
- +
- + // 今回の入力では同期できなかったので、同期用繰り越しバッファに保存だけして終了
- + if (dwSrc >= sizeof(m_SyncBuf))
- + {
- + ::memcpy(m_SyncBuf, &pSrc[dwSrc - sizeof(m_SyncBuf)], sizeof(m_SyncBuf));
- + m_dwSyncBufPos = sizeof(m_SyncBuf);
- + }
- + else if ((dwSyncBufPos + dwSrc) > sizeof(m_SyncBuf))
- + {
- + ::memmove(m_SyncBuf, &m_SyncBuf[(dwSyncBufPos + dwSrc) - sizeof(m_SyncBuf)], (sizeof(m_SyncBuf) - dwSrc));
- + ::memcpy(&m_SyncBuf[sizeof(m_SyncBuf) - dwSrc], pSrc, dwSrc);
- + m_dwSyncBufPos = sizeof(m_SyncBuf);
- + }
- + else
- + {
- + ::memcpy(&m_SyncBuf[dwSyncBufPos], pSrc, dwSrc);
- + m_dwSyncBufPos += dwSrc;
- + }
- + *ppDst = NULL; // 呼び出し側でのdelete[]を保証する
- + *pdwDst = 0;
- + return FALSE;
- +}
- +#endif
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/PacketInit.h b/EDCB-work-plus-s/BonCtrl/PacketInit.h
- --- a/EDCB-work-plus-s/BonCtrl/PacketInit.h 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/PacketInit.h 2015-05-01 05:21:52.000000000 +0900
- @@ -1,9 +1,12 @@
- #pragma once
- +#define USE_MOD_SYNCLOGIC
- +
- #include <windows.h>
- #include "../Common/Util.h"
- +#ifndef USE_MOD_SYNCLOGIC
- class CPacketInit
- {
- public:
- @@ -34,3 +37,40 @@
- DWORD packetSize;
- };
- +#else
- +#define TS_SYNC_BYTE 0x47
- +#define TS_PKTSIZE 188
- +#define TTS_PKTSIZE 192
- +#define TS_FEC_PKTSIZE 204
- +#define TTS_FEC_PKTSIZE 208
- +class CPacketInit
- +{
- +public:
- + CPacketInit(void);
- + ~CPacketInit(void);
- +
- + //入力バッファを188バイト単位のTSに変換し、188の倍数になるようにそろえる
- + //戻り値:
- + // TRUE(成功)、FALSE(失敗)
- + //引数:
- + // inData [IN]入力TSデータ
- + // inSize [IN]inDataのサイズ(BYTE単位)
- + // outData [OUT]188バイトに整列したバッファ(呼び出し元でdeleteする必要あり)
- + // outSize [OUT]outDataのサイズ(BYTE単位)
- + BOOL GetTSData(
- + BYTE* pSrc,
- + DWORD dwSrc,
- + BYTE** ppDst,
- + DWORD* pdwDst
- + );
- +
- + //内部バッファのクリア
- + void ClearBuff();
- +
- +protected:
- + BYTE m_SyncBuf[256];
- + DWORD m_dwSyncBufPos;
- +
- + DWORD m_dwUnitSize;
- +};
- +#endif
- \ No newline at end of file
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/PMTUtil.cpp b/EDCB-work-plus-s/BonCtrl/PMTUtil.cpp
- --- a/EDCB-work-plus-s/BonCtrl/PMTUtil.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/PMTUtil.cpp 2015-04-29 06:07:47.000000000 +0900
- @@ -7,10 +7,10 @@
- CPMTUtil::CPMTUtil(void)
- {
- this->program_number = 0xFFFF;
- + this->version_number = 0xFF;
- this->PCR_PID = 0xFFFF;
- }
- -
- CPMTUtil::~CPMTUtil(void)
- {
- Clear();
- @@ -22,17 +22,18 @@
- return FALSE;
- }
- if( buffUtil.Add188TS(packet) == TRUE ){
- - BYTE* section = NULL;
- - DWORD sectionSize = 0;
- + BYTE* section;
- + DWORD sectionSize;
- + BOOL ret = FALSE;
- while( buffUtil.GetSectionBuff( §ion, §ionSize ) == TRUE ){
- - if( DecodePMT(section, sectionSize) == FALSE ){
- - return FALSE;
- + if (DecodePMT(section, sectionSize) == TRUE){
- + // 一回でも新PMTが来たらTRUEを返す(バッファを空にするためループは最後まで回す)
- + ret = TRUE;
- }
- }
- - }else{
- - return FALSE;
- + return ret;
- }
- - return TRUE;
- + return FALSE;
- }
- void CPMTUtil::Clear()
- @@ -41,29 +42,26 @@
- SAFE_DELETE(ESInfoList[i]);
- }
- ESInfoList.clear();
- -
- PIDList.clear();
- }
- BOOL CPMTUtil::DecodePMT(BYTE* data, DWORD dataSize)
- {
- - Clear();
- -
- +/*
- if( data == NULL ){
- return FALSE;
- }
- -
- +*/
- if( dataSize < 7 ){
- return FALSE;
- }
- - DWORD readSize = 0;
- //////////////////////////////////////////////////////
- //解析処理
- table_id = data[0];
- section_syntax_indicator = (data[1]&0x80)>>7;
- section_length = ((WORD)data[1]&0x0F)<<8 | data[2];
- - readSize+=3;
- + DWORD readSize = 3;
- if( section_syntax_indicator != 1 ){
- //固定値がおかしい
- @@ -91,12 +89,24 @@
- }
- if( section_length > 12 ){
- - program_number = ((WORD)data[readSize])<<8 | data[readSize+1];
- - version_number = (data[readSize+2]&0x3E)>>1;
- +
- + WORD new_program_number = ((WORD)data[readSize]) << 8 | data[readSize + 1];
- + BYTE new_version_number = (data[readSize + 2] >> 1) & 0x1F;
- + WORD new_PCR_PID = ((WORD)data[readSize + 5] & 0x1F) << 8 | data[readSize + 6];
- + if (PCR_PID == new_PCR_PID && program_number == new_program_number && version_number == new_version_number){
- + //バージョン同じ
- + return FALSE;
- + }
- +
- + // リストがつくり直しになるのでここでClear()
- + Clear();
- +
- + program_number = new_program_number;
- + version_number = new_version_number;
- current_next_indicator = data[readSize+2]&0x01;
- section_number = data[readSize+3];
- last_section_number = data[readSize+4];
- - PCR_PID = ((WORD)data[readSize+5]&0x1F)<<8 | data[readSize+6];
- + PCR_PID = new_PCR_PID;
- program_info_length = ((WORD)data[readSize+7]&0x0F)<<8 | data[readSize+8];
- readSize += 9;
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/portable.h b/EDCB-work-plus-s/BonCtrl/portable.h
- --- a/EDCB-work-plus-s/BonCtrl/portable.h 1970-01-01 09:00:00.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/portable.h 2015-02-13 00:10:58.000000000 +0900
- @@ -0,0 +1,21 @@
- +#ifndef PORTABLE_H
- +#define PORTABLE_H
- +
- +#if (defined(_WINDOWS) && MSC_VER < 1300)
- +
- +typedef unsigned char uint8_t;
- +typedef signed char int8_t;
- +typedef unsigned short uint16_t;
- +typedef signed short int16_t;
- +typedef unsigned int uint32_t;
- +typedef signed int int32_t;
- +typedef unsigned __int64 uint64_t;
- +typedef signed __int64 int64_t;
- +
- +#else
- +
- +#include <inttypes.h>
- +
- +#endif
- +
- +#endif /* PORTABLE_H */
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/ScrambleDecoderUtil.cpp b/EDCB-work-plus-s/BonCtrl/ScrambleDecoderUtil.cpp
- --- a/EDCB-work-plus-s/BonCtrl/ScrambleDecoderUtil.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/ScrambleDecoderUtil.cpp 2015-02-14 06:01:12.000000000 +0900
- @@ -6,9 +6,8 @@
- {
- this->currentDll = L"";
- - this->decodeIF = NULL;
- - this->decodeIF2 = NULL;
- this->module = NULL;
- + this->b25 = NULL;
- this->emmEnable = false;
- }
- @@ -27,30 +26,23 @@
- if( this->module == NULL ){
- return FALSE;
- }
- - IB25Decoder* (*func)();
- - func = (IB25Decoder* (*)())::GetProcAddress( this->module, "CreateB25Decoder");
- - if( !func ){
- + t_create_b_cas_card f_bcas;
- + f_bcas = (t_create_b_cas_card)::GetProcAddress(this->module, "create_b_cas_card");
- + if( !f_bcas ){
- ret = FALSE;
- goto ERR_END;
- }
- - this->decodeIF = func();
- - if( this->decodeIF->Initialize() == FALSE ){
- - this->decodeIF->Release();
- - this->decodeIF = NULL;
- + t_create_arib_std_b25 f_b25;
- + f_b25 = (t_create_arib_std_b25)::GetProcAddress(this->module, "create_arib_std_b25");
- + if( !f_b25 ){
- + ret = FALSE;
- + goto ERR_END;
- + }
- +
- + this->b25 = new B25Decoder(f_bcas, f_b25);
- + B25Decoder::emm_proc = this->emmEnable ? 1 : 0;
- + if( this->b25->init() < 0 ){
- ret = FALSE;
- - }else{
- - try{
- - this->decodeIF2 = dynamic_cast<IB25Decoder2 *>(this->decodeIF);
- - if( this->decodeIF2 != NULL ){
- - //this->decodeIF2->EnableEmmProcess(false);
- - this->decodeIF2->DiscardNullPacket(true);
- - this->decodeIF2->DiscardScramblePacket(false);
- - this->decodeIF2->EnableEmmProcess(this->emmEnable);
- - }
- - }
- - catch(std::__non_rtti_object){
- - this->decodeIF2 = NULL;
- - }
- }
- ERR_END:
- if( ret == FALSE ){
- @@ -62,10 +54,9 @@
- void CScrambleDecoderUtil::UnLoadDll()
- {
- - if( this->decodeIF != NULL ){
- - this->decodeIF->Release();
- - this->decodeIF = NULL;
- - this->decodeIF2 = NULL;
- + if( this->b25 != NULL ){
- + delete this->b25;
- + this->b25 = NULL;
- }
- if( this->module != NULL ){
- ::FreeLibrary( this->module );
- @@ -114,8 +105,8 @@
- dllPath += defDll;
- this->loadDll = defDll;
- }else{
- - dllPath += L"\\B25Decoder.dll";
- - this->loadDll = L"B25Decoder.dll";
- + dllPath += L"\\arib_std_b25.dll";
- + this->loadDll = L"arib_std_b25.dll";
- }
- if( CompareNoCase(dllPath, this->currentDll) != 0 ){
- @@ -126,6 +117,8 @@
- this->currentDll = dllPath;
- ret = TRUE;
- }
- + }else{
- + ret = TRUE;
- }
- return ret;
- @@ -133,31 +126,33 @@
- BOOL CScrambleDecoderUtil::Decode(BYTE* src, DWORD srcSize, BYTE** dest, DWORD* destSize)
- {
- - if( this->decodeIF == NULL ){
- + if( this->b25 == NULL ){
- return FALSE;
- }
- - return this->decodeIF->Decode(src, srcSize, dest, destSize);
- + ARIB_STD_B25_BUFFER buf;
- + buf.data = src;
- + buf.size = srcSize;
- + this->b25->decode(&buf);
- + *dest = buf.data;
- + *destSize = buf.size;
- + return TRUE;
- }
- +/*
- void CScrambleDecoderUtil::Reset()
- {
- - if( this->decodeIF == NULL ){
- + if( this->b25 == NULL ){
- return ;
- }
- - this->decodeIF->Reset();
- + this->b25->Reset();
- }
- -
- +*/
- BOOL CScrambleDecoderUtil::SetEmm(BOOL enable)
- {
- - if( this->decodeIF2 == NULL ){
- - return FALSE;
- - }
- if( enable == TRUE ){
- - this->decodeIF2->EnableEmmProcess(true);
- this->emmEnable = true;
- }else{
- - this->decodeIF2->EnableEmmProcess(false);
- this->emmEnable = false;
- }
- return TRUE;
- @@ -165,10 +160,7 @@
- DWORD CScrambleDecoderUtil::GetEmmCount()
- {
- - if( this->decodeIF2 == NULL ){
- - return 0;
- - }
- - return this->decodeIF2->GetEmmProcessNum();
- + return 0;
- }
- BOOL CScrambleDecoderUtil::GetLoadStatus(wstring& loadErrDll)
- @@ -180,4 +172,3 @@
- return TRUE;
- }
- }
- -
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/ScrambleDecoderUtil.h b/EDCB-work-plus-s/BonCtrl/ScrambleDecoderUtil.h
- --- a/EDCB-work-plus-s/BonCtrl/ScrambleDecoderUtil.h 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/ScrambleDecoderUtil.h 2015-02-13 00:23:28.000000000 +0900
- @@ -7,7 +7,7 @@
- #include "../Common/StringUtil.h"
- #include "../Common/ErrDef.h"
- -#include "IB25Decoder.h"
- +#include "decoder.h"
- class CScrambleDecoderUtil
- {
- @@ -32,8 +32,7 @@
- wstring currentDll;
- wstring loadDll;
- - IB25Decoder* decodeIF;
- - IB25Decoder2* decodeIF2;
- + B25Decoder *b25;
- HMODULE module;
- bool emmEnable;
- @@ -41,4 +40,3 @@
- protected:
- BOOL LoadDll(LPCWSTR dllPath);
- };
- -
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/SendUDP.cpp b/EDCB-work-plus-s/BonCtrl/SendUDP.cpp
- --- a/EDCB-work-plus-s/BonCtrl/SendUDP.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/SendUDP.cpp 2015-04-25 07:28:42.000000000 +0900
- @@ -47,7 +47,7 @@
- m_hSendStopEvent = NULL;
- }
- - if( m_hCriticalEvent == NULL ){
- + if( m_hCriticalEvent != NULL ){
- ::WaitForSingleObject(m_hCriticalEvent, 300);
- ::CloseHandle(m_hCriticalEvent);
- m_hCriticalEvent = NULL;
- diff -u -r -N a/EDCB-work-plus-s/BonCtrl/TSOut.cpp b/EDCB-work-plus-s/BonCtrl/TSOut.cpp
- --- a/EDCB-work-plus-s/BonCtrl/TSOut.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/BonCtrl/TSOut.cpp 2015-05-01 10:31:42.000000000 +0900
- @@ -25,6 +25,8 @@
- this->nextCtrlID = 1;
- this->epgFile = NULL;
- +
- + this->decodeBuff.reserve(188*256);
- }
- @@ -166,11 +168,11 @@
- if( this->enableDecodeFlag != FALSE || this->emmEnableFlag != FALSE ){
- //スクランブル解除かEMM処理が設定されている場合だけ実行
- - if( this->decodeUtil.SetNetwork(onid, tsid) == FALSE ){
- + this->decodeUtil.SetEmm(this->emmEnableFlag);
- + if (this->decodeUtil.SetNetwork(onid, tsid) == FALSE){
- OutputDebugString(L"★★Decode DLL load err [CTSOut::OnChChanged()]\r\n");
- //再試行は意味がなさそうなので廃止
- }
- - this->decodeUtil.SetEmm(this->emmEnableFlag);
- }
- ResetErrCount();
- @@ -209,26 +211,14 @@
- UnLock();
- return NO_ERR;
- }
- - //簡易パケット解析
- - if( packet.transport_scrambling_control != 0 ){
- - //スクランブルパケットなので解析できない
- - continue;
- - }
- - if( packet.data_byteSize < 3 ){
- - //サイズが小さすぎる
- - continue;
- - }
- - if(packet.payload_unit_start_indicator == 1 &&
- - packet.data_byte[0] == 0x00 &&
- - packet.data_byte[1] == 0x00 &&
- - packet.data_byte[2] == 0x01){
- - //PES
- + if( packet.PID > 0x30 ){
- + //PIDが0x30以下のパケット以外は不要
- continue;
- }
- try{
- this->epgUtil.AddTSPacket(data->data + i, 188);
- }catch(...){
- - _OutputDebugString(L"★★CTSOut::AddTSBuff epgUtil.AddTSPacket");
- + OutputDebugString(L"★★CTSOut::AddTSBuff epgUtil.AddTSPacket");
- this->epgUtil.UnInitialize();
- this->epgUtil.Initialize(FALSE);
- }
- @@ -237,9 +227,8 @@
- if( this->epgUtil.GetTSID(&onid, &tsid) == NO_ERR ){
- if( onid != this->lastONID || tsid != this->lastTSID ){
- OutputDebugString(L"★Ch Change Complete\r\n");
- - _OutputDebugString(L"★Ch 0x%04X 0x%04X => 0x%04X 0x%04X\r\n", this->lastONID, this->lastTSID, onid, tsid);
- + _OutputDebugString(L"★Ch 0x%04X 0x%04X => 0x%04X 0x%04X\r\n", this->lastONID, this->lastTSID, onid, tsid);
- OnChChanged(onid, tsid);
- -
- }else if( GetTickCount() - this->chChangeTime > 7000 ){
- OutputDebugString(L"★Ch NoChange\r\n");
- OnChChanged(onid, tsid);
- @@ -256,8 +245,8 @@
- this->lastONID = onid;
- this->lastTSID = tsid;
- //this->epgUtil.ClearSectionStatus();
- - //this->decodeUtil.SetNetwork(onid, tsid);
- //this->decodeUtil.SetEmm(this->emmEnableFlag);
- + //this->decodeUtil.SetNetwork(onid, tsid);
- //ResetErrCount();
- }
- continue;
- @@ -274,9 +263,8 @@
- if(this->catUtil->AddPacket(&packet) == TRUE){
- CheckNeedPID();
- }
- - }
- - //PMT
- - if( packet.payload_unit_start_indicator == 1 && packet.data_byteSize > 0){
- + }else if( packet.payload_unit_start_indicator == 1 && packet.data_byteSize > 0){
- + // PMT探しなのでCATだとわかっている物は除外しても大丈夫
- BYTE pointer = packet.data_byte[0];
- if( pointer+1 < packet.data_byteSize ){
- if( packet.data_byte[1+pointer] == 0x02 ){
- @@ -346,8 +334,8 @@
- this->lastONID = 0xFFFF;
- this->lastTSID = 0xFFFF;
- //this->epgUtil.ClearSectionStatus();
- - //this->decodeUtil.SetNetwork(onid, tsid);
- //this->decodeUtil.SetEmm(this->emmEnableFlag);
- + //this->decodeUtil.SetNetwork(onid, tsid);
- //ResetErrCount();
- }
- }
- @@ -367,10 +355,11 @@
- }
- }
- }catch(...){
- - _OutputDebugString(L"★★CTSOut::AddTSBuff Exception1");
- + OutputDebugString(L"★★CTSOut::AddTSBuff Exception1");
- UnLock();
- return ERR_FALSE;
- }
- +
- try{
- if( this->decodeBuff.empty() == false ){
- if( this->enableDecodeFlag == TRUE && this->chChangeFlag == FALSE ){
- @@ -393,19 +382,24 @@
- }
- }
- }catch(...){
- - _OutputDebugString(L"★★CTSOut::AddTSBuff Exception2");
- + OutputDebugString(L"★★CTSOut::AddTSBuff Exception2");
- //デコード失敗
- decodeData = &this->decodeBuff.front();
- decodeSize = (DWORD)this->decodeBuff.size();
- }
- -
- +
- //デコード済みのデータを解析させる
- try{
- for( DWORD i=0; i<decodeSize; i+=188 ){
- - this->epgUtil.AddTSPacket(decodeData + i, 188);
- + WORD pid = ((((WORD)decodeData[i + 1] & 0x1f) << 8) | decodeData[i + 2]);
- + if( pid <= 0x30 ){
- + // PIDが0x30以下のパケットのみEPG解析に回す
- + // PMTに関しては内部でパースはされるものの使用はされていないので渡さなくても大丈夫
- + this->epgUtil.AddTSPacket(decodeData + i, 188);
- + }
- }
- }catch(...){
- - _OutputDebugString(L"★★CTSOut::AddTSBuff Exception3");
- + OutputDebugString(L"★★CTSOut::AddTSBuff Exception3");
- this->epgUtil.UnInitialize();
- this->epgUtil.Initialize(FALSE);
- UnLock();
- @@ -419,7 +413,7 @@
- itrService->second->AddTSBuff(decodeData, decodeSize);
- }
- }catch(...){
- - _OutputDebugString(L"★★CTSOut::AddTSBuff Exception4");
- + OutputDebugString(L"★★CTSOut::AddTSBuff Exception4");
- UnLock();
- return ERR_FALSE;
- }
- @@ -441,8 +435,8 @@
- map<WORD, string> pidName;
- map<WORD, CPMTUtil*>::iterator itrPmt;
- - for( itrPmt = pmtUtilMap.begin(); itrPmt != pmtUtilMap.end(); itrPmt++ ){
- - string name = "";
- + for( itrPmt = pmtUtilMap.begin(); itrPmt != pmtUtilMap.end(); ++itrPmt ){
- + string name;
- Format(name, "PMT(ServiceID 0x%04X)", itrPmt->second->program_number);
- pidName.insert(pair<WORD, string>(itrPmt->first, name));
- map<WORD, WORD>::iterator itrPID;
- @@ -460,6 +454,9 @@
- case 0x1B:
- name = "MPEG4 VIDEO";
- break;
- + case 0x24:
- + name = "HEVC VIDEO";
- + break;
- case 0x04:
- name = "MPEG2 AUDIO";
- break;
- @@ -491,12 +488,12 @@
- //各サービスのPMTを探す
- map<DWORD, COneServiceUtil*>::iterator itrService;
- - for( itrService = serviceUtilMap.begin(); itrService != serviceUtilMap.end(); itrService++ ){
- + for( itrService = serviceUtilMap.begin(); itrService != serviceUtilMap.end(); ++itrService ){
- if( itrService->second->GetSID() == 0xFFFF ){
- //全サービス対象
- this->serviceOnlyFlag = FALSE;
- map<WORD, CPMTUtil*>::iterator itrPmt;
- - for( itrPmt = pmtUtilMap.begin(); itrPmt != pmtUtilMap.end(); itrPmt++ ){
- + for( itrPmt = pmtUtilMap.begin(); itrPmt != pmtUtilMap.end(); ++itrPmt ){
- //PAT作成用のPMTリスト作成
- CCreatePATPacket::PROGRAM_PID_INFO item;
- item.PMTPID = itrPmt->first;
- @@ -506,12 +503,12 @@
- //PMT記載のPIDを登録
- this->needPIDMap.insert(pair<WORD,WORD>(itrPmt->first, 0));
- map<WORD,WORD>::iterator itrPID;
- - for( itrPID = itrPmt->second->PIDList.begin(); itrPID != itrPmt->second->PIDList.end(); itrPID++ ){
- + for( itrPID = itrPmt->second->PIDList.begin(); itrPID != itrPmt->second->PIDList.end(); ++itrPID ){
- this->needPIDMap.insert(pair<WORD,WORD>(itrPID->first, itrPID->second));
- }
- }
- }else{
- - for( itrPmt = pmtUtilMap.begin(); itrPmt != pmtUtilMap.end(); itrPmt++ ){
- + for( itrPmt = pmtUtilMap.begin(); itrPmt != pmtUtilMap.end(); ++itrPmt ){
- if( itrService->second->GetSID() == itrPmt->second->program_number ){
- //PMT発見
- itrService->second->SetPmtPID(this->lastTSID, itrPmt->first);
- @@ -519,7 +516,6 @@
- itrService->second->SetEmmPID(&catUtil->PIDList);
- }
- -
- //PAT作成用のPMTリスト作成
- CCreatePATPacket::PROGRAM_PID_INFO item2;
- item2.PMTPID = itrPmt->first;
- @@ -530,7 +526,7 @@
- this->needPIDMap.insert(pair<WORD,WORD>(itrPmt->first, 0));
- this->needPIDMap.insert(pair<WORD,WORD>(itrPmt->second->PCR_PID, 0));
- map<WORD,WORD>::iterator itrPID;
- - for( itrPID = itrPmt->second->PIDList.begin(); itrPID != itrPmt->second->PIDList.end(); itrPID++ ){
- + for( itrPID = itrPmt->second->PIDList.begin(); itrPID != itrPmt->second->PIDList.end(); ++itrPID ){
- this->needPIDMap.insert(pair<WORD,WORD>(itrPID->first, itrPID->second));
- }
- }
- @@ -539,14 +535,15 @@
- itrService->second->SetPIDName(&pidName);
- }
- this->patUtil.SetParam(this->lastTSID, &PIDMap);
- -
- }
- BOOL CTSOut::IsNeedPID(CTSPacketUtil* packet)
- {
- +/*
- if( packet == NULL ){
- return FALSE;
- }
- +*/
- if( packet->PID <= 0x30 ){
- return TRUE;
- }
- @@ -663,6 +660,7 @@
- if( enable != FALSE && this->enableDecodeFlag == FALSE && this->emmEnableFlag == FALSE ){
- //最初に EMM 処理が設定される場合は DLL を読み込む
- //スクランブル解除が設定されている場合は読み込み済みなので除外
- + this->decodeUtil.SetEmm(TRUE);
- if( this->decodeUtil.SetNetwork(this->lastONID, this->lastTSID) == FALSE ){
- OutputDebugString(L"★★Decode DLL load err [CTSOut::SetEmm()]\r\n");
- }
- @@ -673,11 +671,10 @@
- return FALSE;
- }
- - BOOL err = this->decodeUtil.SetEmm(enable);
- this->emmEnableFlag = enable;
- UnLock();
- - return err;
- + return TRUE;
- }
- //EMM処理を行った数
- @@ -1204,6 +1201,7 @@
- if( enable != FALSE && this->enableDecodeFlag == FALSE && this->emmEnableFlag == FALSE ){
- //最初にスクランブル解除が設定される場合は DLL を再読み込みする
- //EMM 処理が設定されている場合は読み込み済みなので除外
- + this->decodeUtil.SetEmm(FALSE);
- if( this->decodeUtil.SetNetwork(this->lastONID, this->lastTSID) == FALSE ){
- OutputDebugString(L"★★Decode DLL load err [CTSOut::SetScramble()]\r\n");
- }
- diff -u -r -N a/EDCB-work-plus-s/Common/SendCtrlCmd.cpp b/EDCB-work-plus-s/Common/SendCtrlCmd.cpp
- --- a/EDCB-work-plus-s/Common/SendCtrlCmd.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/Common/SendCtrlCmd.cpp 2015-05-02 02:00:19.000000000 +0900
- @@ -238,7 +238,6 @@
- server.sin_addr.S_un.S_addr = inet_addr(strA.c_str());
- DWORD socketBuffSize = 1024*1024;
- setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (const char*)&socketBuffSize, sizeof(socketBuffSize));
- - setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (const char*)&socketBuffSize, sizeof(socketBuffSize));
- int ret = connect(sock, (struct sockaddr *)&server, sizeof(server));
- if( ret == SOCKET_ERROR ){
- diff -u -r -N a/EDCB-work-plus-s/Common/StringUtil.cpp b/EDCB-work-plus-s/Common/StringUtil.cpp
- --- a/EDCB-work-plus-s/Common/StringUtil.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/Common/StringUtil.cpp 2015-04-29 05:25:43.000000000 +0900
- @@ -6,17 +6,16 @@
- va_list params;
- va_start(params, format);
- - int iResult;
- - char *buff;
- int length = _vscprintf(format, params);
- - buff = new char [length + 1];
- - iResult = vsprintf_s(buff, length + 1, format, params);
- - buff[length] = '\0';
- - if (buff != NULL) {
- + char *buff = new char[length + 1];
- + if (buff == NULL){
- + strBuff = "";
- + }else{
- + vsprintf_s(buff, length + 1, format, params);
- + buff[length] = '\0';
- strBuff = buff;
- delete[] buff;
- }
- -
- va_end(params);
- }
- diff -u -r -N a/EDCB-work-plus-s/Common/TSBuffUtil.cpp b/EDCB-work-plus-s/Common/TSBuffUtil.cpp
- --- a/EDCB-work-plus-s/Common/TSBuffUtil.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/Common/TSBuffUtil.cpp 2015-04-29 15:45:59.000000000 +0900
- @@ -23,11 +23,11 @@
- void CTSBuffUtil::Clear()
- {
- - for(size_t i=0; i<this->packetList.size(); i++ ){
- - SAFE_DELETE(this->packetList[i]);
- + while (!this->packetList.empty()){
- + SECTION_BUFF *p = this->packetList.front();
- + this->packetList.pop_front();
- + delete p;
- }
- - this->packetList.clear();
- -
- this->lastPID = 0xFFFF;
- this->lastCounter = 0xFF;
- @@ -43,64 +43,57 @@
- this->duplicateFlag = FALSE;
- return TRUE;
- }
- - if( this->lastPID != 0xFFFF || this->lastCounter != 0xFF ){
- - if( this->lastPID != tsPacket->PID ){
- - //PID変更されたので不連続
- - this->duplicateFlag = FALSE;
- - return FALSE;
- - }else{
- - if( tsPacket->adaptation_field_control == 0x00 || tsPacket->adaptation_field_control == 0x02 ){
- - //ペイロードが存在しない場合は意味なし
- - this->duplicateFlag = FALSE;
- - if( tsPacket->adaptation_field_control == 0x02 || tsPacket->adaptation_field_control == 0x03 ){
- - if( tsPacket->transport_scrambling_control == 0 ){
- - if(tsPacket->discontinuity_indicator == 1){
- - //不連続の判定が必要
- - return FALSE;
- - }else{
- - return TRUE;
- - }
- - }else{
- - return TRUE;
- - }
- - }else{
- - return TRUE;
- - }
- - }
- - if( this->lastCounter == tsPacket->continuity_counter ){
- - if( tsPacket->adaptation_field_control == 0x01 || tsPacket->adaptation_field_control == 0x03 ){
- - if( tsPacket->transport_scrambling_control == 0 ){
- - if( this->duplicateFlag == FALSE ){
- - //重送?一応連続と判定
- - this->duplicateFlag = TRUE;
- - if( tsPacket->adaptation_field_control == 0x02 || tsPacket->adaptation_field_control == 0x03 ){
- - if(tsPacket->discontinuity_indicator == 1){
- - //不連続の判定が必要
- - return FALSE;
- - }else{
- - return TRUE;
- - }
- - }else{
- - return TRUE;
- - }
- - }else{
- - //前回重送と判断してるので不連続
- - this->duplicateFlag = FALSE;
- - return FALSE;
- - }
- - }else{
- - return TRUE;
- - }
- +
- + if (this->lastPID == 0xFFFF){
- + // 初回
- + return TRUE;
- + }
- +
- + if( this->lastPID != tsPacket->PID ){
- + //PID変更されたので不連続
- + this->duplicateFlag = FALSE;
- + return FALSE;
- + }
- +
- + if ((tsPacket->adaptation_field_control & 0x01) == 0){
- + //ペイロードが存在しない場合は意味なし
- + this->duplicateFlag = FALSE;
- + if( tsPacket->adaptation_field_control == 0x02 ){
- + if( tsPacket->transport_scrambling_control == 0 ){
- + if(tsPacket->discontinuity_indicator == 1){
- + //不連続の判定が必要
- + return FALSE;
- }
- }
- - if( this->lastCounter+1 != tsPacket->continuity_counter ){
- - if( this->lastCounter != 0x0F && tsPacket->continuity_counter != 0x00 ){
- - //カウンターが飛んだので不連続
- + }
- + return TRUE;
- + }
- +
- + if( this->lastCounter == tsPacket->continuity_counter ){
- + if (this->duplicateFlag == TRUE){
- + //前回重送と判断してるので不連続
- + this->duplicateFlag = FALSE;
- + return FALSE;
- + }
- + if (tsPacket->transport_scrambling_control == 0){
- + if( tsPacket->adaptation_field_control == 0x03 ){
- + if(tsPacket->discontinuity_indicator == 1){
- + //不連続の判定が必要
- + this->duplicateFlag = FALSE;
- return FALSE;
- }
- }
- }
- + //重送?一応連続と判定
- + this->duplicateFlag = TRUE;
- + return TRUE;
- }
- +
- + if( ((this->lastCounter+1) & 0x0F) != tsPacket->continuity_counter ){
- + //カウンターが飛んだので不連続
- + return FALSE;
- + }
- +
- return TRUE;
- }
- @@ -149,33 +142,21 @@
- Clear();
- return ERR_NOT_SUPPORT;
- }
- - }
- -
- - if( this->lastPID == 0xFFFF && this->lastCounter == 0xFF ){
- - //初回
- - if( tsPacket->payload_unit_start_indicator == 1 ){
- - //PSI
- - this->lastPID = tsPacket->PID;
- - this->lastCounter = tsPacket->continuity_counter;
- - if( this->PESMode == FALSE ){
- - return AddSectionBuff(tsPacket);
- - }else{
- - return AddPESBuff(tsPacket);
- - }
- - }else{
- - //スタート位置ではない
- - return ERR_ADD_NEXT;
- - }
- }else{
- - this->lastPID = tsPacket->PID;
- - this->lastCounter = tsPacket->continuity_counter;
- - if( this->PESMode == FALSE ){
- - return AddSectionBuff(tsPacket);
- - }else{
- - return AddPESBuff(tsPacket);
- + if (this->lastPID == 0xFFFF){
- + //初回だけどスタート位置ではない
- + return ERR_ADD_NEXT;
- }
- }
- + //PSI
- + this->lastPID = tsPacket->PID;
- + this->lastCounter = tsPacket->continuity_counter;
- + if( this->PESMode == FALSE ){
- + return AddSectionBuff(tsPacket);
- + }else{
- + return AddPESBuff(tsPacket);
- + }
- }
- BOOL CTSBuffUtil::IsPES()
- @@ -185,13 +166,13 @@
- BOOL CTSBuffUtil::GetSectionBuff(BYTE** sectionData, DWORD* dataSize)
- {
- - SAFE_DELETE(lastGetBuff);
- if( packetList.size() == 0 ){
- return FALSE;
- }
- - lastGetBuff = packetList[0];
- - packetList.erase(packetList.begin());
- + delete lastGetBuff;
- + lastGetBuff = packetList.front();
- + packetList.pop_front();
- *sectionData = lastGetBuff->data;
- *dataSize = lastGetBuff->dataSize;
- @@ -204,19 +185,16 @@
- if( tsPacket->data_byteSize == 0 || tsPacket->data_byte == NULL ){
- return ERR_ADD_NEXT;
- }
- - if( tsPacket->payload_unit_start_indicator != 1 && creatingBuff == NULL ){
- - return ERR_ADD_NEXT;
- - }
- - BYTE readSize = 0;
- - if( tsPacket->payload_unit_start_indicator == 1 ){
- - BOOL addBuff = FALSE;
- + BOOL addBuff = FALSE;
- + DWORD readSize;
- + if (tsPacket->payload_unit_start_indicator == 1){
- BYTE pointer_field = tsPacket->data_byte[0];
- - readSize++;
- - if( pointer_field != 0 ){
- + readSize = 1;
- + if (pointer_field != 0){
- //マルチセクション
- - if( creatingBuff != NULL ){
- - if( creatingBuff->dataSize - creatingBuff->copySize == pointer_field ){
- + if (creatingBuff != NULL){
- + if (creatingBuff->dataSize - creatingBuff->copySize == pointer_field){
- memcpy(creatingBuff->data + creatingBuff->copySize, tsPacket->data_byte + readSize, pointer_field);
- creatingBuff->copySize += pointer_field;
- packetList.push_back(creatingBuff);
- @@ -228,88 +206,83 @@
- SAFE_DELETE(creatingBuff);
- }
- }
- - }else{
- - if( creatingBuff != NULL ){
- + readSize += pointer_field;
- + if (readSize > tsPacket->data_byteSize){
- + //サイズが小さすぎる
- + _OutputDebugString(L"★psi size err PID 0x%04X\r\n", tsPacket->PID);
- SAFE_DELETE(creatingBuff);
- - creatingBuff = NULL;
- - }
- - }
- - readSize+=pointer_field;
- -
- - if( pointer_field + 1 > tsPacket->data_byteSize ){
- - //サイズが小さすぎる
- - SAFE_DELETE(creatingBuff);
- - _OutputDebugString(L"★psi size err PID 0x%04X\r\n", tsPacket->PID);
- - if( addBuff == TRUE ){
- - return TRUE;
- - }else{
- + if (addBuff == TRUE){
- + return TRUE;
- + }
- return FALSE;
- }
- - }
- -
- - //マルチセクションチェック
- - while( readSize+3 < tsPacket->data_byteSize ){
- - if( tsPacket->data_byte[readSize] == 0xFF &&
- - tsPacket->data_byte[readSize+1] == 0xFF &&
- - tsPacket->data_byte[readSize+2] == 0xFF){
- - //残りはスタッフィングバイト
- - break;
- - }
- -
- - SECTION_BUFF* buff = new SECTION_BUFF;
- - buff->dataSize = (((DWORD)tsPacket->data_byte[readSize+1]&0x0F) << 8 | tsPacket->data_byte[readSize+2]) + 3;
- - buff->data = new BYTE[buff->dataSize];
- -
- - if( buff->dataSize <= (DWORD)tsPacket->data_byteSize - readSize ){
- - buff->copySize = buff->dataSize;
- - }else{
- - buff->copySize = tsPacket->data_byteSize - readSize;
- - }
- -
- - memcpy( buff->data, tsPacket->data_byte+readSize, buff->copySize );
- - readSize += (BYTE)buff->copySize;
- -
- - if( buff->copySize == buff->dataSize ){
- - //このパケットだけで完結
- - packetList.push_back(buff);
- - }else{
- - //次のパケットが必要
- - creatingBuff = buff;
- - break;
- - }
- - }
- - if( creatingBuff == NULL ){
- - return TRUE;
- }else{
- - //次のパケット必要
- - if( addBuff == TRUE ){
- - return TRUE;
- - }else{
- - return ERR_ADD_NEXT;
- - }
- + SAFE_DELETE(creatingBuff);
- }
- }else{
- //複数パケットにまたがっている
- - DWORD copySize = 0;
- + if (creatingBuff == NULL){
- + //先頭からのデータを保持していなかったらエラー
- + return FALSE;
- + }
- + DWORD copySize;
- DWORD needSize = creatingBuff->dataSize - creatingBuff->copySize;
- -
- - if( needSize <= tsPacket->data_byteSize ){
- + if (needSize <= tsPacket->data_byteSize){
- copySize = needSize;
- }else{
- copySize = tsPacket->data_byteSize;
- }
- -
- - memcpy( creatingBuff->data + creatingBuff->copySize, tsPacket->data_byte, copySize );
- -
- + memcpy(creatingBuff->data + creatingBuff->copySize, tsPacket->data_byte, copySize);
- creatingBuff->copySize += copySize;
- - if( creatingBuff->dataSize == creatingBuff->copySize ){
- + if (creatingBuff->copySize == creatingBuff->dataSize){
- + //完成した
- packetList.push_back(creatingBuff);
- creatingBuff = NULL;
- - return TRUE;
- + addBuff = TRUE;
- }else{
- + //次のパケットが必要(creatingBuffはそのまま持ちこし)
- return ERR_ADD_NEXT;
- }
- + readSize = copySize;
- + }
- +
- + //マルチセクションチェック
- + while( readSize+3 < tsPacket->data_byteSize ){
- + if( tsPacket->data_byte[readSize] == 0xFF &&
- + tsPacket->data_byte[readSize+1] == 0xFF &&
- + tsPacket->data_byte[readSize+2] == 0xFF){
- + //残りはスタッフィングバイト
- + break;
- + }
- +
- + SECTION_BUFF* buff = new SECTION_BUFF;
- + buff->dataSize = (((DWORD)tsPacket->data_byte[readSize+1]&0x0F) << 8 | tsPacket->data_byte[readSize+2]) + 3;
- + buff->data = new BYTE[buff->dataSize];
- +
- + if( buff->dataSize <= (DWORD)tsPacket->data_byteSize - readSize ){
- + buff->copySize = buff->dataSize;
- + }else{
- + buff->copySize = tsPacket->data_byteSize - readSize;
- + }
- +
- + memcpy( buff->data, tsPacket->data_byte+readSize, buff->copySize );
- + readSize += buff->copySize;
- +
- + if( buff->copySize == buff->dataSize ){
- + //このパケットだけで完結
- + packetList.push_back(buff);
- + addBuff = TRUE;
- + }else{
- + //次のパケットが必要
- + creatingBuff = buff;
- + break;
- + }
- }
- + if( addBuff != TRUE ){
- + //このパケットでは一つも完成しなかった
- + return ERR_ADD_NEXT;
- + }
- + return TRUE;
- }
- DWORD CTSBuffUtil::AddPESBuff(CTSPacketUtil* tsPacket)
- @@ -317,9 +290,6 @@
- if( tsPacket->data_byteSize == 0 || tsPacket->data_byte == NULL ){
- return ERR_ADD_NEXT;
- }
- - if( tsPacket->payload_unit_start_indicator != 1 && creatingBuff == NULL ){
- - return ERR_ADD_NEXT;
- - }
- if( tsPacket->payload_unit_start_indicator == 1 ){
- if(tsPacket->data_byteSize < 6 || tsPacket->data_byte[0] != 0x00 || tsPacket->data_byte[1] != 0x00 || tsPacket->data_byte[2] != 0x01){
- @@ -358,28 +328,27 @@
- return ERR_ADD_NEXT;
- }else{
- packetList.push_back(buff);
- - creatingBuff = NULL;
- return TRUE;
- }
- }
- }else{
- //複数パケットにまたがっている
- - if( creatingBuff->unknownSize == TRUE ){
- + if (creatingBuff == NULL){
- + return ERR_ADD_NEXT;
- + }
- + if (creatingBuff->unknownSize == TRUE){
- if( tsPacket->data_byteSize + creatingBuff->copySize > creatingBuff->dataSize ){
- BYTE* newBuff = new BYTE[creatingBuff->dataSize*2];
- memcpy(newBuff, creatingBuff->data, creatingBuff->copySize);
- - memcpy(newBuff + creatingBuff->copySize, tsPacket->data_byte, tsPacket->data_byteSize);
- - SAFE_DELETE_ARRAY(creatingBuff->data);
- + delete[] creatingBuff->data;
- creatingBuff->data = newBuff;
- creatingBuff->dataSize = creatingBuff->dataSize*2;
- - creatingBuff->copySize += tsPacket->data_byteSize;
- - }else{
- - memcpy(creatingBuff->data + creatingBuff->copySize, tsPacket->data_byte, tsPacket->data_byteSize);
- - creatingBuff->copySize += tsPacket->data_byteSize;
- }
- + memcpy(creatingBuff->data + creatingBuff->copySize, tsPacket->data_byte, tsPacket->data_byteSize);
- + creatingBuff->copySize += tsPacket->data_byteSize;
- return ERR_ADD_NEXT;
- }else{
- - DWORD copySize = 0;
- + DWORD copySize;
- DWORD needSize = creatingBuff->dataSize - creatingBuff->copySize;
- if( needSize <= tsPacket->data_byteSize ){
- diff -u -r -N a/EDCB-work-plus-s/Common/TSBuffUtil.h b/EDCB-work-plus-s/Common/TSBuffUtil.h
- --- a/EDCB-work-plus-s/Common/TSBuffUtil.h 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/Common/TSBuffUtil.h 2015-04-29 15:44:46.000000000 +0900
- @@ -31,7 +31,7 @@
- SAFE_DELETE_ARRAY(data);
- };
- }SECTION_BUFF;
- - vector<SECTION_BUFF*> packetList;
- + deque<SECTION_BUFF*> packetList;
- WORD lastPID;
- BYTE lastCounter;
- diff -u -r -N a/EDCB-work-plus-s/Common/TSPacketUtil.cpp b/EDCB-work-plus-s/Common/TSPacketUtil.cpp
- --- a/EDCB-work-plus-s/Common/TSPacketUtil.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/Common/TSPacketUtil.cpp 2015-05-04 10:31:48.000000000 +0900
- @@ -13,6 +13,116 @@
- BOOL CTSPacketUtil::Set188TS(BYTE* data, DWORD dataSize)
- {
- +#ifdef DELETE_UNUSED_MEMBER
- +/*
- + if( data == NULL || dataSize != 188){
- + return FALSE;
- + }
- +*/
- + data_byteSize = 0;
- +
- + if( data[0] != 0x47 ){
- + return FALSE;
- + }
- + //transport_error_indicator
- + if ((data[1] >> 7) & 0x1){
- + return FALSE;
- + }
- + payload_unit_start_indicator = (data[1] >> 6) & 0x1;
- + PID = (((WORD)data[1] & 0x1f) << 8) | data[2];
- + transport_scrambling_control = (data[3] >> 6) & 0x3;
- + adaptation_field_control = (data[3] >> 4) & 0x3;
- + continuity_counter = data[3] & 0x0f;
- + DWORD readSize = 4;
- +
- + if( adaptation_field_control & 0x02 ){
- + adaptation_field_length = data[4];
- + readSize++;
- + if( adaptation_field_length > 0 ){
- + /*
- + discontinuity_indicator : 1;
- + random_access_indicator : 1;
- + elementary_stream_priority_indicator : 1;
- + PCR_flag : 1;
- + OPCR_flag : 1;
- + splicing_point_flag : 1;
- + transport_private_data_flag : 1;
- + adaptation_field_extension_flag : 1;
- + */
- + BYTE flags = data[readSize];
- + discontinuity_indicator = (flags >> 7) & 0x1;
- + random_access_indicator = (flags >> 6) & 0x1;
- + PCR_flag = (flags >> 4) & 0x1;
- + OPCR_flag = (flags >> 3) & 0x1;
- + readSize++;
- + if( PCR_flag ){
- + program_clock_reference_base = ((ULONGLONG)data[readSize])<<25 |
- + ((ULONGLONG)data[readSize+1])<<17 |
- + ((ULONGLONG)data[readSize+2])<<9 |
- + ((ULONGLONG)data[readSize+3])<<1 |
- + ((ULONGLONG)data[readSize+4])>>7;
- + readSize+=6;
- + }
- + if( OPCR_flag ){
- + readSize+=6;
- + }
- + if( flags & 0x04 ){
- + readSize++;
- + }
- + if( flags & 0x02 ){
- + readSize += 1 + data[readSize];
- + }
- + if( flags & 0x01 ){
- + if( readSize + 1 >= 188 ){
- + return FALSE;
- + }
- + /*
- + ltw_flag : 1
- + piecewise_rate_flag : 1
- + seamless_splice_flag : 1
- + reserved : 5
- + */
- + BYTE flags2 = data[readSize+1];
- + readSize+=2;
- + if( flags2 & 0x80 ){
- + readSize+=2;
- + }
- + if( flags2 & 0x40 ){
- + readSize+=3;
- + }
- + if( flags2 & 0x20 ){
- + readSize+=5;
- + }
- + }
- + //ここまでのデータのどれかが異常なのでエラー
- + if( readSize > 188 ){
- + return FALSE;
- + }
- + readSize = 5 + adaptation_field_length;
- + }else{
- + discontinuity_indicator = 0;
- + random_access_indicator = 0;
- + PCR_flag = 0;
- + OPCR_flag = 0;
- + }
- + }else{
- + adaptation_field_length = 0;
- + discontinuity_indicator = 0;
- + random_access_indicator = 0;
- + PCR_flag = 0;
- + OPCR_flag = 0;
- + }
- +
- + if( adaptation_field_control & 0x01 ){
- + if( readSize >= 188 ){
- + return FALSE;
- + }
- + data_byteSize = (BYTE)(188-readSize);
- + data_byte = data+readSize;
- + }
- +
- + return TRUE;
- +#else
- if( data == NULL || dataSize != 188){
- return FALSE;
- }
- @@ -145,4 +255,5 @@
- }
- }
- return TRUE;
- +#endif
- }
- diff -u -r -N a/EDCB-work-plus-s/Common/TSPacketUtil.h b/EDCB-work-plus-s/Common/TSPacketUtil.h
- --- a/EDCB-work-plus-s/Common/TSPacketUtil.h 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/Common/TSPacketUtil.h 2015-05-01 05:03:58.000000000 +0900
- @@ -84,12 +84,29 @@
- }
- */
- +#define DELETE_UNUSED_MEMBER
- #include "Util.h"
- class CTSPacketUtil
- {
- public:
- +#ifdef DELETE_UNUSED_MEMBER
- + BYTE payload_unit_start_indicator;
- + WORD PID;
- + BYTE transport_scrambling_control;
- + BYTE adaptation_field_control;
- + BYTE continuity_counter;
- + BYTE data_byteSize;
- + BYTE* data_byte;
- +
- + BYTE adaptation_field_length;
- + BYTE discontinuity_indicator;
- + BYTE random_access_indicator;
- + BYTE PCR_flag;
- + BYTE OPCR_flag;
- + ULONGLONG program_clock_reference_base;
- +#else
- BYTE sync_byte;
- BYTE transport_error_indicator;
- BYTE payload_unit_start_indicator;
- @@ -127,6 +144,7 @@
- DWORD piecewise_rate;
- BYTE splice_type;
- ULONGLONG DTS_next_AU;
- +#endif
- public:
- CTSPacketUtil(void);
- diff -u -r -N a/EDCB-work-plus-s/Common/Util.h b/EDCB-work-plus-s/Common/Util.h
- --- a/EDCB-work-plus-s/Common/Util.h 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/Common/Util.h 2015-05-01 05:01:25.000000000 +0900
- @@ -18,6 +18,7 @@
- #include <string>
- #include <map>
- #include <vector>
- +#include <deque>
- #include <algorithm>
- #endif
- using std::string;
- @@ -26,6 +27,7 @@
- using std::map;
- using std::multimap;
- using std::vector;
- +using std::deque;
- #include <TCHAR.h>
- #include <windows.h>
- diff -u -r -N a/EDCB-work-plus-s/EpgDataCap3/EpgDataCap3/AribDescriptor.cpp b/EDCB-work-plus-s/EpgDataCap3/EpgDataCap3/AribDescriptor.cpp
- --- a/EDCB-work-plus-s/EpgDataCap3/EpgDataCap3/AribDescriptor.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/EpgDataCap3/EpgDataCap3/AribDescriptor.cpp 2015-05-10 10:46:28.000000000 +0900
- @@ -908,6 +908,7 @@
- CDescriptor::CDescriptor()
- {
- + rootProperty.reserve(8);
- }
- CDescriptor::~CDescriptor()
- @@ -980,6 +981,7 @@
- //ローカル参照用スタック
- std::vector<DESCRIPTOR_PROPERTY> localProperty;
- + localProperty.reserve(8);
- int readSize = DecodeProperty(data, dataSize, &parser, &this->rootProperty, &localProperty);
- if( readSize < 0 ){
- diff -u -r -N a/EDCB-work-plus-s/EpgDataCap3/EpgDataCap3/DecodeUtil.cpp b/EDCB-work-plus-s/EpgDataCap3/EpgDataCap3/DecodeUtil.cpp
- --- a/EDCB-work-plus-s/EpgDataCap3/EpgDataCap3/DecodeUtil.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/EpgDataCap3/EpgDataCap3/DecodeUtil.cpp 2015-05-10 10:42:23.000000000 +0900
- @@ -36,7 +36,7 @@
- {
- map<WORD, CTSBuffUtil*>::iterator itr;
- for( itr = this->buffUtilMap.begin(); itr != this->buffUtilMap.end(); itr++ ){
- - SAFE_DELETE(itr->second);
- + delete itr->second;
- }
- this->buffUtilMap.clear();
- @@ -44,7 +44,7 @@
- map<WORD, CPMTTable*>::iterator itrPmt;
- for( itrPmt = this->pmtMap.begin(); itrPmt != this->pmtMap.end(); itrPmt++ ){
- - SAFE_DELETE(itrPmt->second);
- + delete itrPmt->second;
- }
- this->pmtMap.clear();
- @@ -71,7 +71,7 @@
- itr = this->buffUtilMap.begin();
- while( itr != this->buffUtilMap.end() ){
- if( itr->first != noClearPid ){
- - SAFE_DELETE(itr->second);
- + delete itr->second;
- this->buffUtilMap.erase(itr++);
- }else{
- itr++;
- @@ -87,7 +87,7 @@
- map<WORD, CPMTTable*>::iterator itrPmt;
- for( itrPmt = this->pmtMap.begin(); itrPmt != this->pmtMap.end(); itrPmt++ ){
- - SAFE_DELETE(itrPmt->second);
- + delete itrPmt->second;
- }
- this->pmtMap.clear();
- @@ -109,87 +109,84 @@
- void CDecodeUtil::AddTSData(BYTE* data)
- {
- - {
- - CTSPacketUtil tsPacket;
- - if( tsPacket.Set188TS(data, 188) == TRUE ){
- - if( tsPacket.PID == 0x1FFF ){
- - return;
- - }
- - CTSBuffUtil* buffUtil = NULL;
- -
- - map<WORD, CTSBuffUtil*>::iterator itr;
- - itr = this->buffUtilMap.find( tsPacket.PID );
- - if( itr == this->buffUtilMap.end() ){
- - //まだPIDがないので新規
- - buffUtil = new CTSBuffUtil;
- - this->buffUtilMap.insert(pair<WORD, CTSBuffUtil*>(tsPacket.PID, buffUtil));
- - }else{
- - buffUtil = itr->second;
- - }
- - if( buffUtil->Add188TS(&tsPacket) == TRUE ){
- - BYTE* section = NULL;
- - DWORD sectionSize = 0;
- - while( buffUtil->GetSectionBuff( §ion, §ionSize ) == TRUE ){
- - if( buffUtil->IsPES() == TRUE ){
- - continue;
- - }
- - CTableUtil tableUtil;
- -
- - vector<TABLE_DATA*> tableList;
- - DWORD decodeReadSize = 0;
- - if( tableUtil.Decode(section, sectionSize, &tableList, &decodeReadSize) == TRUE ){
- - for( size_t j=0; j<tableList.size(); j++ ){
- - if( tableList[j]->PATTable != NULL ){
- - if( CheckPAT(tsPacket.PID, tableList[j]->PATTable) == TRUE ){
- - tableList[j]->PATTable = NULL;
- - }
- - }else if( tableList[j]->PMTTable != NULL ){
- - if( CheckPMT(tsPacket.PID, tableList[j]->PMTTable) == TRUE ){
- - tableList[j]->PMTTable = NULL;
- - }
- - }else if( tableList[j]->NITTable != NULL ){
- - if( CheckNIT(tsPacket.PID, tableList[j]->NITTable) == TRUE ){
- - tableList[j]->NITTable = NULL;
- - }
- - }else if( tableList[j]->SDTTable != NULL ){
- - if( CheckSDT(tsPacket.PID, tableList[j]->SDTTable) == TRUE ){
- - tableList[j]->SDTTable = NULL;
- - }
- - }else if( tableList[j]->TOTTable != NULL ){
- - if( CheckTOT(tsPacket.PID, tableList[j]->TOTTable) == TRUE ){
- - tableList[j]->TOTTable = NULL;
- - }
- - }else if( tableList[j]->TDTTable != NULL ){
- - if( CheckTDT(tsPacket.PID, tableList[j]->TDTTable) == TRUE ){
- - tableList[j]->TDTTable = NULL;
- - }
- - }else if( tableList[j]->EITTable != NULL ){
- - if( CheckEIT(tsPacket.PID, tableList[j]->EITTable) == TRUE ){
- - tableList[j]->EITTable = NULL;
- - }
- - }else if( tableList[j]->BITTable != NULL ){
- - if( CheckBIT(tsPacket.PID, tableList[j]->BITTable) == TRUE ){
- - tableList[j]->BITTable = NULL;
- - }
- - }else if( tableList[j]->SITTable != NULL ){
- - if( CheckSIT(tsPacket.PID, tableList[j]->SITTable) == TRUE ){
- - tableList[j]->SITTable = NULL;
- - }
- - }else if( tableList[j]->EITTable_SD != NULL ){
- - if( CheckEIT_SD(tsPacket.PID, tableList[j]->EITTable_SD) == TRUE ){
- - tableList[j]->EITTable_SD = NULL;
- - }
- - }else if( tableList[j]->EITTable_SD2 != NULL ){
- - if( CheckEIT_SD2(tsPacket.PID, tableList[j]->EITTable_SD2) == TRUE ){
- - tableList[j]->EITTable_SD2 = NULL;
- - }
- - }
- - SAFE_DELETE(tableList[j]);
- + CTSPacketUtil tsPacket;
- + if( tsPacket.Set188TS(data, 188) == TRUE ){
- + if( tsPacket.PID == 0x1FFF ){
- + return;
- + }
- + CTSBuffUtil* buffUtil;
- +
- + map<WORD, CTSBuffUtil*>::iterator itr;
- + itr = this->buffUtilMap.find( tsPacket.PID );
- + if( itr == this->buffUtilMap.end() ){
- + //まだPIDがないので新規
- + buffUtil = new CTSBuffUtil;
- + this->buffUtilMap.insert(pair<WORD, CTSBuffUtil*>(tsPacket.PID, buffUtil));
- + }else{
- + buffUtil = itr->second;
- + }
- + if( buffUtil->Add188TS(&tsPacket) == TRUE ){
- + BYTE* section;
- + DWORD sectionSize;
- + while( buffUtil->GetSectionBuff( §ion, §ionSize ) == TRUE ){
- + if( buffUtil->IsPES() == TRUE ){
- + continue;
- + }
- + CTableUtil tableUtil;
- +
- + vector<TABLE_DATA*> tableList;
- + if( tableUtil.Decode(section, sectionSize, &tableList, NULL) == TRUE ){
- + for( size_t j=0; j<tableList.size(); j++ ){
- + BOOL ret;
- + switch( tableList[j]->type ){
- + case TABLE_DATA::TYPE_PAT:
- + ret = CheckPAT(tsPacket.PID, static_cast<CPATTable*>(tableList[j]->table));
- + break;
- + case TABLE_DATA::TYPE_PMT:
- + ret = CheckPMT(tsPacket.PID, static_cast<CPMTTable*>(tableList[j]->table));
- + break;
- + case TABLE_DATA::TYPE_NIT:
- + ret = CheckNIT(tsPacket.PID, static_cast<CNITTable*>(tableList[j]->table));
- + break;
- + case TABLE_DATA::TYPE_SDT:
- + ret = CheckSDT(tsPacket.PID, static_cast<CSDTTable*>(tableList[j]->table));
- + break;
- + case TABLE_DATA::TYPE_EIT:
- + ret = CheckEIT(tsPacket.PID, static_cast<CEITTable*>(tableList[j]->table));
- + break;
- + case TABLE_DATA::TYPE_TDT:
- + ret = CheckTDT(tsPacket.PID, static_cast<CTDTTable*>(tableList[j]->table));
- + break;
- + case TABLE_DATA::TYPE_TOT:
- + ret = CheckTOT(tsPacket.PID, static_cast<CTOTTable*>(tableList[j]->table));
- + break;
- + case TABLE_DATA::TYPE_SIT:
- + ret = CheckSIT(tsPacket.PID, static_cast<CSITTable*>(tableList[j]->table));
- + break;
- + case TABLE_DATA::TYPE_BIT:
- + ret = CheckBIT(tsPacket.PID, static_cast<CBITTable*>(tableList[j]->table));
- + break;
- + case TABLE_DATA::TYPE_EIT_SD:
- + ret = CheckEIT_SD(tsPacket.PID, static_cast<CEITTable_SD*>(tableList[j]->table));
- + break;
- + case TABLE_DATA::TYPE_EIT_SD2:
- + ret = CheckEIT_SD2(tsPacket.PID, static_cast<CEITTable_SD2*>(tableList[j]->table));
- + break;
- + case TABLE_DATA::TYPE_CAT:
- + case TABLE_DATA::TYPE_BAT:
- + case TABLE_DATA::TYPE_SDTT:
- + case TABLE_DATA::TYPE_CDT:
- + default:
- + ret = FALSE;
- }
- - }else{
- - if( section[0] == 0 ){
- - _OutputDebugString(L"★pid 0x%04X\r\n", tsPacket.PID);
- + if (ret == TRUE){
- + tableList[j]->table = NULL;
- }
- + delete tableList[j];
- + }
- + }else{
- + if( section[0] == 0 ){
- + _OutputDebugString(L"★pid 0x%04X\r\n", tsPacket.PID);
- }
- }
- }
- @@ -213,7 +210,7 @@
- this->patInfo = pat;
- }else if(this->patInfo->version_number != pat->version_number){
- //バージョン変わった
- - SAFE_DELETE(this->patInfo);
- + delete this->patInfo;
- this->patInfo = pat;
- }else{
- //変更なし
- @@ -237,7 +234,7 @@
- }else{
- if( itrPmt->second->version_number != pmt->version_number ){
- //バージョン変わった
- - SAFE_DELETE(itrPmt->second);
- + delete itrPmt->second;
- this->pmtMap.erase(itrPmt);
- this->pmtMap.insert(pair<WORD, CPMTTable*>(PID, pmt));
- @@ -273,7 +270,7 @@
- if( this->nitActualInfo->network_id != nit->network_id ){
- //NID変わったのでネットワーク変わった
- ChangeTSIDClear(PID);
- - SAFE_DELETE(this->nitActualInfo);
- + delete this->nitActualInfo;
- this->nitActualInfo = new NIT_SECTION_INFO;
- this->nitActualInfo->network_id = nit->network_id;
- this->nitActualInfo->version_number = nit->version_number;
- @@ -281,7 +278,7 @@
- this->nitActualInfo->nitSection.insert(pair<BYTE, CNITTable*>(nit->section_number, nit));
- }else if(this->nitActualInfo->version_number != nit->version_number){
- //バージョン変わった
- - SAFE_DELETE(this->nitActualInfo);
- + delete this->nitActualInfo;
- this->nitActualInfo = new NIT_SECTION_INFO;
- this->nitActualInfo->network_id = nit->network_id;
- this->nitActualInfo->version_number = nit->version_number;
- @@ -297,7 +294,7 @@
- if( itr->second->TSInfoList[0]->original_network_id != nit->TSInfoList[0]->original_network_id ){
- //ONID変わったのでネットワーク変わった
- ChangeTSIDClear(PID);
- - SAFE_DELETE(this->nitActualInfo);
- + delete this->nitActualInfo;
- this->nitActualInfo = new NIT_SECTION_INFO;
- this->nitActualInfo->network_id = nit->network_id;
- this->nitActualInfo->version_number = nit->version_number;
- @@ -307,7 +304,7 @@
- if( itr->second->TSInfoList[0]->transport_stream_id != nit->TSInfoList[0]->transport_stream_id ){
- //TSID変わったのでネットワーク変わった
- ChangeTSIDClear(PID);
- - SAFE_DELETE(this->nitActualInfo);
- + delete this->nitActualInfo;
- this->nitActualInfo = new NIT_SECTION_INFO;
- this->nitActualInfo->network_id = nit->network_id;
- this->nitActualInfo->version_number = nit->version_number;
- @@ -411,7 +408,7 @@
- if( this->sdtActualInfo->original_network_id != sdt->original_network_id ){
- //ONID変わったのでネットワーク変わった
- ChangeTSIDClear(PID);
- - SAFE_DELETE(this->sdtActualInfo);
- + delete this->sdtActualInfo;
- this->sdtActualInfo = new SDT_SECTION_INFO;
- this->sdtActualInfo->original_network_id = sdt->original_network_id;
- this->sdtActualInfo->transport_stream_id = sdt->transport_stream_id;
- @@ -421,7 +418,7 @@
- }else if( this->sdtActualInfo->transport_stream_id != sdt->transport_stream_id ){
- //TSID変わったのでチャンネル変わった
- ChangeTSIDClear(PID);
- - SAFE_DELETE(this->sdtActualInfo);
- + delete this->sdtActualInfo;
- this->sdtActualInfo = new SDT_SECTION_INFO;
- this->sdtActualInfo->original_network_id = sdt->original_network_id;
- this->sdtActualInfo->transport_stream_id = sdt->transport_stream_id;
- @@ -430,7 +427,7 @@
- this->sdtActualInfo->sdtSection.insert(pair<BYTE, CSDTTable*>(sdt->section_number, sdt));
- }else if( this->sdtActualInfo->version_number != sdt->version_number ){
- //バージョン変わった
- - SAFE_DELETE(this->sdtActualInfo);
- + delete this->sdtActualInfo;
- this->sdtActualInfo = new SDT_SECTION_INFO;
- this->sdtActualInfo->original_network_id = sdt->original_network_id;
- this->sdtActualInfo->transport_stream_id = sdt->transport_stream_id;
- @@ -584,7 +581,7 @@
- this->bitInfo = bit;
- }else if( this->bitInfo->version_number != bit->version_number ){
- //バージョン変わった
- - SAFE_DELETE(this->bitInfo);
- + delete this->bitInfo;
- this->bitInfo = bit;
- }else{
- //変化なし
- @@ -641,7 +638,7 @@
- }else{
- if( this->sitInfo->version_number != sit->version_number ){
- //バージョン変わった
- - SAFE_DELETE(this->sitInfo);
- + delete this->sitInfo;
- this->sitInfo = sit;
- }else{
- //変化なし
- diff -u -r -N a/EDCB-work-plus-s/EpgDataCap3/EpgDataCap3/Table/TableUtil.cpp b/EDCB-work-plus-s/EpgDataCap3/EpgDataCap3/Table/TableUtil.cpp
- --- a/EDCB-work-plus-s/EpgDataCap3/EpgDataCap3/Table/TableUtil.cpp 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/EpgDataCap3/EpgDataCap3/Table/TableUtil.cpp 2015-05-01 09:48:07.000000000 +0900
- @@ -13,8 +13,8 @@
- {
- if( tableList != NULL ){
- vector<TABLE_DATA*>::iterator itr;
- - for( itr = tableList->begin(); itr != tableList->end(); itr++ ){
- - SAFE_DELETE(*itr);
- + for( itr = tableList->begin(); itr != tableList->end(); ++itr ){
- + delete *itr;
- }
- tableList->clear();
- }
- @@ -27,156 +27,95 @@
- }
- DWORD decodeSize = 0;
- while( decodeSize < dataSize ){
- - DWORD readSize = 0;
- TABLE_DATA* item = new TABLE_DATA;
- - if( data[decodeSize] == 0x00 ){
- - item->PATTable = new CPATTable;
- - if( item->PATTable->Decode(data + decodeSize, dataSize-decodeSize, &readSize) == FALSE ){
- - SAFE_DELETE(item);
- - Clear(tableList);
- - return FALSE;
- - }else{
- - tableList->push_back(item);
- - }
- - }else if( data[decodeSize] == 0x01 ){
- - item->CATTable = new CCATTable;
- - if( item->CATTable->Decode(data + decodeSize, dataSize-decodeSize, &readSize) == FALSE ){
- - SAFE_DELETE(item);
- - Clear(tableList);
- - return FALSE;
- + switch (data[decodeSize]){
- + case 0x00:
- + item->type = TABLE_DATA::TYPE_PAT;
- + item->table = new CPATTable;
- + break;
- + case 0x01:
- + item->type = TABLE_DATA::TYPE_CAT;
- + item->table = new CCATTable;
- + break;
- + case 0x02:
- + item->type = TABLE_DATA::TYPE_PMT;
- + item->table = new CPMTTable;
- + break;
- + case 0x40:
- + case 0x41:
- + item->type = TABLE_DATA::TYPE_NIT;
- + item->table = new CNITTable;
- + break;
- + case 0x42:
- + case 0x46:
- + item->type = TABLE_DATA::TYPE_SDT;
- + item->table = new CSDTTable;
- + break;
- + case 0x4A:
- + item->type = TABLE_DATA::TYPE_BAT;
- + item->table = new CBATTable;
- + break;
- + case 0x70:
- + item->type = TABLE_DATA::TYPE_TDT;
- + item->table = new CTDTTable;
- + break;
- + case 0x73:
- + item->type = TABLE_DATA::TYPE_TOT;
- + item->table = new CTOTTable;
- + break;
- + case 0xC8:
- + item->type = TABLE_DATA::TYPE_CDT;
- + item->table = new CCDTTable;
- + break;
- + case 0xC3:
- + item->type = TABLE_DATA::TYPE_SDTT;
- + item->table = new CSDTTTable;
- + break;
- + case 0xC4:
- + item->type = TABLE_DATA::TYPE_BIT;
- + item->table = new CBITTable;
- + break;
- + case 0x7F:
- + item->type = TABLE_DATA::TYPE_SIT;
- + item->table = new CSITTable;
- + break;
- + case 0xA4:
- + case 0xA7:
- + item->type = TABLE_DATA::TYPE_EIT_SD;
- + item->table = new CEITTable_SD;
- + break;
- + case 0xA2:
- + case 0xA3:
- + item->type = TABLE_DATA::TYPE_EIT_SD2;
- + item->table = new CEITTable_SD2;
- + break;
- + default:
- + if( 0x4E <= data[decodeSize] && data[decodeSize] <= 0x6F ){
- + item->type = TABLE_DATA::TYPE_EIT;
- + item->table = new CEITTable;
- + }else if( data[decodeSize] == 0xFF ){
- + //stuffing
- + delete item;
- + decodeSize = dataSize;
- + continue;
- }else{
- - tableList->push_back(item);
- - }
- - }else if( data[decodeSize] == 0x02 ){
- - item->PMTTable = new CPMTTable;
- - if( item->PMTTable->Decode(data + decodeSize, dataSize-decodeSize, &readSize) == FALSE ){
- - SAFE_DELETE(item);
- + //_OutputDebugString(L"++CTableUtil:: err UnknownTable 0x%02X\r\n", data[decodeSize]);
- + delete item;
- Clear(tableList);
- return FALSE;
- - }else{
- - tableList->push_back(item);
- }
- - }else if( data[decodeSize] == 0x40 || data[decodeSize] == 0x41 ){
- - item->NITTable = new CNITTable;
- - if( item->NITTable->Decode(data + decodeSize, dataSize-decodeSize, &readSize) == FALSE ){
- - SAFE_DELETE(item);
- - Clear(tableList);
- - return FALSE;
- - }else{
- - tableList->push_back(item);
- - }
- - }else if( data[decodeSize] == 0x42 || data[decodeSize] == 0x46 ){
- - item->SDTTable = new CSDTTable;
- - if( item->SDTTable->Decode(data + decodeSize, dataSize-decodeSize, &readSize) == FALSE ){
- - SAFE_DELETE(item);
- - Clear(tableList);
- - return FALSE;
- - }else{
- - tableList->push_back(item);
- - }
- - }else if( data[decodeSize] == 0x4A ){
- - item->BATTable = new CBATTable;
- - if( item->BATTable->Decode(data + decodeSize, dataSize-decodeSize, &readSize) == FALSE ){
- - SAFE_DELETE(item);
- - Clear(tableList);
- - return FALSE;
- - }else{
- - tableList->push_back(item);
- - }
- - }else if( 0x4E <= data[decodeSize] && data[decodeSize] <= 0x6F ){
- - item->EITTable = new CEITTable;
- - if( item->EITTable->Decode(data + decodeSize, dataSize-decodeSize, &readSize) == FALSE ){
- - SAFE_DELETE(item);
- - Clear(tableList);
- - return FALSE;
- - }else{
- - tableList->push_back(item);
- - }
- - }else if( data[decodeSize] == 0x70 ){
- - item->TDTTable = new CTDTTable;
- - if( item->TDTTable->Decode(data + decodeSize, dataSize-decodeSize, &readSize) == FALSE ){
- - SAFE_DELETE(item);
- - Clear(tableList);
- - return FALSE;
- - }else{
- - tableList->push_back(item);
- - }
- - }else if( data[decodeSize] == 0x73 ){
- - item->TOTTable = new CTOTTable;
- - if( item->TOTTable->Decode(data + decodeSize, dataSize-decodeSize, &readSize) == FALSE ){
- - SAFE_DELETE(item);
- - Clear(tableList);
- - return FALSE;
- - }else{
- - tableList->push_back(item);
- - }
- - }else if( data[decodeSize] == 0xC8 ){
- - item->CDTTable = new CCDTTable;
- - if( item->CDTTable->Decode(data + decodeSize, dataSize-decodeSize, &readSize) == FALSE ){
- - SAFE_DELETE(item);
- - Clear(tableList);
- - return FALSE;
- - }else{
- - tableList->push_back(item);
- - }
- - }else if( data[decodeSize] == 0xC3 ){
- - item->SDTTTable = new CSDTTTable;
- - if( item->SDTTTable->Decode(data + decodeSize, dataSize-decodeSize, &readSize) == FALSE ){
- - SAFE_DELETE(item);
- - Clear(tableList);
- - return FALSE;
- - }else{
- - tableList->push_back(item);
- - }
- - }else if( data[decodeSize] == 0xC4 ){
- - item->BITTable = new CBITTable;
- - if( item->BITTable->Decode(data + decodeSize, dataSize-decodeSize, &readSize) == FALSE ){
- - SAFE_DELETE(item);
- - Clear(tableList);
- - return FALSE;
- - }else{
- - tableList->push_back(item);
- - }
- - }else if( data[decodeSize] == 0x7F ){
- - item->SITTable = new CSITTable;
- - if( item->SITTable->Decode(data + decodeSize, dataSize-decodeSize, &readSize) == FALSE ){
- - SAFE_DELETE(item);
- - Clear(tableList);
- - return FALSE;
- - }else{
- - tableList->push_back(item);
- - }
- - }else if( 0xA4 == data[decodeSize] || 0xA7 == data[decodeSize]){
- - item->EITTable_SD = new CEITTable_SD;
- - if( item->EITTable_SD->Decode(data + decodeSize, dataSize-decodeSize, &readSize) == FALSE ){
- - SAFE_DELETE(item);
- - Clear(tableList);
- - return FALSE;
- - }else{
- - tableList->push_back(item);
- - }
- - }else if( 0xA2 == data[decodeSize] || 0xA3 == data[decodeSize]){
- - item->EITTable_SD2 = new CEITTable_SD2;
- - if( item->EITTable_SD2->Decode(data + decodeSize, dataSize-decodeSize, &readSize) == FALSE ){
- - SAFE_DELETE(item);
- - Clear(tableList);
- - return FALSE;
- - }else{
- - tableList->push_back(item);
- - }
- - }else if( data[decodeSize] == 0xFF ){
- - //stuffing
- - decodeSize = dataSize;
- - }else{
- - //_OutputDebugString(L"++CTableUtil:: err UnknownTable 0x%02X\r\n", data[decodeSize]);
- - SAFE_DELETE(item);
- + }
- + DWORD readSize;
- + if( item->table->Decode(data+decodeSize, dataSize-decodeSize, &readSize) == FALSE ){
- + delete item;
- Clear(tableList);
- return FALSE;
- }
- + tableList->push_back(item);
- decodeSize += readSize;
- }
- if( decodeReadSize != NULL ){
- - *decodeReadSize = dataSize;
- + *decodeReadSize = decodeSize;
- }
- return TRUE;
- }
- diff -u -r -N a/EDCB-work-plus-s/EpgDataCap3/EpgDataCap3/Table/TableUtilDef.h b/EDCB-work-plus-s/EpgDataCap3/EpgDataCap3/Table/TableUtilDef.h
- --- a/EDCB-work-plus-s/EpgDataCap3/EpgDataCap3/Table/TableUtilDef.h 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/EpgDataCap3/EpgDataCap3/Table/TableUtilDef.h 2015-05-01 03:30:34.000000000 +0900
- @@ -1,6 +1,7 @@
- #ifndef __TABLE_UTIL_DEF_H__
- #define __TABLE_UTIL_DEF_H__
- +#include "PSITable.h"
- #include "BATTable.h"
- #include "CATTable.h"
- #include "EITTable.h"
- @@ -18,55 +19,33 @@
- #include "EITTable_SD2.h"
- typedef struct _TABLE_DATA{
- - CBATTable* BATTable;
- - CCATTable* CATTable;
- - CEITTable* EITTable;
- - CNITTable* NITTable;
- - CPATTable* PATTable;
- - CPMTTable* PMTTable;
- - CSDTTable* SDTTable;
- - CTDTTable* TDTTable;
- - CTOTTable* TOTTable;
- - CCDTTable* CDTTable;
- - CSDTTTable* SDTTTable;
- - CBITTable* BITTable;
- - CSITTable* SITTable;
- - CEITTable_SD* EITTable_SD;
- - CEITTable_SD2* EITTable_SD2;
- + enum t_type{
- + TYPE_PAT = 0,
- + TYPE_PMT,
- + TYPE_CAT,
- + TYPE_NIT,
- + TYPE_SDT,
- + TYPE_BAT,
- + TYPE_EIT,
- + TYPE_TDT,
- + TYPE_TOT,
- + TYPE_SIT,
- + TYPE_SDTT,
- + TYPE_BIT,
- + TYPE_EIT_SD,
- + TYPE_EIT_SD2,
- + TYPE_CDT,
- + TYPE_OTHER,
- + };
- + t_type type;
- + CPSITable* table;
- _TABLE_DATA(void){
- - BATTable = NULL;
- - CATTable = NULL;
- - EITTable = NULL;
- - NITTable = NULL;
- - PATTable = NULL;
- - PMTTable = NULL;
- - SDTTable = NULL;
- - TDTTable = NULL;
- - TOTTable = NULL;
- - CDTTable = NULL;
- - SDTTTable = NULL;
- - BITTable = NULL;
- - SITTable = NULL;
- - EITTable_SD = NULL;
- - EITTable_SD2 = NULL;
- + type = TYPE_OTHER;
- + table = NULL;
- };
- ~_TABLE_DATA(void){
- - SAFE_DELETE(BATTable);
- - SAFE_DELETE(CATTable);
- - SAFE_DELETE(EITTable);
- - SAFE_DELETE(NITTable);
- - SAFE_DELETE(PATTable);
- - SAFE_DELETE(PMTTable);
- - SAFE_DELETE(SDTTable);
- - SAFE_DELETE(TDTTable);
- - SAFE_DELETE(TOTTable);
- - SAFE_DELETE(CDTTable);
- - SAFE_DELETE(SDTTTable);
- - SAFE_DELETE(BITTable);
- - SAFE_DELETE(SITTable);
- - SAFE_DELETE(EITTable_SD);
- - SAFE_DELETE(EITTable_SD2);
- + delete table;
- };
- }TABLE_DATA;
- diff -u -r -N a/EDCB-work-plus-s/EpgDataCap_Bon/EpgDataCap_Bon/EpgDataCap_Bon.vcxproj b/EDCB-work-plus-s/EpgDataCap_Bon/EpgDataCap_Bon/EpgDataCap_Bon.vcxproj
- --- a/EDCB-work-plus-s/EpgDataCap_Bon/EpgDataCap_Bon/EpgDataCap_Bon.vcxproj 2015-05-06 02:05:26.000000000 +0900
- +++ b/EDCB-work-plus-s/EpgDataCap_Bon/EpgDataCap_Bon/EpgDataCap_Bon.vcxproj 2015-05-01 10:57:30.000000000 +0900
- @@ -193,20 +193,23 @@
- <None Include="res\EpgDataCap_Bon_Vista_vio_rev2.ico" />
- </ItemGroup>
- <ItemGroup>
- + <ClInclude Include="..\..\BonCtrl\arib_std_b25.h" />
- <ClInclude Include="..\..\BonCtrl\BonCtrl.h" />
- <ClInclude Include="..\..\BonCtrl\BonCtrlDef.h" />
- <ClInclude Include="..\..\BonCtrl\BonDriverUtil.h" />
- + <ClInclude Include="..\..\BonCtrl\b_cas_card.h" />
- <ClInclude Include="..\..\BonCtrl\CATUtil.h" />
- <ClInclude Include="..\..\BonCtrl\ChSetUtil.h" />
- <ClInclude Include="..\..\BonCtrl\CreatePATPacket.h" />
- <ClInclude Include="..\..\BonCtrl\CreatePMTPacket.h" />
- + <ClInclude Include="..\..\BonCtrl\decoder.h" />
- <ClInclude Include="..\..\BonCtrl\DropCount.h" />
- - <ClInclude Include="..\..\BonCtrl\IB25Decoder.h" />
- <ClInclude Include="..\..\BonCtrl\IBonDriver.h" />
- <ClInclude Include="..\..\BonCtrl\IBonDriver2.h" />
- <ClInclude Include="..\..\BonCtrl\OneServiceUtil.h" />
- <ClInclude Include="..\..\BonCtrl\PacketInit.h" />
- <ClInclude Include="..\..\BonCtrl\PMTUtil.h" />
- + <ClInclude Include="..\..\BonCtrl\portable.h" />
- <ClInclude Include="..\..\BonCtrl\ScrambleDecoderUtil.h" />
- <ClInclude Include="..\..\BonCtrl\SendTCP.h" />
- <ClInclude Include="..\..\BonCtrl\SendUDP.h" />
- @@ -257,6 +260,7 @@
- <ClCompile Include="..\..\BonCtrl\ChSetUtil.cpp" />
- <ClCompile Include="..\..\BonCtrl\CreatePATPacket.cpp" />
- <ClCompile Include="..\..\BonCtrl\CreatePMTPacket.cpp" />
- + <ClCompile Include="..\..\BonCtrl\decoder.cpp" />
- <ClCompile Include="..\..\BonCtrl\DropCount.cpp" />
- <ClCompile Include="..\..\BonCtrl\OneServiceUtil.cpp" />
- <ClCompile Include="..\..\BonCtrl\PacketInit.cpp" />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement