@@ -1144,7 +1144,7 @@ static int netcam_rtsp_read_image(struct rtsp_context *rtsp_data)
1144
1144
{
1145
1145
1146
1146
int size_decoded ;
1147
- int retcd , errcnt , haveimage ;
1147
+ int retcd , nodata , haveimage ;
1148
1148
char errstr [128 ];
1149
1149
netcam_buff * xchg ;
1150
1150
@@ -1164,32 +1164,30 @@ static int netcam_rtsp_read_image(struct rtsp_context *rtsp_data)
1164
1164
rtsp_data -> status = RTSP_READINGIMAGE ;
1165
1165
rtsp_data -> img_recv -> used = 0 ;
1166
1166
size_decoded = 0 ;
1167
- errcnt = 0 ;
1167
+ nodata = 0 ;
1168
1168
haveimage = FALSE;
1169
1169
1170
- /* We allow for one failure on the av_read_frame. Upon the second failure, we exit the function
1171
- * with a fail code to either end the program or possibly try to reconnnect to camera
1172
- */
1173
- while ((!haveimage ) && (!rtsp_data -> interrupted )) {
1170
+ while ((haveimage == FALSE) && (rtsp_data -> interrupted == FALSE)) {
1174
1171
retcd = av_read_frame (rtsp_data -> format_context , rtsp_data -> packet_recv );
1175
- if (retcd < 0 ) {
1176
- errcnt ++ ;
1177
- }
1178
- if ((rtsp_data -> interrupted ) || (errcnt > 1 )) {
1172
+ /* The 2000 for nodata tries is arbritrary*/
1173
+ if ((rtsp_data -> interrupted ) || (retcd < 0 ) || (nodata > 2000 )) {
1179
1174
if (rtsp_data -> interrupted ) {
1180
1175
MOTION_LOG (INF , TYPE_NETCAM , NO_ERRNO
1181
1176
,_ ("%s: Interrupted" ),rtsp_data -> cameratype );
1182
- } else {
1177
+ } else if ( retcd < 0 ) {
1183
1178
av_strerror (retcd , errstr , sizeof (errstr ));
1184
1179
MOTION_LOG (INF , TYPE_NETCAM , NO_ERRNO
1185
1180
,_ ("%s: av_read_frame: %s" )
1186
1181
,rtsp_data -> cameratype , errstr );
1182
+ } else {
1183
+ MOTION_LOG (INF , TYPE_NETCAM , NO_ERRNO
1184
+ ,_ ("%s: Excessive tries to get data from camera %d" )
1185
+ ,rtsp_data -> cameratype , nodata );
1187
1186
}
1188
1187
netcam_rtsp_free_pkt (rtsp_data );
1189
1188
netcam_rtsp_close_context (rtsp_data );
1190
1189
return -1 ;
1191
1190
} else {
1192
- errcnt = 0 ;
1193
1191
if (rtsp_data -> packet_recv -> stream_index == rtsp_data -> video_stream_index ) {
1194
1192
/* For a high resolution pass-through we don't decode the image */
1195
1193
if (rtsp_data -> high_resolution && rtsp_data -> passthrough ) {
@@ -1205,6 +1203,7 @@ static int netcam_rtsp_read_image(struct rtsp_context *rtsp_data)
1205
1203
haveimage = TRUE;
1206
1204
} else if (size_decoded == 0 ) {
1207
1205
/* Did not fail, just didn't get anything. Try again */
1206
+ nodata ++ ;
1208
1207
netcam_rtsp_free_pkt (rtsp_data );
1209
1208
rtsp_data -> packet_recv = my_packet_alloc (rtsp_data -> packet_recv );
1210
1209
} else {
0 commit comments