如何在自定义插件中创建GstBuffer Pool

问题描述

我有一个GST管道,如下所示。

SRC ->A ->ROI ->B-> SINK

我通过使用Gstreamer错误插件工具 element-maker 创建了自定义元素(A,ROI和B),如下所示。

./ element-maker videofilter

我已从上述自定义插件代码删除 transform_frame()函数,并使用了transform_frame_ip()以便将这些插件用作传递对象。

上面的管道可以正常工作。

要求

在这里,“ ROI”元素将产生多个帧,并将这些帧传递到元素“ B”以进行进一步处理。

要实现此算法,我从下面提到的链接中在Gstreamer中看到了 GstBuffer Pool概念

https://gstreamer.freedesktop.org/documentation/gstreamer/gstbufferpool.html?gi-language=c

我的ROI功能就像上游元素一样,下面是init_ROI元素内部的池配置

 static void gst_ROI_init (GstROI *ROI){
    
  /* GstBuffer Pool Config.*/
  pool = gst_buffer_pool_new();
  config = gst_buffer_pool_get_config(pool);
  size = 420*420*3; // For RGB fromat.
  min_ = 1;
  max_ = 10;
  caps = gst_caps_from_string("video/x-raw");

  gst_buffer_pool_config_set_params (config,caps,size,min_,max_);
  gst_caps_unref(caps);
  if ( gst_buffer_pool_set_config (pool,config)){
     std::cout << "[INFO] Pool configuration done 
    successfully\n";
  if( gst_buffer_pool_set_active( pool,TRUE )){   
      std::cout << "Successfully activated the pool 
     buffer\n"; 
   }
   else{    
    std::cout << "[ERROR] Failed to activate the 
buffer pool\n";
}

} //end if
else {
std::cout << "[ERROR] Failed to set the pool 
config.\n"; 
  } 
}

我的**'B'元素**作为下游元素,下面是从缓冲池获取帧的代码

  gst_B_transform_frame_ip (GstVideoFilter * filter,GstVideoFrame * frame)
  { 
  /* GstBufferPool */ 
 /*if (gst_buffer_pool_acquire_buffer(pool,&buf,NULL) == GST_FLOW_EOS){ // pool variable is shared 
 variable ascross the ROI and B element.
std::cout << "[ERROR] Failed to acquire the frame\n";      
 } 

问题: 但是上述实现未按预期工作。看来我做错了。

我对GstBuffer池有一些疑问。

1-如何在上游元素的缓冲池内部添加帧?

2-是否有其他替代方法和简单的方法可以做到这一点。例如,我可以创建一个 GstBuffer可共享的数组存储n个裁剪的图像,并且将在 B内部访问元素而不是实现GstBuffer池?

这个环境是全新的。任何反馈对我都会有用。

先谢谢您

任何人都可以提供有关上述实现的反馈意见,如果任何人都可以共享参考代码以实现相同的实现 GstBufferPool,我将非常感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)