session: move session header code in session object

This commit is contained in:
Wim Taymans 2012-11-12 12:40:34 +01:00
parent 4dba434f16
commit 5b4340067a
3 changed files with 28 additions and 10 deletions

View file

@ -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) {

View file

@ -256,6 +256,30 @@ gst_rtsp_session_get_sessionid (GstRTSPSession * session)
return session->sessionid;
}
/**
* 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

View file

@ -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);