Restarting the deepstream app leads to `create pipeline failed` error.

I was playing around with the source code of deepstream reference app which comes with deepstream sdk.
I am using live rtsp sources as input. The app works fine for the initial run.

So as given in the source code -
when the app encounters an error it goes to done and performs the required cleanup.

	g_print ("Quitting\n");
	for (i = 0; i < num_instances; i++) {
	if (appCtx[i]->return_value == -1)
	  return_value = -1;
	int return_after_destroy = destroy_pipeline (appCtx[i]);

	g_mutex_lock (&disp_lock);
	if (windows[i])
	  XDestroyWindow (display, windows[i]);
	windows[i] = 0;
	g_mutex_unlock (&disp_lock);

	g_free (appCtx[i]);

	g_mutex_lock (&disp_lock);
	if (display)
	XCloseDisplay (display);
	display = NULL;
	g_mutex_unlock (&disp_lock);
	g_mutex_clear (&disp_lock);

	if (main_loop) {
	g_main_loop_unref (main_loop);

	if (ctx) {
	g_option_context_free (ctx);

	if (return_value == 0) {
	g_print ("App run successful\n");
	} else {
	g_print ("App run failed\n");

I wish to have a restart function in the app so that when it crashes it again restarts the process after sometime. In order to do that, I wrote a wrapper main function and changed the original function to some other function.

// updated main
int main(int argc, char* argv)
   some_other_function(argc, argv);// original main

and now am calling some other function again whenever the app goes to the done state. The app runs fine for the first time , but when I am recalling the function for the second time, I get the create pipeline failed message. I found out that gst_pipeline_new is unable to create a new pipeline. How to solve this ?

Well I was able to move on from here by commenting out gst_deinit, but even though the app again starts working nothing happens.

Other users may have similar experience of handling unstable RTSP source and can give suggestion.

Meanwhile, we will try to reproduce the issue with information you provide in