client: add state to current thread

Add the client to the ClientState object.
Place the ClientState on the current thread.
This commit is contained in:
Wim Taymans 2013-07-09 16:01:29 +02:00
parent 0499a1ec7d
commit c9d6455ad3
2 changed files with 24 additions and 0 deletions

View 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)

View 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