gstreamer - GStreamer:动态删除混合器 src 元素冻结管道
问题描述
我正在尝试使用 gstaudiomixer 从我动态添加和删除的两个源元素中混合音频。
+---------+ +------------+
| source1 |--->| |
+---------+ | | +-----------+
| audiomixer |--->| audiosink |
+---------+ | | +-----------+
| source2 |--->| |
+---------+ +------------+
动态添加元素(使用请求垫和垫模板)似乎按预期工作。但是,当动态移除焊盘时会导致管道冻结。
这是我用来删除元素的代码:
public void remove(Gst.Element? element)
{
/* Removes the element from the pipeline */
if (element == null) return;
element.set_state(Gst.State.NULL); // Stop it from streaming data
element.unlink(this.mixer);
this.pipeline.remove(element);
}
这是我的第二次尝试,试图阻止垫:
public void remove(Gst.Element? element)
{
/* Removes the element from the pipeline */
if (element == null) return;
element.get_static_pad("src").get_peer().add_probe(Gst.PadProbeType.IDLE, (pad, info) => {
element.set_state(Gst.State.NULL); // Stop it from streaming data
element.unlink(this.mixer);
this.pipeline.remove(element);
return Gst.PadProbeReturn.REMOVE;
});
}
这样做的正确方法是什么?
解决方案
如果要从管道中更改或删除元素,请确保停止将缓冲区推送到元素,向元素发送 eos 并添加新元素并继续。它在这个链接中得到了很好的解释
推荐阅读
- python - 如何使用 NN 输入的对象列表处理分类数据?
- javascript - 如何将 Bootstrap 4 轮播与一组控件同步?
- python - 使用 numpy reshape((-1,1)) 的替代方法
- python - cython vs python numpy 用于(简单地)添加数组
- android - Retrofit2,调试和发布版本的不同行为
- json - 如何在firebase实时数据库中向大JSON对象添加另一个属性
- ios - 如何从 Firebase 数据库中删除特定的子值
- javascript - 我正在尝试使用 javascript 从 Web 解析 JSON,但它不起作用
- svg - 使用 RSelenium 和 XPath 查找 SVG 元素
- php - 如何将值转换为数组 PHP