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_PORT,
PROP_POOL,
PROP_FACTORY,
PROP_LAST
};
@ -86,6 +87,15 @@ gst_rtsp_server_class_init (GstRTSPServerClass * klass)
g_object_class_install_property (gobject_class, PROP_POOL,
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));
/**
* 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;
}
@ -197,7 +207,7 @@ gst_rtsp_server_set_session_pool (GstRTSPServer *server, GstRTSPSessionPool *poo
if (server->pool)
g_object_unref (server->pool);
if (pool)
pool = g_object_ref (pool);
g_object_ref (pool);
server->pool = pool;
}
@ -224,6 +234,54 @@ gst_rtsp_server_get_session_pool (GstRTSPServer *server)
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
gst_rtsp_server_get_property (GObject *object, guint propid,
GValue *value, GParamSpec *pspec)
@ -240,6 +298,9 @@ gst_rtsp_server_get_property (GObject *object, guint propid,
case PROP_POOL:
g_value_take_object (value, gst_rtsp_server_get_session_pool (server));
break;
case PROP_FACTORY:
g_value_take_object (value, gst_rtsp_server_get_media_factory (server));
break;
default:
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:
gst_rtsp_server_set_session_pool (server, g_value_get_object (value));
break;
case PROP_FACTORY:
gst_rtsp_server_set_media_factory (server, g_value_get_object (value));
break;
default:
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 */
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
* the connection and will run the remainder of the communication with the
* client asyncronously. */

View file

@ -34,6 +34,7 @@
#include <gst/gst.h>
#include "rtsp-session-pool.h"
#include "rtsp-media-factory.h"
#include "rtsp-client.h"
#ifndef __GST_RTSP_SERVER_H__
@ -70,6 +71,9 @@ struct _GstRTSPServer {
/* sessions on this server */
GstRTSPSessionPool *pool;
/* media factory for this server */
GstRTSPMediaFactory *factory;
};
/**
@ -86,25 +90,28 @@ struct _GstRTSPServerClass {
GstRTSPClient * (*accept_client) (GstRTSPServer *server, GIOChannel *channel);
};
GType gst_rtsp_server_get_type (void);
GType gst_rtsp_server_get_type (void);
GstRTSPServer * gst_rtsp_server_new (void);
GstRTSPServer * gst_rtsp_server_new (void);
void gst_rtsp_server_set_port (GstRTSPServer *server, gint port);
gint gst_rtsp_server_get_port (GstRTSPServer *server);
void gst_rtsp_server_set_port (GstRTSPServer *server, gint port);
gint gst_rtsp_server_get_port (GstRTSPServer *server);
void gst_rtsp_server_set_backlog (GstRTSPServer *server, gint backlog);
gint gst_rtsp_server_get_backlog (GstRTSPServer *server);
void gst_rtsp_server_set_backlog (GstRTSPServer *server, gint backlog);
gint gst_rtsp_server_get_backlog (GstRTSPServer *server);
void gst_rtsp_server_set_session_pool (GstRTSPServer *server, GstRTSPSessionPool *pool);
GstRTSPSessionPool * gst_rtsp_server_get_session_pool (GstRTSPServer *server);
void gst_rtsp_server_set_session_pool (GstRTSPServer *server, GstRTSPSessionPool *pool);
GstRTSPSessionPool * gst_rtsp_server_get_session_pool (GstRTSPServer *server);
gboolean gst_rtsp_server_io_func (GIOChannel *channel, GIOCondition condition,
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,
GstRTSPServer *server);
GIOChannel * gst_rtsp_server_get_io_channel (GstRTSPServer *server);
GSource * gst_rtsp_server_create_watch (GstRTSPServer *server);
guint gst_rtsp_server_attach (GstRTSPServer *server,
GIOChannel * gst_rtsp_server_get_io_channel (GstRTSPServer *server);
GSource * gst_rtsp_server_create_watch (GstRTSPServer *server);
guint gst_rtsp_server_attach (GstRTSPServer *server,
GMainContext *context);
G_END_DECLS