appsink的功能

簡單的說 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()

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章