From 5b4340067a0bc29d8efdded823064ccdf54c3257 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 12 Nov 2012 12:40:34 +0100 Subject: [PATCH] session: move session header code in session object --- gst/rtsp-server/rtsp-client.c | 12 ++---------- gst/rtsp-server/rtsp-session.c | 24 ++++++++++++++++++++++++ gst/rtsp-server/rtsp-session.h | 2 ++ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/gst/rtsp-server/rtsp-client.c b/gst/rtsp-server/rtsp-client.c index b0a6d90..3f1efa8 100644 --- a/gst/rtsp-server/rtsp-client.c +++ b/gst/rtsp-server/rtsp-client.c @@ -310,16 +310,8 @@ send_response (GstRTSPClient * client, GstRTSPSession * session, /* add the new session header for new session ids */ if (session) { - gchar *str; - - if (session->timeout != 60) - str = - g_strdup_printf ("%s; timeout=%d", session->sessionid, - session->timeout); - else - str = g_strdup (session->sessionid); - - gst_rtsp_message_take_header (response, GST_RTSP_HDR_SESSION, str); + gst_rtsp_message_take_header (response, GST_RTSP_HDR_SESSION, + gst_rtsp_session_get_header (session)); } if (gst_debug_category_get_threshold (rtsp_client_debug) >= GST_LEVEL_LOG) { diff --git a/gst/rtsp-server/rtsp-session.c b/gst/rtsp-server/rtsp-session.c index 6b93bee..a6a2409 100644 --- a/gst/rtsp-server/rtsp-session.c +++ b/gst/rtsp-server/rtsp-session.c @@ -257,6 +257,30 @@ gst_rtsp_session_get_sessionid (GstRTSPSession * session) } /** + * gst_rtsp_session_get_header: + * @session: a #GstRTSPSession + * + * Get the string that can be placed in the Session header field. + * + * Returns: (transfer full): the Session header of @session. g_free() after usage. + */ +gchar * +gst_rtsp_session_get_header (GstRTSPSession * session) +{ + gchar *result; + + g_return_val_if_fail (GST_IS_RTSP_SESSION (session), NULL); + + if (session->timeout != 60) + result = g_strdup_printf ("%s; timeout=%d", session->sessionid, + session->timeout); + else + result = g_strdup (session->sessionid); + + return result; +} + +/** * gst_rtsp_session_set_timeout: * @session: a #GstRTSPSession * @timeout: the new timeout diff --git a/gst/rtsp-server/rtsp-session.h b/gst/rtsp-server/rtsp-session.h index ced2251..efac74c 100644 --- a/gst/rtsp-server/rtsp-session.h +++ b/gst/rtsp-server/rtsp-session.h @@ -79,6 +79,8 @@ GstRTSPSession * gst_rtsp_session_new (const gchar *sessi const gchar * gst_rtsp_session_get_sessionid (GstRTSPSession *session); +gchar * gst_rtsp_session_get_header (GstRTSPSession *session); + void gst_rtsp_session_set_timeout (GstRTSPSession *session, guint timeout); guint gst_rtsp_session_get_timeout (GstRTSPSession *session); -- 2.7.4