summaryrefslogtreecommitdiff
path: root/gst/rtsp-server/rtsp-client.c
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2014-07-08 12:36:12 +0200
committerWim Taymans <wtaymans@redhat.com>2014-07-08 14:46:13 +0200
commit5aec4af1b96ef5bddfc02a015e9cec3488c89f4a (patch)
tree20af1e7997b81087978be3f5430957ebe5bc33ee /gst/rtsp-server/rtsp-client.c
parentfc6fa3f16a9f98e477442dd2630602e6ddffe266 (diff)
client: manage media in session as a last step
Once we manage a media in a session, we can't unmanage it anymore without destroying it. Therefore, first check everything before we manage the media, otherwise if something is wrong we have no way to unmanage the media. If we created a new session and something went wrong, remove the session again. Fixes a leak in the unit test.
Diffstat (limited to 'gst/rtsp-server/rtsp-client.c')
-rw-r--r--gst/rtsp-server/rtsp-client.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/gst/rtsp-server/rtsp-client.c b/gst/rtsp-server/rtsp-client.c
index 47c9657..46da780 100644
--- a/gst/rtsp-server/rtsp-client.c
+++ b/gst/rtsp-server/rtsp-client.c
@@ -1770,6 +1770,7 @@ handle_setup_request (GstRTSPClient * client, GstRTSPContext * ctx)
GstRTSPClientClass *klass;
gchar *path, *control;
gint matched;
+ gboolean new_session = FALSE;
if (!ctx->uri)
goto no_uri;
@@ -1842,6 +1843,7 @@ handle_setup_request (GstRTSPClient * client, GstRTSPContext * ctx)
/* make sure this client is closed when the session is closed */
client_watch_session (client, session);
+ new_session = TRUE;
/* signal new session */
g_signal_emit (client, gst_rtsp_client_signals[SIGNAL_NEW_SESSION], 0,
session);
@@ -1849,18 +1851,6 @@ handle_setup_request (GstRTSPClient * client, GstRTSPContext * ctx)
ctx->session = session;
}
- if (sessmedia == NULL) {
- /* manage the media in our session now, if not done already */
- sessmedia = gst_rtsp_session_manage_media (session, path, media);
- /* if we stil have no media, error */
- if (sessmedia == NULL)
- goto sessmedia_unavailable;
- } else {
- g_object_unref (media);
- }
-
- ctx->sessmedia = sessmedia;
-
if (!klass->configure_client_media (client, media, stream, ctx))
goto configure_media_failed_no_reply;
@@ -1881,6 +1871,18 @@ handle_setup_request (GstRTSPClient * client, GstRTSPContext * ctx)
goto keymgmt_error;
}
+ if (sessmedia == NULL) {
+ /* manage the media in our session now, if not done already */
+ sessmedia = gst_rtsp_session_manage_media (session, path, media);
+ /* if we stil have no media, error */
+ if (sessmedia == NULL)
+ goto sessmedia_unavailable;
+ } else {
+ g_object_unref (media);
+ }
+
+ ctx->sessmedia = sessmedia;
+
/* set in the session media transport */
trans = gst_rtsp_session_media_set_transport (sessmedia, stream, ct);
@@ -2014,6 +2016,8 @@ keymgmt_error:
cleanup_transport:
gst_rtsp_transport_free (ct);
cleanup_session:
+ if (new_session)
+ gst_rtsp_session_pool_remove (priv->session_pool, session);
g_object_unref (session);
cleanup_path:
g_free (path);