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 _priv_gst_registry_chunk_free (GstRegistryChunk * chunk)
102 if (!(chunk->flags & GST_REGISTRY_CHUNK_FLAG_CONST)) {
103 if ((chunk->flags & GST_REGISTRY_CHUNK_FLAG_MALLOC))
104 g_free (chunk->data);
106 g_slice_free1 (chunk->size, chunk->data);
108 g_slice_free (GstRegistryChunk, chunk);
112 * gst_registry_chunks_save_const_string:
114 * Store a const string in a binary chunk.
116 * Returns: %TRUE for success
118 inline static gboolean
119 gst_registry_chunks_save_const_string (GList ** list, const gchar * str)
121 GstRegistryChunk *chunk;
123 if (G_UNLIKELY (str == NULL)) {
124 GST_ERROR ("unexpected NULL string in plugin or plugin feature data");
128 chunk = g_slice_new (GstRegistryChunk);
129 chunk->data = (gpointer) str;
130 chunk->size = strlen ((gchar *) chunk->data) + 1;
131 chunk->flags = GST_REGISTRY_CHUNK_FLAG_CONST;
132 chunk->align = FALSE;
133 *list = g_list_prepend (*list, chunk);
138 * gst_registry_chunks_save_string:
140 * Store a string in a binary chunk.
142 * Returns: %TRUE for success
144 inline static gboolean
145 gst_registry_chunks_save_string (GList ** list, gchar * str)
147 GstRegistryChunk *chunk;
149 chunk = g_slice_new (GstRegistryChunk);
151 chunk->size = strlen ((gchar *) chunk->data) + 1;
152 chunk->flags = GST_REGISTRY_CHUNK_FLAG_MALLOC;
153 chunk->align = FALSE;
154 *list = g_list_prepend (*list, chunk);
159 * gst_registry_chunks_save_data:
161 * Store some data in a binary chunk.
163 * Returns: the initialized chunk
165 inline static GstRegistryChunk *
166 gst_registry_chunks_make_data (gpointer data, gulong size)
168 GstRegistryChunk *chunk;
170 chunk = g_slice_new (GstRegistryChunk);
173 chunk->flags = GST_REGISTRY_CHUNK_FLAG_NONE;
180 * gst_registry_chunks_save_pad_template:
182 * Store pad_templates in binary chunks.
184 * Returns: %TRUE for success
187 gst_registry_chunks_save_pad_template (GList ** list,
188 GstStaticPadTemplate * template)
190 GstRegistryChunkPadTemplate *pt;
191 GstRegistryChunk *chk;
193 pt = g_slice_new (GstRegistryChunkPadTemplate);
195 gst_registry_chunks_make_data (pt, sizeof (GstRegistryChunkPadTemplate));
197 pt->presence = template->presence;
198 pt->direction = template->direction;
200 /* pack pad template strings */
201 gst_registry_chunks_save_const_string (list,
202 (gchar *) (template->static_caps.string));
203 gst_registry_chunks_save_const_string (list, template->name_template);
205 *list = g_list_prepend (*list, chk);
210 #define VALIDATE_UTF8(__details, __entry) \
212 if (!g_utf8_validate (__details->__entry, -1, NULL)) { \
213 g_warning ("Invalid UTF-8 in " G_STRINGIFY (__entry) ": %s", \
214 __details->__entry); \
215 g_free (__details->__entry); \
216 __details->__entry = g_strdup ("[ERROR: invalid UTF-8]"); \
221 * gst_registry_chunks_save_feature:
223 * Store features in binary chunks.
225 * Returns: %TRUE for success
228 gst_registry_chunks_save_feature (GList ** list, GstPluginFeature * feature)
230 const gchar *type_name = g_type_name (G_OBJECT_TYPE (feature));
231 GstRegistryChunkPluginFeature *pf = NULL;
232 GstRegistryChunk *chk = NULL;
236 GST_ERROR ("NULL feature type_name, aborting.");
240 if (GST_IS_ELEMENT_FACTORY (feature)) {
241 GstRegistryChunkElementFactory *ef;
242 GstElementFactory *factory = GST_ELEMENT_FACTORY (feature);
244 /* Initialize with zeroes because of struct padding and
245 * valgrind complaining about copying unitialized memory
247 ef = g_slice_new0 (GstRegistryChunkElementFactory);
249 gst_registry_chunks_make_data (ef,
250 sizeof (GstRegistryChunkElementFactory));
251 ef->npadtemplates = ef->ninterfaces = ef->nuriprotocols = 0;
252 pf = (GstRegistryChunkPluginFeature *) ef;
254 /* save interfaces */
255 for (walk = factory->interfaces; walk;
256 walk = g_list_next (walk), ef->ninterfaces++) {
257 gst_registry_chunks_save_const_string (list, (gchar *) walk->data);
259 GST_DEBUG ("Feature %s: saved %d interfaces %d pad templates",
260 GST_OBJECT_NAME (feature), ef->ninterfaces, ef->npadtemplates);
263 if (GST_URI_TYPE_IS_VALID (factory->uri_type)) {
264 if (factory->uri_protocols && *factory->uri_protocols) {
265 GstRegistryChunk *subchk;
269 gst_registry_chunks_make_data (&factory->uri_type,
270 sizeof (factory->uri_type));
271 subchk->flags = GST_REGISTRY_CHUNK_FLAG_CONST;
273 protocol = factory->uri_protocols;
275 gst_registry_chunks_save_const_string (list, *protocol++);
278 *list = g_list_prepend (*list, subchk);
279 GST_DEBUG ("Saved %d UriTypes", ef->nuriprotocols);
281 g_warning ("GStreamer feature '%s' is URI handler but does not provide"
282 " any protocols it can handle", GST_OBJECT_NAME (feature));
286 /* save pad-templates */
287 for (walk = factory->staticpadtemplates; walk;
288 walk = g_list_next (walk), ef->npadtemplates++) {
289 GstStaticPadTemplate *template = walk->data;
291 if (!gst_registry_chunks_save_pad_template (list, template)) {
292 GST_ERROR ("Can't fill pad template, aborting.");
297 /* pack element metadata strings */
298 gst_registry_chunks_save_string (list,
299 gst_structure_to_string (factory->metadata));
300 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
301 GstRegistryChunkTypeFindFactory *tff;
302 GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
305 /* Initialize with zeroes because of struct padding and
306 * valgrind complaining about copying unitialized memory
308 tff = g_slice_new0 (GstRegistryChunkTypeFindFactory);
310 gst_registry_chunks_make_data (tff,
311 sizeof (GstRegistryChunkTypeFindFactory));
312 tff->nextensions = 0;
313 pf = (GstRegistryChunkPluginFeature *) tff;
315 /* save extensions */
316 if (factory->extensions) {
317 while (factory->extensions[tff->nextensions]) {
318 gst_registry_chunks_save_const_string (list,
319 factory->extensions[tff->nextensions++]);
324 /* we copy the caps here so we can simplify them before saving. This
325 * is a lot faster when loading them later on */
326 if (!gst_caps_is_fixed (factory->caps)) {
327 GstCaps *copy = gst_caps_copy (factory->caps);
328 gst_caps_do_simplify (copy);
329 str = gst_caps_to_string (copy);
330 gst_caps_unref (copy);
332 str = gst_caps_to_string (factory->caps);
334 gst_registry_chunks_save_string (list, str);
336 gst_registry_chunks_save_const_string (list, "");
339 GST_WARNING ("unhandled feature type '%s'", type_name);
343 pf->rank = feature->rank;
344 *list = g_list_prepend (*list, chk);
346 /* pack plugin feature strings */
347 gst_registry_chunks_save_const_string (list, GST_OBJECT_NAME (feature));
348 gst_registry_chunks_save_const_string (list, (gchar *) type_name);
361 gst_registry_chunks_save_plugin_dep (GList ** list, GstPluginDep * dep)
363 GstRegistryChunkDep *ed;
364 GstRegistryChunk *chk;
367 ed = g_slice_new (GstRegistryChunkDep);
368 chk = gst_registry_chunks_make_data (ed, sizeof (GstRegistryChunkDep));
370 ed->flags = dep->flags;
375 ed->env_hash = dep->env_hash;
376 ed->stat_hash = dep->stat_hash;
378 for (s = dep->env_vars; s != NULL && *s != NULL; ++s, ++ed->n_env_vars)
379 gst_registry_chunks_save_string (list, g_strdup (*s));
381 for (s = dep->paths; s != NULL && *s != NULL; ++s, ++ed->n_paths)
382 gst_registry_chunks_save_string (list, g_strdup (*s));
384 for (s = dep->names; s != NULL && *s != NULL; ++s, ++ed->n_names)
385 gst_registry_chunks_save_string (list, g_strdup (*s));
387 *list = g_list_prepend (*list, chk);
389 GST_LOG ("Saved external plugin dependency");
394 * _priv_gst_registry_chunks_save_plugin:
396 * Adapt a GstPlugin to our GstRegistryChunkPluginElement structure, and
397 * prepend it as a GstRegistryChunk in the provided list.
401 _priv_gst_registry_chunks_save_plugin (GList ** list, GstRegistry * registry,
404 GstRegistryChunkPluginElement *pe;
405 GstRegistryChunk *chk;
406 GList *plugin_features = NULL;
409 pe = g_slice_new (GstRegistryChunkPluginElement);
411 gst_registry_chunks_make_data (pe,
412 sizeof (GstRegistryChunkPluginElement));
414 pe->file_size = plugin->file_size;
415 pe->file_mtime = plugin->file_mtime;
419 /* pack external deps */
420 for (walk = plugin->priv->deps; walk != NULL; walk = walk->next) {
421 if (!gst_registry_chunks_save_plugin_dep (list, walk->data)) {
422 GST_ERROR ("Could not save external plugin dependency, aborting.");
428 /* pack plugin features */
430 gst_registry_get_feature_list_by_plugin (registry, plugin->desc.name);
431 for (walk = plugin_features; walk; walk = g_list_next (walk), pe->nfeatures++) {
432 GstPluginFeature *feature = GST_PLUGIN_FEATURE (walk->data);
434 if (!gst_registry_chunks_save_feature (list, feature)) {
435 GST_ERROR ("Can't fill plugin feature, aborting.");
440 gst_plugin_feature_list_free (plugin_features);
442 /* pack cache data */
443 if (plugin->priv->cache_data) {
444 gchar *cache_str = gst_structure_to_string (plugin->priv->cache_data);
445 gst_registry_chunks_save_string (list, cache_str);
447 gst_registry_chunks_save_const_string (list, "");
450 /* pack plugin element strings */
451 gst_registry_chunks_save_const_string (list,
452 (plugin->desc.release_datetime) ? plugin->desc.release_datetime : "");
453 gst_registry_chunks_save_const_string (list, plugin->desc.origin);
454 gst_registry_chunks_save_const_string (list, plugin->desc.package);
455 gst_registry_chunks_save_const_string (list, plugin->desc.source);
456 gst_registry_chunks_save_const_string (list, plugin->desc.license);
457 gst_registry_chunks_save_const_string (list, plugin->desc.version);
458 gst_registry_chunks_save_const_string (list, plugin->filename);
459 gst_registry_chunks_save_const_string (list, plugin->desc.description);
460 gst_registry_chunks_save_const_string (list, plugin->desc.name);
462 *list = g_list_prepend (*list, chk);
464 GST_DEBUG ("Found %d features in plugin \"%s\"", pe->nfeatures,
470 gst_plugin_feature_list_free (plugin_features);
477 * gst_registry_chunks_load_pad_template:
479 * Make a new GstStaticPadTemplate from current GstRegistryChunkPadTemplate
482 * Returns: new GstStaticPadTemplate
485 gst_registry_chunks_load_pad_template (GstElementFactory * factory, gchar ** in,
488 GstRegistryChunkPadTemplate *pt;
489 GstStaticPadTemplate *template = NULL;
492 GST_DEBUG ("Reading/casting for GstRegistryChunkPadTemplate at address %p",
494 unpack_element (*in, pt, GstRegistryChunkPadTemplate, end, fail);
496 template = g_slice_new (GstStaticPadTemplate);
497 template->presence = pt->presence;
498 template->direction = (GstPadDirection) pt->direction;
499 template->static_caps.caps = NULL;
501 /* unpack pad template strings */
502 unpack_const_string (*in, template->name_template, end, fail);
503 unpack_const_string (*in, template->static_caps.string, end, fail);
505 __gst_element_factory_add_static_pad_template (factory, template);
506 GST_DEBUG ("Added pad_template %s", template->name_template);
510 GST_INFO ("Reading pad template failed");
512 g_slice_free (GstStaticPadTemplate, template);
517 * gst_registry_chunks_load_feature:
519 * Make a new GstPluginFeature from current binary plugin feature structure
521 * Returns: new GstPluginFeature
524 gst_registry_chunks_load_feature (GstRegistry * registry, gchar ** in,
525 gchar * end, GstPlugin * plugin)
527 GstRegistryChunkPluginFeature *pf = NULL;
528 GstPluginFeature *feature = NULL;
529 const gchar *const_str, *type_name;
530 const gchar *feature_name;
531 const gchar *plugin_name;
536 plugin_name = plugin->desc.name;
538 /* unpack plugin feature strings */
539 unpack_string_nocopy (*in, type_name, end, fail);
541 if (G_UNLIKELY (!type_name)) {
542 GST_ERROR ("No feature type name");
546 /* unpack more plugin feature strings */
547 unpack_string_nocopy (*in, feature_name, end, fail);
549 GST_DEBUG ("Plugin '%s' feature '%s' typename : '%s'", plugin_name,
550 feature_name, type_name);
552 if (G_UNLIKELY (!(type = g_type_from_name (type_name)))) {
553 GST_ERROR ("Unknown type from typename '%s' for plugin '%s'", type_name,
557 if (G_UNLIKELY ((feature = g_object_newv (type, 0, NULL)) == NULL)) {
558 GST_ERROR ("Can't create feature from type");
561 gst_plugin_feature_set_name (feature, feature_name);
563 if (G_UNLIKELY (!GST_IS_PLUGIN_FEATURE (feature))) {
564 GST_ERROR ("typename : '%s' is not a plugin feature", type_name);
568 if (GST_IS_ELEMENT_FACTORY (feature)) {
569 GstRegistryChunkElementFactory *ef;
571 GstElementFactory *factory = GST_ELEMENT_FACTORY_CAST (feature);
573 const gchar *meta_data_str;
576 GST_LOG ("Reading/casting for GstRegistryChunkElementFactory at address %p",
578 unpack_element (*in, ef, GstRegistryChunkElementFactory, end, fail);
579 pf = (GstRegistryChunkPluginFeature *) ef;
581 /* unpack element factory strings */
582 unpack_string_nocopy (*in, meta_data_str, end, fail);
583 if (meta_data_str && *meta_data_str) {
584 factory->metadata = gst_structure_from_string (meta_data_str, NULL);
585 if (!factory->metadata) {
587 ("Error when trying to deserialize structure for metadata '%s'",
592 n = ef->npadtemplates;
593 GST_DEBUG ("Element factory : npadtemplates=%d", n);
595 /* load pad templates */
596 for (i = 0; i < n; i++) {
597 if (G_UNLIKELY (!gst_registry_chunks_load_pad_template (factory, in,
599 GST_ERROR ("Error while loading binary pad template");
605 if (G_UNLIKELY ((n = ef->nuriprotocols))) {
606 GST_DEBUG ("Reading %d UriTypes at address %p", n, *in);
609 factory->uri_type = *((guint *) * in);
610 *in += sizeof (factory->uri_type);
611 /*unpack_element(*in, &factory->uri_type, factory->uri_type, end, fail); */
613 factory->uri_protocols = g_new0 (gchar *, n + 1);
614 for (i = 0; i < n; i++) {
615 unpack_string (*in, str, end, fail);
616 factory->uri_protocols[i] = str;
619 /* load interfaces */
620 if (G_UNLIKELY ((n = ef->ninterfaces))) {
621 GST_DEBUG ("Reading %d Interfaces at address %p", n, *in);
622 for (i = 0; i < n; i++) {
623 unpack_string_nocopy (*in, const_str, end, fail);
624 __gst_element_factory_add_interface (factory, const_str);
627 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
628 GstRegistryChunkTypeFindFactory *tff;
629 GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
633 ("Reading/casting for GstRegistryChunkPluginFeature at address %p",
635 unpack_element (*in, tff, GstRegistryChunkTypeFindFactory, end, fail);
636 pf = (GstRegistryChunkPluginFeature *) tff;
638 /* load typefinder caps */
639 unpack_string_nocopy (*in, const_str, end, fail);
640 if (const_str != NULL && *const_str != '\0')
641 factory->caps = gst_caps_from_string (const_str);
643 factory->caps = NULL;
645 /* load extensions */
646 if (tff->nextensions) {
647 GST_DEBUG ("Reading %d Typefind extensions at address %p",
648 tff->nextensions, *in);
649 factory->extensions = g_new0 (gchar *, tff->nextensions + 1);
650 /* unpack in reverse order to maintain the correct order */
651 for (i = tff->nextensions; i > 0; i--) {
652 unpack_string (*in, str, end, fail);
653 factory->extensions[i - 1] = str;
657 GST_WARNING ("unhandled factory type : %s", G_OBJECT_TYPE_NAME (feature));
661 feature->rank = pf->rank;
663 feature->plugin_name = plugin_name;
664 feature->plugin = plugin;
665 g_object_add_weak_pointer ((GObject *) plugin,
666 (gpointer *) & feature->plugin);
668 gst_registry_add_feature (registry, feature);
669 GST_DEBUG ("Added feature %s, plugin %p %s", GST_OBJECT_NAME (feature),
670 plugin, plugin_name);
676 GST_INFO ("Reading plugin feature failed");
678 if (GST_IS_OBJECT (feature))
679 gst_object_unref (feature);
681 g_object_unref (feature);
687 gst_registry_chunks_load_plugin_dep_strv (gchar ** in, gchar * end, guint n)
694 arr = g_new0 (gchar *, n + 1);
696 unpack_string (*in, arr[n - 1], end, fail);
701 GST_INFO ("Reading plugin dependency strings failed");
706 gst_registry_chunks_load_plugin_dep (GstPlugin * plugin, gchar ** in,
710 GstRegistryChunkDep *d;
714 GST_LOG_OBJECT (plugin, "Unpacking GstRegistryChunkDep from %p", *in);
715 unpack_element (*in, d, GstRegistryChunkDep, end, fail);
717 dep = g_slice_new (GstPluginDep);
719 dep->env_hash = d->env_hash;
720 dep->stat_hash = d->stat_hash;
722 dep->flags = (GstPluginDependencyFlags) d->flags;
724 dep->names = gst_registry_chunks_load_plugin_dep_strv (in, end, d->n_names);
725 dep->paths = gst_registry_chunks_load_plugin_dep_strv (in, end, d->n_paths);
727 gst_registry_chunks_load_plugin_dep_strv (in, end, d->n_env_vars);
729 plugin->priv->deps = g_list_append (plugin->priv->deps, dep);
731 GST_DEBUG_OBJECT (plugin, "Loaded external plugin dependency from registry: "
732 "env_hash: %08x, stat_hash: %08x", dep->env_hash, dep->stat_hash);
733 for (s = dep->env_vars; s != NULL && *s != NULL; ++s)
734 GST_LOG_OBJECT (plugin, " evar: %s", *s);
735 for (s = dep->paths; s != NULL && *s != NULL; ++s)
736 GST_LOG_OBJECT (plugin, " path: %s", *s);
737 for (s = dep->names; s != NULL && *s != NULL; ++s)
738 GST_LOG_OBJECT (plugin, " name: %s", *s);
742 GST_INFO ("Reading plugin dependency failed");
748 * _priv_gst_registry_chunks_load_plugin:
750 * Make a new GstPlugin from current GstRegistryChunkPluginElement structure
751 * and add it to the GstRegistry. Return an offset to the next
752 * GstRegistryChunkPluginElement structure.
755 _priv_gst_registry_chunks_load_plugin (GstRegistry * registry, gchar ** in,
756 gchar * end, GstPlugin ** out_plugin)
758 #ifndef GST_DISABLE_GST_DEBUG
761 GstRegistryChunkPluginElement *pe;
762 const gchar *cache_str = NULL;
763 GstPlugin *plugin = NULL;
767 GST_LOG ("Reading/casting for GstRegistryChunkPluginElement at address %p",
769 unpack_element (*in, pe, GstRegistryChunkPluginElement, end, fail);
771 plugin = g_object_newv (GST_TYPE_PLUGIN, 0, NULL);
773 /* TODO: also set GST_PLUGIN_FLAG_CONST */
774 plugin->flags |= GST_PLUGIN_FLAG_CACHED;
775 plugin->file_mtime = pe->file_mtime;
776 plugin->file_size = pe->file_size;
778 /* unpack plugin element strings */
779 unpack_const_string (*in, plugin->desc.name, end, fail);
780 unpack_const_string (*in, plugin->desc.description, end, fail);
781 unpack_string (*in, plugin->filename, end, fail);
782 unpack_const_string (*in, plugin->desc.version, end, fail);
783 unpack_const_string (*in, plugin->desc.license, end, fail);
784 unpack_const_string (*in, plugin->desc.source, end, fail);
785 unpack_const_string (*in, plugin->desc.package, end, fail);
786 unpack_const_string (*in, plugin->desc.origin, end, fail);
787 unpack_const_string (*in, plugin->desc.release_datetime, end, fail);
789 GST_LOG ("read strings for name='%s'", plugin->desc.name);
790 GST_LOG (" desc.description='%s'", plugin->desc.description);
791 GST_LOG (" filename='%s'", plugin->filename);
792 GST_LOG (" desc.version='%s'", plugin->desc.version);
793 GST_LOG (" desc.license='%s'", plugin->desc.license);
794 GST_LOG (" desc.source='%s'", plugin->desc.source);
795 GST_LOG (" desc.package='%s'", plugin->desc.package);
796 GST_LOG (" desc.origin='%s'", plugin->desc.origin);
797 GST_LOG (" desc.datetime=%s", plugin->desc.release_datetime);
799 if (plugin->desc.release_datetime[0] == '\0')
800 plugin->desc.release_datetime = NULL;
802 /* unpack cache data */
803 unpack_string_nocopy (*in, cache_str, end, fail);
804 if (cache_str != NULL && *cache_str != '\0')
805 plugin->priv->cache_data = gst_structure_from_string (cache_str, NULL);
807 /* If the license string is 'BLACKLIST', mark this as a blacklisted
809 if (strcmp (plugin->desc.license, "BLACKLIST") == 0)
810 plugin->flags |= GST_PLUGIN_FLAG_BLACKLISTED;
812 plugin->basename = g_path_get_basename (plugin->filename);
814 /* Takes ownership of plugin */
815 gst_registry_add_plugin (registry, plugin);
817 GST_DEBUG ("Added plugin '%s' plugin with %d features from binary registry",
818 plugin->desc.name, n);
820 /* Load plugin features */
821 for (i = 0; i < n; i++) {
822 if (G_UNLIKELY (!gst_registry_chunks_load_feature (registry, in, end,
824 GST_ERROR ("Error while loading binary feature for plugin '%s'",
825 GST_STR_NULL (plugin->desc.name));
826 gst_registry_remove_plugin (registry, plugin);
831 /* Load external plugin dependencies */
832 for (i = 0; i < pe->n_deps; ++i) {
833 if (G_UNLIKELY (!gst_registry_chunks_load_plugin_dep (plugin, in, end))) {
834 GST_ERROR_OBJECT (plugin, "Could not read external plugin dependency "
835 "for plugin '%s'", GST_STR_NULL (plugin->desc.name));
836 gst_registry_remove_plugin (registry, plugin);
842 *out_plugin = plugin;
848 GST_INFO ("Reading plugin failed after %u bytes", (guint) (end - start));
853 _priv_gst_registry_chunks_save_global_header (GList ** list,
854 GstRegistry * registry, guint32 filter_env_hash)
856 GstRegistryChunkGlobalHeader *hdr;
857 GstRegistryChunk *chk;
859 hdr = g_slice_new (GstRegistryChunkGlobalHeader);
860 chk = gst_registry_chunks_make_data (hdr,
861 sizeof (GstRegistryChunkGlobalHeader));
863 hdr->filter_env_hash = filter_env_hash;
865 *list = g_list_prepend (*list, chk);
867 GST_LOG ("Saved global header (filter_env_hash=0x%08x)", filter_env_hash);
871 _priv_gst_registry_chunks_load_global_header (GstRegistry * registry,
872 gchar ** in, gchar * end, guint32 * filter_env_hash)
874 GstRegistryChunkGlobalHeader *hdr;
877 GST_LOG ("Reading/casting for GstRegistryChunkGlobalHeader at %p", *in);
878 unpack_element (*in, hdr, GstRegistryChunkGlobalHeader, end, fail);
879 *filter_env_hash = hdr->filter_env_hash;
884 GST_WARNING ("Reading global header failed");