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