【gstreamer】gstreamer-appsink元素的使用

appsink的功能
extract samples from a pipeline
use a queue to collect buffers from the streaming thread
简单的说 appsink 元素作为gstreamer的sink节点,它可以实现pipeline中的流媒体数据与其他应用程序的交换,比如实现gstreamer与CUDA交互,gstreamer与OpenCV交互,等等吧。
`
主要作用是借助gstreamer pipeline的 media streaming, 我们通过appsink用一个buffer来收集流媒体的数据,提供给其他应用程序来处理使用。

appsink的使用
通常方法:
gst_app_sink_pull_sample(), gst_app_sink_pull_preroll()
gst_app_sink_pull_preroll(),gst_app_sink_pull_preroll()

max-buffers 属性  限制buffer size
!!!  If the application is not pulling samples fast enough, this queue will consume a lot of memory over time.

drop 属性    控制streaming thread是否阻塞,或者是否在达到最大队列时丢弃旧的缓存区
!!! 阻塞线程流会对实时性能产生影响,应该避免使用。

使用步骤:

创建gstreamer pipeline, 最后的sink节点是appsink
appsink
gst_appsink_callback

  • onEOS
  • onPrerool
  • onBuffer

//获取media sample相关的缓冲区 gstBuffer
gst_app_sink_pull_sample()
gst_sample_get_buffer()
buffer 映射 map.data map.size
gst_buffer_map()

根据appsink的caps 得到数据类型,每帧数据的width heigth
gst_sample_get_caps()
gst_caps_get_structure()
gst_structure_get_int()

分配内存,内存拷贝
参考文档:
GstAppSink — Easy way for applications to extract samples from a pipeline

GstBuffer — Data-passing buffer type
GstSample — A media sample

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值