-
-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathGlibAPI.java
230 lines (201 loc) · 7.79 KB
/
GlibAPI.java
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
/*
* Copyright (c) 2009 Levente Farkas
* Copyright (c) 2007 Wayne Meissner
*
* This file is part of gstreamer-java.
*
* This code is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
*/
package org.freedesktop.gstreamer.lowlevel;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import com.sun.jna.ptr.IntByReference;
import org.freedesktop.gstreamer.lowlevel.annotations.CallerOwnsReturn;
import com.sun.jna.Callback;
import com.sun.jna.Library;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.PointerByReference;
import org.freedesktop.gstreamer.glib.GMainContext;
import org.freedesktop.gstreamer.glib.GSource;
/**
*
*/
@SuppressWarnings("serial")
public interface GlibAPI extends Library {
GlibAPI GLIB_API = GNative.loadLibrary("glib-2.0", GlibAPI.class,
new HashMap<String, Object>() {{
put(Library.OPTION_TYPE_MAPPER, new GTypeMapper());
}});
public static final int GLIB_SYSDEF_AF_UNIX = 1;
public static final int GLIB_SYSDEF_AF_INET = 2;
public static final int GLIB_SYSDEF_AF_INET6 = 23;
Pointer g_main_loop_new(GMainContext context, boolean running);
void g_main_loop_run(MainLoop loop);
boolean g_main_loop_is_running(MainLoop loop);
@CallerOwnsReturn GMainContext g_main_loop_get_context(MainLoop loop);
void g_main_loop_quit(MainLoop loop);
void g_main_loop_ref(GPointer ptr);
void g_main_loop_unref(GPointer ptr);
/*
* GMainContext functions
*/
Pointer g_main_context_new();
void g_main_context_ref(GPointer context);
void g_main_context_unref(GPointer context);
Pointer g_main_context_default();
boolean g_main_context_pending(GMainContext ctx);
boolean g_main_context_acquire(GMainContext ctx);
void g_main_context_release(GMainContext ctx);
boolean g_main_context_is_owner(GMainContext ctx);
boolean g_main_context_wait(GMainContext ctx);
@CallerOwnsReturn GSource g_idle_source_new();
@CallerOwnsReturn GSource g_timeout_source_new(int interval);
@CallerOwnsReturn GSource g_timeout_source_new_seconds(int interval);
int g_source_attach(GSource source, GMainContext context);
void g_source_destroy(Pointer source);
void g_source_destroy(GSource source);
Pointer g_source_ref(Pointer source);
void g_source_unref(Pointer source);
void g_source_set_callback(GSource source, GSourceFunc callback, Object data, GDestroyNotify destroy);
boolean g_source_is_destroyed(Pointer source);
boolean g_source_is_destroyed(GSource source);
/*
* GThread functions
*/
interface GThreadFunc extends Callback {
Pointer callback(Pointer data);
}
Pointer g_thread_create(GThreadFunc func, Pointer data, boolean joinable, PointerByReference error);
Pointer g_thread_self();
Pointer g_thread_join(Pointer thread);
void g_thread_yield();
void g_thread_set_priority(Pointer thread, int priority);
void g_thread_exit(Pointer retval);
interface GSourceFunc extends Callback {
boolean callback(Pointer data);
}
NativeLong g_idle_add(GSourceFunc function, Pointer data);
interface GDestroyNotify extends Callback {
void callback(Pointer data);
}
int g_timeout_add(int interval, GSourceFunc function, Pointer data);
int g_timeout_add_full(int priority, int interval, GSourceFunc function,
Pointer data, GDestroyNotify notify);
int g_timeout_add_seconds(int interval, GSourceFunc function, Pointer data);
GstAPI.GErrorStruct g_error_new(int quark, int code, String message);
void g_error_free(Pointer error);
void g_error_free(GstAPI.GErrorStruct error);
void g_source_remove(int id);
void g_free(Pointer ptr);
// GType g_date_get_type();
Pointer g_date_new();
Pointer g_date_new_dmy(int day, int month, int year);
Pointer g_date_new_julian(int julian_day);
int g_date_get_year(Pointer date);
int g_date_get_month(Pointer date);
int g_date_get_day(Pointer date);
void g_date_free(Pointer date);
Pointer g_bytes_new(Pointer source, int size);
Pointer g_bytes_get_data(Pointer bytes, IntByReference size);
int g_bytes_get_size(Pointer bytes);
Pointer g_bytes_ref(Pointer bytes);
void g_bytes_unref(Pointer bytes);
GList g_list_append(GList list, Pointer data);
public static final class GList extends com.sun.jna.Structure {
public volatile Pointer data;
public volatile Pointer _next;
public volatile Pointer _prev;
public GList() {
clear();
}
public GList(Pointer ptr) {
useMemory(ptr);
read();
}
public static GList valueOf(Pointer ptr) {
return ptr != null ? new GList(ptr) : null;
}
public GList next() {
return valueOf(_next);
}
public GList prev() {
return valueOf(_prev);
}
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{
"data", "_next", "_prev"
});
}
}
public static final class GSList extends com.sun.jna.Structure {
public volatile Pointer data;
public volatile Pointer _next;
public GSList() {
clear();
}
public GSList(Pointer ptr) {
useMemory(ptr);
read();
}
public static GSList valueOf(Pointer ptr) {
return ptr != null ? new GSList(ptr) : null;
}
public GSList next() {
return valueOf(_next);
}
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{
"data", "_next"
});
}
}
/*
* Miscellaneous Utility Functions
*/
/**
* Returns the value of an environment variable.
*
* On UNIX, the name and value are byte strings which might or might not be
* in some consistent character set and encoding. On Windows, they are in UTF-8.
* On Windows, in case the environment variable's value contains references
* to other environment variables, they are expanded.
*
* @param variable the environment variable to get.
* @return the value of the environment variable, or NULL if the
* environment variable is not found.
*/
String g_getenv(String variable);
/**
* Sets an environment variable.
*
* On UNIX, both the variable's name and value can be arbitrary byte strings,
* except that the variable's name cannot contain '='.
* On Windows, they should be in UTF-8.
*
* @param variable the environment variable to set, must not contain '='.
* @param value the value for to set the variable to.
* @param overwrite whether to change the variable if it already exists.
* @return FALSE if the environment variable couldn't be set.
*/
boolean g_setenv(String variable, String value, boolean overwrite);
/**
* Removes an environment variable from the environment.
*
* @param variable the environment variable to remove, must not contain '='.
*/
void g_unsetenv(String variable);
}