Gstreamer插件教程2.2—编写一个插件(Writing a Plugin):详解pads(Specifying the pads)

来源:互联网 发布:java.util.Locale 编辑:程序博客网 时间:2024/04/28 07:57

英文原文:https://gstreamer.freedesktop.org/documentation/plugin-development/basics/pads.html

正如前面所说,pad是数据进出element时的端口,这使得pad在element的创建过程中成为非常重要的一步。在boilerplate代码中,我们已经看到了静态pad模板是如何通过element class来注册pad模板的。这里,我们将看到如何创建一个真实的element:用一个_event()-函数来配置一个特殊的格式。还将看到如何注册函数,使得数据流通过element。

在element的_init()函数被调用前,你从pad模板中创建的pad已经在_class_init()函数中被注册到element。在创建了pad之后,你必须设置一个_chain()函数指针,它能够接收及处理sinkpad输入的数据。你也可以选择设置一个_event()函数指针和一个_query()函数指针。同样的,pad也可以在一个循环的模式下工作,这意味着它们能够自己获取数据。后面将更详细地讨论这一衣话题。在那之后,你必须在element中注册pad,形式如下:

static voidgst_my_filter_init (GstMyFilter *filter){  /* pad through which data comes in to the element */  filter->sinkpad = gst_pad_new_from_static_template (    &sink_template, "sink");  /* pads are configured here with gst_pad_set_*_function () */  ...  gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);  /* pad through which data goes out of the element */  filter->srcpad = gst_pad_new_from_static_template (    &src_template, "src");  /* pads are configured here with gst_pad_set_*_function () */  ...  gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);  /* properties initial value */  filter->silent = FALSE;}


1 0
原创粉丝点击