改行コードを変更
This commit is contained in:
parent
957e2e3786
commit
a488fe5044
@ -1,232 +1,232 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// B25Decoder.cpp
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include "B25Decoder.h"
|
||||
|
||||
int B25Decoder::strip = 1;
|
||||
int B25Decoder::emm_proc = 0;
|
||||
int B25Decoder::multi2_round = 4;
|
||||
|
||||
B25Decoder::B25Decoder() : _bcas(nullptr), _b25(nullptr), _data(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
B25Decoder::~B25Decoder()
|
||||
{
|
||||
if (_data)
|
||||
::free(_data);
|
||||
|
||||
std::lock_guard<std::mutex> lock(_mtx);
|
||||
|
||||
if (_b25)
|
||||
_b25->release(_b25);
|
||||
|
||||
if (_bcas)
|
||||
_bcas->release(_bcas);
|
||||
|
||||
char log[64];
|
||||
::wsprintfA(log, "B25Decoder::dtor() : end");
|
||||
::OutputDebugStringA(log);
|
||||
}
|
||||
|
||||
int B25Decoder::init()
|
||||
{
|
||||
int rc;
|
||||
|
||||
std::lock_guard<std::mutex> lock(_mtx);
|
||||
|
||||
if (_b25)
|
||||
return -2;
|
||||
|
||||
char log[64];
|
||||
|
||||
_bcas = create_b_cas_card();
|
||||
if (!_bcas)
|
||||
return -3;
|
||||
|
||||
rc = _bcas->init(_bcas);
|
||||
if (rc < 0)
|
||||
{
|
||||
::wsprintfA(log, "B25Decoder::init() : bcas init error / rc(%d)", rc);
|
||||
::OutputDebugStringA(log);
|
||||
rc = -4;
|
||||
goto err;
|
||||
}
|
||||
|
||||
_b25 = create_arib_std_b25();
|
||||
if (!_b25)
|
||||
{
|
||||
rc = -5;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (_b25->set_b_cas_card(_b25, _bcas) < 0)
|
||||
{
|
||||
rc = -6;
|
||||
goto err;
|
||||
}
|
||||
|
||||
_b25->set_strip(_b25, strip);
|
||||
_b25->set_emm_proc(_b25, emm_proc);
|
||||
_b25->set_multi2_round(_b25, multi2_round);
|
||||
|
||||
::wsprintfA(log, "B25Decoder::init() : success");
|
||||
::OutputDebugStringA(log);
|
||||
return 0; // success
|
||||
|
||||
err:
|
||||
if (_b25)
|
||||
{
|
||||
_b25->release(_b25);
|
||||
_b25 = nullptr;
|
||||
}
|
||||
|
||||
if (_bcas)
|
||||
{
|
||||
_bcas->release(_bcas);
|
||||
_bcas = nullptr;
|
||||
}
|
||||
|
||||
::wsprintfA(log, "B25Decoder::init() : error / rc(%d)", rc);
|
||||
::OutputDebugStringA(log);
|
||||
_errtime = ::GetTickCount();
|
||||
return rc; // error
|
||||
}
|
||||
|
||||
void B25Decoder::setemm(bool flag)
|
||||
{
|
||||
if (_b25)
|
||||
_b25->set_emm_proc(_b25, flag ? 1 : 0);
|
||||
}
|
||||
|
||||
void B25Decoder::decode(BYTE *pSrc, DWORD dwSrcSize, BYTE **ppDst, DWORD *pdwDstSize)
|
||||
{
|
||||
if (!_b25)
|
||||
{
|
||||
DWORD now = ::GetTickCount();
|
||||
if ((now - _errtime) > RETRY_INTERVAL)
|
||||
{
|
||||
if (init() < 0)
|
||||
_errtime = now;
|
||||
}
|
||||
|
||||
if (!_b25)
|
||||
{
|
||||
if (*ppDst != pSrc)
|
||||
{
|
||||
*ppDst = pSrc;
|
||||
*pdwDstSize = dwSrcSize;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (_data)
|
||||
{
|
||||
::free(_data);
|
||||
_data = nullptr;
|
||||
}
|
||||
|
||||
char log[64];
|
||||
|
||||
ARIB_STD_B25_BUFFER buf;
|
||||
buf.data = pSrc;
|
||||
buf.size = dwSrcSize;
|
||||
const int rc = _b25->put(_b25, &buf);
|
||||
if (rc < 0)
|
||||
{
|
||||
if (rc >= ARIB_STD_B25_ERROR_NO_ECM_IN_HEAD_32M)
|
||||
{
|
||||
// pass through
|
||||
_b25->release(_b25);
|
||||
_b25 = nullptr;
|
||||
_bcas->release(_bcas);
|
||||
_bcas = nullptr;
|
||||
if (*ppDst != pSrc)
|
||||
{
|
||||
*ppDst = pSrc;
|
||||
*pdwDstSize = dwSrcSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BYTE *p = nullptr;
|
||||
_b25->withdraw(_b25, &buf); // withdraw src buffer
|
||||
if (buf.size > 0)
|
||||
{
|
||||
::wsprintfA(log, "B25Decoder::decode() : error / withdraw size(%u)", buf.size);
|
||||
::OutputDebugStringA(log);
|
||||
p = (BYTE *)::malloc(buf.size + dwSrcSize);
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
::memcpy(p, buf.data, buf.size);
|
||||
::memcpy(p + buf.size, pSrc, dwSrcSize);
|
||||
*ppDst = p;
|
||||
*pdwDstSize = buf.size + dwSrcSize;
|
||||
_data = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*ppDst != pSrc)
|
||||
{
|
||||
*ppDst = pSrc;
|
||||
*pdwDstSize = dwSrcSize;
|
||||
}
|
||||
}
|
||||
|
||||
if (rc == ARIB_STD_B25_ERROR_ECM_PROC_FAILURE)
|
||||
{
|
||||
// pass through
|
||||
_b25->release(_b25);
|
||||
_b25 = nullptr;
|
||||
_bcas->release(_bcas);
|
||||
_bcas = nullptr;
|
||||
}
|
||||
}
|
||||
::wsprintfA(log, "B25Decoder::decode() : error / rc(%d)", rc);
|
||||
::OutputDebugStringA(log);
|
||||
_errtime = ::GetTickCount();
|
||||
return; // error
|
||||
}
|
||||
_b25->get(_b25, &buf);
|
||||
*ppDst = buf.data;
|
||||
*pdwDstSize = buf.size;
|
||||
return; // success
|
||||
}
|
||||
|
||||
int B25Decoder::reset()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (_b25)
|
||||
rc = _b25->reset(_b25);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int B25Decoder::flush()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (_b25)
|
||||
rc = _b25->flush(_b25);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int B25Decoder::put(BYTE *pSrc, DWORD dwSrcSize)
|
||||
{
|
||||
ARIB_STD_B25_BUFFER buf;
|
||||
buf.data = pSrc;
|
||||
buf.size = dwSrcSize;
|
||||
return _b25->put(_b25, &buf);
|
||||
}
|
||||
|
||||
int B25Decoder::get(BYTE **ppDst, DWORD *pdwDstSize)
|
||||
{
|
||||
ARIB_STD_B25_BUFFER buf;
|
||||
int rc = _b25->get(_b25, &buf);
|
||||
*ppDst = buf.data;
|
||||
*pdwDstSize = buf.size;
|
||||
return rc;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// B25Decoder.cpp
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include "B25Decoder.h"
|
||||
|
||||
int B25Decoder::strip = 1;
|
||||
int B25Decoder::emm_proc = 0;
|
||||
int B25Decoder::multi2_round = 4;
|
||||
|
||||
B25Decoder::B25Decoder() : _bcas(nullptr), _b25(nullptr), _data(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
B25Decoder::~B25Decoder()
|
||||
{
|
||||
if (_data)
|
||||
::free(_data);
|
||||
|
||||
std::lock_guard<std::mutex> lock(_mtx);
|
||||
|
||||
if (_b25)
|
||||
_b25->release(_b25);
|
||||
|
||||
if (_bcas)
|
||||
_bcas->release(_bcas);
|
||||
|
||||
char log[64];
|
||||
::wsprintfA(log, "B25Decoder::dtor() : end");
|
||||
::OutputDebugStringA(log);
|
||||
}
|
||||
|
||||
int B25Decoder::init()
|
||||
{
|
||||
int rc;
|
||||
|
||||
std::lock_guard<std::mutex> lock(_mtx);
|
||||
|
||||
if (_b25)
|
||||
return -2;
|
||||
|
||||
char log[64];
|
||||
|
||||
_bcas = create_b_cas_card();
|
||||
if (!_bcas)
|
||||
return -3;
|
||||
|
||||
rc = _bcas->init(_bcas);
|
||||
if (rc < 0)
|
||||
{
|
||||
::wsprintfA(log, "B25Decoder::init() : bcas init error / rc(%d)", rc);
|
||||
::OutputDebugStringA(log);
|
||||
rc = -4;
|
||||
goto err;
|
||||
}
|
||||
|
||||
_b25 = create_arib_std_b25();
|
||||
if (!_b25)
|
||||
{
|
||||
rc = -5;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (_b25->set_b_cas_card(_b25, _bcas) < 0)
|
||||
{
|
||||
rc = -6;
|
||||
goto err;
|
||||
}
|
||||
|
||||
_b25->set_strip(_b25, strip);
|
||||
_b25->set_emm_proc(_b25, emm_proc);
|
||||
_b25->set_multi2_round(_b25, multi2_round);
|
||||
|
||||
::wsprintfA(log, "B25Decoder::init() : success");
|
||||
::OutputDebugStringA(log);
|
||||
return 0; // success
|
||||
|
||||
err:
|
||||
if (_b25)
|
||||
{
|
||||
_b25->release(_b25);
|
||||
_b25 = nullptr;
|
||||
}
|
||||
|
||||
if (_bcas)
|
||||
{
|
||||
_bcas->release(_bcas);
|
||||
_bcas = nullptr;
|
||||
}
|
||||
|
||||
::wsprintfA(log, "B25Decoder::init() : error / rc(%d)", rc);
|
||||
::OutputDebugStringA(log);
|
||||
_errtime = ::GetTickCount();
|
||||
return rc; // error
|
||||
}
|
||||
|
||||
void B25Decoder::setemm(bool flag)
|
||||
{
|
||||
if (_b25)
|
||||
_b25->set_emm_proc(_b25, flag ? 1 : 0);
|
||||
}
|
||||
|
||||
void B25Decoder::decode(BYTE *pSrc, DWORD dwSrcSize, BYTE **ppDst, DWORD *pdwDstSize)
|
||||
{
|
||||
if (!_b25)
|
||||
{
|
||||
DWORD now = ::GetTickCount();
|
||||
if ((now - _errtime) > RETRY_INTERVAL)
|
||||
{
|
||||
if (init() < 0)
|
||||
_errtime = now;
|
||||
}
|
||||
|
||||
if (!_b25)
|
||||
{
|
||||
if (*ppDst != pSrc)
|
||||
{
|
||||
*ppDst = pSrc;
|
||||
*pdwDstSize = dwSrcSize;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (_data)
|
||||
{
|
||||
::free(_data);
|
||||
_data = nullptr;
|
||||
}
|
||||
|
||||
char log[64];
|
||||
|
||||
ARIB_STD_B25_BUFFER buf;
|
||||
buf.data = pSrc;
|
||||
buf.size = dwSrcSize;
|
||||
const int rc = _b25->put(_b25, &buf);
|
||||
if (rc < 0)
|
||||
{
|
||||
if (rc >= ARIB_STD_B25_ERROR_NO_ECM_IN_HEAD_32M)
|
||||
{
|
||||
// pass through
|
||||
_b25->release(_b25);
|
||||
_b25 = nullptr;
|
||||
_bcas->release(_bcas);
|
||||
_bcas = nullptr;
|
||||
if (*ppDst != pSrc)
|
||||
{
|
||||
*ppDst = pSrc;
|
||||
*pdwDstSize = dwSrcSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BYTE *p = nullptr;
|
||||
_b25->withdraw(_b25, &buf); // withdraw src buffer
|
||||
if (buf.size > 0)
|
||||
{
|
||||
::wsprintfA(log, "B25Decoder::decode() : error / withdraw size(%u)", buf.size);
|
||||
::OutputDebugStringA(log);
|
||||
p = (BYTE *)::malloc(buf.size + dwSrcSize);
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
::memcpy(p, buf.data, buf.size);
|
||||
::memcpy(p + buf.size, pSrc, dwSrcSize);
|
||||
*ppDst = p;
|
||||
*pdwDstSize = buf.size + dwSrcSize;
|
||||
_data = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*ppDst != pSrc)
|
||||
{
|
||||
*ppDst = pSrc;
|
||||
*pdwDstSize = dwSrcSize;
|
||||
}
|
||||
}
|
||||
|
||||
if (rc == ARIB_STD_B25_ERROR_ECM_PROC_FAILURE)
|
||||
{
|
||||
// pass through
|
||||
_b25->release(_b25);
|
||||
_b25 = nullptr;
|
||||
_bcas->release(_bcas);
|
||||
_bcas = nullptr;
|
||||
}
|
||||
}
|
||||
::wsprintfA(log, "B25Decoder::decode() : error / rc(%d)", rc);
|
||||
::OutputDebugStringA(log);
|
||||
_errtime = ::GetTickCount();
|
||||
return; // error
|
||||
}
|
||||
_b25->get(_b25, &buf);
|
||||
*ppDst = buf.data;
|
||||
*pdwDstSize = buf.size;
|
||||
return; // success
|
||||
}
|
||||
|
||||
int B25Decoder::reset()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (_b25)
|
||||
rc = _b25->reset(_b25);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int B25Decoder::flush()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (_b25)
|
||||
rc = _b25->flush(_b25);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int B25Decoder::put(BYTE *pSrc, DWORD dwSrcSize)
|
||||
{
|
||||
ARIB_STD_B25_BUFFER buf;
|
||||
buf.data = pSrc;
|
||||
buf.size = dwSrcSize;
|
||||
return _b25->put(_b25, &buf);
|
||||
}
|
||||
|
||||
int B25Decoder::get(BYTE **ppDst, DWORD *pdwDstSize)
|
||||
{
|
||||
ARIB_STD_B25_BUFFER buf;
|
||||
int rc = _b25->get(_b25, &buf);
|
||||
*ppDst = buf.data;
|
||||
*pdwDstSize = buf.size;
|
||||
return rc;
|
||||
}
|
||||
|
@ -1,41 +1,41 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// B25Decoder.h
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __B25DECODER_H__
|
||||
#define __B25DECODER_H__
|
||||
#include <windows.h>
|
||||
#include <mutex>
|
||||
#include "arib_std_b25.h"
|
||||
#include "arib_std_b25_error_code.h"
|
||||
|
||||
#define RETRY_INTERVAL 10000 // 10sec interval
|
||||
|
||||
class B25Decoder
|
||||
{
|
||||
public:
|
||||
B25Decoder();
|
||||
~B25Decoder();
|
||||
int init();
|
||||
void setemm(bool flag);
|
||||
void decode(BYTE *pSrc, DWORD dwSrcSize, BYTE **ppDst, DWORD *pdwDstSize);
|
||||
|
||||
// libaribb25 wrapper
|
||||
int reset();
|
||||
int flush();
|
||||
int put(BYTE *pSrc, DWORD dwSrcSize);
|
||||
int get(BYTE **ppDst, DWORD *pdwDstSize);
|
||||
|
||||
// initialize parameter
|
||||
static int strip;
|
||||
static int emm_proc;
|
||||
static int multi2_round;
|
||||
|
||||
private:
|
||||
std::mutex _mtx;
|
||||
B_CAS_CARD *_bcas;
|
||||
ARIB_STD_B25 *_b25;
|
||||
BYTE *_data;
|
||||
DWORD _errtime;
|
||||
};
|
||||
|
||||
#endif // __B25DECODER_H__
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// B25Decoder.h
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __B25DECODER_H__
|
||||
#define __B25DECODER_H__
|
||||
#include <windows.h>
|
||||
#include <mutex>
|
||||
#include "arib_std_b25.h"
|
||||
#include "arib_std_b25_error_code.h"
|
||||
|
||||
#define RETRY_INTERVAL 10000 // 10sec interval
|
||||
|
||||
class B25Decoder
|
||||
{
|
||||
public:
|
||||
B25Decoder();
|
||||
~B25Decoder();
|
||||
int init();
|
||||
void setemm(bool flag);
|
||||
void decode(BYTE *pSrc, DWORD dwSrcSize, BYTE **ppDst, DWORD *pdwDstSize);
|
||||
|
||||
// libaribb25 wrapper
|
||||
int reset();
|
||||
int flush();
|
||||
int put(BYTE *pSrc, DWORD dwSrcSize);
|
||||
int get(BYTE **ppDst, DWORD *pdwDstSize);
|
||||
|
||||
// initialize parameter
|
||||
static int strip;
|
||||
static int emm_proc;
|
||||
static int multi2_round;
|
||||
|
||||
private:
|
||||
std::mutex _mtx;
|
||||
B_CAS_CARD *_bcas;
|
||||
ARIB_STD_B25 *_b25;
|
||||
BYTE *_data;
|
||||
DWORD _errtime;
|
||||
};
|
||||
|
||||
#endif // __B25DECODER_H__
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,61 +1,61 @@
|
||||
#ifndef ARIB_STD_B25_H
|
||||
#define ARIB_STD_B25_H
|
||||
|
||||
#include "portable.h"
|
||||
#include "b_cas_card.h"
|
||||
|
||||
typedef struct {
|
||||
uint8_t *data;
|
||||
uint32_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);
|
||||
|
||||
int (*withdraw)(void *std_b25, ARIB_STD_B25_BUFFER *buf);
|
||||
|
||||
} ARIB_STD_B25;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern ARIB_STD_B25 *create_arib_std_b25(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ARIB_STD_B25_H */
|
||||
#ifndef ARIB_STD_B25_H
|
||||
#define ARIB_STD_B25_H
|
||||
|
||||
#include "portable.h"
|
||||
#include "b_cas_card.h"
|
||||
|
||||
typedef struct {
|
||||
uint8_t *data;
|
||||
uint32_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);
|
||||
|
||||
int (*withdraw)(void *std_b25, ARIB_STD_B25_BUFFER *buf);
|
||||
|
||||
} ARIB_STD_B25;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern ARIB_STD_B25 *create_arib_std_b25(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ARIB_STD_B25_H */
|
||||
|
@ -1,25 +1,25 @@
|
||||
#ifndef ARIB_STD_B25_ERROR_CODE_H
|
||||
#define ARIB_STD_B25_ERROR_CODE_H
|
||||
|
||||
#define ARIB_STD_B25_ERROR_INVALID_PARAM -1
|
||||
#define ARIB_STD_B25_ERROR_NO_ENOUGH_MEMORY -2
|
||||
#define ARIB_STD_B25_ERROR_NON_TS_INPUT_STREAM -3
|
||||
#define ARIB_STD_B25_ERROR_NO_PAT_IN_HEAD_16M -4
|
||||
#define ARIB_STD_B25_ERROR_NO_PMT_IN_HEAD_32M -5
|
||||
#define ARIB_STD_B25_ERROR_NO_ECM_IN_HEAD_32M -6
|
||||
#define ARIB_STD_B25_ERROR_EMPTY_B_CAS_CARD -7
|
||||
#define ARIB_STD_B25_ERROR_INVALID_B_CAS_STATUS -8
|
||||
#define ARIB_STD_B25_ERROR_ECM_PROC_FAILURE -9
|
||||
#define ARIB_STD_B25_ERROR_DECRYPT_FAILURE -10
|
||||
#define ARIB_STD_B25_ERROR_PAT_PARSE_FAILURE -11
|
||||
#define ARIB_STD_B25_ERROR_PMT_PARSE_FAILURE -12
|
||||
#define ARIB_STD_B25_ERROR_ECM_PARSE_FAILURE -13
|
||||
#define ARIB_STD_B25_ERROR_CAT_PARSE_FAILURE -14
|
||||
#define ARIB_STD_B25_ERROR_EMM_PARSE_FAILURE -15
|
||||
#define ARIB_STD_B25_ERROR_EMM_PROC_FAILURE -16
|
||||
|
||||
#define ARIB_STD_B25_WARN_UNPURCHASED_ECM 1
|
||||
#define ARIB_STD_B25_WARN_TS_SECTION_ID_MISSMATCH 2
|
||||
#define ARIB_STD_B25_WARN_BROKEN_TS_SECTION 3
|
||||
|
||||
#endif /* ARIB_STD_B25_ERROR_CODE_H */
|
||||
#ifndef ARIB_STD_B25_ERROR_CODE_H
|
||||
#define ARIB_STD_B25_ERROR_CODE_H
|
||||
|
||||
#define ARIB_STD_B25_ERROR_INVALID_PARAM -1
|
||||
#define ARIB_STD_B25_ERROR_NO_ENOUGH_MEMORY -2
|
||||
#define ARIB_STD_B25_ERROR_NON_TS_INPUT_STREAM -3
|
||||
#define ARIB_STD_B25_ERROR_NO_PAT_IN_HEAD_16M -4
|
||||
#define ARIB_STD_B25_ERROR_NO_PMT_IN_HEAD_32M -5
|
||||
#define ARIB_STD_B25_ERROR_NO_ECM_IN_HEAD_32M -6
|
||||
#define ARIB_STD_B25_ERROR_EMPTY_B_CAS_CARD -7
|
||||
#define ARIB_STD_B25_ERROR_INVALID_B_CAS_STATUS -8
|
||||
#define ARIB_STD_B25_ERROR_ECM_PROC_FAILURE -9
|
||||
#define ARIB_STD_B25_ERROR_DECRYPT_FAILURE -10
|
||||
#define ARIB_STD_B25_ERROR_PAT_PARSE_FAILURE -11
|
||||
#define ARIB_STD_B25_ERROR_PMT_PARSE_FAILURE -12
|
||||
#define ARIB_STD_B25_ERROR_ECM_PARSE_FAILURE -13
|
||||
#define ARIB_STD_B25_ERROR_CAT_PARSE_FAILURE -14
|
||||
#define ARIB_STD_B25_ERROR_EMM_PARSE_FAILURE -15
|
||||
#define ARIB_STD_B25_ERROR_EMM_PROC_FAILURE -16
|
||||
|
||||
#define ARIB_STD_B25_WARN_UNPURCHASED_ECM 1
|
||||
#define ARIB_STD_B25_WARN_TS_SECTION_ID_MISSMATCH 2
|
||||
#define ARIB_STD_B25_WARN_BROKEN_TS_SECTION 3
|
||||
|
||||
#endif /* ARIB_STD_B25_ERROR_CODE_H */
|
||||
|
1464
aribb25/b_cas_card.c
1464
aribb25/b_cas_card.c
File diff suppressed because it is too large
Load Diff
@ -1,75 +1,75 @@
|
||||
#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, int32_t len);
|
||||
int (* proc_emm)(void *bcas, uint8_t *src, int32_t len);
|
||||
|
||||
} B_CAS_CARD;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern B_CAS_CARD *create_b_cas_card(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* B_CAS_CARD_H */
|
||||
#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, int32_t len);
|
||||
int (* proc_emm)(void *bcas, uint8_t *src, int32_t len);
|
||||
|
||||
} B_CAS_CARD;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern B_CAS_CARD *create_b_cas_card(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* B_CAS_CARD_H */
|
||||
|
@ -1,11 +1,11 @@
|
||||
#ifndef B_CAS_CARD_ERROR_CODE_H
|
||||
#define B_CAS_CARD_ERROR_CODE_H
|
||||
|
||||
#define B_CAS_CARD_ERROR_INVALID_PARAMETER -1
|
||||
#define B_CAS_CARD_ERROR_NOT_INITIALIZED -2
|
||||
#define B_CAS_CARD_ERROR_NO_SMART_CARD_READER -3
|
||||
#define B_CAS_CARD_ERROR_ALL_READERS_CONNECTION_FAILED -4
|
||||
#define B_CAS_CARD_ERROR_NO_ENOUGH_MEMORY -5
|
||||
#define B_CAS_CARD_ERROR_TRANSMIT_FAILED -6
|
||||
|
||||
#endif /* B_CAS_CARD_ERROR_CODE_H */
|
||||
#ifndef B_CAS_CARD_ERROR_CODE_H
|
||||
#define B_CAS_CARD_ERROR_CODE_H
|
||||
|
||||
#define B_CAS_CARD_ERROR_INVALID_PARAMETER -1
|
||||
#define B_CAS_CARD_ERROR_NOT_INITIALIZED -2
|
||||
#define B_CAS_CARD_ERROR_NO_SMART_CARD_READER -3
|
||||
#define B_CAS_CARD_ERROR_ALL_READERS_CONNECTION_FAILED -4
|
||||
#define B_CAS_CARD_ERROR_NO_ENOUGH_MEMORY -5
|
||||
#define B_CAS_CARD_ERROR_TRANSMIT_FAILED -6
|
||||
|
||||
#endif /* B_CAS_CARD_ERROR_CODE_H */
|
||||
|
1054
aribb25/multi2.c
1054
aribb25/multi2.c
File diff suppressed because it is too large
Load Diff
@ -1,35 +1,35 @@
|
||||
#ifndef MULTI2_H
|
||||
#define MULTI2_H
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
typedef struct {
|
||||
|
||||
void *private_data;
|
||||
|
||||
void (* release)(void *m2);
|
||||
int (* add_ref)(void *m2);
|
||||
|
||||
int (* set_round)(void *m2, int32_t val);
|
||||
|
||||
int (* set_system_key)(void *m2, uint8_t *val);
|
||||
int (* set_init_cbc)(void *m2, uint8_t *val);
|
||||
int (* set_scramble_key)(void *m2, uint8_t *val);
|
||||
int (* clear_scramble_key)(void *m2);
|
||||
|
||||
int (* encrypt)(void *m2, int32_t type, uint8_t *buf, int32_t size);
|
||||
int (* decrypt)(void *m2, int32_t type, uint8_t *buf, intptr_t size);
|
||||
|
||||
} MULTI2;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern MULTI2 *create_multi2(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MULTI2_H */
|
||||
#ifndef MULTI2_H
|
||||
#define MULTI2_H
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
typedef struct {
|
||||
|
||||
void *private_data;
|
||||
|
||||
void (* release)(void *m2);
|
||||
int (* add_ref)(void *m2);
|
||||
|
||||
int (* set_round)(void *m2, int32_t val);
|
||||
|
||||
int (* set_system_key)(void *m2, uint8_t *val);
|
||||
int (* set_init_cbc)(void *m2, uint8_t *val);
|
||||
int (* set_scramble_key)(void *m2, uint8_t *val);
|
||||
int (* clear_scramble_key)(void *m2);
|
||||
|
||||
int (* encrypt)(void *m2, int32_t type, uint8_t *buf, int32_t size);
|
||||
int (* decrypt)(void *m2, int32_t type, uint8_t *buf, intptr_t size);
|
||||
|
||||
} MULTI2;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern MULTI2 *create_multi2(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MULTI2_H */
|
||||
|
@ -1,9 +1,9 @@
|
||||
#ifndef MULTI2_ERROR_CODE_H
|
||||
#define MULTI2_ERROR_CODE_H
|
||||
|
||||
#define MULTI2_ERROR_INVALID_PARAMETER -1
|
||||
#define MULTI2_ERROR_UNSET_SYSTEM_KEY -2
|
||||
#define MULTI2_ERROR_UNSET_CBC_INIT -3
|
||||
#define MULTI2_ERROR_UNSET_SCRAMBLE_KEY -4
|
||||
|
||||
#endif /* MULTI2_ERROR_CODE_H */
|
||||
#ifndef MULTI2_ERROR_CODE_H
|
||||
#define MULTI2_ERROR_CODE_H
|
||||
|
||||
#define MULTI2_ERROR_INVALID_PARAMETER -1
|
||||
#define MULTI2_ERROR_UNSET_SYSTEM_KEY -2
|
||||
#define MULTI2_ERROR_UNSET_CBC_INIT -3
|
||||
#define MULTI2_ERROR_UNSET_SCRAMBLE_KEY -4
|
||||
|
||||
#endif /* MULTI2_ERROR_CODE_H */
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef PORTABLE_H
|
||||
#define PORTABLE_H
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#endif /* PORTABLE_H */
|
||||
#ifndef PORTABLE_H
|
||||
#define PORTABLE_H
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#endif /* PORTABLE_H */
|
||||
|
872
aribb25/td.c
872
aribb25/td.c
@ -1,436 +1,436 @@
|
||||
#if defined(WIN32)
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <io.h>
|
||||
#include <windows.h>
|
||||
#include <crtdbg.h>
|
||||
#else
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "arib_std_b25.h"
|
||||
#include "b_cas_card.h"
|
||||
|
||||
typedef struct {
|
||||
int32_t round;
|
||||
int32_t strip;
|
||||
int32_t emm;
|
||||
int32_t verbose;
|
||||
int32_t power_ctrl;
|
||||
} OPTION;
|
||||
|
||||
static void show_usage();
|
||||
static int parse_arg(OPTION *dst, int argc, char **argv);
|
||||
static void test_arib_std_b25(const char *src, const char *dst, OPTION *opt);
|
||||
static void show_bcas_power_on_control_info(B_CAS_CARD *bcas);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int n;
|
||||
OPTION opt;
|
||||
|
||||
#if defined(WIN32)
|
||||
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
|
||||
_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT );
|
||||
_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
|
||||
_CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT );
|
||||
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
|
||||
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );
|
||||
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_DELAY_FREE_MEM_DF|_CRTDBG_CHECK_ALWAYS_DF|_CRTDBG_LEAK_CHECK_DF);
|
||||
#endif
|
||||
|
||||
n = parse_arg(&opt, argc, argv);
|
||||
if(n+2 > argc){
|
||||
show_usage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for(;n<=(argc-2);n+=2){
|
||||
test_arib_std_b25(argv[n+0], argv[n+1], &opt);
|
||||
}
|
||||
|
||||
#if defined(WIN32)
|
||||
_CrtDumpMemoryLeaks();
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static void show_usage()
|
||||
{
|
||||
fprintf(stderr, "b25 - ARIB STD-B25 test program ver. 0.2.5 (2012, 2/13)\n");
|
||||
fprintf(stderr, "usage: b25 [options] src.m2t dst.m2t [more pair ..]\n");
|
||||
fprintf(stderr, "options:\n");
|
||||
fprintf(stderr, " -r round (integer, default=4)\n");
|
||||
fprintf(stderr, " -s strip\n");
|
||||
fprintf(stderr, " 0: keep null(padding) stream (default)\n");
|
||||
fprintf(stderr, " 1: strip null stream\n");
|
||||
fprintf(stderr, " -m EMM\n");
|
||||
fprintf(stderr, " 0: ignore EMM (default)\n");
|
||||
fprintf(stderr, " 1: send EMM to B-CAS card\n");
|
||||
fprintf(stderr, " -p power_on_control_info\n");
|
||||
fprintf(stderr, " 0: do nothing additionaly\n");
|
||||
fprintf(stderr, " 1: show B-CAS EMM receiving request (default)\n");
|
||||
fprintf(stderr, " -v verbose\n");
|
||||
fprintf(stderr, " 0: silent\n");
|
||||
fprintf(stderr, " 1: show processing status (default)\n");
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
static int parse_arg(OPTION *dst, int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
dst->round = 4;
|
||||
dst->strip = 0;
|
||||
dst->emm = 0;
|
||||
dst->power_ctrl = 1;
|
||||
dst->verbose = 1;
|
||||
|
||||
for(i=1;i<argc;i++){
|
||||
if(argv[i][0] != '-'){
|
||||
break;
|
||||
}
|
||||
switch(argv[i][1]){
|
||||
case 'm':
|
||||
if(argv[i][2]){
|
||||
dst->emm = atoi(argv[i]+2);
|
||||
}else{
|
||||
dst->emm = atoi(argv[i+1]);
|
||||
i += 1;
|
||||
}
|
||||
break;
|
||||
case 'p':
|
||||
if(argv[i][2]){
|
||||
dst->power_ctrl = atoi(argv[i]+2);
|
||||
}else{
|
||||
dst->power_ctrl = atoi(argv[i+1]);
|
||||
i += 1;
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
if(argv[i][2]){
|
||||
dst->round = atoi(argv[i]+2);
|
||||
}else{
|
||||
dst->round = atoi(argv[i+1]);
|
||||
i += 1;
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
if(argv[i][2]){
|
||||
dst->strip = atoi(argv[i]+2);
|
||||
}else{
|
||||
dst->strip = atoi(argv[i+1]);
|
||||
i += 1;
|
||||
}
|
||||
break;
|
||||
case 'v':
|
||||
if(argv[i][2]){
|
||||
dst->verbose = atoi(argv[i]+2);
|
||||
}else{
|
||||
dst->verbose = atoi(argv[i+1]);
|
||||
i += 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "error - unknown option '-%c'\n", argv[i][1]);
|
||||
return argc;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static void test_arib_std_b25(const char *src, const char *dst, OPTION *opt)
|
||||
{
|
||||
int code,i,n,m;
|
||||
int sfd,dfd;
|
||||
|
||||
int64_t total;
|
||||
int64_t offset;
|
||||
#if defined(WIN32)
|
||||
unsigned long tick,tock;
|
||||
#else
|
||||
struct timeval tick,tock;
|
||||
double millisec;
|
||||
#endif
|
||||
double mbps;
|
||||
|
||||
ARIB_STD_B25 *b25;
|
||||
B_CAS_CARD *bcas;
|
||||
|
||||
ARIB_STD_B25_PROGRAM_INFO pgrm;
|
||||
|
||||
uint8_t data[64*1024];
|
||||
|
||||
ARIB_STD_B25_BUFFER sbuf;
|
||||
ARIB_STD_B25_BUFFER dbuf;
|
||||
|
||||
sfd = -1;
|
||||
dfd = -1;
|
||||
b25 = NULL;
|
||||
bcas = NULL;
|
||||
|
||||
sfd = _open(src, _O_BINARY|_O_RDONLY|_O_SEQUENTIAL);
|
||||
if(sfd < 0){
|
||||
fprintf(stderr, "error - failed on _open(%s) [src]\n", src);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
_lseeki64(sfd, 0, SEEK_END);
|
||||
total = _telli64(sfd);
|
||||
_lseeki64(sfd, 0, SEEK_SET);
|
||||
|
||||
b25 = create_arib_std_b25();
|
||||
if(b25 == NULL){
|
||||
fprintf(stderr, "error - failed on create_arib_std_b25()\n");
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
code = b25->set_multi2_round(b25, opt->round);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::set_multi2_round() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
code = b25->set_strip(b25, opt->strip);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::set_strip() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
code = b25->set_emm_proc(b25, opt->emm);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::set_emm_proc() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
bcas = create_b_cas_card();
|
||||
if(bcas == NULL){
|
||||
fprintf(stderr, "error - failed on create_b_cas_card()\n");
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
code = bcas->init(bcas);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on B_CAS_CARD::init() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
code = b25->set_b_cas_card(b25, bcas);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::set_b_cas_card() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
dfd = _open(dst, _O_BINARY|_O_WRONLY|_O_SEQUENTIAL|_O_CREAT|_O_TRUNC, _S_IREAD|_S_IWRITE);
|
||||
if(dfd < 0){
|
||||
fprintf(stderr, "error - failed on _open(%s) [dst]\n", dst);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
offset = 0;
|
||||
#if defined(WIN32)
|
||||
tock = GetTickCount();
|
||||
#else
|
||||
gettimeofday(&tock, NULL);
|
||||
#endif
|
||||
while( (n = _read(sfd, data, sizeof(data))) > 0 ){
|
||||
sbuf.data = data;
|
||||
sbuf.size = n;
|
||||
|
||||
code = b25->put(b25, &sbuf);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::put() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
code = b25->get(b25, &dbuf);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::get() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
if(dbuf.size > 0){
|
||||
n = _write(dfd, dbuf.data, dbuf.size);
|
||||
if(n != dbuf.size){
|
||||
fprintf(stderr, "error failed on _write(%d)\n", dbuf.size);
|
||||
goto LAST;
|
||||
}
|
||||
}
|
||||
|
||||
offset += sbuf.size;
|
||||
if(opt->verbose != 0){
|
||||
m = (int)(10000*offset/total);
|
||||
mbps = 0.0;
|
||||
#if defined(WIN32)
|
||||
tick = GetTickCount();
|
||||
if (tick-tock > 100) {
|
||||
mbps = offset;
|
||||
mbps /= 1024;
|
||||
mbps /= (tick-tock);
|
||||
}
|
||||
#else
|
||||
gettimeofday(&tick, NULL);
|
||||
millisec = (tick.tv_sec - tock.tv_sec) * 1000;
|
||||
millisec += (tick.tv_usec - tock.tv_usec) / 1000;
|
||||
if(millisec > 100.0) {
|
||||
mbps = offset;
|
||||
mbps /= 1024;
|
||||
mbps /= millisec;
|
||||
}
|
||||
#endif
|
||||
fprintf(stderr, "\rprocessing: %2d.%02d%% [%6.2f MB/sec]", m/100, m%100, mbps);
|
||||
}
|
||||
}
|
||||
|
||||
code = b25->flush(b25);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::flush() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
code = b25->get(b25, &dbuf);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::get() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
if(dbuf.size > 0){
|
||||
n = _write(dfd, dbuf.data, dbuf.size);
|
||||
if(n != dbuf.size){
|
||||
fprintf(stderr, "error - failed on _write(%d)\n", dbuf.size);
|
||||
goto LAST;
|
||||
}
|
||||
}
|
||||
|
||||
if(opt->verbose != 0){
|
||||
mbps = 0.0;
|
||||
#if defined(WIN32)
|
||||
tick = GetTickCount();
|
||||
if (tick-tock > 100) {
|
||||
mbps = offset;
|
||||
mbps /= 1024;
|
||||
mbps /= (tick-tock);
|
||||
}
|
||||
#else
|
||||
gettimeofday(&tick, NULL);
|
||||
millisec = (tick.tv_sec - tock.tv_sec) * 1000;
|
||||
millisec += (tick.tv_usec - tock.tv_usec) / 1000;
|
||||
if(millisec > 100.0) {
|
||||
mbps = offset;
|
||||
mbps /= 1024;
|
||||
mbps /= millisec;
|
||||
}
|
||||
#endif
|
||||
fprintf(stderr, "\rprocessing: finish [%6.2f MB/sec]\n", mbps);
|
||||
fflush(stderr);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
n = b25->get_program_count(b25);
|
||||
if(n < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::get_program_count() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
for(i=0;i<n;i++){
|
||||
code = b25->get_program_info(b25, &pgrm, i);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::get_program_info(%d) : code=%d\n", i, code);
|
||||
goto LAST;
|
||||
}
|
||||
if(pgrm.ecm_unpurchased_count > 0){
|
||||
fprintf(stderr, "warning - unpurchased ECM is detected\n");
|
||||
fprintf(stderr, " channel: %d\n", pgrm.program_number);
|
||||
fprintf(stderr, " unpurchased ECM count: %d\n", pgrm.ecm_unpurchased_count);
|
||||
fprintf(stderr, " last ECM error code: %04x\n", pgrm.last_ecm_error_code);
|
||||
#if defined(WIN32)
|
||||
fprintf(stderr, " undecrypted TS packet: %I64d\n", pgrm.undecrypted_packet_count);
|
||||
fprintf(stderr, " total TS packet: %I64d\n", pgrm.total_packet_count);
|
||||
#else
|
||||
fprintf(stderr, " undecrypted TS packet: %"PRId64"\n", pgrm.undecrypted_packet_count);
|
||||
fprintf(stderr, " total TS packet: %"PRId64"\n", pgrm.total_packet_count);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if(opt->power_ctrl != 0){
|
||||
show_bcas_power_on_control_info(bcas);
|
||||
}
|
||||
|
||||
LAST:
|
||||
|
||||
if(sfd >= 0){
|
||||
_close(sfd);
|
||||
sfd = -1;
|
||||
}
|
||||
|
||||
if(dfd >= 0){
|
||||
_close(dfd);
|
||||
dfd = -1;
|
||||
}
|
||||
|
||||
if(b25 != NULL){
|
||||
b25->release(b25);
|
||||
b25 = NULL;
|
||||
}
|
||||
|
||||
if(bcas != NULL){
|
||||
bcas->release(bcas);
|
||||
bcas = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void show_bcas_power_on_control_info(B_CAS_CARD *bcas)
|
||||
{
|
||||
int code;
|
||||
int i,w;
|
||||
B_CAS_PWR_ON_CTRL_INFO pwc;
|
||||
|
||||
code = bcas->get_pwr_on_ctrl(bcas, &pwc);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on B_CAS_CARD::get_pwr_on_ctrl() : code=%d\n", code);
|
||||
return;
|
||||
}
|
||||
|
||||
if(pwc.count == 0){
|
||||
fprintf(stdout, "no EMM receiving request\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stdout, "total %d EMM receiving request\n", pwc.count);
|
||||
for(i=0;i<pwc.count;i++){
|
||||
fprintf(stdout, "+ [%d] : tune ", i);
|
||||
switch(pwc.data[i].network_id){
|
||||
case 4:
|
||||
w = pwc.data[i].transport_id;
|
||||
fprintf(stdout, "BS-%d/TS-%d ", ((w >> 4) & 0x1f), (w & 7));
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
w = pwc.data[i].transport_id;
|
||||
fprintf(stdout, "ND-%d/TS-%d ", ((w >> 4) & 0x1f), (w & 7));
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "unknown(b:0x%02x,n:0x%04x,t:0x%04x) ", pwc.data[i].broadcaster_group_id, pwc.data[i].network_id, pwc.data[i].transport_id);
|
||||
break;
|
||||
}
|
||||
fprintf(stdout, "between %04d %02d/%02d ", pwc.data[i].s_yy, pwc.data[i].s_mm, pwc.data[i].s_dd);
|
||||
fprintf(stdout, "to %04d %02d/%02d ", pwc.data[i].l_yy, pwc.data[i].l_mm, pwc.data[i].l_dd);
|
||||
fprintf(stdout, "least %d hours\n", pwc.data[i].hold_time);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(WIN32)
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <io.h>
|
||||
#include <windows.h>
|
||||
#include <crtdbg.h>
|
||||
#else
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "arib_std_b25.h"
|
||||
#include "b_cas_card.h"
|
||||
|
||||
typedef struct {
|
||||
int32_t round;
|
||||
int32_t strip;
|
||||
int32_t emm;
|
||||
int32_t verbose;
|
||||
int32_t power_ctrl;
|
||||
} OPTION;
|
||||
|
||||
static void show_usage();
|
||||
static int parse_arg(OPTION *dst, int argc, char **argv);
|
||||
static void test_arib_std_b25(const char *src, const char *dst, OPTION *opt);
|
||||
static void show_bcas_power_on_control_info(B_CAS_CARD *bcas);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int n;
|
||||
OPTION opt;
|
||||
|
||||
#if defined(WIN32)
|
||||
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
|
||||
_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT );
|
||||
_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
|
||||
_CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT );
|
||||
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
|
||||
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );
|
||||
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_DELAY_FREE_MEM_DF|_CRTDBG_CHECK_ALWAYS_DF|_CRTDBG_LEAK_CHECK_DF);
|
||||
#endif
|
||||
|
||||
n = parse_arg(&opt, argc, argv);
|
||||
if(n+2 > argc){
|
||||
show_usage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for(;n<=(argc-2);n+=2){
|
||||
test_arib_std_b25(argv[n+0], argv[n+1], &opt);
|
||||
}
|
||||
|
||||
#if defined(WIN32)
|
||||
_CrtDumpMemoryLeaks();
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static void show_usage()
|
||||
{
|
||||
fprintf(stderr, "b25 - ARIB STD-B25 test program ver. 0.2.5 (2012, 2/13)\n");
|
||||
fprintf(stderr, "usage: b25 [options] src.m2t dst.m2t [more pair ..]\n");
|
||||
fprintf(stderr, "options:\n");
|
||||
fprintf(stderr, " -r round (integer, default=4)\n");
|
||||
fprintf(stderr, " -s strip\n");
|
||||
fprintf(stderr, " 0: keep null(padding) stream (default)\n");
|
||||
fprintf(stderr, " 1: strip null stream\n");
|
||||
fprintf(stderr, " -m EMM\n");
|
||||
fprintf(stderr, " 0: ignore EMM (default)\n");
|
||||
fprintf(stderr, " 1: send EMM to B-CAS card\n");
|
||||
fprintf(stderr, " -p power_on_control_info\n");
|
||||
fprintf(stderr, " 0: do nothing additionaly\n");
|
||||
fprintf(stderr, " 1: show B-CAS EMM receiving request (default)\n");
|
||||
fprintf(stderr, " -v verbose\n");
|
||||
fprintf(stderr, " 0: silent\n");
|
||||
fprintf(stderr, " 1: show processing status (default)\n");
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
static int parse_arg(OPTION *dst, int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
dst->round = 4;
|
||||
dst->strip = 0;
|
||||
dst->emm = 0;
|
||||
dst->power_ctrl = 1;
|
||||
dst->verbose = 1;
|
||||
|
||||
for(i=1;i<argc;i++){
|
||||
if(argv[i][0] != '-'){
|
||||
break;
|
||||
}
|
||||
switch(argv[i][1]){
|
||||
case 'm':
|
||||
if(argv[i][2]){
|
||||
dst->emm = atoi(argv[i]+2);
|
||||
}else{
|
||||
dst->emm = atoi(argv[i+1]);
|
||||
i += 1;
|
||||
}
|
||||
break;
|
||||
case 'p':
|
||||
if(argv[i][2]){
|
||||
dst->power_ctrl = atoi(argv[i]+2);
|
||||
}else{
|
||||
dst->power_ctrl = atoi(argv[i+1]);
|
||||
i += 1;
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
if(argv[i][2]){
|
||||
dst->round = atoi(argv[i]+2);
|
||||
}else{
|
||||
dst->round = atoi(argv[i+1]);
|
||||
i += 1;
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
if(argv[i][2]){
|
||||
dst->strip = atoi(argv[i]+2);
|
||||
}else{
|
||||
dst->strip = atoi(argv[i+1]);
|
||||
i += 1;
|
||||
}
|
||||
break;
|
||||
case 'v':
|
||||
if(argv[i][2]){
|
||||
dst->verbose = atoi(argv[i]+2);
|
||||
}else{
|
||||
dst->verbose = atoi(argv[i+1]);
|
||||
i += 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "error - unknown option '-%c'\n", argv[i][1]);
|
||||
return argc;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static void test_arib_std_b25(const char *src, const char *dst, OPTION *opt)
|
||||
{
|
||||
int code,i,n,m;
|
||||
int sfd,dfd;
|
||||
|
||||
int64_t total;
|
||||
int64_t offset;
|
||||
#if defined(WIN32)
|
||||
unsigned long tick,tock;
|
||||
#else
|
||||
struct timeval tick,tock;
|
||||
double millisec;
|
||||
#endif
|
||||
double mbps;
|
||||
|
||||
ARIB_STD_B25 *b25;
|
||||
B_CAS_CARD *bcas;
|
||||
|
||||
ARIB_STD_B25_PROGRAM_INFO pgrm;
|
||||
|
||||
uint8_t data[64*1024];
|
||||
|
||||
ARIB_STD_B25_BUFFER sbuf;
|
||||
ARIB_STD_B25_BUFFER dbuf;
|
||||
|
||||
sfd = -1;
|
||||
dfd = -1;
|
||||
b25 = NULL;
|
||||
bcas = NULL;
|
||||
|
||||
sfd = _open(src, _O_BINARY|_O_RDONLY|_O_SEQUENTIAL);
|
||||
if(sfd < 0){
|
||||
fprintf(stderr, "error - failed on _open(%s) [src]\n", src);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
_lseeki64(sfd, 0, SEEK_END);
|
||||
total = _telli64(sfd);
|
||||
_lseeki64(sfd, 0, SEEK_SET);
|
||||
|
||||
b25 = create_arib_std_b25();
|
||||
if(b25 == NULL){
|
||||
fprintf(stderr, "error - failed on create_arib_std_b25()\n");
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
code = b25->set_multi2_round(b25, opt->round);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::set_multi2_round() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
code = b25->set_strip(b25, opt->strip);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::set_strip() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
code = b25->set_emm_proc(b25, opt->emm);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::set_emm_proc() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
bcas = create_b_cas_card();
|
||||
if(bcas == NULL){
|
||||
fprintf(stderr, "error - failed on create_b_cas_card()\n");
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
code = bcas->init(bcas);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on B_CAS_CARD::init() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
code = b25->set_b_cas_card(b25, bcas);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::set_b_cas_card() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
dfd = _open(dst, _O_BINARY|_O_WRONLY|_O_SEQUENTIAL|_O_CREAT|_O_TRUNC, _S_IREAD|_S_IWRITE);
|
||||
if(dfd < 0){
|
||||
fprintf(stderr, "error - failed on _open(%s) [dst]\n", dst);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
offset = 0;
|
||||
#if defined(WIN32)
|
||||
tock = GetTickCount();
|
||||
#else
|
||||
gettimeofday(&tock, NULL);
|
||||
#endif
|
||||
while( (n = _read(sfd, data, sizeof(data))) > 0 ){
|
||||
sbuf.data = data;
|
||||
sbuf.size = n;
|
||||
|
||||
code = b25->put(b25, &sbuf);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::put() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
code = b25->get(b25, &dbuf);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::get() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
if(dbuf.size > 0){
|
||||
n = _write(dfd, dbuf.data, dbuf.size);
|
||||
if(n != dbuf.size){
|
||||
fprintf(stderr, "error failed on _write(%d)\n", dbuf.size);
|
||||
goto LAST;
|
||||
}
|
||||
}
|
||||
|
||||
offset += sbuf.size;
|
||||
if(opt->verbose != 0){
|
||||
m = (int)(10000*offset/total);
|
||||
mbps = 0.0;
|
||||
#if defined(WIN32)
|
||||
tick = GetTickCount();
|
||||
if (tick-tock > 100) {
|
||||
mbps = offset;
|
||||
mbps /= 1024;
|
||||
mbps /= (tick-tock);
|
||||
}
|
||||
#else
|
||||
gettimeofday(&tick, NULL);
|
||||
millisec = (tick.tv_sec - tock.tv_sec) * 1000;
|
||||
millisec += (tick.tv_usec - tock.tv_usec) / 1000;
|
||||
if(millisec > 100.0) {
|
||||
mbps = offset;
|
||||
mbps /= 1024;
|
||||
mbps /= millisec;
|
||||
}
|
||||
#endif
|
||||
fprintf(stderr, "\rprocessing: %2d.%02d%% [%6.2f MB/sec]", m/100, m%100, mbps);
|
||||
}
|
||||
}
|
||||
|
||||
code = b25->flush(b25);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::flush() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
code = b25->get(b25, &dbuf);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::get() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
|
||||
if(dbuf.size > 0){
|
||||
n = _write(dfd, dbuf.data, dbuf.size);
|
||||
if(n != dbuf.size){
|
||||
fprintf(stderr, "error - failed on _write(%d)\n", dbuf.size);
|
||||
goto LAST;
|
||||
}
|
||||
}
|
||||
|
||||
if(opt->verbose != 0){
|
||||
mbps = 0.0;
|
||||
#if defined(WIN32)
|
||||
tick = GetTickCount();
|
||||
if (tick-tock > 100) {
|
||||
mbps = offset;
|
||||
mbps /= 1024;
|
||||
mbps /= (tick-tock);
|
||||
}
|
||||
#else
|
||||
gettimeofday(&tick, NULL);
|
||||
millisec = (tick.tv_sec - tock.tv_sec) * 1000;
|
||||
millisec += (tick.tv_usec - tock.tv_usec) / 1000;
|
||||
if(millisec > 100.0) {
|
||||
mbps = offset;
|
||||
mbps /= 1024;
|
||||
mbps /= millisec;
|
||||
}
|
||||
#endif
|
||||
fprintf(stderr, "\rprocessing: finish [%6.2f MB/sec]\n", mbps);
|
||||
fflush(stderr);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
n = b25->get_program_count(b25);
|
||||
if(n < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::get_program_count() : code=%d\n", code);
|
||||
goto LAST;
|
||||
}
|
||||
for(i=0;i<n;i++){
|
||||
code = b25->get_program_info(b25, &pgrm, i);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on ARIB_STD_B25::get_program_info(%d) : code=%d\n", i, code);
|
||||
goto LAST;
|
||||
}
|
||||
if(pgrm.ecm_unpurchased_count > 0){
|
||||
fprintf(stderr, "warning - unpurchased ECM is detected\n");
|
||||
fprintf(stderr, " channel: %d\n", pgrm.program_number);
|
||||
fprintf(stderr, " unpurchased ECM count: %d\n", pgrm.ecm_unpurchased_count);
|
||||
fprintf(stderr, " last ECM error code: %04x\n", pgrm.last_ecm_error_code);
|
||||
#if defined(WIN32)
|
||||
fprintf(stderr, " undecrypted TS packet: %I64d\n", pgrm.undecrypted_packet_count);
|
||||
fprintf(stderr, " total TS packet: %I64d\n", pgrm.total_packet_count);
|
||||
#else
|
||||
fprintf(stderr, " undecrypted TS packet: %"PRId64"\n", pgrm.undecrypted_packet_count);
|
||||
fprintf(stderr, " total TS packet: %"PRId64"\n", pgrm.total_packet_count);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if(opt->power_ctrl != 0){
|
||||
show_bcas_power_on_control_info(bcas);
|
||||
}
|
||||
|
||||
LAST:
|
||||
|
||||
if(sfd >= 0){
|
||||
_close(sfd);
|
||||
sfd = -1;
|
||||
}
|
||||
|
||||
if(dfd >= 0){
|
||||
_close(dfd);
|
||||
dfd = -1;
|
||||
}
|
||||
|
||||
if(b25 != NULL){
|
||||
b25->release(b25);
|
||||
b25 = NULL;
|
||||
}
|
||||
|
||||
if(bcas != NULL){
|
||||
bcas->release(bcas);
|
||||
bcas = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void show_bcas_power_on_control_info(B_CAS_CARD *bcas)
|
||||
{
|
||||
int code;
|
||||
int i,w;
|
||||
B_CAS_PWR_ON_CTRL_INFO pwc;
|
||||
|
||||
code = bcas->get_pwr_on_ctrl(bcas, &pwc);
|
||||
if(code < 0){
|
||||
fprintf(stderr, "error - failed on B_CAS_CARD::get_pwr_on_ctrl() : code=%d\n", code);
|
||||
return;
|
||||
}
|
||||
|
||||
if(pwc.count == 0){
|
||||
fprintf(stdout, "no EMM receiving request\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stdout, "total %d EMM receiving request\n", pwc.count);
|
||||
for(i=0;i<pwc.count;i++){
|
||||
fprintf(stdout, "+ [%d] : tune ", i);
|
||||
switch(pwc.data[i].network_id){
|
||||
case 4:
|
||||
w = pwc.data[i].transport_id;
|
||||
fprintf(stdout, "BS-%d/TS-%d ", ((w >> 4) & 0x1f), (w & 7));
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
w = pwc.data[i].transport_id;
|
||||
fprintf(stdout, "ND-%d/TS-%d ", ((w >> 4) & 0x1f), (w & 7));
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "unknown(b:0x%02x,n:0x%04x,t:0x%04x) ", pwc.data[i].broadcaster_group_id, pwc.data[i].network_id, pwc.data[i].transport_id);
|
||||
break;
|
||||
}
|
||||
fprintf(stdout, "between %04d %02d/%02d ", pwc.data[i].s_yy, pwc.data[i].s_mm, pwc.data[i].s_dd);
|
||||
fprintf(stdout, "to %04d %02d/%02d ", pwc.data[i].l_yy, pwc.data[i].l_mm, pwc.data[i].l_dd);
|
||||
fprintf(stdout, "least %d hours\n", pwc.data[i].hold_time);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,36 +1,36 @@
|
||||
#ifndef TS_COMMON_TYPES_H
|
||||
#define TS_COMMON_TYPES_H
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
typedef struct {
|
||||
int32_t sync; /* 0- 7 : 8 bits */
|
||||
int32_t transport_error_indicator; /* 8- 8 : 1 bit */
|
||||
int32_t payload_unit_start_indicator; /* 9- 9 : 1 bit */
|
||||
int32_t transport_priority; /* 10-10 : 1 bits */
|
||||
int32_t pid; /* 11-23 : 13 bits */
|
||||
int32_t transport_scrambling_control; /* 24-25 : 2 bits */
|
||||
int32_t adaptation_field_control; /* 26-27 : 2 bits */
|
||||
int32_t continuity_counter; /* 28-31 : 4 bits */
|
||||
} TS_HEADER;
|
||||
|
||||
typedef struct {
|
||||
int32_t table_id; /* 0- 7 : 8 bits */
|
||||
int32_t section_syntax_indicator; /* 8- 8 : 1 bit */
|
||||
int32_t private_indicator; /* 9- 9 : 1 bit */
|
||||
int32_t section_length; /* 12-23 : 12 bits */
|
||||
int32_t table_id_extension; /* 24-39 : 16 bits */
|
||||
int32_t version_number; /* 42-46 : 5 bits */
|
||||
int32_t current_next_indicator; /* 47-57 : 1 bit */
|
||||
int32_t section_number; /* 48-55 : 8 bits */
|
||||
int32_t last_section_number; /* 56-63 : 8 bits */
|
||||
} TS_SECTION_HEADER;
|
||||
|
||||
typedef struct {
|
||||
TS_SECTION_HEADER hdr;
|
||||
uint8_t *raw;
|
||||
uint8_t *data;
|
||||
uint8_t *tail;
|
||||
} TS_SECTION;
|
||||
|
||||
#endif /* TS_COMMON_TYPES_H */
|
||||
#ifndef TS_COMMON_TYPES_H
|
||||
#define TS_COMMON_TYPES_H
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
typedef struct {
|
||||
int32_t sync; /* 0- 7 : 8 bits */
|
||||
int32_t transport_error_indicator; /* 8- 8 : 1 bit */
|
||||
int32_t payload_unit_start_indicator; /* 9- 9 : 1 bit */
|
||||
int32_t transport_priority; /* 10-10 : 1 bits */
|
||||
int32_t pid; /* 11-23 : 13 bits */
|
||||
int32_t transport_scrambling_control; /* 24-25 : 2 bits */
|
||||
int32_t adaptation_field_control; /* 26-27 : 2 bits */
|
||||
int32_t continuity_counter; /* 28-31 : 4 bits */
|
||||
} TS_HEADER;
|
||||
|
||||
typedef struct {
|
||||
int32_t table_id; /* 0- 7 : 8 bits */
|
||||
int32_t section_syntax_indicator; /* 8- 8 : 1 bit */
|
||||
int32_t private_indicator; /* 9- 9 : 1 bit */
|
||||
int32_t section_length; /* 12-23 : 12 bits */
|
||||
int32_t table_id_extension; /* 24-39 : 16 bits */
|
||||
int32_t version_number; /* 42-46 : 5 bits */
|
||||
int32_t current_next_indicator; /* 47-57 : 1 bit */
|
||||
int32_t section_number; /* 48-55 : 8 bits */
|
||||
int32_t last_section_number; /* 56-63 : 8 bits */
|
||||
} TS_SECTION_HEADER;
|
||||
|
||||
typedef struct {
|
||||
TS_SECTION_HEADER hdr;
|
||||
uint8_t *raw;
|
||||
uint8_t *data;
|
||||
uint8_t *tail;
|
||||
} TS_SECTION;
|
||||
|
||||
#endif /* TS_COMMON_TYPES_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,40 +1,40 @@
|
||||
#ifndef TS_SECTION_PARSER_H
|
||||
#define TS_SECTION_PARSER_H
|
||||
|
||||
#include "ts_common_types.h"
|
||||
|
||||
typedef struct {
|
||||
int64_t total; /* total received section count */
|
||||
int64_t unique; /* unique section count */
|
||||
int64_t error; /* crc and other error section count */
|
||||
} TS_SECTION_PARSER_STAT;
|
||||
|
||||
typedef struct {
|
||||
|
||||
void *private_data;
|
||||
|
||||
void (* release)(void *parser);
|
||||
|
||||
int (* reset)(void *parser);
|
||||
|
||||
int (* put)(void *parser, TS_HEADER *hdr, uint8_t *data, intptr_t size);
|
||||
int (* get)(void *parser, TS_SECTION *sect);
|
||||
int (* ret)(void *parser, TS_SECTION *sect);
|
||||
|
||||
int (* get_count)(void *parser);
|
||||
|
||||
int (* get_stat)(void *parser, TS_SECTION_PARSER_STAT *stat);
|
||||
|
||||
} TS_SECTION_PARSER;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern TS_SECTION_PARSER *create_ts_section_parser(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TS_SECTION_PARSER_H */
|
||||
#ifndef TS_SECTION_PARSER_H
|
||||
#define TS_SECTION_PARSER_H
|
||||
|
||||
#include "ts_common_types.h"
|
||||
|
||||
typedef struct {
|
||||
int64_t total; /* total received section count */
|
||||
int64_t unique; /* unique section count */
|
||||
int64_t error; /* crc and other error section count */
|
||||
} TS_SECTION_PARSER_STAT;
|
||||
|
||||
typedef struct {
|
||||
|
||||
void *private_data;
|
||||
|
||||
void (* release)(void *parser);
|
||||
|
||||
int (* reset)(void *parser);
|
||||
|
||||
int (* put)(void *parser, TS_HEADER *hdr, uint8_t *data, intptr_t size);
|
||||
int (* get)(void *parser, TS_SECTION *sect);
|
||||
int (* ret)(void *parser, TS_SECTION *sect);
|
||||
|
||||
int (* get_count)(void *parser);
|
||||
|
||||
int (* get_stat)(void *parser, TS_SECTION_PARSER_STAT *stat);
|
||||
|
||||
} TS_SECTION_PARSER;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern TS_SECTION_PARSER *create_ts_section_parser(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TS_SECTION_PARSER_H */
|
||||
|
@ -1,12 +1,12 @@
|
||||
#ifndef TS_SECTION_PARSER_ERROR_CODE_H
|
||||
#define TS_SECTION_PARESR_ERROR_CODE_H
|
||||
|
||||
#define TS_SECTION_PARSER_ERROR_INVALID_PARAM -1
|
||||
#define TS_SECTION_PARSER_ERROR_NO_ENOUGH_MEMORY -2
|
||||
#define TS_SECTION_PARSER_ERROR_INVALID_TS_PID -3
|
||||
#define TS_SECTION_PARSER_ERROR_NO_SECTION_DATA -4
|
||||
|
||||
#define TS_SECTION_PARSER_WARN_CRC_MISSMATCH 1
|
||||
#define TS_SECTION_PARSER_WARN_LENGTH_MISSMATCH 2
|
||||
|
||||
#endif /* TS_SECTION_PARSER_ERROR_CODE_H */
|
||||
#ifndef TS_SECTION_PARSER_ERROR_CODE_H
|
||||
#define TS_SECTION_PARESR_ERROR_CODE_H
|
||||
|
||||
#define TS_SECTION_PARSER_ERROR_INVALID_PARAM -1
|
||||
#define TS_SECTION_PARSER_ERROR_NO_ENOUGH_MEMORY -2
|
||||
#define TS_SECTION_PARSER_ERROR_INVALID_TS_PID -3
|
||||
#define TS_SECTION_PARSER_ERROR_NO_SECTION_DATA -4
|
||||
|
||||
#define TS_SECTION_PARSER_WARN_CRC_MISSMATCH 1
|
||||
#define TS_SECTION_PARSER_WARN_LENGTH_MISSMATCH 2
|
||||
|
||||
#endif /* TS_SECTION_PARSER_ERROR_CODE_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user