Commit 68ae457e authored by Benjamin Berg's avatar Benjamin Berg
Browse files

wfd: Fix a number of memory leaks

Some of the getters return references, others don't. Fix the various
cases so we don't leak any objects.
parent 0fa9faa8
......@@ -59,6 +59,8 @@ wfd_client_finalize (GObject *object)
{
WfdClient *self = (WfdClient *) object;
g_debug ("WfdClient: Finalize");
g_clear_pointer (&self->params, wfd_params_free);
if (self->keep_alive_source_id)
......@@ -196,7 +198,9 @@ wfd_client_configure_client_media (GstRTSPClient * client,
GstRTSPContext * ctx)
{
WfdClient *self = WFD_CLIENT (client);
g_autoptr(GstElement) element;
g_autoptr(GstRTSPThreadPool) thread_pool = NULL;
g_autoptr(GstRTSPThread) thread = NULL;
g_autoptr(GstElement) element = NULL;
gboolean res;
g_return_val_if_fail (self->params->selected_codec, FALSE);
......@@ -207,7 +211,9 @@ wfd_client_configure_client_media (GstRTSPClient * client,
res = GST_RTSP_CLIENT_CLASS (wfd_client_parent_class)->configure_client_media (client, media, stream, ctx);
gst_rtsp_media_prepare (media, gst_rtsp_thread_pool_get_thread (gst_rtsp_client_get_thread_pool (client), GST_RTSP_THREAD_TYPE_MEDIA, ctx));
thread_pool = gst_rtsp_client_get_thread_pool (client);
thread = gst_rtsp_thread_pool_get_thread (thread_pool, GST_RTSP_THREAD_TYPE_MEDIA, ctx);
gst_rtsp_media_prepare (media, g_steal_pointer (&thread));
return res;
}
......
......@@ -362,7 +362,8 @@ wfd_media_factory_construct (GstRTSPMediaFactory *factory, const GstRTSPUrl *url
GstRTSPContext *ctx;
GstRTSPMedia *res;
GstRTSPClient *client;
GstRTSPStream * stream;
GstRTSPStream *stream;
g_autoptr(GstSDPMessage) sdp = NULL;
res = GST_RTSP_MEDIA_FACTORY_CLASS (wfd_media_factory_parent_class)->construct (factory, url);
......@@ -370,10 +371,8 @@ wfd_media_factory_construct (GstRTSPMediaFactory *factory, const GstRTSPUrl *url
ctx = gst_rtsp_context_get_current ();
client = ctx->client;
g_autoptr(GstSDPMessage) sdp = NULL;
sdp = GST_RTSP_CLIENT_GET_CLASS (client)->create_sdp (client, res);
g_debug ("WfdMedia init: Got %d streams", gst_rtsp_media_n_streams (res));
stream = gst_rtsp_media_get_stream (res, 0);
gst_rtsp_stream_set_control (stream, "streamid=0");
g_debug ("WfdMedia init: Got %d streams", gst_rtsp_media_n_streams (res));
......
......@@ -81,14 +81,22 @@ wfd_server_create_client (GstRTSPServer *server)
{
g_autoptr(WfdClient) client;
GstRTSPClient *rtsp_client;
g_autoptr(GstRTSPSessionPool) session_pool = NULL;
g_autoptr(GstRTSPMountPoints) mount_points = NULL;
g_autoptr(GstRTSPAuth) auth = NULL;
g_autoptr(GstRTSPThreadPool) thread_pool = NULL;
client = wfd_client_new ();
rtsp_client = GST_RTSP_CLIENT (client);
gst_rtsp_client_set_session_pool (rtsp_client, gst_rtsp_server_get_session_pool (server));
gst_rtsp_client_set_mount_points (rtsp_client, gst_rtsp_server_get_mount_points (server));
gst_rtsp_client_set_auth (rtsp_client, gst_rtsp_server_get_auth (server));
gst_rtsp_client_set_thread_pool (rtsp_client, gst_rtsp_server_get_thread_pool (server));
session_pool = gst_rtsp_server_get_session_pool (server);
gst_rtsp_client_set_session_pool (rtsp_client, session_pool);
mount_points = gst_rtsp_server_get_mount_points (server);
gst_rtsp_client_set_mount_points (rtsp_client, mount_points);
auth = gst_rtsp_server_get_auth (server);
gst_rtsp_client_set_auth (rtsp_client, auth);
thread_pool = gst_rtsp_server_get_thread_pool (server);
gst_rtsp_client_set_thread_pool (rtsp_client, thread_pool);
return GST_RTSP_CLIENT (g_steal_pointer (&client));
}
......@@ -162,7 +170,7 @@ static gboolean
clean_pool (gpointer user_data)
{
GstRTSPServer *server = GST_RTSP_SERVER (user_data);
GstRTSPSessionPool *pool;
g_autoptr(GstRTSPSessionPool) pool = NULL;
pool = gst_rtsp_server_get_session_pool (server);
gst_rtsp_session_pool_cleanup (pool);
......@@ -184,7 +192,7 @@ static void
wfd_server_init (WfdServer *self)
{
g_autoptr(WfdMediaFactory) factory = NULL;
GstRTSPMountPoints *mount_points;
g_autoptr(GstRTSPMountPoints) mount_points = NULL;
/* We need to clean up the pool regularly as it does not happen
* automatically. */
self->clean_pool_source_id = g_timeout_add_seconds (2, clean_pool, self);
......@@ -223,11 +231,15 @@ void
wfd_server_purge (WfdServer *self)
{
GstRTSPServer *server = GST_RTSP_SERVER (self);
GstRTSPSessionPool *session_pool;
g_autoptr(GstRTSPSessionPool) session_pool = NULL;
g_autoptr(GstRTSPThreadPool) thread_pool = NULL;
session_pool = gst_rtsp_server_get_session_pool (server);
gst_rtsp_session_pool_filter (session_pool, pool_filter_remove_cb, NULL);
gst_rtsp_server_client_filter (server, client_filter_remove_cb, NULL);
thread_pool = gst_rtsp_server_get_thread_pool (server);
gst_rtsp_session_pool_filter (session_pool, pool_filter_remove_cb, NULL);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment