我正在写一个gstreamer-1.0插件。 我需要通过传递其他元素将参数从一个插件传递到另一个插件。我想使用元数据。我只需传输一个“双”类型变量,并希望避免必须定义新的元数据及其API。我试图搜索已经定义但没有找到任何内容的元数据列表。
我的问题是: 已经定义了具有这些特征的元数据吗?
答案 0 :(得分:0)
不幸的是,我不知道你可以捎带的任何通用元类型。如果您想与我们分享您尝试传递的数据类型,则可以建议某种解决方法。
以下是我们最终做的传递简单GstClockTime值的Meta API示例。
gstmark.h
#ifndef __GST_MARK_H__
#define __GST_MARK_H__
#include <gst/gst.h>
#include <gst/gstmeta.h>
G_BEGIN_DECLS
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))
G_END_DECLS
#endif
gstmark.c
#include "gstmark.h"
GType
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;
}
gboolean
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;
}
gboolean
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;
}
void
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;
}
然后添加元数据:
GstMetaMarking* meta = GST_META_MARKING_ADD(in);