已经定义了gstreamer元数据的标准模板吗? [英] There is a standard template of gstreamer metadata already defined?

查看:93
本文介绍了已经定义了gstreamer元数据的标准模板吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用c编写一个gstreamer-1.0插件.我需要通过其他元素通过管道将参数从一个插件传递到另一个插件.我想使用元数据.我只需要传输一个双精度"类型变量,并希望避免定义新的元数据及其API.我试图搜索已定义但未找到任何内容的元数据列表.

I'm writing a gstreamer-1.0 plugin in c. I would need to pass a parameter through the pipeline from one plugin to another by passing through other elements. I want to use metadata. I just have to transmit a "double" type variable and would like to avoid having to define a new metadata and its API. I tried to search a list of metadata already defined but have not found anything.

我的问题是:已经定义了具有这些特征的元数据吗?

My question is: There is a metadata already defined that has these characteristics ?

推荐答案

很遗憾,我不知道您可以使用任何通用的元类型.如果您想与我们分享您要传递给他人的数据类型,则可以提出解决方法.

I'm not aware of any generic meta type that you could piggy back on, unfortunately. If you'd like to share with us what type of data you're trying to pass someone may be able to to suggest a workaround.

这是我们最终用来传递一个简单的GstClockTime值的示例元API.

Here's a sample Meta API we ended up doing to pass a simple GstClockTime value.

gstmark.h

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

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);

这篇关于已经定义了gstreamer元数据的标准模板吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆