From 00997d956ff6f1428c39d9c7245b8840a12749d6 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 10 Jul 2013 17:06:36 +0200 Subject: [PATCH] client: add method to configure thread pool --- gst/rtsp-server/rtsp-client.c | 60 ++++++++++++++++++++++++++++++++++++++++++- gst/rtsp-server/rtsp-client.h | 4 +++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/gst/rtsp-server/rtsp-client.c b/gst/rtsp-server/rtsp-client.c index 50d68cf..886bbbe 100644 --- a/gst/rtsp-server/rtsp-client.c +++ b/gst/rtsp-server/rtsp-client.c @@ -49,6 +49,7 @@ struct _GstRTSPClientPrivate GstRTSPSessionPool *session_pool; GstRTSPMountPoints *mount_points; GstRTSPAuth *auth; + GstRTSPThreadPool *thread_pool; /* used to cache the media in the last requested DESCRIBE so that * we can pick it up in the next SETUP immediately */ @@ -590,7 +591,7 @@ no_prepare: GST_ERROR ("client %p: can't prepare media", client); send_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, state); g_object_unref (media); - state->media = media; + state->media = NULL; g_object_unref (factory); state->factory = NULL; return NULL; @@ -2224,6 +2225,63 @@ gst_rtsp_client_get_auth (GstRTSPClient * client) } /** + * gst_rtsp_client_set_thread_pool: + * @client: a #GstRTSPClient + * @pool: a #GstRTSPThreadPool + * + * configure @pool to be used as the thread pool of @client. + */ +void +gst_rtsp_client_set_thread_pool (GstRTSPClient * client, + GstRTSPThreadPool * pool) +{ + GstRTSPClientPrivate *priv; + GstRTSPThreadPool *old; + + g_return_if_fail (GST_IS_RTSP_CLIENT (client)); + + priv = client->priv; + + if (pool) + g_object_ref (pool); + + g_mutex_lock (&priv->lock); + old = priv->thread_pool; + priv->thread_pool = pool; + g_mutex_unlock (&priv->lock); + + if (old) + g_object_unref (old); +} + +/** + * gst_rtsp_client_get_thread_pool: + * @client: a #GstRTSPClient + * + * Get the #GstRTSPThreadPool used as the thread pool of @client. + * + * Returns: (transfer full): the #GstRTSPThreadPool of @client. g_object_unref() after + * usage. + */ +GstRTSPThreadPool * +gst_rtsp_client_get_thread_pool (GstRTSPClient * client) +{ + GstRTSPClientPrivate *priv; + GstRTSPThreadPool *result; + + g_return_val_if_fail (GST_IS_RTSP_CLIENT (client), NULL); + + priv = client->priv; + + g_mutex_lock (&priv->lock); + if ((result = priv->thread_pool)) + g_object_ref (result); + g_mutex_unlock (&priv->lock); + + return result; +} + +/** * gst_rtsp_client_set_connection: * @client: a #GstRTSPClient * @conn: (transfer full): a #GstRTSPConnection diff --git a/gst/rtsp-server/rtsp-client.h b/gst/rtsp-server/rtsp-client.h index 5b6963f..c0d9629 100644 --- a/gst/rtsp-server/rtsp-client.h +++ b/gst/rtsp-server/rtsp-client.h @@ -36,6 +36,7 @@ typedef struct _GstRTSPClientPrivate GstRTSPClientPrivate; #include "rtsp-session-pool.h" #include "rtsp-session-media.h" #include "rtsp-auth.h" +#include "rtsp-thread-pool.h" #include "rtsp-token.h" #include "rtsp-sdp.h" @@ -163,6 +164,9 @@ gboolean gst_rtsp_client_get_use_client_settings (GstRTSPClient * c void gst_rtsp_client_set_auth (GstRTSPClient *client, GstRTSPAuth *auth); GstRTSPAuth * gst_rtsp_client_get_auth (GstRTSPClient *client); +void gst_rtsp_client_set_thread_pool (GstRTSPClient *client, GstRTSPThreadPool *pool); +GstRTSPThreadPool * gst_rtsp_client_get_thread_pool (GstRTSPClient *client); + gboolean gst_rtsp_client_set_connection (GstRTSPClient *client, GstRTSPConnection *conn); GstRTSPConnection * gst_rtsp_client_get_connection (GstRTSPClient *client); -- 2.7.4