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 GstRegistry * */
42 #include "gstregistry.h"
43 #include "gststructure.h"
45 /* we need this in pretty much all files */
48 /* for the flags in the GstPluginDep structure below */
49 #include "gstplugin.h"
51 /* for the pad cache */
55 #include "gstelement.h"
57 /* for GstDeviceProvider */
58 #include "gstdeviceprovider.h"
63 #include "gstdatetime.h"
65 #include "gsttracerutils.h"
69 /* used by gstparse.c and grammar.y */
70 struct _GstParseContext {
71 GList * missing_elements;
74 /* used by gstplugin.c and gstregistrybinary.c */
76 /* details registered via gst_plugin_add_dependency() */
77 GstPluginDependencyFlags flags;
82 /* information saved from the last time the plugin was loaded (-1 = unset) */
83 guint env_hash; /* hash of content of environment variables in env_vars */
84 guint stat_hash; /* hash of stat() on all relevant files and directories */
87 struct _GstPluginPrivate {
88 GList *deps; /* list of GstPluginDep structures */
89 GstStructure *cache_data;
92 /* FIXME: could rename all priv_gst_* functions to __gst_* now */
93 G_GNUC_INTERNAL gboolean priv_gst_plugin_loading_have_whitelist (void);
95 G_GNUC_INTERNAL guint32 priv_gst_plugin_loading_get_whitelist_hash (void);
97 G_GNUC_INTERNAL gboolean priv_gst_plugin_desc_is_whitelisted (GstPluginDesc * desc,
98 const gchar * filename);
100 G_GNUC_INTERNAL gboolean _priv_plugin_deps_env_vars_changed (GstPlugin * plugin);
102 G_GNUC_INTERNAL gboolean _priv_plugin_deps_files_changed (GstPlugin * plugin);
104 G_GNUC_INTERNAL gboolean _priv_gst_in_valgrind (void);
106 /* init functions called from gst_init(). */
107 G_GNUC_INTERNAL void _priv_gst_quarks_initialize (void);
108 G_GNUC_INTERNAL void _priv_gst_mini_object_initialize (void);
109 G_GNUC_INTERNAL void _priv_gst_memory_initialize (void);
110 G_GNUC_INTERNAL void _priv_gst_allocator_initialize (void);
111 G_GNUC_INTERNAL void _priv_gst_buffer_initialize (void);
112 G_GNUC_INTERNAL void _priv_gst_buffer_list_initialize (void);
113 G_GNUC_INTERNAL void _priv_gst_structure_initialize (void);
114 G_GNUC_INTERNAL void _priv_gst_caps_initialize (void);
115 G_GNUC_INTERNAL void _priv_gst_caps_features_initialize (void);
116 G_GNUC_INTERNAL void _priv_gst_event_initialize (void);
117 G_GNUC_INTERNAL void _priv_gst_format_initialize (void);
118 G_GNUC_INTERNAL void _priv_gst_message_initialize (void);
119 G_GNUC_INTERNAL void _priv_gst_meta_initialize (void);
120 G_GNUC_INTERNAL void _priv_gst_plugin_initialize (void);
121 G_GNUC_INTERNAL void _priv_gst_query_initialize (void);
122 G_GNUC_INTERNAL void _priv_gst_sample_initialize (void);
123 G_GNUC_INTERNAL void _priv_gst_tag_initialize (void);
124 G_GNUC_INTERNAL void _priv_gst_value_initialize (void);
125 G_GNUC_INTERNAL void _priv_gst_debug_init (void);
126 G_GNUC_INTERNAL void _priv_gst_context_initialize (void);
127 G_GNUC_INTERNAL void _priv_gst_toc_initialize (void);
128 G_GNUC_INTERNAL void _priv_gst_date_time_initialize (void);
130 /* Private registry functions */
132 gboolean _priv_gst_registry_remove_cache_plugins (GstRegistry *registry);
134 G_GNUC_INTERNAL void _priv_gst_registry_cleanup (void);
136 gboolean _gst_plugin_loader_client_run (void);
138 G_GNUC_INTERNAL GstPlugin * _priv_gst_plugin_load_file_for_registry (const gchar *filename,
139 GstRegistry * registry,
142 /* Used in GstBin for manual state handling */
143 G_GNUC_INTERNAL void _priv_gst_element_state_changed (GstElement *element,
144 GstState oldstate, GstState newstate, GstState pending);
146 /* used in both gststructure.c and gstcaps.c; numbers are completely made up */
147 #define STRUCTURE_ESTIMATED_STRING_LEN(s) (16 + gst_structure_n_fields(s) * 22)
148 #define FEATURES_ESTIMATED_STRING_LEN(s) (16 + gst_caps_features_get_size(s) * 14)
151 gboolean priv_gst_structure_append_to_gstring (const GstStructure * structure,
154 gboolean priv__gst_structure_append_template_to_gstring (GQuark field_id,
159 void priv_gst_caps_features_append_to_gstring (const GstCapsFeatures * features, GString *s);
162 gboolean priv_gst_structure_parse_name (gchar * str, gchar **start, gchar ** end, gchar ** next);
164 gboolean priv_gst_structure_parse_fields (gchar *str, gchar ** end, GstStructure *structure);
166 /* used in gstvalue.c and gststructure.c */
168 #define GST_WRAPPED_PTR_FORMAT "p\aa"
171 gchar *priv_gst_string_take_and_wrap (gchar * s);
173 /* registry cache backends */
175 gboolean priv_gst_registry_binary_read_cache (GstRegistry * registry, const char *location);
178 gboolean priv_gst_registry_binary_write_cache (GstRegistry * registry, GList * plugins, const char *location);
182 void __gst_element_factory_add_static_pad_template (GstElementFactory * elementfactory,
183 GstStaticPadTemplate * templ);
186 void __gst_element_factory_add_interface (GstElementFactory * elementfactory,
187 const gchar * interfacename);
189 /* used in gstvalue.c and gststructure.c */
190 #define GST_ASCII_IS_STRING(c) (g_ascii_isalnum((c)) || ((c) == '_') || \
191 ((c) == '-') || ((c) == '+') || ((c) == '/') || ((c) == ':') || \
194 /* This is only meant for internal uses */
196 gint __gst_date_time_compare (const GstDateTime * dt1, const GstDateTime * dt2);
199 gchar * __gst_date_time_serialize (GstDateTime * datetime, gboolean with_usecs);
201 /* Non-static, for access from the testsuite, but not for external use */
203 _priv_gst_do_linear_regression (GstClockTime *times, guint n,
204 GstClockTime * m_num, GstClockTime * m_denom, GstClockTime * b,
205 GstClockTime * xbase, gdouble * r_squared);
207 /* For use in gstdebugutils */
209 GstCapsFeatures * __gst_caps_get_features_unchecked (const GstCaps * caps, guint idx);
211 #ifndef GST_DISABLE_REGISTRY
212 /* Secret variable to initialise gst without registry cache */
213 GST_EXPORT gboolean _gst_disable_registry_cache;
216 /* provide inline gst_g_value_get_foo_unchecked(), used in gststructure.c */
217 #define DEFINE_INLINE_G_VALUE_GET_UNCHECKED(ret_type,name_type,v_field) \
218 static inline ret_type \
219 gst_g_value_get_##name_type##_unchecked (const GValue *value) \
221 return value->data[0].v_field; \
224 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gboolean,boolean,v_int)
225 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gint,int,v_int)
226 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(guint,uint,v_uint)
227 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gint64,int64,v_int64)
228 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(guint64,uint64,v_uint64)
229 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gfloat,float,v_float)
230 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gdouble,double,v_double)
231 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(const gchar *,string,v_pointer)
234 /*** debugging categories *****************************************************/
236 #ifndef GST_REMOVE_GST_DEBUG
238 GST_EXPORT GstDebugCategory *GST_CAT_GST_INIT;
239 GST_EXPORT GstDebugCategory *GST_CAT_MEMORY;
240 GST_EXPORT GstDebugCategory *GST_CAT_PARENTAGE;
241 GST_EXPORT GstDebugCategory *GST_CAT_STATES;
242 GST_EXPORT GstDebugCategory *GST_CAT_SCHEDULING;
243 GST_EXPORT GstDebugCategory *GST_CAT_BUFFER;
244 GST_EXPORT GstDebugCategory *GST_CAT_BUFFER_LIST;
245 GST_EXPORT GstDebugCategory *GST_CAT_BUS;
246 GST_EXPORT GstDebugCategory *GST_CAT_CAPS;
247 GST_EXPORT GstDebugCategory *GST_CAT_CLOCK;
248 GST_EXPORT GstDebugCategory *GST_CAT_ELEMENT_PADS;
249 GST_EXPORT GstDebugCategory *GST_CAT_PADS;
250 GST_EXPORT GstDebugCategory *GST_CAT_PERFORMANCE;
251 GST_EXPORT GstDebugCategory *GST_CAT_PIPELINE;
252 GST_EXPORT GstDebugCategory *GST_CAT_PLUGIN_LOADING;
253 GST_EXPORT GstDebugCategory *GST_CAT_PLUGIN_INFO;
254 GST_EXPORT GstDebugCategory *GST_CAT_PROPERTIES;
255 GST_EXPORT GstDebugCategory *GST_CAT_NEGOTIATION;
256 GST_EXPORT GstDebugCategory *GST_CAT_REFCOUNTING;
257 GST_EXPORT GstDebugCategory *GST_CAT_ERROR_SYSTEM;
258 GST_EXPORT GstDebugCategory *GST_CAT_EVENT;
259 GST_EXPORT GstDebugCategory *GST_CAT_MESSAGE;
260 GST_EXPORT GstDebugCategory *GST_CAT_PARAMS;
261 GST_EXPORT GstDebugCategory *GST_CAT_CALL_TRACE;
262 GST_EXPORT GstDebugCategory *GST_CAT_SIGNAL;
263 GST_EXPORT GstDebugCategory *GST_CAT_PROBE;
264 GST_EXPORT GstDebugCategory *GST_CAT_REGISTRY;
265 GST_EXPORT GstDebugCategory *GST_CAT_QOS;
266 GST_EXPORT GstDebugCategory *GST_CAT_META;
267 GST_EXPORT GstDebugCategory *GST_CAT_LOCKING;
268 GST_EXPORT GstDebugCategory *GST_CAT_CONTEXT;
270 /* Categories that should be completely private to
271 * libgstreamer should be done like this: */
272 #define GST_CAT_POLL _priv_GST_CAT_POLL
273 extern GstDebugCategory *_priv_GST_CAT_POLL;
275 #define GST_CAT_PROTECTION _priv_GST_CAT_PROTECTION
276 extern GstDebugCategory *_priv_GST_CAT_PROTECTION;
278 extern GstClockTime _priv_gst_start_time;
282 #define GST_CAT_GST_INIT NULL
283 #define GST_CAT_AUTOPLUG NULL
284 #define GST_CAT_AUTOPLUG_ATTEMPT NULL
285 #define GST_CAT_PARENTAGE NULL
286 #define GST_CAT_STATES NULL
287 #define GST_CAT_SCHEDULING NULL
288 #define GST_CAT_DATAFLOW NULL
289 #define GST_CAT_BUFFER NULL
290 #define GST_CAT_BUFFER_LIST NULL
291 #define GST_CAT_BUS NULL
292 #define GST_CAT_CAPS NULL
293 #define GST_CAT_CLOCK NULL
294 #define GST_CAT_ELEMENT_PADS NULL
295 #define GST_CAT_PADS NULL
296 #define GST_CAT_PERFORMANCE NULL
297 #define GST_CAT_PIPELINE NULL
298 #define GST_CAT_PLUGIN_LOADING NULL
299 #define GST_CAT_PLUGIN_INFO NULL
300 #define GST_CAT_PROPERTIES NULL
301 #define GST_CAT_NEGOTIATION NULL
302 #define GST_CAT_REFCOUNTING NULL
303 #define GST_CAT_ERROR_SYSTEM NULL
304 #define GST_CAT_EVENT NULL
305 #define GST_CAT_MESSAGE NULL
306 #define GST_CAT_PARAMS NULL
307 #define GST_CAT_CALL_TRACE NULL
308 #define GST_CAT_SIGNAL NULL
309 #define GST_CAT_PROBE NULL
310 #define GST_CAT_REGISTRY NULL
311 #define GST_CAT_QOS NULL
312 #define GST_CAT_TYPES NULL
313 #define GST_CAT_POLL NULL
314 #define GST_CAT_META NULL
315 #define GST_CAT_LOCKING NULL
316 #define GST_CAT_CONTEXT NULL
317 #define GST_CAT_PROTECTION NULL
321 #ifdef GST_DISABLE_GST_DEBUG
322 /* for _gst_element_error_printf */
323 #define __gst_vasprintf __gst_info_fallback_vasprintf
324 int __gst_vasprintf (char **result, char const *format, va_list args);
327 /**** objects made opaque until the private bits have been made private ****/
330 #include <time.h> /* time_t */
331 #include <sys/types.h> /* off_t */
332 #include <sys/stat.h> /* off_t */
334 typedef struct _GstPluginPrivate GstPluginPrivate;
342 GstPluginDesc *orig_desc;
345 gchar * basename; /* base name (non-dir part) of plugin path */
347 GModule * module; /* contains the module if plugin is loaded */
351 gboolean registered; /* TRUE when the registry has seen a filename
352 * that matches the plugin's basename */
354 GstPluginPrivate *priv;
356 gpointer _gst_reserved[GST_PADDING];
359 struct _GstPluginClass {
360 GstObjectClass object_class;
363 gpointer _gst_reserved[GST_PADDING];
366 struct _GstPluginFeature {
373 const gchar *plugin_name;
374 GstPlugin *plugin; /* weak ref */
377 gpointer _gst_reserved[GST_PADDING];
380 struct _GstPluginFeatureClass {
381 GstObjectClass parent_class;
384 gpointer _gst_reserved[GST_PADDING];
387 #include "gsttypefind.h"
389 struct _GstTypeFindFactory {
390 GstPluginFeature feature;
393 GstTypeFindFunction function;
398 GDestroyNotify user_data_notify;
400 gpointer _gst_reserved[GST_PADDING];
403 struct _GstTypeFindFactoryClass {
404 GstPluginFeatureClass parent;
407 gpointer _gst_reserved[GST_PADDING];
410 struct _GstTracerFactory {
411 GstPluginFeature feature;
418 GDestroyNotify user_data_notify;
421 gpointer _gst_reserved[GST_PADDING];
424 struct _GstTracerFactoryClass {
425 GstPluginFeatureClass parent;
428 gpointer _gst_reserved[GST_PADDING];
431 struct _GstElementFactory {
432 GstPluginFeature parent;
434 GType type; /* unique GType of element or 0 if not loaded */
438 GList * staticpadtemplates; /* GstStaticPadTemplate list */
439 guint numpadtemplates;
441 /* URI interface stuff */
443 gchar ** uri_protocols;
445 GList * interfaces; /* interface type names this element implements */
448 gpointer _gst_reserved[GST_PADDING];
451 struct _GstElementFactoryClass {
452 GstPluginFeatureClass parent_class;
454 gpointer _gst_reserved[GST_PADDING];
457 struct _GstDeviceProviderFactory {
458 GstPluginFeature feature;
461 GType type; /* unique GType the device factory or 0 if not loaded */
463 volatile GstDeviceProvider *provider;
466 gpointer _gst_reserved[GST_PADDING];
469 struct _GstDeviceProviderFactoryClass {
470 GstPluginFeatureClass parent;
473 gpointer _gst_reserved[GST_PADDING];
476 /* privat flag used by GstBus / GstMessage */
477 #define GST_MESSAGE_FLAG_ASYNC_DELIVERY (GST_MINI_OBJECT_FLAG_LAST << 0)
480 #endif /* __GST_PRIVATE_H__ */