mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
rtspsrc: Keep track of connected state
Keep track of the state of the connection and don't try to send TEARDOWN when the server has closed the connection.
This commit is contained in:
parent
7353cdc029
commit
1dc5c34143
2 changed files with 15 additions and 11 deletions
|
@ -2911,6 +2911,7 @@ gst_rtspsrc_loop_udp (GstRTSPSrc * src)
|
||||||
gst_rtsp_connection_connect (src->connection, src->ptcp_timeout);
|
gst_rtsp_connection_connect (src->connection, src->ptcp_timeout);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
goto connect_error;
|
goto connect_error;
|
||||||
|
src->connected = TRUE;
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
goto receive_error;
|
goto receive_error;
|
||||||
|
@ -3025,6 +3026,7 @@ connect_error:
|
||||||
{
|
{
|
||||||
gchar *str = gst_rtsp_strresult (res);
|
gchar *str = gst_rtsp_strresult (res);
|
||||||
|
|
||||||
|
src->connected = FALSE;
|
||||||
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ_WRITE, (NULL),
|
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ_WRITE, (NULL),
|
||||||
("Could not connect to server. (%s)", str));
|
("Could not connect to server. (%s)", str));
|
||||||
g_free (str);
|
g_free (str);
|
||||||
|
@ -3471,6 +3473,8 @@ receive_error:
|
||||||
gst_rtsp_connection_connect (src->connection,
|
gst_rtsp_connection_connect (src->connection,
|
||||||
src->ptcp_timeout)) == 0)
|
src->ptcp_timeout)) == 0)
|
||||||
goto again;
|
goto again;
|
||||||
|
|
||||||
|
src->connected = FALSE;
|
||||||
}
|
}
|
||||||
/* only try once after reconnect, then fallthrough and error out */
|
/* only try once after reconnect, then fallthrough and error out */
|
||||||
default:
|
default:
|
||||||
|
@ -3978,8 +3982,10 @@ gst_rtspsrc_setup_streams (GstRTSPSrc * src)
|
||||||
|
|
||||||
gst_rtsp_message_get_header (&response, GST_RTSP_HDR_TRANSPORT,
|
gst_rtsp_message_get_header (&response, GST_RTSP_HDR_TRANSPORT,
|
||||||
&resptrans, 0);
|
&resptrans, 0);
|
||||||
if (!resptrans)
|
if (!resptrans) {
|
||||||
|
gst_rtspsrc_stream_free_udp (stream);
|
||||||
goto no_transport;
|
goto no_transport;
|
||||||
|
}
|
||||||
|
|
||||||
/* parse transport, go to next stream on parse error */
|
/* parse transport, go to next stream on parse error */
|
||||||
if (gst_rtsp_transport_parse (resptrans, &transport) != GST_RTSP_OK) {
|
if (gst_rtsp_transport_parse (resptrans, &transport) != GST_RTSP_OK) {
|
||||||
|
@ -4191,6 +4197,8 @@ restart:
|
||||||
gst_rtsp_connection_connect (src->connection, src->ptcp_timeout)) < 0)
|
gst_rtsp_connection_connect (src->connection, src->ptcp_timeout)) < 0)
|
||||||
goto could_not_connect;
|
goto could_not_connect;
|
||||||
|
|
||||||
|
src->connected = TRUE;
|
||||||
|
|
||||||
/* create OPTIONS */
|
/* create OPTIONS */
|
||||||
GST_DEBUG_OBJECT (src, "create options...");
|
GST_DEBUG_OBJECT (src, "create options...");
|
||||||
res =
|
res =
|
||||||
|
@ -4238,6 +4246,7 @@ restart:
|
||||||
gst_rtsp_connection_close (src->connection);
|
gst_rtsp_connection_close (src->connection);
|
||||||
gst_rtsp_connection_free (src->connection);
|
gst_rtsp_connection_free (src->connection);
|
||||||
src->connection = NULL;
|
src->connection = NULL;
|
||||||
|
src->connected = FALSE;
|
||||||
|
|
||||||
gst_rtsp_message_unset (&request);
|
gst_rtsp_message_unset (&request);
|
||||||
gst_rtsp_message_unset (&response);
|
gst_rtsp_message_unset (&response);
|
||||||
|
@ -4375,6 +4384,7 @@ cleanup_error:
|
||||||
GST_DEBUG_OBJECT (src, "free connection");
|
GST_DEBUG_OBJECT (src, "free connection");
|
||||||
gst_rtsp_connection_free (src->connection);
|
gst_rtsp_connection_free (src->connection);
|
||||||
src->connection = NULL;
|
src->connection = NULL;
|
||||||
|
src->connected = FALSE;
|
||||||
}
|
}
|
||||||
GST_RTSP_STATE_UNLOCK (src);
|
GST_RTSP_STATE_UNLOCK (src);
|
||||||
gst_rtsp_message_unset (&request);
|
gst_rtsp_message_unset (&request);
|
||||||
|
@ -4436,7 +4446,7 @@ gst_rtspsrc_close (GstRTSPSrc * src)
|
||||||
GST_DEBUG_OBJECT (src, "stop connection flush");
|
GST_DEBUG_OBJECT (src, "stop connection flush");
|
||||||
gst_rtsp_connection_flush (src->connection, FALSE);
|
gst_rtsp_connection_flush (src->connection, FALSE);
|
||||||
|
|
||||||
if (src->methods & (GST_RTSP_PLAY | GST_RTSP_TEARDOWN)) {
|
if (src->methods & (GST_RTSP_PLAY | GST_RTSP_TEARDOWN) && src->connected) {
|
||||||
/* do TEARDOWN */
|
/* do TEARDOWN */
|
||||||
res =
|
res =
|
||||||
gst_rtsp_message_init_request (&request, GST_RTSP_TEARDOWN,
|
gst_rtsp_message_init_request (&request, GST_RTSP_TEARDOWN,
|
||||||
|
@ -4457,12 +4467,11 @@ gst_rtspsrc_close (GstRTSPSrc * src)
|
||||||
|
|
||||||
/* close connection */
|
/* close connection */
|
||||||
GST_DEBUG_OBJECT (src, "closing connection...");
|
GST_DEBUG_OBJECT (src, "closing connection...");
|
||||||
if ((res = gst_rtsp_connection_close (src->connection)) < 0)
|
gst_rtsp_connection_close (src->connection);
|
||||||
goto close_failed;
|
|
||||||
|
|
||||||
/* free connection */
|
/* free connection */
|
||||||
gst_rtsp_connection_free (src->connection);
|
gst_rtsp_connection_free (src->connection);
|
||||||
src->connection = NULL;
|
src->connection = NULL;
|
||||||
|
src->connected = FALSE;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
|
@ -4489,12 +4498,6 @@ send_error:
|
||||||
("Could not send message."));
|
("Could not send message."));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
close_failed:
|
|
||||||
{
|
|
||||||
GST_RTSP_STATE_UNLOCK (src);
|
|
||||||
GST_ELEMENT_ERROR (src, RESOURCE, CLOSE, (NULL), ("Close failed."));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* RTP-Info is of the format:
|
/* RTP-Info is of the format:
|
||||||
|
|
|
@ -204,6 +204,7 @@ struct _GstRTSPSrc {
|
||||||
gulong session_ptmap_id;
|
gulong session_ptmap_id;
|
||||||
|
|
||||||
GstRTSPConnection *connection;
|
GstRTSPConnection *connection;
|
||||||
|
gboolean connected;
|
||||||
|
|
||||||
/* a list of RTSP extensions as GstElement */
|
/* a list of RTSP extensions as GstElement */
|
||||||
GstRTSPExtensionList *extensions;
|
GstRTSPExtensionList *extensions;
|
||||||
|
|
Loading…
Reference in a new issue