首页 > 解决方案 > Gstreamer:向正在运行的管道添加一个 bin

问题描述

我有一个正在运行的视频管道。现在我想动态添加一个录音箱......(有时主管道已经运行了一段时间......)

我的管道的图像架构如附件。上面的管道是我的工作管道,而底部是我要连接到上面的独立录音箱

安装bin的步骤如下(我所知道的)

  1. 获取 bin 的 pad(即在这种情况下为记录 bin)
  2. 用探针挡住这个焊盘(bin)
  3. 将 bin 的状态设置为正在运行
  4. 获取要连接的管道或组件的焊盘
  5. 用探针挡住这个焊盘(管道)
  6. 将它们连接在一起'
  7. 取下探头
//get sink pad to recording bin and block it
// https://gstreamer.freedesktop.org/documentation/application-development/advanced/pipeline-manipulation.html?gi-language=c#dynamically-changing-the-pipeline
GstElement *temp = gst_bin_get_by_name(GST_BIN(recording), "queuer" );
pad = gst_element_get_static_pad(temp,"sink");

gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, &GstProbeCallback, NULL,  NULL);

 gst_bin_add(GST_BIN(pipeline),recording);

// when the bin has been attached, now set it to play
gst_element_set_state(recording,GST_STATE_PLAYING);
g_print(" Starting to play \n");
        
t_sink_pad = gst_element_get_request_pad (tee,"src_2");
gst_pad_add_probe (tee_sink_pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, &GstProbeCallback, NULL,  NULL);

if(gst_pad_link (tee_sink_pad,pad) != GST_PAD_LINK_OK)
{
    g_printerr ("Tee(Record) could not be linked.\n");
    gst_object_unref (pipeline);
    return -1;
}
g_print("Linking Done for recording \n\n");
GST_DEBUG_OBJECT (pipeline, "Linking Done for recording");

但是我好像遇到了无法建立链接的问题

Tee(Record) could not be linked.

我想知道我错过了哪一步......据说这是从一个更简单的情况下添加到管道并删除它们

谢谢你的帮助

标签: c++gstreamer

解决方案


推荐阅读