summaryrefslogtreecommitdiffstats
path: root/gst
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-02-04 11:38:30 +0100
committerWim Taymans <wim.taymans@collabora.co.uk>2009-02-04 11:38:30 +0100
commit1dc5c341432f17f5b33c055fc5eae66ef52840f6 (patch)
tree45bb7113a3e194c7ccf55d9543a4086fe42811b2 /gst
parent7353cdc02960b207433a31489c91f618b15f725d (diff)
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.
Diffstat (limited to 'gst')
-rw-r--r--gst/rtsp/gstrtspsrc.c25
-rw-r--r--gst/rtsp/gstrtspsrc.h1
2 files changed, 15 insertions, 11 deletions
diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c
index e677c991..02970c42 100644
--- a/gst/rtsp/gstrtspsrc.c
+++ b/gst/rtsp/gstrtspsrc.c
@@ -2911,6 +2911,7 @@ gst_rtspsrc_loop_udp (GstRTSPSrc * src)
gst_rtsp_connection_connect (src->connection, src->ptcp_timeout);
if (res < 0)
goto connect_error;
+ src->connected = TRUE;
continue;
default:
goto receive_error;
@@ -3025,6 +3026,7 @@ connect_error:
{
gchar *str = gst_rtsp_strresult (res);
+ src->connected = FALSE;
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ_WRITE, (NULL),
("Could not connect to server. (%s)", str));
g_free (str);
@@ -3471,6 +3473,8 @@ receive_error:
gst_rtsp_connection_connect (src->connection,
src->ptcp_timeout)) == 0)
goto again;
+
+ src->connected = FALSE;
}
/* only try once after reconnect, then fallthrough and error out */
default:
@@ -3978,8 +3982,10 @@ gst_rtspsrc_setup_streams (GstRTSPSrc * src)
gst_rtsp_message_get_header (&response, GST_RTSP_HDR_TRANSPORT,
&resptrans, 0);
- if (!resptrans)
+ if (!resptrans) {
+ gst_rtspsrc_stream_free_udp (stream);
goto no_transport;
+ }
/* parse transport, go to next stream on parse error */
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)
goto could_not_connect;
+ src->connected = TRUE;
+
/* create OPTIONS */
GST_DEBUG_OBJECT (src, "create options...");
res =
@@ -4238,6 +4246,7 @@ restart:
gst_rtsp_connection_close (src->connection);
gst_rtsp_connection_free (src->connection);
src->connection = NULL;
+ src->connected = FALSE;
gst_rtsp_message_unset (&request);
gst_rtsp_message_unset (&response);
@@ -4375,6 +4384,7 @@ cleanup_error:
GST_DEBUG_OBJECT (src, "free connection");
gst_rtsp_connection_free (src->connection);
src->connection = NULL;
+ src->connected = FALSE;
}
GST_RTSP_STATE_UNLOCK (src);
gst_rtsp_message_unset (&request);
@@ -4436,7 +4446,7 @@ gst_rtspsrc_close (GstRTSPSrc * src)
GST_DEBUG_OBJECT (src, "stop connection flush");
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 */
res =
gst_rtsp_message_init_request (&request, GST_RTSP_TEARDOWN,
@@ -4457,12 +4467,11 @@ gst_rtspsrc_close (GstRTSPSrc * src)
/* close connection */
GST_DEBUG_OBJECT (src, "closing connection...");
- if ((res = gst_rtsp_connection_close (src->connection)) < 0)
- goto close_failed;
-
+ gst_rtsp_connection_close (src->connection);
/* free connection */
gst_rtsp_connection_free (src->connection);
src->connection = NULL;
+ src->connected = FALSE;
done:
/* cleanup */
@@ -4489,12 +4498,6 @@ send_error:
("Could not send message."));
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:
diff --git a/gst/rtsp/gstrtspsrc.h b/gst/rtsp/gstrtspsrc.h
index 2f16cf0f..95dd9869 100644
--- a/gst/rtsp/gstrtspsrc.h
+++ b/gst/rtsp/gstrtspsrc.h
@@ -204,6 +204,7 @@ struct _GstRTSPSrc {
gulong session_ptmap_id;
GstRTSPConnection *connection;
+ gboolean connected;
/* a list of RTSP extensions as GstElement */
GstRTSPExtensionList *extensions;