API change: remove gst_object_destroy and #defines to it
[platform/upstream/gstreamer.git] / gst / gstbin.h
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  */
22
23
24 #ifndef __GST_BIN_H__
25 #define __GST_BIN_H__
26
27 #include <gst/gstelement.h>
28
29 G_BEGIN_DECLS
30
31 extern GstElementDetails gst_bin_details;
32 extern GType _gst_bin_type;
33
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
39 #define GST_BIN_CAST(obj)            ((GstBin*)(obj))
40 #define GST_BIN_CLASS_CAST(klass)    ((GstBinClass*)(klass))
41
42 #ifdef GST_TYPE_PARANOID
43 # define GST_BIN(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BIN, GstBin))
44 # define GST_BIN_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BIN, GstBinClass))
45 #else
46 # define GST_BIN                     GST_BIN_CAST
47 # define GST_BIN_CLASS               GST_BIN_CLASS_CAST
48 #endif
49
50 typedef void            (*GstBinPrePostIterateFunction)         (GstBin *bin, gpointer user_data);
51
52 typedef enum {
53   /* this bin is a manager of child elements, i.e. a pipeline or thread */
54   GST_BIN_FLAG_MANAGER          = GST_ELEMENT_FLAG_LAST,
55
56   /* this bin iterates itself */
57   GST_BIN_SELF_SCHEDULABLE,
58
59   /* we prefer to have cothreads when its an option, over chain-based */
60   GST_BIN_FLAG_PREFER_COTHREADS,
61
62   GST_BIN_FLAG_FIXED_CLOCK,
63
64   /* padding */
65   GST_BIN_FLAG_LAST             = GST_ELEMENT_FLAG_LAST + 5
66 } GstBinFlags;
67
68 /*typedef struct _GstBin GstBin; */
69 /*typedef struct _GstBinClass GstBinClass; */
70
71 struct _GstBin {
72   GstElement     element;
73
74   /* our children */
75   gint           numchildren;
76   GList         *children;
77
78   GstElementState child_states[GST_NUM_STATES];
79
80   GstBinPrePostIterateFunction  pre_iterate_func;
81   GstBinPrePostIterateFunction post_iterate_func;
82   gpointer                  pre_iterate_data;
83   gpointer                  post_iterate_data;
84
85   gpointer       dummy[8];
86 };
87
88 struct _GstBinClass {
89   GstElementClass parent_class;
90
91   /* vtable */
92   void          (*add_element)          (GstBin *bin, GstElement *element);
93   void          (*remove_element)       (GstBin *bin, GstElement *element);
94
95   /* run a full iteration of operation */
96   gboolean      (*iterate)              (GstBin *bin);
97
98   /* signals */
99   void          (*element_added)        (GstBin *bin, GstElement *child);
100   void          (*element_removed)      (GstBin *bin, GstElement *child);
101
102   gpointer       dummy[8];
103 };
104
105 GType           gst_bin_get_type                (void);
106 GstElement*     gst_bin_new                     (const gchar *name);
107
108 /* add and remove elements from the bin */
109 void            gst_bin_add                     (GstBin *bin, GstElement *element);
110 void            gst_bin_add_many                (GstBin *bin, GstElement *element_1, ...);
111 void            gst_bin_remove                  (GstBin *bin, GstElement *element);
112 void            gst_bin_remove_many             (GstBin *bin, GstElement *element_1, ...);
113
114 /* retrieve a single element or the list of children */
115 GstElement*     gst_bin_get_by_name             (GstBin *bin, const gchar *name);
116 GstElement*     gst_bin_get_by_name_recurse_up  (GstBin *bin, const gchar *name);
117 const GList*    gst_bin_get_list                (GstBin *bin);
118
119 gboolean        gst_bin_iterate                 (GstBin *bin);
120
121 void            gst_bin_use_clock               (GstBin *bin, GstClock *clock);
122 GstClock*       gst_bin_get_clock               (GstBin *bin);
123 void            gst_bin_auto_clock              (GstBin *bin);
124
125 /* internal */
126 /* one of our childs signaled a state change */
127 void            gst_bin_child_state_change              (GstBin *bin, GstElementState oldstate, 
128                                                          GstElementState newstate, GstElement *child);
129
130 void            gst_bin_set_pre_iterate_function        (GstBin *bin, 
131                                                          GstBinPrePostIterateFunction func, 
132                                                          gpointer user_data);
133 void            gst_bin_set_post_iterate_function       (GstBin *bin, 
134                                                          GstBinPrePostIterateFunction func, 
135                                                          gpointer user_data);
136
137 G_END_DECLS
138
139
140 #endif /* __GST_BIN_H__ */
141