Move dataurisrc element from -bad
[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 GST_EXPORT */
42 #include "gst/gstconfig.h"
43
44 /* Needed for GstRegistry * */
45 #include "gstregistry.h"
46 #include "gststructure.h"
47
48 /* we need this in pretty much all files */
49 #include "gstinfo.h"
50
51 /* for the flags in the GstPluginDep structure below */
52 #include "gstplugin.h"
53
54 /* for the pad cache */
55 #include "gstpad.h"
56
57 /* for GstElement */
58 #include "gstelement.h"
59
60 /* for GstDeviceProvider */
61 #include "gstdeviceprovider.h"
62
63 /* for GstToc */
64 #include "gsttoc.h"
65
66 #include "gstdatetime.h"
67
68 #include "gsttracerutils.h"
69
70 G_BEGIN_DECLS
71
72 /* used by gstparse.c and grammar.y */
73 struct _GstParseContext {
74   GList * missing_elements;
75 };
76
77 /* used by gstplugin.c and gstregistrybinary.c */
78 typedef struct {
79   /* details registered via gst_plugin_add_dependency() */
80   GstPluginDependencyFlags  flags;
81   gchar **env_vars;
82   gchar **paths;
83   gchar **names;
84
85   /* information saved from the last time the plugin was loaded (-1 = unset) */
86   guint   env_hash;  /* hash of content of environment variables in env_vars */
87   guint   stat_hash; /* hash of stat() on all relevant files and directories */
88 } GstPluginDep;
89
90 struct _GstPluginPrivate {
91   GList *deps;    /* list of GstPluginDep structures */
92   GstStructure *cache_data;
93 };
94
95 /* FIXME: could rename all priv_gst_* functions to __gst_* now */
96 G_GNUC_INTERNAL  gboolean priv_gst_plugin_loading_have_whitelist (void);
97
98 G_GNUC_INTERNAL  guint32  priv_gst_plugin_loading_get_whitelist_hash (void);
99
100 G_GNUC_INTERNAL  gboolean priv_gst_plugin_desc_is_whitelisted (GstPluginDesc * desc,
101                                                                const gchar   * filename);
102
103 G_GNUC_INTERNAL  gboolean _priv_plugin_deps_env_vars_changed (GstPlugin * plugin);
104
105 G_GNUC_INTERNAL  gboolean _priv_plugin_deps_files_changed (GstPlugin * plugin);
106
107 G_GNUC_INTERNAL  gboolean _priv_gst_in_valgrind (void);
108
109 /* init functions called from gst_init(). */
110 G_GNUC_INTERNAL  void  _priv_gst_quarks_initialize (void);
111 G_GNUC_INTERNAL  void  _priv_gst_mini_object_initialize (void);
112 G_GNUC_INTERNAL  void  _priv_gst_memory_initialize (void);
113 G_GNUC_INTERNAL  void  _priv_gst_allocator_initialize (void);
114 G_GNUC_INTERNAL  void  _priv_gst_buffer_initialize (void);
115 G_GNUC_INTERNAL  void  _priv_gst_buffer_list_initialize (void);
116 G_GNUC_INTERNAL  void  _priv_gst_structure_initialize (void);
117 G_GNUC_INTERNAL  void  _priv_gst_caps_initialize (void);
118 G_GNUC_INTERNAL  void  _priv_gst_caps_features_initialize (void);
119 G_GNUC_INTERNAL  void  _priv_gst_event_initialize (void);
120 G_GNUC_INTERNAL  void  _priv_gst_format_initialize (void);
121 G_GNUC_INTERNAL  void  _priv_gst_message_initialize (void);
122 G_GNUC_INTERNAL  void  _priv_gst_meta_initialize (void);
123 G_GNUC_INTERNAL  void  _priv_gst_plugin_initialize (void);
124 G_GNUC_INTERNAL  void  _priv_gst_query_initialize (void);
125 G_GNUC_INTERNAL  void  _priv_gst_sample_initialize (void);
126 G_GNUC_INTERNAL  void  _priv_gst_tag_initialize (void);
127 G_GNUC_INTERNAL  void  _priv_gst_value_initialize (void);
128 G_GNUC_INTERNAL  void  _priv_gst_debug_init (void);
129 G_GNUC_INTERNAL  void  _priv_gst_context_initialize (void);
130 G_GNUC_INTERNAL  void  _priv_gst_toc_initialize (void);
131 G_GNUC_INTERNAL  void  _priv_gst_date_time_initialize (void);
132
133 /* cleanup functions called from gst_deinit(). */
134 G_GNUC_INTERNAL  void  _priv_gst_allocator_cleanup (void);
135 G_GNUC_INTERNAL  void  _priv_gst_caps_features_cleanup (void);
136 G_GNUC_INTERNAL  void  _priv_gst_caps_cleanup (void);
137
138 /* called from gst_task_cleanup_all(). */
139 G_GNUC_INTERNAL  void  _priv_gst_element_cleanup (void);
140
141 /* Private registry functions */
142 G_GNUC_INTERNAL
143 gboolean _priv_gst_registry_remove_cache_plugins (GstRegistry *registry);
144
145 G_GNUC_INTERNAL  void _priv_gst_registry_cleanup (void);
146
147 gboolean _gst_plugin_loader_client_run (void);
148
149 G_GNUC_INTERNAL  GstPlugin * _priv_gst_plugin_load_file_for_registry (const gchar *filename,
150                                                                       GstRegistry * registry,
151                                                                       GError** error);
152
153 /* Used in GstBin for manual state handling */
154 G_GNUC_INTERNAL  void _priv_gst_element_state_changed (GstElement *element,
155                       GstState oldstate, GstState newstate, GstState pending);
156
157 /* used in both gststructure.c and gstcaps.c; numbers are completely made up */
158 #define STRUCTURE_ESTIMATED_STRING_LEN(s) (16 + gst_structure_n_fields(s) * 22)
159 #define FEATURES_ESTIMATED_STRING_LEN(s) (16 + gst_caps_features_get_size(s) * 14)
160
161 G_GNUC_INTERNAL
162 gboolean  priv_gst_structure_append_to_gstring (const GstStructure * structure,
163                                                 GString            * s);
164 G_GNUC_INTERNAL
165 gboolean priv__gst_structure_append_template_to_gstring (GQuark field_id,
166                                                         const GValue *value,
167                                                         gpointer user_data);
168
169 G_GNUC_INTERNAL
170 void priv_gst_caps_features_append_to_gstring (const GstCapsFeatures * features, GString *s);
171
172 G_GNUC_INTERNAL
173 gboolean priv_gst_structure_parse_name (gchar * str, gchar **start, gchar ** end, gchar ** next);
174 G_GNUC_INTERNAL
175 gboolean priv_gst_structure_parse_fields (gchar *str, gchar ** end, GstStructure *structure);
176
177 /* used in gstvalue.c and gststructure.c */
178
179 #define GST_WRAPPED_PTR_FORMAT     "p\aa"
180
181 G_GNUC_INTERNAL
182 gchar *priv_gst_string_take_and_wrap (gchar * s);
183
184 /* registry cache backends */
185 G_GNUC_INTERNAL
186 gboolean                priv_gst_registry_binary_read_cache     (GstRegistry * registry, const char *location);
187
188 G_GNUC_INTERNAL
189 gboolean                priv_gst_registry_binary_write_cache    (GstRegistry * registry, GList * plugins, const char *location);
190
191
192 G_GNUC_INTERNAL
193 void      __gst_element_factory_add_static_pad_template (GstElementFactory    * elementfactory,
194                                                          GstStaticPadTemplate * templ);
195
196 G_GNUC_INTERNAL
197 void      __gst_element_factory_add_interface           (GstElementFactory    * elementfactory,
198                                                          const gchar          * interfacename);
199
200 /* used in gstvalue.c and gststructure.c */
201 #define GST_ASCII_IS_STRING(c) (g_ascii_isalnum((c)) || ((c) == '_') || \
202     ((c) == '-') || ((c) == '+') || ((c) == '/') || ((c) == ':') || \
203     ((c) == '.'))
204
205 /* This is only meant for internal uses */
206 G_GNUC_INTERNAL
207 gint __gst_date_time_compare (const GstDateTime * dt1, const GstDateTime * dt2);
208
209 G_GNUC_INTERNAL
210 gchar * __gst_date_time_serialize (GstDateTime * datetime, gboolean with_usecs);
211
212 /* Non-static, for access from the testsuite, but not for external use */
213 gboolean
214 _priv_gst_do_linear_regression (GstClockTime *times, guint n,
215     GstClockTime * m_num, GstClockTime * m_denom, GstClockTime * b,
216     GstClockTime * xbase, gdouble * r_squared);
217
218 /* For use in gstdebugutils */
219 G_GNUC_INTERNAL
220 GstCapsFeatures * __gst_caps_get_features_unchecked (const GstCaps * caps, guint idx);
221
222 #ifndef GST_DISABLE_REGISTRY
223 /* Secret variable to initialise gst without registry cache */
224 GST_EXPORT gboolean _gst_disable_registry_cache;
225 #endif
226
227 /* provide inline gst_g_value_get_foo_unchecked(), used in gststructure.c */
228 #define DEFINE_INLINE_G_VALUE_GET_UNCHECKED(ret_type,name_type,v_field) \
229 static inline ret_type                                                  \
230 gst_g_value_get_##name_type##_unchecked (const GValue *value)           \
231 {                                                                       \
232   return value->data[0].v_field;                                        \
233 }
234
235 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gboolean,boolean,v_int)
236 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gint,int,v_int)
237 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(guint,uint,v_uint)
238 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gint64,int64,v_int64)
239 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(guint64,uint64,v_uint64)
240 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gfloat,float,v_float)
241 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gdouble,double,v_double)
242 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(const gchar *,string,v_pointer)
243
244
245 /*** debugging categories *****************************************************/
246
247 #ifndef GST_REMOVE_GST_DEBUG
248
249 GST_EXPORT GstDebugCategory *GST_CAT_GST_INIT;
250 GST_EXPORT GstDebugCategory *GST_CAT_MEMORY;
251 GST_EXPORT GstDebugCategory *GST_CAT_PARENTAGE;
252 GST_EXPORT GstDebugCategory *GST_CAT_STATES;
253 GST_EXPORT GstDebugCategory *GST_CAT_SCHEDULING;
254 GST_EXPORT GstDebugCategory *GST_CAT_BUFFER;
255 GST_EXPORT GstDebugCategory *GST_CAT_BUFFER_LIST;
256 GST_EXPORT GstDebugCategory *GST_CAT_BUS;
257 GST_EXPORT GstDebugCategory *GST_CAT_CAPS;
258 GST_EXPORT GstDebugCategory *GST_CAT_CLOCK;
259 GST_EXPORT GstDebugCategory *GST_CAT_ELEMENT_PADS;
260 GST_EXPORT GstDebugCategory *GST_CAT_PADS;
261 GST_EXPORT GstDebugCategory *GST_CAT_PERFORMANCE;
262 GST_EXPORT GstDebugCategory *GST_CAT_PIPELINE;
263 GST_EXPORT GstDebugCategory *GST_CAT_PLUGIN_LOADING;
264 GST_EXPORT GstDebugCategory *GST_CAT_PLUGIN_INFO;
265 GST_EXPORT GstDebugCategory *GST_CAT_PROPERTIES;
266 GST_EXPORT GstDebugCategory *GST_CAT_NEGOTIATION;
267 GST_EXPORT GstDebugCategory *GST_CAT_REFCOUNTING;
268 GST_EXPORT GstDebugCategory *GST_CAT_ERROR_SYSTEM;
269 GST_EXPORT GstDebugCategory *GST_CAT_EVENT;
270 GST_EXPORT GstDebugCategory *GST_CAT_MESSAGE;
271 GST_EXPORT GstDebugCategory *GST_CAT_PARAMS;
272 GST_EXPORT GstDebugCategory *GST_CAT_CALL_TRACE;
273 GST_EXPORT GstDebugCategory *GST_CAT_SIGNAL;
274 GST_EXPORT GstDebugCategory *GST_CAT_PROBE;
275 GST_EXPORT GstDebugCategory *GST_CAT_REGISTRY;
276 GST_EXPORT GstDebugCategory *GST_CAT_QOS;
277 GST_EXPORT GstDebugCategory *GST_CAT_META;
278 GST_EXPORT GstDebugCategory *GST_CAT_LOCKING;
279 GST_EXPORT GstDebugCategory *GST_CAT_CONTEXT;
280
281 /* Categories that should be completely private to
282  * libgstreamer should be done like this: */
283 #define GST_CAT_POLL _priv_GST_CAT_POLL
284 extern GstDebugCategory *_priv_GST_CAT_POLL;
285
286 #define GST_CAT_PROTECTION _priv_GST_CAT_PROTECTION
287 extern GstDebugCategory *_priv_GST_CAT_PROTECTION;
288
289 extern GstClockTime _priv_gst_start_time;
290
291 #else
292
293 #define GST_CAT_GST_INIT         NULL
294 #define GST_CAT_AUTOPLUG         NULL
295 #define GST_CAT_AUTOPLUG_ATTEMPT NULL
296 #define GST_CAT_PARENTAGE        NULL
297 #define GST_CAT_STATES           NULL
298 #define GST_CAT_SCHEDULING       NULL
299 #define GST_CAT_DATAFLOW         NULL
300 #define GST_CAT_BUFFER           NULL
301 #define GST_CAT_BUFFER_LIST      NULL
302 #define GST_CAT_BUS              NULL
303 #define GST_CAT_CAPS             NULL
304 #define GST_CAT_CLOCK            NULL
305 #define GST_CAT_ELEMENT_PADS     NULL
306 #define GST_CAT_PADS             NULL
307 #define GST_CAT_PERFORMANCE      NULL
308 #define GST_CAT_PIPELINE         NULL
309 #define GST_CAT_PLUGIN_LOADING   NULL
310 #define GST_CAT_PLUGIN_INFO      NULL
311 #define GST_CAT_PROPERTIES       NULL
312 #define GST_CAT_NEGOTIATION      NULL
313 #define GST_CAT_REFCOUNTING      NULL
314 #define GST_CAT_ERROR_SYSTEM     NULL
315 #define GST_CAT_EVENT            NULL
316 #define GST_CAT_MESSAGE          NULL
317 #define GST_CAT_PARAMS           NULL
318 #define GST_CAT_CALL_TRACE       NULL
319 #define GST_CAT_SIGNAL           NULL
320 #define GST_CAT_PROBE            NULL
321 #define GST_CAT_REGISTRY         NULL
322 #define GST_CAT_QOS              NULL
323 #define GST_CAT_TYPES            NULL
324 #define GST_CAT_POLL             NULL
325 #define GST_CAT_META             NULL
326 #define GST_CAT_LOCKING          NULL
327 #define GST_CAT_CONTEXT          NULL
328 #define GST_CAT_PROTECTION       NULL
329
330 #endif
331
332 #ifdef GST_DISABLE_GST_DEBUG
333 /* for _gst_element_error_printf */
334 #define __gst_vasprintf __gst_info_fallback_vasprintf
335 int __gst_vasprintf (char **result, char const *format, va_list args);
336 #endif
337
338 /**** objects made opaque until the private bits have been made private ****/
339
340 #include <gmodule.h>
341 #include <time.h> /* time_t */
342 #include <sys/types.h> /* off_t */
343 #include <sys/stat.h> /* off_t */
344
345 typedef struct _GstPluginPrivate GstPluginPrivate;
346
347 struct _GstPlugin {
348   GstObject       object;
349
350   /*< private >*/
351   GstPluginDesc desc;
352
353   GstPluginDesc *orig_desc;
354
355   gchar *       filename;
356   gchar *       basename;       /* base name (non-dir part) of plugin path */
357
358   GModule *     module;         /* contains the module if plugin is loaded */
359
360   off_t         file_size;
361   time_t        file_mtime;
362   gboolean      registered;     /* TRUE when the registry has seen a filename
363                                  * that matches the plugin's basename */
364
365   GstPluginPrivate *priv;
366
367   gpointer _gst_reserved[GST_PADDING];
368 };
369
370 struct _GstPluginClass {
371   GstObjectClass  object_class;
372
373   /*< private >*/
374   gpointer _gst_reserved[GST_PADDING];
375 };
376
377 struct _GstPluginFeature {
378   GstObject      object;
379
380   /*< private >*/
381   gboolean       loaded;
382   guint          rank;
383
384   const gchar   *plugin_name;
385   GstPlugin     *plugin;      /* weak ref */
386
387   /*< private >*/
388   gpointer _gst_reserved[GST_PADDING];
389 };
390
391 struct _GstPluginFeatureClass {
392   GstObjectClass        parent_class;
393
394   /*< private >*/
395   gpointer _gst_reserved[GST_PADDING];
396 };
397
398 #include "gsttypefind.h"
399
400 struct _GstTypeFindFactory {
401   GstPluginFeature              feature;
402   /* <private> */
403
404   GstTypeFindFunction           function;
405   gchar **                      extensions;
406   GstCaps *                     caps;
407
408   gpointer                      user_data;
409   GDestroyNotify                user_data_notify;
410
411   gpointer _gst_reserved[GST_PADDING];
412 };
413
414 struct _GstTypeFindFactoryClass {
415   GstPluginFeatureClass         parent;
416   /* <private> */
417
418   gpointer _gst_reserved[GST_PADDING];
419 };
420
421 struct _GstTracerFactory {
422   GstPluginFeature              feature;
423   /* <private> */
424
425   GType                         type;
426
427   /*
428   gpointer                      user_data;
429   GDestroyNotify                user_data_notify;
430   */
431
432   gpointer _gst_reserved[GST_PADDING];
433 };
434
435 struct _GstTracerFactoryClass {
436   GstPluginFeatureClass         parent;
437   /* <private> */
438
439   gpointer _gst_reserved[GST_PADDING];
440 };
441
442 struct _GstElementFactory {
443   GstPluginFeature      parent;
444
445   GType                 type;                   /* unique GType of element or 0 if not loaded */
446
447   gpointer              metadata;
448
449   GList *               staticpadtemplates;     /* GstStaticPadTemplate list */
450   guint                 numpadtemplates;
451
452   /* URI interface stuff */
453   GstURIType            uri_type;
454   gchar **              uri_protocols;
455
456   GList *               interfaces;             /* interface type names this element implements */
457
458   /*< private >*/
459   gpointer _gst_reserved[GST_PADDING];
460 };
461
462 struct _GstElementFactoryClass {
463   GstPluginFeatureClass parent_class;
464
465   gpointer _gst_reserved[GST_PADDING];
466 };
467
468 struct _GstDeviceProviderFactory {
469   GstPluginFeature           feature;
470   /* <private> */
471
472   GType                      type;              /* unique GType the device factory or 0 if not loaded */
473
474   volatile GstDeviceProvider *provider;
475   gpointer                   metadata;
476
477   gpointer _gst_reserved[GST_PADDING];
478 };
479
480 struct _GstDeviceProviderFactoryClass {
481   GstPluginFeatureClass         parent;
482   /* <private> */
483
484   gpointer _gst_reserved[GST_PADDING];
485 };
486
487 struct _GstDynamicTypeFactory {
488   GstPluginFeature           feature;
489
490   GType                      type; /* GType of the type, when loaded. 0 if not */
491 };
492
493 struct _GstDynamicTypeFactoryClass {
494   GstPluginFeatureClass      parent;
495 };
496
497 /* privat flag used by GstBus / GstMessage */
498 #define GST_MESSAGE_FLAG_ASYNC_DELIVERY (GST_MINI_OBJECT_FLAG_LAST << 0)
499
500 G_END_DECLS
501 #endif /* __GST_PRIVATE_H__ */