My code is largely based on test2.cpp sample referenced here.
Upon camera disconnect, the appsink eos callback is fired.
I am trying to repeatedly set the pipeline status to NULL and then to PLAYBACK until state change success is received.
Is there a standard way of dealing with camera disconnects?
Thank you for the response.
In the code below, I use ping to wait for the disconnected camera to come back and then switch the pipeline to PLAYING. This goes fine. The camera comes back and the pipeline switches into PLAYING mode successfully. But I see no streaming. The new_buffer callback is not occuring.
static void appsink_eos(GstAppSink * appsink, gpointer user_data)
{
printf("app sink received eos\n");
eos = 1;
delete restart_handle;
restart_handle = new std::thread{restart_thread};
restart_handle->detach();
}
void restart_thread()
{
wait_for_camera_ON( ip_from_url(g_camera_url));
std::cout << "camera back ON." << std::endl;
sleep(40);
std::cout << "setting pipeline to PLAYING" << std::endl;
eos = 1;
gst_element_set_state((GstElement*)gst_pipeline, GST_STATE_PLAYING);
while(eos != 0)
{
GstStateChangeReturn ret = gst_element_get_state((GstElement*)gst_pipeline, nullptr,
nullptr, GST_CLOCK_TIME_NONE);
if(ret == GST_STATE_CHANGE_SUCCESS)
{
std::cout << "state change success." << std::endl;
eos = 0;
break;
}
else if(ret == GST_STATE_CHANGE_FAILURE)
{
std::cout << "state change failure.. stopping" << std::endl;
//end_capture();
exit(0);
}
else
{
std::cout << "Intermediate return code.. waiting 5 more secs.." << std::endl;
sleep(5);
}
}
}
This is the output:
Using launch string: rtspsrc location=rtsp://admin:mercury_123@192.168.1.23:554/Streaming/Channels/101 ! decodebin ! nvvidconv ! video/x-raw, format=I420 ! appsink name=mysink
nvbuf_utils: Could not get EGL display connection
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
PID=12176 frames#25 stats=0 FPS : 33 MB : 0 %
PID=12176 frames#50 stats=25 FPS : 33 MB : 9 %
PID=12176 frames#75 stats=24 FPS : 33 MB : 9 %
PID=12176 frames#100 stats=24 FPS : 34 MB : 9 %
PID=12176 frames#125 stats=24 FPS : 34 MB : 9 %
PID=12176 frames#150 stats=25 FPS : 34 MB : 9 %
PID=12176 frames#175 stats=25 FPS : 34 MB : 8 %
PID=12176 frames#200 stats=0 FPS : 32 MB : 0 %
app sink received eos
waiting on camera:192.168.1.23
camera back ON.
setting pipeline to PLAYING
state change success.
(--- long wait without any output here --- )
^C
I am not setting the pipeline to NULL in the modified logic.
Do you have any suggestions here?
Users in the forum is more experienced in various gstreamer usecases.
Once you get it working with avdec_h264, it should work fine to replace it with nvv4l2decoder.
Hi,
The sample is from me and I may lack of experience about this usecase. Would be great if you can get support from gstreamer forum and share the solution here. To help me learn from your experience. Thank you.