Thanks for your response. I used your advice and made some changes to the
code but to no avail. I am making sure that I do not invoke this code
twice. Also there is a check for the current state to not be NULL before
calling this API. The code still gets stuck at "gst_element_set_state".