Allow setting a custom media factory for a server

This commit is contained in:
Wim Taymans 2009-01-20 19:47:07 +01:00 committed by Wim Taymans
parent 94d60a8611
commit ddf17f338b
2 changed files with 87 additions and 13 deletions

View file

@ -31,6 +31,7 @@ enum
PROP_BACKLOG, PROP_BACKLOG,
PROP_PORT, PROP_PORT,
PROP_POOL, PROP_POOL,
PROP_FACTORY,
PROP_LAST PROP_LAST
}; };
@ -86,6 +87,15 @@ gst_rtsp_server_class_init (GstRTSPServerClass * klass)
g_object_class_install_property (gobject_class, PROP_POOL, g_object_class_install_property (gobject_class, PROP_POOL,
g_param_spec_object ("pool", "Pool", "The session pool to use for client session", g_param_spec_object ("pool", "Pool", "The session pool to use for client session",
GST_TYPE_RTSP_SESSION_POOL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); GST_TYPE_RTSP_SESSION_POOL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstRTSPServer::factory
*
* The media factory to use for this server. By default the server has no
* media factories and thus cannot map urls to media streams.
*/
g_object_class_install_property (gobject_class, PROP_POOL,
g_param_spec_object ("factory", "Factory", "The media factory to use for client session",
GST_TYPE_RTSP_MEDIA_FACTORY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
klass->accept_client = gst_rtsp_server_accept_client; klass->accept_client = gst_rtsp_server_accept_client;
} }
@ -197,7 +207,7 @@ gst_rtsp_server_set_session_pool (GstRTSPServer *server, GstRTSPSessionPool *poo
if (server->pool) if (server->pool)
g_object_unref (server->pool); g_object_unref (server->pool);
if (pool) if (pool)
pool = g_object_ref (pool); g_object_ref (pool);
server->pool = pool; server->pool = pool;
} }
@ -224,6 +234,54 @@ gst_rtsp_server_get_session_pool (GstRTSPServer *server)
return result; return result;
} }
/**
* gst_rtsp_server_set_media_factory:
* @server: a #GstRTSPServer
* @factory: a #GstRTSPMediaFactory
*
* configure @factory to be used as the media factory of @server.
*/
void
gst_rtsp_server_set_media_factory (GstRTSPServer *server, GstRTSPMediaFactory *factory)
{
GstRTSPMediaFactory *old;
g_return_if_fail (GST_IS_RTSP_SERVER (server));
old = server->factory;
if (old != factory) {
if (factory)
g_object_ref (factory);
server->factory = factory;
if (old)
g_object_unref (old);
}
}
/**
* gst_rtsp_server_get_media_factory:
* @server: a #GstRTSPServer
*
* Get the #GstRTSPMediaFactory used as the media factory of @server.
*
* Returns: the #GstRTSPMediaFactory of @server. g_object_unref() after
* usage.
*/
GstRTSPMediaFactory *
gst_rtsp_server_get_media_factory (GstRTSPServer *server)
{
GstRTSPMediaFactory *result;
g_return_val_if_fail (GST_IS_RTSP_SERVER (server), NULL);
if ((result = server->factory))
g_object_ref (result);
return result;
}
static void static void
gst_rtsp_server_get_property (GObject *object, guint propid, gst_rtsp_server_get_property (GObject *object, guint propid,
GValue *value, GParamSpec *pspec) GValue *value, GParamSpec *pspec)
@ -240,6 +298,9 @@ gst_rtsp_server_get_property (GObject *object, guint propid,
case PROP_POOL: case PROP_POOL:
g_value_take_object (value, gst_rtsp_server_get_session_pool (server)); g_value_take_object (value, gst_rtsp_server_get_session_pool (server));
break; break;
case PROP_FACTORY:
g_value_take_object (value, gst_rtsp_server_get_media_factory (server));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
} }
@ -261,6 +322,9 @@ gst_rtsp_server_set_property (GObject *object, guint propid,
case PROP_POOL: case PROP_POOL:
gst_rtsp_server_set_session_pool (server, g_value_get_object (value)); gst_rtsp_server_set_session_pool (server, g_value_get_object (value));
break; break;
case PROP_FACTORY:
gst_rtsp_server_set_media_factory (server, g_value_get_object (value));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
} }
@ -375,6 +439,9 @@ gst_rtsp_server_accept_client (GstRTSPServer *server, GIOChannel *channel)
/* set the session pool that this client should use */ /* set the session pool that this client should use */
gst_rtsp_client_set_session_pool (client, server->pool); gst_rtsp_client_set_session_pool (client, server->pool);
/* set the session pool that this client should use */
gst_rtsp_client_set_media_factory (client, server->factory);
/* accept connections for that client, this function returns after accepting /* accept connections for that client, this function returns after accepting
* the connection and will run the remainder of the communication with the * the connection and will run the remainder of the communication with the
* client asyncronously. */ * client asyncronously. */

View file

@ -34,6 +34,7 @@
#include <gst/gst.h> #include <gst/gst.h>
#include "rtsp-session-pool.h" #include "rtsp-session-pool.h"
#include "rtsp-media-factory.h"
#include "rtsp-client.h" #include "rtsp-client.h"
#ifndef __GST_RTSP_SERVER_H__ #ifndef __GST_RTSP_SERVER_H__
@ -70,6 +71,9 @@ struct _GstRTSPServer {
/* sessions on this server */ /* sessions on this server */
GstRTSPSessionPool *pool; GstRTSPSessionPool *pool;
/* media factory for this server */
GstRTSPMediaFactory *factory;
}; };
/** /**
@ -99,6 +103,9 @@ gint gst_rtsp_server_get_backlog (GstRTSPServer *server
void gst_rtsp_server_set_session_pool (GstRTSPServer *server, GstRTSPSessionPool *pool); void gst_rtsp_server_set_session_pool (GstRTSPServer *server, GstRTSPSessionPool *pool);
GstRTSPSessionPool * gst_rtsp_server_get_session_pool (GstRTSPServer *server); GstRTSPSessionPool * gst_rtsp_server_get_session_pool (GstRTSPServer *server);
void gst_rtsp_server_set_media_factory (GstRTSPServer *server, GstRTSPMediaFactory *factory);
GstRTSPMediaFactory * gst_rtsp_server_get_media_factory (GstRTSPServer *server);
gboolean gst_rtsp_server_io_func (GIOChannel *channel, GIOCondition condition, gboolean gst_rtsp_server_io_func (GIOChannel *channel, GIOCondition condition,
GstRTSPServer *server); GstRTSPServer *server);