capsfilter如何起作用?

分析了三个函数,gst_base_transform_getcaps gst_base_transform_transform_caps, gst_capsfilter_transform_caps 。

static GstCaps *

gst_base_transform_getcaps (GstPad * pad){

  otherpad = (pad == trans->srcpad) ? trans->sinkpad : trans->srcpad;//得到sinkpad.

  peercaps = gst_pad_peer_get_caps_reffed (otherpad); //即得到本sinkpadcpas.

if (peercaps) {

      //得到sinkpadtmplate caps.

      templ = gst_pad_get_pad_template_caps (otherpad);

        //进行相交

temp = gst_caps_intersect_full (peercaps, templ,   GST_CAPS_INTERSECT_FIRST);

}

  /* then see what we can transform this to */

  //可以参考下面的函数解释。

  caps = gst_base_transform_transform_caps (trans,

      GST_PAD_DIRECTION (otherpad), temp);

  /* and filter against the template of this pad */

  //如下得到srctmplate caps.    

  templ = gst_pad_get_pad_template_caps (pad);

  /* We keep the caps sorted like the returned caps */

  temp = gst_caps_intersect_full (caps, templ, GST_CAPS_INTERSECT_FIRST);

  caps = temp;

  ……

  return caps;

}

 

static GstCaps *

gst_base_transform_transform_caps (GstBaseTransform * trans,

    GstPadDirection direction, GstCaps * caps)

{

   gint n = gst_caps_get_size (caps);

   for (i = 0; i < n; i++) {

GstCaps *nth;

        nth = gst_caps_copy_nth (caps, i);

//下面调用的是gst_capsfilter_transform_caps,如果filter_capsnth无交集,   //那得到的tmp是空。

        temp = klass->transform_caps (trans, direction, nth);

        gst_caps_merge (ret, temp);

   }

  return ret;

}

//可以看出只是跟filter_caps做相交,这是可以从外面设置,如:

//g_object_set(capsfilter, "caps", caps0, NULL);

static GstCaps *

gst_capsfilter_transform_caps (GstBaseTransform * base,

    GstPadDirection direction, GstCaps * caps)

{

  ret = gst_caps_intersect (caps, filter_caps);

  return ret;

}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
以下是一个简单的C语言示例代码,用于将三个队列连接到一个capsfilter插件进行多路自定义数据合并: ``` #include <gst/gst.h> int main(int argc, char *argv[]) { GstElement *pipeline, *queue1, *queue2, *queue3, *capsfilter; GstCaps *caps; GstBus *bus; GstMessage *msg; GstStateChangeReturn ret; /* Initialize GStreamer */ gst_init(&argc, &argv); /* Create the elements */ queue1 = gst_element_factory_make("queue", "queue1"); queue2 = gst_element_factory_make("queue", "queue2"); queue3 = gst_element_factory_make("queue", "queue3"); capsfilter = gst_element_factory_make("capsfilter", "capsfilter"); pipeline = gst_pipeline_new("test-pipeline"); if (!pipeline || !queue1 || !queue2 || !queue3 || !capsfilter) { g_printerr("Not all elements could be created.\n"); return -1; } /* Build the pipeline */ gst_bin_add_many(GST_BIN(pipeline), queue1, queue2, queue3, capsfilter, NULL); if (gst_element_link_many(queue1, capsfilter, NULL) != TRUE || gst_element_link_many(queue2, capsfilter, NULL) != TRUE || gst_element_link_many(queue3, capsfilter, NULL) != TRUE) { g_printerr("Elements could not be linked.\n"); gst_object_unref(pipeline); return -1; } /* Set caps on the capsfilter */ caps = gst_caps_new_simple("video/x-raw", "format", G_TYPE_STRING, "RGB", "width", G_TYPE_INT, 640, "height", G_TYPE_INT, 480, NULL); g_object_set(G_OBJECT(capsfilter), "caps", caps, NULL); gst_caps_unref(caps); /* Start playing */ ret = gst_element_set_state(pipeline, GST_STATE_PLAYING); if (ret == GST_STATE_CHANGE_FAILURE) { g_printerr("Unable to set the pipeline to the playing state.\n"); gst_object_unref(pipeline); return -1; } /* Wait until error or EOS */ bus = gst_element_get_bus(pipeline); msg = gst_bus_timed_pop_filtered(bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS); /* Free resources */ if (msg != NULL) gst_message_unref(msg); gst_object_unref(bus); gst_element_set_state(pipeline, GST_STATE_NULL); gst_object_unref(pipeline); return 0; } ``` 这个示例代码创建了一个包含三个队列和一个capsfilter插件的GStreamer管道,并将三个队列连接到capsfilter插件,以进行多路自定义数据合并。在这个示例中,我们将capsfilter插件的输出格式设置为"video/x-raw",分辨率为640x480,格式为RGB。你可以根据自己的需求修改这些参数。 请注意,这个示例代码仅仅是一个演示,实际应用中可能需要更复杂的管道和更多的元素来实现多路数据合并。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

山西茄子

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

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

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

打赏作者

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

抵扣说明:

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

余额充值