Adding Custom Meta in Gst Plugins Upstream from Gst-nvstreammux

The DeepStream SDK creates batch level metadata in the Gst-nvstreammux plugin. It holds NvDsBatchMeta metadata in a hierarchy of batches, frames within batches, and objects within frames.
To add metadata to the plugin before Gst-nvstreammux
This procedure introduces metadata to the DeepStream pipeline at a plugin before Gst-nvstreammux.
1. Set the plugin’s following members of the plugin’s NvDsUserMeta structure:
copy_func
free_func
meta_type
gst_to_nvds_meta_transform_func
gst_to_nvds_meta_release_func
2. Attach the metadata by calling gst_buffer_add_nvds_meta() and set the meta_type in the NvDsMeta instance returned by gst_buffer_add_nvds_meta().
3. The Gst-nvstreammux plugin transforms the input gst-meta created in step 2 from the Gst Buffer into an NvDsUserMeta object associated with the corresponding NvDsFrameMeta object. It adds this object to the frame_user_data list.
4. Search the frame_user_meta list in the NvDsFrameMeta object for the meta_type that was set in step 2, and access the attached metadata.
See the sample application source code in sources/apps/sample_apps/deepstream-gst-metadata-test/deepstream_gst_metadata.c for more details. If gst meta is not attached with gst_buffer_add_nvds_meta(), it is not transformed into DeepStream metadata. It is still available in the Gst Buffer.