Add iterate mutex for future use
[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 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32
33 extern GstElementDetails gst_bin_details;
34 extern GType _gst_bin_type;
35
36 #define GST_TYPE_BIN                 (_gst_bin_type)
37 # define GST_IS_BIN(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_BIN))
38 # define GST_IS_BIN_CLASS(obj)       (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_BIN))
39
40 #define GST_BIN_CAST(obj)            ((GstBin*)(obj))
41 #define GST_BIN_CLASS_CAST(klass)    ((GstBinClass*)(klass))
42
43 #ifdef GST_TYPE_PARANOID
44 # define GST_BIN(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BIN, GstBin))
45 # define GST_BIN_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BIN, GstBinClass))
46 #else
47 # define GST_BIN                     GST_BIN_CAST
48 # define GST_BIN_CLASS               GST_BIN_CLASS_CAST
49 #endif
50
51 typedef enum {
52   /* this bin is a manager of child elements, i.e. a pipeline or thread */
53   GST_BIN_FLAG_MANAGER          = GST_ELEMENT_FLAG_LAST,
54
55   /* this bin iterates itself */
56   GST_BIN_SELF_SCHEDULABLE,
57
58   /* we prefer to have cothreads when its an option, over chain-based */
59   GST_BIN_FLAG_PREFER_COTHREADS,
60
61   GST_BIN_FLAG_FIXED_CLOCK,
62
63   /* padding */
64   GST_BIN_FLAG_LAST             = GST_ELEMENT_FLAG_LAST + 5,
65 } GstBinFlags;
66
67 /*typedef struct _GstBin GstBin; */
68 /*typedef struct _GstBinClass GstBinClass; */
69
70 struct _GstBin {
71   GstElement     element;
72
73   /* our children */
74   gint           numchildren;
75   GList         *children;
76
77   GMutex        *iterate_mutex;
78   GCond         *iterate_cond;
79
80   GstElementState child_states[GST_NUM_STATES];
81
82   gpointer       sched_private;
83 };
84
85 struct _GstBinClass {
86   GstElementClass parent_class;
87
88   /* signals */
89   void          (*object_added)         (GstObject *object, GstObject *child);
90   void          (*object_removed)       (GstObject *object, GstObject *child);
91
92   /* change the state of elements of the given type */
93   gboolean      (*change_state_type)    (GstBin *bin,
94                                          GstElementState state,
95                                          GType type);
96   /* run a full iteration of operation */
97   gboolean      (*iterate)              (GstBin *bin);
98 };
99
100 GType           gst_bin_get_type                (void);
101 GstElement*     gst_bin_new                     (const gchar *name);
102 #define         gst_bin_destroy(bin)            gst_object_destroy(GST_OBJECT(bin))
103
104 /* add and remove elements from the bin */
105 void            gst_bin_add                     (GstBin *bin, GstElement *element);
106 void            gst_bin_add_many                (GstBin *bin, GstElement *element_1, ...);
107 void            gst_bin_remove                  (GstBin *bin, GstElement *element);
108
109 /* retrieve a single element or the list of children */
110 GstElement*     gst_bin_get_by_name             (GstBin *bin, const gchar *name);
111 GstElement*     gst_bin_get_by_name_recurse_up  (GstBin *bin, const gchar *name);
112 const GList*    gst_bin_get_list                (GstBin *bin);
113
114 gboolean        gst_bin_set_state_type          (GstBin *bin, GstElementState state, GType type);
115
116 gboolean        gst_bin_iterate                 (GstBin *bin);
117
118 void            gst_bin_use_clock               (GstBin *bin, GstClock *clock);
119 GstClock*       gst_bin_get_clock               (GstBin *bin);
120 void            gst_bin_auto_clock              (GstBin *bin);
121
122 /* internal */
123 /* one of our childs signaled a state change */
124 void            gst_bin_child_state_change      (GstBin *bin, GstElementState oldstate, 
125                                                  GstElementState newstate, GstElement *child);
126
127 #ifdef __cplusplus
128 }
129 #endif /* __cplusplus */
130
131
132 #endif /* __GST_BIN_H__ */
133