2 * Copyright (C) 2006 Josep Torra <josep@fluendo.com>
3 * 2006 Mathieu Garcia <matthieu@fluendo.com>
4 * 2006,2007 Stefan Kost <ensonic@users.sf.net>
5 * 2008 Sebastian Dröge <slomo@circular-chaos.org>
6 * 2008 Jan Schmidt <jan.schmidt@sun.com>
8 * gstregistrychunks.c: GstRegistryChunk helper for serialising/deserialising
9 * plugin entries and features.
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
21 * You should have received a copy of the GNU Library General Public
22 * License along with this library; if not, write to the
23 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 * Boston, MA 02111-1307, USA.
31 #include <gst/gst_private.h>
32 #include <gst/gstconfig.h>
33 #include <gst/gstelement.h>
34 #include <gst/gsttypefind.h>
35 #include <gst/gsttypefindfactory.h>
36 #include <gst/gsturi.h>
37 #include <gst/gstinfo.h>
38 #include <gst/gstenumtypes.h>
39 #include <gst/gstpadtemplate.h>
41 #include <gst/gstregistrychunks.h>
43 #define GST_CAT_DEFAULT GST_CAT_REGISTRY
45 /* count string length, but return -1 if we hit the eof */
47 _strnlen (const gchar * str, gint maxlen)
51 while (G_LIKELY (len < maxlen)) {
52 if (G_UNLIKELY (str[len] == '\0'))
60 #define unpack_element(inptr, outptr, element, endptr, error_label) G_STMT_START{ \
61 if (inptr + sizeof(element) > endptr) { \
62 GST_ERROR ("Failed reading element " G_STRINGIFY (element) \
63 ". Have %d bytes need %" G_GSSIZE_FORMAT, \
64 (int) (endptr - inptr), sizeof(element)); \
67 outptr = (element *) inptr; \
68 inptr += sizeof (element); \
71 #define unpack_const_string(inptr, outptr, endptr, error_label) G_STMT_START{\
72 gint _len = _strnlen (inptr, (endptr-inptr)); \
75 outptr = g_intern_string ((const gchar *)inptr); \
79 #define unpack_string(inptr, outptr, endptr, error_label) G_STMT_START{\
80 gint _len = _strnlen (inptr, (endptr-inptr)); \
83 outptr = g_memdup ((gconstpointer)inptr, _len + 1); \
87 #define unpack_string_nocopy(inptr, outptr, endptr, error_label) G_STMT_START{\
88 gint _len = _strnlen (inptr, (endptr-inptr)); \
91 outptr = (const gchar *)inptr; \
95 #define ALIGNMENT (sizeof (void *))
96 #define alignment(_address) (gsize)_address%ALIGNMENT
97 #define align(_ptr) _ptr += (( alignment(_ptr) == 0) ? 0 : ALIGNMENT-alignment(_ptr))
100 * gst_registry_chunks_save_const_string:
102 * Store a const string in a binary chunk.
104 * Returns: %TRUE for success
106 inline static gboolean
107 gst_registry_chunks_save_const_string (GList ** list, const gchar * str)
109 GstRegistryChunk *chunk;
111 if (G_UNLIKELY (str == NULL)) {
112 GST_ERROR ("unexpected NULL string in plugin or plugin feature data");
116 chunk = g_malloc (sizeof (GstRegistryChunk));
117 chunk->data = (gpointer) str;
118 chunk->size = strlen ((gchar *) chunk->data) + 1;
119 chunk->flags = GST_REGISTRY_CHUNK_FLAG_CONST;
120 chunk->align = FALSE;
121 *list = g_list_prepend (*list, chunk);
126 * gst_registry_chunks_save_string:
128 * Store a string in a binary chunk.
130 * Returns: %TRUE for success
132 inline static gboolean
133 gst_registry_chunks_save_string (GList ** list, gchar * str)
135 GstRegistryChunk *chunk;
137 chunk = g_malloc (sizeof (GstRegistryChunk));
139 chunk->size = strlen ((gchar *) chunk->data) + 1;
140 chunk->flags = GST_REGISTRY_CHUNK_FLAG_NONE;
141 chunk->align = FALSE;
142 *list = g_list_prepend (*list, chunk);
147 * gst_registry_chunks_save_data:
149 * Store some data in a binary chunk.
151 * Returns: the initialized chunk
153 inline static GstRegistryChunk *
154 gst_registry_chunks_make_data (gpointer data, gulong size)
156 GstRegistryChunk *chunk;
158 chunk = g_malloc (sizeof (GstRegistryChunk));
161 chunk->flags = GST_REGISTRY_CHUNK_FLAG_NONE;
168 * gst_registry_chunks_save_pad_template:
170 * Store pad_templates in binary chunks.
172 * Returns: %TRUE for success
175 gst_registry_chunks_save_pad_template (GList ** list,
176 GstStaticPadTemplate * template)
178 GstRegistryChunkPadTemplate *pt;
179 GstRegistryChunk *chk;
181 pt = g_malloc0 (sizeof (GstRegistryChunkPadTemplate));
183 gst_registry_chunks_make_data (pt, sizeof (GstRegistryChunkPadTemplate));
185 pt->presence = template->presence;
186 pt->direction = template->direction;
188 /* pack pad template strings */
189 gst_registry_chunks_save_const_string (list,
190 (gchar *) (template->static_caps.string));
191 gst_registry_chunks_save_const_string (list, template->name_template);
193 *list = g_list_prepend (*list, chk);
199 * gst_registry_chunks_save_feature:
201 * Store features in binary chunks.
203 * Returns: %TRUE for success
206 gst_registry_chunks_save_feature (GList ** list, GstPluginFeature * feature)
208 const gchar *type_name = g_type_name (G_OBJECT_TYPE (feature));
209 GstRegistryChunkPluginFeature *pf = NULL;
210 GstRegistryChunk *chk = NULL;
214 GST_ERROR ("NULL feature type_name, aborting.");
218 if (GST_IS_ELEMENT_FACTORY (feature)) {
219 GstRegistryChunkElementFactory *ef;
220 GstElementFactory *factory = GST_ELEMENT_FACTORY (feature);
222 ef = g_malloc0 (sizeof (GstRegistryChunkElementFactory));
224 gst_registry_chunks_make_data (ef,
225 sizeof (GstRegistryChunkElementFactory));
226 ef->npadtemplates = ef->ninterfaces = ef->nuriprotocols = 0;
227 pf = (GstRegistryChunkPluginFeature *) ef;
229 /* save interfaces */
230 for (walk = factory->interfaces; walk;
231 walk = g_list_next (walk), ef->ninterfaces++) {
232 gst_registry_chunks_save_const_string (list, (gchar *) walk->data);
234 GST_DEBUG ("Feature %s: saved %d interfaces %d pad templates",
235 feature->name, ef->ninterfaces, ef->npadtemplates);
238 if (GST_URI_TYPE_IS_VALID (factory->uri_type)) {
239 if (factory->uri_protocols && *factory->uri_protocols) {
240 GstRegistryChunk *subchk;
244 gst_registry_chunks_make_data (&factory->uri_type,
245 sizeof (factory->uri_type));
246 subchk->flags = GST_REGISTRY_CHUNK_FLAG_CONST;
248 protocol = factory->uri_protocols;
250 gst_registry_chunks_save_const_string (list, *protocol++);
253 *list = g_list_prepend (*list, subchk);
254 GST_DEBUG ("Saved %d UriTypes", ef->nuriprotocols);
256 g_warning ("GStreamer feature '%s' is URI handler but does not provide"
257 " any protocols it can handle", feature->name);
261 /* save pad-templates */
262 for (walk = factory->staticpadtemplates; walk;
263 walk = g_list_next (walk), ef->npadtemplates++) {
264 GstStaticPadTemplate *template = walk->data;
266 if (!gst_registry_chunks_save_pad_template (list, template)) {
267 GST_ERROR ("Can't fill pad template, aborting.");
272 /* pack element factory strings */
273 gst_registry_chunks_save_const_string (list, factory->details.author);
274 gst_registry_chunks_save_const_string (list, factory->details.description);
275 gst_registry_chunks_save_const_string (list, factory->details.klass);
276 gst_registry_chunks_save_const_string (list, factory->details.longname);
277 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
278 GstRegistryChunkTypeFindFactory *tff;
279 GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
282 tff = g_malloc0 (sizeof (GstRegistryChunkTypeFindFactory));
284 gst_registry_chunks_make_data (tff,
285 sizeof (GstRegistryChunkTypeFindFactory));
286 tff->nextensions = 0;
287 pf = (GstRegistryChunkPluginFeature *) tff;
289 /* save extensions */
290 if (factory->extensions) {
291 while (factory->extensions[tff->nextensions]) {
292 gst_registry_chunks_save_const_string (list,
293 factory->extensions[tff->nextensions++]);
298 /* we copy the caps here so we can simplify them before saving. This
299 * is a lot faster when loading them later on */
300 GstCaps *copy = gst_caps_copy (factory->caps);
302 gst_caps_do_simplify (copy);
303 str = gst_caps_to_string (copy);
304 gst_caps_unref (copy);
305 gst_registry_chunks_save_string (list, str);
307 gst_registry_chunks_save_const_string (list, "");
309 } else if (GST_IS_INDEX_FACTORY (feature)) {
310 GstIndexFactory *factory = GST_INDEX_FACTORY (feature);
312 pf = g_malloc0 (sizeof (GstRegistryChunkPluginFeature));
314 gst_registry_chunks_make_data (pf,
315 sizeof (GstRegistryChunkPluginFeature));
316 pf->rank = feature->rank;
318 /* pack element factory strings */
319 gst_registry_chunks_save_const_string (list, factory->longdesc);
321 GST_WARNING ("unhandled feature type '%s'", type_name);
325 pf->rank = feature->rank;
326 *list = g_list_prepend (*list, chk);
328 /* pack plugin feature strings */
329 gst_registry_chunks_save_const_string (list, feature->name);
330 gst_registry_chunks_save_const_string (list, (gchar *) type_name);
343 gst_registry_chunks_save_plugin_dep (GList ** list, GstPluginDep * dep)
345 GstRegistryChunkDep *ed;
346 GstRegistryChunk *chk;
349 ed = g_malloc0 (sizeof (GstRegistryChunkDep));
350 chk = gst_registry_chunks_make_data (ed, sizeof (GstRegistryChunkDep));
352 ed->flags = dep->flags;
357 ed->env_hash = dep->env_hash;
358 ed->stat_hash = dep->stat_hash;
360 for (s = dep->env_vars; s != NULL && *s != NULL; ++s, ++ed->n_env_vars)
361 gst_registry_chunks_save_string (list, g_strdup (*s));
363 for (s = dep->paths; s != NULL && *s != NULL; ++s, ++ed->n_paths)
364 gst_registry_chunks_save_string (list, g_strdup (*s));
366 for (s = dep->names; s != NULL && *s != NULL; ++s, ++ed->n_names)
367 gst_registry_chunks_save_string (list, g_strdup (*s));
369 *list = g_list_prepend (*list, chk);
371 GST_LOG ("Saved external plugin dependency");
376 * _priv_gst_registry_chunks_save_plugin:
378 * Adapt a GstPlugin to our GstRegistryChunkPluginElement structure, and
379 * prepend it as a GstRegistryChunk in the provided list.
383 _priv_gst_registry_chunks_save_plugin (GList ** list, GstRegistry * registry,
386 GstRegistryChunkPluginElement *pe;
387 GstRegistryChunk *chk;
388 GList *plugin_features = NULL;
391 pe = g_malloc0 (sizeof (GstRegistryChunkPluginElement));
393 gst_registry_chunks_make_data (pe,
394 sizeof (GstRegistryChunkPluginElement));
396 pe->file_size = plugin->file_size;
397 pe->file_mtime = plugin->file_mtime;
401 /* pack external deps */
402 for (walk = plugin->priv->deps; walk != NULL; walk = walk->next) {
403 if (!gst_registry_chunks_save_plugin_dep (list, walk->data)) {
404 GST_ERROR ("Could not save external plugin dependency, aborting.");
410 /* pack plugin features */
412 gst_registry_get_feature_list_by_plugin (registry, plugin->desc.name);
413 for (walk = plugin_features; walk; walk = g_list_next (walk), pe->nfeatures++) {
414 GstPluginFeature *feature = GST_PLUGIN_FEATURE (walk->data);
416 if (!gst_registry_chunks_save_feature (list, feature)) {
417 GST_ERROR ("Can't fill plugin feature, aborting.");
422 gst_plugin_feature_list_free (plugin_features);
424 /* pack cache data */
425 if (plugin->priv->cache_data) {
426 gchar *cache_str = gst_structure_to_string (plugin->priv->cache_data);
427 gst_registry_chunks_save_string (list, cache_str);
429 gst_registry_chunks_save_const_string (list, "");
432 /* pack plugin element strings */
433 gst_registry_chunks_save_const_string (list, plugin->desc.origin);
434 gst_registry_chunks_save_const_string (list, plugin->desc.package);
435 gst_registry_chunks_save_const_string (list, plugin->desc.source);
436 gst_registry_chunks_save_const_string (list, plugin->desc.license);
437 gst_registry_chunks_save_const_string (list, plugin->desc.version);
438 gst_registry_chunks_save_const_string (list, plugin->filename);
439 gst_registry_chunks_save_const_string (list, plugin->desc.description);
440 gst_registry_chunks_save_const_string (list, plugin->desc.name);
442 *list = g_list_prepend (*list, chk);
444 GST_DEBUG ("Found %d features in plugin \"%s\"", pe->nfeatures,
450 gst_plugin_feature_list_free (plugin_features);
457 * gst_registry_chunks_load_pad_template:
459 * Make a new GstStaticPadTemplate from current GstRegistryChunkPadTemplate
462 * Returns: new GstStaticPadTemplate
465 gst_registry_chunks_load_pad_template (GstElementFactory * factory, gchar ** in,
468 GstRegistryChunkPadTemplate *pt;
469 GstStaticPadTemplate *template = NULL;
472 GST_DEBUG ("Reading/casting for GstRegistryChunkPadTemplate at address %p",
474 unpack_element (*in, pt, GstRegistryChunkPadTemplate, end, fail);
476 template = g_new0 (GstStaticPadTemplate, 1);
477 template->presence = pt->presence;
478 template->direction = pt->direction;
480 /* unpack pad template strings */
481 unpack_const_string (*in, template->name_template, end, fail);
482 unpack_string (*in, template->static_caps.string, end, fail);
484 __gst_element_factory_add_static_pad_template (factory, template);
485 GST_DEBUG ("Added pad_template %s", template->name_template);
489 GST_INFO ("Reading pad template failed");
495 * gst_registry_chunks_load_feature:
497 * Make a new GstPluginFeature from current binary plugin feature structure
499 * Returns: new GstPluginFeature
502 gst_registry_chunks_load_feature (GstRegistry * registry, gchar ** in,
503 gchar * end, const gchar * plugin_name)
505 GstRegistryChunkPluginFeature *pf = NULL;
506 GstPluginFeature *feature = NULL;
507 const gchar *const_str, *type_name;
508 gchar *str, *feature_name;
512 /* unpack plugin feature strings */
513 unpack_string_nocopy (*in, type_name, end, fail);
515 if (G_UNLIKELY (!type_name)) {
516 GST_ERROR ("No feature type name");
520 /* unpack more plugin feature strings */
521 unpack_string (*in, feature_name, end, fail);
523 GST_DEBUG ("Plugin '%s' feature '%s' typename : '%s'", plugin_name,
524 feature_name, type_name);
526 if (G_UNLIKELY (!(type = g_type_from_name (type_name)))) {
527 GST_ERROR ("Unknown type from typename '%s' for plugin '%s'", type_name,
529 g_free (feature_name);
532 if (G_UNLIKELY ((feature = g_object_newv (type, 0, NULL)) == NULL)) {
533 GST_ERROR ("Can't create feature from type");
534 g_free (feature_name);
538 feature->name = feature_name;
540 if (G_UNLIKELY (!GST_IS_PLUGIN_FEATURE (feature))) {
541 GST_ERROR ("typename : '%s' is not a plugin feature", type_name);
545 if (GST_IS_ELEMENT_FACTORY (feature)) {
546 GstRegistryChunkElementFactory *ef;
548 GstElementFactory *factory = GST_ELEMENT_FACTORY_CAST (feature);
551 GST_LOG ("Reading/casting for GstRegistryChunkElementFactory at address %p",
553 unpack_element (*in, ef, GstRegistryChunkElementFactory, end, fail);
554 pf = (GstRegistryChunkPluginFeature *) ef;
556 /* unpack element factory strings */
557 unpack_string (*in, factory->details.longname, end, fail);
558 unpack_string (*in, factory->details.klass, end, fail);
559 unpack_string (*in, factory->details.description, end, fail);
560 unpack_string (*in, factory->details.author, end, fail);
561 n = ef->npadtemplates;
562 GST_DEBUG ("Element factory : '%s' with npadtemplates=%d",
563 factory->details.longname, n);
565 /* load pad templates */
566 for (i = 0; i < n; i++) {
567 if (G_UNLIKELY (!gst_registry_chunks_load_pad_template (factory, in,
569 GST_ERROR ("Error while loading binary pad template");
575 if (G_UNLIKELY ((n = ef->nuriprotocols))) {
576 GST_DEBUG ("Reading %d UriTypes at address %p", n, *in);
579 factory->uri_type = *((guint *) * in);
580 *in += sizeof (factory->uri_type);
581 /*unpack_element(*in, &factory->uri_type, factory->uri_type, end, fail); */
583 factory->uri_protocols = g_new0 (gchar *, n + 1);
584 for (i = 0; i < n; i++) {
585 unpack_string (*in, str, end, fail);
586 factory->uri_protocols[i] = str;
589 /* load interfaces */
590 if (G_UNLIKELY ((n = ef->ninterfaces))) {
591 GST_DEBUG ("Reading %d Interfaces at address %p", n, *in);
592 for (i = 0; i < n; i++) {
593 unpack_string_nocopy (*in, const_str, end, fail);
594 __gst_element_factory_add_interface (factory, const_str);
597 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
598 GstRegistryChunkTypeFindFactory *tff;
599 GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
603 ("Reading/casting for GstRegistryChunkPluginFeature at address %p",
605 unpack_element (*in, tff, GstRegistryChunkTypeFindFactory, end, fail);
606 pf = (GstRegistryChunkPluginFeature *) tff;
608 /* load typefinder caps */
609 unpack_string_nocopy (*in, const_str, end, fail);
610 if (const_str != NULL && *const_str != '\0')
611 factory->caps = gst_caps_from_string (const_str);
613 factory->caps = NULL;
615 /* load extensions */
616 if (tff->nextensions) {
617 GST_DEBUG ("Reading %d Typefind extensions at address %p",
618 tff->nextensions, *in);
619 factory->extensions = g_new0 (gchar *, tff->nextensions + 1);
620 for (i = 0; i < tff->nextensions; i++) {
621 unpack_string (*in, str, end, fail);
622 factory->extensions[i] = str;
625 } else if (GST_IS_INDEX_FACTORY (feature)) {
626 GstIndexFactory *factory = GST_INDEX_FACTORY (feature);
630 ("Reading/casting for GstRegistryChunkPluginFeature at address %p",
632 unpack_element (*in, pf, GstRegistryChunkPluginFeature, end, fail);
634 /* unpack index factory strings */
635 unpack_string (*in, factory->longdesc, end, fail);
637 GST_WARNING ("unhandled factory type : %s", G_OBJECT_TYPE_NAME (feature));
641 feature->rank = pf->rank;
643 feature->plugin_name = plugin_name;
645 gst_registry_add_feature (registry, feature);
646 GST_DEBUG ("Added feature %s", feature->name);
652 GST_INFO ("Reading plugin feature failed");
654 if (GST_IS_OBJECT (feature))
655 gst_object_unref (feature);
657 g_object_unref (feature);
663 gst_registry_chunks_load_plugin_dep_strv (gchar ** in, gchar * end, guint n)
670 arr = g_new0 (gchar *, n + 1);
672 unpack_string (*in, arr[n - 1], end, fail);
677 GST_INFO ("Reading plugin dependency strings failed");
682 gst_registry_chunks_load_plugin_dep (GstPlugin * plugin, gchar ** in,
686 GstRegistryChunkDep *d;
690 GST_LOG_OBJECT (plugin, "Unpacking GstRegistryChunkDep from %p", *in);
691 unpack_element (*in, d, GstRegistryChunkDep, end, fail);
693 dep = g_malloc0 (sizeof (GstPluginDep));
695 dep->env_hash = d->env_hash;
696 dep->stat_hash = d->stat_hash;
698 dep->flags = d->flags;
700 dep->names = gst_registry_chunks_load_plugin_dep_strv (in, end, d->n_names);
701 dep->paths = gst_registry_chunks_load_plugin_dep_strv (in, end, d->n_paths);
703 gst_registry_chunks_load_plugin_dep_strv (in, end, d->n_env_vars);
705 plugin->priv->deps = g_list_append (plugin->priv->deps, dep);
707 GST_DEBUG_OBJECT (plugin, "Loaded external plugin dependency from registry: "
708 "env_hash: %08x, stat_hash: %08x", dep->env_hash, dep->stat_hash);
709 for (s = dep->env_vars; s != NULL && *s != NULL; ++s)
710 GST_LOG_OBJECT (plugin, " evar: %s", *s);
711 for (s = dep->paths; s != NULL && *s != NULL; ++s)
712 GST_LOG_OBJECT (plugin, " path: %s", *s);
713 for (s = dep->names; s != NULL && *s != NULL; ++s)
714 GST_LOG_OBJECT (plugin, " name: %s", *s);
718 GST_INFO ("Reading plugin dependency failed");
724 * _priv_gst_registry_chunks_load_plugin:
726 * Make a new GstPlugin from current GstRegistryChunkPluginElement structure
727 * and add it to the GstRegistry. Return an offset to the next
728 * GstRegistryChunkPluginElement structure.
731 _priv_gst_registry_chunks_load_plugin (GstRegistry * registry, gchar ** in,
732 gchar * end, GstPlugin ** out_plugin)
734 #ifndef GST_DISABLE_GST_DEBUG
737 GstRegistryChunkPluginElement *pe;
738 const gchar *cache_str = NULL;
739 GstPlugin *plugin = NULL;
743 GST_LOG ("Reading/casting for GstRegistryChunkPluginElement at address %p",
745 unpack_element (*in, pe, GstRegistryChunkPluginElement, end, fail);
747 plugin = g_object_newv (GST_TYPE_PLUGIN, 0, NULL);
749 /* TODO: also set GST_PLUGIN_FLAG_CONST */
750 plugin->flags |= GST_PLUGIN_FLAG_CACHED;
751 plugin->file_mtime = pe->file_mtime;
752 plugin->file_size = pe->file_size;
754 /* unpack plugin element strings */
755 unpack_const_string (*in, plugin->desc.name, end, fail);
756 unpack_string (*in, plugin->desc.description, end, fail);
757 unpack_string (*in, plugin->filename, end, fail);
758 unpack_const_string (*in, plugin->desc.version, end, fail);
759 unpack_const_string (*in, plugin->desc.license, end, fail);
760 unpack_const_string (*in, plugin->desc.source, end, fail);
761 unpack_const_string (*in, plugin->desc.package, end, fail);
762 unpack_const_string (*in, plugin->desc.origin, end, fail);
763 GST_LOG ("read strings for name='%s'", plugin->desc.name);
764 GST_LOG (" desc.description='%s'", plugin->desc.description);
765 GST_LOG (" filename='%s'", plugin->filename);
766 GST_LOG (" desc.version='%s'", plugin->desc.version);
767 GST_LOG (" desc.license='%s'", plugin->desc.license);
768 GST_LOG (" desc.source='%s'", plugin->desc.source);
769 GST_LOG (" desc.package='%s'", plugin->desc.package);
770 GST_LOG (" desc.origin='%s'", plugin->desc.origin);
772 /* unpack cache data */
773 unpack_string_nocopy (*in, cache_str, end, fail);
774 if (cache_str != NULL && *cache_str != '\0')
775 plugin->priv->cache_data = gst_structure_from_string (cache_str, NULL);
777 /* If the license string is 'BLACKLIST', mark this as a blacklisted
779 if (strcmp (plugin->desc.license, "BLACKLIST") == 0)
780 plugin->flags |= GST_PLUGIN_FLAG_BLACKLISTED;
782 plugin->basename = g_path_get_basename (plugin->filename);
784 /* Takes ownership of plugin */
785 gst_registry_add_plugin (registry, plugin);
787 GST_DEBUG ("Added plugin '%s' plugin with %d features from binary registry",
788 plugin->desc.name, n);
790 /* Load plugin features */
791 for (i = 0; i < n; i++) {
792 if (G_UNLIKELY (!gst_registry_chunks_load_feature (registry, in, end,
793 plugin->desc.name))) {
794 GST_ERROR ("Error while loading binary feature for plugin '%s'",
795 GST_STR_NULL (plugin->desc.name));
796 gst_registry_remove_plugin (registry, plugin);
801 /* Load external plugin dependencies */
802 for (i = 0; i < pe->n_deps; ++i) {
803 if (G_UNLIKELY (!gst_registry_chunks_load_plugin_dep (plugin, in, end))) {
804 GST_ERROR_OBJECT (plugin, "Could not read external plugin dependency "
805 "for plugin '%s'", GST_STR_NULL (plugin->desc.name));
806 gst_registry_remove_plugin (registry, plugin);
812 *out_plugin = plugin;
818 GST_INFO ("Reading plugin failed after %u bytes", (guint) (end - start));