#endif
#include <signal.h>
#include <errno.h>
+#include <string.h>
#include "glib-compat-private.h"
return quark;
}
-#ifndef GST_REMOVE_DEPRECATED
-#ifdef GST_DISABLE_DEPRECATED
-void _gst_plugin_register_static (GstPluginDesc * desc);
-#endif
-/* this function can be called in the GCC constructor extension, before
- * the _gst_plugin_initialize() was called. In that case, we store the
- * plugin description in a list to initialize it when we open the main
- * module later on.
- * When the main module is known, we can register the plugin right away.
- */
-void
-_gst_plugin_register_static (GstPluginDesc * desc)
-{
- g_return_if_fail (desc != NULL);
-
- if (!_gst_plugin_inited) {
- /* We can't use any GLib functions here, since g_thread_init hasn't been
- * called yet, and we can't call it here either, or programs that don't
- * guard their g_thread_init calls in main() will just abort */
- ++_num_static_plugins;
- _static_plugins =
- realloc (_static_plugins, _num_static_plugins * sizeof (GstPluginDesc));
- /* assume strings in the GstPluginDesc are static const or live forever */
- _static_plugins[_num_static_plugins - 1] = *desc;
- } else {
- gst_plugin_register_static (desc->major_version, desc->minor_version,
- desc->name, desc->description, desc->plugin_init, desc->version,
- desc->license, desc->source, desc->package, desc->origin);
- }
-}
-#endif
-
/**
* gst_plugin_register_static:
* @major_version: the major version number of the GStreamer core that the
* library-specific namespace prefix in order to avoid name conflicts in
* case a similar plugin with the same name ever gets added to GStreamer)
* @description: description of the plugin
- * @init_func: pointer to the init function of this plugin.
+ * @init_func: (scope call): pointer to the init function of this plugin.
* @version: version string of the plugin
* @license: effective license of plugin. Must be one of the approved licenses
* (see #GstPluginDesc above) or the plugin will not be registered.
const gchar * package, const gchar * origin)
{
GstPluginDesc desc = { major_version, minor_version, name, description,
- init_func, version, license, source, package, origin,
+ init_func, version, license, source, package, origin, NULL,
};
GstPlugin *plugin;
gboolean res = FALSE;
* library-specific namespace prefix in order to avoid name conflicts in
* case a similar plugin with the same name ever gets added to GStreamer)
* @description: description of the plugin
- * @init_full_func: pointer to the init function with user data of this plugin.
+ * @init_full_func: (scope call): pointer to the init function with user data
+ * of this plugin.
* @version: version string of the plugin
* @license: effective license of plugin. Must be one of the approved licenses
* (see #GstPluginDesc above) or the plugin will not be registered.
{
GstPluginDesc desc = { major_version, minor_version, name, description,
(GstPluginInitFunc) init_full_func, version, license, source, package,
- origin,
+ origin, NULL,
};
GstPlugin *plugin;
gboolean res = FALSE;
}
void
-_gst_plugin_initialize (void)
+_priv_gst_plugin_initialize (void)
{
const gchar *whitelist;
guint i;
g_print ("%s\n\n", _gst_plugin_fault_handler_filename);
g_print ("Please either:\n");
g_print ("- remove it and restart.\n");
- g_print ("- run with --gst-disable-segtrap and debug.\n");
+ g_print
+ ("- run with --gst-disable-segtrap --gst-disable-registry-fork and debug.\n");
exit (-1);
break;
default:
}
#endif /* HAVE_SIGACTION */
+/* g_time_val_from_iso8601() doesn't do quite what we want */
+static gboolean
+check_release_datetime (const gchar * date_time)
+{
+ guint64 val;
+
+ /* we require YYYY-MM-DD or YYYY-MM-DDTHH:MMZ format */
+ if (!g_ascii_isdigit (*date_time))
+ return FALSE;
+
+ val = g_ascii_strtoull (date_time, (gchar **) & date_time, 10);
+ if (val < 2000 || val > 2100 || *date_time != '-')
+ return FALSE;
+
+ val = g_ascii_strtoull (date_time + 1, (gchar **) & date_time, 10);
+ if (val == 0 || val > 12 || *date_time != '-')
+ return FALSE;
+
+ val = g_ascii_strtoull (date_time + 1, (gchar **) & date_time, 10);
+ if (val == 0 || val > 32)
+ return FALSE;
+
+ /* end of string or date/time separator + HH:MMZ */
+ if (*date_time == 'T' || *date_time == ' ') {
+ val = g_ascii_strtoull (date_time + 1, (gchar **) & date_time, 10);
+ if (val > 24 || *date_time != ':')
+ return FALSE;
+
+ val = g_ascii_strtoull (date_time + 1, (gchar **) & date_time, 10);
+ if (val > 59 || *date_time != 'Z')
+ return FALSE;
+
+ ++date_time;
+ }
+
+ return (*date_time == '\0');
+}
+
static GStaticMutex gst_plugin_loading_mutex = G_STATIC_MUTEX_INIT;
#define CHECK_PLUGIN_DESC_FIELD(desc,field,fn) \
*
* Loads the given plugin and refs it. Caller needs to unref after use.
*
- * Returns: a reference to the existing loaded GstPlugin, a reference to the
- * newly-loaded GstPlugin, or NULL if an error occurred.
+ * Returns: (transfer full): a reference to the existing loaded GstPlugin, a
+ * reference to the newly-loaded GstPlugin, or NULL if an error occurred.
*/
GstPlugin *
gst_plugin_load_file (const gchar * filename, GError ** error)
GStatBuf file_status;
GstRegistry *registry;
gboolean new_plugin = TRUE;
+ GModuleFlags flags;
g_return_val_if_fail (filename != NULL, NULL);
goto return_error;
}
- module = g_module_open (filename, G_MODULE_BIND_LOCAL);
+ flags = G_MODULE_BIND_LOCAL;
+ /* libgstpython.so is the gst-python plugin loader. It needs to be loaded with
+ * G_MODULE_BIND_LAZY.
+ *
+ * Ideally there should be a generic way for plugins to specify that they
+ * need to be loaded with _LAZY.
+ * */
+ if (strstr (filename, "libgstpython"))
+ flags |= G_MODULE_BIND_LAZY;
+
+ module = g_module_open (filename, flags);
if (module == NULL) {
GST_CAT_WARNING (GST_CAT_PLUGIN_LOADING, "module_open failed: %s",
g_module_error ());
CHECK_PLUGIN_DESC_FIELD (plugin->orig_desc, source, filename);
CHECK_PLUGIN_DESC_FIELD (plugin->orig_desc, package, filename);
CHECK_PLUGIN_DESC_FIELD (plugin->orig_desc, origin, filename);
+
+ if (plugin->orig_desc->release_datetime != NULL &&
+ !check_release_datetime (plugin->orig_desc->release_datetime)) {
+ GST_ERROR ("GstPluginDesc for '%s' has invalid datetime '%s'",
+ filename, plugin->orig_desc->release_datetime);
+ plugin->orig_desc->release_datetime = NULL;
+ }
}
GST_LOG ("Plugin %p for file \"%s\" prepared, calling entry function...",
dest->source = g_intern_string (src->source);
dest->package = g_intern_string (src->package);
dest->origin = g_intern_string (src->origin);
+ dest->release_datetime = g_intern_string (src->release_datetime);
}
/**
*
* Returns: the long name of the plugin
*/
-G_CONST_RETURN gchar *
+const gchar *
gst_plugin_get_description (GstPlugin * plugin)
{
g_return_val_if_fail (plugin != NULL, NULL);
*
* Returns: the filename of the plugin
*/
-G_CONST_RETURN gchar *
+const gchar *
gst_plugin_get_filename (GstPlugin * plugin)
{
g_return_val_if_fail (plugin != NULL, NULL);
*
* Returns: the version of the plugin
*/
-G_CONST_RETURN gchar *
+const gchar *
gst_plugin_get_version (GstPlugin * plugin)
{
g_return_val_if_fail (plugin != NULL, NULL);
*
* Returns: the license of the plugin
*/
-G_CONST_RETURN gchar *
+const gchar *
gst_plugin_get_license (GstPlugin * plugin)
{
g_return_val_if_fail (plugin != NULL, NULL);
*
* Returns: the source of the plugin
*/
-G_CONST_RETURN gchar *
+const gchar *
gst_plugin_get_source (GstPlugin * plugin)
{
g_return_val_if_fail (plugin != NULL, NULL);
*
* Returns: the package of the plugin
*/
-G_CONST_RETURN gchar *
+const gchar *
gst_plugin_get_package (GstPlugin * plugin)
{
g_return_val_if_fail (plugin != NULL, NULL);
*
* Returns: the origin of the plugin
*/
-G_CONST_RETURN gchar *
+const gchar *
gst_plugin_get_origin (GstPlugin * plugin)
{
g_return_val_if_fail (plugin != NULL, NULL);
* Gets the #GModule of the plugin. If the plugin isn't loaded yet, NULL is
* returned.
*
- * Returns: module belonging to the plugin or NULL if the plugin isn't
- * loaded yet.
+ * Returns: (transfer none): module belonging to the plugin or NULL if the
+ * plugin isn't loaded yet.
*/
GModule *
gst_plugin_get_module (GstPlugin * plugin)
* Gets the plugin specific data cache. If it is %NULL there is no cached data
* stored. This is the case when the registry is getting rebuilt.
*
- * Returns: The cached data as a #GstStructure or %NULL.
+ * Returns: (transfer none): The cached data as a #GstStructure or %NULL.
*
* Since: 0.10.24
*/
-G_CONST_RETURN GstStructure *
+const GstStructure *
gst_plugin_get_cache_data (GstPlugin * plugin)
{
g_return_val_if_fail (GST_IS_PLUGIN (plugin), NULL);
/**
* gst_plugin_set_cache_data:
* @plugin: a plugin
- * @cache_data: a structure containing the data to cache
+ * @cache_data: (transfer full): a structure containing the data to cache
*
* Adds plugin specific data to cache. Passes the ownership of the structure to
* the @plugin.
*
* Load the named plugin. Refs the plugin.
*
- * Returns: A reference to a loaded plugin, or NULL on error.
+ * Returns: (transfer full): a reference to a loaded plugin, or NULL on error.
*/
GstPlugin *
gst_plugin_load_by_name (const gchar * name)
/**
* gst_plugin_load:
- * @plugin: plugin to load
+ * @plugin: (transfer none): plugin to load
*
* Loads @plugin. Note that the *return value* is the loaded plugin; @plugin is
* untouched. The normal use pattern of this function goes like this:
* plugin = loaded_plugin;
* </programlisting>
*
- * Returns: A reference to a loaded plugin, or NULL on error.
+ * Returns: (transfer full): a reference to a loaded plugin, or NULL on error.
*/
GstPlugin *
gst_plugin_load (GstPlugin * plugin)
/**
* gst_plugin_list_free:
- * @list: list of #GstPlugin
+ * @list: (transfer full) (element-type Gst.Plugin): list of #GstPlugin
*
* Unrefs each member of @list, then frees the list.
*/
return FALSE;
}
-static GList *
+static void
gst_plugin_ext_dep_extract_env_vars_paths (GstPlugin * plugin,
- GstPluginDep * dep)
+ GstPluginDep * dep, GQueue * paths)
{
gchar **evars;
- GList *paths = NULL;
for (evars = dep->env_vars; evars != NULL && *evars != NULL; ++evars) {
const gchar *e;
full_path = g_strdup (arr[i]);
}
- if (!g_list_find_custom (paths, full_path, (GCompareFunc) strcmp)) {
+ if (!g_queue_find_custom (paths, full_path, (GCompareFunc) strcmp)) {
GST_LOG_OBJECT (plugin, "path: '%s'", full_path);
- paths = g_list_prepend (paths, full_path);
+ g_queue_push_tail (paths, full_path);
full_path = NULL;
} else {
GST_LOG_OBJECT (plugin, "path: '%s' (duplicate,ignoring)", full_path);
g_strfreev (components);
}
- GST_LOG_OBJECT (plugin, "Extracted %d paths from environment",
- g_list_length (paths));
-
- return paths;
+ GST_LOG_OBJECT (plugin, "Extracted %d paths from environment", paths->length);
}
static guint
gst_plugin_ext_dep_get_stat_hash (GstPlugin * plugin, GstPluginDep * dep)
{
gboolean paths_are_default_only;
- GList *scan_paths;
+ GQueue scan_paths = G_QUEUE_INIT;
guint scan_hash = 0;
+ gchar *path;
GST_LOG_OBJECT (plugin, "start");
paths_are_default_only =
dep->flags & GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY;
- scan_paths = gst_plugin_ext_dep_extract_env_vars_paths (plugin, dep);
+ gst_plugin_ext_dep_extract_env_vars_paths (plugin, dep, &scan_paths);
- if (scan_paths == NULL || !paths_are_default_only) {
+ if (g_queue_is_empty (&scan_paths) || !paths_are_default_only) {
gchar **paths;
for (paths = dep->paths; paths != NULL && *paths != NULL; ++paths) {
const gchar *path = *paths;
- if (!g_list_find_custom (scan_paths, path, (GCompareFunc) strcmp)) {
+ if (!g_queue_find_custom (&scan_paths, path, (GCompareFunc) strcmp)) {
GST_LOG_OBJECT (plugin, "path: '%s'", path);
- scan_paths = g_list_prepend (scan_paths, g_strdup (path));
+ g_queue_push_tail (&scan_paths, g_strdup (path));
} else {
GST_LOG_OBJECT (plugin, "path: '%s' (duplicate, ignoring)", path);
}
}
}
- /* not that the order really matters, but it makes debugging easier */
- scan_paths = g_list_reverse (scan_paths);
-
- while (scan_paths != NULL) {
- const gchar *path = scan_paths->data;
-
+ while ((path = g_queue_pop_head (&scan_paths))) {
scan_hash += gst_plugin_ext_dep_scan_path_with_filenames (plugin, path,
(const gchar **) dep->names, dep->flags);
scan_hash = scan_hash << 1;
-
- g_free (scan_paths->data);
- scan_paths = g_list_delete_link (scan_paths, scan_paths);
+ g_free (path);
}
GST_LOG_OBJECT (plugin, "done, scan_hash: %08x", scan_hash);
/**
* gst_plugin_add_dependency:
* @plugin: a #GstPlugin
- * @env_vars: NULL-terminated array of environent variables affecting the
+ * @env_vars: NULL-terminated array of environment variables affecting the
* feature set of the plugin (e.g. an environment variable containing
* paths where to look for additional modules/plugins of a library),
* or NULL. Environment variable names may be followed by a path component
/**
* gst_plugin_add_dependency_simple:
* @plugin: the #GstPlugin
- * @env_vars: one or more environent variables (separated by ':', ';' or ','),
+ * @env_vars: one or more environment variables (separated by ':', ';' or ','),
* or NULL. Environment variable names may be followed by a path component
* which will be added to the content of the environment variable, e.g.
* "HOME/.mystuff/plugins:MYSTUFF_PLUGINS_PATH"