-
Notifications
You must be signed in to change notification settings - Fork 4
/
module_api.h
261 lines (216 loc) · 7.68 KB
/
module_api.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#ifndef __TSD_MODULES_HOOKS
#define __TSD_MODULES_HOOKS
typedef void (*register_hooks_t)();
typedef const TSDCHAR* (*cmd_handler_t)(const TSDCHAR*);
#define TSDUMP_MODULE_API_VER 7
typedef enum {
TSDUMP_SCALE_NONE,
TSDUMP_SCALE_COUNTER,
TSDUMP_SCALE_DECIBEL,
TSDUMP_SCALE_RELATIVE,
} signal_value_scale_t;
typedef struct{
const TSDCHAR *cmd_name;
const TSDCHAR *cmd_description;
int have_option;
cmd_handler_t cmd_handler;
} cmd_def_t;
typedef struct{
int mod_ver;
const TSDCHAR *modname;
register_hooks_t register_hooks;
cmd_def_t *cmds;
void(*init_handler)();
void(*api_init_handler)(void*);
} module_def_t;
typedef struct{
int sp_num;
int ch_num;
int n_services;
unsigned int *services;
int mode_all_services;
const TSDCHAR *tuner_name;
const TSDCHAR *sp_str;
const TSDCHAR *ch_str;
} ch_info_t;
typedef void* (*hook_pgoutput_precreate_t)(const TSDCHAR*, const proginfo_t*, const ch_info_t*, const int, int*);
typedef void(*hook_pgoutput_changed_t)(void*, const proginfo_t*, const proginfo_t*);
typedef void(*hook_pgoutput_end_t)(void*, const proginfo_t*);
typedef void(*hook_pgoutput_postclose_t)(void*, const proginfo_t*, const void*);
typedef void* (*hook_pgoutput_create_t)(void*, const TSDCHAR*, const proginfo_t*, const ch_info_t*, const int);
typedef int (*hook_pgoutput_t)(void*, const unsigned char*, const size_t);
typedef const int (*hook_pgoutput_check_t)(void*);
typedef void (*hook_pgoutput_close_t)(void*, const proginfo_t*);
typedef int (*hook_pgoutput_forceclose_t)(void*, int, int);
typedef int (*hook_postconfig_t)();
typedef void (*hook_preclose_module_t)();
typedef void (*hook_close_module_t)();
typedef void (*hook_open_stream_t)();
typedef void (*hook_encrypted_stream_t)(const unsigned char*, const size_t);
typedef void (*hook_stream_t)(const unsigned char*, const size_t, const int);
typedef void (*hook_close_stream_t)();
typedef void (*hook_stream_generator_t)(void *, unsigned char **, int *);
typedef int (*hook_stream_generator_open_t)(void**, ch_info_t*);
typedef int (*hook_stream_generator_wait_t)(void *, int);
typedef void (*hook_stream_generator_siglevel_t)(void*, double*, signal_value_scale_t*);
typedef void (*hook_stream_generator_cnr_t)(void*, double*, signal_value_scale_t*);
typedef void (*hook_stream_generator_close_t)(void*);
typedef void (*hook_tick_t)(int64_t);
typedef struct {
hook_stream_generator_open_t open_handler;
hook_stream_generator_t handler;
hook_stream_generator_wait_t wait_handler;
hook_stream_generator_siglevel_t siglevel_handler;
hook_stream_generator_cnr_t cnr_handler;
hook_stream_generator_close_t close_handler;
} hooks_stream_generator_t;
typedef struct {
int64_t n_input;
int64_t n_output;
int64_t n_dropped;
int64_t n_scrambled;
} decoder_stats_t;
typedef struct {
signal_value_scale_t cnr_scale;
double cnr;
signal_value_scale_t level_scale;
double level;
} signal_stats_t;
typedef struct {
int64_t total_bytes;
decoder_stats_t s_decoder;
signal_stats_t s_signal;
double mbps;
int buf_all;
int buf_used;
int buf_dirty;
int buf_cached;
} stream_stats_t;
typedef int (*hook_stream_decoder_open_t)(void**, int *);
typedef void (*hook_stream_decoder_t)(void*, unsigned char **, int *, const unsigned char *, int);
typedef void (*hook_stream_decoder_stats_t)(void*, decoder_stats_t*);
typedef void (*hook_stream_decoder_close_t)(void*);
typedef struct {
hook_stream_decoder_open_t open_handler;
hook_stream_decoder_t handler;
hook_stream_decoder_stats_t stats_handler;
hook_stream_decoder_close_t close_handler;
} hooks_stream_decoder_t;
typedef enum {
MSG_NONE = 0,
MSG_WARNING = 1,
MSG_ERROR = 2,
MSG_SYSERROR = 3,
MSG_WINSOCKERROR = 4,
MSG_NOTIFY = 5,
MSG_DISP = 6,
MSG_PACKETERROR = 7,
MSG_DEBUG = 8,
} message_type_t;
#ifdef TSD_PLATFORM_MSVC
typedef DWORD tsd_syserr_t;
#else
typedef int tsd_syserr_t;
#endif
typedef void (*hook_message_t)(const TSDCHAR*, message_type_t, tsd_syserr_t*, const TSDCHAR*);
typedef void (*hook_path_resolver_t)(const proginfo_t*, const ch_info_t*, TSDCHAR*);
//typedef void(*hook_stream_splitter)();
#define output_message(type, ...) _output_message( __FILE__ , type, __VA_ARGS__ )
#define TSD_API_DEF(type, name, args) type (* name) args
#define __TSD_MODULES_HOOKS2
typedef struct {
#include "core/module_api.h"
} tsd_api_set_t;
#undef __TSD_MODULES_HOOKS2
#undef TSD_API_DEF
#ifdef IN_SHARED_MODULE
#ifdef TSD_PLATFORM_MSVC
#ifdef __cplusplus
#define MODULE_DEF extern "C" __declspec(dllexport)
#else
#define MODULE_DEF __declspec(dllexport)
#endif
#else
#ifdef __cplusplus
#define MODULE_DEF extern "C"
#else
#define MODULE_DEF
#endif
#endif
#ifdef IS_SHARED_MODULE
#define TSD_API_DEF(type, name, args) type (*name) args
#else
#define TSD_API_DEF(type, name, args) extern type (*name) args
#endif
#else /* IN_SHARED_MODULE */
#ifdef __cplusplus
#define MODULE_DEF extern "C"
#define MODULE_API_FUNC extern "C"
#else
#define MODULE_DEF
#define MODULE_API_FUNC
#endif
#define TSD_API_DEF(type, name, args) MODULE_API_FUNC type name args
#endif /* IN_SHARED_MODULE */
#endif /* __TSD_MODULES_HOOKS */
TSD_API_DEF(void, _output_message, (const char *fname, message_type_t msgtype, const TSDCHAR *fmt, ...));
TSD_API_DEF(void, get_stream_stats, (const stream_stats_t **s));
TSD_API_DEF(void, request_shutdown, (int));
TSD_API_DEF(int, module_buffer_dropped, (const void*, int));
TSD_API_DEF(size_t, module_buffer_dropped_bytes, (const void*, int));
TSD_API_DEF(void, register_hook_pgoutput_precreate, (hook_pgoutput_precreate_t));
TSD_API_DEF(void, register_hook_pgoutput_changed, (hook_pgoutput_changed_t));
TSD_API_DEF(void, register_hook_pgoutput_end, (hook_pgoutput_end_t));
TSD_API_DEF(void, register_hook_pgoutput_postclose, (hook_pgoutput_postclose_t));
TSD_API_DEF(void, register_hook_pgoutput_create, (hook_pgoutput_create_t));
TSD_API_DEF(void, register_hook_pgoutput, (hook_pgoutput_t, int));
TSD_API_DEF(void, set_use_retval_pgoutput, ());
TSD_API_DEF(void, register_hook_pgoutput_check, (hook_pgoutput_check_t));
TSD_API_DEF(void, register_hook_pgoutput_close, (hook_pgoutput_close_t));
TSD_API_DEF(void, register_hook_pgoutput_forceclose, (hook_pgoutput_forceclose_t));
TSD_API_DEF(void, register_hook_postconfig, (hook_postconfig_t));
TSD_API_DEF(void, register_hook_preclose_module, (hook_preclose_module_t));
TSD_API_DEF(void, register_hook_close_module, (hook_close_module_t));
TSD_API_DEF(void, register_hook_open_stream, (hook_open_stream_t));
TSD_API_DEF(void, register_hook_encrypted_stream, (hook_encrypted_stream_t));
TSD_API_DEF(void, register_hook_stream, (hook_stream_t));
TSD_API_DEF(void, register_hook_close_stream, (hook_close_stream_t));
TSD_API_DEF(int, register_hooks_stream_generator, (hooks_stream_generator_t*));
TSD_API_DEF(int, register_hooks_stream_decoder, (hooks_stream_decoder_t*));
TSD_API_DEF(void, register_hook_message, (hook_message_t));
TSD_API_DEF(int, register_hook_path_resolver, (hook_path_resolver_t));
TSD_API_DEF(void, register_hook_tick, (hook_tick_t));
#ifndef __TSD_MODULES_HOOKS2
#define __TSD_MODULES_HOOKS2
#ifdef IN_SHARED_MODULE
#ifdef IS_SHARED_MODULE
#undef TSD_API_DEF
#define TSD_API_DEF(type, name, args) name = set->name
static void __tsd_api_init(void *p)
{
tsd_api_set_t *set = (tsd_api_set_t*)p;
#include "core/module_api.h"
}
#endif
#else /* IN_SHARED_MODULE */
#define __tsd_api_init NULL
#ifdef TSD_MODULES_HOOKS_API_SET
#undef TSD_API_DEF
#define TSD_API_DEF(type, name, args) set->name = name
static void tsd_api_init_set(void *p)
{
tsd_api_set_t *set =(tsd_api_set_t*)p;
#include "core/module_api.h"
}
#endif
#endif
#define TSD_MODULE_DEF(name, reg_hooks, cmds, init_handler) \
MODULE_DEF module_def_t name = { \
TSDUMP_MODULE_API_VER, \
TSD_TEXT(#name), \
reg_hooks, \
cmds, \
init_handler, \
__tsd_api_init \
}
#endif /* __TSD_MODULES_HOOKS2 */