1 /* GStreamer
2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
4 *
5 * gstbin.h: Header for GstBin container object
6 *
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.
11 *
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.
16 *
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.
21 */
24 #ifndef __GST_BIN_H__
25 #define __GST_BIN_H__
27 #include <gst/gstelement.h>
28 #include <gst/cothreads.h>
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
34 extern GstElementDetails gst_bin_details;
36 #define GST_TYPE_BIN \
37 (gst_bin_get_type())
38 #define GST_BIN(obj) \
39 (GTK_CHECK_CAST((obj),GST_TYPE_BIN,GstBin))
40 #define GST_BIN_CLASS(klass) \
41 (GTK_CHECK_CLASS_CAST((klass),GST_TYPE_BIN,GstBinClass))
42 #define GST_IS_BIN(obj) \
43 (GTK_CHECK_TYPE((obj),GST_TYPE_BIN))
44 #define GST_IS_BIN_CLASS(obj) \
45 (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_BIN))
47 typedef enum {
48 /* this bin is a manager of child elements, i.e. a pipeline or thread */
49 GST_BIN_FLAG_MANAGER = GST_ELEMENT_FLAG_LAST,
50 /* this bin is actually a meta-bin, and may need to be scheduled */
51 GST_BIN_SELF_SCHEDULABLE,
53 /* we prefer to have cothreads when its an option, over chain-based */
54 GST_BIN_FLAG_PREFER_COTHREADS,
56 /* padding */
57 GST_BIN_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 4,
58 } GstBinFlags;
60 //typedef struct _GstBin GstBin;
61 //typedef struct _GstBinClass GstBinClass;
62 typedef struct __GstBinChain _GstBinChain;
64 struct _GstBin {
65 GstElement element;
67 /* our children */
68 gint numchildren;
69 GList *children;
70 gint num_eos_providers;
71 GList *eos_providers;
72 GCond *eoscond;
74 /* iteration state */
75 gboolean need_cothreads;
76 GList *managed_elements;
77 gint num_managed_elements;
79 GList *chains;
80 gint num_chains;
81 GList *entries;
82 gint num_entries;
84 cothread_context *threadcontext;
85 gboolean use_cothreads;
86 };
88 struct _GstBinClass {
89 GstElementClass parent_class;
91 /* signals */
92 void (*object_added) (GstObject *object, GstObject *child);
93 void (*object_removed) (GstObject *object, GstObject *child);
95 /* change the state of elements of the given type */
96 gboolean (*change_state_type) (GstBin *bin,
97 GstElementState state,
98 GtkType type);
99 /* run a full iteration of operation */
100 gboolean (*iterate) (GstBin *bin);
101 };
103 struct __GstBinChain {
104 GList *elements;
105 gint num_elements;
107 GList *entries;
109 gboolean need_cothreads;
110 gboolean need_scheduling;
111 };
114 GtkType gst_bin_get_type (void);
115 GstElement* gst_bin_new (const gchar *name);
116 #define gst_bin_destroy(bin) gst_object_destroy(GST_OBJECT(bin))
118 void gst_bin_set_element_manager (GstElement *element, GstElement *manager);
119 void gst_bin_add_managed_element (GstBin *bin, GstElement *element);
120 void gst_bin_remove_managed_element (GstBin *bin, GstElement *element);
122 /* add and remove elements from the bin */
123 void gst_bin_add (GstBin *bin,
124 GstElement *element);
125 void gst_bin_remove (GstBin *bin,
126 GstElement *element);
128 /* retrieve a single element or the list of children */
129 GstElement* gst_bin_get_by_name (GstBin *bin,
130 const gchar *name);
131 GstElement* gst_bin_get_by_name_recurse_up (GstBin *bin,
132 const gchar *name);
133 GList* gst_bin_get_list (GstBin *bin);
135 gboolean gst_bin_set_state_type (GstBin *bin,
136 GstElementState state,
137 GtkType type);
139 gboolean gst_bin_iterate (GstBin *bin);
141 /* hack FIXME */
142 void gst_bin_use_cothreads (GstBin *bin,
143 gboolean enabled);
145 #ifdef __cplusplus
146 }
147 #endif /* __cplusplus */
150 #endif /* __GST_BIN_H__ */