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