mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-05 05:52:37 +00:00
registry: allow plugins to cache extra data in registry. Fixes #570233
Add a GstStructure to GstPlugin. Plugins can retieve it in plugin_init and access the cached info or build the cache and store it there.
This commit is contained in:
parent
55577a48ea
commit
ed88db818b
7 changed files with 69 additions and 1 deletions
|
@ -1717,6 +1717,8 @@ gst_plugin_get_source
|
||||||
gst_plugin_get_version
|
gst_plugin_get_version
|
||||||
gst_plugin_get_module
|
gst_plugin_get_module
|
||||||
gst_plugin_is_loaded
|
gst_plugin_is_loaded
|
||||||
|
gst_plugin_get_cache_data
|
||||||
|
gst_plugin_set_cache_data
|
||||||
gst_plugin_name_filter
|
gst_plugin_name_filter
|
||||||
gst_plugin_load_file
|
gst_plugin_load_file
|
||||||
gst_plugin_load
|
gst_plugin_load
|
||||||
|
|
|
@ -68,6 +68,7 @@ typedef struct {
|
||||||
|
|
||||||
struct _GstPluginPrivate {
|
struct _GstPluginPrivate {
|
||||||
GList *deps; /* list of GstPluginDep structures */
|
GList *deps; /* list of GstPluginDep structures */
|
||||||
|
GstStructure *cache_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
gboolean _priv_plugin_deps_env_vars_changed (GstPlugin * plugin);
|
gboolean _priv_plugin_deps_env_vars_changed (GstPlugin * plugin);
|
||||||
|
|
|
@ -137,6 +137,10 @@ gst_plugin_finalize (GObject * object)
|
||||||
g_list_free (plugin->priv->deps);
|
g_list_free (plugin->priv->deps);
|
||||||
plugin->priv->deps = NULL;
|
plugin->priv->deps = NULL;
|
||||||
|
|
||||||
|
if (plugin->priv->cache_data) {
|
||||||
|
gst_structure_free (plugin->priv->cache_data);
|
||||||
|
}
|
||||||
|
|
||||||
G_OBJECT_CLASS (gst_plugin_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gst_plugin_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -853,6 +857,45 @@ gst_plugin_is_loaded (GstPlugin * plugin)
|
||||||
return (plugin->module != NULL || plugin->filename == NULL);
|
return (plugin->module != NULL || plugin->filename == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_plugin_get_cache_data:
|
||||||
|
* @plugin: a 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 rebuild.
|
||||||
|
*
|
||||||
|
* Returns: The cached data as a #GstStructure or %NULL.
|
||||||
|
*/
|
||||||
|
G_CONST_RETURN GstStructure *
|
||||||
|
gst_plugin_get_cache_data (GstPlugin * plugin)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GST_IS_PLUGIN (plugin), NULL);
|
||||||
|
|
||||||
|
return plugin->priv->cache_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_plugin_set_cache_data:
|
||||||
|
* @plugin: a plugin
|
||||||
|
* @cache_data: a structure containing the data to cache
|
||||||
|
*
|
||||||
|
* Adds plugin specific data to cache. Passes the ownership of the structure to
|
||||||
|
* the @plugin.
|
||||||
|
*
|
||||||
|
* The cache is flushed every time the registry is rebuild.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_plugin_set_cache_data (GstPlugin * plugin, GstStructure * cache_data)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GST_IS_PLUGIN (plugin));
|
||||||
|
g_return_if_fail (GST_IS_STRUCTURE (cache_data));
|
||||||
|
|
||||||
|
if (plugin->priv->cache_data) {
|
||||||
|
gst_structure_free (plugin->priv->cache_data);
|
||||||
|
}
|
||||||
|
plugin->priv->cache_data = cache_data;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/**
|
/**
|
||||||
* gst_plugin_feature_list:
|
* gst_plugin_feature_list:
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <gmodule.h>
|
#include <gmodule.h>
|
||||||
#include <gst/gstobject.h>
|
#include <gst/gstobject.h>
|
||||||
#include <gst/gstmacros.h>
|
#include <gst/gstmacros.h>
|
||||||
|
#include <gst/gststructure.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -345,6 +346,9 @@ G_CONST_RETURN gchar* gst_plugin_get_license (GstPlugin *plugin);
|
||||||
G_CONST_RETURN gchar* gst_plugin_get_source (GstPlugin *plugin);
|
G_CONST_RETURN gchar* gst_plugin_get_source (GstPlugin *plugin);
|
||||||
G_CONST_RETURN gchar* gst_plugin_get_package (GstPlugin *plugin);
|
G_CONST_RETURN gchar* gst_plugin_get_package (GstPlugin *plugin);
|
||||||
G_CONST_RETURN gchar* gst_plugin_get_origin (GstPlugin *plugin);
|
G_CONST_RETURN gchar* gst_plugin_get_origin (GstPlugin *plugin);
|
||||||
|
G_CONST_RETURN GstStructure* gst_plugin_get_cache_data (GstPlugin * plugin);
|
||||||
|
void gst_plugin_set_cache_data (GstPlugin * plugin, GstStructure *cache_data);
|
||||||
|
|
||||||
GModule * gst_plugin_get_module (GstPlugin *plugin);
|
GModule * gst_plugin_get_module (GstPlugin *plugin);
|
||||||
gboolean gst_plugin_is_loaded (GstPlugin *plugin);
|
gboolean gst_plugin_is_loaded (GstPlugin *plugin);
|
||||||
|
|
||||||
|
|
|
@ -674,6 +674,14 @@ gst_registry_binary_save_plugin (GList ** list, GstRegistry * registry,
|
||||||
|
|
||||||
gst_plugin_feature_list_free (plugin_features);
|
gst_plugin_feature_list_free (plugin_features);
|
||||||
|
|
||||||
|
/* pack cache data */
|
||||||
|
if (plugin->priv->cache_data) {
|
||||||
|
gchar *cache_str = gst_structure_to_string (plugin->priv->cache_data);
|
||||||
|
gst_registry_binary_save_string (list, cache_str);
|
||||||
|
} else {
|
||||||
|
gst_registry_binary_save_const_string (list, "");
|
||||||
|
}
|
||||||
|
|
||||||
/* pack plugin element strings */
|
/* pack plugin element strings */
|
||||||
gst_registry_binary_save_const_string (list, plugin->desc.origin);
|
gst_registry_binary_save_const_string (list, plugin->desc.origin);
|
||||||
gst_registry_binary_save_const_string (list, plugin->desc.package);
|
gst_registry_binary_save_const_string (list, plugin->desc.package);
|
||||||
|
@ -1111,6 +1119,7 @@ gst_registry_binary_load_plugin (GstRegistry * registry, gchar ** in,
|
||||||
{
|
{
|
||||||
GstBinaryPluginElement *pe;
|
GstBinaryPluginElement *pe;
|
||||||
GstPlugin *plugin = NULL;
|
GstPlugin *plugin = NULL;
|
||||||
|
gchar *cache_str = NULL;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
align (*in);
|
align (*in);
|
||||||
|
@ -1142,6 +1151,13 @@ gst_registry_binary_load_plugin (GstRegistry * registry, gchar ** in,
|
||||||
GST_LOG (" desc.package='%s'", plugin->desc.package);
|
GST_LOG (" desc.package='%s'", plugin->desc.package);
|
||||||
GST_LOG (" desc.origin='%s'", plugin->desc.origin);
|
GST_LOG (" desc.origin='%s'", plugin->desc.origin);
|
||||||
|
|
||||||
|
/* unpack cache data */
|
||||||
|
unpack_string (*in, cache_str, end, fail);
|
||||||
|
if (*cache_str) {
|
||||||
|
plugin->priv->cache_data = gst_structure_from_string (cache_str, NULL);
|
||||||
|
}
|
||||||
|
g_free (cache_str);
|
||||||
|
|
||||||
plugin->basename = g_path_get_basename (plugin->filename);
|
plugin->basename = g_path_get_basename (plugin->filename);
|
||||||
|
|
||||||
/* Takes ownership of plugin */
|
/* Takes ownership of plugin */
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
* This _must_ be updated whenever the registry format changes,
|
* This _must_ be updated whenever the registry format changes,
|
||||||
* we currently use the core version where this change happened.
|
* we currently use the core version where this change happened.
|
||||||
*/
|
*/
|
||||||
#define GST_MAGIC_BINARY_VERSION_STR ("0.10.21.2")
|
#define GST_MAGIC_BINARY_VERSION_STR ("0.10.23.1")
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GST_MAGIC_BINARY_VERSION_LEN:
|
* GST_MAGIC_BINARY_VERSION_LEN:
|
||||||
|
|
|
@ -703,6 +703,7 @@ EXPORTS
|
||||||
gst_plugin_feature_set_rank
|
gst_plugin_feature_set_rank
|
||||||
gst_plugin_feature_type_name_filter
|
gst_plugin_feature_type_name_filter
|
||||||
gst_plugin_flags_get_type
|
gst_plugin_flags_get_type
|
||||||
|
gst_plugin_get_cache_data
|
||||||
gst_plugin_get_description
|
gst_plugin_get_description
|
||||||
gst_plugin_get_filename
|
gst_plugin_get_filename
|
||||||
gst_plugin_get_license
|
gst_plugin_get_license
|
||||||
|
@ -721,6 +722,7 @@ EXPORTS
|
||||||
gst_plugin_name_filter
|
gst_plugin_name_filter
|
||||||
gst_plugin_register_static
|
gst_plugin_register_static
|
||||||
gst_plugin_register_static_full
|
gst_plugin_register_static_full
|
||||||
|
gst_plugin_set_cache_data
|
||||||
gst_poll_add_fd
|
gst_poll_add_fd
|
||||||
gst_poll_fd_can_read
|
gst_poll_fd_can_read
|
||||||
gst_poll_fd_can_write
|
gst_poll_fd_can_write
|
||||||
|
|
Loading…
Reference in a new issue