60680881daed5b45f8bf7419a98dfe4392f86e55
[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
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))
46
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
51   /* we prefer to have cothreads when its an option, over chain-based */
52   GST_BIN_FLAG_PREFER_COTHREADS,
53
54   /* padding */
55   GST_BIN_FLAG_LAST             = GST_ELEMENT_FLAG_LAST + 4,
56 } GstBinFlags;
57
58 typedef struct _GstBin GstBin;
59 typedef struct _GstBinClass GstBinClass;
60 typedef struct __GstBinChain _GstBinChain;
61
62 struct _GstBin {
63   GstElement element;
64
65   /* our children */
66   gint numchildren;
67   GList *children;
68   gint num_eos_providers;
69   GList *eos_providers;
70   GCond *eoscond;
71
72   /* iteration state */
73   gboolean need_cothreads;
74   GList *managed_elements;
75   gint num_managed_elements;
76
77   GList *chains;
78   gint num_chains;
79   GList *entries;
80   gint num_entries;
81
82   cothread_context *threadcontext;
83   gboolean use_cothreads;
84 };
85
86 struct _GstBinClass {
87   GstElementClass parent_class;
88
89   /* signals */
90   void          (*object_added)         (GstObject *object, GstObject *child);
91   void          (*object_removed)       (GstObject *object, GstObject *child);
92
93   /* change the state of elements of the given type */
94   gboolean      (*change_state_type)    (GstBin *bin,
95                                          GstElementState state,
96                                          GtkType type);
97   /* create a plan for the execution of the bin */
98   void          (*create_plan)          (GstBin *bin);
99   void          (*schedule)             (GstBin *bin);
100   /* run a full iteration of operation */
101   gboolean      (*iterate)              (GstBin *bin);
102 };
103
104 struct __GstBinChain {
105   GList *elements;
106   gint num_elements;
107
108   GList *entries;
109
110   gboolean need_cothreads;
111   gboolean need_scheduling;
112 };
113
114
115 GtkType         gst_bin_get_type                (void);
116 GstElement*     gst_bin_new                     (const gchar *name);
117 #define         gst_bin_destroy(bin)            gst_object_destroy(GST_OBJECT(bin))
118
119 /* add and remove elements from the bin */
120 void            gst_bin_add                     (GstBin *bin,
121                                                  GstElement *element);
122 void            gst_bin_remove                  (GstBin *bin,
123                                                  GstElement *element);
124
125 /* retrieve a single element or the list of children */
126 GstElement*     gst_bin_get_by_name             (GstBin *bin,
127                                                  const gchar *name);
128 GList*          gst_bin_get_list                (GstBin *bin);
129
130 void            gst_bin_create_plan             (GstBin *bin);
131 void            gst_bin_schedule                (GstBin *bin);
132 gboolean        gst_bin_set_state_type          (GstBin *bin,
133                                                  GstElementState state,
134                                                  GtkType type);
135
136 gboolean        gst_bin_iterate                 (GstBin *bin);
137
138 /* hack FIXME */
139 void            gst_bin_use_cothreads           (GstBin *bin,
140                                                  gboolean enabled);
141
142 #ifdef __cplusplus
143 }
144 #endif /* __cplusplus */
145
146
147 #endif /* __GST_BIN_H__ */
148