英文:
Attach meta data to the GstBuffer
问题
我需要将一些元数据附加到由我的GstElement
pad提供的GstBuffer
。我知道可以使用GstMetaInfo
和gst_buffer_add_meta
的方法。但这种方法涉及在我的GstElement
代码和实际接收缓冲区的代码中都使用相同的MyCustomMetaData
类,由于某些原因,这是不可取的。如何实现这一目标?
英文:
I need to attach some meta data to the GstBuffer
which provided by my GstElement
pad. I know that there is a way to use GstMetaInfo
and gst_buffer_add_meta
. But this method involves using the same MyCustomMetaData
class both in the code of my GstElement
and in the code that actually receives the buffer. Which is undesirable for certain reasons. How could it be achieved?
答案1
得分: 1
将缓冲区添加元数据:
static const gchar* tags[] = { NULL };
auto meta_info = gst_meta_register_custom ("mymeta", tags, NULL, NULL, NULL);
auto meta = gst_buffer_add_custom_meta (*buf, "mymeta");
auto metadata = gst_custom_meta_get_structure (meta);
gst_structure_set (metadata, "property_name", G_TYPE_INT64, gint64(1), nullptr);
从缓冲区检索元数据:
auto meta = gst_buffer_get_custom_meta (buffer, "mymeta");
auto metadata = gst_custom_meta_get_structure (meta);
gint64 property;
gst_structure_get_int64 (metadata, "property_name", &property);
英文:
Add metadata to the buffer:
static const gchar* tags[] = { NULL };
auto meta_info = gst_meta_register_custom ("mymeta", tags, NULL, NULL, NULL);
auto meta = gst_buffer_add_custom_meta (*buf, "mymeta");
auto metadata = gst_custom_meta_get_structure (meta);
gst_structure_set (metadata, "property_name", G_TYPE_INT64, gint64(1), nullptr);
Retrive metadata from the buffer:
auto meta = gst_buffer_get_custom_meta (buffer, "mymeta");
auto metadata = gst_custom_meta_get_structure (meta);
gint64 property;
gst_structure_get_int64 (metadata, "property_name", &property);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论