gstreamer插件开发-Specifying the pads

Specifying the pads

如前所述,pad是数据进出元素的端口,这使得它们在元素创建过程中成为非常重要的项。在样板代码中,我们已经看到了静态pad模板如何将pad模板注册到元素类中。在这里,我们将看到如何创建实际的元素,使用_event()函数来配置特定的格式,以及如何注册函数来让数据流过元素。

在element _init()函数中,您从pad模板创建pad,该pad模板已经在_class_init()函数中的元素类中注册。创建pad之后,必须设置一个_chain()函数指针,它将接收和处理sinkpad上的输入数据。你也可以选择设置_event()函数指针和_query()函数指针。另外,pad也可以在循环模式下运行,这意味着它们可以自己提取数据。稍后将详细介绍此主题。之后,您必须将pad注册到元素中。事情是这样发生的:

static void gst_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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

威威攻城狮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值