forked from u-n-k-n-o-w-n/BonDriverProxy_Linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBonDriverProxy.h
More file actions
135 lines (113 loc) · 3.18 KB
/
BonDriverProxy.h
File metadata and controls
135 lines (113 loc) · 3.18 KB
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
#ifndef __BONDRIVERPROXY_H__
#define __BONDRIVERPROXY_H__
// Shut up warning
// warning: 'daemon' is deprecated: first deprecated in OS X 10.5
#if __APPLE__
#define daemon fake_daemon
#endif
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <dlfcn.h>
#include <pthread.h>
#include <list>
#include <queue>
#include "typedef.h"
#include "IBonDriver3.h"
#if __APPLE__
#undef daemon
extern "C" {
extern int daemon(int, int);
}
#endif
namespace BonDriverProxy {
#define WAIT_TIME 10 // GetTsStream()の後で、dwRemainが0だった場合に待つ時間(ms)
////////////////////////////////////////////////////////////////////////////////
static char g_Host[256];
static char g_Port[8];
static size_t g_PacketFifoSize = 64;
static DWORD g_TsPacketBufSize = (188 * 1024);
static BOOL g_DisableUnloadBonDriver = TRUE; // bdplの標準はTRUEにする
#define BONDRIVER_PATH_MAX 512
struct stLoadedDriver {
char strBonDriver[BONDRIVER_PATH_MAX];
HMODULE hModule;
};
static std::list<stLoadedDriver *> g_LoadedDriverList;
////////////////////////////////////////////////////////////////////////////////
#include "Common.h"
#include "BdpPacket.h"
////////////////////////////////////////////////////////////////////////////////
class cProxyServer;
struct stTsReaderArg {
IBonDriver *pIBon;
volatile BOOL StopTsRead;
volatile BOOL ChannelChanged;
DWORD pos;
std::list<cProxyServer *> TsReceiversList;
std::list<cProxyServer *> WaitExclusivePrivList;
cCriticalSection TsLock;
stTsReaderArg()
{
StopTsRead = FALSE;
ChannelChanged = TRUE;
pos = 0;
}
};
class cProxyServer {
IBonDriver *m_pIBon;
IBonDriver2 *m_pIBon2;
IBonDriver3 *m_pIBon3;
HMODULE m_hModule;
SOCKET m_s;
pthread_cond_t m_c;
pthread_mutex_t m_m;
cEvent m_Error;
char m_strBonDriver[BONDRIVER_PATH_MAX];
BOOL m_bTunerOpen;
BYTE m_bChannelLock;
DWORD m_tRet;
pthread_t m_hTsRead;
stTsReaderArg *m_pTsReaderArg;
cPacketFifo m_fifoSend;
cPacketFifo m_fifoRecv;
DWORD Process();
int ReceiverHelper(char *pDst, DWORD left);
static void *Receiver(LPVOID pv);
void makePacket(enumCommand eCmd, BOOL b);
void makePacket(enumCommand eCmd, DWORD dw);
void makePacket(enumCommand eCmd, LPCTSTR str);
void makePacket(enumCommand eCmd, BYTE *pSrc, DWORD dwSize, float fSignalLevel);
static void *Sender(LPVOID pv);
static void *TsReader(LPVOID pv);
BOOL SelectBonDriver(LPCSTR p);
IBonDriver *CreateBonDriver();
// IBonDriver
const BOOL OpenTuner(void);
void CloseTuner(void);
void PurgeTsStream(void);
// IBonDriver2
LPCTSTR EnumTuningSpace(const DWORD dwSpace);
LPCTSTR EnumChannelName(const DWORD dwSpace, const DWORD dwChannel);
const BOOL SetChannel(const DWORD dwSpace, const DWORD dwChannel);
// IBonDriver3
const DWORD GetTotalDeviceNum(void);
const DWORD GetActiveDeviceNum(void);
const BOOL SetLnbPower(const BOOL bEnable);
public:
cProxyServer();
~cProxyServer();
void setSocket(SOCKET s){ m_s = s; }
static void *Reception(LPVOID pv);
};
static std::list<cProxyServer *> g_InstanceList;
static cCriticalSection g_Lock;
}
#endif // __BONDRIVERPROXY_H__