Please provide complete information as applicable to your setup.
• Hardware Platform ( Tesla T4)
• CUDA Version: 11.4
• Ubuntu Version: 18.04
• DeepStream Version: 6.0.1
• gstreamer Version: 1.14.5
• TensorRT Version: 8.0.1
• NVIDIA GPU Driver Version: 470.82.01
• Issue Type(bugs)
**• opencv version : 4.6.0 **
I have a program that want to dynamic add and delete sources, the pipeline just like below:
nvurisrcbin ! nvstreammux ! queue ! nvpreprocess ! nvinfer ! queue ! nvtracker ! queue ! tee ! queue ! nvmultistreamtiler ! nvvideoconvert ! nvdsosd ! nvvideoconvert ! fakesink
and, I have referenced the demo: https://github.com/NVIDIA-AI-IOT/deepstream_reference_apps/blob/master/runtime_source_add_delete/deepstream_test_rt_src_add_del.c
some code like this:
while (1) {
for(size_t i = 0; i < 30; i++) {
addDeviceScheduler(ctx, (char*)std::to_string(i).c_str(), "rtsp://admin:123456@192.168.26.201/mpeg4");
sleep(5);
}
for(size_t i = 0; i < 30; i++) {
deleteDeviceScheduler(ctx, (char*)std::to_string(i).c_str());
sleep(5);
}
sleep(2);
}
bool NVGstPipeline::remove_source(guint index, std::string url)
{
LOG(INFO) << "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
g_mutex_lock (&app_ctx.lock);
GstElement *src_bin = NULL;
GstElement *streammux = NULL;
GstPad *pad = NULL;
gchar bin_name[NAME_LENGTH] = {};
gchar pad_name[NAME_LENGTH] = {};
GstStateChangeReturn state_ret;
LOG(INFO) << "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB";
//根据index获取source
g_snprintf(bin_name, NAME_LENGTH, SOURCE_BIN_NAME_V, index);
src_bin = gst_bin_get_by_name(GST_BIN(app_ctx.pipeline), bin_name);
LOG(INFO) << "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC";
//获取streammux
streammux = gst_bin_get_by_name(GST_BIN(app_ctx.pipeline), STREAM_MUXER_NAME);
if (!src_bin || !streammux) {
LOG(ERROR) << "Can't find some element when deleting source.";
g_mutex_unlock (&app_ctx.lock);
return false;
}
LOG(INFO) << "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD";
gst_element_send_event(src_bin, gst_event_new_eos());
gst_element_send_event(src_bin, gst_event_new_flush_stop (FALSE));
usleep(50000);
state_ret = gst_element_set_state(src_bin, GST_STATE_NULL);
LOG(INFO) << "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE";
switch(state_ret) {
case GST_STATE_CHANGE_ASYNC:
gst_element_get_state(src_bin, NULL, NULL, GST_CLOCK_TIME_NONE);
LOG(INFO) << "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
case GST_STATE_CHANGE_SUCCESS:
g_snprintf(pad_name, NAME_LENGTH, "sink_%u", index);
pad = gst_element_get_static_pad(streammux, pad_name);
LOG(INFO) << "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG";
//eos 会卡住,释放不掉,原因pipeline状态未设置NULL
if(pad) {
gst_pad_send_event(pad, gst_event_new_eos());
LOG(INFO) << "HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH";
gst_pad_send_event(pad, gst_event_new_flush_stop (FALSE));
LOG(INFO) << "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII";
gst_element_release_request_pad(streammux, pad);
LOG(INFO) << "JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ";
gst_object_unref(pad);
LOG(INFO) << "KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK";
usleep(500);
gst_bin_remove(GST_BIN(app_ctx.pipeline), src_bin);
LOG(INFO) << "SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS";
gst_object_unref(src_bin);
LOG(INFO) << "TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT";
}
break;
case GST_STATE_CHANGE_FAILURE:
LOG(ERROR) << "STATE CHANGE FAILURE";
break;
case GST_STATE_CHANGE_NO_PREROLL:
LOG(ERROR) << "STATE CHANGE NO PREROLL";
break;
default:
LOG(ERROR) << "UNKNOWED";
break;
}
app_ctx.source_bin[index].index = -1;
app_ctx.source_bin[index].url.clear();
app_ctx.source_bin[index].device_id.clear();
app_ctx.source_bin[index].srcBin = NULL;
app_ctx.source_bin[index].alive = FALSE;
app_ctx.source_bin[index].reconfiguring = FALSE;
app_ctx.connect_count --;
LOG(INFO) << "Source removed, index = " << index << ", url = " << url;
g_mutex_unlock (&app_ctx.lock);
return true;
}
when I dynamic delete the source ,it would stuck on line : state_ret = gst_element_set_state(src_bin, GST_STATE_NULL);
logs:
0:03:25.919650477 30071 0x7f2c680026d0 WARN v4l2 gstv4l2object.c:3051:gst_v4l2_object_get_nearest_size:<nvv4l2decoder29:sink> Unable to try format: Unknown error -1
0:03:25.919665162 30071 0x7f2c680026d0 WARN v4l2 gstv4l2object.c:2937:gst_v4l2_object_probe_caps_for_format:<nvv4l2decoder29:sink> Could not probe minimum capture size for pixelformat VP80
0:03:25.919679666 30071 0x7f2c680026d0 WARN v4l2 gstv4l2object.c:3051:gst_v4l2_object_get_nearest_size:<nvv4l2decoder29:sink> Unable to try format: Unknown error -1
0:03:25.919694451 30071 0x7f2c680026d0 WARN v4l2 gstv4l2object.c:2943:gst_v4l2_object_probe_caps_for_format:<nvv4l2decoder29:sink> Could not probe maximum capture size for pixelformat VP80
0:03:25.919725768 30071 0x7f2c680026d0 WARN v4l2 gstv4l2object.c:3051:gst_v4l2_object_get_nearest_size:<nvv4l2decoder29:sink> Unable to try format: Unknown error -1
0:03:25.919740877 30071 0x7f2c680026d0 WARN v4l2 gstv4l2object.c:2937:gst_v4l2_object_probe_caps_for_format:<nvv4l2decoder29:sink> Could not probe minimum capture size for pixelformat H264
0:03:25.919755280 30071 0x7f2c680026d0 WARN v4l2 gstv4l2object.c:3051:gst_v4l2_object_get_nearest_size:<nvv4l2decoder29:sink> Unable to try format: Unknown error -1
0:03:25.919770400 30071 0x7f2c680026d0 WARN v4l2 gstv4l2object.c:2943:gst_v4l2_object_probe_caps_for_format:<nvv4l2decoder29:sink> Could not probe maximum capture size for pixelformat H264
0:03:25.919862135 30071 0x7f2c680026d0 WARN v4l2 gstv4l2object.c:3051:gst_v4l2_object_get_nearest_size:<nvv4l2decoder29:src> Unable to try format: Unknown error -1
0:03:25.919878643 30071 0x7f2c680026d0 WARN v4l2 gstv4l2object.c:2937:gst_v4l2_object_probe_caps_for_format:<nvv4l2decoder29:src> Could not probe minimum capture size for pixelformat NM12
0:03:25.919893453 30071 0x7f2c680026d0 WARN v4l2 gstv4l2object.c:3051:gst_v4l2_object_get_nearest_size:<nvv4l2decoder29:src> Unable to try format: Unknown error -1
0:03:25.919908025 30071 0x7f2c680026d0 WARN v4l2 gstv4l2object.c:2943:gst_v4l2_object_probe_caps_for_format:<nvv4l2decoder29:src> Could not probe maximum capture size for pixelformat NM12
0:03:25.919931141 30071 0x7f2c680026d0 WARN v4l2 gstv4l2object.c:2388:gst_v4l2_object_add_interlace_mode:0x7f2c58080020 Failed to determine interlace mode
0:03:26.244276652 30071 0x7f2c680026d0 WARN v4l2videodec gstv4l2videodec.c:1685:gst_v4l2_video_dec_decide_allocation:<nvv4l2decoder29> Duration invalid, not setting latency
0:03:26.247351155 30071 0x7f2c680026d0 WARN v4l2bufferpool gstv4l2bufferpool.c:1065:gst_v4l2_buffer_pool_start:<nvv4l2decoder29:pool:src> Uncertain or not enough buffers, enabling copy threshold
0:03:26.252909052 30071 0x7f2c580034a0 WARN v4l2bufferpool gstv4l2bufferpool.c:1512:gst_v4l2_buffer_pool_dqbuf:<nvv4l2decoder29:pool:src> Driver should never set v4l2_buffer.field to ANY
I0809 13:57:33.946566 30071 captureenginescheduler.cpp:212] Enter deleteDeviceScheduler()
I0809 13:57:33.946648 30071 captureenginecontext.cpp:152] 1111111111111111111111111111111111111111
I0809 13:57:33.946681 30071 nvgstpipeline.cpp:469] AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
I0809 13:57:33.946694 30071 nvgstpipeline.cpp:478] BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
I0809 13:57:33.947454 30071 nvgstpipeline.cpp:482] CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
I0809 13:57:33.947772 30071 nvgstpipeline.cpp:490] DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
0:03:54.356493688 30071 0x7f34bc02b630 WARN rtspsrc gstrtspsrc.c:3155:on_timeout:<src> source e4faeeec, stream e4faeeec in session 0 timed out