info: add new locking debug category
[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., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, 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 gboolean priv_gst_plugin_loading_have_whitelist (void);
89
90 guint32  priv_gst_plugin_loading_get_whitelist_hash (void);
91
92 gboolean priv_gst_plugin_desc_is_whitelisted (GstPluginDesc * desc,
93                                               const gchar   * filename);
94
95 gboolean _priv_plugin_deps_env_vars_changed (GstPlugin * plugin);
96 gboolean _priv_plugin_deps_files_changed (GstPlugin * plugin);
97
98 gboolean _priv_gst_in_valgrind (void);
99
100 /* init functions called from gst_init(). */
101 void  _priv_gst_quarks_initialize (void);
102 void  _priv_gst_mini_object_initialize (void);
103 void  _priv_gst_buffer_initialize (void);
104 void  _priv_gst_buffer_list_initialize (void);
105 void  _priv_gst_structure_initialize (void);
106 void  _priv_gst_caps_initialize (void);
107 void  _priv_gst_event_initialize (void);
108 void  _priv_gst_format_initialize (void);
109 void  _priv_gst_message_initialize (void);
110 void  _priv_gst_memory_initialize (void);
111 void  _priv_gst_meta_initialize (void);
112 void  _priv_gst_plugin_initialize (void);
113 void  _priv_gst_query_initialize (void);
114 void  _priv_gst_sample_initialize (void);
115 void  _priv_gst_tag_initialize (void);
116 void  _priv_gst_value_initialize (void);
117 void  _priv_gst_debug_init (void);
118
119 /* Private registry functions */
120 gboolean _priv_gst_registry_remove_cache_plugins (GstRegistry *registry);
121 void _priv_gst_registry_cleanup (void);
122 gboolean _gst_plugin_loader_client_run (void);
123
124 /* Used in GstBin for manual state handling */
125 void _priv_gst_element_state_changed (GstElement *element, GstState oldstate,
126     GstState newstate, GstState pending);
127
128 /* used in both gststructure.c and gstcaps.c; numbers are completely made up */
129 #define STRUCTURE_ESTIMATED_STRING_LEN(s) (16 + gst_structure_n_fields(s) * 22)
130
131 gboolean  priv_gst_structure_append_to_gstring (const GstStructure * structure,
132                                                 GString            * s);
133 /* registry cache backends */
134 gboolean                priv_gst_registry_binary_read_cache     (GstRegistry * registry, const char *location);
135 gboolean                priv_gst_registry_binary_write_cache    (GstRegistry * registry, GList * plugins, const char *location);
136
137 void      __gst_element_factory_add_static_pad_template (GstElementFactory    * elementfactory,
138                                                          GstStaticPadTemplate * templ);
139
140 void      __gst_element_factory_add_interface           (GstElementFactory    * elementfactory,
141                                                          const gchar          * interfacename);
142
143 /* used in gstvalue.c and gststructure.c */
144 #define GST_ASCII_IS_STRING(c) (g_ascii_isalnum((c)) || ((c) == '_') || \
145     ((c) == '-') || ((c) == '+') || ((c) == '/') || ((c) == ':') || \
146     ((c) == '.'))
147
148 /* This is only meant for internal uses */
149 gint __gst_date_time_compare (const GstDateTime * dt1, const GstDateTime * dt2);
150
151 #ifndef GST_DISABLE_REGISTRY
152 /* Secret variable to initialise gst without registry cache */
153 GST_EXPORT gboolean _gst_disable_registry_cache;
154 #endif
155
156 /* provide inline gst_g_value_get_foo_unchecked(), used in gststructure.c */
157 #define DEFINE_INLINE_G_VALUE_GET_UNCHECKED(ret_type,name_type,v_field) \
158 static inline ret_type                                                  \
159 gst_g_value_get_##name_type##_unchecked (const GValue *value)           \
160 {                                                                       \
161   return value->data[0].v_field;                                        \
162 }
163
164 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gboolean,boolean,v_int)
165 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gint,int,v_int)
166 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(guint,uint,v_uint)
167 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gint64,int64,v_int64)
168 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(guint64,uint64,v_uint64)
169 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gfloat,float,v_float)
170 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(gdouble,double,v_double)
171 DEFINE_INLINE_G_VALUE_GET_UNCHECKED(const gchar *,string,v_pointer)
172
173
174 /*** debugging categories *****************************************************/
175
176 #ifndef GST_REMOVE_GST_DEBUG
177
178 GST_EXPORT GstDebugCategory *GST_CAT_GST_INIT;
179 GST_EXPORT GstDebugCategory *GST_CAT_MEMORY;
180 GST_EXPORT GstDebugCategory *GST_CAT_PARENTAGE;
181 GST_EXPORT GstDebugCategory *GST_CAT_STATES;
182 GST_EXPORT GstDebugCategory *GST_CAT_SCHEDULING;
183 GST_EXPORT GstDebugCategory *GST_CAT_BUFFER;
184 GST_EXPORT GstDebugCategory *GST_CAT_BUFFER_LIST;
185 GST_EXPORT GstDebugCategory *GST_CAT_BUS;
186 GST_EXPORT GstDebugCategory *GST_CAT_CAPS;
187 GST_EXPORT GstDebugCategory *GST_CAT_CLOCK;
188 GST_EXPORT GstDebugCategory *GST_CAT_ELEMENT_PADS;
189 GST_EXPORT GstDebugCategory *GST_CAT_PADS;
190 GST_EXPORT GstDebugCategory *GST_CAT_PERFORMANCE;
191 GST_EXPORT GstDebugCategory *GST_CAT_PIPELINE;
192 GST_EXPORT GstDebugCategory *GST_CAT_PLUGIN_LOADING;
193 GST_EXPORT GstDebugCategory *GST_CAT_PLUGIN_INFO;
194 GST_EXPORT GstDebugCategory *GST_CAT_PROPERTIES;
195 GST_EXPORT GstDebugCategory *GST_CAT_NEGOTIATION;
196 GST_EXPORT GstDebugCategory *GST_CAT_REFCOUNTING;
197 GST_EXPORT GstDebugCategory *GST_CAT_ERROR_SYSTEM;
198 GST_EXPORT GstDebugCategory *GST_CAT_EVENT;
199 GST_EXPORT GstDebugCategory *GST_CAT_MESSAGE;
200 GST_EXPORT GstDebugCategory *GST_CAT_PARAMS;
201 GST_EXPORT GstDebugCategory *GST_CAT_CALL_TRACE;
202 GST_EXPORT GstDebugCategory *GST_CAT_SIGNAL;
203 GST_EXPORT GstDebugCategory *GST_CAT_PROBE;
204 GST_EXPORT GstDebugCategory *GST_CAT_REGISTRY;
205 GST_EXPORT GstDebugCategory *GST_CAT_QOS;
206 GST_EXPORT GstDebugCategory *GST_CAT_META;
207 GST_EXPORT GstDebugCategory *GST_CAT_LOCKING;
208
209 /* Categories that should be completely private to
210  * libgstreamer should be done like this: */
211 #define GST_CAT_POLL _priv_GST_CAT_POLL
212 extern GstDebugCategory *_priv_GST_CAT_POLL;
213
214 #else
215
216 #define GST_CAT_GST_INIT         NULL
217 #define GST_CAT_AUTOPLUG         NULL
218 #define GST_CAT_AUTOPLUG_ATTEMPT NULL
219 #define GST_CAT_PARENTAGE        NULL
220 #define GST_CAT_STATES           NULL
221 #define GST_CAT_SCHEDULING       NULL
222 #define GST_CAT_DATAFLOW         NULL
223 #define GST_CAT_BUFFER           NULL
224 #define GST_CAT_BUFFER_LIST      NULL
225 #define GST_CAT_BUS              NULL
226 #define GST_CAT_CAPS             NULL
227 #define GST_CAT_CLOCK            NULL
228 #define GST_CAT_ELEMENT_PADS     NULL
229 #define GST_CAT_PADS             NULL
230 #define GST_CAT_PERFORMANCE      NULL
231 #define GST_CAT_PIPELINE         NULL
232 #define GST_CAT_PLUGIN_LOADING   NULL
233 #define GST_CAT_PLUGIN_INFO      NULL
234 #define GST_CAT_PROPERTIES       NULL
235 #define GST_CAT_NEGOTIATION      NULL
236 #define GST_CAT_REFCOUNTING      NULL
237 #define GST_CAT_ERROR_SYSTEM     NULL
238 #define GST_CAT_EVENT            NULL
239 #define GST_CAT_MESSAGE          NULL
240 #define GST_CAT_PARAMS           NULL
241 #define GST_CAT_CALL_TRACE       NULL
242 #define GST_CAT_SIGNAL           NULL
243 #define GST_CAT_PROBE            NULL
244 #define GST_CAT_REGISTRY         NULL
245 #define GST_CAT_QOS              NULL
246 #define GST_CAT_TYPES            NULL
247 #define GST_CAT_POLL             NULL
248 #define GST_CAT_META             NULL
249 #define GST_CAT_LOCKING          NULL
250
251 #endif
252
253
254 /**** objects made opaque until the private bits have been made private ****/
255
256 #include <gmodule.h>
257 #include <time.h> /* time_t */
258 #include <sys/types.h> /* off_t */
259 #include <sys/stat.h> /* off_t */
260
261 typedef struct _GstPluginPrivate GstPluginPrivate;
262
263 struct _GstPlugin {
264   GstObject       object;
265
266   /*< private >*/
267   GstPluginDesc desc;
268
269   GstPluginDesc *orig_desc;
270
271   gchar *       filename;
272   gchar *       basename;       /* base name (non-dir part) of plugin path */
273
274   GModule *     module;         /* contains the module if plugin is loaded */
275
276   off_t         file_size;
277   time_t        file_mtime;
278   gboolean      registered;     /* TRUE when the registry has seen a filename
279                                  * that matches the plugin's basename */
280
281   GstPluginPrivate *priv;
282
283   gpointer _gst_reserved[GST_PADDING];
284 };
285
286 struct _GstPluginClass {
287   GstObjectClass  object_class;
288
289   /*< private >*/
290   gpointer _gst_reserved[GST_PADDING];
291 };
292
293 struct _GstPluginFeature {
294   GstObject      object;
295
296   /*< private >*/
297   gboolean       loaded;
298   guint          rank;
299
300   const gchar   *plugin_name;
301   GstPlugin     *plugin;      /* weak ref */
302
303   /*< private >*/
304   gpointer _gst_reserved[GST_PADDING];
305 };
306
307 struct _GstPluginFeatureClass {
308   GstObjectClass        parent_class;
309
310   /*< private >*/
311   gpointer _gst_reserved[GST_PADDING];
312 };
313
314 #include "gsttypefind.h"
315
316 struct _GstTypeFindFactory {
317   GstPluginFeature              feature;
318   /* <private> */
319
320   GstTypeFindFunction           function;
321   gchar **                      extensions;
322   GstCaps *                     caps; /* FIXME: not yet saved in registry */
323
324   gpointer                      user_data;
325   GDestroyNotify                user_data_notify;
326
327   gpointer _gst_reserved[GST_PADDING];
328 };
329
330 struct _GstTypeFindFactoryClass {
331   GstPluginFeatureClass         parent;
332   /* <private> */
333
334   gpointer _gst_reserved[GST_PADDING];
335 };
336
337 struct _GstElementFactory {
338   GstPluginFeature      parent;
339
340   GType                 type;                   /* unique GType of element or 0 if not loaded */
341
342   gpointer              metadata;
343
344   GList *               staticpadtemplates;     /* GstStaticPadTemplate list */
345   guint                 numpadtemplates;
346
347   /* URI interface stuff */
348   GstURIType            uri_type;
349   gchar **              uri_protocols;
350
351   GList *               interfaces;             /* interface type names this element implements */
352
353   /*< private >*/
354   gpointer _gst_reserved[GST_PADDING];
355 };
356
357 struct _GstElementFactoryClass {
358   GstPluginFeatureClass parent_class;
359
360   gpointer _gst_reserved[GST_PADDING];
361 };
362
363 G_END_DECLS
364 #endif /* __GST_PRIVATE_H__ */