Implementing a new GstMeta,but call gst_meta_api_type_register error

I Implementing a new GstMeta of GstMetaMarking.I want to create data in src element and get data in next element, but an error occured, i don’t know why(I call GST_META_MARKING_GET in src element is successful).
Create buf in src elements use GST_META_MARKING_ADD() to add meta, and in the next element use GST_META_MARKING_GET to get meta,. receive errro in the next elsment when call GST_META_MARKING_GET() (–>gst_meta_marking_api_get_type()–>gst_meta_api_type_register ()),
the error is

(ai_gstreamer:68557): GLib-GObject-CRITICAL **: 17:20:48.596: g_pointer_type_register_static: assertion 'g_type_from_name (name) == 0' failed

(ai_gstreamer:68557): GLib-GObject-CRITICAL **: 17:20:48.597: g_type_set_qdata: assertion 'node != NULL' failed

(ai_gstreamer:68557): GLib-CRITICAL **: 17:20:48.597: g_once_init_leave: assertion 'result != 0' failed

(ai_gstreamer:68557): GStreamer-CRITICAL **: 17:20:48.597: gst_buffer_get_meta: assertion 'api != 0' failed

----------------src elements—

GstBuffer *buf;
  buf = gst_buffer_new();
  GstMetaMarking * meta = GST_META_MARKING_ADD(buf);

----------------next elements--------

  GstMetaMarking * meta = GST_META_MARKING_GET(buf)


typedef struct _GstMetaMarking GstMetaMarking; 
struct _GstMetaMarking {
	    GstMeta meta;
	    GstClockTime in_timestamp;
GType gst_meta_marking_api_get_type (void);
const GstMetaInfo* gst_meta_marking_get_info (void);
#define GST_META_MARKING_GET(buf) ((GstMetaMarking *)gst_buffer_get_meta(buf,gst_meta_marking_api_get_type()))
#define GST_META_MARKING_ADD(buf) ((GstMetaMarking *)gst_buffer_add_meta(buf,gst_meta_marking_get_info(),(gpointer)NULL))


gst_meta_marking_api_get_type (void)
  static volatile GType type;
  static const gchar *tags[] = { NULL };
  if (g_once_init_enter (&type)) {
    GType _type = gst_meta_api_type_register ("GstMetaMarkingAPI", tags);
    g_once_init_leave (&type, _type);
  return type;
gst_meta_marking_init(GstMeta *meta, gpointer params, GstBuffer *buffer)
    GstMetaMarking* marking_meta = (GstMetaMarking*)meta;
    marking_meta->in_timestamp = GST_CLOCK_TIME_NONE;
    return TRUE;
gst_meta_marking_transform (GstBuffer *dest_buf,
                             GstMeta *src_meta,
                             GstBuffer *src_buf,
                             GQuark type,
                             gpointer data) {
    GstMeta* dest_meta = GST_META_MARKING_ADD(dest_buf);
    GstMetaMarking* src_meta_marking = (GstMetaMarking*)src_meta;
    GstMetaMarking* dest_meta_marking = (GstMetaMarking*)dest_meta;
    dest_meta_marking->in_timestamp = src_meta_marking->in_timestamp;
    return TRUE;
gst_meta_marking_free (GstMeta *meta, GstBuffer *buffer) {
const GstMetaInfo *
gst_meta_marking_get_info (void)
  static const GstMetaInfo *meta_info = NULL;
  if (g_once_init_enter (&meta_info)) {
    const GstMetaInfo *meta =
        gst_meta_register (gst_meta_marking_api_get_type (), "GstMetaMarking",
        sizeof (GstMetaMarking), (GstMetaInitFunction)gst_meta_marking_init,
        (GstMetaFreeFunction)gst_meta_marking_free, (GstMetaTransformFunction) gst_meta_marking_transform);
    g_once_init_leave (&meta_info, meta);
  return meta_info;

The meta seems to be registered twice. You can get more details with env G_DEBUG=fatal_criticals and gdb. The program will abort instead of continuing. You should be able to see what is the trigger.

1 Like