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;
508 gchar *type_name = NULL, *str;
513 /* unpack plugin feature strings */
514 unpack_string (*in, type_name, end, fail);
516 if (G_UNLIKELY (!type_name)) {
517 GST_ERROR ("No feature type name");
521 /* unpack more plugin feature strings */
522 unpack_string (*in, feature_name, end, fail);
524 GST_DEBUG ("Plugin '%s' feature '%s' typename : '%s'", plugin_name,
525 feature_name, type_name);
527 if (G_UNLIKELY (!(type = g_type_from_name (type_name)))) {
528 GST_ERROR ("Unknown type from typename '%s' for plugin '%s'", type_name,
531 g_free (feature_name);
534 if (G_UNLIKELY ((feature = g_object_newv (type, 0, NULL)) == NULL)) {
535 GST_ERROR ("Can't create feature from type");
537 g_free (feature_name);
541 feature->name = feature_name;
543 if (G_UNLIKELY (!GST_IS_PLUGIN_FEATURE (feature))) {
544 GST_ERROR ("typename : '%s' is not a plugin feature", type_name);
548 if (GST_IS_ELEMENT_FACTORY (feature)) {
549 GstRegistryChunkElementFactory *ef;
551 GstElementFactory *factory = GST_ELEMENT_FACTORY_CAST (feature);
554 GST_LOG ("Reading/casting for GstRegistryChunkElementFactory at address %p",
556 unpack_element (*in, ef, GstRegistryChunkElementFactory, end, fail);
557 pf = (GstRegistryChunkPluginFeature *) ef;
559 /* unpack element factory strings */
560 unpack_string (*in, factory->details.longname, end, fail);
561 unpack_string (*in, factory->details.klass, end, fail);
562 unpack_string (*in, factory->details.description, end, fail);
563 unpack_string (*in, factory->details.author, end, fail);
564 n = ef->npadtemplates;
565 GST_DEBUG ("Element factory : '%s' with npadtemplates=%d",
566 factory->details.longname, n);
568 /* load pad templates */
569 for (i = 0; i < n; i++) {
570 if (G_UNLIKELY (!gst_registry_chunks_load_pad_template (factory, in,
572 GST_ERROR ("Error while loading binary pad template");
578 if (G_UNLIKELY ((n = ef->nuriprotocols))) {
579 GST_DEBUG ("Reading %d UriTypes at address %p", n, *in);
582 factory->uri_type = *((guint *) * in);
583 *in += sizeof (factory->uri_type);
584 /*unpack_element(*in, &factory->uri_type, factory->uri_type, end, fail); */
586 factory->uri_protocols = g_new0 (gchar *, n + 1);
587 for (i = 0; i < n; i++) {
588 unpack_string (*in, str, end, fail);
589 factory->uri_protocols[i] = str;
592 /* load interfaces */
593 if (G_UNLIKELY ((n = ef->ninterfaces))) {
594 GST_DEBUG ("Reading %d Interfaces at address %p", n, *in);
595 for (i = 0; i < n; i++) {
596 unpack_string_nocopy (*in, const_str, end, fail);
597 __gst_element_factory_add_interface (factory, const_str);
600 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
601 GstRegistryChunkTypeFindFactory *tff;
602 GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
606 ("Reading/casting for GstRegistryChunkPluginFeature at address %p",
608 unpack_element (*in, tff, GstRegistryChunkTypeFindFactory, end, fail);
609 pf = (GstRegistryChunkPluginFeature *) tff;
611 /* load typefinder caps */
612 unpack_string_nocopy (*in, const_str, end, fail);
613 if (const_str != NULL && *const_str != '\0')
614 factory->caps = gst_caps_from_string (const_str);
616 factory->caps = NULL;
618 /* load extensions */
619 if (tff->nextensions) {
620 GST_DEBUG ("Reading %d Typefind extensions at address %p",
621 tff->nextensions, *in);
622 factory->extensions = g_new0 (gchar *, tff->nextensions + 1);
623 for (i = 0; i < tff->nextensions; i++) {
624 unpack_string (*in, str, end, fail);
625 factory->extensions[i] = str;
628 } else if (GST_IS_INDEX_FACTORY (feature)) {
629 GstIndexFactory *factory = GST_INDEX_FACTORY (feature);
633 ("Reading/casting for GstRegistryChunkPluginFeature at address %p",
635 unpack_element (*in, pf, GstRegistryChunkPluginFeature, end, fail);
637 /* unpack index factory strings */
638 unpack_string (*in, factory->longdesc, end, fail);
640 GST_WARNING ("unhandled factory type : %s", G_OBJECT_TYPE_NAME (feature));
644 feature->rank = pf->rank;
646 feature->plugin_name = plugin_name;
648 gst_registry_add_feature (registry, feature);
649 GST_DEBUG ("Added feature %s", feature->name);
656 GST_INFO ("Reading plugin feature failed");
659 if (GST_IS_OBJECT (feature))
660 gst_object_unref (feature);
662 g_object_unref (feature);
668 gst_registry_chunks_load_plugin_dep_strv (gchar ** in, gchar * end, guint n)
675 arr = g_new0 (gchar *, n + 1);
677 unpack_string (*in, arr[n - 1], end, fail);
682 GST_INFO ("Reading plugin dependency strings failed");
687 gst_registry_chunks_load_plugin_dep (GstPlugin * plugin, gchar ** in,
691 GstRegistryChunkDep *d;
695 GST_LOG_OBJECT (plugin, "Unpacking GstRegistryChunkDep from %p", *in);
696 unpack_element (*in, d, GstRegistryChunkDep, end, fail);
698 dep = g_malloc0 (sizeof (GstPluginDep));
700 dep->env_hash = d->env_hash;
701 dep->stat_hash = d->stat_hash;
703 dep->flags = d->flags;
705 dep->names = gst_registry_chunks_load_plugin_dep_strv (in, end, d->n_names);
706 dep->paths = gst_registry_chunks_load_plugin_dep_strv (in, end, d->n_paths);
708 gst_registry_chunks_load_plugin_dep_strv (in, end, d->n_env_vars);
710 plugin->priv->deps = g_list_append (plugin->priv->deps, dep);
712 GST_DEBUG_OBJECT (plugin, "Loaded external plugin dependency from registry: "
713 "env_hash: %08x, stat_hash: %08x", dep->env_hash, dep->stat_hash);
714 for (s = dep->env_vars; s != NULL && *s != NULL; ++s)
715 GST_LOG_OBJECT (plugin, " evar: %s", *s);
716 for (s = dep->paths; s != NULL && *s != NULL; ++s)
717 GST_LOG_OBJECT (plugin, " path: %s", *s);
718 for (s = dep->names; s != NULL && *s != NULL; ++s)
719 GST_LOG_OBJECT (plugin, " name: %s", *s);
723 GST_INFO ("Reading plugin dependency failed");
729 * _priv_gst_registry_chunks_load_plugin:
731 * Make a new GstPlugin from current GstRegistryChunkPluginElement structure
732 * and add it to the GstRegistry. Return an offset to the next
733 * GstRegistryChunkPluginElement structure.
736 _priv_gst_registry_chunks_load_plugin (GstRegistry * registry, gchar ** in,
737 gchar * end, GstPlugin ** out_plugin)
739 #ifndef GST_DISABLE_GST_DEBUG
742 GstRegistryChunkPluginElement *pe;
743 const gchar *cache_str = NULL;
744 GstPlugin *plugin = NULL;
748 GST_LOG ("Reading/casting for GstRegistryChunkPluginElement at address %p",
750 unpack_element (*in, pe, GstRegistryChunkPluginElement, end, fail);
752 plugin = g_object_newv (GST_TYPE_PLUGIN, 0, NULL);
754 /* TODO: also set GST_PLUGIN_FLAG_CONST */
755 plugin->flags |= GST_PLUGIN_FLAG_CACHED;
756 plugin->file_mtime = pe->file_mtime;
757 plugin->file_size = pe->file_size;
759 /* unpack plugin element strings */
760 unpack_const_string (*in, plugin->desc.name, end, fail);
761 unpack_string (*in, plugin->desc.description, end, fail);
762 unpack_string (*in, plugin->filename, end, fail);
763 unpack_const_string (*in, plugin->desc.version, end, fail);
764 unpack_const_string (*in, plugin->desc.license, end, fail);
765 unpack_const_string (*in, plugin->desc.source, end, fail);
766 unpack_const_string (*in, plugin->desc.package, end, fail);
767 unpack_const_string (*in, plugin->desc.origin, end, fail);
768 GST_LOG ("read strings for name='%s'", plugin->desc.name);
769 GST_LOG (" desc.description='%s'", plugin->desc.description);
770 GST_LOG (" filename='%s'", plugin->filename);
771 GST_LOG (" desc.version='%s'", plugin->desc.version);
772 GST_LOG (" desc.license='%s'", plugin->desc.license);
773 GST_LOG (" desc.source='%s'", plugin->desc.source);
774 GST_LOG (" desc.package='%s'", plugin->desc.package);
775 GST_LOG (" desc.origin='%s'", plugin->desc.origin);
777 /* unpack cache data */
778 unpack_string_nocopy (*in, cache_str, end, fail);
779 if (cache_str != NULL && *cache_str != '\0')
780 plugin->priv->cache_data = gst_structure_from_string (cache_str, NULL);
782 /* If the license string is 'BLACKLIST', mark this as a blacklisted
784 if (strcmp (plugin->desc.license, "BLACKLIST") == 0)
785 plugin->flags |= GST_PLUGIN_FLAG_BLACKLISTED;
787 plugin->basename = g_path_get_basename (plugin->filename);
789 /* Takes ownership of plugin */
790 gst_registry_add_plugin (registry, plugin);
792 GST_DEBUG ("Added plugin '%s' plugin with %d features from binary registry",
793 plugin->desc.name, n);
795 /* Load plugin features */
796 for (i = 0; i < n; i++) {
797 if (G_UNLIKELY (!gst_registry_chunks_load_feature (registry, in, end,
798 plugin->desc.name))) {
799 GST_ERROR ("Error while loading binary feature for plugin '%s'",
800 GST_STR_NULL (plugin->desc.name));
801 gst_registry_remove_plugin (registry, plugin);
806 /* Load external plugin dependencies */
807 for (i = 0; i < pe->n_deps; ++i) {
808 if (G_UNLIKELY (!gst_registry_chunks_load_plugin_dep (plugin, in, end))) {
809 GST_ERROR_OBJECT (plugin, "Could not read external plugin dependency "
810 "for plugin '%s'", GST_STR_NULL (plugin->desc.name));
811 gst_registry_remove_plugin (registry, plugin);
817 *out_plugin = plugin;
823 GST_INFO ("Reading plugin failed after %u bytes", (guint) (end - start));