Lots of editor changes:
[platform/upstream/gstreamer.git] / gst / gstbin.h
1 /* Gnome-Streamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20
21 #ifndef __GST_BIN_H__
22 #define __GST_BIN_H__
23
24 #include <gst/gstelement.h>
25 #include <gst/cothreads.h>
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif /* __cplusplus */
30
31 extern GstElementDetails gst_bin_details;
32
33 #define GST_TYPE_BIN \
34   (gst_bin_get_type())
35 #define GST_BIN(obj) \
36   (GTK_CHECK_CAST((obj),GST_TYPE_BIN,GstBin))
37 #define GST_BIN_CLASS(klass) \
38   (GTK_CHECK_CLASS_CAST((klass),GST_TYPE_BIN,GstBinClass))
39 #define GST_IS_BIN(obj) \
40   (GTK_CHECK_TYPE((obj),GST_TYPE_BIN))
41 #define GST_IS_BIN_CLASS(obj) \
42   (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_BIN))
43
44 typedef enum {
45   // this bin is a manager of child elements, i.e. a pipeline or thread
46   GST_BIN_FLAG_MANAGER          = GST_ELEMENT_FLAG_LAST,
47
48   // we prefer to have cothreads when its an option, over chain-based
49   GST_BIN_FLAG_PREFER_COTHREADS,
50
51   /* padding */
52   GST_BIN_FLAG_LAST             = GST_ELEMENT_FLAG_LAST + 4,
53 } GstBinFlags;
54
55 typedef struct _GstBin GstBin;
56 typedef struct _GstBinClass GstBinClass;
57
58 struct _GstBin {
59   GstElement element;
60
61   // our children
62   gint numchildren;
63   GList *children;
64
65   // iteration state
66   gboolean need_cothreads;
67   GList *managed_elements;
68   gint num_managed_elements;
69   GList *entries;
70   gint num_entries;
71
72   cothread_context *threadcontext;
73   gboolean use_cothreads;
74   GList *outside_schedules;
75 };
76
77 struct _GstBinClass {
78   GstElementClass parent_class;
79
80   /* signals */
81   void          (*object_added)         (GstObject *object, GstObject *child);
82   void          (*object_removed)       (GstObject *object, GstObject *child);
83
84   /* change the state of elements of the given type */
85   gboolean      (*change_state_type)    (GstBin *bin,
86                                          GstElementState state,
87                                          GtkType type);
88   /* create a plan for the execution of the bin */
89   void          (*create_plan)          (GstBin *bin);
90   /* run a full iteration of operation */
91   void          (*iterate)              (GstBin *bin);
92 };
93
94
95
96 GtkType         gst_bin_get_type                (void);
97 GstElement*     gst_bin_new                     (gchar *name);
98 #define         gst_bin_destroy(bin)            gst_object_destroy(GST_OBJECT(bin))
99
100 /* add and remove elements from the bin */
101 void            gst_bin_add                     (GstBin *bin,
102                                                  GstElement *element);
103 void            gst_bin_remove                  (GstBin *bin,
104                                                  GstElement *element);
105
106 /* retrieve a single element or the list of children */
107 GstElement*     gst_bin_get_by_name             (GstBin *bin,
108                                                  gchar *name);
109 GList*          gst_bin_get_list                (GstBin *bin);
110
111 void            gst_bin_create_plan             (GstBin *bin);
112 gboolean        gst_bin_set_state_type          (GstBin *bin,
113                                                  GstElementState state,
114                                                  GtkType type);
115
116 void            gst_bin_iterate                 (GstBin *bin);
117
118 // hack FIXME
119 void            gst_bin_use_cothreads           (GstBin *bin,
120                                                  gboolean enabled);
121
122 #ifdef __cplusplus
123 }
124 #endif /* __cplusplus */
125
126
127 #endif /* __GST_BIN_H__ */     
128