Deepstream dynamically add source and sink

I find add source example in https://github.com/NVIDIA-AI-IOT/deepstream_reference_apps runtime_source_add_delete example.

P1 pipeline
create_source_bin
create_source_bin
-------------------> nvstreammux->pgie->nvtracker->mqttsink
create_source_bin/
create_source_bin/
In P1 I can dynamically add or delete source .It work well.
P2 pipeline:
create_source_bin-------------------------------------------------------create_rtmp_sink
create_source_bin-------------------------------------------------------create_rtmp_sink
-------------------> nvstreammux->pgie->nvtracker->nvstreamdemux->
create_source_bin-------------------------------------------------------create_rtmp_sink
create_source_bin-------------------------------------------------------create_rtmp_sink
In P2 I can dynamically delete source and sink .When I add source and sink ,it print error at add sorce code

code:
gst_bin_add(GST_BIN(pipeline), source_bin);
GstStateChangeReturn state_return =
gst_element_set_state (g_source_bin_list[i], GST_STATE_PLAYING);
switch (state_return)
{
case GST_STATE_CHANGE_SUCCESS:
g_print (“Source STATE CHANGE SUCCESS\n\n”);
i++;
break;
case GST_STATE_CHANGE_FAILURE:
g_print (“Source STATE CHANGE FAILURE\n\n”);
break;
case GST_STATE_CHANGE_ASYNC:
g_print (“Source STATE CHANGE ASYNC\n\n”);
state_return =
gst_element_get_state (g_source_bin_list[i], NULL, NULL, GST_CLOCK_TIME_NONE);
i++;
break;
case GST_STATE_CHANGE_NO_PREROLL:
g_print (“Source STATE CHANGE NO PREROLL\n\n”);
break;
default:
break;
}
print Source STATE CHANGE NO PREROLL

How can add or delete one rtsp source and rtmp sink in runtime.

• Hardware Platform (Jetson / GPU)
• DeepStream Version5.0 DP
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)

RTSP connection failure. You need to debug RTSP streaming first. Can gst-launch-1.0 pipeline work for your rtsp case?

add rtsp is well. that is happend at delete

Hi [Fiona.Chen] I changed description.

and . In GST_STATE_PLAYING add sorce and sink gst_element_get_request_pad(streamdemux, pad_name) will failed,

so I do this
for (int i = 0; i < MAX_NUM_SOURCES; i++)
{
GstPad *srcpad = NULL;
gchar pad_name[16] = { };
g_snprintf(pad_name, 15, “src_%d”, i);
srcpad = gst_element_get_request_pad(streamdemux, pad_name);
gst_object_unref(srcpad);
}
and In GST_STATE_PLAYING add sorce and sink I can use gst_element_get_static_pad(streamdemux, pad_name) .

The sample codes of runtime_source_add_delete has shown you the way.

  1. You can not delete all srcs or all sinks, if there is no src or no sink left, the pipeline stops.
  2. You need to change the source or sink state to NULL before you delete it.
  3. The dynamic(ghost) pad needs specific handling. https://gstreamer.freedesktop.org/documentation/application-development/basics/pads.html?gi-language=c
    https://github.com/NVIDIA-AI-IOT/deepstream_reference_apps/blob/master/runtime_source_add_delete/deepstream_test_rt_src_add_del.c

More information can be got from the sample codes.