Delay on reconnect (#983)

This commit is contained in:
Mr-DaveDev
2019-08-13 20:17:33 -06:00
committed by Mr-Dave
parent 05150afc44
commit ddec009f57
2 changed files with 26 additions and 2 deletions

View File

@@ -975,6 +975,7 @@ static void netcam_rtsp_set_parms (struct context *cnt, struct rtsp_context *rts
rtsp_data->pktarray = NULL;
rtsp_data->handler_finished = TRUE;
rtsp_data->first_image = TRUE;
rtsp_data->reconnect_count = 0;
snprintf(rtsp_data->threadname, 15, "%s",_("Unknown"));
@@ -1350,7 +1351,7 @@ static void netcam_rtsp_handler_wait(struct rtsp_context *rtsp_data){
static void netcam_rtsp_handler_reconnect(struct rtsp_context *rtsp_data){
long usec_maxrate;
int framerate;
int framerate, retcd;
if ((rtsp_data->status == RTSP_CONNECTED) ||
(rtsp_data->status == RTSP_READINGIMAGE)){
@@ -1378,7 +1379,29 @@ static void netcam_rtsp_handler_reconnect(struct rtsp_context *rtsp_data){
}
rtsp_data->status = RTSP_RECONNECTING;
netcam_rtsp_connect(rtsp_data);
/*
* The retry count of 100 is arbritrary.
* We want to try many times quickly to not lose too much information
* before we go into the long wait phase
*/
retcd = netcam_rtsp_connect(rtsp_data);
if (retcd < 0){
if (rtsp_data->reconnect_count < 100){
rtsp_data->reconnect_count++;
} else if (rtsp_data->reconnect_count == 100){
MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO
,_("%s: Camera did not reconnect."), rtsp_data->cameratype);
MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO
,_("%s: Checking for camera every 10 seconds."),rtsp_data->cameratype);
rtsp_data->reconnect_count++;
SLEEP(10,0);
} else {
SLEEP(10,0);
}
} else {
rtsp_data->reconnect_count = 0;
}
}

View File

@@ -74,6 +74,7 @@ struct rtsp_context {
int v4l2_palette; /* Palette from config for v4l2 devices */
int framerate; /* Frames per second from configuration file */
long cnct_delay; /* Delay offset to prevent handler being too slow*/
int reconnect_count; /* Count of the times reconnection is tried*/
int src_fps; /* The fps provided from source*/
struct timeval frame_prev_tm; /* The time set before calling the av functions */