Official way to stop a pipeline in Python?

pisymbol . pisymbol at gmail.com
Mon Sep 9 14:57:46 UTC 2019


I have an application that worked fine on Ubuntu 16.04 but now hangs on
Ubuntu 18.04 when I try to stop my pipeline.

Here is how I am initializing my pipeline;:

self.recorderBin = Gst.parse_bin_from_description(RECORD_PIPELINE, False)
self.recorderPipeline = Gst.Pipeline()
self.recorderPipeline.add(self.recorderBin)
bus = self.recorderPipeline.get_bus()
bus.add_watch(GLib.PRIORITY_DEFAULT, self._on_message)

At some point, the application starts recording and the bus is set into the
PLAYING state which succeeds, recording begins.

Now when the user presses the stop button:

self.recorderPipeline.send_event(Gst.Event.new_eos())

When the EOS is sent to the bus and self._on_message is triggered and
caught:

self.recorderPipeline.set_state(Gst.State.NULL)
HANG

Am I doing something wrong? I looked at the gst-launch-1.0 code and it
seems to be using an event_loop() that polls for messages instead of the
callback approach above. Also, gst-launch-1.0 PAUSES the bus, sets the bus
state back into the READY state, before actually setting it to the NULL
state, de-referencing it, and exiting. I actually tried it that as well but
when I set the bus state to PAUSE then READY is hangs again.

Why does the Python code above hang when setting the state while the C code
seems to work? Do I need to poll for bus messages and not rely on the auto
main loop created underneath me? I can't find a singe Python example that
polls for messages. Almost all of them are some flavor of connecting to the
bus via callbacks.

Some guidance would be appreciated,

-aps
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20190909/0a5a8296/attachment.html>


More information about the gstreamer-devel mailing list