dynamically replacing elements in a playing gstreamer pipeline

markymark mark.rollins at yahoo.com
Fri Aug 24 10:45:20 PDT 2012


0 down vote favorite
	

I'm looking for the correct technique, if one exists, for dynamically
replacing an element in a running gstreamer pipeline. I have a gstreamer
based c++ app and the pipeline it creates looks like this (using gst-launch
syntax) :

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

During the middle of playback (i.e. 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. 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



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/dynamically-replacing-elements-in-a-playing-gstreamer-pipeline-tp4656068.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list