附加元数据到 GstBuffer

huangapple go评论81阅读模式
英文:

Attach meta data to the GstBuffer

问题

我需要将一些元数据附加到由我的GstElement pad提供的GstBuffer。我知道可以使用GstMetaInfogst_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);

huangapple
  • 本文由 发表于 2023年5月25日 20:58:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76332530.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定