diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 925cb34439..048d24fed8 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -1717,6 +1717,8 @@ gst_plugin_get_source gst_plugin_get_version gst_plugin_get_module gst_plugin_is_loaded +gst_plugin_get_cache_data +gst_plugin_set_cache_data gst_plugin_name_filter gst_plugin_load_file gst_plugin_load diff --git a/gst/gst_private.h b/gst/gst_private.h index 553f7161c8..ce65f5c33a 100644 --- a/gst/gst_private.h +++ b/gst/gst_private.h @@ -68,6 +68,7 @@ typedef struct { struct _GstPluginPrivate { GList *deps; /* list of GstPluginDep structures */ + GstStructure *cache_data; }; gboolean _priv_plugin_deps_env_vars_changed (GstPlugin * plugin); diff --git a/gst/gstplugin.c b/gst/gstplugin.c index a27ef699c1..e3eea17761 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -137,6 +137,10 @@ gst_plugin_finalize (GObject * object) g_list_free (plugin->priv->deps); 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); } @@ -853,6 +857,45 @@ gst_plugin_is_loaded (GstPlugin * plugin) 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 /** * gst_plugin_feature_list: diff --git a/gst/gstplugin.h b/gst/gstplugin.h index d77f8579f8..de4a0d7090 100644 --- a/gst/gstplugin.h +++ b/gst/gstplugin.h @@ -32,6 +32,7 @@ #include #include #include +#include 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_package (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); gboolean gst_plugin_is_loaded (GstPlugin *plugin); diff --git a/gst/gstregistrybinary.c b/gst/gstregistrybinary.c index 7e33e49678..654354a91b 100644 --- a/gst/gstregistrybinary.c +++ b/gst/gstregistrybinary.c @@ -674,6 +674,14 @@ gst_registry_binary_save_plugin (GList ** list, GstRegistry * registry, 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 */ gst_registry_binary_save_const_string (list, plugin->desc.origin); 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; GstPlugin *plugin = NULL; + gchar *cache_str = NULL; guint i; 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.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); /* Takes ownership of plugin */ diff --git a/gst/gstregistrybinary.h b/gst/gstregistrybinary.h index bcdb8a65e9..a6ceab2313 100644 --- a/gst/gstregistrybinary.h +++ b/gst/gstregistrybinary.h @@ -57,7 +57,7 @@ * This _must_ be updated whenever the registry format changes, * 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: diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index 7cb014c043..006ad95943 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -703,6 +703,7 @@ EXPORTS gst_plugin_feature_set_rank gst_plugin_feature_type_name_filter gst_plugin_flags_get_type + gst_plugin_get_cache_data gst_plugin_get_description gst_plugin_get_filename gst_plugin_get_license @@ -721,6 +722,7 @@ EXPORTS gst_plugin_name_filter gst_plugin_register_static gst_plugin_register_static_full + gst_plugin_set_cache_data gst_poll_add_fd gst_poll_fd_can_read gst_poll_fd_can_write