Skip to content

webrtcsrc: use @watch instead of @to-owned

@to-owned increases refcount of the element, which prevents the object from proper destruction, as the initial refcount with ElementFactory::make is larger than 1.

Instead, use @watch to create a weak reference and unbind the closure automatically if the object gets destroyed.

Found when following through this blog example.

GstElement* elem = gst_element_factory_make("webrtcsrc", nullptr);
GObject* signaller = nullptr;
g_object_get(elem, "signaller", &signaller, nullptr);
gst_object_unref(elem);

This blog's snippet did not quite work as expected, since gst_object_unref does not actually destroy the object, which then causes the app to panic, since elem is still alive and reacts to producer-added event, which it cannot handle in NULL state.

With this fix the element gets destroyed as expected :)

Edited by Maksym Khomenko

Merge request reports