mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
app: Generate GLib enums with glib-mkenums
This commit is contained in:
parent
e05127a510
commit
b56dcb3e20
5 changed files with 91 additions and 31 deletions
|
@ -2,11 +2,18 @@ lib_LTLIBRARIES = libgstapp-@GST_API_VERSION@.la
|
|||
|
||||
glib_enum_define = GST_APP
|
||||
glib_gen_prefix = __gst_app
|
||||
glib_gen_basename = gstapp
|
||||
glib_gen_basename = app
|
||||
|
||||
glib_enum_headers = gstappsrc.h
|
||||
|
||||
built_sources = app-enumtypes.c
|
||||
built_headers = app-enumtypes.h
|
||||
BUILT_SOURCES = $(built_sources) $(built_headers)
|
||||
|
||||
include $(top_srcdir)/common/gst-glib-gen.mak
|
||||
|
||||
libgstapp_@GST_API_VERSION@_la_SOURCES = gstappsrc.c gstappsink.c
|
||||
libgstapp_@GST_API_VERSION@_la_SOURCES = gstappsrc.c gstappsink.c
|
||||
nodist_libgstapp_@GST_API_VERSION@_la_SOURCES = $(BUILT_SOURCES)
|
||||
libgstapp_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) \
|
||||
$(GST_BASE_CFLAGS) $(GST_CFLAGS)
|
||||
libgstapp_@GST_API_VERSION@_la_LIBADD = $(GST_BASE_LIBS)
|
||||
|
@ -17,6 +24,9 @@ libgstapp_@GST_API_VERSION@include_HEADERS = \
|
|||
app.h \
|
||||
gstappsrc.h \
|
||||
gstappsink.h
|
||||
nodist_libgstapp_@GST_API_VERSION@include_HEADERS = app-enumtypes.h
|
||||
|
||||
CLEANFILES = $(BUILT_SOURCES)
|
||||
|
||||
if HAVE_INTROSPECTION
|
||||
BUILT_GIRSOURCES = GstApp-@GST_API_VERSION@.gir
|
||||
|
@ -69,5 +79,5 @@ typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)
|
|||
--includedir=`PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" $(PKG_CONFIG) --variable=girdir gstreamer-base-@GST_API_VERSION@` \
|
||||
$(INTROSPECTION_COMPILER_OPTS) $< -o $(@F)
|
||||
|
||||
CLEANFILES = $(BUILT_GIRSOURCES) $(typelibs_DATA)
|
||||
CLEANFILES += $(BUILT_GIRSOURCES) $(typelibs_DATA)
|
||||
endif
|
||||
|
|
55
gst-libs/gst/app/app_mkenum.py
Executable file
55
gst-libs/gst/app/app_mkenum.py
Executable file
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# This is in its own file rather than inside meson.build
|
||||
# because a) mixing the two is ugly and b) trying to
|
||||
# make special characters such as \n go through all
|
||||
# backends is a fool's errand.
|
||||
|
||||
import sys, os, shutil, subprocess
|
||||
|
||||
h_array = ['--fhead',
|
||||
"#ifndef __GST_APP_ENUM_TYPES_H__\n#define __GST_APP_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n",
|
||||
'--fprod',
|
||||
"\n/* enumerations from \"@filename@\" */\n",
|
||||
'--vhead',
|
||||
'GType @enum_name@_get_type (void);\n#define GST_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n',
|
||||
'--ftail',
|
||||
'G_END_DECLS\n\n#endif /* __GST_APP_ENUM_TYPES_H__ */',
|
||||
]
|
||||
|
||||
c_array = ['--fhead',
|
||||
"#include \"app-enumtypes.h\"\n\n#include \"app.h\" \n#include \"gstappsrc.h\"",
|
||||
'--fprod',
|
||||
"\n/* enumerations from \"@filename@\" */",
|
||||
'--vhead',
|
||||
"GType\n@enum_name@_get_type (void)\n{\n static volatile gsize g_define_type_id__volatile = 0;\n if (g_once_init_enter (&g_define_type_id__volatile)) {\n static const G@Type@Value values[] = {",
|
||||
'--vprod',
|
||||
" { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" },",
|
||||
'--vtail',
|
||||
" { 0, NULL, NULL }\n };\n GType g_define_type_id = g_@type@_register_static (\"@EnumName@\", values);\n g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);\n }\n return g_define_type_id__volatile;\n}\n",
|
||||
]
|
||||
|
||||
cmd = []
|
||||
argn = 1
|
||||
# Find the full command needed to run glib-mkenums
|
||||
# On UNIX-like, this is just the full path to glib-mkenums
|
||||
# On Windows, this is the full path to interpreter + full path to glib-mkenums
|
||||
for arg in sys.argv[1:]:
|
||||
cmd.append(arg)
|
||||
argn += 1
|
||||
if arg.endswith('glib-mkenums'):
|
||||
break
|
||||
ofilename = sys.argv[argn]
|
||||
headers = sys.argv[argn + 1:]
|
||||
|
||||
if ofilename.endswith('.h'):
|
||||
arg_array = h_array
|
||||
else:
|
||||
arg_array = c_array
|
||||
|
||||
cmd_array = cmd + arg_array + headers
|
||||
pc = subprocess.Popen(cmd_array, stdout=subprocess.PIPE)
|
||||
(stdo, _) = pc.communicate()
|
||||
if pc.returncode != 0:
|
||||
sys.exit(pc.returncode)
|
||||
open(ofilename, 'wb').write(stdo)
|
|
@ -191,26 +191,6 @@ GST_STATIC_PAD_TEMPLATE ("src",
|
|||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS_ANY);
|
||||
|
||||
GType
|
||||
gst_app_stream_type_get_type (void)
|
||||
{
|
||||
static volatile gsize stream_type_type = 0;
|
||||
static const GEnumValue stream_type[] = {
|
||||
{GST_APP_STREAM_TYPE_STREAM, "GST_APP_STREAM_TYPE_STREAM", "stream"},
|
||||
{GST_APP_STREAM_TYPE_SEEKABLE, "GST_APP_STREAM_TYPE_SEEKABLE", "seekable"},
|
||||
{GST_APP_STREAM_TYPE_RANDOM_ACCESS, "GST_APP_STREAM_TYPE_RANDOM_ACCESS",
|
||||
"random-access"},
|
||||
{0, NULL, NULL}
|
||||
};
|
||||
|
||||
if (g_once_init_enter (&stream_type_type)) {
|
||||
GType tmp = g_enum_register_static ("GstAppStreamType", stream_type);
|
||||
g_once_init_leave (&stream_type_type, tmp);
|
||||
}
|
||||
|
||||
return (GType) stream_type_type;
|
||||
}
|
||||
|
||||
static void gst_app_src_uri_handler_init (gpointer g_iface,
|
||||
gpointer iface_data);
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/base/gstpushsrc.h>
|
||||
#include <gst/app/app-enumtypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -117,10 +118,6 @@ struct _GstAppSrcClass
|
|||
|
||||
GType gst_app_src_get_type(void);
|
||||
|
||||
/* GType getter for GstAppStreamType */
|
||||
#define GST_TYPE_APP_STREAM_TYPE (gst_app_stream_type_get_type ())
|
||||
GType gst_app_stream_type_get_type (void);
|
||||
|
||||
void gst_app_src_set_caps (GstAppSrc *appsrc, const GstCaps *caps);
|
||||
GstCaps* gst_app_src_get_caps (GstAppSrc *appsrc);
|
||||
|
||||
|
|
|
@ -1,10 +1,29 @@
|
|||
app_sources = ['gstappsrc.c', 'gstappsink.c']
|
||||
|
||||
app_headers = [ 'app.h', 'gstappsrc.h', 'gstappsink.h' ]
|
||||
app_mkenum_headers = [
|
||||
'gstappsrc.h',
|
||||
]
|
||||
|
||||
app_headers = app_mkenum_headers + [ 'app.h', 'gstappsrc.h' ]
|
||||
install_headers(app_headers, subdir : 'gstreamer-1.0/gst/app/')
|
||||
|
||||
mkenums = find_program('app_mkenum.py')
|
||||
gstapp_h = custom_target('gstappenum_h',
|
||||
output : 'app-enumtypes.h',
|
||||
input : app_mkenum_headers,
|
||||
install : true,
|
||||
install_dir : 'include/gstreamer-1.0/gst/app/',
|
||||
command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
|
||||
|
||||
gstapp_c = custom_target('gstappenum_c',
|
||||
output : 'app-enumtypes.c',
|
||||
input : app_mkenum_headers,
|
||||
depends : [gstapp_h],
|
||||
command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
|
||||
app_gen_sources = [gstapp_h]
|
||||
|
||||
gstapp = library('gstapp-@0@'.format(api_version),
|
||||
app_sources,
|
||||
app_sources, gstapp_h, gstapp_c,
|
||||
c_args : gst_plugins_base_args,
|
||||
include_directories: [configinc, libsinc],
|
||||
version : libversion,
|
||||
|
@ -14,10 +33,9 @@ gstapp = library('gstapp-@0@'.format(api_version),
|
|||
vs_module_defs: vs_module_defs_dir + 'libgstapp.def',
|
||||
)
|
||||
|
||||
app_gen_sources = []
|
||||
if build_gir
|
||||
app_gen_sources += [gnome.generate_gir(gstapp,
|
||||
sources : app_sources + app_headers,
|
||||
sources : app_sources + app_headers + [gstapp_c] + [gstapp_h],
|
||||
namespace : 'GstApp',
|
||||
nsversion : api_version,
|
||||
identifier_prefix : 'Gst',
|
||||
|
|
Loading…
Reference in a new issue