server: add method to iterate clients of server
authorWim Taymans <wim.taymans@collabora.co.uk>
Fri, 2 Aug 2013 15:15:09 +0000 (17:15 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Fri, 2 Aug 2013 15:19:42 +0000 (17:19 +0200)
docs/libs/gst-rtsp-server-sections.txt
gst/rtsp-server/rtsp-client.c
gst/rtsp-server/rtsp-server.c
gst/rtsp-server/rtsp-server.h

index 3c6511b..0178bac 100644 (file)
@@ -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
index 73de18b..f0d629e 100644 (file)
@@ -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
  *
index 538a2d2..0e18fab 100644 (file)
@@ -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;
+}
index 4e18561..84aa178 100644 (file)
@@ -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__ */