GStreamer reference count not decreasing

shelbinpaul shelbinpaul at gmail.com
Thu Feb 25 09:24:29 UTC 2021


Following pipeline is  my initial pipeline.

*olcamerasrc->capsfilter->queue->appsink*

olcamersrc is custom element - will produce H264 encoded video in its src
pad. It also have a sink pad to accept overlay buffer to be encoded with the
video.

After setting initial pipeline's state to PLAYING I am trying to add below
mentioned pipeline dynamically to above one to display an overlay on the
video. overlay buffer will be fed to appsrc once new pipeline is added.

*appsrc-->alphacolor-->queue-->capsfilter->ovelaysink( sink pad of
olcamerasrc element)*

After setting new elements state to PLAYING I printed the reference count of
each elements. It is suddenly changed to 6 from 1. When I trying to remove
these elements from pipeline reference count never reaching to zero. Seems
like it causing memory leak. I have done a performance testing by adding and
removing new pipeline elements and application got killed by OS due to
increase in memory usage.

My steps to add pipeline elements:
1) Add a probe in source pad of olcamerasrc
2) Inside the call back method of probe
    a) Add new elements to pipeline using -gst_bin_add_many
    b) Link new elements using - gst_element_link_many
    c) Request new sink pad from olcamerasrc.
    d) Link overlay sink pad of olcamerasrc and src pad of capsfilter
    e) Set state to PLAYING for new  elements
3) return pad drop 


My steps to remove pipeline elements:
1) Add a probe in source pad of olcamerasrc
2) Inside the call back method of probe
    a) Unlink overlay sink pad of olcamerasrc and src pad of capsfilter
    b) Unlink new elements using - gst_element_unlink_many
    c) Remove new elements from pipeline using -gst_bin_remove_many
    d) Release new sink pad from olcamerasrc.
    e) Set state to NULL for new  elements
3) return pad drop 


I have a few confusions here .
1) Is it required to add any probe( in pad of olcamerasrc)  in order to
add/remove overlay ( above pipeline ) dynamically to initial pipeline?

2) What would be the reason for the spike in reference count when state
changing to PLAYING?

3) How can I  properly reach zero reference count for elements after
removing from pipeline?

*Could you please help me to identify the above mentioned issues ?*




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list