├── TVCAS_B1
├── TVCAS_B1.def
├── TVCAS_B1.rc
├── BonBaseClass.h
├── TVCAS_B1.h
├── BonBaseClass.cpp
├── stdafx.cpp
├── StdUtil.h
├── MediaData.h
├── TsPacketParser.h
├── MediaDecoder.h
├── Exception.h
├── Common.h
├── stdafx.h
├── MediaDecoder.cpp
├── StdUtil.cpp
├── Multi2Decoder.h
├── CasCard.h
├── TVCAS_B1.vcxproj.filters
├── TsPacketParser.cpp
├── CardReader.h
├── TsUtilClass.h
├── TsDescrambler.h
├── TsEncode.h
├── Exception.cpp
├── MediaData.cpp
├── TVCAS.h
└── TsStream.h
├── TVCAS_B25
├── TVCAS_B25.def
├── TVCAS_B25.rc
├── BonBaseClass.h
├── TVCAS_B25.h
├── BonBaseClass.cpp
├── stdafx.cpp
├── StdUtil.h
├── MediaData.h
├── TsPacketParser.h
├── MediaDecoder.h
├── Exception.h
├── Common.h
├── stdafx.h
├── MediaDecoder.cpp
├── StdUtil.cpp
├── Multi2Decoder.h
├── CasCard.h
├── TVCAS_B25.vcxproj.filters
├── TsPacketParser.cpp
├── CardReader.h
├── TsUtilClass.h
├── TsDescrambler.h
├── TsEncode.h
├── Exception.cpp
├── MediaData.cpp
├── TVCAS.h
└── TsStream.h
├── Multi2Decoder
├── stdafx.cpp
├── Multi2Decoder.vcxproj.filters
├── Multi2DecoderSIMD.h
├── stdafx.h
├── Multi2Decoder.h
└── Multi2Decoder.vcxproj
├── ReadMe.md
├── TvCas.sln
└── .gitignore
/TVCAS_B1/TVCAS_B1.def:
--------------------------------------------------------------------------------
1 | EXPORTS
2 | TVCAS_GetModuleInfo
3 | TVCAS_CreateInstance
4 |
--------------------------------------------------------------------------------
/TVCAS_B25/TVCAS_B25.def:
--------------------------------------------------------------------------------
1 | EXPORTS
2 | TVCAS_GetModuleInfo
3 | TVCAS_CreateInstance
4 |
--------------------------------------------------------------------------------
/TVCAS_B1/TVCAS_B1.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tsukumijima/TvCas/master/TVCAS_B1/TVCAS_B1.rc
--------------------------------------------------------------------------------
/TVCAS_B25/TVCAS_B25.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tsukumijima/TvCas/master/TVCAS_B25/TVCAS_B25.rc
--------------------------------------------------------------------------------
/TVCAS_B1/BonBaseClass.h:
--------------------------------------------------------------------------------
1 | #ifndef BON_BASE_CLASS_H
2 | #define BON_BASE_CLASS_H
3 |
4 |
5 | #include "Exception.h"
6 | #include "TsUtilClass.h"
7 |
8 |
9 | class __declspec(novtable) CBonBaseClass : public CBonErrorHandler
10 | {
11 | CTracer *m_pTracer;
12 | public:
13 | CBonBaseClass();
14 | virtual ~CBonBaseClass() = 0;
15 | virtual void SetTracer(CTracer *pTracer);
16 | protected:
17 | void Trace(LPCTSTR pszOutput, ...);
18 | };
19 |
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/TVCAS_B25/BonBaseClass.h:
--------------------------------------------------------------------------------
1 | #ifndef BON_BASE_CLASS_H
2 | #define BON_BASE_CLASS_H
3 |
4 |
5 | #include "Exception.h"
6 | #include "TsUtilClass.h"
7 |
8 |
9 | class __declspec(novtable) CBonBaseClass : public CBonErrorHandler
10 | {
11 | CTracer *m_pTracer;
12 | public:
13 | CBonBaseClass();
14 | virtual ~CBonBaseClass() = 0;
15 | virtual void SetTracer(CTracer *pTracer);
16 | protected:
17 | void Trace(LPCTSTR pszOutput, ...);
18 | };
19 |
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/TVCAS_B1/TVCAS_B1.h:
--------------------------------------------------------------------------------
1 | #ifndef TVCAS_B1_H
2 | #define TVCAS_B1_H
3 |
4 |
5 | /*
6 | 改変する場合、以下の条件に従ってください。
7 |
8 | ・ファイル名をオリジナルと異なるものにすること。
9 | ・著作権表記を書き換えること。
10 |
11 | ReadMe.txt も読んでください。
12 | */
13 |
14 | #define TVCAS_MODULE_NAME "B1"
15 | #define TVCAS_MODULE_COPYRIGHT "2sen"
16 | #define TVCAS_MODULE_ORIGINAL_FILE_NAME "B1.tvcas"
17 | #define TVCAS_MODULE_VERSION "0.9.1"
18 |
19 | #define TVCAS_MODULE_VERSION_MAJOR 0
20 | #define TVCAS_MODULE_VERSION_MINOR 9
21 | #define TVCAS_MODULE_VERSION_BUILD 1
22 |
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/TVCAS_B25/TVCAS_B25.h:
--------------------------------------------------------------------------------
1 | #ifndef TVCAS_B25_H
2 | #define TVCAS_B25_H
3 |
4 |
5 | /*
6 | 改変する場合、以下の条件に従ってください。
7 |
8 | ・ファイル名をオリジナルと異なるものにすること。
9 | ・著作権表記を書き換えること。
10 |
11 | ReadMe.txt も読んでください。
12 | */
13 |
14 | #define TVCAS_MODULE_NAME "B25"
15 | #define TVCAS_MODULE_COPYRIGHT "2sen"
16 | #define TVCAS_MODULE_ORIGINAL_FILE_NAME "B25.tvcas"
17 | #define TVCAS_MODULE_VERSION "0.9.1"
18 |
19 | #define TVCAS_MODULE_VERSION_MAJOR 0
20 | #define TVCAS_MODULE_VERSION_MINOR 9
21 | #define TVCAS_MODULE_VERSION_BUILD 1
22 |
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/TVCAS_B1/BonBaseClass.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "BonBaseClass.h"
3 |
4 |
5 |
6 |
7 | CBonBaseClass::CBonBaseClass()
8 | : m_pTracer(NULL)
9 | {
10 | }
11 |
12 |
13 | CBonBaseClass::~CBonBaseClass()
14 | {
15 | }
16 |
17 |
18 | void CBonBaseClass::SetTracer(CTracer *pTracer)
19 | {
20 | m_pTracer = pTracer;
21 | }
22 |
23 |
24 | void CBonBaseClass::Trace(LPCTSTR pszOutput, ...)
25 | {
26 | if (m_pTracer != NULL && pszOutput != NULL) {
27 | va_list Args;
28 |
29 | va_start(Args, pszOutput);
30 | m_pTracer->TraceV(pszOutput, Args);
31 | va_end(Args);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/TVCAS_B25/BonBaseClass.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "BonBaseClass.h"
3 |
4 |
5 |
6 |
7 | CBonBaseClass::CBonBaseClass()
8 | : m_pTracer(NULL)
9 | {
10 | }
11 |
12 |
13 | CBonBaseClass::~CBonBaseClass()
14 | {
15 | }
16 |
17 |
18 | void CBonBaseClass::SetTracer(CTracer *pTracer)
19 | {
20 | m_pTracer = pTracer;
21 | }
22 |
23 |
24 | void CBonBaseClass::Trace(LPCTSTR pszOutput, ...)
25 | {
26 | if (m_pTracer != NULL && pszOutput != NULL) {
27 | va_list Args;
28 |
29 | va_start(Args, pszOutput);
30 | m_pTracer->TraceV(pszOutput, Args);
31 | va_end(Args);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/TVCAS_B1/stdafx.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 |
4 | #ifdef _DEBUG
5 | void DebugTrace(LPCTSTR szFormat, ...)
6 | {
7 | TCHAR szTempStr[1024];
8 | int Length;
9 |
10 | SYSTEMTIME st;
11 | ::GetLocalTime(&st);
12 | Length = ::_stprintf_s(szTempStr, _countof(szTempStr),
13 | TEXT("%02d/%02d %02d:%02d:%02d > "),
14 | st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
15 |
16 | va_list Args;
17 | va_start(Args, szFormat);
18 | ::_vstprintf_s(szTempStr + Length, _countof(szTempStr) - Length, szFormat, Args);
19 | va_end(Args);
20 |
21 | ::OutputDebugString(szTempStr);
22 | }
23 | #endif
24 |
--------------------------------------------------------------------------------
/TVCAS_B25/stdafx.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 |
4 | #ifdef _DEBUG
5 | void DebugTrace(LPCTSTR szFormat, ...)
6 | {
7 | TCHAR szTempStr[1024];
8 | int Length;
9 |
10 | SYSTEMTIME st;
11 | ::GetLocalTime(&st);
12 | Length = ::_stprintf_s(szTempStr, _countof(szTempStr),
13 | TEXT("%02d/%02d %02d:%02d:%02d > "),
14 | st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
15 |
16 | va_list Args;
17 | va_start(Args, szFormat);
18 | ::_vstprintf_s(szTempStr + Length, _countof(szTempStr) - Length, szFormat, Args);
19 | va_end(Args);
20 |
21 | ::OutputDebugString(szTempStr);
22 | }
23 | #endif
24 |
--------------------------------------------------------------------------------
/Multi2Decoder/stdafx.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 |
4 | #ifdef _DEBUG
5 | void DebugTrace(LPCTSTR szFormat, ...)
6 | {
7 | TCHAR szTempStr[1024];
8 | int Length;
9 |
10 | SYSTEMTIME st;
11 | ::GetLocalTime(&st);
12 | Length = ::_stprintf_s(szTempStr, _countof(szTempStr),
13 | TEXT("%02d/%02d %02d:%02d:%02d > "),
14 | st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
15 |
16 | va_list Args;
17 | va_start(Args, szFormat);
18 | ::_vstprintf_s(szTempStr + Length, _countof(szTempStr) - Length, szFormat, Args);
19 | va_end(Args);
20 |
21 | ::OutputDebugString(szTempStr);
22 | }
23 | #endif
24 |
--------------------------------------------------------------------------------
/TVCAS_B1/StdUtil.h:
--------------------------------------------------------------------------------
1 | #ifndef STD_UTIL_H
2 | #define STD_UTIL_H
3 |
4 |
5 | namespace StdUtil {
6 |
7 | int snprintf(char *s,size_t n,const char *format, ...);
8 | int snprintf(wchar_t *s,size_t n,const wchar_t *format, ...);
9 | int vsnprintf(char *s,size_t n,const char *format,va_list args);
10 | int vsnprintf(wchar_t *s,size_t n,const wchar_t *format,va_list args);
11 | inline size_t strlen(const char *s) { return ::strlen(s); }
12 | inline size_t strlen(const wchar_t *s) { return ::wcslen(s); }
13 | inline size_t strnlen(const char *s,size_t n) { return ::strnlen(s,n); }
14 | inline size_t strnlen(const wchar_t *s,size_t n) { return ::wcsnlen(s,n); }
15 | inline char *strcpy(char *dest,const char *src) { return ::strcpy(dest,src); }
16 | inline wchar_t *strcpy(wchar_t *dest,const wchar_t *src) { return ::wcscpy(dest,src); }
17 | char *strncpy(char *dest,size_t n,const char *src);
18 | wchar_t *strncpy(wchar_t *dest,size_t n,const wchar_t *src);
19 | char *strdup(const char *s);
20 | wchar_t *strdup(const wchar_t *s);
21 |
22 | }
23 |
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/TVCAS_B25/StdUtil.h:
--------------------------------------------------------------------------------
1 | #ifndef STD_UTIL_H
2 | #define STD_UTIL_H
3 |
4 |
5 | namespace StdUtil {
6 |
7 | int snprintf(char *s,size_t n,const char *format, ...);
8 | int snprintf(wchar_t *s,size_t n,const wchar_t *format, ...);
9 | int vsnprintf(char *s,size_t n,const char *format,va_list args);
10 | int vsnprintf(wchar_t *s,size_t n,const wchar_t *format,va_list args);
11 | inline size_t strlen(const char *s) { return ::strlen(s); }
12 | inline size_t strlen(const wchar_t *s) { return ::wcslen(s); }
13 | inline size_t strnlen(const char *s,size_t n) { return ::strnlen(s,n); }
14 | inline size_t strnlen(const wchar_t *s,size_t n) { return ::wcsnlen(s,n); }
15 | inline char *strcpy(char *dest,const char *src) { return ::strcpy(dest,src); }
16 | inline wchar_t *strcpy(wchar_t *dest,const wchar_t *src) { return ::wcscpy(dest,src); }
17 | char *strncpy(char *dest,size_t n,const char *src);
18 | wchar_t *strncpy(wchar_t *dest,size_t n,const wchar_t *src);
19 | char *strdup(const char *s);
20 | wchar_t *strdup(const wchar_t *s);
21 |
22 | }
23 |
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/Multi2Decoder/Multi2Decoder.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | ソース ファイル
16 |
17 |
18 | ソース ファイル
19 |
20 |
21 | ソース ファイル
22 |
23 |
24 |
25 |
26 | ヘッダー ファイル
27 |
28 |
29 | ヘッダー ファイル
30 |
31 |
32 | ヘッダー ファイル
33 |
34 |
35 |
--------------------------------------------------------------------------------
/Multi2Decoder/Multi2DecoderSIMD.h:
--------------------------------------------------------------------------------
1 | #ifndef MULTI2_DECODER_SIMD
2 | #define MULTI2_DECODER_SIMD
3 |
4 |
5 | namespace Multi2DecoderSIMD
6 | {
7 |
8 | struct WORKKEY;
9 |
10 | bool IsSSE2Available();
11 | bool IsSSSE3Available();
12 | bool Initialize();
13 |
14 | void AllocWorkKey(WORKKEY **ppWorkKeyOdd, WORKKEY **ppWorkKeyEven);
15 | void FreeWorkKey(WORKKEY **ppWorkKeyOdd, WORKKEY **ppWorkKeyEven);
16 | void SetWorkKey(WORKKEY *pWorkKey, const CMulti2Decoder::SYSKEY &SrcKey);
17 |
18 | void Decode(BYTE * __restrict pData, const DWORD dwSize,
19 | const CMulti2Decoder::SYSKEY * __restrict pWorkKey,
20 | const WORKKEY * __restrict pPackedWorkKey,
21 | const CMulti2Decoder::DATKEY * __restrict pInitialCbc);
22 | #ifdef MULTI2_SSE2
23 | void DecodeSSE2(BYTE * __restrict pData, const DWORD dwSize,
24 | const CMulti2Decoder::SYSKEY * __restrict pWorkKey,
25 | const WORKKEY * __restrict pPackedWorkKey,
26 | const CMulti2Decoder::DATKEY * __restrict pInitialCbc);
27 | #endif
28 | #ifdef MULTI2_SSSE3
29 | void DecodeSSSE3(BYTE * __restrict pData, const DWORD dwSize,
30 | const CMulti2Decoder::SYSKEY * __restrict pWorkKey,
31 | const WORKKEY * __restrict pPackedWorkKey,
32 | const CMulti2Decoder::DATKEY * __restrict pInitialCbc);
33 | #endif
34 |
35 | } // namespace Multi2DecoderSIMD
36 |
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/TVCAS_B1/MediaData.h:
--------------------------------------------------------------------------------
1 | // MediaData.h: CMediaData クラスのインターフェイス
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #pragma once
6 |
7 |
8 | class CMediaData
9 | {
10 | public:
11 | CMediaData();
12 | CMediaData(const CMediaData &Operand);
13 | CMediaData(const DWORD dwBuffSize);
14 | CMediaData(const BYTE *pData, const DWORD dwDataSize);
15 | CMediaData(const BYTE byFiller, const DWORD dwDataSize);
16 |
17 | virtual ~CMediaData();
18 |
19 | CMediaData & operator = (const CMediaData &Operand);
20 | CMediaData & operator += (const CMediaData &Operand);
21 |
22 | BYTE *GetData();
23 | const BYTE *GetData() const;
24 | const DWORD GetSize() const { return m_dwDataSize; }
25 |
26 | void SetAt(const DWORD dwPos, const BYTE byData);
27 | const BYTE GetAt(const DWORD dwPos) const;
28 |
29 | const DWORD SetData(const void *pData, const DWORD dwDataSize);
30 | const DWORD AddData(const void *pData, const DWORD dwDataSize);
31 | const DWORD AddData(const CMediaData *pData);
32 | const DWORD AddByte(const BYTE byData);
33 | const DWORD TrimHead(const DWORD dwTrimSize = 1UL);
34 | const DWORD TrimTail(const DWORD dwTrimSize = 1UL);
35 |
36 | const DWORD GetBuffer(const DWORD dwGetSize);
37 |
38 | const DWORD SetSize(const DWORD dwSetSize);
39 | const DWORD SetSize(const DWORD dwSetSize, const BYTE byFiller);
40 |
41 | void ClearSize(void);
42 | void ClearBuffer(void);
43 |
44 | protected:
45 | virtual void *Allocate(size_t Size);
46 | virtual void Free(void *pBuffer);
47 | virtual void *ReAllocate(void *pBuffer, size_t Size);
48 |
49 | DWORD m_dwDataSize;
50 | DWORD m_dwBuffSize;
51 | BYTE *m_pData;
52 | };
53 |
--------------------------------------------------------------------------------
/TVCAS_B25/MediaData.h:
--------------------------------------------------------------------------------
1 | // MediaData.h: CMediaData クラスのインターフェイス
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #pragma once
6 |
7 |
8 | class CMediaData
9 | {
10 | public:
11 | CMediaData();
12 | CMediaData(const CMediaData &Operand);
13 | CMediaData(const DWORD dwBuffSize);
14 | CMediaData(const BYTE *pData, const DWORD dwDataSize);
15 | CMediaData(const BYTE byFiller, const DWORD dwDataSize);
16 |
17 | virtual ~CMediaData();
18 |
19 | CMediaData & operator = (const CMediaData &Operand);
20 | CMediaData & operator += (const CMediaData &Operand);
21 |
22 | BYTE *GetData();
23 | const BYTE *GetData() const;
24 | const DWORD GetSize() const { return m_dwDataSize; }
25 |
26 | void SetAt(const DWORD dwPos, const BYTE byData);
27 | const BYTE GetAt(const DWORD dwPos) const;
28 |
29 | const DWORD SetData(const void *pData, const DWORD dwDataSize);
30 | const DWORD AddData(const void *pData, const DWORD dwDataSize);
31 | const DWORD AddData(const CMediaData *pData);
32 | const DWORD AddByte(const BYTE byData);
33 | const DWORD TrimHead(const DWORD dwTrimSize = 1UL);
34 | const DWORD TrimTail(const DWORD dwTrimSize = 1UL);
35 |
36 | const DWORD GetBuffer(const DWORD dwGetSize);
37 |
38 | const DWORD SetSize(const DWORD dwSetSize);
39 | const DWORD SetSize(const DWORD dwSetSize, const BYTE byFiller);
40 |
41 | void ClearSize(void);
42 | void ClearBuffer(void);
43 |
44 | protected:
45 | virtual void *Allocate(size_t Size);
46 | virtual void Free(void *pBuffer);
47 | virtual void *ReAllocate(void *pBuffer, size_t Size);
48 |
49 | DWORD m_dwDataSize;
50 | DWORD m_dwBuffSize;
51 | BYTE *m_pData;
52 | };
53 |
--------------------------------------------------------------------------------
/TVCAS_B1/TsPacketParser.h:
--------------------------------------------------------------------------------
1 | // TsPacketParser.h: CTsPacketParser クラスのインターフェイス
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #pragma once
6 |
7 |
8 | #include "MediaDecoder.h"
9 | #include "TsStream.h"
10 |
11 |
12 | /////////////////////////////////////////////////////////////////////////////
13 | // TSパケット抽出デコーダ(バイナリデータからTSパケットを抽出する)
14 | /////////////////////////////////////////////////////////////////////////////
15 | // Input #0 : CMediaData TSパケットを含むバイナリデータ
16 | // Output #0 : CTsPacket TSパケット
17 | /////////////////////////////////////////////////////////////////////////////
18 |
19 | class CTsPacketParser : public CMediaDecoder
20 | {
21 | public:
22 | CTsPacketParser(IEventHandler *pEventHandler = NULL);
23 | virtual ~CTsPacketParser();
24 |
25 | // IMediaDecoder
26 | virtual void Reset(void);
27 | virtual const bool InputMedia(CMediaData *pMediaData, const DWORD dwInputIndex = 0UL);
28 |
29 | // CTsPacketParser
30 | bool InputPacket(const void *pData, DWORD DataSize);
31 | void SetOutputNullPacket(const bool bEnable = true);
32 | ULONGLONG GetInputPacketCount(void) const;
33 | ULONGLONG GetOutputPacketCount(void) const;
34 | ULONGLONG GetErrorPacketCount(void) const;
35 | ULONGLONG GetContinuityErrorPacketCount(void) const;
36 | void ResetErrorPacketCount(void);
37 |
38 | private:
39 | void inline SyncPacket(const BYTE *pData, const DWORD dwSize);
40 | bool inline ParsePacket(void);
41 |
42 | CTsPacket m_TsPacket;
43 |
44 | bool m_bOutputNullPacket;
45 |
46 | ULONGLONG m_InputPacketCount;
47 | ULONGLONG m_OutputPacketCount;
48 | ULONGLONG m_ErrorPacketCount;
49 | ULONGLONG m_ContinuityErrorPacketCount;
50 | BYTE m_abyContCounter[0x1FFF];
51 | };
52 |
--------------------------------------------------------------------------------
/TVCAS_B25/TsPacketParser.h:
--------------------------------------------------------------------------------
1 | // TsPacketParser.h: CTsPacketParser クラスのインターフェイス
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #pragma once
6 |
7 |
8 | #include "MediaDecoder.h"
9 | #include "TsStream.h"
10 |
11 |
12 | /////////////////////////////////////////////////////////////////////////////
13 | // TSパケット抽出デコーダ(バイナリデータからTSパケットを抽出する)
14 | /////////////////////////////////////////////////////////////////////////////
15 | // Input #0 : CMediaData TSパケットを含むバイナリデータ
16 | // Output #0 : CTsPacket TSパケット
17 | /////////////////////////////////////////////////////////////////////////////
18 |
19 | class CTsPacketParser : public CMediaDecoder
20 | {
21 | public:
22 | CTsPacketParser(IEventHandler *pEventHandler = NULL);
23 | virtual ~CTsPacketParser();
24 |
25 | // IMediaDecoder
26 | virtual void Reset(void);
27 | virtual const bool InputMedia(CMediaData *pMediaData, const DWORD dwInputIndex = 0UL);
28 |
29 | // CTsPacketParser
30 | bool InputPacket(const void *pData, DWORD DataSize);
31 | void SetOutputNullPacket(const bool bEnable = true);
32 | ULONGLONG GetInputPacketCount(void) const;
33 | ULONGLONG GetOutputPacketCount(void) const;
34 | ULONGLONG GetErrorPacketCount(void) const;
35 | ULONGLONG GetContinuityErrorPacketCount(void) const;
36 | void ResetErrorPacketCount(void);
37 |
38 | private:
39 | void inline SyncPacket(const BYTE *pData, const DWORD dwSize);
40 | bool inline ParsePacket(void);
41 |
42 | CTsPacket m_TsPacket;
43 |
44 | bool m_bOutputNullPacket;
45 |
46 | ULONGLONG m_InputPacketCount;
47 | ULONGLONG m_OutputPacketCount;
48 | ULONGLONG m_ErrorPacketCount;
49 | ULONGLONG m_ContinuityErrorPacketCount;
50 | BYTE m_abyContCounter[0x1FFF];
51 | };
52 |
--------------------------------------------------------------------------------
/TVCAS_B1/MediaDecoder.h:
--------------------------------------------------------------------------------
1 | // MediaDecoder.h: CMediaDecoder クラスのインターフェイス
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #pragma once
6 |
7 |
8 | #include "Common.h"
9 | #include "BonBaseClass.h"
10 | #include "MediaData.h"
11 | #include "TsUtilClass.h"
12 |
13 |
14 | //////////////////////////////////////////////////////////////////////
15 | // メディアデコーダ基底クラス
16 | //////////////////////////////////////////////////////////////////////
17 |
18 | class ABSTRACT_CLASS_DECL CMediaDecoder : public CBonBaseClass
19 | {
20 | public:
21 | class ABSTRACT_CLASS_DECL IEventHandler
22 | {
23 | public:
24 | virtual const DWORD OnDecoderEvent(CMediaDecoder *pDecoder, const DWORD dwEventID, PVOID pParam) = 0;
25 | };
26 |
27 | CMediaDecoder(IEventHandler *pEventHandler = NULL, const DWORD dwInputNum = 1UL, const DWORD dwOutputNum = 1UL);
28 | virtual ~CMediaDecoder() = 0;
29 |
30 | virtual void Reset(void);
31 | virtual void ResetGraph(void);
32 |
33 | virtual const DWORD GetInputNum(void) const;
34 | virtual const DWORD GetOutputNum(void) const;
35 |
36 | const bool SetOutputDecoder(CMediaDecoder *pDecoder, const DWORD dwOutputIndex = 0UL, const DWORD dwInputIndex = 0UL);
37 | virtual const bool InputMedia(CMediaData *pMediaData, const DWORD dwInputIndex = 0UL);
38 |
39 | protected:
40 | const bool OutputMedia(CMediaData *pMediaData, const DWORD dwOutptIndex = 0UL);
41 | void ResetDownstreamDecoder(void);
42 | const DWORD SendDecoderEvent(const DWORD dwEventID, PVOID pParam = NULL);
43 |
44 | // 出力ピンデータベース
45 | struct TAG_OUTPUTDECODER
46 | {
47 | CMediaDecoder *pDecoder;
48 | DWORD dwInputIndex;
49 | } m_aOutputDecoder[4];
50 |
51 | IEventHandler *m_pEventHandler;
52 |
53 | const DWORD m_dwInputNum;
54 | const DWORD m_dwOutputNum;
55 |
56 | mutable CCriticalLock m_DecoderLock;
57 | };
58 |
--------------------------------------------------------------------------------
/TVCAS_B25/MediaDecoder.h:
--------------------------------------------------------------------------------
1 | // MediaDecoder.h: CMediaDecoder クラスのインターフェイス
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #pragma once
6 |
7 |
8 | #include "Common.h"
9 | #include "BonBaseClass.h"
10 | #include "MediaData.h"
11 | #include "TsUtilClass.h"
12 |
13 |
14 | //////////////////////////////////////////////////////////////////////
15 | // メディアデコーダ基底クラス
16 | //////////////////////////////////////////////////////////////////////
17 |
18 | class ABSTRACT_CLASS_DECL CMediaDecoder : public CBonBaseClass
19 | {
20 | public:
21 | class ABSTRACT_CLASS_DECL IEventHandler
22 | {
23 | public:
24 | virtual const DWORD OnDecoderEvent(CMediaDecoder *pDecoder, const DWORD dwEventID, PVOID pParam) = 0;
25 | };
26 |
27 | CMediaDecoder(IEventHandler *pEventHandler = NULL, const DWORD dwInputNum = 1UL, const DWORD dwOutputNum = 1UL);
28 | virtual ~CMediaDecoder() = 0;
29 |
30 | virtual void Reset(void);
31 | virtual void ResetGraph(void);
32 |
33 | virtual const DWORD GetInputNum(void) const;
34 | virtual const DWORD GetOutputNum(void) const;
35 |
36 | const bool SetOutputDecoder(CMediaDecoder *pDecoder, const DWORD dwOutputIndex = 0UL, const DWORD dwInputIndex = 0UL);
37 | virtual const bool InputMedia(CMediaData *pMediaData, const DWORD dwInputIndex = 0UL);
38 |
39 | protected:
40 | const bool OutputMedia(CMediaData *pMediaData, const DWORD dwOutptIndex = 0UL);
41 | void ResetDownstreamDecoder(void);
42 | const DWORD SendDecoderEvent(const DWORD dwEventID, PVOID pParam = NULL);
43 |
44 | // 出力ピンデータベース
45 | struct TAG_OUTPUTDECODER
46 | {
47 | CMediaDecoder *pDecoder;
48 | DWORD dwInputIndex;
49 | } m_aOutputDecoder[4];
50 |
51 | IEventHandler *m_pEventHandler;
52 |
53 | const DWORD m_dwInputNum;
54 | const DWORD m_dwOutputNum;
55 |
56 | mutable CCriticalLock m_DecoderLock;
57 | };
58 |
--------------------------------------------------------------------------------
/TVCAS_B1/Exception.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 |
4 | class CBonException
5 | {
6 | public:
7 | CBonException();
8 | CBonException(LPCTSTR pszText,LPCTSTR pszAdvise=NULL,LPCTSTR pszSystemMessage=NULL);
9 | CBonException(int ErrorCode,LPCTSTR pszText,LPCTSTR pszAdvise=NULL,LPCTSTR pszSystemMessage=NULL);
10 | CBonException(const CBonException &Exception);
11 | virtual ~CBonException();
12 | CBonException &operator=(const CBonException &Exception);
13 | LPCTSTR GetText() const { return m_pszText; }
14 | LPCTSTR GetAdvise() const { return m_pszAdvise; }
15 | LPCTSTR GetSystemMessage() const { return m_pszSystemMessage; }
16 | int GetErrorCode() const { return m_ErrorCode; }
17 |
18 | friend class CBonErrorHandler;
19 |
20 | protected:
21 | LPTSTR m_pszText;
22 | LPTSTR m_pszAdvise;
23 | LPTSTR m_pszSystemMessage;
24 | int m_ErrorCode;
25 | void SetText(LPCTSTR pszText);
26 | void SetAdvise(LPCTSTR pszAdvise);
27 | void SetSystemMessage(LPCTSTR pszSystemMessage);
28 | void Clear();
29 | };
30 |
31 | class CBonErrorHandler
32 | {
33 | public:
34 | CBonErrorHandler();
35 | CBonErrorHandler(const CBonErrorHandler &ErrorHandler);
36 | virtual ~CBonErrorHandler();
37 | CBonErrorHandler &operator=(const CBonErrorHandler &ErrorHandler);
38 | LPCTSTR GetLastErrorText() const;
39 | LPCTSTR GetLastErrorAdvise() const;
40 | LPCTSTR GetLastErrorSystemMessage() const;
41 | int GetLastErrorCode() const;
42 | const CBonException &GetLastErrorException() const { return m_Exception; }
43 | void FormatLastErrorText(LPTSTR pszText,int MaxLength,LPCTSTR pszLead=NULL) const;
44 |
45 | protected:
46 | void SetErrorText(LPCTSTR pszText);
47 | void SetErrorAdvise(LPCTSTR pszAdvise);
48 | void SetErrorSystemMessage(LPCTSTR pszSystemMessage);
49 | void SetErrorSystemMessageByErrorCode(DWORD ErrorCode);
50 | void SetErrorCode(int ErrorCode);
51 | void SetError(int ErrorCode,LPCTSTR pszText,LPCTSTR pszAdvise=NULL,LPCTSTR pszSystemMessage=NULL);
52 | void SetError(LPCTSTR pszText,LPCTSTR pszAdvise=NULL,LPCTSTR pszSystemMessage=NULL);
53 | void SetError(const CBonException &Exception);
54 | void ClearError();
55 |
56 | private:
57 | CBonException m_Exception;
58 | };
59 |
--------------------------------------------------------------------------------
/TVCAS_B25/Exception.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 |
4 | class CBonException
5 | {
6 | public:
7 | CBonException();
8 | CBonException(LPCTSTR pszText,LPCTSTR pszAdvise=NULL,LPCTSTR pszSystemMessage=NULL);
9 | CBonException(int ErrorCode,LPCTSTR pszText,LPCTSTR pszAdvise=NULL,LPCTSTR pszSystemMessage=NULL);
10 | CBonException(const CBonException &Exception);
11 | virtual ~CBonException();
12 | CBonException &operator=(const CBonException &Exception);
13 | LPCTSTR GetText() const { return m_pszText; }
14 | LPCTSTR GetAdvise() const { return m_pszAdvise; }
15 | LPCTSTR GetSystemMessage() const { return m_pszSystemMessage; }
16 | int GetErrorCode() const { return m_ErrorCode; }
17 |
18 | friend class CBonErrorHandler;
19 |
20 | protected:
21 | LPTSTR m_pszText;
22 | LPTSTR m_pszAdvise;
23 | LPTSTR m_pszSystemMessage;
24 | int m_ErrorCode;
25 | void SetText(LPCTSTR pszText);
26 | void SetAdvise(LPCTSTR pszAdvise);
27 | void SetSystemMessage(LPCTSTR pszSystemMessage);
28 | void Clear();
29 | };
30 |
31 | class CBonErrorHandler
32 | {
33 | public:
34 | CBonErrorHandler();
35 | CBonErrorHandler(const CBonErrorHandler &ErrorHandler);
36 | virtual ~CBonErrorHandler();
37 | CBonErrorHandler &operator=(const CBonErrorHandler &ErrorHandler);
38 | LPCTSTR GetLastErrorText() const;
39 | LPCTSTR GetLastErrorAdvise() const;
40 | LPCTSTR GetLastErrorSystemMessage() const;
41 | int GetLastErrorCode() const;
42 | const CBonException &GetLastErrorException() const { return m_Exception; }
43 | void FormatLastErrorText(LPTSTR pszText,int MaxLength,LPCTSTR pszLead=NULL) const;
44 |
45 | protected:
46 | void SetErrorText(LPCTSTR pszText);
47 | void SetErrorAdvise(LPCTSTR pszAdvise);
48 | void SetErrorSystemMessage(LPCTSTR pszSystemMessage);
49 | void SetErrorSystemMessageByErrorCode(DWORD ErrorCode);
50 | void SetErrorCode(int ErrorCode);
51 | void SetError(int ErrorCode,LPCTSTR pszText,LPCTSTR pszAdvise=NULL,LPCTSTR pszSystemMessage=NULL);
52 | void SetError(LPCTSTR pszText,LPCTSTR pszAdvise=NULL,LPCTSTR pszSystemMessage=NULL);
53 | void SetError(const CBonException &Exception);
54 | void ClearError();
55 |
56 | private:
57 | CBonException m_Exception;
58 | };
59 |
--------------------------------------------------------------------------------
/TVCAS_B1/Common.h:
--------------------------------------------------------------------------------
1 | // Common.h: BonTsEngine共通ヘッダ
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #ifndef BONTSENGINE_COMMON_H
6 | #define BONTSENGINE_COMMON_H
7 |
8 |
9 | // 抽象クラス用
10 | #define ABSTRACT_CLASS_DECL __declspec(novtable)
11 |
12 | // PID
13 | #define PID_PAT 0x0000U // PAT
14 | #define PID_CAT 0x0001U // CAT
15 | #define PID_NIT 0x0010U // NIT
16 | #define PID_SDT 0x0011U // SDT
17 | #define PID_HEIT 0x0012U // H-EIT
18 | #define PID_TOT 0x0014U // TOT
19 | #define PID_SDTT 0x0023U // SDTT
20 | #define PID_BIT 0x0024U // BIT
21 | #define PID_MEIT 0x0026U // M-EIT
22 | #define PID_LEIT 0x0027U // L-EIT
23 | #define PID_CDT 0x0029U // CDT
24 |
25 | // stream_type
26 | #define STREAM_TYPE_MPEG1 0x01 // MPEG-1
27 | #define STREAM_TYPE_MPEG2 0x02 // MPEG-2
28 | #define STREAM_TYPE_CAPTION 0x06 // 字幕
29 | #define STREAM_TYPE_DATACARROUSEL 0x0D // データ放送
30 | #define STREAM_TYPE_AAC 0x0F // AAC
31 | #define STREAM_TYPE_H264 0x1B // H.264
32 | #define STREAM_TYPE_INVALID 0xFF // 無効
33 |
34 | // service_type
35 | #define SERVICE_TYPE_DIGITALTV 0x01 // デジタルTVサービス
36 | #define SERVICE_TYPE_DIGITALAUDIO 0x02 // デジタル音声サービス
37 | #define SERVICE_TYPE_TEMPORARYVIDEO 0xA1 // 臨時映像サービス
38 | #define SERVICE_TYPE_TEMPORARYAUDIO 0xA2 // 臨時音声サービス
39 | #define SERVICE_TYPE_TEMPORARYDATA 0xA3 // 臨時データサービス
40 | #define SERVICE_TYPE_ENGINEERING 0xA4 // エンジニアリングサービス
41 | #define SERVICE_TYPE_PROMOTIONVIDEO 0xA5 // プロモーション映像サービス
42 | #define SERVICE_TYPE_PROMOTIONAUDIO 0xA6 // プロモーション音声サービス
43 | #define SERVICE_TYEP_PROMOTIONDATA 0xA7 // プロモーションデータサービス
44 | #define SERVICE_TYPE_ACCUMULATIONDATA 0xA8 // 事前蓄積用データサービス
45 | #define SERVICE_TYPE_ACCUMULATIONONLYDATA 0xA9 // 蓄積専用データサービス
46 | #define SERVICE_TYPE_BOOKMARKLISTDATA 0xAA // ブックマーク一覧データサービス
47 | #define SERVICE_TYPE_DATA 0xC0 // データサービス
48 | #define SERVICE_TYPE_INVALID 0xFF // 無効
49 |
50 | // ISO 639 language code
51 | #define LANGUAGE_CODE_JPN 0x6A706EUL // 日本語
52 | #define LANGUAGE_CODE_ENG 0x656E67UL // 英語
53 | #define LANGUAGE_CODE_DEU 0x646575UL // ドイツ語
54 | #define LANGUAGE_CODE_FRA 0x667261UL // フランス語
55 | #define LANGUAGE_CODE_ITA 0x697461UL // イタリア語
56 | #define LANGUAGE_CODE_RUS 0x727573UL // ロシア語
57 | #define LANGUAGE_CODE_ZHO 0x7A686FUL // 中国語
58 | #define LANGUAGE_CODE_KOR 0x6B6F72UL // 韓国語
59 | #define LANGUAGE_CODE_SPA 0x737061UL // スペイン語
60 | #define LANGUAGE_CODE_ETC 0x657463UL // その他
61 |
62 |
63 | #endif
64 |
--------------------------------------------------------------------------------
/TVCAS_B25/Common.h:
--------------------------------------------------------------------------------
1 | // Common.h: BonTsEngine共通ヘッダ
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #ifndef BONTSENGINE_COMMON_H
6 | #define BONTSENGINE_COMMON_H
7 |
8 |
9 | // 抽象クラス用
10 | #define ABSTRACT_CLASS_DECL __declspec(novtable)
11 |
12 | // PID
13 | #define PID_PAT 0x0000U // PAT
14 | #define PID_CAT 0x0001U // CAT
15 | #define PID_NIT 0x0010U // NIT
16 | #define PID_SDT 0x0011U // SDT
17 | #define PID_HEIT 0x0012U // H-EIT
18 | #define PID_TOT 0x0014U // TOT
19 | #define PID_SDTT 0x0023U // SDTT
20 | #define PID_BIT 0x0024U // BIT
21 | #define PID_MEIT 0x0026U // M-EIT
22 | #define PID_LEIT 0x0027U // L-EIT
23 | #define PID_CDT 0x0029U // CDT
24 |
25 | // stream_type
26 | #define STREAM_TYPE_MPEG1 0x01 // MPEG-1
27 | #define STREAM_TYPE_MPEG2 0x02 // MPEG-2
28 | #define STREAM_TYPE_CAPTION 0x06 // 字幕
29 | #define STREAM_TYPE_DATACARROUSEL 0x0D // データ放送
30 | #define STREAM_TYPE_AAC 0x0F // AAC
31 | #define STREAM_TYPE_H264 0x1B // H.264
32 | #define STREAM_TYPE_INVALID 0xFF // 無効
33 |
34 | // service_type
35 | #define SERVICE_TYPE_DIGITALTV 0x01 // デジタルTVサービス
36 | #define SERVICE_TYPE_DIGITALAUDIO 0x02 // デジタル音声サービス
37 | #define SERVICE_TYPE_TEMPORARYVIDEO 0xA1 // 臨時映像サービス
38 | #define SERVICE_TYPE_TEMPORARYAUDIO 0xA2 // 臨時音声サービス
39 | #define SERVICE_TYPE_TEMPORARYDATA 0xA3 // 臨時データサービス
40 | #define SERVICE_TYPE_ENGINEERING 0xA4 // エンジニアリングサービス
41 | #define SERVICE_TYPE_PROMOTIONVIDEO 0xA5 // プロモーション映像サービス
42 | #define SERVICE_TYPE_PROMOTIONAUDIO 0xA6 // プロモーション音声サービス
43 | #define SERVICE_TYEP_PROMOTIONDATA 0xA7 // プロモーションデータサービス
44 | #define SERVICE_TYPE_ACCUMULATIONDATA 0xA8 // 事前蓄積用データサービス
45 | #define SERVICE_TYPE_ACCUMULATIONONLYDATA 0xA9 // 蓄積専用データサービス
46 | #define SERVICE_TYPE_BOOKMARKLISTDATA 0xAA // ブックマーク一覧データサービス
47 | #define SERVICE_TYPE_DATA 0xC0 // データサービス
48 | #define SERVICE_TYPE_INVALID 0xFF // 無効
49 |
50 | // ISO 639 language code
51 | #define LANGUAGE_CODE_JPN 0x6A706EUL // 日本語
52 | #define LANGUAGE_CODE_ENG 0x656E67UL // 英語
53 | #define LANGUAGE_CODE_DEU 0x646575UL // ドイツ語
54 | #define LANGUAGE_CODE_FRA 0x667261UL // フランス語
55 | #define LANGUAGE_CODE_ITA 0x697461UL // イタリア語
56 | #define LANGUAGE_CODE_RUS 0x727573UL // ロシア語
57 | #define LANGUAGE_CODE_ZHO 0x7A686FUL // 中国語
58 | #define LANGUAGE_CODE_KOR 0x6B6F72UL // 韓国語
59 | #define LANGUAGE_CODE_SPA 0x737061UL // スペイン語
60 | #define LANGUAGE_CODE_ETC 0x657463UL // その他
61 |
62 |
63 | #endif
64 |
--------------------------------------------------------------------------------
/TVCAS_B1/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : 標準のシステム インクルード ファイルのインクルード ファイル、または
2 | // 参照回数が多く、かつあまり変更されない、プロジェクト専用のインクルード ファイル
3 | // を記述します。
4 |
5 | #pragma once
6 |
7 | #ifndef WINVER
8 | #define WINVER 0x0600 // Windows Vista
9 | #endif
10 |
11 | #ifndef _WIN32_WINNT
12 | #define _WIN32_WINNT 0x0600 // Windows Vista
13 | #endif
14 |
15 | #ifndef _WIN32_IE
16 | #define _WIN32_IE 0x0600 // Internet Explorer 6.0
17 | #endif
18 |
19 | // Winsock2 とヘッダが干渉しないようにする
20 | #define _WINSOCKAPI_
21 |
22 | #define _WIN32_DCOM // for CoInitializeEx()
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 |
33 | #ifdef _DEBUG
34 | #define _CRTDBG_MAP_ALLOC
35 | #endif
36 | #include
37 | #ifdef _DEBUG
38 | #undef strdup
39 | #define strdup strdup
40 | #define DEBUG_NEW new(_NORMAL_BLOCK,__FILE__,__LINE__)
41 | #endif // _DEBUG
42 |
43 | #undef _WINSOCKAPI_
44 |
45 |
46 | // 警告の無効設定
47 | #pragma warning(disable: 4355) // warning C4355: "'this' : ベース メンバ初期化リストで使用されました。"
48 | #pragma warning(disable: 4995) // warning C4995: 名前が避けられた #pragma として記述されています。
49 | #pragma warning(disable: 4996) // warning C4996: "This function or variable may be unsafe."
50 |
51 |
52 | // ライブラリのリンク
53 | #pragma comment(lib, "Kernel32.lib")
54 | #pragma comment(lib, "User32.lib")
55 | #pragma comment(lib, "Shell32.lib")
56 | #pragma comment(lib, "Strmiids.lib")
57 | #pragma comment(lib, "Ole32.lib")
58 | #pragma comment(lib, "Winmm.lib")
59 | #pragma comment(lib, "ShLwApi.lib")
60 |
61 | // トレース出力
62 | #ifdef _DEBUG
63 | #undef TRACE
64 | #define TRACE ::DebugTrace
65 | void DebugTrace(LPCTSTR szFormat, ...);
66 | #else
67 | #define TRACE __noop
68 | #endif
69 |
70 | #ifndef _DEBUG
71 | #define _SECURE_SCL 0
72 | #endif
73 |
74 | // コンパイラ別設定
75 | #if _MSC_VER < 1400
76 | #define __restrict
77 | #endif
78 | #if _MSC_VER >= 1600 // VC2010
79 | #undef NULL
80 | #define NULL nullptr
81 | #define MOVE_SEMANTICS_SUPPORTED
82 | #else
83 | #define nullptr NULL
84 | #ifndef _WIN64
85 | #define WINDOWS2000_SUPPORT // Windows 2000 対応
86 | #endif
87 | #endif
88 |
89 |
90 | // BonTsEngine の設定
91 | #ifdef TVH264
92 | #ifndef TVH264_FOR_HD
93 | #define BONTSENGINE_1SEG_SUPPORT // ワンセグ対応
94 | #define BONTSENGINE_RADIO_SUPPORT // 音声放送対応
95 | #endif
96 | #define BONTSENGINE_H264_SUPPORT // H.264 対応
97 | #else // TVH264
98 | #define BONTSENGINE_MPEG2_SUPPORT // MPEG-2 対応
99 | #define BONTSENGINE_RADIO_SUPPORT // 音声放送対応
100 | #endif
101 |
--------------------------------------------------------------------------------
/TVCAS_B25/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : 標準のシステム インクルード ファイルのインクルード ファイル、または
2 | // 参照回数が多く、かつあまり変更されない、プロジェクト専用のインクルード ファイル
3 | // を記述します。
4 |
5 | #pragma once
6 |
7 | #ifndef WINVER
8 | #define WINVER 0x0600 // Windows Vista
9 | #endif
10 |
11 | #ifndef _WIN32_WINNT
12 | #define _WIN32_WINNT 0x0600 // Windows Vista
13 | #endif
14 |
15 | #ifndef _WIN32_IE
16 | #define _WIN32_IE 0x0600 // Internet Explorer 6.0
17 | #endif
18 |
19 | // Winsock2 とヘッダが干渉しないようにする
20 | #define _WINSOCKAPI_
21 |
22 | #define _WIN32_DCOM // for CoInitializeEx()
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 |
33 | #ifdef _DEBUG
34 | #define _CRTDBG_MAP_ALLOC
35 | #endif
36 | #include
37 | #ifdef _DEBUG
38 | #undef strdup
39 | #define strdup strdup
40 | #define DEBUG_NEW new(_NORMAL_BLOCK,__FILE__,__LINE__)
41 | #endif // _DEBUG
42 |
43 | #undef _WINSOCKAPI_
44 |
45 |
46 | // 警告の無効設定
47 | #pragma warning(disable: 4355) // warning C4355: "'this' : ベース メンバ初期化リストで使用されました。"
48 | #pragma warning(disable: 4995) // warning C4995: 名前が避けられた #pragma として記述されています。
49 | #pragma warning(disable: 4996) // warning C4996: "This function or variable may be unsafe."
50 |
51 |
52 | // ライブラリのリンク
53 | #pragma comment(lib, "Kernel32.lib")
54 | #pragma comment(lib, "User32.lib")
55 | #pragma comment(lib, "Shell32.lib")
56 | #pragma comment(lib, "Strmiids.lib")
57 | #pragma comment(lib, "Ole32.lib")
58 | #pragma comment(lib, "Winmm.lib")
59 | #pragma comment(lib, "ShLwApi.lib")
60 |
61 | // トレース出力
62 | #ifdef _DEBUG
63 | #undef TRACE
64 | #define TRACE ::DebugTrace
65 | void DebugTrace(LPCTSTR szFormat, ...);
66 | #else
67 | #define TRACE __noop
68 | #endif
69 |
70 | #ifndef _DEBUG
71 | #define _SECURE_SCL 0
72 | #endif
73 |
74 | // コンパイラ別設定
75 | #if _MSC_VER < 1400
76 | #define __restrict
77 | #endif
78 | #if _MSC_VER >= 1600 // VC2010
79 | #undef NULL
80 | #define NULL nullptr
81 | #define MOVE_SEMANTICS_SUPPORTED
82 | #else
83 | #define nullptr NULL
84 | #ifndef _WIN64
85 | #define WINDOWS2000_SUPPORT // Windows 2000 対応
86 | #endif
87 | #endif
88 |
89 |
90 | // BonTsEngine の設定
91 | #ifdef TVH264
92 | #ifndef TVH264_FOR_HD
93 | #define BONTSENGINE_1SEG_SUPPORT // ワンセグ対応
94 | #define BONTSENGINE_RADIO_SUPPORT // 音声放送対応
95 | #endif
96 | #define BONTSENGINE_H264_SUPPORT // H.264 対応
97 | #else // TVH264
98 | #define BONTSENGINE_MPEG2_SUPPORT // MPEG-2 対応
99 | #define BONTSENGINE_RADIO_SUPPORT // 音声放送対応
100 | #endif
101 |
--------------------------------------------------------------------------------
/Multi2Decoder/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : 標準のシステム インクルード ファイルのインクルード ファイル、または
2 | // 参照回数が多く、かつあまり変更されない、プロジェクト専用のインクルード ファイル
3 | // を記述します。
4 |
5 | #pragma once
6 |
7 | #ifndef WINVER
8 | #define WINVER 0x0600 // Windows Vista
9 | #endif
10 |
11 | #ifndef _WIN32_WINNT
12 | #define _WIN32_WINNT 0x0600 // Windows Vista
13 | #endif
14 |
15 | #ifndef _WIN32_IE
16 | #define _WIN32_IE 0x0600 // Internet Explorer 6.0
17 | #endif
18 |
19 | // Winsock2 とヘッダが干渉しないようにする
20 | #define _WINSOCKAPI_
21 |
22 | #define _WIN32_DCOM // for CoInitializeEx()
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 |
33 | #ifdef _DEBUG
34 | #define _CRTDBG_MAP_ALLOC
35 | #endif
36 | #include
37 | #ifdef _DEBUG
38 | #undef strdup
39 | #define strdup strdup
40 | #define DEBUG_NEW new(_NORMAL_BLOCK,__FILE__,__LINE__)
41 | #endif // _DEBUG
42 |
43 | #undef _WINSOCKAPI_
44 |
45 |
46 | // 警告の無効設定
47 | #pragma warning(disable: 4355) // warning C4355: "'this' : ベース メンバ初期化リストで使用されました。"
48 | #pragma warning(disable: 4995) // warning C4995: 名前が避けられた #pragma として記述されています。
49 | #pragma warning(disable: 4996) // warning C4996: "This function or variable may be unsafe."
50 |
51 |
52 | // ライブラリのリンク
53 | #pragma comment(lib, "Kernel32.lib")
54 | #pragma comment(lib, "User32.lib")
55 | #pragma comment(lib, "Shell32.lib")
56 | #pragma comment(lib, "Strmiids.lib")
57 | #pragma comment(lib, "Ole32.lib")
58 | #pragma comment(lib, "Winmm.lib")
59 | #pragma comment(lib, "ShLwApi.lib")
60 |
61 | // トレース出力
62 | #ifdef _DEBUG
63 | #undef TRACE
64 | #define TRACE ::DebugTrace
65 | void DebugTrace(LPCTSTR szFormat, ...);
66 | #else
67 | #define TRACE __noop
68 | #endif
69 |
70 | #ifndef _DEBUG
71 | #define _SECURE_SCL 0
72 | #endif
73 |
74 | // コンパイラ別設定
75 | #if _MSC_VER < 1400
76 | #define __restrict
77 | #endif
78 | #if _MSC_VER >= 1600 // VC2010
79 | #undef NULL
80 | #define NULL nullptr
81 | #define MOVE_SEMANTICS_SUPPORTED
82 | #else
83 | #define nullptr NULL
84 | #ifndef _WIN64
85 | #define WINDOWS2000_SUPPORT // Windows 2000 対応
86 | #endif
87 | #endif
88 |
89 |
90 | // BonTsEngine の設定
91 | #ifdef TVH264
92 | #ifndef TVH264_FOR_HD
93 | #define BONTSENGINE_1SEG_SUPPORT // ワンセグ対応
94 | #define BONTSENGINE_RADIO_SUPPORT // 音声放送対応
95 | #endif
96 | #define BONTSENGINE_H264_SUPPORT // H.264 対応
97 | #else // TVH264
98 | #define BONTSENGINE_MPEG2_SUPPORT // MPEG-2 対応
99 | #define BONTSENGINE_RADIO_SUPPORT // 音声放送対応
100 | #endif
101 |
--------------------------------------------------------------------------------
/TVCAS_B1/MediaDecoder.cpp:
--------------------------------------------------------------------------------
1 | // MediaDecoder.cpp: CMediaDecoder クラスのインプリメンテーション
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #include "stdafx.h"
6 | #include "MediaDecoder.h"
7 |
8 | #ifdef _DEBUG
9 | #undef THIS_FILE
10 | static char THIS_FILE[]=__FILE__;
11 | #define new DEBUG_NEW
12 | #endif
13 |
14 |
15 | //////////////////////////////////////////////////////////////////////
16 | // CMediaDecoder 構築/消滅
17 | //////////////////////////////////////////////////////////////////////
18 |
19 | CMediaDecoder::CMediaDecoder(IEventHandler *pEventHandler, const DWORD dwInputNum, const DWORD dwOutputNum)
20 | : m_pEventHandler(pEventHandler)
21 | , m_dwInputNum(dwInputNum)
22 | , m_dwOutputNum(dwOutputNum)
23 | {
24 | // 出力フィルタ配列をクリアする
25 | ::ZeroMemory(m_aOutputDecoder, sizeof(m_aOutputDecoder));
26 | }
27 |
28 | CMediaDecoder::~CMediaDecoder()
29 | {
30 | }
31 |
32 | void CMediaDecoder::Reset()
33 | {
34 | }
35 |
36 | void CMediaDecoder::ResetGraph(void)
37 | {
38 | CBlockLock Lock(&m_DecoderLock);
39 |
40 | Reset();
41 | ResetDownstreamDecoder();
42 | }
43 |
44 | const DWORD CMediaDecoder::GetInputNum(void) const
45 | {
46 | // 入力数を返す
47 | return m_dwInputNum;
48 | }
49 |
50 | const DWORD CMediaDecoder::GetOutputNum(void) const
51 | {
52 | // 出力数を返す
53 | return m_dwOutputNum;
54 | }
55 |
56 | const bool CMediaDecoder::SetOutputDecoder(CMediaDecoder *pDecoder, const DWORD dwOutputIndex, const DWORD dwInputIndex)
57 | {
58 | CBlockLock Lock(&m_DecoderLock);
59 |
60 | if (dwOutputIndex >= m_dwOutputNum)
61 | return false;
62 |
63 | // 出力フィルタをセットする
64 | m_aOutputDecoder[dwOutputIndex].pDecoder = pDecoder;
65 | m_aOutputDecoder[dwOutputIndex].dwInputIndex = dwInputIndex;
66 | return true;
67 | }
68 |
69 | const bool CMediaDecoder::InputMedia(CMediaData *pMediaData, const DWORD dwInputIndex)
70 | {
71 | CBlockLock Lock(&m_DecoderLock);
72 |
73 | OutputMedia(pMediaData, dwInputIndex);
74 | return true;
75 | }
76 |
77 | const bool CMediaDecoder::OutputMedia(CMediaData *pMediaData, const DWORD dwOutptIndex)
78 | {
79 | // 出力処理
80 | if (dwOutptIndex >= m_dwOutputNum)
81 | return false;
82 |
83 | // 次のフィルタにデータを渡す
84 | if (m_aOutputDecoder[dwOutptIndex].pDecoder) {
85 | return m_aOutputDecoder[dwOutptIndex].pDecoder->InputMedia(pMediaData, m_aOutputDecoder[dwOutptIndex].dwInputIndex);
86 | }
87 | return false;
88 | }
89 |
90 | void CMediaDecoder::ResetDownstreamDecoder(void)
91 | {
92 | // 次のフィルタをリセットする
93 | for (DWORD dwOutputIndex = 0UL ; dwOutputIndex < m_dwOutputNum ; dwOutputIndex++) {
94 | if (m_aOutputDecoder[dwOutputIndex].pDecoder)
95 | m_aOutputDecoder[dwOutputIndex].pDecoder->ResetGraph();
96 | }
97 | }
98 |
99 | const DWORD CMediaDecoder::SendDecoderEvent(const DWORD dwEventID, PVOID pParam)
100 | {
101 | // イベントを通知する
102 | if (m_pEventHandler==NULL)
103 | return 0;
104 | return m_pEventHandler->OnDecoderEvent(this, dwEventID, pParam);
105 | }
106 |
--------------------------------------------------------------------------------
/TVCAS_B25/MediaDecoder.cpp:
--------------------------------------------------------------------------------
1 | // MediaDecoder.cpp: CMediaDecoder クラスのインプリメンテーション
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #include "stdafx.h"
6 | #include "MediaDecoder.h"
7 |
8 | #ifdef _DEBUG
9 | #undef THIS_FILE
10 | static char THIS_FILE[]=__FILE__;
11 | #define new DEBUG_NEW
12 | #endif
13 |
14 |
15 | //////////////////////////////////////////////////////////////////////
16 | // CMediaDecoder 構築/消滅
17 | //////////////////////////////////////////////////////////////////////
18 |
19 | CMediaDecoder::CMediaDecoder(IEventHandler *pEventHandler, const DWORD dwInputNum, const DWORD dwOutputNum)
20 | : m_pEventHandler(pEventHandler)
21 | , m_dwInputNum(dwInputNum)
22 | , m_dwOutputNum(dwOutputNum)
23 | {
24 | // 出力フィルタ配列をクリアする
25 | ::ZeroMemory(m_aOutputDecoder, sizeof(m_aOutputDecoder));
26 | }
27 |
28 | CMediaDecoder::~CMediaDecoder()
29 | {
30 | }
31 |
32 | void CMediaDecoder::Reset()
33 | {
34 | }
35 |
36 | void CMediaDecoder::ResetGraph(void)
37 | {
38 | CBlockLock Lock(&m_DecoderLock);
39 |
40 | Reset();
41 | ResetDownstreamDecoder();
42 | }
43 |
44 | const DWORD CMediaDecoder::GetInputNum(void) const
45 | {
46 | // 入力数を返す
47 | return m_dwInputNum;
48 | }
49 |
50 | const DWORD CMediaDecoder::GetOutputNum(void) const
51 | {
52 | // 出力数を返す
53 | return m_dwOutputNum;
54 | }
55 |
56 | const bool CMediaDecoder::SetOutputDecoder(CMediaDecoder *pDecoder, const DWORD dwOutputIndex, const DWORD dwInputIndex)
57 | {
58 | CBlockLock Lock(&m_DecoderLock);
59 |
60 | if (dwOutputIndex >= m_dwOutputNum)
61 | return false;
62 |
63 | // 出力フィルタをセットする
64 | m_aOutputDecoder[dwOutputIndex].pDecoder = pDecoder;
65 | m_aOutputDecoder[dwOutputIndex].dwInputIndex = dwInputIndex;
66 | return true;
67 | }
68 |
69 | const bool CMediaDecoder::InputMedia(CMediaData *pMediaData, const DWORD dwInputIndex)
70 | {
71 | CBlockLock Lock(&m_DecoderLock);
72 |
73 | OutputMedia(pMediaData, dwInputIndex);
74 | return true;
75 | }
76 |
77 | const bool CMediaDecoder::OutputMedia(CMediaData *pMediaData, const DWORD dwOutptIndex)
78 | {
79 | // 出力処理
80 | if (dwOutptIndex >= m_dwOutputNum)
81 | return false;
82 |
83 | // 次のフィルタにデータを渡す
84 | if (m_aOutputDecoder[dwOutptIndex].pDecoder) {
85 | return m_aOutputDecoder[dwOutptIndex].pDecoder->InputMedia(pMediaData, m_aOutputDecoder[dwOutptIndex].dwInputIndex);
86 | }
87 | return false;
88 | }
89 |
90 | void CMediaDecoder::ResetDownstreamDecoder(void)
91 | {
92 | // 次のフィルタをリセットする
93 | for (DWORD dwOutputIndex = 0UL ; dwOutputIndex < m_dwOutputNum ; dwOutputIndex++) {
94 | if (m_aOutputDecoder[dwOutputIndex].pDecoder)
95 | m_aOutputDecoder[dwOutputIndex].pDecoder->ResetGraph();
96 | }
97 | }
98 |
99 | const DWORD CMediaDecoder::SendDecoderEvent(const DWORD dwEventID, PVOID pParam)
100 | {
101 | // イベントを通知する
102 | if (m_pEventHandler==NULL)
103 | return 0;
104 | return m_pEventHandler->OnDecoderEvent(this, dwEventID, pParam);
105 | }
106 |
--------------------------------------------------------------------------------
/TVCAS_B1/StdUtil.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "StdUtil.h"
3 | #include
4 |
5 | #ifdef _DEBUG
6 | #undef THIS_FILE
7 | static char THIS_FILE[]=__FILE__;
8 | #define new DEBUG_NEW
9 | #endif
10 |
11 |
12 |
13 |
14 | int StdUtil::snprintf(char *s,size_t n,const char *format, ...)
15 | {
16 | va_list args;
17 | int Length;
18 |
19 | va_start(args,format);
20 | #if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
21 | // 実質的にVCでしかコンパイルできないので無意味だが...
22 | Length=::vsnprintf(s,n,format,args);
23 | #else
24 | if (n>0) {
25 | Length=::vsprintf_s(s,n,format,args);
26 | } else {
27 | Length=0;
28 | }
29 | #endif
30 | va_end(args);
31 | return Length;
32 | }
33 |
34 |
35 | int StdUtil::snprintf(wchar_t *s,size_t n,const wchar_t *format, ...)
36 | {
37 | va_list args;
38 | int Length;
39 |
40 | va_start(args,format);
41 | if (n>0) {
42 | Length=::vswprintf_s(s,n,format,args);
43 | } else {
44 | Length=0;
45 | }
46 | va_end(args);
47 | return Length;
48 | }
49 |
50 |
51 | int StdUtil::vsnprintf(char *s,size_t n,const char *format,va_list args)
52 | {
53 | int Length;
54 |
55 | #if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
56 | Length=::vsnprintf(s,n,format,args);
57 | #else
58 | if (n>0) {
59 | Length=::vsprintf_s(s,n,format,args);
60 | } else {
61 | Length=0;
62 | }
63 | #endif
64 | return Length;
65 | }
66 |
67 |
68 | int StdUtil::vsnprintf(wchar_t *s,size_t n,const wchar_t *format,va_list args)
69 | {
70 | int Length;
71 |
72 | if (n>0) {
73 | Length=::vswprintf_s(s,n,format,args);
74 | } else {
75 | Length=0;
76 | }
77 | return Length;
78 | }
79 |
80 |
81 | char *StdUtil::strncpy(char *dest,size_t n,const char *src)
82 | {
83 | #if 0
84 | size_t length=::strlen(src);
85 |
86 | if (n-1
4 |
5 | #ifdef _DEBUG
6 | #undef THIS_FILE
7 | static char THIS_FILE[]=__FILE__;
8 | #define new DEBUG_NEW
9 | #endif
10 |
11 |
12 |
13 |
14 | int StdUtil::snprintf(char *s,size_t n,const char *format, ...)
15 | {
16 | va_list args;
17 | int Length;
18 |
19 | va_start(args,format);
20 | #if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
21 | // 実質的にVCでしかコンパイルできないので無意味だが...
22 | Length=::vsnprintf(s,n,format,args);
23 | #else
24 | if (n>0) {
25 | Length=::vsprintf_s(s,n,format,args);
26 | } else {
27 | Length=0;
28 | }
29 | #endif
30 | va_end(args);
31 | return Length;
32 | }
33 |
34 |
35 | int StdUtil::snprintf(wchar_t *s,size_t n,const wchar_t *format, ...)
36 | {
37 | va_list args;
38 | int Length;
39 |
40 | va_start(args,format);
41 | if (n>0) {
42 | Length=::vswprintf_s(s,n,format,args);
43 | } else {
44 | Length=0;
45 | }
46 | va_end(args);
47 | return Length;
48 | }
49 |
50 |
51 | int StdUtil::vsnprintf(char *s,size_t n,const char *format,va_list args)
52 | {
53 | int Length;
54 |
55 | #if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
56 | Length=::vsnprintf(s,n,format,args);
57 | #else
58 | if (n>0) {
59 | Length=::vsprintf_s(s,n,format,args);
60 | } else {
61 | Length=0;
62 | }
63 | #endif
64 | return Length;
65 | }
66 |
67 |
68 | int StdUtil::vsnprintf(wchar_t *s,size_t n,const wchar_t *format,va_list args)
69 | {
70 | int Length;
71 |
72 | if (n>0) {
73 | Length=::vswprintf_s(s,n,format,args);
74 | } else {
75 | Length=0;
76 | }
77 | return Length;
78 | }
79 |
80 |
81 | char *StdUtil::strncpy(char *dest,size_t n,const char *src)
82 | {
83 | #if 0
84 | size_t length=::strlen(src);
85 |
86 | if (n-1本プログラムは、デジタル放送における CAS 処理の試験又は研究のために公開されています。
55 | >
56 | >以下の条項に同意する場合にのみ利用することができます。
57 | >
58 | >・試験又は研究の目的に限り利用することができます。
59 | >・使用又は使用不能によって生じたいかなる損害も補償しません。
60 | >・正規のカード以外で利用することはできません。
61 | >
62 | >改変する場合、以下の条件に従ってください。
63 | >
64 | >・ファイル名をオリジナルと異なるものにすること。
65 | >・著作権表記を書き換えること。
66 | >・原著作者が一切関わっていないことを明確にすること。
67 | >・正規のカード以外で利用するための改変をしないこと。
68 | >
69 | >
70 | >2012 デジタル放送総合技術研究開発機構
--------------------------------------------------------------------------------
/TvCas.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30330.147
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Multi2Decoder", "Multi2Decoder\Multi2Decoder.vcxproj", "{F92B34A6-7FA5-4497-96B1-0BC32E3080C0}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TVCAS_B25", "TVCAS_B25\TVCAS_B25.vcxproj", "{A3869304-1481-431E-B7C6-C4ED342106EB}"
9 | ProjectSection(ProjectDependencies) = postProject
10 | {F92B34A6-7FA5-4497-96B1-0BC32E3080C0} = {F92B34A6-7FA5-4497-96B1-0BC32E3080C0}
11 | EndProjectSection
12 | EndProject
13 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TVCAS_B1", "TVCAS_B1\TVCAS_B1.vcxproj", "{F7BCFC38-69E7-4E57-88BF-C87E57C7083C}"
14 | ProjectSection(ProjectDependencies) = postProject
15 | {F92B34A6-7FA5-4497-96B1-0BC32E3080C0} = {F92B34A6-7FA5-4497-96B1-0BC32E3080C0}
16 | EndProjectSection
17 | EndProject
18 | Global
19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
20 | Debug|x64 = Debug|x64
21 | Debug|x86 = Debug|x86
22 | Release|x64 = Release|x64
23 | Release|x86 = Release|x86
24 | EndGlobalSection
25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
26 | {F92B34A6-7FA5-4497-96B1-0BC32E3080C0}.Debug|x64.ActiveCfg = Debug|x64
27 | {F92B34A6-7FA5-4497-96B1-0BC32E3080C0}.Debug|x64.Build.0 = Debug|x64
28 | {F92B34A6-7FA5-4497-96B1-0BC32E3080C0}.Debug|x86.ActiveCfg = Debug|Win32
29 | {F92B34A6-7FA5-4497-96B1-0BC32E3080C0}.Debug|x86.Build.0 = Debug|Win32
30 | {F92B34A6-7FA5-4497-96B1-0BC32E3080C0}.Release|x64.ActiveCfg = Release|x64
31 | {F92B34A6-7FA5-4497-96B1-0BC32E3080C0}.Release|x64.Build.0 = Release|x64
32 | {F92B34A6-7FA5-4497-96B1-0BC32E3080C0}.Release|x86.ActiveCfg = Release|Win32
33 | {F92B34A6-7FA5-4497-96B1-0BC32E3080C0}.Release|x86.Build.0 = Release|Win32
34 | {A3869304-1481-431E-B7C6-C4ED342106EB}.Debug|x64.ActiveCfg = Debug|x64
35 | {A3869304-1481-431E-B7C6-C4ED342106EB}.Debug|x64.Build.0 = Debug|x64
36 | {A3869304-1481-431E-B7C6-C4ED342106EB}.Debug|x86.ActiveCfg = Debug|Win32
37 | {A3869304-1481-431E-B7C6-C4ED342106EB}.Debug|x86.Build.0 = Debug|Win32
38 | {A3869304-1481-431E-B7C6-C4ED342106EB}.Release|x64.ActiveCfg = Release|x64
39 | {A3869304-1481-431E-B7C6-C4ED342106EB}.Release|x64.Build.0 = Release|x64
40 | {A3869304-1481-431E-B7C6-C4ED342106EB}.Release|x86.ActiveCfg = Release|Win32
41 | {A3869304-1481-431E-B7C6-C4ED342106EB}.Release|x86.Build.0 = Release|Win32
42 | {F7BCFC38-69E7-4E57-88BF-C87E57C7083C}.Debug|x64.ActiveCfg = Debug|x64
43 | {F7BCFC38-69E7-4E57-88BF-C87E57C7083C}.Debug|x64.Build.0 = Debug|x64
44 | {F7BCFC38-69E7-4E57-88BF-C87E57C7083C}.Debug|x86.ActiveCfg = Debug|Win32
45 | {F7BCFC38-69E7-4E57-88BF-C87E57C7083C}.Debug|x86.Build.0 = Debug|Win32
46 | {F7BCFC38-69E7-4E57-88BF-C87E57C7083C}.Release|x64.ActiveCfg = Release|x64
47 | {F7BCFC38-69E7-4E57-88BF-C87E57C7083C}.Release|x64.Build.0 = Release|x64
48 | {F7BCFC38-69E7-4E57-88BF-C87E57C7083C}.Release|x86.ActiveCfg = Release|Win32
49 | {F7BCFC38-69E7-4E57-88BF-C87E57C7083C}.Release|x86.Build.0 = Release|Win32
50 | EndGlobalSection
51 | GlobalSection(SolutionProperties) = preSolution
52 | HideSolutionNode = FALSE
53 | EndGlobalSection
54 | GlobalSection(ExtensibilityGlobals) = postSolution
55 | SolutionGuid = {CC1762F9-A76B-4116-ABB5-6E3244CD7FE8}
56 | EndGlobalSection
57 | EndGlobal
58 |
--------------------------------------------------------------------------------
/TVCAS_B1/Multi2Decoder.h:
--------------------------------------------------------------------------------
1 | // Multi2Decoder.h: CMulti2Decoder クラスのインターフェイス
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #pragma once
6 |
7 |
8 | #define MULTI2_USE_INTRINSIC // 組み込み関数を利用
9 | #define MULTI2_SIMD // SIMD対応
10 |
11 | #ifdef MULTI2_SIMD
12 | /*
13 | ICCを使用しない場合は、MULTI2_SIMD_ICCを定義しないようにする
14 | (ただし20%ぐらい遅くなる)
15 | */
16 | #define MULTI2_SSE2 // SSE2対応
17 | #define MULTI2_SSSE3 // SSSE3対応
18 | #define MULTI2_SIMD_ICC // Intel C++ Compiler を利用する
19 |
20 | namespace Multi2DecoderSIMD {
21 | struct WORKKEY;
22 | };
23 | #endif // MULTI2_SIMD
24 |
25 |
26 | class CMulti2Decoder
27 | {
28 | public:
29 | #ifdef MULTI2_SIMD
30 | enum InstructionType
31 | {
32 | INSTRUCTION_NORMAL,
33 | INSTRUCTION_SSE2,
34 | INSTRUCTION_SSSE3
35 | };
36 | #endif
37 |
38 | CMulti2Decoder(
39 | #ifdef MULTI2_SIMD
40 | InstructionType Instruction
41 | #endif
42 | );
43 | ~CMulti2Decoder(void);
44 |
45 | const bool Initialize(const BYTE *pSystemKey, const BYTE *pInitialCbc);
46 | const bool SetScrambleKey(const BYTE *pScrambleKey);
47 | const bool Decode(BYTE *pData, const DWORD dwSize, const BYTE byScrCtrl) const;
48 |
49 | #ifdef MULTI2_SIMD
50 | static bool IsSSE2Available();
51 | static bool IsSSSE3Available();
52 | #endif
53 |
54 | class SYSKEY // System Key(Sk), Expanded Key(Wk) 256bit
55 | {
56 | public:
57 | inline void SetHexData(const BYTE *pHexData);
58 | inline void GetHexData(BYTE *pHexData) const;
59 |
60 | union {
61 | #if !defined(MULTI2_USE_INTRINSIC) || !defined(_WIN64)
62 | struct {
63 | DWORD dwKey1, dwKey2, dwKey3, dwKey4, dwKey5, dwKey6, dwKey7, dwKey8;
64 | };
65 | #else
66 | struct {
67 | DWORD dwKey2, dwKey1, dwKey4, dwKey3, dwKey6, dwKey5, dwKey8, dwKey7;
68 | };
69 | unsigned __int64 Data64[4];
70 | #endif
71 | BYTE Data[32];
72 | };
73 | };
74 |
75 | class DATKEY // Data Key(Dk) 64bit
76 | {
77 | public:
78 | inline void SetHexData(const BYTE *pHexData);
79 | inline void GetHexData(BYTE *pHexData) const;
80 | DATKEY &operator^=(const DATKEY &Operand) {
81 | #ifndef _WIN64
82 | dwRight ^= Operand.dwRight;
83 | dwLeft ^= Operand.dwLeft;
84 | #else
85 | Data64 ^= Operand.Data64;
86 | #endif
87 | return *this;
88 | }
89 |
90 | union {
91 | struct {
92 | DWORD dwRight, dwLeft;
93 | };
94 | unsigned __int64 Data64;
95 | BYTE Data[8];
96 | };
97 | };
98 |
99 | private:
100 | static void KeySchedule(SYSKEY &WorkKey, const SYSKEY &SysKey, DATKEY &DataKey);
101 |
102 | static inline void RoundFuncPi1(DATKEY &Block);
103 | static inline void RoundFuncPi2(DATKEY &Block, const DWORD dwK1);
104 | static inline void RoundFuncPi3(DATKEY &Block, const DWORD dwK2, const DWORD dwK3);
105 | static inline void RoundFuncPi4(DATKEY &Block, const DWORD dwK4);
106 |
107 | static inline const DWORD LeftRotate(const DWORD dwValue, const DWORD dwRotate);
108 |
109 | DATKEY m_InitialCbc;
110 | SYSKEY m_SystemKey;
111 | SYSKEY m_WorkKeyOdd, m_WorkKeyEven;
112 |
113 | bool m_bIsSysKeyValid;
114 | bool m_bIsWorkKeyValid;
115 |
116 | #ifdef MULTI2_SIMD
117 | InstructionType m_Instruction;
118 | typedef void (*DecodeFunc)(BYTE * __restrict pData, const DWORD dwSize,
119 | const SYSKEY * __restrict pWorkKey,
120 | const Multi2DecoderSIMD::WORKKEY * __restrict pPackedWorkKey,
121 | const DATKEY * __restrict pInitialCbc);
122 | DecodeFunc m_pDecodeFunc;
123 | Multi2DecoderSIMD::WORKKEY *m_pSSE2WorkKeyOdd, *m_pSSE2WorkKeyEven;
124 | #endif
125 | };
126 |
--------------------------------------------------------------------------------
/TVCAS_B25/Multi2Decoder.h:
--------------------------------------------------------------------------------
1 | // Multi2Decoder.h: CMulti2Decoder クラスのインターフェイス
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #pragma once
6 |
7 |
8 | #define MULTI2_USE_INTRINSIC // 組み込み関数を利用
9 | #define MULTI2_SIMD // SIMD対応
10 |
11 | #ifdef MULTI2_SIMD
12 | /*
13 | ICCを使用しない場合は、MULTI2_SIMD_ICCを定義しないようにする
14 | (ただし20%ぐらい遅くなる)
15 | */
16 | #define MULTI2_SSE2 // SSE2対応
17 | #define MULTI2_SSSE3 // SSSE3対応
18 | #define MULTI2_SIMD_ICC // Intel C++ Compiler を利用する
19 |
20 | namespace Multi2DecoderSIMD {
21 | struct WORKKEY;
22 | };
23 | #endif // MULTI2_SIMD
24 |
25 |
26 | class CMulti2Decoder
27 | {
28 | public:
29 | #ifdef MULTI2_SIMD
30 | enum InstructionType
31 | {
32 | INSTRUCTION_NORMAL,
33 | INSTRUCTION_SSE2,
34 | INSTRUCTION_SSSE3
35 | };
36 | #endif
37 |
38 | CMulti2Decoder(
39 | #ifdef MULTI2_SIMD
40 | InstructionType Instruction
41 | #endif
42 | );
43 | ~CMulti2Decoder(void);
44 |
45 | const bool Initialize(const BYTE *pSystemKey, const BYTE *pInitialCbc);
46 | const bool SetScrambleKey(const BYTE *pScrambleKey);
47 | const bool Decode(BYTE *pData, const DWORD dwSize, const BYTE byScrCtrl) const;
48 |
49 | #ifdef MULTI2_SIMD
50 | static bool IsSSE2Available();
51 | static bool IsSSSE3Available();
52 | #endif
53 |
54 | class SYSKEY // System Key(Sk), Expanded Key(Wk) 256bit
55 | {
56 | public:
57 | inline void SetHexData(const BYTE *pHexData);
58 | inline void GetHexData(BYTE *pHexData) const;
59 |
60 | union {
61 | #if !defined(MULTI2_USE_INTRINSIC) || !defined(_WIN64)
62 | struct {
63 | DWORD dwKey1, dwKey2, dwKey3, dwKey4, dwKey5, dwKey6, dwKey7, dwKey8;
64 | };
65 | #else
66 | struct {
67 | DWORD dwKey2, dwKey1, dwKey4, dwKey3, dwKey6, dwKey5, dwKey8, dwKey7;
68 | };
69 | unsigned __int64 Data64[4];
70 | #endif
71 | BYTE Data[32];
72 | };
73 | };
74 |
75 | class DATKEY // Data Key(Dk) 64bit
76 | {
77 | public:
78 | inline void SetHexData(const BYTE *pHexData);
79 | inline void GetHexData(BYTE *pHexData) const;
80 | DATKEY &operator^=(const DATKEY &Operand) {
81 | #ifndef _WIN64
82 | dwRight ^= Operand.dwRight;
83 | dwLeft ^= Operand.dwLeft;
84 | #else
85 | Data64 ^= Operand.Data64;
86 | #endif
87 | return *this;
88 | }
89 |
90 | union {
91 | struct {
92 | DWORD dwRight, dwLeft;
93 | };
94 | unsigned __int64 Data64;
95 | BYTE Data[8];
96 | };
97 | };
98 |
99 | private:
100 | static void KeySchedule(SYSKEY &WorkKey, const SYSKEY &SysKey, DATKEY &DataKey);
101 |
102 | static inline void RoundFuncPi1(DATKEY &Block);
103 | static inline void RoundFuncPi2(DATKEY &Block, const DWORD dwK1);
104 | static inline void RoundFuncPi3(DATKEY &Block, const DWORD dwK2, const DWORD dwK3);
105 | static inline void RoundFuncPi4(DATKEY &Block, const DWORD dwK4);
106 |
107 | static inline const DWORD LeftRotate(const DWORD dwValue, const DWORD dwRotate);
108 |
109 | DATKEY m_InitialCbc;
110 | SYSKEY m_SystemKey;
111 | SYSKEY m_WorkKeyOdd, m_WorkKeyEven;
112 |
113 | bool m_bIsSysKeyValid;
114 | bool m_bIsWorkKeyValid;
115 |
116 | #ifdef MULTI2_SIMD
117 | InstructionType m_Instruction;
118 | typedef void (*DecodeFunc)(BYTE * __restrict pData, const DWORD dwSize,
119 | const SYSKEY * __restrict pWorkKey,
120 | const Multi2DecoderSIMD::WORKKEY * __restrict pPackedWorkKey,
121 | const DATKEY * __restrict pInitialCbc);
122 | DecodeFunc m_pDecodeFunc;
123 | Multi2DecoderSIMD::WORKKEY *m_pSSE2WorkKeyOdd, *m_pSSE2WorkKeyEven;
124 | #endif
125 | };
126 |
--------------------------------------------------------------------------------
/Multi2Decoder/Multi2Decoder.h:
--------------------------------------------------------------------------------
1 | // Multi2Decoder.h: CMulti2Decoder クラスのインターフェイス
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #pragma once
6 |
7 |
8 | #define MULTI2_USE_INTRINSIC // 組み込み関数を利用
9 | #define MULTI2_SIMD // SIMD対応
10 |
11 | #ifdef MULTI2_SIMD
12 | /*
13 | ICCを使用しない場合は、MULTI2_SIMD_ICCを定義しないようにする
14 | (ただし20%ぐらい遅くなる)
15 | */
16 | #define MULTI2_SSE2 // SSE2対応
17 | #define MULTI2_SSSE3 // SSSE3対応
18 | #define MULTI2_SIMD_ICC // Intel C++ Compiler を利用する
19 |
20 | namespace Multi2DecoderSIMD {
21 | struct WORKKEY;
22 | };
23 | #endif // MULTI2_SIMD
24 |
25 |
26 | class CMulti2Decoder
27 | {
28 | public:
29 | #ifdef MULTI2_SIMD
30 | enum InstructionType
31 | {
32 | INSTRUCTION_NORMAL,
33 | INSTRUCTION_SSE2,
34 | INSTRUCTION_SSSE3
35 | };
36 | #endif
37 |
38 | CMulti2Decoder(
39 | #ifdef MULTI2_SIMD
40 | InstructionType Instruction
41 | #endif
42 | );
43 | ~CMulti2Decoder(void);
44 |
45 | const bool Initialize(const BYTE *pSystemKey, const BYTE *pInitialCbc);
46 | const bool SetScrambleKey(const BYTE *pScrambleKey);
47 | const bool Decode(BYTE *pData, const DWORD dwSize, const BYTE byScrCtrl) const;
48 |
49 | #ifdef MULTI2_SIMD
50 | static bool IsSSE2Available();
51 | static bool IsSSSE3Available();
52 | #endif
53 |
54 | class SYSKEY // System Key(Sk), Expanded Key(Wk) 256bit
55 | {
56 | public:
57 | inline void SetHexData(const BYTE *pHexData);
58 | inline void GetHexData(BYTE *pHexData) const;
59 |
60 | union {
61 | #if !defined(MULTI2_USE_INTRINSIC) || !defined(_WIN64)
62 | struct {
63 | DWORD dwKey1, dwKey2, dwKey3, dwKey4, dwKey5, dwKey6, dwKey7, dwKey8;
64 | };
65 | #else
66 | struct {
67 | DWORD dwKey2, dwKey1, dwKey4, dwKey3, dwKey6, dwKey5, dwKey8, dwKey7;
68 | };
69 | unsigned __int64 Data64[4];
70 | #endif
71 | BYTE Data[32];
72 | };
73 | };
74 |
75 | class DATKEY // Data Key(Dk) 64bit
76 | {
77 | public:
78 | inline void SetHexData(const BYTE *pHexData);
79 | inline void GetHexData(BYTE *pHexData) const;
80 | DATKEY &operator^=(const DATKEY &Operand) {
81 | #ifndef _WIN64
82 | dwRight ^= Operand.dwRight;
83 | dwLeft ^= Operand.dwLeft;
84 | #else
85 | Data64 ^= Operand.Data64;
86 | #endif
87 | return *this;
88 | }
89 |
90 | union {
91 | struct {
92 | DWORD dwRight, dwLeft;
93 | };
94 | unsigned __int64 Data64;
95 | BYTE Data[8];
96 | };
97 | };
98 |
99 | private:
100 | static void KeySchedule(SYSKEY &WorkKey, const SYSKEY &SysKey, DATKEY &DataKey);
101 |
102 | static inline void RoundFuncPi1(DATKEY &Block);
103 | static inline void RoundFuncPi2(DATKEY &Block, const DWORD dwK1);
104 | static inline void RoundFuncPi3(DATKEY &Block, const DWORD dwK2, const DWORD dwK3);
105 | static inline void RoundFuncPi4(DATKEY &Block, const DWORD dwK4);
106 |
107 | static inline const DWORD LeftRotate(const DWORD dwValue, const DWORD dwRotate);
108 |
109 | DATKEY m_InitialCbc;
110 | SYSKEY m_SystemKey;
111 | SYSKEY m_WorkKeyOdd, m_WorkKeyEven;
112 |
113 | bool m_bIsSysKeyValid;
114 | bool m_bIsWorkKeyValid;
115 |
116 | #ifdef MULTI2_SIMD
117 | InstructionType m_Instruction;
118 | typedef void (*DecodeFunc)(BYTE * __restrict pData, const DWORD dwSize,
119 | const SYSKEY * __restrict pWorkKey,
120 | const Multi2DecoderSIMD::WORKKEY * __restrict pPackedWorkKey,
121 | const DATKEY * __restrict pInitialCbc);
122 | DecodeFunc m_pDecodeFunc;
123 | Multi2DecoderSIMD::WORKKEY *m_pSSE2WorkKeyOdd, *m_pSSE2WorkKeyEven;
124 | #endif
125 | };
126 |
--------------------------------------------------------------------------------
/TVCAS_B1/CasCard.h:
--------------------------------------------------------------------------------
1 | // CasCard.h: CCasCard クラスのインターフェイス
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #pragma once
6 |
7 |
8 | #include "BonBaseClass.h"
9 | #include "CardReader.h"
10 |
11 | // ECMデータの最小/最大サイズ
12 | #define MIN_ECM_DATA_SIZE 30
13 | #define MAX_ECM_DATA_SIZE 256
14 | // EMMデータの最大サイズ
15 | #define MAX_EMM_DATA_SIZE 263
16 |
17 | class CCasCard : public CBonBaseClass
18 | {
19 | public:
20 | // エラーコード
21 | enum {
22 | ERR_NOERROR = 0x00000000UL, // エラーなし
23 | ERR_INTERNALERROR = 0x00000001UL, // 内部エラー
24 | ERR_NOTESTABLISHED = 0x00000002UL, // コンテキスト確立失敗
25 | ERR_NOCARDREADERS = 0x00000003UL, // カードリーダがない
26 | ERR_ALREADYOPEN = 0x00000004UL, // 既にオープン済み
27 | ERR_CARDOPENERROR = 0x00000005UL, // カードオープン失敗
28 | ERR_CARDNOTOPEN = 0x00000006UL, // カード未オープン
29 | ERR_TRANSMITERROR = 0x00000007UL, // 通信エラー
30 | ERR_BADARGUMENT = 0x00000008UL, // 引数が不正
31 | ERR_ECMREFUSED = 0x00000009UL, // ECM受付拒否
32 | ERR_EMMERROR = 0x0000000AUL, // EMM処理エラー
33 | ERR_UNCONTRACTED = 0x0000000BUL, // 非契約
34 | ERR_PURCHASEAVAIL = 0x0000000CUL, // 購入可
35 | ERR_PURCHASEREFUSED = 0x0000000DUL, // 購入拒否
36 | ERR_SECURITY = 0x0000000EUL, // セキュリティエラー
37 | ERR_UNKNOWNCODE = 0x0000000FUL, // 不明なコード
38 | ERR_NONOPERATIONAL = 0x00000010UL // 非運用
39 | };
40 |
41 | enum {
42 | CARDTYPE_PREPAID = 0x00,
43 | CARDTYPE_STANDARD = 0x01,
44 | CARDTYPE_INVALID = 0xFF
45 | };
46 |
47 | struct CasCardInfo
48 | {
49 | WORD CASystemID; // CA_system_id
50 | BYTE CardID[6]; // Card ID
51 | BYTE CardType; // Card type
52 | BYTE MessagePartitionLength; // Message partition length
53 | BYTE SystemKey[32]; // Descrambling system key
54 | BYTE InitialCbc[8]; // Descrambler CBC initial value
55 | BYTE CardManufacturerID; // Manufacturer identifier
56 | BYTE CardVersion; // Version
57 | WORD CheckCode; // Check code
58 | };
59 |
60 | CCasCard();
61 | ~CCasCard();
62 |
63 | const DWORD GetCardReaderNum(void) const;
64 | LPCTSTR EnumCardReader(const DWORD dwIndex) const;
65 |
66 | const bool OpenCard(CCardReader::ReaderType ReaderType = CCardReader::READER_SCARD, LPCTSTR lpszReader = NULL);
67 | void CloseCard(void);
68 | const bool ReOpenCard();
69 | const bool IsCardOpen() const;
70 | CCardReader::ReaderType GetCardReaderType() const;
71 | LPCTSTR GetCardReaderName() const;
72 |
73 | const bool GetCasCardInfo(CasCardInfo *pInfo) const;
74 | const bool GetCASystemID(WORD *pID) const;
75 | const BYTE * GetCardID(void) const;
76 | const BYTE GetCardType(void) const;
77 | const BYTE GetMessagePartitionLength(void) const;
78 | const BYTE * GetInitialCbc(void) const;
79 | const BYTE * GetSystemKey(void) const;
80 | const char GetCardManufacturerID() const;
81 | const BYTE GetCardVersion() const;
82 | const int FormatCardID(LPTSTR pszText, int MaxLength) const;
83 |
84 | const BYTE * GetKsFromEcm(const BYTE *pEcmData, const DWORD dwEcmSize);
85 | const bool SendEmmSection(const BYTE *pEmmData, const DWORD dwEmmSize);
86 | const bool ConfirmContract(const BYTE *pVerificationData, const DWORD DataSize, const WORD Date);
87 | const bool SendCommand(const BYTE *pSendData, const DWORD SendSize, BYTE *pReceiveData, DWORD *pReceiveSize);
88 |
89 | protected:
90 | const bool OpenAndInitialize(LPCTSTR pszReader);
91 | const bool InitialSetting(void);
92 |
93 | CCardReader *m_pCardReader;
94 |
95 | CasCardInfo m_CasCardInfo;
96 |
97 | struct TAG_ECMSTATUS
98 | {
99 | DWORD dwLastEcmSize; // 最後に問い合わせのあったECMサイズ
100 | BYTE LastEcmData[MAX_ECM_DATA_SIZE]; // 最後に問い合わせのあったECMデータ
101 | BYTE KsData[16]; // Ks Odd + Even
102 | bool bSucceeded; // ECMが受け付けられたか
103 | } m_EcmStatus;
104 | };
105 |
--------------------------------------------------------------------------------
/TVCAS_B25/CasCard.h:
--------------------------------------------------------------------------------
1 | // CasCard.h: CCasCard クラスのインターフェイス
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #pragma once
6 |
7 |
8 | #include "BonBaseClass.h"
9 | #include "CardReader.h"
10 |
11 | // ECMデータの最小/最大サイズ
12 | #define MIN_ECM_DATA_SIZE 30
13 | #define MAX_ECM_DATA_SIZE 256
14 | // EMMデータの最大サイズ
15 | #define MAX_EMM_DATA_SIZE 263
16 |
17 | class CCasCard : public CBonBaseClass
18 | {
19 | public:
20 | // エラーコード
21 | enum {
22 | ERR_NOERROR = 0x00000000UL, // エラーなし
23 | ERR_INTERNALERROR = 0x00000001UL, // 内部エラー
24 | ERR_NOTESTABLISHED = 0x00000002UL, // コンテキスト確立失敗
25 | ERR_NOCARDREADERS = 0x00000003UL, // カードリーダがない
26 | ERR_ALREADYOPEN = 0x00000004UL, // 既にオープン済み
27 | ERR_CARDOPENERROR = 0x00000005UL, // カードオープン失敗
28 | ERR_CARDNOTOPEN = 0x00000006UL, // カード未オープン
29 | ERR_TRANSMITERROR = 0x00000007UL, // 通信エラー
30 | ERR_BADARGUMENT = 0x00000008UL, // 引数が不正
31 | ERR_ECMREFUSED = 0x00000009UL, // ECM受付拒否
32 | ERR_EMMERROR = 0x0000000AUL, // EMM処理エラー
33 | ERR_UNCONTRACTED = 0x0000000BUL, // 非契約
34 | ERR_PURCHASEAVAIL = 0x0000000CUL, // 購入可
35 | ERR_PURCHASEREFUSED = 0x0000000DUL, // 購入拒否
36 | ERR_SECURITY = 0x0000000EUL, // セキュリティエラー
37 | ERR_UNKNOWNCODE = 0x0000000FUL, // 不明なコード
38 | ERR_NONOPERATIONAL = 0x00000010UL // 非運用
39 | };
40 |
41 | enum {
42 | CARDTYPE_PREPAID = 0x00,
43 | CARDTYPE_STANDARD = 0x01,
44 | CARDTYPE_INVALID = 0xFF
45 | };
46 |
47 | struct CasCardInfo
48 | {
49 | WORD CASystemID; // CA_system_id
50 | BYTE CardID[6]; // Card ID
51 | BYTE CardType; // Card type
52 | BYTE MessagePartitionLength; // Message partition length
53 | BYTE SystemKey[32]; // Descrambling system key
54 | BYTE InitialCbc[8]; // Descrambler CBC initial value
55 | BYTE CardManufacturerID; // Manufacturer identifier
56 | BYTE CardVersion; // Version
57 | WORD CheckCode; // Check code
58 | };
59 |
60 | CCasCard();
61 | ~CCasCard();
62 |
63 | const DWORD GetCardReaderNum(void) const;
64 | LPCTSTR EnumCardReader(const DWORD dwIndex) const;
65 |
66 | const bool OpenCard(CCardReader::ReaderType ReaderType = CCardReader::READER_SCARD, LPCTSTR lpszReader = NULL);
67 | void CloseCard(void);
68 | const bool ReOpenCard();
69 | const bool IsCardOpen() const;
70 | CCardReader::ReaderType GetCardReaderType() const;
71 | LPCTSTR GetCardReaderName() const;
72 |
73 | const bool GetCasCardInfo(CasCardInfo *pInfo) const;
74 | const bool GetCASystemID(WORD *pID) const;
75 | const BYTE * GetCardID(void) const;
76 | const BYTE GetCardType(void) const;
77 | const BYTE GetMessagePartitionLength(void) const;
78 | const BYTE * GetInitialCbc(void) const;
79 | const BYTE * GetSystemKey(void) const;
80 | const char GetCardManufacturerID() const;
81 | const BYTE GetCardVersion() const;
82 | const int FormatCardID(LPTSTR pszText, int MaxLength) const;
83 |
84 | const BYTE * GetKsFromEcm(const BYTE *pEcmData, const DWORD dwEcmSize);
85 | const bool SendEmmSection(const BYTE *pEmmData, const DWORD dwEmmSize);
86 | const bool ConfirmContract(const BYTE *pVerificationData, const DWORD DataSize, const WORD Date);
87 | const bool SendCommand(const BYTE *pSendData, const DWORD SendSize, BYTE *pReceiveData, DWORD *pReceiveSize);
88 |
89 | protected:
90 | const bool OpenAndInitialize(LPCTSTR pszReader);
91 | const bool InitialSetting(void);
92 |
93 | CCardReader *m_pCardReader;
94 |
95 | CasCardInfo m_CasCardInfo;
96 |
97 | struct TAG_ECMSTATUS
98 | {
99 | DWORD dwLastEcmSize; // 最後に問い合わせのあったECMサイズ
100 | BYTE LastEcmData[MAX_ECM_DATA_SIZE]; // 最後に問い合わせのあったECMデータ
101 | BYTE KsData[16]; // Ks Odd + Even
102 | bool bSucceeded; // ECMが受け付けられたか
103 | } m_EcmStatus;
104 | };
105 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opensdf
80 | *.sdf
81 | *.cachefile
82 |
83 | # Visual Studio profiler
84 | *.psess
85 | *.vsp
86 | *.vspx
87 | *.sap
88 |
89 | # TFS 2012 Local Workspace
90 | $tf/
91 |
92 | # Guidance Automation Toolkit
93 | *.gpState
94 |
95 | # ReSharper is a .NET coding add-in
96 | _ReSharper*/
97 | *.[Rr]e[Ss]harper
98 | *.DotSettings.user
99 |
100 | # JustCode is a .NET coding add-in
101 | .JustCode
102 |
103 | # TeamCity is a build add-in
104 | _TeamCity*
105 |
106 | # DotCover is a Code Coverage Tool
107 | *.dotCover
108 |
109 | # NCrunch
110 | _NCrunch_*
111 | .*crunch*.local.xml
112 | nCrunchTemp_*
113 |
114 | # MightyMoose
115 | *.mm.*
116 | AutoTest.Net/
117 |
118 | # Web workbench (sass)
119 | .sass-cache/
120 |
121 | # Installshield output folder
122 | [Ee]xpress/
123 |
124 | # DocProject is a documentation generator add-in
125 | DocProject/buildhelp/
126 | DocProject/Help/*.HxT
127 | DocProject/Help/*.HxC
128 | DocProject/Help/*.hhc
129 | DocProject/Help/*.hhk
130 | DocProject/Help/*.hhp
131 | DocProject/Help/Html2
132 | DocProject/Help/html
133 |
134 | # Click-Once directory
135 | publish/
136 |
137 | # Publish Web Output
138 | *.[Pp]ublish.xml
139 | *.azurePubxml
140 | # TODO: Comment the next line if you want to checkin your web deploy settings
141 | # but database connection strings (with potential passwords) will be unencrypted
142 | *.pubxml
143 | *.publishproj
144 |
145 | # NuGet Packages
146 | *.nupkg
147 | # The packages folder can be ignored because of Package Restore
148 | **/packages/*
149 | # except build/, which is used as an MSBuild target.
150 | !**/packages/build/
151 | # Uncomment if necessary however generally it will be regenerated when needed
152 | #!**/packages/repositories.config
153 |
154 | # Windows Azure Build Output
155 | csx/
156 | *.build.csdef
157 |
158 | # Windows Azure Emulator
159 | efc/
160 | rfc/
161 |
162 | # Windows Store app package directory
163 | AppPackages/
164 |
165 | # Visual Studio cache files
166 | # files ending in .cache can be ignored
167 | *.[Cc]ache
168 | # but keep track of directories ending in .cache
169 | !*.[Cc]ache/
170 |
171 | # Others
172 | ClientBin/
173 | [Ss]tyle[Cc]op.*
174 | ~$*
175 | *~
176 | *.dbmdl
177 | *.dbproj.schemaview
178 | *.pfx
179 | *.publishsettings
180 | node_modules/
181 | orleans.codegen.cs
182 |
183 | # RIA/Silverlight projects
184 | Generated_Code/
185 |
186 | # Backup & report files from converting an old project file
187 | # to a newer Visual Studio version. Backup files are not needed,
188 | # because we have git ;-)
189 | _UpgradeReport_Files/
190 | Backup*/
191 | UpgradeLog*.XML
192 | UpgradeLog*.htm
193 |
194 | # SQL Server files
195 | *.mdf
196 | *.ldf
197 |
198 | # Business Intelligence projects
199 | *.rdl.data
200 | *.bim.layout
201 | *.bim_*.settings
202 |
203 | # Microsoft Fakes
204 | FakesAssemblies/
205 |
206 | # GhostDoc plugin setting file
207 | *.GhostDoc.xml
208 |
209 | # Node.js Tools for Visual Studio
210 | .ntvs_analysis.dat
211 |
212 | # Visual Studio 6 build log
213 | *.plg
214 |
215 | # Visual Studio 6 workspace options file
216 | *.opt
217 |
218 | # Visual Studio LightSwitch build output
219 | **/*.HTMLClient/GeneratedArtifacts
220 | **/*.DesktopClient/GeneratedArtifacts
221 | **/*.DesktopClient/ModelManifest.xml
222 | **/*.Server/GeneratedArtifacts
223 | **/*.Server/ModelManifest.xml
224 | _Pvt_Extensions
225 |
226 | # Paket dependency manager
227 | .paket/paket.exe
228 |
229 | # FAKE - F# Make
230 | .fake/
231 |
232 | # SPHD files
233 | DebugSPHD/
234 | ReleaseSPHD/
--------------------------------------------------------------------------------
/TVCAS_B1/TVCAS_B1.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source files
20 |
21 |
22 | Source files
23 |
24 |
25 | Source files
26 |
27 |
28 | Source files
29 |
30 |
31 | Source files
32 |
33 |
34 | Source files
35 |
36 |
37 | Source files
38 |
39 |
40 | Source files
41 |
42 |
43 | Source files
44 |
45 |
46 | Source files
47 |
48 |
49 | Source files
50 |
51 |
52 | Source files
53 |
54 |
55 | Source files
56 |
57 |
58 | Source files
59 |
60 |
61 | Source files
62 |
63 |
64 | Source files
65 |
66 |
67 | Source files
68 |
69 |
70 |
71 |
72 | Header files
73 |
74 |
75 | Header files
76 |
77 |
78 | Header files
79 |
80 |
81 | Header files
82 |
83 |
84 | Header files
85 |
86 |
87 | Header files
88 |
89 |
90 | Header files
91 |
92 |
93 | Header files
94 |
95 |
96 | Header files
97 |
98 |
99 | Header files
100 |
101 |
102 | Header files
103 |
104 |
105 | Header files
106 |
107 |
108 | Header files
109 |
110 |
111 | Header files
112 |
113 |
114 | Header files
115 |
116 |
117 | Header files
118 |
119 |
120 | Header files
121 |
122 |
123 | Header files
124 |
125 |
126 | Header files
127 |
128 |
129 |
130 |
131 | Resource files
132 |
133 |
134 |
--------------------------------------------------------------------------------
/TVCAS_B25/TVCAS_B25.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source files
20 |
21 |
22 | Source files
23 |
24 |
25 | Source files
26 |
27 |
28 | Source files
29 |
30 |
31 | Source files
32 |
33 |
34 | Source files
35 |
36 |
37 | Source files
38 |
39 |
40 | Source files
41 |
42 |
43 | Source files
44 |
45 |
46 | Source files
47 |
48 |
49 | Source files
50 |
51 |
52 | Source files
53 |
54 |
55 | Source files
56 |
57 |
58 | Source files
59 |
60 |
61 | Source files
62 |
63 |
64 | Source files
65 |
66 |
67 | Source files
68 |
69 |
70 |
71 |
72 | Header files
73 |
74 |
75 | Header files
76 |
77 |
78 | Header files
79 |
80 |
81 | Header files
82 |
83 |
84 | Header files
85 |
86 |
87 | Header files
88 |
89 |
90 | Header files
91 |
92 |
93 | Header files
94 |
95 |
96 | Header files
97 |
98 |
99 | Header files
100 |
101 |
102 | Header files
103 |
104 |
105 | Header files
106 |
107 |
108 | Header files
109 |
110 |
111 | Header files
112 |
113 |
114 | Header files
115 |
116 |
117 | Header files
118 |
119 |
120 | Header files
121 |
122 |
123 | Header files
124 |
125 |
126 | Header files
127 |
128 |
129 |
130 |
131 | Resource files
132 |
133 |
134 |
--------------------------------------------------------------------------------
/TVCAS_B1/TsPacketParser.cpp:
--------------------------------------------------------------------------------
1 | // TsPacketParser.cpp: CTsPacketParser クラスのインプリメンテーション
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #include "stdafx.h"
6 | #include "TsPacketParser.h"
7 |
8 | #ifdef _DEBUG
9 | #undef THIS_FILE
10 | static char THIS_FILE[]=__FILE__;
11 | #define new DEBUG_NEW
12 | #endif
13 |
14 |
15 | #define TS_HEADSYNCBYTE (0x47U)
16 |
17 |
18 | //////////////////////////////////////////////////////////////////////
19 | // 構築/消滅
20 | //////////////////////////////////////////////////////////////////////
21 |
22 |
23 | CTsPacketParser::CTsPacketParser(IEventHandler *pEventHandler)
24 | : CMediaDecoder(pEventHandler, 1UL, 1UL)
25 | , m_bOutputNullPacket(false)
26 | , m_InputPacketCount(0)
27 | , m_OutputPacketCount(0)
28 | , m_ErrorPacketCount(0)
29 | , m_ContinuityErrorPacketCount(0)
30 | {
31 | // パケット連続性カウンタを初期化する
32 | ::FillMemory(m_abyContCounter, sizeof(m_abyContCounter), 0x10UL);
33 | }
34 |
35 | CTsPacketParser::~CTsPacketParser()
36 | {
37 | }
38 |
39 | void CTsPacketParser::Reset(void)
40 | {
41 | CBlockLock Lock(&m_DecoderLock);
42 |
43 | // パケットカウンタをクリアする
44 | m_InputPacketCount = 0;
45 | m_OutputPacketCount = 0;
46 | m_ErrorPacketCount = 0;
47 | m_ContinuityErrorPacketCount = 0;
48 |
49 | // パケット連続性カウンタを初期化する
50 | ::FillMemory(m_abyContCounter, sizeof(m_abyContCounter), 0x10UL);
51 |
52 | // 状態をリセットする
53 | m_TsPacket.ClearSize();
54 | }
55 |
56 | const bool CTsPacketParser::InputMedia(CMediaData *pMediaData, const DWORD dwInputIndex)
57 | {
58 | CBlockLock Lock(&m_DecoderLock);
59 |
60 | /*
61 | if (dwInputIndex >= GetInputNum())
62 | return false;
63 | */
64 |
65 | // TSパケットを処理する
66 | SyncPacket(pMediaData->GetData(), pMediaData->GetSize());
67 |
68 | return true;
69 | }
70 |
71 | bool CTsPacketParser::InputPacket(const void *pData, DWORD DataSize)
72 | {
73 | if (pData == NULL || DataSize != TS_PACKETSIZE)
74 | return false;
75 |
76 | m_TsPacket.SetData(pData, DataSize);
77 |
78 | return ParsePacket();
79 | }
80 |
81 | void CTsPacketParser::SetOutputNullPacket(const bool bEnable)
82 | {
83 | // NULLパケットの出力有無を設定する
84 | m_bOutputNullPacket = bEnable;
85 | }
86 |
87 | ULONGLONG CTsPacketParser::GetInputPacketCount(void) const
88 | {
89 | // 入力パケット数を返す
90 | return m_InputPacketCount;
91 | }
92 |
93 | ULONGLONG CTsPacketParser::GetOutputPacketCount(void) const
94 | {
95 | // 出力パケット数を返す
96 | return m_OutputPacketCount;
97 | }
98 |
99 | ULONGLONG CTsPacketParser::GetErrorPacketCount(void) const
100 | {
101 | // エラーパケット数を返す
102 | return m_ErrorPacketCount;
103 | }
104 |
105 | ULONGLONG CTsPacketParser::GetContinuityErrorPacketCount(void) const
106 | {
107 | // 連続性エラーパケット数を返す
108 | return m_ContinuityErrorPacketCount;
109 | }
110 |
111 | void CTsPacketParser::ResetErrorPacketCount(void)
112 | {
113 | m_ErrorPacketCount = 0;
114 | m_ContinuityErrorPacketCount = 0;
115 | }
116 |
117 | void inline CTsPacketParser::SyncPacket(const BYTE *pData, const DWORD dwSize)
118 | {
119 | // ※この方法は完全ではない、同期が乱れた場合に前回呼び出し時のデータまでさかのぼっては再同期はできない
120 | DWORD dwCurSize;
121 | DWORD dwCurPos = 0UL;
122 |
123 | while (dwCurPos < dwSize) {
124 | dwCurSize = m_TsPacket.GetSize();
125 |
126 | if (dwCurSize==0) {
127 | // 同期バイト待ち中
128 | do {
129 | if (pData[dwCurPos++] == TS_HEADSYNCBYTE) {
130 | // 同期バイト発見
131 | m_TsPacket.AddByte(TS_HEADSYNCBYTE);
132 | break;
133 | }
134 | } while (dwCurPos < dwSize);
135 | } else if (dwCurSize == TS_PACKETSIZE) {
136 | // パケットサイズ分データがそろった
137 |
138 | if (pData[dwCurPos] == TS_HEADSYNCBYTE) {
139 | // 次のデータは同期バイト
140 | ParsePacket();
141 | } else {
142 | // 同期エラー
143 | m_TsPacket.ClearSize();
144 |
145 | // 位置を元に戻す
146 | if (dwCurPos >= (TS_PACKETSIZE - 1UL))
147 | dwCurPos -= (TS_PACKETSIZE - 1UL);
148 | else
149 | dwCurPos = 0UL;
150 | }
151 | } else {
152 | // データ待ち
153 | DWORD dwRemain = (TS_PACKETSIZE - dwCurSize);
154 | if ((dwSize - dwCurPos) >= dwRemain) {
155 | m_TsPacket.AddData(&pData[dwCurPos], dwRemain);
156 | dwCurPos += dwRemain;
157 | } else {
158 | m_TsPacket.AddData(&pData[dwCurPos], dwSize - dwCurPos);
159 | break;
160 | }
161 | }
162 | }
163 | }
164 |
165 | bool inline CTsPacketParser::ParsePacket(void)
166 | {
167 | bool bOK;
168 |
169 | // 入力カウントインクリメント
170 | m_InputPacketCount++;
171 |
172 | // パケットを解析/チェックする
173 | switch (m_TsPacket.ParsePacket(m_abyContCounter)) {
174 | case CTsPacket::EC_CONTINUITY:
175 | m_ContinuityErrorPacketCount++;
176 | case CTsPacket::EC_VALID:
177 | // 次のデコーダにデータを渡す
178 | if (m_bOutputNullPacket || m_TsPacket.GetPID() != 0x1FFFU) {
179 | // 出力カウントインクリメント
180 | OutputMedia(&m_TsPacket);
181 |
182 | m_OutputPacketCount++;
183 | }
184 | bOK=true;
185 | break;
186 | case CTsPacket::EC_FORMAT:
187 | case CTsPacket::EC_TRANSPORT:
188 | // エラーカウントインクリメント
189 | m_ErrorPacketCount++;
190 | bOK=false;
191 | break;
192 | }
193 |
194 | // サイズをクリアし次のストアに備える
195 | m_TsPacket.ClearSize();
196 |
197 | return bOK;
198 | }
199 |
--------------------------------------------------------------------------------
/TVCAS_B25/TsPacketParser.cpp:
--------------------------------------------------------------------------------
1 | // TsPacketParser.cpp: CTsPacketParser クラスのインプリメンテーション
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #include "stdafx.h"
6 | #include "TsPacketParser.h"
7 |
8 | #ifdef _DEBUG
9 | #undef THIS_FILE
10 | static char THIS_FILE[]=__FILE__;
11 | #define new DEBUG_NEW
12 | #endif
13 |
14 |
15 | #define TS_HEADSYNCBYTE (0x47U)
16 |
17 |
18 | //////////////////////////////////////////////////////////////////////
19 | // 構築/消滅
20 | //////////////////////////////////////////////////////////////////////
21 |
22 |
23 | CTsPacketParser::CTsPacketParser(IEventHandler *pEventHandler)
24 | : CMediaDecoder(pEventHandler, 1UL, 1UL)
25 | , m_bOutputNullPacket(false)
26 | , m_InputPacketCount(0)
27 | , m_OutputPacketCount(0)
28 | , m_ErrorPacketCount(0)
29 | , m_ContinuityErrorPacketCount(0)
30 | {
31 | // パケット連続性カウンタを初期化する
32 | ::FillMemory(m_abyContCounter, sizeof(m_abyContCounter), 0x10UL);
33 | }
34 |
35 | CTsPacketParser::~CTsPacketParser()
36 | {
37 | }
38 |
39 | void CTsPacketParser::Reset(void)
40 | {
41 | CBlockLock Lock(&m_DecoderLock);
42 |
43 | // パケットカウンタをクリアする
44 | m_InputPacketCount = 0;
45 | m_OutputPacketCount = 0;
46 | m_ErrorPacketCount = 0;
47 | m_ContinuityErrorPacketCount = 0;
48 |
49 | // パケット連続性カウンタを初期化する
50 | ::FillMemory(m_abyContCounter, sizeof(m_abyContCounter), 0x10UL);
51 |
52 | // 状態をリセットする
53 | m_TsPacket.ClearSize();
54 | }
55 |
56 | const bool CTsPacketParser::InputMedia(CMediaData *pMediaData, const DWORD dwInputIndex)
57 | {
58 | CBlockLock Lock(&m_DecoderLock);
59 |
60 | /*
61 | if (dwInputIndex >= GetInputNum())
62 | return false;
63 | */
64 |
65 | // TSパケットを処理する
66 | SyncPacket(pMediaData->GetData(), pMediaData->GetSize());
67 |
68 | return true;
69 | }
70 |
71 | bool CTsPacketParser::InputPacket(const void *pData, DWORD DataSize)
72 | {
73 | if (pData == NULL || DataSize != TS_PACKETSIZE)
74 | return false;
75 |
76 | m_TsPacket.SetData(pData, DataSize);
77 |
78 | return ParsePacket();
79 | }
80 |
81 | void CTsPacketParser::SetOutputNullPacket(const bool bEnable)
82 | {
83 | // NULLパケットの出力有無を設定する
84 | m_bOutputNullPacket = bEnable;
85 | }
86 |
87 | ULONGLONG CTsPacketParser::GetInputPacketCount(void) const
88 | {
89 | // 入力パケット数を返す
90 | return m_InputPacketCount;
91 | }
92 |
93 | ULONGLONG CTsPacketParser::GetOutputPacketCount(void) const
94 | {
95 | // 出力パケット数を返す
96 | return m_OutputPacketCount;
97 | }
98 |
99 | ULONGLONG CTsPacketParser::GetErrorPacketCount(void) const
100 | {
101 | // エラーパケット数を返す
102 | return m_ErrorPacketCount;
103 | }
104 |
105 | ULONGLONG CTsPacketParser::GetContinuityErrorPacketCount(void) const
106 | {
107 | // 連続性エラーパケット数を返す
108 | return m_ContinuityErrorPacketCount;
109 | }
110 |
111 | void CTsPacketParser::ResetErrorPacketCount(void)
112 | {
113 | m_ErrorPacketCount = 0;
114 | m_ContinuityErrorPacketCount = 0;
115 | }
116 |
117 | void inline CTsPacketParser::SyncPacket(const BYTE *pData, const DWORD dwSize)
118 | {
119 | // ※この方法は完全ではない、同期が乱れた場合に前回呼び出し時のデータまでさかのぼっては再同期はできない
120 | DWORD dwCurSize;
121 | DWORD dwCurPos = 0UL;
122 |
123 | while (dwCurPos < dwSize) {
124 | dwCurSize = m_TsPacket.GetSize();
125 |
126 | if (dwCurSize==0) {
127 | // 同期バイト待ち中
128 | do {
129 | if (pData[dwCurPos++] == TS_HEADSYNCBYTE) {
130 | // 同期バイト発見
131 | m_TsPacket.AddByte(TS_HEADSYNCBYTE);
132 | break;
133 | }
134 | } while (dwCurPos < dwSize);
135 | } else if (dwCurSize == TS_PACKETSIZE) {
136 | // パケットサイズ分データがそろった
137 |
138 | if (pData[dwCurPos] == TS_HEADSYNCBYTE) {
139 | // 次のデータは同期バイト
140 | ParsePacket();
141 | } else {
142 | // 同期エラー
143 | m_TsPacket.ClearSize();
144 |
145 | // 位置を元に戻す
146 | if (dwCurPos >= (TS_PACKETSIZE - 1UL))
147 | dwCurPos -= (TS_PACKETSIZE - 1UL);
148 | else
149 | dwCurPos = 0UL;
150 | }
151 | } else {
152 | // データ待ち
153 | DWORD dwRemain = (TS_PACKETSIZE - dwCurSize);
154 | if ((dwSize - dwCurPos) >= dwRemain) {
155 | m_TsPacket.AddData(&pData[dwCurPos], dwRemain);
156 | dwCurPos += dwRemain;
157 | } else {
158 | m_TsPacket.AddData(&pData[dwCurPos], dwSize - dwCurPos);
159 | break;
160 | }
161 | }
162 | }
163 | }
164 |
165 | bool inline CTsPacketParser::ParsePacket(void)
166 | {
167 | bool bOK;
168 |
169 | // 入力カウントインクリメント
170 | m_InputPacketCount++;
171 |
172 | // パケットを解析/チェックする
173 | switch (m_TsPacket.ParsePacket(m_abyContCounter)) {
174 | case CTsPacket::EC_CONTINUITY:
175 | m_ContinuityErrorPacketCount++;
176 | case CTsPacket::EC_VALID:
177 | // 次のデコーダにデータを渡す
178 | if (m_bOutputNullPacket || m_TsPacket.GetPID() != 0x1FFFU) {
179 | // 出力カウントインクリメント
180 | OutputMedia(&m_TsPacket);
181 |
182 | m_OutputPacketCount++;
183 | }
184 | bOK=true;
185 | break;
186 | case CTsPacket::EC_FORMAT:
187 | case CTsPacket::EC_TRANSPORT:
188 | // エラーカウントインクリメント
189 | m_ErrorPacketCount++;
190 | bOK=false;
191 | break;
192 | }
193 |
194 | // サイズをクリアし次のストアに備える
195 | m_TsPacket.ClearSize();
196 |
197 | return bOK;
198 | }
199 |
--------------------------------------------------------------------------------
/TVCAS_B1/CardReader.h:
--------------------------------------------------------------------------------
1 | #ifndef CARD_READER_H
2 | #define CARD_READER_H
3 |
4 | #define CARDREADER_SCARD_DYNAMIC_SUPPORT
5 | #define CARDREADER_BONCASCLIENT_SUPPORT
6 |
7 | #include
8 | #include "BonBaseClass.h"
9 |
10 |
11 | // カードリーダー基底クラス
12 | class __declspec(novtable) CCardReader : public CBonBaseClass
13 | {
14 | public:
15 | enum ReaderType {
16 | READER_NONE,
17 | READER_SCARD,
18 | #ifdef CARDREADER_SCARD_DYNAMIC_SUPPORT
19 | READER_SCARD_DYNAMIC,
20 | #endif
21 | #ifdef CARDREADER_BONCASCLIENT_SUPPORT
22 | READER_BONCASCLIENT,
23 | #endif
24 | READER_TRAILER,
25 | READER_LAST = READER_TRAILER-1
26 | };
27 |
28 | CCardReader();
29 | virtual ~CCardReader();
30 | virtual bool Open(LPCTSTR pszReader = NULL) = 0;
31 | virtual void Close() = 0;
32 | virtual LPCTSTR GetReaderName() const = 0;
33 | virtual int NumReaders() const { return 1; }
34 | virtual LPCTSTR EnumReader(int Index) const;
35 | ReaderType GetReaderType() const { return m_ReaderType; }
36 | virtual bool IsAvailable() = 0;
37 | virtual bool IsReaderAvailable(LPCTSTR pszReader) = 0;
38 | virtual bool CheckAvailability(bool *pbAvailable, LPTSTR pszMessage, int MaxLength) = 0;
39 | virtual bool Transmit(const void *pSendData, DWORD SendSize, void *pRecvData, DWORD *pRecvSize) = 0;
40 |
41 | static CCardReader *CreateCardReader(ReaderType Type);
42 |
43 | private:
44 | ReaderType m_ReaderType;
45 | };
46 |
47 | // スマートカードリーダー
48 | class CSCardReader : public CCardReader
49 | {
50 | SCARDCONTEXT m_SCardContext;
51 | SCARDHANDLE m_hSCard;
52 | bool m_bIsEstablish;
53 | LPTSTR m_pReaderList;
54 | int m_NumReaders;
55 | LPTSTR m_pszReaderName;
56 |
57 | public:
58 | CSCardReader();
59 | ~CSCardReader();
60 |
61 | // CCardReader
62 | bool Open(LPCTSTR pszReader) override;
63 | void Close() override;
64 | LPCTSTR GetReaderName() const override;
65 | int NumReaders() const override;
66 | LPCTSTR EnumReader(int Index) const override;
67 | bool IsAvailable() override;
68 | bool IsReaderAvailable(LPCTSTR pszReader) override;
69 | bool CheckAvailability(bool *pbAvailable, LPTSTR pszMessage, int MaxLength) override;
70 | bool Transmit(const void *pSendData, DWORD SendSize, void *pRecvData, DWORD *pRecvSize) override;
71 | };
72 |
73 | #ifdef CARDREADER_SCARD_DYNAMIC_SUPPORT
74 | class CDynamicSCardReader : public CCardReader
75 | {
76 | HMODULE m_hLib;
77 | SCARDCONTEXT m_SCardContext;
78 | SCARDHANDLE m_hSCard;
79 | LPTSTR m_pReaderList;
80 | LPTSTR m_pszReaderName;
81 | typedef LONG (WINAPI *SCardReleaseContextFunc)(SCARDCONTEXT);
82 | typedef LONG (WINAPI *SCardConnectFunc)(SCARDCONTEXT, LPCTSTR, DWORD, DWORD, LPSCARDHANDLE, LPDWORD);
83 | typedef LONG (WINAPI *SCardDisconnectFunc)(SCARDHANDLE, DWORD);
84 | typedef LONG (WINAPI *SCardTransmitFunc)(SCARDHANDLE, LPCSCARD_IO_REQUEST, LPCBYTE,
85 | DWORD, LPSCARD_IO_REQUEST, LPBYTE, LPDWORD);
86 | SCardReleaseContextFunc m_pSCardReleaseContext;
87 | SCardConnectFunc m_pSCardConnect;
88 | SCardDisconnectFunc m_pSCardDisconnect;
89 | SCardTransmitFunc m_pSCardTransmit;
90 |
91 | bool Load(LPCTSTR pszFileName);
92 | void Unload();
93 |
94 | public:
95 | CDynamicSCardReader();
96 | ~CDynamicSCardReader();
97 |
98 | // CCardReader
99 | bool Open(LPCTSTR pszReader) override;
100 | void Close() override;
101 | LPCTSTR GetReaderName() const override;
102 | int NumReaders() const override;
103 | LPCTSTR EnumReader(int Index) const override;
104 | bool IsAvailable() override;
105 | bool IsReaderAvailable(LPCTSTR pszReader) override;
106 | bool CheckAvailability(bool *pbAvailable, LPTSTR pszMessage, int MaxLength) override;
107 | bool Transmit(const void *pSendData, DWORD SendSize, void *pRecvData, DWORD *pRecvSize) override;
108 | };
109 | #endif // CARDREADER_SCARD_DYNAMIC_SUPPORT
110 |
111 | #ifdef CARDREADER_BONCASCLIENT_SUPPORT
112 | // BonCasClient
113 | class CBonCasClientCardReader : public CCardReader
114 | {
115 | HMODULE m_hLib;
116 | SCARDCONTEXT m_SCardContext;
117 | SCARDHANDLE m_hSCard;
118 | LPTSTR m_pReaderList;
119 | LPTSTR m_pszReaderName;
120 | typedef LONG (WINAPI *CasLinkReleaseContextFunc)(SCARDCONTEXT);
121 | typedef LONG (WINAPI *CasLinkConnectFunc)(SCARDCONTEXT, LPCTSTR, DWORD, DWORD, LPSCARDHANDLE, LPDWORD);
122 | typedef LONG (WINAPI *CasLinkDisconnectFunc)(SCARDHANDLE, DWORD);
123 | typedef LONG (WINAPI *CasLinkTransmitFunc)(SCARDHANDLE, LPCSCARD_IO_REQUEST, LPCBYTE,
124 | DWORD, LPSCARD_IO_REQUEST, LPBYTE, LPDWORD);
125 | CasLinkReleaseContextFunc m_pCasLinkReleaseContext;
126 | CasLinkConnectFunc m_pCasLinkConnect;
127 | CasLinkDisconnectFunc m_pCasLinkDisconnect;
128 | CasLinkTransmitFunc m_pCasLinkTransmit;
129 |
130 | void GetModulePath(LPTSTR pszPath) const;
131 | bool Load(LPCTSTR pszFileName);
132 | bool Connect(LPCTSTR pszReader);
133 |
134 | public:
135 | CBonCasClientCardReader();
136 | ~CBonCasClientCardReader();
137 |
138 | // CCardReader
139 | bool Open(LPCTSTR pszReader) override;
140 | void Close() override;
141 | LPCTSTR GetReaderName() const override;
142 | int NumReaders() const override;
143 | LPCTSTR EnumReader(int Index) const override;
144 | bool IsAvailable() override;
145 | bool IsReaderAvailable(LPCTSTR pszReader) override;
146 | bool CheckAvailability(bool *pbAvailable, LPTSTR pszMessage, int MaxLength) override;
147 | bool Transmit(const void *pSendData, DWORD SendSize, void *pRecvData, DWORD *pRecvSize) override;
148 | };
149 | #endif // CARDREADER_BONCASCLIENT_SUPPORT
150 |
151 |
152 | #endif
153 |
--------------------------------------------------------------------------------
/TVCAS_B25/CardReader.h:
--------------------------------------------------------------------------------
1 | #ifndef CARD_READER_H
2 | #define CARD_READER_H
3 |
4 | #define CARDREADER_SCARD_DYNAMIC_SUPPORT
5 | #define CARDREADER_BONCASCLIENT_SUPPORT
6 |
7 | #include
8 | #include "BonBaseClass.h"
9 |
10 |
11 | // カードリーダー基底クラス
12 | class __declspec(novtable) CCardReader : public CBonBaseClass
13 | {
14 | public:
15 | enum ReaderType {
16 | READER_NONE,
17 | READER_SCARD,
18 | #ifdef CARDREADER_SCARD_DYNAMIC_SUPPORT
19 | READER_SCARD_DYNAMIC,
20 | #endif
21 | #ifdef CARDREADER_BONCASCLIENT_SUPPORT
22 | READER_BONCASCLIENT,
23 | #endif
24 | READER_TRAILER,
25 | READER_LAST = READER_TRAILER-1
26 | };
27 |
28 | CCardReader();
29 | virtual ~CCardReader();
30 | virtual bool Open(LPCTSTR pszReader = NULL) = 0;
31 | virtual void Close() = 0;
32 | virtual LPCTSTR GetReaderName() const = 0;
33 | virtual int NumReaders() const { return 1; }
34 | virtual LPCTSTR EnumReader(int Index) const;
35 | ReaderType GetReaderType() const { return m_ReaderType; }
36 | virtual bool IsAvailable() = 0;
37 | virtual bool IsReaderAvailable(LPCTSTR pszReader) = 0;
38 | virtual bool CheckAvailability(bool *pbAvailable, LPTSTR pszMessage, int MaxLength) = 0;
39 | virtual bool Transmit(const void *pSendData, DWORD SendSize, void *pRecvData, DWORD *pRecvSize) = 0;
40 |
41 | static CCardReader *CreateCardReader(ReaderType Type);
42 |
43 | private:
44 | ReaderType m_ReaderType;
45 | };
46 |
47 | // スマートカードリーダー
48 | class CSCardReader : public CCardReader
49 | {
50 | SCARDCONTEXT m_SCardContext;
51 | SCARDHANDLE m_hSCard;
52 | bool m_bIsEstablish;
53 | LPTSTR m_pReaderList;
54 | int m_NumReaders;
55 | LPTSTR m_pszReaderName;
56 |
57 | public:
58 | CSCardReader();
59 | ~CSCardReader();
60 |
61 | // CCardReader
62 | bool Open(LPCTSTR pszReader) override;
63 | void Close() override;
64 | LPCTSTR GetReaderName() const override;
65 | int NumReaders() const override;
66 | LPCTSTR EnumReader(int Index) const override;
67 | bool IsAvailable() override;
68 | bool IsReaderAvailable(LPCTSTR pszReader) override;
69 | bool CheckAvailability(bool *pbAvailable, LPTSTR pszMessage, int MaxLength) override;
70 | bool Transmit(const void *pSendData, DWORD SendSize, void *pRecvData, DWORD *pRecvSize) override;
71 | };
72 |
73 | #ifdef CARDREADER_SCARD_DYNAMIC_SUPPORT
74 | class CDynamicSCardReader : public CCardReader
75 | {
76 | HMODULE m_hLib;
77 | SCARDCONTEXT m_SCardContext;
78 | SCARDHANDLE m_hSCard;
79 | LPTSTR m_pReaderList;
80 | LPTSTR m_pszReaderName;
81 | typedef LONG (WINAPI *SCardReleaseContextFunc)(SCARDCONTEXT);
82 | typedef LONG (WINAPI *SCardConnectFunc)(SCARDCONTEXT, LPCTSTR, DWORD, DWORD, LPSCARDHANDLE, LPDWORD);
83 | typedef LONG (WINAPI *SCardDisconnectFunc)(SCARDHANDLE, DWORD);
84 | typedef LONG (WINAPI *SCardTransmitFunc)(SCARDHANDLE, LPCSCARD_IO_REQUEST, LPCBYTE,
85 | DWORD, LPSCARD_IO_REQUEST, LPBYTE, LPDWORD);
86 | SCardReleaseContextFunc m_pSCardReleaseContext;
87 | SCardConnectFunc m_pSCardConnect;
88 | SCardDisconnectFunc m_pSCardDisconnect;
89 | SCardTransmitFunc m_pSCardTransmit;
90 |
91 | bool Load(LPCTSTR pszFileName);
92 | void Unload();
93 |
94 | public:
95 | CDynamicSCardReader();
96 | ~CDynamicSCardReader();
97 |
98 | // CCardReader
99 | bool Open(LPCTSTR pszReader) override;
100 | void Close() override;
101 | LPCTSTR GetReaderName() const override;
102 | int NumReaders() const override;
103 | LPCTSTR EnumReader(int Index) const override;
104 | bool IsAvailable() override;
105 | bool IsReaderAvailable(LPCTSTR pszReader) override;
106 | bool CheckAvailability(bool *pbAvailable, LPTSTR pszMessage, int MaxLength) override;
107 | bool Transmit(const void *pSendData, DWORD SendSize, void *pRecvData, DWORD *pRecvSize) override;
108 | };
109 | #endif // CARDREADER_SCARD_DYNAMIC_SUPPORT
110 |
111 | #ifdef CARDREADER_BONCASCLIENT_SUPPORT
112 | // BonCasClient
113 | class CBonCasClientCardReader : public CCardReader
114 | {
115 | HMODULE m_hLib;
116 | SCARDCONTEXT m_SCardContext;
117 | SCARDHANDLE m_hSCard;
118 | LPTSTR m_pReaderList;
119 | LPTSTR m_pszReaderName;
120 | typedef LONG (WINAPI *CasLinkReleaseContextFunc)(SCARDCONTEXT);
121 | typedef LONG (WINAPI *CasLinkConnectFunc)(SCARDCONTEXT, LPCTSTR, DWORD, DWORD, LPSCARDHANDLE, LPDWORD);
122 | typedef LONG (WINAPI *CasLinkDisconnectFunc)(SCARDHANDLE, DWORD);
123 | typedef LONG (WINAPI *CasLinkTransmitFunc)(SCARDHANDLE, LPCSCARD_IO_REQUEST, LPCBYTE,
124 | DWORD, LPSCARD_IO_REQUEST, LPBYTE, LPDWORD);
125 | CasLinkReleaseContextFunc m_pCasLinkReleaseContext;
126 | CasLinkConnectFunc m_pCasLinkConnect;
127 | CasLinkDisconnectFunc m_pCasLinkDisconnect;
128 | CasLinkTransmitFunc m_pCasLinkTransmit;
129 |
130 | void GetModulePath(LPTSTR pszPath) const;
131 | bool Load(LPCTSTR pszFileName);
132 | bool Connect(LPCTSTR pszReader);
133 |
134 | public:
135 | CBonCasClientCardReader();
136 | ~CBonCasClientCardReader();
137 |
138 | // CCardReader
139 | bool Open(LPCTSTR pszReader) override;
140 | void Close() override;
141 | LPCTSTR GetReaderName() const override;
142 | int NumReaders() const override;
143 | LPCTSTR EnumReader(int Index) const override;
144 | bool IsAvailable() override;
145 | bool IsReaderAvailable(LPCTSTR pszReader) override;
146 | bool CheckAvailability(bool *pbAvailable, LPTSTR pszMessage, int MaxLength) override;
147 | bool Transmit(const void *pSendData, DWORD SendSize, void *pRecvData, DWORD *pRecvSize) override;
148 | };
149 | #endif // CARDREADER_BONCASCLIENT_SUPPORT
150 |
151 |
152 | #endif
153 |
--------------------------------------------------------------------------------
/TVCAS_B1/TsUtilClass.h:
--------------------------------------------------------------------------------
1 | // TsUtilClass.h: TSユーティリティークラスのインターフェイス
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #pragma once
6 |
7 |
8 | /////////////////////////////////////////////////////////////////////////////
9 | // ダイナミックリファレンス管理ベースクラス
10 | /////////////////////////////////////////////////////////////////////////////
11 |
12 | class CDynamicReferenceable
13 | {
14 | public:
15 | CDynamicReferenceable();
16 | virtual ~CDynamicReferenceable();
17 |
18 | void AddRef(void);
19 | void ReleaseRef(void);
20 |
21 | private:
22 | LONG m_RefCount;
23 | };
24 |
25 |
26 | /////////////////////////////////////////////////////////////////////////////
27 | // クリティカルセクションラッパークラス
28 | /////////////////////////////////////////////////////////////////////////////
29 |
30 | class CCriticalLock
31 | {
32 | public:
33 | CCriticalLock();
34 | virtual ~CCriticalLock();
35 |
36 | void Lock(void);
37 | void Unlock(void);
38 | bool TryLock(DWORD TimeOut=0);
39 | private:
40 | CRITICAL_SECTION m_CriticalSection;
41 | };
42 |
43 |
44 | /////////////////////////////////////////////////////////////////////////////
45 | // ブロックスコープロッククラス
46 | /////////////////////////////////////////////////////////////////////////////
47 |
48 | class CBlockLock
49 | {
50 | public:
51 | CBlockLock(CCriticalLock *pCriticalLock);
52 | virtual ~CBlockLock();
53 |
54 | private:
55 | CCriticalLock *m_pCriticalLock;
56 | };
57 |
58 | class CTryBlockLock
59 | {
60 | public:
61 | CTryBlockLock(CCriticalLock *pCriticalLock);
62 | bool TryLock(DWORD TimeOut=0);
63 | ~CTryBlockLock();
64 | private:
65 | CCriticalLock *m_pCriticalLock;
66 | bool m_bLocked;
67 | };
68 |
69 |
70 | /////////////////////////////////////////////////////////////////////////////
71 | // イベントクラス
72 | /////////////////////////////////////////////////////////////////////////////
73 |
74 | class CLocalEvent
75 | {
76 | HANDLE m_hEvent;
77 | public:
78 | CLocalEvent();
79 | ~CLocalEvent();
80 | bool Create(bool bManual = false, bool bInitialState = false);
81 | bool IsCreated() const;
82 | void Close();
83 | bool Set();
84 | bool Reset();
85 | DWORD Wait(DWORD Timeout = INFINITE);
86 | DWORD SignalAndWait(HANDLE hHandle, DWORD Timeout = INFINITE, bool bAlertable = false);
87 | DWORD SignalAndWait(CLocalEvent *pEvent, DWORD Timeout = INFINITE);
88 | bool IsSignaled();
89 | };
90 |
91 |
92 | /////////////////////////////////////////////////////////////////////////////
93 | // 日時クラス
94 | /////////////////////////////////////////////////////////////////////////////
95 |
96 | class CDateTime
97 | {
98 | SYSTEMTIME m_Time;
99 | public:
100 | CDateTime();
101 | CDateTime(const SYSTEMTIME &Time);
102 | CDateTime &operator=(const SYSTEMTIME &Time);
103 | CDateTime &operator=(const FILETIME &Time);
104 | void LocalTime();
105 | void UTCTime();
106 | //bool LocalToUTC();
107 | //bool UTCToLocal();
108 | bool Offset(LONGLONG Milliseconds);
109 | void Set(const SYSTEMTIME &Time) { m_Time = Time; }
110 | const SYSTEMTIME &Get() const { return m_Time; }
111 | void Get(SYSTEMTIME *pTime) const;
112 | int GetYear() const { return m_Time.wYear; }
113 | int GetMonth() const { return m_Time.wMonth; }
114 | int GetDay() const { return m_Time.wDay; }
115 | int GetDayOfWeek() const { return m_Time.wDayOfWeek; }
116 | int GetHour() const { return m_Time.wHour; }
117 | int GetMinute() const { return m_Time.wMinute; }
118 | int GetSecond() const { return m_Time.wSecond; }
119 | DWORD GetMilliseconds() const { return m_Time.wMilliseconds; }
120 | static LONGLONG SECONDS(int Sec) { return Sec * 1000LL; }
121 | static LONGLONG MINUTES(int Min) { return Min * (1000LL * 60LL); }
122 | static LONGLONG HOURS(int Hours) { return Hours * (1000LL * 60LL * 60LL); }
123 | };
124 |
125 |
126 | /////////////////////////////////////////////////////////////////////////////
127 | // トレースクラス
128 | /////////////////////////////////////////////////////////////////////////////
129 |
130 | class CTracer
131 | {
132 | TCHAR m_szBuffer[256];
133 | public:
134 | virtual ~CTracer() {}
135 | void Trace(LPCTSTR pszOutput, ...);
136 | void TraceV(LPCTSTR pszOutput,va_list Args);
137 | protected:
138 | virtual void OnTrace(LPCTSTR pszOutput)=0;
139 | };
140 |
141 |
142 | /////////////////////////////////////////////////////////////////////////////
143 | // CRC計算クラス
144 | /////////////////////////////////////////////////////////////////////////////
145 |
146 | class CCrcCalculator
147 | {
148 | public:
149 | static WORD CalcCrc16(const BYTE *pData, SIZE_T DataSize, WORD wCurCrc = 0xFFFF);
150 | static DWORD CalcCrc32(const BYTE *pData, SIZE_T DataSize, DWORD dwCurCrc = 0xFFFFFFFFUL);
151 | };
152 |
153 | class CCrc32
154 | {
155 | DWORD m_Crc;
156 | public:
157 | CCrc32();
158 | DWORD GetCrc() const;
159 | void Calc(const void *pData, SIZE_T DataSize);
160 | void Reset();
161 | };
162 |
163 |
164 | /////////////////////////////////////////////////////////////////////////////
165 | // MD5計算クラス
166 | /////////////////////////////////////////////////////////////////////////////
167 |
168 | class CMD5Calculator
169 | {
170 | static void MD5Transform(DWORD pBuffer[4], const void *pData);
171 | public:
172 | static void CalcMD5(const void *pData, SIZE_T DataSize, BYTE pMD5[16]);
173 | };
174 |
175 |
176 | /////////////////////////////////////////////////////////////////////////////
177 | // ビットレート計算クラス
178 | /////////////////////////////////////////////////////////////////////////////
179 |
180 | class CBitRateCalculator
181 | {
182 | DWORD m_Time;
183 | SIZE_T m_Size;
184 | DWORD m_BitRate;
185 | public:
186 | CBitRateCalculator();
187 | void Initialize();
188 | void Reset();
189 | bool Update(SIZE_T Size);
190 | DWORD GetBitRate() const { return m_BitRate; }
191 | };
192 |
--------------------------------------------------------------------------------
/TVCAS_B25/TsUtilClass.h:
--------------------------------------------------------------------------------
1 | // TsUtilClass.h: TSユーティリティークラスのインターフェイス
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #pragma once
6 |
7 |
8 | /////////////////////////////////////////////////////////////////////////////
9 | // ダイナミックリファレンス管理ベースクラス
10 | /////////////////////////////////////////////////////////////////////////////
11 |
12 | class CDynamicReferenceable
13 | {
14 | public:
15 | CDynamicReferenceable();
16 | virtual ~CDynamicReferenceable();
17 |
18 | void AddRef(void);
19 | void ReleaseRef(void);
20 |
21 | private:
22 | LONG m_RefCount;
23 | };
24 |
25 |
26 | /////////////////////////////////////////////////////////////////////////////
27 | // クリティカルセクションラッパークラス
28 | /////////////////////////////////////////////////////////////////////////////
29 |
30 | class CCriticalLock
31 | {
32 | public:
33 | CCriticalLock();
34 | virtual ~CCriticalLock();
35 |
36 | void Lock(void);
37 | void Unlock(void);
38 | bool TryLock(DWORD TimeOut=0);
39 | private:
40 | CRITICAL_SECTION m_CriticalSection;
41 | };
42 |
43 |
44 | /////////////////////////////////////////////////////////////////////////////
45 | // ブロックスコープロッククラス
46 | /////////////////////////////////////////////////////////////////////////////
47 |
48 | class CBlockLock
49 | {
50 | public:
51 | CBlockLock(CCriticalLock *pCriticalLock);
52 | virtual ~CBlockLock();
53 |
54 | private:
55 | CCriticalLock *m_pCriticalLock;
56 | };
57 |
58 | class CTryBlockLock
59 | {
60 | public:
61 | CTryBlockLock(CCriticalLock *pCriticalLock);
62 | bool TryLock(DWORD TimeOut=0);
63 | ~CTryBlockLock();
64 | private:
65 | CCriticalLock *m_pCriticalLock;
66 | bool m_bLocked;
67 | };
68 |
69 |
70 | /////////////////////////////////////////////////////////////////////////////
71 | // イベントクラス
72 | /////////////////////////////////////////////////////////////////////////////
73 |
74 | class CLocalEvent
75 | {
76 | HANDLE m_hEvent;
77 | public:
78 | CLocalEvent();
79 | ~CLocalEvent();
80 | bool Create(bool bManual = false, bool bInitialState = false);
81 | bool IsCreated() const;
82 | void Close();
83 | bool Set();
84 | bool Reset();
85 | DWORD Wait(DWORD Timeout = INFINITE);
86 | DWORD SignalAndWait(HANDLE hHandle, DWORD Timeout = INFINITE, bool bAlertable = false);
87 | DWORD SignalAndWait(CLocalEvent *pEvent, DWORD Timeout = INFINITE);
88 | bool IsSignaled();
89 | };
90 |
91 |
92 | /////////////////////////////////////////////////////////////////////////////
93 | // 日時クラス
94 | /////////////////////////////////////////////////////////////////////////////
95 |
96 | class CDateTime
97 | {
98 | SYSTEMTIME m_Time;
99 | public:
100 | CDateTime();
101 | CDateTime(const SYSTEMTIME &Time);
102 | CDateTime &operator=(const SYSTEMTIME &Time);
103 | CDateTime &operator=(const FILETIME &Time);
104 | void LocalTime();
105 | void UTCTime();
106 | //bool LocalToUTC();
107 | //bool UTCToLocal();
108 | bool Offset(LONGLONG Milliseconds);
109 | void Set(const SYSTEMTIME &Time) { m_Time = Time; }
110 | const SYSTEMTIME &Get() const { return m_Time; }
111 | void Get(SYSTEMTIME *pTime) const;
112 | int GetYear() const { return m_Time.wYear; }
113 | int GetMonth() const { return m_Time.wMonth; }
114 | int GetDay() const { return m_Time.wDay; }
115 | int GetDayOfWeek() const { return m_Time.wDayOfWeek; }
116 | int GetHour() const { return m_Time.wHour; }
117 | int GetMinute() const { return m_Time.wMinute; }
118 | int GetSecond() const { return m_Time.wSecond; }
119 | DWORD GetMilliseconds() const { return m_Time.wMilliseconds; }
120 | static LONGLONG SECONDS(int Sec) { return Sec * 1000LL; }
121 | static LONGLONG MINUTES(int Min) { return Min * (1000LL * 60LL); }
122 | static LONGLONG HOURS(int Hours) { return Hours * (1000LL * 60LL * 60LL); }
123 | };
124 |
125 |
126 | /////////////////////////////////////////////////////////////////////////////
127 | // トレースクラス
128 | /////////////////////////////////////////////////////////////////////////////
129 |
130 | class CTracer
131 | {
132 | TCHAR m_szBuffer[256];
133 | public:
134 | virtual ~CTracer() {}
135 | void Trace(LPCTSTR pszOutput, ...);
136 | void TraceV(LPCTSTR pszOutput,va_list Args);
137 | protected:
138 | virtual void OnTrace(LPCTSTR pszOutput)=0;
139 | };
140 |
141 |
142 | /////////////////////////////////////////////////////////////////////////////
143 | // CRC計算クラス
144 | /////////////////////////////////////////////////////////////////////////////
145 |
146 | class CCrcCalculator
147 | {
148 | public:
149 | static WORD CalcCrc16(const BYTE *pData, SIZE_T DataSize, WORD wCurCrc = 0xFFFF);
150 | static DWORD CalcCrc32(const BYTE *pData, SIZE_T DataSize, DWORD dwCurCrc = 0xFFFFFFFFUL);
151 | };
152 |
153 | class CCrc32
154 | {
155 | DWORD m_Crc;
156 | public:
157 | CCrc32();
158 | DWORD GetCrc() const;
159 | void Calc(const void *pData, SIZE_T DataSize);
160 | void Reset();
161 | };
162 |
163 |
164 | /////////////////////////////////////////////////////////////////////////////
165 | // MD5計算クラス
166 | /////////////////////////////////////////////////////////////////////////////
167 |
168 | class CMD5Calculator
169 | {
170 | static void MD5Transform(DWORD pBuffer[4], const void *pData);
171 | public:
172 | static void CalcMD5(const void *pData, SIZE_T DataSize, BYTE pMD5[16]);
173 | };
174 |
175 |
176 | /////////////////////////////////////////////////////////////////////////////
177 | // ビットレート計算クラス
178 | /////////////////////////////////////////////////////////////////////////////
179 |
180 | class CBitRateCalculator
181 | {
182 | DWORD m_Time;
183 | SIZE_T m_Size;
184 | DWORD m_BitRate;
185 | public:
186 | CBitRateCalculator();
187 | void Initialize();
188 | void Reset();
189 | bool Update(SIZE_T Size);
190 | DWORD GetBitRate() const { return m_BitRate; }
191 | };
192 |
--------------------------------------------------------------------------------
/TVCAS_B1/TsDescrambler.h:
--------------------------------------------------------------------------------
1 | // TsDescrambler.h: CTsDescrambler クラスのインターフェイス
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 | #pragma once
6 |
7 |
8 | #include
9 | #include
10 | #include