2a9c22cf9fe42e11c548c01c79d1b26f09e13d04
[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 #include <gst/cothreads.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33
34 extern GstElementDetails gst_bin_details;
35 extern GType _gst_bin_type;
36
37 #define GST_TYPE_BIN                 (_gst_bin_type)
38 # define GST_IS_BIN(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_BIN))
39 # define GST_IS_BIN_CLASS(obj)       (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_BIN))
40
41 #define GST_BIN_FAST(obj)            ((GstBin*)(obj))
42 #define GST_BIN_CLASS_FAST(klass)    ((GstBinClass*)(klass))
43
44 #ifdef GST_TYPE_PARANOID
45 # define GST_BIN(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BIN, GstBin))
46 # define GST_BIN_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BIN, GstBinClass))
47 #else
48 # define GST_BIN                     GST_BIN_FAST
49 # define GST_BIN_CLASS               GST_BIN_CLASS_FAST
50 #endif
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   /* this bin is actually a meta-bin, and may need to be scheduled */
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   /* padding */
62   GST_BIN_FLAG_LAST             = GST_ELEMENT_FLAG_LAST + 4,
63 } GstBinFlags;
64
65 //typedef struct _GstBin GstBin;
66 //typedef struct _GstBinClass GstBinClass;
67
68 struct _GstBin {
69   GstElement element;
70
71   /* our children */
72   gint numchildren;
73   GList *children;
74   gint num_eos_providers;
75   GList *eos_providers;
76   GCond *eoscond;
77
78   GstElementState child_states[GST_NUM_STATES];
79   
80   cothread_context *threadcontext;
81 };
82
83 struct _GstBinClass {
84   GstElementClass parent_class;
85
86   /* signals */
87   void          (*object_added)         (GstObject *object, GstObject *child);
88   void          (*object_removed)       (GstObject *object, GstObject *child);
89
90   /* change the state of elements of the given type */
91   gboolean      (*change_state_type)    (GstBin *bin,
92                                          GstElementState state,
93                                          GType type);
94   /* run a full iteration of operation */
95   gboolean      (*iterate)              (GstBin *bin);
96 };
97
98 GType           gst_bin_get_type                (void);
99 GstElement*     gst_bin_new                     (const gchar *name);
100 #define         gst_bin_destroy(bin)            gst_object_destroy(GST_OBJECT(bin))
101
102 /* add and remove elements from the bin */
103 void            gst_bin_add                     (GstBin *bin, GstElement *element);
104 void            gst_bin_remove                  (GstBin *bin, GstElement *element);
105
106 /* retrieve a single element or the list of children */
107 GstElement*     gst_bin_get_by_name             (GstBin *bin, const gchar *name);
108 GstElement*     gst_bin_get_by_name_recurse_up  (GstBin *bin, const gchar *name);
109 GList*          gst_bin_get_list                (GstBin *bin);
110
111 gboolean        gst_bin_set_state_type          (GstBin *bin, GstElementState state, GType type);
112
113 gboolean        gst_bin_iterate                 (GstBin *bin);
114
115 #ifdef __cplusplus
116 }
117 #endif /* __cplusplus */
118
119
120 #endif /* __GST_BIN_H__ */
121