Custom frame information to eventmsgmeta

Hi @18241266008

NvDsEventMsgMeta is a type of DeepStream user meta and there is a NvDsUserMetaList in the batch, frame and object levels of DeepStream metadata, so you can add message meta per-batch, per-frame, or per-object. We use it on the batch level adding a JSON as message meta:

void
add_meta_to_buffer (GstBuffer * buf, gchar * meta)
{
  NvDsBatchMeta *batch_meta;
  NvDsUserMeta *user_meta;
  batch_meta = gst_buffer_get_nvds_batch_meta (buf);
  user_meta = nvds_acquire_user_meta_from_pool (batch_meta);
  if (user_meta) {
    NvDsEventMsgMeta *msg_meta =
        (NvDsEventMsgMeta *) g_malloc0 (sizeof (NvDsEventMsgMeta));
    msg_meta->otherAttrs = meta;
    msg_meta->objectId = g_strdup ("custom");
    user_meta->user_meta_data = (void *) msg_meta;
    user_meta->base_meta.batch_meta = batch_meta;
    user_meta->base_meta.meta_type = NVDS_EVENT_MSG_META;
    user_meta->base_meta.copy_func = (NvDsMetaCopyFunc) custom_meta_copy_func;
    user_meta->base_meta.release_func =
        (NvDsMetaReleaseFunc) custom_meta_free_func;
    nvds_add_user_meta_to_batch (batch_meta, user_meta);
  }
}

To get the meta on the other element that uses it:

  NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta (buffer);
  if (NULL == batch_meta){
    g_print ("No DeepStream meta found\n");
    return;
  }
  NvDsUserMetaList *user_meta_list = batch_meta->batch_user_meta_list;
  while (user_meta_list != NULL) {
    NvDsUserMeta *user_meta = (NvDsUserMeta *) user_meta_list->data;
    if (user_meta->base_meta.meta_type == NVDS_EVENT_MSG_META) {
      NvDsEventMsgMeta *msg_meta =
          (NvDsEventMsgMeta *) user_meta->user_meta_data;
      if (g_strcmp0 (msg_meta->objectId, "custom") == 0) {
        g_print ("CustomMeta\n%s\n", msg_meta->otherAttrs);
      }
    }
    user_meta_list = user_meta_list->next;
  }

I hope this helps