2016-11-16 99 views
0

我正在编写一个gstreamer-1.0插件。 我需要通过其他元素通过管道从一个插件传递给另一个参数。我想使用元数据。我只需要发送一个“double”类型的变量,并且想避免定义一个新的元数据及其API。我试图搜索已经定义的元数据列表,但没有找到任何东西。已经定义了gstreamer元数据的标准模板?

我的问题是: 有一个元数据已经定义,具有这些特点?

+0

你描述你试图解决的问题。现在你的问题是什么?你有什么尝试?你的尝试是如何工作或不工作的?最后,你有什么尝试?你的尝试是如何工作的?并请[请阅读如何提出问题](http://stackoverflow.com/help/how-to-ask),以及学习如何创建[最小,完整和可验证的示例](http:///stackoverflow.com/help/mcve)。 –

回答

0

不幸的是,我不知道任何通用的元类型,你可以捎带回来。如果您想与我们分享您尝试通过某人的数据类型,可能会提出一种解决方法。

下面是一个示例Meta API,我们最终做了一个简单的GstClockTime值。

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); 
相关问题