-
Notifications
You must be signed in to change notification settings - Fork 12
/
BonDriver_Mirakurun.h
executable file
·149 lines (108 loc) · 3.3 KB
/
BonDriver_Mirakurun.h
1
2
3
4
5
6
7
8
9
10
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#include <winsock2.h>
#include <ws2tcpip.h>
#include <InitGuid.h>
#include "IBonDriver2.h"
#include "binzume\http.h"
#include "picojson\picojson.h"
using namespace std;
using namespace Net;
#if !defined(_BONTUNER_H_)
#define _BONTUNER_H_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define dllimport dllexport
#define TUNER_NAME "BonDriver_Mirakurun"
// 受信サイズ
#define TSDATASIZE 48128 // TSデータのサイズ 188 * 256
static wchar_t g_IniFilePath[MAX_PATH] = { '\0' };
// チューナ空間
#define SPACE_NUM 8
static char *g_pType[SPACE_NUM];
static DWORD g_Max_Type;
static DWORD g_Channel_Base[SPACE_NUM];
#define MAX_HOST_LEN 256
#define MAX_PORT_LEN 8
static char g_ServerHost[MAX_HOST_LEN];
static char g_ServerPort[MAX_PORT_LEN];
static int g_DecodeB25;
static int g_Priority;
static int g_Service_Split;
picojson::value g_Channel_JSON;
static int g_MagicPacket_Enable;
static char g_MagicPacket_TargetMAC[18];
static char g_MagicPacket_TargetIP[16];
#define MAGICPACKET_WAIT_SECONDS 20
class CBonTuner : public IBonDriver2
{
public:
CBonTuner();
virtual ~CBonTuner();
// Initialize channel
void InitChannel(void);
// IBonDriver
const BOOL OpenTuner(void);
void CloseTuner(void);
const BOOL SetChannel(const BYTE bCh);
const float GetSignalLevel(void);
const DWORD WaitTsStream(const DWORD dwTimeOut = 0);
const DWORD GetReadyCount(void);
const BOOL GetTsStream(BYTE *pDst, DWORD *pdwSize, DWORD *pdwRemain);
const BOOL GetTsStream(BYTE **ppDst, DWORD *pdwSize, DWORD *pdwRemain);
void PurgeTsStream(void);
// IBonDriver2(暫定)
LPCTSTR GetTunerName(void);
const BOOL IsTunerOpening(void);
LPCTSTR EnumTuningSpace(const DWORD dwSpace);
LPCTSTR EnumChannelName(const DWORD dwSpace, const DWORD dwChannel);
const BOOL SetChannel(const DWORD dwSpace, const DWORD dwChannel);
const DWORD GetCurSpace(void);
const DWORD GetCurChannel(void);
void Release(void);
static CBonTuner * m_pThis;
static HINSTANCE m_hModule;
static char * m_cList[7];
protected:
// I/Oリクエストキューデータ
struct AsyncIoReq
{
WSAOVERLAPPED OverLapped;
DWORD dwState;
DWORD dwRxdSize;
BYTE RxdBuff[TSDATASIZE];
AsyncIoReq *pNext;
};
AsyncIoReq * AllocIoReqBuff(const DWORD dwBuffNum);
void FreeIoReqBuff(AsyncIoReq *pBuff);
static DWORD WINAPI PushIoThread(LPVOID pParam);
static DWORD WINAPI PopIoThread(LPVOID pParam);
const BOOL PushIoRequest(SOCKET sock);
const BOOL PopIoRequest(SOCKET sock);
bool m_bTunerOpen;
HANDLE m_hMutex;
BYTE m_RxdBuff[256];
AsyncIoReq *m_pIoReqBuff;
AsyncIoReq *m_pIoPushReq;
AsyncIoReq *m_pIoPopReq;
AsyncIoReq *m_pIoGetReq;
DWORD m_dwBusyReqNum;
DWORD m_dwReadyReqNum;
HANDLE m_hPushIoThread;
HANDLE m_hPopIoThread;
BOOL m_bLoopIoThread;
HANDLE m_hOnStreamEvent;
CRITICAL_SECTION m_CriticalSection;
DWORD m_dwCurSpace;
DWORD m_dwCurChannel;
// 追加 byMeru(2008/03/27)
SOCKET m_sock;
float m_fBitRate;
void CalcBitRate();
void GetApiChannels(picojson::value *json_array, int service_split);
DWORD m_dwRecvBytes;
DWORD m_dwLastCalcTick;
ULONGLONG m_u64RecvBytes;
ULONGLONG m_u64LastCalcByte;
};
#endif // !defined(_BONTUNER_H_)