2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
5 * gstbin.h: Header for GstBin container object
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
27 #include <gst/gstelement.h>
28 #include <gst/gstiterator.h>
32 GST_EXPORT GType _gst_bin_type;
34 #define GST_TYPE_BIN (_gst_bin_type)
35 #define GST_IS_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_BIN))
36 #define GST_IS_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_BIN))
37 #define GST_BIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BIN, GstBinClass))
38 #define GST_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BIN, GstBin))
39 #define GST_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BIN, GstBinClass))
40 #define GST_BIN_CAST(obj) ((GstBin*)(obj))
44 * @GST_BIN_FLAG_MANAGER: this bin is a manager of child elements, i.e.
45 * a pipeline or thread.
46 * @GST_BIN_SELF_SCHEDULABLE: the bin iterates itself.
47 * @GST_BIN_FLAG_PREFER_COTHREADS: we prefer to have cothreads when its
48 * an option, over chain-based.
49 * @GST_BIN_FLAG_FIXED_CLOCK: bin has one clock that cannot be changed.
50 * @GST_BIN_STATE_LOCKED: indicator that we are in a non-recursive
51 * state-change on the bin, or that kids should not change parent state.
52 * Both are internally used to prevent infinitely recursive loops of
53 * state changes. Since they are mutually exclusive and serve the same
54 * purpose, we use the same flag for them.
55 * @GST_BIN_FLAG_LAST: the last enum in the series of flags in a bin,
56 * derived classes can use this as first value in a list of flags.
58 * GstBinFlags are a set of flags specific to bins. Most are set/used
59 * internally. They can be checked using the GST_FLAG_IS_SET () macro,
60 * and (un)set using GST_FLAG_SET () and GST_FLAG_UNSET ().
63 GST_BIN_FLAG_FIXED_CLOCK = GST_ELEMENT_FLAG_LAST,
65 GST_BIN_SELF_SCHEDULABLE,
68 GST_BIN_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 5
71 /*typedef struct _GstBin GstBin; */
72 /*typedef struct _GstBinClass GstBinClass; */
74 #define GST_BIN_NUMCHILDREN(bin) (GST_BIN_CAST(bin)->numchildren);
75 #define GST_BIN_CHILDREN(bin) (GST_BIN_CAST(bin)->children);
76 #define GST_BIN_CHILDREN_COOKIE(bin) (GST_BIN_CAST(bin)->children_cookie);
81 /*< public >*/ /* with LOCK */
82 /* our children, subclass are supposed to update these
83 * fields to reflect their state with _iterate_*() */
86 guint32 children_cookie;
88 GstElementState child_states[GST_NUM_STATES];
91 gpointer _gst_reserved[GST_PADDING];
95 GstElementClass parent_class;
99 /* run a full iteration of operation */
100 gboolean (*iterate) (GstBin *bin);
101 void (*child_state_change) (GstBin *bin, GstElementState oldstate,
102 GstElementState newstate, GstElement *element);
106 void (*element_added) (GstBin *bin, GstElement *child);
107 void (*element_removed) (GstBin *bin, GstElement *child);
111 gboolean (*add_element) (GstBin *bin, GstElement *element);
112 gboolean (*remove_element) (GstBin *bin, GstElement *element);
115 gpointer _gst_reserved[GST_PADDING];
118 GType gst_bin_get_type (void);
119 GstElement* gst_bin_new (const gchar *name);
121 /* add and remove elements from the bin */
122 gboolean gst_bin_add (GstBin *bin, GstElement *element);
123 gboolean gst_bin_remove (GstBin *bin, GstElement *element);
125 /* retrieve a single child */
126 GstElement* gst_bin_get_by_name (GstBin *bin, const gchar *name);
127 GstElement* gst_bin_get_by_name_recurse_up (GstBin *bin, const gchar *name);
128 GstElement* gst_bin_get_by_interface (GstBin *bin, GType interface);
130 /* retrieve multiple children */
131 GstIterator* gst_bin_iterate_elements (GstBin *bin);
132 GstIterator* gst_bin_iterate_recurse (GstBin *bin);
133 GstIterator* gst_bin_iterate_recurse_up (GstBin *bin);
135 GstIterator* gst_bin_iterate_sinks (GstBin *bin);
136 GstIterator* gst_bin_iterate_all_by_interface (GstBin *bin, GType interface);
138 gboolean gst_bin_iterate (GstBin *bin);
140 GstElementStateReturn gst_bin_sync_children_state (GstBin *bin);
143 /* one of our childs signaled a state change */
144 void gst_bin_child_state_change (GstBin *bin, GstElementState oldstate,
145 GstElementState newstate, GstElement *child);
150 #endif /* __GST_BIN_H__ */