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

通常方法:
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()

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐