gst: Add new GstContext miniobject for sharing contexts in a pipeline
[platform/upstream/gstreamer.git] / gst / gst_private.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *
5  * gst_private.h: Private header for within libgst
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., 51 Franklin St, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22
23 #ifndef __GST_PRIVATE_H__
24 #define __GST_PRIVATE_H__
25
26 #ifdef HAVE_CONFIG_H
27 # ifndef GST_LICENSE   /* don't include config.h twice, it has no guards */
28 #  include "config.h"
29 # endif
30 #endif
31
32 /* This needs to be before glib.h, since it might be used in inline
33  * functions */
34 extern const char             g_log_domain_gstreamer[];
35
36 #include <glib.h>
37
38 #include <stdlib.h>
39 #include <string.h>
40
41 /* Needed for GstRegistry * */
42 #include "gstregistry.h"
43 #include "gststructure.h"
44
45 /* we need this in pretty much all files */
46 #include "gstinfo.h"
47
48 /* for the flags in the GstPluginDep structure below */
49 #include "gstplugin.h"
50
51 /* for the pad cache */
52 #include "gstpad.h"
53
54 /* for GstElement */
55 #include "gstelement.h"
56
57 /* for GstToc */
58 #include "gsttoc.h"
59
60 #include "gstdatetime.h"
61
62 G_BEGIN_DECLS
63
64 /* used by gstparse.c and grammar.y */
65 struct _GstParseContext {
66   GList * missing_elements;
67 };
68
69 /* used by gstplugin.c and gstregistrybinary.c */
70 typedef struct {
71   /* details registered via gst_plugin_add_dependency() */
72   GstPluginDependencyFlags  flags;
73   gchar **env_vars;
74   gchar **paths;
75   gchar **names;
76
77   /* information saved from the last time the plugin was loaded (-1 = unset) */
78   guint   env_hash;  /* hash of content of environment variables in env_vars */
79   guint   stat_hash; /* hash of stat() on all relevant files and directories */
80 } GstPluginDep;
81
82 struct _GstPluginPrivate {
83   GList *deps;    /* list of GstPluginDep structures */
84   GstStructure *cache_data;
85 };
86
87 /* FIXME: could rename all priv_gst_* functions to __gst_* now */
88 G_GNUC_INTERNAL  gboolean priv_gst_plugin_loading_have_whitelist (void);
89
90 G_GNUC_INTERNAL  guint32  priv_gst_plugin_loading_get_whitelist_hash (void);
91
92 G_GNUC_INTERNAL  gboolean priv_gst_plugin_desc_is_whitelisted (GstPluginDesc * desc,
93                                                                const gchar   * filename);
94
95 G_GNUC_INTERNAL  gboolean _priv_plugin_deps_env_vars_changed (GstPlugin * plugin);
96
97 G_GNUC_INTERNAL  gboolean _priv_plugin_deps_files_changed (GstPlugin * plugin);
98
99 G_GNUC_INTERNAL  gboolean _priv_gst_in_valgrind (void);
100
101 /* init functions called from gst_init(). */
102 G_GNUC_INTERNAL  void  _priv_gst_quarks_initialize (void);
103 G_GNUC_INTERNAL  void  _priv_gst_mini_object_initialize (void);
104 G_GNUC_INTERNAL  void  _priv_gst_buffer_initialize (void);
105 G_GNUC_INTERNAL  void  _priv_gst_buffer_list_initialize (void);
106 G_GNUC_INTERNAL  void  _priv_gst_structure_initialize (void);
107 G_GNUC_INTERNAL  void  _priv_gst_caps_initialize (void);
108 G_GNUC_INTERNAL  void  _priv_gst_event_initialize (void);
109 G_GNUC_INTERNAL  void  _priv_gst_format_initialize (void);
110 G_GNUC_INTERNAL  void  _priv_gst_message_initialize (void);
111 G_GNUC_INTERNAL  void  _priv_gst_memory_initialize (void);
112 G_GNUC_INTERNAL  void  _priv_gst_meta_initialize (void);
113 G_GNUC_INTERNAL  void  _priv_gst_plugin_initialize (void);
114 G_GNUC_INTERNAL  void  _priv_gst_query_initialize (void);
115 G_GNUC_INTERNAL  void  _priv_gst_sample_initialize (void);
116 G_GNUC_INTERNAL  void  _priv_gst_tag_initialize (void);
117 G_GNUC_INTERNAL  void  _priv_gst_value_initialize (void);
118 G_GNUC_INTERNAL  void  _priv_gst_debug_init (void);
119 G_GNUC_INTERNAL  void  _priv_gst_context_initialize (void);
120
121 /* Private registry functions */
122 G_GNUC_INTERNAL
123 gboolean _priv_gst_registry_remove_cache_plugins (GstRegistry *registry);
124
125 G_GNUC_INTERNAL  void _priv_gst_registry_cleanup (void);
126
127 gboolean _gst_plugin_loader_client_run (void);
128
129 /* Used in GstBin for manual state handling */
130 G_GNUC_INTERNAL  void _priv_gst_element_state_changed (GstElement *element,
131                       GstState oldstate, GstState newstate, GstState pending);
132
133 /* used in both gststructure.c and gstcaps.c; numbers are completely made up */
134 #define STRUCTURE_ESTIMATED_STRING_LEN(s) (16 + gst_structure_n_fields(s) * 22)
135
136 G_GNUC_INTERNAL
137 gboolean  priv_gst_structure_append_to_gstring (const GstStructure * structure,
138                                                 GString            * s);
139 /* registry cache backends */
140 G_GNUC_INTERNAL
141 gboolean                priv_gst_registry_binary_read_cache     (GstRegistry * registry, const char *location);
142
143 G_GNUC_INTERNAL
144 gboolean                priv_gst_registry_binary_write_cache    (GstRegistry * registry, GList * plugins, const char *location);
145
146
147 G_GNUC_INTERNAL
148 void      __gst_element_factory_add_static_pad_template (GstElementFactory    * elementfactory,
149                                                          GstStaticPadTemplate * templ);
150
151 G_GNUC_INTERNAL
152 void      __gst_element_factory_add_interface           (GstElementFactory    * elementfactory,
153                                                          const gchar          * interfacename);
154
155 /* used in gstvalue.c and gststructure.c */
156 #define GST_ASCII_IS_STRING(c) (g_ascii_isalnum((c)) || ((c) == '_') || \
157     ((c) == '-') || ((c) == '+') || ((c) == '/') || ((c) == ':') || \
158     ((c) == '.'))
159
160 /* This is only meant for internal uses */
161 G_GNUC_INTERNAL
162 gint __gst_date_time_compare (const GstDateTime * dt1, const GstDateTime * dt2);
163
164 G_GNUC_INTERNAL
165 gchar * __gst_date_time_serialize (GstDateTime * datetime, gboolean with_usecs);
166
167 #ifndef GST_DISABLE_REGISTRY
168 /* Secret variable to initialise gst without registry cache */
169 GST_EXPORT gboolean _gst_disable_registry_cache;
170 #endif
171
172 /* provide inline gst_g_value_get_foo_unchecked(), used in gststructure.c */
173 #define DEFINE_INLINE_G_VALUE_GET_UNCHECKED(ret_type,name_type,v_field) \
174 static inline ret_type                                                  \
175 gst_g_value_get_##name_type##_unchecked (const GValue *value)           \
176 {                                                                       \
177   return value->data[0].v_field;                                        \
178 }
179
180 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gboolean,boolean,v_int)
181 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gint,int,v_int)
182 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(guint,uint,v_uint)
183 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gint64,int64,v_int64)
184 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(guint64,uint64,v_uint64)
185 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gfloat,float,v_float)
186 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gdouble,double,v_double)
187 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(const gchar *,string,v_pointer)
188
189
190 /*** debugging categories *****************************************************/
191
192 #ifndef GST_REMOVE_GST_DEBUG
193
194 GST_EXPORT GstDebugCategory *GST_CAT_GST_INIT;
195 GST_EXPORT GstDebugCategory *GST_CAT_MEMORY;
196 GST_EXPORT GstDebugCategory *GST_CAT_PARENTAGE;
197 GST_EXPORT GstDebugCategory *GST_CAT_STATES;
198 GST_EXPORT GstDebugCategory *GST_CAT_SCHEDULING;
199 GST_EXPORT GstDebugCategory *GST_CAT_BUFFER;
200 GST_EXPORT GstDebugCategory *GST_CAT_BUFFER_LIST;
201 GST_EXPORT GstDebugCategory *GST_CAT_BUS;
202 GST_EXPORT GstDebugCategory *GST_CAT_CAPS;
203 GST_EXPORT GstDebugCategory *GST_CAT_CLOCK;
204 GST_EXPORT GstDebugCategory *GST_CAT_ELEMENT_PADS;
205 GST_EXPORT GstDebugCategory *GST_CAT_PADS;
206 GST_EXPORT GstDebugCategory *GST_CAT_PERFORMANCE;
207 GST_EXPORT GstDebugCategory *GST_CAT_PIPELINE;
208 GST_EXPORT GstDebugCategory *GST_CAT_PLUGIN_LOADING;
209 GST_EXPORT GstDebugCategory *GST_CAT_PLUGIN_INFO;
210 GST_EXPORT GstDebugCategory *GST_CAT_PROPERTIES;
211 GST_EXPORT GstDebugCategory *GST_CAT_NEGOTIATION;
212 GST_EXPORT GstDebugCategory *GST_CAT_REFCOUNTING;
213 GST_EXPORT GstDebugCategory *GST_CAT_ERROR_SYSTEM;
214 GST_EXPORT GstDebugCategory *GST_CAT_EVENT;
215 GST_EXPORT GstDebugCategory *GST_CAT_MESSAGE;
216 GST_EXPORT GstDebugCategory *GST_CAT_PARAMS;
217 GST_EXPORT GstDebugCategory *GST_CAT_CALL_TRACE;
218 GST_EXPORT GstDebugCategory *GST_CAT_SIGNAL;
219 GST_EXPORT GstDebugCategory *GST_CAT_PROBE;
220 GST_EXPORT GstDebugCategory *GST_CAT_REGISTRY;
221 GST_EXPORT GstDebugCategory *GST_CAT_QOS;
222 GST_EXPORT GstDebugCategory *GST_CAT_META;
223 GST_EXPORT GstDebugCategory *GST_CAT_LOCKING;
224 GST_EXPORT GstDebugCategory *GST_CAT_CONTEXT;
225
226 /* Categories that should be completely private to
227  * libgstreamer should be done like this: */
228 #define GST_CAT_POLL _priv_GST_CAT_POLL
229 extern GstDebugCategory *_priv_GST_CAT_POLL;
230
231 #else
232
233 #define GST_CAT_GST_INIT         NULL
234 #define GST_CAT_AUTOPLUG         NULL
235 #define GST_CAT_AUTOPLUG_ATTEMPT NULL
236 #define GST_CAT_PARENTAGE        NULL
237 #define GST_CAT_STATES           NULL
238 #define GST_CAT_SCHEDULING       NULL
239 #define GST_CAT_DATAFLOW         NULL
240 #define GST_CAT_BUFFER           NULL
241 #define GST_CAT_BUFFER_LIST      NULL
242 #define GST_CAT_BUS              NULL
243 #define GST_CAT_CAPS             NULL
244 #define GST_CAT_CLOCK            NULL
245 #define GST_CAT_ELEMENT_PADS     NULL
246 #define GST_CAT_PADS             NULL
247 #define GST_CAT_PERFORMANCE      NULL
248 #define GST_CAT_PIPELINE         NULL
249 #define GST_CAT_PLUGIN_LOADING   NULL
250 #define GST_CAT_PLUGIN_INFO      NULL
251 #define GST_CAT_PROPERTIES       NULL
252 #define GST_CAT_NEGOTIATION      NULL
253 #define GST_CAT_REFCOUNTING      NULL
254 #define GST_CAT_ERROR_SYSTEM     NULL
255 #define GST_CAT_EVENT            NULL
256 #define GST_CAT_MESSAGE          NULL
257 #define GST_CAT_PARAMS           NULL
258 #define GST_CAT_CALL_TRACE       NULL
259 #define GST_CAT_SIGNAL           NULL
260 #define GST_CAT_PROBE            NULL
261 #define GST_CAT_REGISTRY         NULL
262 #define GST_CAT_QOS              NULL
263 #define GST_CAT_TYPES            NULL
264 #define GST_CAT_POLL             NULL
265 #define GST_CAT_META             NULL
266 #define GST_CAT_LOCKING          NULL
267 #define GST_CAT_CONTEXT          NULL
268
269 #endif
270
271
272 /**** objects made opaque until the private bits have been made private ****/
273
274 #include <gmodule.h>
275 #include <time.h> /* time_t */
276 #include <sys/types.h> /* off_t */
277 #include <sys/stat.h> /* off_t */
278
279 typedef struct _GstPluginPrivate GstPluginPrivate;
280
281 struct _GstPlugin {
282   GstObject       object;
283
284   /*< private >*/
285   GstPluginDesc desc;
286
287   GstPluginDesc *orig_desc;
288
289   gchar *       filename;
290   gchar *       basename;       /* base name (non-dir part) of plugin path */
291
292   GModule *     module;         /* contains the module if plugin is loaded */
293
294   off_t         file_size;
295   time_t        file_mtime;
296   gboolean      registered;     /* TRUE when the registry has seen a filename
297                                  * that matches the plugin's basename */
298
299   GstPluginPrivate *priv;
300
301   gpointer _gst_reserved[GST_PADDING];
302 };
303
304 struct _GstPluginClass {
305   GstObjectClass  object_class;
306
307   /*< private >*/
308   gpointer _gst_reserved[GST_PADDING];
309 };
310
311 struct _GstPluginFeature {
312   GstObject      object;
313
314   /*< private >*/
315   gboolean       loaded;
316   guint          rank;
317
318   const gchar   *plugin_name;
319   GstPlugin     *plugin;      /* weak ref */
320
321   /*< private >*/
322   gpointer _gst_reserved[GST_PADDING];
323 };
324
325 struct _GstPluginFeatureClass {
326   GstObjectClass        parent_class;
327
328   /*< private >*/
329   gpointer _gst_reserved[GST_PADDING];
330 };
331
332 #include "gsttypefind.h"
333
334 struct _GstTypeFindFactory {
335   GstPluginFeature              feature;
336   /* <private> */
337
338   GstTypeFindFunction           function;
339   gchar **                      extensions;
340   GstCaps *                     caps; /* FIXME: not yet saved in registry */
341
342   gpointer                      user_data;
343   GDestroyNotify                user_data_notify;
344
345   gpointer _gst_reserved[GST_PADDING];
346 };
347
348 struct _GstTypeFindFactoryClass {
349   GstPluginFeatureClass         parent;
350   /* <private> */
351
352   gpointer _gst_reserved[GST_PADDING];
353 };
354
355 struct _GstElementFactory {
356   GstPluginFeature      parent;
357
358   GType                 type;                   /* unique GType of element or 0 if not loaded */
359
360   gpointer              metadata;
361
362   GList *               staticpadtemplates;     /* GstStaticPadTemplate list */
363   guint                 numpadtemplates;
364
365   /* URI interface stuff */
366   GstURIType            uri_type;
367   gchar **              uri_protocols;
368
369   GList *               interfaces;             /* interface type names this element implements */
370
371   /*< private >*/
372   gpointer _gst_reserved[GST_PADDING];
373 };
374
375 struct _GstElementFactoryClass {
376   GstPluginFeatureClass parent_class;
377
378   gpointer _gst_reserved[GST_PADDING];
379 };
380
381 G_END_DECLS
382 #endif /* __GST_PRIVATE_H__ */