about summary refs log tree commit diff stats
path: root/src/wrapped/wrappedgstbase.c
blob: 3d143af78f3c87ecbce5dc3ff2fa70d77d3ef621 (plain) (blame)
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
#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"
#include "gtkclass.h"
#include "fileutils.h"

const char* gstbaseName = "libgstbase-1.0.so.0";
#define ALTNAME "libgstbase-1.0.so"

#define LIBNAME gstbase

typedef size_t  (*LFv_t)();

#define ADDED_FUNCTIONS()                   \
    GO(gst_base_transform_get_type, LFv_t)  \
    GO(gst_base_sink_get_type, LFv_t)       \
    GO(gst_aggregator_get_type, LFv_t)      \
    GO(gst_push_src_get_type, LFv_t)        \
    GO(gst_base_src_get_type, LFv_t)        \
    GO(gst_aggregator_pad_get_type, LFv_t)  \

#include "generated/wrappedgstbasetypes.h"

#include "wrappercallback.h"

#define SUPER() \
GO(0)   \
GO(1)   \
GO(2)   \
GO(3)

// GstCollectPadsFunction ...
#define GO(A)   \
static uintptr_t my_GstCollectPadsFunction_fct_##A = 0;                     \
static int my_GstCollectPadsFunction_##A(void* a, void* b)                  \
{                                                                           \
    return RunFunctionFmt(my_GstCollectPadsFunction_fct_##A, "pp", a, b);   \
}
SUPER()
#undef GO
static void* findGstCollectPadsFunctionFct(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_GstCollectPadsFunction_fct_##A == (uintptr_t)fct) return my_GstCollectPadsFunction_##A;
    SUPER()
    #undef GO
    #define GO(A) if(my_GstCollectPadsFunction_fct_##A == 0) {my_GstCollectPadsFunction_fct_##A = (uintptr_t)fct; return my_GstCollectPadsFunction_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for gstbase GstCollectPadsFunction callback\n");
    return NULL;
}
// GstCollectDataDestroyNotify ...
#define GO(A)   \
static uintptr_t my_GstCollectDataDestroyNotify_fct_##A = 0;        \
static void my_GstCollectDataDestroyNotify_##A(void* a)             \
{                                                                   \
    RunFunctionFmt(my_GstCollectDataDestroyNotify_fct_##A, "p", a); \
}
SUPER()
#undef GO
static void* findGstCollectDataDestroyNotifyFct(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_GstCollectDataDestroyNotify_fct_##A == (uintptr_t)fct) return my_GstCollectDataDestroyNotify_##A;
    SUPER()
    #undef GO
    #define GO(A) if(my_GstCollectDataDestroyNotify_fct_##A == 0) {my_GstCollectDataDestroyNotify_fct_##A = (uintptr_t)fct; return my_GstCollectDataDestroyNotify_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for gstbase GstCollectDataDestroyNotify callback\n");
    return NULL;
}
// GstCollectPadsEventFunction ...
#define GO(A)   \
static uintptr_t my_GstCollectPadsEventFunction_fct_##A = 0;                            \
static int my_GstCollectPadsEventFunction_##A(void* a, void* b, void* c, void* d)       \
{                                                                                       \
    return RunFunctionFmt(my_GstCollectPadsEventFunction_fct_##A, "pppp", a, b, c, d);  \
}
SUPER()
#undef GO
static void* findGstCollectPadsEventFunctionFct(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_GstCollectPadsEventFunction_fct_##A == (uintptr_t)fct) return my_GstCollectPadsEventFunction_##A;
    SUPER()
    #undef GO
    #define GO(A) if(my_GstCollectPadsEventFunction_fct_##A == 0) {my_GstCollectPadsEventFunction_fct_##A = (uintptr_t)fct; return my_GstCollectPadsEventFunction_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for gstbase GstCollectPadsEventFunction callback\n");
    return NULL;
}
// GstCollectPadsQueryFunction ...
#define GO(A)   \
static uintptr_t my_GstCollectPadsQueryFunction_fct_##A = 0;                            \
static int my_GstCollectPadsQueryFunction_##A(void* a, void* b, void* c, void* d)       \
{                                                                                       \
    return RunFunctionFmt(my_GstCollectPadsQueryFunction_fct_##A, "pppp", a, b, c, d);  \
}
SUPER()
#undef GO
static void* findGstCollectPadsQueryFunctionFct(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_GstCollectPadsQueryFunction_fct_##A == (uintptr_t)fct) return my_GstCollectPadsQueryFunction_##A;
    SUPER()
    #undef GO
    #define GO(A) if(my_GstCollectPadsQueryFunction_fct_##A == 0) {my_GstCollectPadsQueryFunction_fct_##A = (uintptr_t)fct; return my_GstCollectPadsQueryFunction_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for gstbase GstCollectPadsQueryFunction callback\n");
    return NULL;
}
// GstCollectPadsClipFunction ...
#define GO(A)   \
static uintptr_t my_GstCollectPadsClipFunction_fct_##A = 0;                                 \
static int my_GstCollectPadsClipFunction_##A(void* a, void* b, void* c, void* d, void* e)   \
{                                                                                           \
    return RunFunctionFmt(my_GstCollectPadsClipFunction_fct_##A, "ppppp", a, b, c, d, e);   \
}
SUPER()
#undef GO
static void* findGstCollectPadsClipFunctionFct(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_GstCollectPadsClipFunction_fct_##A == (uintptr_t)fct) return my_GstCollectPadsClipFunction_##A;
    SUPER()
    #undef GO
    #define GO(A) if(my_GstCollectPadsClipFunction_fct_##A == 0) {my_GstCollectPadsClipFunction_fct_##A = (uintptr_t)fct; return my_GstCollectPadsClipFunction_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for gstbase GstCollectPadsClipFunction callback\n");
    return NULL;
}
// GstCollectPadsBufferFunction ...
#define GO(A)   \
static uintptr_t my_GstCollectPadsBufferFunction_fct_##A = 0;                           \
static int my_GstCollectPadsBufferFunction_##A(void* a, void* b, void* c, void* d)      \
{                                                                                       \
    return RunFunctionFmt(my_GstCollectPadsBufferFunction_fct_##A, "pppp", a, b, c, d); \
}
SUPER()
#undef GO
static void* findGstCollectPadsBufferFunctionFct(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_GstCollectPadsBufferFunction_fct_##A == (uintptr_t)fct) return my_GstCollectPadsBufferFunction_##A;
    SUPER()
    #undef GO
    #define GO(A) if(my_GstCollectPadsBufferFunction_fct_##A == 0) {my_GstCollectPadsBufferFunction_fct_##A = (uintptr_t)fct; return my_GstCollectPadsBufferFunction_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for gstbase GstCollectPadsBufferFunction callback\n");
    return NULL;
}

#undef SUPER

EXPORT void my_gst_collect_pads_set_function(x64emu_t* emu, void* p, void* f, void* data)
{
    my->gst_collect_pads_set_function(p, findGstCollectPadsFunctionFct(f), data);
}

EXPORT void* my_gst_collect_pads_add_pad(x64emu_t* emu, void* pads, void* pad, uint32_t size, void* d, int lock)
{
    return my->gst_collect_pads_add_pad(pads, pad, size, findGstCollectDataDestroyNotifyFct(d), lock);
}

EXPORT void my_gst_collect_pads_set_event_function(x64emu_t* emu, void* pads, void* f, void* data)
{
    my->gst_collect_pads_set_event_function(pads, findGstCollectPadsEventFunctionFct(f), data);
}

EXPORT void my_gst_collect_pads_set_query_function(x64emu_t* emu, void* pads, void* f, void* data)
{
    my->gst_collect_pads_set_query_function(pads, findGstCollectPadsQueryFunctionFct(f), data);
}

EXPORT void my_gst_collect_pads_set_clip_function(x64emu_t* emu, void* pads, void* f, void* data)
{
    my->gst_collect_pads_set_clip_function(pads, findGstCollectPadsClipFunctionFct(f), data);
}

EXPORT void my_gst_collect_pads_set_buffer_function(x64emu_t* emu, void* pads, void* f, void* data)
{
    my->gst_collect_pads_set_buffer_function(pads, findGstCollectPadsBufferFunctionFct(f), data);
}

#define PRE_INIT    \
    if(BOX64ENV(nogtk)) \
        return -1;

#define CUSTOM_INIT \
    SetGstBaseTransformID(my->gst_base_transform_get_type());\
    SetGstBaseSinkID(my->gst_base_sink_get_type());\
    SetGstAggregatorID(my->gst_aggregator_get_type());\
    SetGstPushSrcID(my->gst_push_src_get_type());\
    SetGstBaseSrcID(my->gst_base_src_get_type());\
    SetGstAggregatorPadID(my->gst_aggregator_pad_get_type());

#define NEEDED_LIBS "libgstreamer-1.0.so.0"

#include "wrappedlib_init.h"