Hi everyone,
I have a question about properly removing elements from a GStreamer pipeline, particularly when using webrtcsrc. I know this topic has been discussed quite often, such as here, but I’m not entirely sure I understand it fully.
For example, in the follwoing script, I instantiate webrtcsrc elements based on the presence of a specific client. It seems I’m not correctly destroying the webrtcsrc (sub)elements.
def _removing_webrtcsrc(self) -> None:
self._peer_audio_id = ""
if self._webrtcsrc is not None:
self._webrtcsrc.set_state(Gst.State.NULL)
self.pipeline.remove(self._webrtcsrc)
self._webrtcsrc = None
for elt in self._receiver_elements:
self.pipeline.remove(elt)
elt.set_state(Gst.State.NULL)
self._receiver_elements.clear()
self._logger.debug("webrtcsrc removed")
def _webrtcsrc_pad_added_cb(self, webrtcsrc: Gst.Element, pad: Gst.Pad) -> None:
if pad is not None and pad.get_name().startswith("audio"): # type: ignore[union-attr]
self._logger.info("Connecting audio client")
volume = Gst.ElementFactory.make("volume")
assert volume is not None
volume.set_property("volume", 0.2)
sink = Gst.ElementFactory.make("alsasink")
sink.set_property("device", "hw:4,0")
assert sink is not None
self.pipeline.add(volume)
self.pipeline.add(sink)
self._receiver_elements.append(volume)
self._receiver_elements.append(sink)
volume.link(sink)
pad.link(volume.get_static_pad("sink")) # type: ignore[arg-type]
volume.sync_state_with_parent()
sink.sync_state_with_parent()
def _add_webrtcsrc(self, peer_audio_id: str) -> Gst.Element:
webrtcsrc = Gst.ElementFactory.make("webrtcsrc")
assert webrtcsrc is not None
self._webrtcsrc_count += 1
signaller = webrtcsrc.get_property("signaller")
signaller.set_property("producer-peer-id", peer_audio_id)
signaller.set_property("uri", "ws://127.0.0.1:8443")
webrtcsrc.connect("pad-added", self._webrtcsrc_pad_added_cb)
self.pipeline.add(webrtcsrc)
webrtcsrc.sync_state_with_parent()
return webrtcsrc
When I close the program, I encounter the following critical errors:
(python:5872): GStreamer-CRITICAL **: 15:09:59.621:
Trying to dispose element typefind, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.(python:5872): GStreamer-CRITICAL **: 15:09:59.621:
Trying to dispose element parsebin0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.(python:5872): GStreamer-CRITICAL **: 15:09:59.621:
Trying to dispose element multiqueue0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.(python:5872): GStreamer-CRITICAL **: 15:09:59.621:
Trying to dispose element decodebin3-0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.(python:5872): GStreamer-CRITICAL **: 15:09:59.621:
Trying to dispose element bin0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.(python:5872): GStreamer-CRITICAL **: 15:09:59.622:
Trying to dispose element rtpfunnel0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.(python:5872): GStreamer-CRITICAL **: 15:09:59.622:
Trying to dispose element webrtcbin0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
How would you do that properly?
Thanks
PS: using gst-plugins-rs 0.14.1-126f022f