如何在运行时更改 GStreamer 管道的拓扑结构?

How to change a GStreamer pipeline's topology during runtime?

我有一个 GStreamer 管道,其拓扑结构有时会发生变化。我们所做的是:

gst_element_set_state(pipeline, GST_STATE_READY);
gst_element_unlink(node1, tee);
gst_element_link(node1, oldfilm);
gst_element_link(oldfilm, tee);
gst_element_set_state(pipeline, GST_STATE_PLAYING);

我们假设在重新连接元素时必须停止管道。问题:我们的应用程序挂起,通常在我们更改拓扑的前几次后视频停止流式传输,然后对 gst_element_set_state(pipeline, GST_STATE_PLAYING) 的下一次调用永远不会 returns。该应用程序仍然响应 ^C,这当然会杀死它。

我们得出结论,我们没有做对。当应用程序处于 运行 时更改管道拓扑的正确方法是什么?

早在 2016 年的 GStreamer 会议上,我就听到了关于这个主题的演讲,在这种情况下感觉非常有用。

幻灯片: https://gstreamer.freedesktop.org/data/events/gstreamer-conference/2016/Jose%20A.%20Santos%20-%20How%20to%20work%20with%20dynamic%20pipelines%20using%20GStreamer.pdf

对话: https://gstconf.ubicast.tv/videos/how-to-work-dynamic-pipelines/

我希望这解释了如何处理这些类型的问题。