2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
5 * gst_private.h: Private header for within libgst
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.
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.
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.
23 #ifndef __GST_PRIVATE_H__
24 #define __GST_PRIVATE_H__
27 # ifndef GST_LICENSE /* don't include config.h twice, it has no guards */
32 /* This needs to be before glib.h, since it might be used in inline
34 extern const char g_log_domain_gstreamer[];
41 /* Needed for GST_EXPORT */
42 #include "gst/gstconfig.h"
44 /* Needed for GstRegistry * */
45 #include "gstregistry.h"
46 #include "gststructure.h"
48 /* we need this in pretty much all files */
51 /* for the flags in the GstPluginDep structure below */
52 #include "gstplugin.h"
54 /* for the pad cache */
58 #include "gstelement.h"
60 /* for GstDeviceProvider */
61 #include "gstdeviceprovider.h"
66 #include "gstdatetime.h"
68 #include "gsttracerutils.h"
72 /* used by gstparse.c and grammar.y */
73 struct _GstParseContext {
74 GList * missing_elements;
77 /* used by gstplugin.c and gstregistrybinary.c */
79 /* details registered via gst_plugin_add_dependency() */
80 GstPluginDependencyFlags flags;
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 */
90 struct _GstPluginPrivate {
91 GList *deps; /* list of GstPluginDep structures */
92 GstStructure *cache_data;
95 /* FIXME: could rename all priv_gst_* functions to __gst_* now */
96 G_GNUC_INTERNAL gboolean priv_gst_plugin_loading_have_whitelist (void);
98 G_GNUC_INTERNAL guint32 priv_gst_plugin_loading_get_whitelist_hash (void);
100 G_GNUC_INTERNAL gboolean priv_gst_plugin_desc_is_whitelisted (const GstPluginDesc * desc,
101 const gchar * filename);
103 G_GNUC_INTERNAL gboolean _priv_plugin_deps_env_vars_changed (GstPlugin * plugin);
105 G_GNUC_INTERNAL gboolean _priv_plugin_deps_files_changed (GstPlugin * plugin);
107 G_GNUC_INTERNAL gboolean _priv_gst_in_valgrind (void);
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);
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);
138 /* called from gst_task_cleanup_all(). */
139 G_GNUC_INTERNAL void _priv_gst_element_cleanup (void);
141 /* Private registry functions */
143 gboolean _priv_gst_registry_remove_cache_plugins (GstRegistry *registry);
145 G_GNUC_INTERNAL void _priv_gst_registry_cleanup (void);
148 gboolean _gst_plugin_loader_client_run (void);
150 G_GNUC_INTERNAL GstPlugin * _priv_gst_plugin_load_file_for_registry (const gchar *filename,
151 GstRegistry * registry,
154 /* GValue serialization/deserialization */
156 G_GNUC_INTERNAL const char * _priv_gst_value_gtype_to_abbr (GType type);
158 G_GNUC_INTERNAL gboolean _priv_gst_value_parse_string (gchar * s, gchar ** end, gchar ** next, gboolean unescape);
159 G_GNUC_INTERNAL gboolean _priv_gst_value_parse_simple_string (gchar * str, gchar ** end);
160 G_GNUC_INTERNAL gboolean _priv_gst_value_parse_value (gchar * str, gchar ** after, GValue * value, GType default_type);
161 G_GNUC_INTERNAL gchar * _priv_gst_value_serialize_any_list (const GValue * value, const gchar * begin, const gchar * end, gboolean print_type);
163 /* Used in GstBin for manual state handling */
164 G_GNUC_INTERNAL void _priv_gst_element_state_changed (GstElement *element,
165 GstState oldstate, GstState newstate, GstState pending);
167 /* used in both gststructure.c and gstcaps.c; numbers are completely made up */
168 #define STRUCTURE_ESTIMATED_STRING_LEN(s) (16 + gst_structure_n_fields(s) * 22)
169 #define FEATURES_ESTIMATED_STRING_LEN(s) (16 + gst_caps_features_get_size(s) * 14)
172 gboolean priv_gst_structure_append_to_gstring (const GstStructure * structure,
175 gboolean priv__gst_structure_append_template_to_gstring (GQuark field_id,
180 void priv_gst_caps_features_append_to_gstring (const GstCapsFeatures * features, GString *s);
183 gboolean priv_gst_structure_parse_name (gchar * str, gchar **start, gchar ** end, gchar ** next);
185 gboolean priv_gst_structure_parse_fields (gchar *str, gchar ** end, GstStructure *structure);
187 /* used in gstvalue.c and gststructure.c */
189 #define GST_WRAPPED_PTR_FORMAT "p\aa"
192 gchar *priv_gst_string_take_and_wrap (gchar * s);
194 /* registry cache backends */
196 gboolean priv_gst_registry_binary_read_cache (GstRegistry * registry, const char *location);
199 gboolean priv_gst_registry_binary_write_cache (GstRegistry * registry, GList * plugins, const char *location);
203 void __gst_element_factory_add_static_pad_template (GstElementFactory * elementfactory,
204 GstStaticPadTemplate * templ);
207 void __gst_element_factory_add_interface (GstElementFactory * elementfactory,
208 const gchar * interfacename);
210 /* used in gstvalue.c and gststructure.c */
211 #define GST_ASCII_IS_STRING(c) (g_ascii_isalnum((c)) || ((c) == '_') || \
212 ((c) == '-') || ((c) == '+') || ((c) == '/') || ((c) == ':') || \
215 /* This is only meant for internal uses */
217 gint __gst_date_time_compare (const GstDateTime * dt1, const GstDateTime * dt2);
220 gchar * __gst_date_time_serialize (GstDateTime * datetime, gboolean with_usecs);
222 /* For use in gstdebugutils */
224 GstCapsFeatures * __gst_caps_get_features_unchecked (const GstCaps * caps, guint idx);
226 #ifndef GST_DISABLE_REGISTRY
227 /* Secret variable to initialise gst without registry cache */
229 GST_EXPORT gboolean _gst_disable_registry_cache;
232 /* Secret variable to let the plugin scanner use the same base path
233 * as the main application in order to determine dependencies */
234 GST_EXPORT gchar *_gst_executable_path;
236 /* provide inline gst_g_value_get_foo_unchecked(), used in gststructure.c */
237 #define DEFINE_INLINE_G_VALUE_GET_UNCHECKED(ret_type,name_type,v_field) \
238 static inline ret_type \
239 gst_g_value_get_##name_type##_unchecked (const GValue *value) \
241 return value->data[0].v_field; \
244 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gboolean,boolean,v_int)
245 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gint,int,v_int)
246 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(guint,uint,v_uint)
247 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gint64,int64,v_int64)
248 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(guint64,uint64,v_uint64)
249 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gfloat,float,v_float)
250 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gdouble,double,v_double)
251 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(const gchar *,string,v_pointer)
254 /*** debugging categories *****************************************************/
256 #ifndef GST_REMOVE_GST_DEBUG
258 GST_EXPORT GstDebugCategory *GST_CAT_GST_INIT;
259 GST_EXPORT GstDebugCategory *GST_CAT_MEMORY;
260 GST_EXPORT GstDebugCategory *GST_CAT_PARENTAGE;
261 GST_EXPORT GstDebugCategory *GST_CAT_STATES;
262 GST_EXPORT GstDebugCategory *GST_CAT_SCHEDULING;
263 GST_EXPORT GstDebugCategory *GST_CAT_BUFFER;
264 GST_EXPORT GstDebugCategory *GST_CAT_BUFFER_LIST;
265 GST_EXPORT GstDebugCategory *GST_CAT_BUS;
266 GST_EXPORT GstDebugCategory *GST_CAT_CAPS;
267 GST_EXPORT GstDebugCategory *GST_CAT_CLOCK;
268 GST_EXPORT GstDebugCategory *GST_CAT_ELEMENT_PADS;
269 GST_EXPORT GstDebugCategory *GST_CAT_PADS;
270 GST_EXPORT GstDebugCategory *GST_CAT_PERFORMANCE;
271 GST_EXPORT GstDebugCategory *GST_CAT_PIPELINE;
272 GST_EXPORT GstDebugCategory *GST_CAT_PLUGIN_LOADING;
273 GST_EXPORT GstDebugCategory *GST_CAT_PLUGIN_INFO;
274 GST_EXPORT GstDebugCategory *GST_CAT_PROPERTIES;
275 GST_EXPORT GstDebugCategory *GST_CAT_NEGOTIATION;
276 GST_EXPORT GstDebugCategory *GST_CAT_REFCOUNTING;
277 GST_EXPORT GstDebugCategory *GST_CAT_ERROR_SYSTEM;
278 GST_EXPORT GstDebugCategory *GST_CAT_EVENT;
279 GST_EXPORT GstDebugCategory *GST_CAT_MESSAGE;
280 GST_EXPORT GstDebugCategory *GST_CAT_PARAMS;
281 GST_EXPORT GstDebugCategory *GST_CAT_CALL_TRACE;
282 GST_EXPORT GstDebugCategory *GST_CAT_SIGNAL;
283 GST_EXPORT GstDebugCategory *GST_CAT_PROBE;
284 GST_EXPORT GstDebugCategory *GST_CAT_REGISTRY;
285 GST_EXPORT GstDebugCategory *GST_CAT_QOS;
286 GST_EXPORT GstDebugCategory *GST_CAT_META;
287 GST_EXPORT GstDebugCategory *GST_CAT_LOCKING;
288 GST_EXPORT GstDebugCategory *GST_CAT_CONTEXT;
290 /* Categories that should be completely private to
291 * libgstreamer should be done like this: */
292 #define GST_CAT_POLL _priv_GST_CAT_POLL
293 extern GstDebugCategory *_priv_GST_CAT_POLL;
295 #define GST_CAT_PROTECTION _priv_GST_CAT_PROTECTION
296 extern GstDebugCategory *_priv_GST_CAT_PROTECTION;
298 extern GstClockTime _priv_gst_start_time;
302 #define GST_CAT_GST_INIT NULL
303 #define GST_CAT_AUTOPLUG NULL
304 #define GST_CAT_AUTOPLUG_ATTEMPT NULL
305 #define GST_CAT_PARENTAGE NULL
306 #define GST_CAT_STATES NULL
307 #define GST_CAT_SCHEDULING NULL
308 #define GST_CAT_DATAFLOW NULL
309 #define GST_CAT_BUFFER NULL
310 #define GST_CAT_BUFFER_LIST NULL
311 #define GST_CAT_BUS NULL
312 #define GST_CAT_CAPS NULL
313 #define GST_CAT_CLOCK NULL
314 #define GST_CAT_ELEMENT_PADS NULL
315 #define GST_CAT_PADS NULL
316 #define GST_CAT_PERFORMANCE NULL
317 #define GST_CAT_PIPELINE NULL
318 #define GST_CAT_PLUGIN_LOADING NULL
319 #define GST_CAT_PLUGIN_INFO NULL
320 #define GST_CAT_PROPERTIES NULL
321 #define GST_CAT_NEGOTIATION NULL
322 #define GST_CAT_REFCOUNTING NULL
323 #define GST_CAT_ERROR_SYSTEM NULL
324 #define GST_CAT_EVENT NULL
325 #define GST_CAT_MESSAGE NULL
326 #define GST_CAT_PARAMS NULL
327 #define GST_CAT_CALL_TRACE NULL
328 #define GST_CAT_SIGNAL NULL
329 #define GST_CAT_PROBE NULL
330 #define GST_CAT_REGISTRY NULL
331 #define GST_CAT_QOS NULL
332 #define GST_CAT_TYPES NULL
333 #define GST_CAT_POLL NULL
334 #define GST_CAT_META NULL
335 #define GST_CAT_LOCKING NULL
336 #define GST_CAT_CONTEXT NULL
337 #define GST_CAT_PROTECTION NULL
341 #ifdef GST_DISABLE_GST_DEBUG
342 /* for _gst_element_error_printf */
343 #define __gst_vasprintf __gst_info_fallback_vasprintf
344 int __gst_vasprintf (char **result, char const *format, va_list args);
347 /**** objects made opaque until the private bits have been made private ****/
350 #include <time.h> /* time_t */
351 #include <sys/types.h> /* off_t */
352 #include <sys/stat.h> /* off_t */
354 typedef struct _GstPluginPrivate GstPluginPrivate;
363 gchar * basename; /* base name (non-dir part) of plugin path */
365 GModule * module; /* contains the module if plugin is loaded */
369 gboolean registered; /* TRUE when the registry has seen a filename
370 * that matches the plugin's basename */
372 GstPluginPrivate *priv;
374 gpointer _gst_reserved[GST_PADDING];
377 struct _GstPluginClass {
378 GstObjectClass object_class;
381 gpointer _gst_reserved[GST_PADDING];
384 struct _GstPluginFeature {
391 const gchar *plugin_name;
392 GstPlugin *plugin; /* weak ref */
395 gpointer _gst_reserved[GST_PADDING];
398 struct _GstPluginFeatureClass {
399 GstObjectClass parent_class;
402 gpointer _gst_reserved[GST_PADDING];
405 #include "gsttypefind.h"
407 struct _GstTypeFindFactory {
408 GstPluginFeature feature;
411 GstTypeFindFunction function;
416 GDestroyNotify user_data_notify;
418 gpointer _gst_reserved[GST_PADDING];
421 struct _GstTypeFindFactoryClass {
422 GstPluginFeatureClass parent;
425 gpointer _gst_reserved[GST_PADDING];
428 struct _GstTracerFactory {
429 GstPluginFeature feature;
436 GDestroyNotify user_data_notify;
439 gpointer _gst_reserved[GST_PADDING];
442 struct _GstTracerFactoryClass {
443 GstPluginFeatureClass parent;
446 gpointer _gst_reserved[GST_PADDING];
449 struct _GstElementFactory {
450 GstPluginFeature parent;
452 GType type; /* unique GType of element or 0 if not loaded */
456 GList * staticpadtemplates; /* GstStaticPadTemplate list */
457 guint numpadtemplates;
459 /* URI interface stuff */
461 gchar ** uri_protocols;
463 GList * interfaces; /* interface type names this element implements */
466 gpointer _gst_reserved[GST_PADDING];
469 struct _GstElementFactoryClass {
470 GstPluginFeatureClass parent_class;
472 gpointer _gst_reserved[GST_PADDING];
475 struct _GstDeviceProviderFactory {
476 GstPluginFeature feature;
479 GType type; /* unique GType the device factory or 0 if not loaded */
481 volatile GstDeviceProvider *provider;
484 gpointer _gst_reserved[GST_PADDING];
487 struct _GstDeviceProviderFactoryClass {
488 GstPluginFeatureClass parent;
491 gpointer _gst_reserved[GST_PADDING];
494 struct _GstDynamicTypeFactory {
495 GstPluginFeature feature;
497 GType type; /* GType of the type, when loaded. 0 if not */
500 struct _GstDynamicTypeFactoryClass {
501 GstPluginFeatureClass parent;
504 /* privat flag used by GstBus / GstMessage */
505 #define GST_MESSAGE_FLAG_ASYNC_DELIVERY (GST_MINI_OBJECT_FLAG_LAST << 0)
508 #endif /* __GST_PRIVATE_H__ */