transcoder: Automatically generate enums GTypes
authorThibault Saunier <tsaunier@igalia.com>
Thu, 26 Nov 2020 01:21:35 +0000 (22:21 -0300)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 26 Feb 2021 15:37:23 +0000 (15:37 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1840>

gst-libs/gst/transcoder/gsttranscoder.c
gst-libs/gst/transcoder/gsttranscoder.h
gst-libs/gst/transcoder/meson.build
gst-libs/gst/transcoder/transcoder-prelude.h

index 1083616a1cbacdfa9ab0bff984829e6d58f23519..ec704123784ea5b8d2a79fa679431389c26546c4 100644 (file)
@@ -1352,27 +1352,6 @@ gst_transcoder_set_avoid_reencoding (GstTranscoder * self,
   g_object_set (self->transcodebin, "avoid-reencoding", avoid_reencoding, NULL);
 }
 
-#define C_ENUM(v) ((gint) v)
-#define C_FLAGS(v) ((guint) v)
-
-GType
-gst_transcoder_error_get_type (void)
-{
-  static gsize id = 0;
-  static const GEnumValue values[] = {
-    {C_ENUM (GST_TRANSCODER_ERROR_FAILED), "GST_TRANSCODER_ERROR_FAILED",
-        "failed"},
-    {0, NULL, NULL}
-  };
-
-  if (g_once_init_enter (&id)) {
-    GType tmp = g_enum_register_static ("GstTranscoderError", values);
-    g_once_init_leave (&id, tmp);
-  }
-
-  return (GType) id;
-}
-
 /**
  * gst_transcoder_error_get_name:
  * @error: a #GstTranscoderError
index c7542a57d99fcc581fb144bdff63325d0cde5126..ccc3dd7fa4d096389df08443e29ec1a15e86985e 100644 (file)
@@ -8,6 +8,7 @@
 #include <gst/gst.h>
 #include <gst/pbutils/pbutils.h>
 #include "transcoder-prelude.h"
+#include "transcoder-enumtypes.h"
 
 G_BEGIN_DECLS
 
@@ -16,7 +17,6 @@ typedef struct _GstTranscoderSignalDispatcherInterface GstTranscoderSignalDispat
 
 /*********** Error definitions ************/
 #define      GST_TRANSCODER_ERROR                         (gst_transcoder_error_quark ())
-#define      GST_TYPE_TRANSCODER_ERROR                    (gst_transcoder_error_get_type ())
 
 /**
  * GstTranscoderError:
@@ -29,8 +29,6 @@ typedef enum {
 GST_TRANSCODER_API
 GQuark        gst_transcoder_error_quark    (void);
 GST_TRANSCODER_API
-GType         gst_transcoder_error_get_type (void);
-GST_TRANSCODER_API
 const gchar * gst_transcoder_error_get_name (GstTranscoderError error);
 
 /*********** GstTranscoder definition  ************/
index 67323a23fdb534789c40c43593dfe735efbae121..4381efa9e4cf963fdc228b66e3daa69f40657625 100644 (file)
@@ -3,8 +3,21 @@ headers = files(['gsttranscoder.h', 'transcoder-prelude.h'])
 
 install_headers(headers, subdir : 'gstreamer-' + api_version + '/gst/transcoder')
 
+transcoder_enums = gnome.mkenums_simple('transcoder-enumtypes',
+  sources : headers,
+  body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif',
+  header_prefix : '#include <gst/transcoder/transcoder-prelude.h>',
+  decorator: 'GST_TRANSCODER_API',
+  install_header: true,
+  install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/transcoder'))
+
+gsttranscoder_c = transcoder_enums[0]
+gsttranscoder_h = transcoder_enums[1]
+
+transcoder_gen_sources = [gsttranscoder_h]
+
 gst_transcoder = library('gsttranscoder-' + api_version,
-  sources,
+  sources + [gsttranscoder_c]  + transcoder_gen_sources,
   install: true,
   include_directories : [configinc, libsinc],
   dependencies: [gst_dep, gstpbutils_dep],
@@ -22,7 +35,7 @@ pkgconfig.generate(gst_transcoder,
 
 if build_gir
   transcoder_gir = gnome.generate_gir(gst_transcoder,
-    sources : sources + headers,
+    sources : sources + headers + [gsttranscoder_h],
     nsversion : api_version,
     namespace : 'GstTranscoder',
     identifier_prefix : 'Gst',
@@ -34,11 +47,13 @@ if build_gir
     install : true,
     extra_args : gir_init_section
   )
+  transcoder_gen_sources += transcoder_gir
 endif
 
 gst_transcoder_dep = declare_dependency(link_with: gst_transcoder,
   dependencies : [gst_dep, gstpbutils_dep],
-  include_directories : [libsinc]
+  include_directories : [libsinc],
+  sources: transcoder_gen_sources,
 )
 
 meson.override_dependency('gstreamer-transcoder-1.0', gst_transcoder_dep)
index ba153dd164beaa31d2b9fbcfc604239fc2fc59f7..4745db504429d734269b3b8ddeffac43290696bc 100644 (file)
@@ -33,4 +33,6 @@
 # endif
 #endif
 
+#include <gst/transcoder/transcoder-enumtypes.h>
+
 #endif /* __GST_TRANSCODER_PRELUDE_H__ */