inlined more docs, fixed double id-ref
[platform/upstream/gstreamer.git] / gst / gstfilter.c
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 /**
20  * SECTION:gstfilter
21  * @short_description: Take data in and spit data out
22  *
23  * Filters take data in and spit data out. They are the main elements in a
24  * filter graph.
25  * Filters have zero or more inputs and zero or more outputs. Filters are
26  * linked together to form filter graphs. A #GstFilter is the base class and is
27  * not very useful on its own.
28  */
29 #include "gst_private.h"
30 #include <gst/gstfilter.h>
31
32 /**
33  * gst_filter_run:
34  * @list: a linked list
35  * @func: the function to execute for each item
36  * @first: flag to stop execution after a successful item
37  * @user_data: user data
38  *
39  * Iterates over the elements in @list, calling @func with the
40  * list item data for each item.  If @func returns TRUE, @data is
41  * prepended to the list of results returned.  If @first is true,
42  * the search is halted after the first result is found.
43  *
44  * Returns: the list of results
45  */
46 GList *
47 gst_filter_run (const GList * list, GstFilterFunc func, gboolean first,
48     gpointer user_data)
49 {
50   const GList *walk = list;
51   GList *result = NULL;
52
53   while (walk) {
54     gboolean res = TRUE;
55     gpointer data = walk->data;
56
57     walk = g_list_next (walk);
58
59     if (func)
60       res = func (data, user_data);
61
62     if (res) {
63       result = g_list_prepend (result, data);
64
65       if (first)
66         break;
67     }
68   }
69
70   return result;
71 }