简体   繁体   English

动态替换正在播放的gstreamer管道中的元素

[英]dynamically replacing elements in a playing gstreamer pipeline

I'm looking for the correct technique, if one exists, for dynamically replacing an element in a running gstreamer pipeline. 我正在寻找用于动态替换正在运行的gstreamer管道中的元素的正确技术(如果存在)。 I have a gstreamer based c++ app and the pipeline it creates looks like this (using gst-launch syntax) : 我有一个基于gstreamer的c ++应用程序,它创建的管道如下所示(使用gst-launch语法):

souphttpsrc location="http://localhost/local.ts" ! souphttpsrc location =“ http://localhost/local.ts”! mpegtsdemux name=d ! mpegtsdemux name = d! queue ! 排队! mpeg2dec ! mpeg2dec! xvimagesink d. xvimagesink d。 ! queue ! 排队! a52dec ! a52dec! pulsesink pulsesink

During the middle of playback (ie GST_STATE_PLAYING is the pipeline state and the user is happily watching video), I need to remove souphttpsrc from the pipeline and create a new souphttpsrc, or even a new neonhttpsource, and then immediately add that back into the pipeline and continue playback of the same uri source stream at the same time position where playback was before we performed this operation. 在播放的中间阶段(即GST_STATE_PLAYING是管道状态,用户正在愉快地观看视频),我需要从管道中删除souphttpsrc并创建新的souphttpsrc甚至新的neonhttpsource,然后立即将其添加回管道中并在执行此操作之前在播放的相同时间位置继续播放相同的uri源流。 The user might see a small delay and that is fine. 用户可能会看到一个小的延迟,这很好。

We've barely figured out how to remove and replace the source, and we need more understanding. 我们几乎没有弄清楚如何删除和替换源,我们需要更多的了解。 Here's our best attempt thus far: 到目前为止,这是我们最好的尝试:

gst_element_unlink(source, demuxer);
gst_element_set_state(source, GST_STATE_NULL);
gst_bin_remove(GST_BIN(pipeline), source);
source = gst_element_factory_make("souphttpsrc", "src");
g_object_set(G_OBJECT(source), "location", url, NULL);
gst_bin_add(GST_BIN(pipeline), source);
gst_element_link(source, demuxer);
gst_element_sync_state_with_parent(source);

This doesn't work perfectly because the source is playing back from the beginning and the rest of the pipeline is waiting for the correct timestamped buffers (I assume) because after several seconds, playback picks back up. 这并不完美,因为源从头开始播放,而管道的其余部分正在等待正确的带时间戳的缓冲区(我认为),因为在几秒钟后,播放会恢复。 I tried seeking the source in multiple ways but nothing has worked. 我试图以多种方式寻找来源,但没有任何效果。

I need to know the correct way to do this. 我需要知道正确的方法。 It would be nice to know a general technique, if one exists, as well, in case we wanted to dynamically replace the decoder or some other element. 如果我们想动态替换解码器或其他元素,也很高兴知道一种通用技术(如果存在)。

thanks 谢谢

I think this may be what you are looking for: http://cgit.freedesktop.org/gstreamer/gstreamer/tree/docs/design/part-block.txt 我认为这可能是您要寻找的内容: http : //cgit.freedesktop.org/gstreamer/gstreamer/tree/docs/design/part-block.txt

(starting at line 115) (从第115行开始)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM