rtsp: allow NULL func in filters

Passing a null function make the filters return a list of
refcounted objects.
This commit is contained in:
Wim Taymans 2013-11-15 16:35:05 +01:00
parent b2bc84cdbf
commit b0f609ce7f
4 changed files with 43 additions and 12 deletions

View file

@ -133,8 +133,8 @@ static GstRTSPResult default_params_set (GstRTSPClient * client,
GstRTSPContext * ctx);
static GstRTSPResult default_params_get (GstRTSPClient * client,
GstRTSPContext * ctx);
static gchar * default_make_path_from_uri (GstRTSPClient *client,
const GstRTSPUrl *uri);
static gchar *default_make_path_from_uri (GstRTSPClient * client,
const GstRTSPUrl * uri);
G_DEFINE_TYPE (GstRTSPClient, gst_rtsp_client, G_TYPE_OBJECT);
@ -1949,7 +1949,8 @@ handle_request (GstRTSPClient * client, GstRTSPMessage * request)
goto bad_request;
}
absolute_uristr = g_strdup_printf ("rtsp://%s%s", priv->server_ip, uristr);
absolute_uristr =
g_strdup_printf ("rtsp://%s%s", priv->server_ip, uristr);
GST_DEBUG_OBJECT (client, "absolute url: %s", absolute_uristr);
if (gst_rtsp_url_parse (absolute_uristr, &uri) != GST_RTSP_OK) {
@ -2899,6 +2900,8 @@ gst_rtsp_client_attach (GstRTSPClient * client, GMainContext * context)
* will also be added with an additional ref to the result #GList of this
* function..
*
* When @func is %NULL, #GST_RTSP_FILTER_REF will be assumed for each session.
*
* Returns: (element-type GstRTSPSession) (transfer full): a #GList with all
* sessions for which @func returned #GST_RTSP_FILTER_REF. After usage, each
* element in the #GList should be unreffed before the list is freed.
@ -2911,7 +2914,6 @@ gst_rtsp_client_session_filter (GstRTSPClient * client,
GList *result, *walk, *next;
g_return_val_if_fail (GST_IS_RTSP_CLIENT (client), NULL);
g_return_val_if_fail (func != NULL, NULL);
priv = client->priv;
@ -2920,10 +2922,16 @@ gst_rtsp_client_session_filter (GstRTSPClient * client,
g_mutex_lock (&priv->lock);
for (walk = priv->sessions; walk; walk = next) {
GstRTSPSession *sess = walk->data;
GstRTSPFilterResult res;
next = g_list_next (walk);
switch (func (client, sess, user_data)) {
if (func)
res = func (client, sess, user_data);
else
res = GST_RTSP_FILTER_REF;
switch (res) {
case GST_RTSP_FILTER_REMOVE:
/* stop watching the session and pretent it went away */
client_cleanup_session (client, sess);

View file

@ -856,7 +856,8 @@ gst_rtsp_server_create_socket (GstRTSPServer * server,
g_clear_error (&addr_error);
break;
}
port = g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (sockaddr));
port =
g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (sockaddr));
if (port != 0) {
g_free (priv->service);
@ -1345,6 +1346,8 @@ no_source:
* will also be added with an additional ref to the result #GList of this
* function..
*
* When @func is %NULL, #GST_RTSP_FILTER_REF will be assumed for each client.
*
* Returns: (element-type GstRTSPClient) (transfer full): a #GList with all
* clients for which @func returned #GST_RTSP_FILTER_REF. After usage, each
* element in the #GList should be unreffed before the list is freed.
@ -1357,7 +1360,6 @@ gst_rtsp_server_client_filter (GstRTSPServer * server,
GList *result, *walk, *next;
g_return_val_if_fail (GST_IS_RTSP_SERVER (server), NULL);
g_return_val_if_fail (func != NULL, NULL);
priv = server->priv;
@ -1366,10 +1368,16 @@ gst_rtsp_server_client_filter (GstRTSPServer * server,
GST_RTSP_SERVER_LOCK (server);
for (walk = priv->clients; walk; walk = next) {
ClientContext *cctx = walk->data;
GstRTSPFilterResult res;
next = g_list_next (walk);
switch (func (server, cctx->client, user_data)) {
if (func)
res = func (server, cctx->client, user_data);
else
res = GST_RTSP_FILTER_REF;
switch (res) {
case GST_RTSP_FILTER_REMOVE:
/* remove client, FIXME */
break;

View file

@ -483,7 +483,14 @@ typedef struct
static gboolean
filter_func (gchar * sessionid, GstRTSPSession * sess, FilterData * data)
{
switch (data->func (data->pool, sess, data->user_data)) {
GstRTSPFilterResult res;
if (data->func)
res = data->func (data->pool, sess, data->user_data);
else
res = GST_RTSP_FILTER_REF;
switch (res) {
case GST_RTSP_FILTER_REMOVE:
return TRUE;
case GST_RTSP_FILTER_REF:
@ -515,6 +522,8 @@ filter_func (gchar * sessionid, GstRTSPSession * sess, FilterData * data)
* will also be added with an additional ref to the result GList of this
* function..
*
* When @func is %NULL, #GST_RTSP_FILTER_REF will be assumed for all sessions.
*
* Returns: (element-type GstRTSPSession) (transfer full): a GList with all
* sessions for which @func returned #GST_RTSP_FILTER_REF. After usage, each
* element in the GList should be unreffed before the list is freed.
@ -527,7 +536,6 @@ gst_rtsp_session_pool_filter (GstRTSPSessionPool * pool,
FilterData data;
g_return_val_if_fail (GST_IS_RTSP_SESSION_POOL (pool), NULL);
g_return_val_if_fail (func != NULL, NULL);
priv = pool->priv;

View file

@ -327,6 +327,8 @@ gst_rtsp_session_get_media (GstRTSPSession * sess, const gchar * path,
* will also be added with an additional ref to the result #GList of this
* function..
*
* When @func is %NULL, #GST_RTSP_FILTER_REF will be assumed for all media.
*
* Returns: (element-type GstRTSPSessionMedia) (transfer full): a GList with all
* media for which @func returned #GST_RTSP_FILTER_REF. After usage, each
* element in the #GList should be unreffed before the list is freed.
@ -339,7 +341,6 @@ gst_rtsp_session_filter (GstRTSPSession * sess,
GList *result, *walk, *next;
g_return_val_if_fail (GST_IS_RTSP_SESSION (sess), NULL);
g_return_val_if_fail (func != NULL, NULL);
priv = sess->priv;
@ -348,10 +349,16 @@ gst_rtsp_session_filter (GstRTSPSession * sess,
g_mutex_lock (&priv->lock);
for (walk = priv->medias; walk; walk = next) {
GstRTSPSessionMedia *media = walk->data;
GstRTSPFilterResult res;
next = g_list_next (walk);
switch (func (sess, media, user_data)) {
if (func)
res = func (sess, media, user_data);
else
res = GST_RTSP_FILTER_REF;
switch (res) {
case GST_RTSP_FILTER_REMOVE:
g_object_unref (media);
priv->medias = g_list_delete_link (priv->medias, walk);