session: move session header code in session object
authorWim Taymans <wim.taymans@collabora.co.uk>
Mon, 12 Nov 2012 11:40:34 +0000 (12:40 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 12 Nov 2012 11:40:34 +0000 (12:40 +0100)
gst/rtsp-server/rtsp-client.c
gst/rtsp-server/rtsp-session.c
gst/rtsp-server/rtsp-session.h

index b0a6d90..3f1efa8 100644 (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) {
index 6b93bee..a6a2409 100644 (file)
@@ -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
index ced2251..efac74c 100644 (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);