client: add state to current thread
authorWim Taymans <wim.taymans@collabora.co.uk>
Tue, 9 Jul 2013 14:01:29 +0000 (16:01 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Tue, 9 Jul 2013 14:01:29 +0000 (16:01 +0200)
Add the client to the ClientState object.
Place the ClientState on the current thread.

gst/rtsp-server/rtsp-client.c
gst/rtsp-server/rtsp-client.h

index 542c44d..6af4058 100644 (file)
@@ -1780,6 +1780,22 @@ client_session_finalized (GstRTSPClient * client, GstRTSPSession * session)
   }
 }
 
+static GPrivate state_key;
+
+/**
+ * gst_rtsp_client_state_get_current:
+ *
+ * Get the current #GstRTSPClientState. This object is retrieved from the
+ * current thread that is handling the request for a client.
+ *
+ * Returns: a #GstRTSPClientState
+ */
+GstRTSPClientState *
+gst_rtsp_client_state_get_current (void)
+{
+  return g_private_get (&state_key);
+}
+
 static void
 handle_request (GstRTSPClient * client, GstRTSPMessage * request)
 {
@@ -1794,8 +1810,11 @@ handle_request (GstRTSPClient * client, GstRTSPMessage * request)
   GstRTSPMessage response = { 0 };
   gchar *sessid;
 
+  state.client = client;
   state.request = request;
   state.response = &response;
+  state.auth = priv->auth;
+  g_private_set (&state_key, &state);
 
   if (gst_debug_category_get_threshold (rtsp_client_debug) >= GST_LEVEL_LOG) {
     gst_rtsp_message_dump (request);
@@ -1883,6 +1902,7 @@ handle_request (GstRTSPClient * client, GstRTSPMessage * request)
   }
 
 done:
+  g_private_set (&state_key, NULL);
   if (session)
     g_object_unref (session);
   if (uri)
index d772b38..a7311c2 100644 (file)
@@ -49,6 +49,7 @@ typedef struct _GstRTSPClientPrivate GstRTSPClientPrivate;
 
 /**
  * GstRTSPClientState:
+ * @client: the client
  * @request: the complete request
  * @uri: the complete url parsed from @request
  * @method: the parsed method of @uri
@@ -64,6 +65,7 @@ typedef struct _GstRTSPClientPrivate GstRTSPClientPrivate;
  * Information passed around containing the client state of a request.
  */
 struct _GstRTSPClientState {
+  GstRTSPClient       *client;
   GstRTSPMessage      *request;
   GstRTSPUrl          *uri;
   GstRTSPMethod        method;
@@ -77,6 +79,8 @@ struct _GstRTSPClientState {
   GstRTSPMessage      *response;
 };
 
+GstRTSPClientState * gst_rtsp_client_state_get_current   (void);
+
 /**
  * GstRTSPClientSendFunc:
  * @client: a #GstRTSPClient