mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
server: add method to iterate clients of server
This commit is contained in:
parent
a95ab4b29e
commit
f124d11298
4 changed files with 93 additions and 1 deletions
|
@ -356,6 +356,10 @@ gst_rtsp_server_io_func
|
|||
gst_rtsp_server_create_socket
|
||||
gst_rtsp_server_create_source
|
||||
gst_rtsp_server_attach
|
||||
|
||||
GstRTSPServerClientFilterFunc
|
||||
gst_rtsp_server_client_filter
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GST_IS_RTSP_SERVER
|
||||
GST_RTSP_SERVER_CAST
|
||||
|
|
|
@ -2687,7 +2687,7 @@ gst_rtsp_client_attach (GstRTSPClient * client, GMainContext * context)
|
|||
|
||||
/**
|
||||
* gst_rtsp_client_session_filter:
|
||||
* @client: a #GstRTSPclient
|
||||
* @client: a #GstRTSPClient
|
||||
* @func: (scope call): a callback
|
||||
* @user_data: user data passed to @func
|
||||
*
|
||||
|
|
|
@ -1302,3 +1302,63 @@ no_source:
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtsp_server_client_filter:
|
||||
* @server: a #GstRTSPServer
|
||||
* @func: (scope call): a callback
|
||||
* @user_data: user data passed to @func
|
||||
*
|
||||
* Call @func for each client managed by @server. The result value of @func
|
||||
* determines what happens to the client. @func will be called with @server
|
||||
* locked so no further actions on @server can be performed from @func.
|
||||
*
|
||||
* If @func returns #GST_RTSP_FILTER_REMOVE, the client will be removed from
|
||||
* @server.
|
||||
*
|
||||
* If @func returns #GST_RTSP_FILTER_KEEP, the client will remain in @server.
|
||||
*
|
||||
* If @func returns #GST_RTSP_FILTER_REF, the client will remain in @server but
|
||||
* will also be added with an additional ref to the result #GList of this
|
||||
* function..
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
GList *
|
||||
gst_rtsp_server_client_filter (GstRTSPServer * server,
|
||||
GstRTSPServerClientFilterFunc func, gpointer user_data)
|
||||
{
|
||||
GstRTSPServerPrivate *priv;
|
||||
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;
|
||||
|
||||
result = NULL;
|
||||
|
||||
GST_RTSP_SERVER_LOCK (server);
|
||||
for (walk = priv->clients; walk; walk = next) {
|
||||
GstRTSPClient *client = walk->data;
|
||||
|
||||
next = g_list_next (walk);
|
||||
|
||||
switch (func (server, client, user_data)) {
|
||||
case GST_RTSP_FILTER_REMOVE:
|
||||
/* remove client, FIXME */
|
||||
break;
|
||||
case GST_RTSP_FILTER_REF:
|
||||
result = g_list_prepend (result, g_object_ref (client));
|
||||
break;
|
||||
case GST_RTSP_FILTER_KEEP:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
GST_RTSP_SERVER_UNLOCK (server);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -116,6 +116,34 @@ GSource * gst_rtsp_server_create_source (GstRTSPServer *serve
|
|||
guint gst_rtsp_server_attach (GstRTSPServer *server,
|
||||
GMainContext *context);
|
||||
|
||||
/**
|
||||
* GstRTSPServerClientFilterFunc:
|
||||
* @server: a #GstRTSPServer object
|
||||
* @sess: a #GstRTSPClient in @server
|
||||
* @user_data: user data that has been given to gst_rtsp_server_client_filter()
|
||||
*
|
||||
* This function will be called by the gst_rtsp_server_client_filter(). An
|
||||
* implementation should return a value of #GstRTSPFilterResult.
|
||||
*
|
||||
* When this function returns #GST_RTSP_FILTER_REMOVE, @client will be removed
|
||||
* from @server.
|
||||
*
|
||||
* A return value of #GST_RTSP_FILTER_KEEP will leave @client untouched in
|
||||
* @server.
|
||||
*
|
||||
* A value of #GST_RTSP_FILTER_REF will add @client to the result #GList of
|
||||
* gst_rtsp_server_client_filter().
|
||||
*
|
||||
* Returns: a #GstRTSPFilterResult.
|
||||
*/
|
||||
typedef GstRTSPFilterResult (*GstRTSPServerClientFilterFunc) (GstRTSPServer *server,
|
||||
GstRTSPClient *client,
|
||||
gpointer user_data);
|
||||
|
||||
GList * gst_rtsp_server_client_filter (GstRTSPServer *server,
|
||||
GstRTSPServerClientFilterFunc func,
|
||||
gpointer user_data);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_RTSP_SERVER_H__ */
|
||||
|
|
Loading…
Reference in a new issue