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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <dlfcn.h>
#include "wrappedlibs.h"
#include "debug.h"
#include "wrapper.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "x64emu.h"
#include "emu/x64emu_private.h"
#include "callback.h"
#include "librarian.h"
#include "box64context.h"
#include "emu/x64emu_private.h"
#include "myalign.h"
const char* gstreamerName = "libgstreamer-1.0.so.0";
#define LIBNAME gstreamer
#define ADDED_FUNCTIONS() \
#include "generated/wrappedgstreamertypes.h"
#include "wrappercallback.h"
#define SUPER() \
GO(0) \
GO(1) \
GO(2) \
GO(3) \
// GDestroyFunc ...
#define GO(A) \
static uintptr_t my_destroyfunc_fct_##A = 0; \
static int my_destroyfunc_##A(void* a, void* b) \
{ \
return RunFunction(my_context, my_destroyfunc_fct_##A, 2, a, b);\
}
SUPER()
#undef GO
static void* findDestroyFct(void* fct)
{
if(!fct) return fct;
void* p;
if((p = GetNativeFnc((uintptr_t)fct))) return p;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_destroyfunc_fct_##A == (uintptr_t)fct) return my_destroyfunc_##A;
SUPER()
#undef GO
#define GO(A) if(my_destroyfunc_fct_##A == 0) {my_destroyfunc_fct_##A = (uintptr_t)fct; return my_destroyfunc_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for gstreamer GDestroyNotify callback\n");
return NULL;
}
//GstPadActivateModeFunction
#define GO(A) \
static uintptr_t my_GstPadActivateModeFunction_fct_##A = 0; \
static int my_GstPadActivateModeFunction_##A(void* a, void* b, int c, int d) \
{ \
return (int)RunFunction(my_context, my_GstPadActivateModeFunction_fct_##A, 4, a, b, c, d); \
}
SUPER()
#undef GO
static void* findGstPadActivateModeFunctionFct(void* fct)
{
if(!fct) return fct;
void* p;
if((p = GetNativeFnc((uintptr_t)fct))) return p;
#define GO(A) if(my_GstPadActivateModeFunction_fct_##A == (uintptr_t)fct) return my_GstPadActivateModeFunction_##A;
SUPER()
#undef GO
#define GO(A) if(my_GstPadActivateModeFunction_fct_##A == 0) {my_GstPadActivateModeFunction_fct_##A = (uintptr_t)fct; return my_GstPadActivateModeFunction_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for gstreamer GstPadActivateModeFunction callback\n");
return NULL;
}
//GstPadQueryFunction
#define GO(A) \
static uintptr_t my_GstPadQueryFunction_fct_##A = 0; \
static int my_GstPadQueryFunction_##A(void* a, void* b, void* c) \
{ \
return (int)RunFunction(my_context, my_GstPadQueryFunction_fct_##A, 3, a, b, c); \
}
SUPER()
#undef GO
static void* findGstPadQueryFunctionFct(void* fct)
{
if(!fct) return fct;
void* p;
if((p = GetNativeFnc((uintptr_t)fct))) return p;
#define GO(A) if(my_GstPadQueryFunction_fct_##A == (uintptr_t)fct) return my_GstPadQueryFunction_##A;
SUPER()
#undef GO
#define GO(A) if(my_GstPadQueryFunction_fct_##A == 0) {my_GstPadQueryFunction_fct_##A = (uintptr_t)fct; return my_GstPadQueryFunction_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for gstreamer GstPadQueryFunction callback\n");
return NULL;
}
//GstPadGetRangeFunction
#define GO(A) \
static uintptr_t my_GstPadGetRangeFunction_fct_##A = 0; \
static int my_GstPadGetRangeFunction_##A(void* a, void* b, uint64_t c, uint32_t d, void* e) \
{ \
return (int)RunFunction(my_context, my_GstPadGetRangeFunction_fct_##A, 5, a, b, c, d, e); \
}
SUPER()
#undef GO
static void* findGstPadGetRangeFunctionFct(void* fct)
{
if(!fct) return fct;
void* p;
if((p = GetNativeFnc((uintptr_t)fct))) return p;
#define GO(A) if(my_GstPadGetRangeFunction_fct_##A == (uintptr_t)fct) return my_GstPadGetRangeFunction_##A;
SUPER()
#undef GO
#define GO(A) if(my_GstPadGetRangeFunction_fct_##A == 0) {my_GstPadGetRangeFunction_fct_##A = (uintptr_t)fct; return my_GstPadGetRangeFunction_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for gstreamer GstPadGetRangeFunction callback\n");
return NULL;
}
//GstPadChainFunction
#define GO(A) \
static uintptr_t my_GstPadChainFunction_fct_##A = 0; \
static int my_GstPadChainFunction_##A(void* a, void* b, void* c) \
{ \
return (int)RunFunction(my_context, my_GstPadChainFunction_fct_##A, 3, a, b, c); \
}
SUPER()
#undef GO
static void* findGstPadChainFunctionFct(void* fct)
{
if(!fct) return fct;
void* p;
if((p = GetNativeFnc((uintptr_t)fct))) return p;
#define GO(A) if(my_GstPadChainFunction_fct_##A == (uintptr_t)fct) return my_GstPadChainFunction_##A;
SUPER()
#undef GO
#define GO(A) if(my_GstPadChainFunction_fct_##A == 0) {my_GstPadChainFunction_fct_##A = (uintptr_t)fct; return my_GstPadChainFunction_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for gstreamer GstPadChainFunction callback\n");
return NULL;
}
//GstPadEventFunction
#define GO(A) \
static uintptr_t my_GstPadEventFunction_fct_##A = 0; \
static int my_GstPadEventFunction_##A(void* a, void* b, void* c) \
{ \
return (int)RunFunction(my_context, my_GstPadEventFunction_fct_##A, 3, a, b, c); \
}
SUPER()
#undef GO
static void* findGstPadEventFunctionFct(void* fct)
{
if(!fct) return fct;
#define GO(A) if(my_GstPadEventFunction_fct_##A == (uintptr_t)fct) return my_GstPadEventFunction_##A;
SUPER()
#undef GO
#define GO(A) if(my_GstPadEventFunction_fct_##A == 0) {my_GstPadEventFunction_fct_##A = (uintptr_t)fct; return my_GstPadEventFunction_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for gstreamer GstPadEventFunction callback\n");
return NULL;
}
//GstBusSyncHandler
#define GO(A) \
static uintptr_t my_GstBusSyncHandler_fct_##A = 0; \
static int my_GstBusSyncHandler_##A(void* a, void* b, void* c) \
{ \
return (int)RunFunction(my_context, my_GstBusSyncHandler_fct_##A, 3, a, b, c); \
}
SUPER()
#undef GO
static void* findGstBusSyncHandlerFct(void* fct)
{
if(!fct) return fct;
#define GO(A) if(my_GstBusSyncHandler_fct_##A == (uintptr_t)fct) return my_GstBusSyncHandler_##A;
SUPER()
#undef GO
#define GO(A) if(my_GstBusSyncHandler_fct_##A == 0) {my_GstBusSyncHandler_fct_##A = (uintptr_t)fct; return my_GstBusSyncHandler_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for gstreamer GstBusSyncHandler callback\n");
return NULL;
}
#undef SUPER
EXPORT void my_gst_caps_set_simple(x64emu_t* emu, void* caps, void* field, void* b) {
CREATE_VALIST_FROM_VAARG(b, emu->scratch, 2);
my->gst_caps_set_simple_valist(caps, field, VARARGS);
}
EXPORT void my_gst_caps_set_simple_valist(x64emu_t* emu, void* caps, void* field, x64_va_list_t V) {
#ifdef CONVERT_VALIST
CONVERT_VALIST(V);
#else
CREATE_VALIST_FROM_VALIST(V, emu->scratch);
#endif
my->gst_caps_set_simple_valist(caps, field, VARARGS);
}
EXPORT void my_gst_structure_remove_fields(x64emu_t* emu, void* structure, void* field, void* b) {
CREATE_VALIST_FROM_VAARG(b, emu->scratch, 2);
my->gst_structure_remove_fields_valist(structure, field, VARARGS);
}
EXPORT void my_gst_structure_remove_fields_valist(x64emu_t* emu, void* structure, void* field, x64_va_list_t V) {
#ifdef CONVERT_VALIST
CONVERT_VALIST(V);
#else
CREATE_VALIST_FROM_VALIST(V, emu->scratch);
#endif
my->gst_structure_remove_fields_valist(structure, field, VARARGS);
}
EXPORT void my_gst_debug_log(x64emu_t* emu, void* cat, int level, void* file, void* func, int line, void* obj, void* fmt, void* b) {
myStackAlign(emu, (const char*)fmt, b, emu->scratch, R_EAX, 7);
PREPARE_VALIST;
my->gst_debug_log_valist(cat, level, file, func, line, obj, fmt, VARARGS);
}
EXPORT void my_gst_debug_log_valist(x64emu_t* emu, void* cat, int level, void* file, void* func, int line, void* obj, void* fmt, x64_va_list_t V) {
#ifdef CONVERT_VALIST
CONVERT_VALIST(V);
#else
myStackAlignValist(emu, (const char*)fmt, emu->scratch, V);
PREPARE_VALIST;
#endif
my->gst_debug_log_valist(cat, level, file, func, line, obj, fmt, VARARGS);
}
EXPORT int my_gst_structure_get(x64emu_t* emu, void* structure, void* field, void* b) {
CREATE_VALIST_FROM_VAARG(b, emu->scratch, 2);
return my->gst_structure_get_valist(structure, field, VARARGS);
}
EXPORT int my_gst_structure_get_valist(x64emu_t* emu, void* structure, void* field, x64_va_list_t V) {
#ifdef CONVERT_VALIST
CONVERT_VALIST(V);
#else
CREATE_VALIST_FROM_VALIST(V, emu->scratch);
#endif
return my->gst_structure_get_valist(structure, field, VARARGS);
}
EXPORT void my_gst_pad_set_activatemode_function_full(x64emu_t* emu, void* pad, void* f, void* data, void* d)
{
my->gst_pad_set_activatemode_function_full(pad, findGstPadActivateModeFunctionFct(f), data, findDestroyFct(d));
}
EXPORT void my_gst_pad_set_query_function_full(x64emu_t* emu, void* pad, void* f, void* data, void* d)
{
my->gst_pad_set_query_function_full(pad, findGstPadQueryFunctionFct(f), data, findDestroyFct(d));
}
EXPORT void my_gst_pad_set_getrange_function_full(x64emu_t* emu, void* pad, void* f, void* data, void* d)
{
my->gst_pad_set_getrange_function_full(pad, findGstPadGetRangeFunctionFct(f), data, findDestroyFct(d));
}
EXPORT void my_gst_pad_set_chain_function_full(x64emu_t* emu, void* pad, void* f, void* data, void* d)
{
my->gst_pad_set_chain_function_full(pad, findGstPadChainFunctionFct(f), data, findDestroyFct(d));
}
EXPORT void my_gst_pad_set_event_function_full(x64emu_t* emu, void* pad, void* f, void* data, void* d)
{
my->gst_pad_set_event_function_full(pad, findGstPadEventFunctionFct(f), data, findDestroyFct(d));
}
EXPORT void my_gst_bus_set_sync_handler(x64emu_t* emu, void* bus, void* f, void* data, void* d)
{
my->gst_bus_set_sync_handler(bus, findGstBusSyncHandlerFct(f), data, findDestroyFct(d));
}
#define PRE_INIT \
if(box64_nogtk) \
return -1;
#define CUSTOM_INIT \
getMy(lib);
#define CUSTOM_FINI \
freeMy();
#include "wrappedlib_init.h"
|