|
Packit |
f546b1 |
/* GStreamer
|
|
Packit |
f546b1 |
* Copyright (C) 2006 Josep Torra <josep@fluendo.com>
|
|
Packit |
f546b1 |
* 2006 Mathieu Garcia <matthieu@fluendo.com>
|
|
Packit |
f546b1 |
* 2006,2007 Stefan Kost <ensonic@users.sf.net>
|
|
Packit |
f546b1 |
* 2008 Sebastian Dröge <slomo@circular-chaos.org>
|
|
Packit |
f546b1 |
* 2008 Jan Schmidt <jan.schmidt@sun.com>
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* gstregistrychunks.c: GstRegistryChunk helper for serialising/deserialising
|
|
Packit |
f546b1 |
* plugin entries and features.
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
f546b1 |
* modify it under the terms of the GNU Library General Public
|
|
Packit |
f546b1 |
* License as published by the Free Software Foundation; either
|
|
Packit |
f546b1 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
f546b1 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
f546b1 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
f546b1 |
* Library General Public License for more details.
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* You should have received a copy of the GNU Library General Public
|
|
Packit |
f546b1 |
* License along with this library; if not, write to the
|
|
Packit |
f546b1 |
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
Packit |
f546b1 |
* Boston, MA 02110-1301, USA.
|
|
Packit |
f546b1 |
*/
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
f546b1 |
# include "config.h"
|
|
Packit |
f546b1 |
#endif
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
#include <gst/gst_private.h>
|
|
Packit |
f546b1 |
#include <gst/gstconfig.h>
|
|
Packit |
f546b1 |
#include <gst/gstelement.h>
|
|
Packit |
f546b1 |
#include <gst/gsttracerfactory.h>
|
|
Packit |
f546b1 |
#include <gst/gsttypefind.h>
|
|
Packit |
f546b1 |
#include <gst/gsttypefindfactory.h>
|
|
Packit |
f546b1 |
#include <gst/gstdeviceproviderfactory.h>
|
|
Packit |
f546b1 |
#include <gst/gstdynamictypefactory.h>
|
|
Packit |
f546b1 |
#include <gst/gsturi.h>
|
|
Packit |
f546b1 |
#include <gst/gstinfo.h>
|
|
Packit |
f546b1 |
#include <gst/gstenumtypes.h>
|
|
Packit |
f546b1 |
#include <gst/gstpadtemplate.h>
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
#include <gst/gstregistrychunks.h>
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
#define GST_CAT_DEFAULT GST_CAT_REGISTRY
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* count string length, but return -1 if we hit the eof */
|
|
Packit |
f546b1 |
static gint
|
|
Packit |
f546b1 |
_strnlen (const gchar * str, gint maxlen)
|
|
Packit |
f546b1 |
{
|
|
Packit |
f546b1 |
gint len = 0;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
while (G_LIKELY (len < maxlen)) {
|
|
Packit |
f546b1 |
if (G_UNLIKELY (str[len] == '\0'))
|
|
Packit |
f546b1 |
return len;
|
|
Packit |
f546b1 |
len++;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
return -1;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* Macros */
|
|
Packit |
f546b1 |
#define unpack_element(inptr, outptr, element, endptr, error_label) G_STMT_START{ \
|
|
Packit |
f546b1 |
if (inptr + sizeof(element) > endptr) { \
|
|
Packit |
f546b1 |
GST_ERROR ("Failed reading element " G_STRINGIFY (element) \
|
|
Packit |
f546b1 |
". Have %d bytes need %" G_GSIZE_FORMAT, \
|
|
Packit |
f546b1 |
(int) (endptr - inptr), sizeof(element)); \
|
|
Packit |
f546b1 |
goto error_label; \
|
|
Packit |
f546b1 |
} \
|
|
Packit |
f546b1 |
outptr = (element *) inptr; \
|
|
Packit |
f546b1 |
inptr += sizeof (element); \
|
|
Packit |
f546b1 |
}G_STMT_END
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
#define unpack_const_string(inptr, outptr, endptr, error_label) G_STMT_START{\
|
|
Packit |
f546b1 |
gint _len = _strnlen (inptr, (endptr-inptr)); \
|
|
Packit |
f546b1 |
if (_len == -1) \
|
|
Packit |
f546b1 |
goto error_label; \
|
|
Packit |
f546b1 |
outptr = g_intern_string ((const gchar *)inptr); \
|
|
Packit |
f546b1 |
inptr += _len + 1; \
|
|
Packit |
f546b1 |
}G_STMT_END
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
#define unpack_string(inptr, outptr, endptr, error_label) G_STMT_START{\
|
|
Packit |
f546b1 |
gint _len = _strnlen (inptr, (endptr-inptr)); \
|
|
Packit |
f546b1 |
if (_len == -1) \
|
|
Packit |
f546b1 |
goto error_label; \
|
|
Packit |
f546b1 |
outptr = g_memdup ((gconstpointer)inptr, _len + 1); \
|
|
Packit |
f546b1 |
inptr += _len + 1; \
|
|
Packit |
f546b1 |
}G_STMT_END
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
#define unpack_string_nocopy(inptr, outptr, endptr, error_label) G_STMT_START{\
|
|
Packit |
f546b1 |
gint _len = _strnlen (inptr, (endptr-inptr)); \
|
|
Packit |
f546b1 |
if (_len == -1) \
|
|
Packit |
f546b1 |
goto error_label; \
|
|
Packit |
f546b1 |
outptr = (const gchar *)inptr; \
|
|
Packit |
f546b1 |
inptr += _len + 1; \
|
|
Packit |
f546b1 |
}G_STMT_END
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
#define ALIGNMENT (sizeof (void *))
|
|
Packit |
f546b1 |
#define alignment(_address) (gsize)_address%ALIGNMENT
|
|
Packit |
f546b1 |
#define align(_ptr) _ptr += (( alignment(_ptr) == 0) ? 0 : ALIGNMENT-alignment(_ptr))
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
void
|
|
Packit |
f546b1 |
_priv_gst_registry_chunk_free (GstRegistryChunk * chunk)
|
|
Packit |
f546b1 |
{
|
|
Packit |
f546b1 |
if (!(chunk->flags & GST_REGISTRY_CHUNK_FLAG_CONST)) {
|
|
Packit |
f546b1 |
if ((chunk->flags & GST_REGISTRY_CHUNK_FLAG_MALLOC))
|
|
Packit |
f546b1 |
g_free (chunk->data);
|
|
Packit |
f546b1 |
else
|
|
Packit |
f546b1 |
g_slice_free1 (chunk->size, chunk->data);
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
g_slice_free (GstRegistryChunk, chunk);
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/*
|
|
Packit |
f546b1 |
* gst_registry_chunks_save_const_string:
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* Store a const string in a binary chunk.
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* Returns: %TRUE for success
|
|
Packit |
f546b1 |
*/
|
|
Packit |
f546b1 |
inline static gboolean
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (GList ** list, const gchar * str)
|
|
Packit |
f546b1 |
{
|
|
Packit |
f546b1 |
GstRegistryChunk *chunk;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
if (G_UNLIKELY (str == NULL)) {
|
|
Packit |
f546b1 |
GST_ERROR ("unexpected NULL string in plugin or plugin feature data");
|
|
Packit |
f546b1 |
str = "";
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
chunk = g_slice_new (GstRegistryChunk);
|
|
Packit |
f546b1 |
chunk->data = (gpointer) str;
|
|
Packit |
f546b1 |
chunk->size = strlen ((gchar *) chunk->data) + 1;
|
|
Packit |
f546b1 |
chunk->flags = GST_REGISTRY_CHUNK_FLAG_CONST;
|
|
Packit |
f546b1 |
chunk->align = FALSE;
|
|
Packit |
f546b1 |
*list = g_list_prepend (*list, chunk);
|
|
Packit |
f546b1 |
return TRUE;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/*
|
|
Packit |
f546b1 |
* gst_registry_chunks_save_string:
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* Store a string in a binary chunk.
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* Returns: %TRUE for success
|
|
Packit |
f546b1 |
*/
|
|
Packit |
f546b1 |
inline static gboolean
|
|
Packit |
f546b1 |
gst_registry_chunks_save_string (GList ** list, gchar * str)
|
|
Packit |
f546b1 |
{
|
|
Packit |
f546b1 |
GstRegistryChunk *chunk;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
chunk = g_slice_new (GstRegistryChunk);
|
|
Packit |
f546b1 |
chunk->data = str;
|
|
Packit |
f546b1 |
chunk->size = strlen ((gchar *) chunk->data) + 1;
|
|
Packit |
f546b1 |
chunk->flags = GST_REGISTRY_CHUNK_FLAG_MALLOC;
|
|
Packit |
f546b1 |
chunk->align = FALSE;
|
|
Packit |
f546b1 |
*list = g_list_prepend (*list, chunk);
|
|
Packit |
f546b1 |
return TRUE;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/*
|
|
Packit |
f546b1 |
* gst_registry_chunks_save_data:
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* Store some data in a binary chunk.
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* Returns: the initialized chunk
|
|
Packit |
f546b1 |
*/
|
|
Packit |
f546b1 |
inline static GstRegistryChunk *
|
|
Packit |
f546b1 |
gst_registry_chunks_make_data (gpointer data, gulong size)
|
|
Packit |
f546b1 |
{
|
|
Packit |
f546b1 |
GstRegistryChunk *chunk;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
chunk = g_slice_new (GstRegistryChunk);
|
|
Packit |
f546b1 |
chunk->data = data;
|
|
Packit |
f546b1 |
chunk->size = size;
|
|
Packit |
f546b1 |
chunk->flags = GST_REGISTRY_CHUNK_FLAG_NONE;
|
|
Packit |
f546b1 |
chunk->align = TRUE;
|
|
Packit |
f546b1 |
return chunk;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/*
|
|
Packit |
f546b1 |
* gst_registry_chunks_save_pad_template:
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* Store pad_templates in binary chunks.
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* Returns: %TRUE for success
|
|
Packit |
f546b1 |
*/
|
|
Packit |
f546b1 |
static gboolean
|
|
Packit |
f546b1 |
gst_registry_chunks_save_pad_template (GList ** list,
|
|
Packit |
f546b1 |
GstStaticPadTemplate * template)
|
|
Packit |
f546b1 |
{
|
|
Packit |
f546b1 |
GstRegistryChunkPadTemplate *pt;
|
|
Packit |
f546b1 |
GstRegistryChunk *chk;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
pt = g_slice_new (GstRegistryChunkPadTemplate);
|
|
Packit |
f546b1 |
chk =
|
|
Packit |
f546b1 |
gst_registry_chunks_make_data (pt, sizeof (GstRegistryChunkPadTemplate));
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
pt->presence = template->presence;
|
|
Packit |
f546b1 |
pt->direction = template->direction;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* pack pad template strings */
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list,
|
|
Packit |
f546b1 |
(gchar *) (template->static_caps.string));
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list, template->name_template);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
*list = g_list_prepend (*list, chk);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
return TRUE;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/*
|
|
Packit |
f546b1 |
* gst_registry_chunks_save_feature:
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* Store features in binary chunks.
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* Returns: %TRUE for success
|
|
Packit |
f546b1 |
*/
|
|
Packit |
f546b1 |
static gboolean
|
|
Packit |
f546b1 |
gst_registry_chunks_save_feature (GList ** list, GstPluginFeature * feature)
|
|
Packit |
f546b1 |
{
|
|
Packit |
f546b1 |
const gchar *type_name = G_OBJECT_TYPE_NAME (feature);
|
|
Packit |
f546b1 |
GstRegistryChunkPluginFeature *pf = NULL;
|
|
Packit |
f546b1 |
GstRegistryChunk *chk = NULL;
|
|
Packit |
f546b1 |
GList *walk;
|
|
Packit |
f546b1 |
gsize pf_size = 0;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
if (!type_name) {
|
|
Packit |
f546b1 |
GST_ERROR ("NULL feature type_name, aborting.");
|
|
Packit |
f546b1 |
return FALSE;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
if (GST_IS_ELEMENT_FACTORY (feature)) {
|
|
Packit |
f546b1 |
GstRegistryChunkElementFactory *ef;
|
|
Packit |
f546b1 |
GstElementFactory *factory = GST_ELEMENT_FACTORY (feature);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* Initialize with zeroes because of struct padding and
|
|
Packit |
f546b1 |
* valgrind complaining about copying unitialized memory
|
|
Packit |
f546b1 |
*/
|
|
Packit |
f546b1 |
ef = g_slice_new0 (GstRegistryChunkElementFactory);
|
|
Packit |
f546b1 |
pf_size = sizeof (GstRegistryChunkElementFactory);
|
|
Packit |
f546b1 |
chk = gst_registry_chunks_make_data (ef, pf_size);
|
|
Packit |
f546b1 |
ef->npadtemplates = ef->ninterfaces = ef->nuriprotocols = 0;
|
|
Packit |
f546b1 |
pf = (GstRegistryChunkPluginFeature *) ef;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* save interfaces */
|
|
Packit |
f546b1 |
for (walk = factory->interfaces; walk;
|
|
Packit |
f546b1 |
walk = g_list_next (walk), ef->ninterfaces++) {
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list, (gchar *) walk->data);
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
GST_DEBUG_OBJECT (feature, "saved %d interfaces %d pad templates",
|
|
Packit |
f546b1 |
ef->ninterfaces, ef->npadtemplates);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* save uritypes */
|
|
Packit |
f546b1 |
if (GST_URI_TYPE_IS_VALID (factory->uri_type)) {
|
|
Packit |
f546b1 |
if (factory->uri_protocols && *factory->uri_protocols) {
|
|
Packit |
f546b1 |
GstRegistryChunk *subchk;
|
|
Packit |
f546b1 |
gchar **protocol;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
subchk =
|
|
Packit |
f546b1 |
gst_registry_chunks_make_data (&factory->uri_type,
|
|
Packit |
f546b1 |
sizeof (factory->uri_type));
|
|
Packit |
f546b1 |
subchk->flags = GST_REGISTRY_CHUNK_FLAG_CONST;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
protocol = factory->uri_protocols;
|
|
Packit |
f546b1 |
while (*protocol) {
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list, *protocol++);
|
|
Packit |
f546b1 |
ef->nuriprotocols++;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
*list = g_list_prepend (*list, subchk);
|
|
Packit |
f546b1 |
GST_DEBUG_OBJECT (feature, "Saved %d UriTypes", ef->nuriprotocols);
|
|
Packit |
f546b1 |
} else {
|
|
Packit |
f546b1 |
g_warning ("GStreamer feature '%s' is URI handler but does not provide"
|
|
Packit |
f546b1 |
" any protocols it can handle", GST_OBJECT_NAME (feature));
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* save pad-templates */
|
|
Packit |
f546b1 |
for (walk = factory->staticpadtemplates; walk;
|
|
Packit |
f546b1 |
walk = g_list_next (walk), ef->npadtemplates++) {
|
|
Packit |
f546b1 |
GstStaticPadTemplate *template = walk->data;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
if (!gst_registry_chunks_save_pad_template (list, template)) {
|
|
Packit |
f546b1 |
GST_ERROR_OBJECT (feature, "Can't fill pad template, aborting.");
|
|
Packit |
f546b1 |
goto fail;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* pack element metadata strings */
|
|
Packit |
f546b1 |
gst_registry_chunks_save_string (list,
|
|
Packit |
f546b1 |
gst_structure_to_string (factory->metadata));
|
|
Packit |
f546b1 |
} else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
|
|
Packit |
f546b1 |
GstRegistryChunkTypeFindFactory *tff;
|
|
Packit |
f546b1 |
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
|
|
Packit |
f546b1 |
gchar *str;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* Initialize with zeroes because of struct padding and
|
|
Packit |
f546b1 |
* valgrind complaining about copying unitialized memory
|
|
Packit |
f546b1 |
*/
|
|
Packit |
f546b1 |
tff = g_slice_new0 (GstRegistryChunkTypeFindFactory);
|
|
Packit |
f546b1 |
pf_size = sizeof (GstRegistryChunkTypeFindFactory);
|
|
Packit |
f546b1 |
chk = gst_registry_chunks_make_data (tff, pf_size);
|
|
Packit |
f546b1 |
tff->nextensions = 0;
|
|
Packit |
f546b1 |
pf = (GstRegistryChunkPluginFeature *) tff;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* save extensions */
|
|
Packit |
f546b1 |
if (factory->extensions) {
|
|
Packit |
f546b1 |
while (factory->extensions[tff->nextensions]) {
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list,
|
|
Packit |
f546b1 |
factory->extensions[tff->nextensions++]);
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
GST_DEBUG_OBJECT (feature, "saved %d extensions", tff->nextensions);
|
|
Packit |
f546b1 |
/* save caps */
|
|
Packit |
f546b1 |
if (factory->caps) {
|
|
Packit |
f546b1 |
GstCaps *fcaps = gst_caps_ref (factory->caps);
|
|
Packit |
f546b1 |
/* we simplify the caps before saving. This is a lot faster
|
|
Packit |
f546b1 |
* when loading them later on */
|
|
Packit |
f546b1 |
fcaps = gst_caps_simplify (fcaps);
|
|
Packit |
f546b1 |
str = gst_caps_to_string (fcaps);
|
|
Packit |
f546b1 |
gst_caps_unref (fcaps);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
gst_registry_chunks_save_string (list, str);
|
|
Packit |
f546b1 |
} else {
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list, "");
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
} else if (GST_IS_DEVICE_PROVIDER_FACTORY (feature)) {
|
|
Packit |
f546b1 |
GstRegistryChunkDeviceProviderFactory *tff;
|
|
Packit |
f546b1 |
GstDeviceProviderFactory *factory = GST_DEVICE_PROVIDER_FACTORY (feature);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* Initialize with zeroes because of struct padding and
|
|
Packit |
f546b1 |
* valgrind complaining about copying unitialized memory
|
|
Packit |
f546b1 |
*/
|
|
Packit |
f546b1 |
tff = g_slice_new0 (GstRegistryChunkDeviceProviderFactory);
|
|
Packit |
f546b1 |
chk =
|
|
Packit |
f546b1 |
gst_registry_chunks_make_data (tff,
|
|
Packit |
f546b1 |
sizeof (GstRegistryChunkDeviceProviderFactory));
|
|
Packit |
f546b1 |
pf = (GstRegistryChunkPluginFeature *) tff;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* pack element metadata strings */
|
|
Packit |
f546b1 |
gst_registry_chunks_save_string (list,
|
|
Packit |
f546b1 |
gst_structure_to_string (factory->metadata));
|
|
Packit |
f546b1 |
} else if (GST_IS_TRACER_FACTORY (feature)) {
|
|
Packit |
f546b1 |
/* Initialize with zeroes because of struct padding and
|
|
Packit |
f546b1 |
* valgrind complaining about copying unitialized memory
|
|
Packit |
f546b1 |
*/
|
|
Packit |
f546b1 |
pf = g_slice_new0 (GstRegistryChunkPluginFeature);
|
|
Packit |
f546b1 |
pf_size = sizeof (GstRegistryChunkPluginFeature);
|
|
Packit |
f546b1 |
chk = gst_registry_chunks_make_data (pf, pf_size);
|
|
Packit |
f546b1 |
} else if (GST_IS_DYNAMIC_TYPE_FACTORY (feature)) {
|
|
Packit |
f546b1 |
GstRegistryChunkDynamicTypeFactory *tmp;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
tmp = g_slice_new0 (GstRegistryChunkDynamicTypeFactory);
|
|
Packit |
f546b1 |
chk =
|
|
Packit |
f546b1 |
gst_registry_chunks_make_data (tmp,
|
|
Packit |
f546b1 |
sizeof (GstRegistryChunkDynamicTypeFactory));
|
|
Packit |
f546b1 |
pf = (GstRegistryChunkPluginFeature *) tmp;
|
|
Packit |
f546b1 |
} else {
|
|
Packit |
f546b1 |
GST_WARNING_OBJECT (feature, "unhandled feature type '%s'", type_name);
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
if (pf) {
|
|
Packit |
f546b1 |
pf->rank = feature->rank;
|
|
Packit |
f546b1 |
*list = g_list_prepend (*list, chk);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* pack plugin feature strings */
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list, GST_OBJECT_NAME (feature));
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list, (gchar *) type_name);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
return TRUE;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* Errors */
|
|
Packit |
f546b1 |
fail:
|
|
Packit |
f546b1 |
g_slice_free (GstRegistryChunk, chk);
|
|
Packit |
f546b1 |
g_slice_free1 (pf_size, pf);
|
|
Packit |
f546b1 |
return FALSE;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
static gboolean
|
|
Packit |
f546b1 |
gst_registry_chunks_save_plugin_dep (GList ** list, GstPluginDep * dep)
|
|
Packit |
f546b1 |
{
|
|
Packit |
f546b1 |
GstRegistryChunkDep *ed;
|
|
Packit |
f546b1 |
GstRegistryChunk *chk;
|
|
Packit |
f546b1 |
gchar **s;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
ed = g_slice_new (GstRegistryChunkDep);
|
|
Packit |
f546b1 |
chk = gst_registry_chunks_make_data (ed, sizeof (GstRegistryChunkDep));
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
ed->flags = dep->flags;
|
|
Packit |
f546b1 |
ed->n_env_vars = 0;
|
|
Packit |
f546b1 |
ed->n_paths = 0;
|
|
Packit |
f546b1 |
ed->n_names = 0;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
ed->env_hash = dep->env_hash;
|
|
Packit |
f546b1 |
ed->stat_hash = dep->stat_hash;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
for (s = dep->env_vars; s != NULL && *s != NULL; ++s, ++ed->n_env_vars)
|
|
Packit |
f546b1 |
gst_registry_chunks_save_string (list, g_strdup (*s));
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
for (s = dep->paths; s != NULL && *s != NULL; ++s, ++ed->n_paths)
|
|
Packit |
f546b1 |
gst_registry_chunks_save_string (list, g_strdup (*s));
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
for (s = dep->names; s != NULL && *s != NULL; ++s, ++ed->n_names)
|
|
Packit |
f546b1 |
gst_registry_chunks_save_string (list, g_strdup (*s));
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
*list = g_list_prepend (*list, chk);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
GST_LOG ("Saved external plugin dependency");
|
|
Packit |
f546b1 |
return TRUE;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/*
|
|
Packit |
f546b1 |
* _priv_gst_registry_chunks_save_plugin:
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* Adapt a GstPlugin to our GstRegistryChunkPluginElement structure, and
|
|
Packit |
f546b1 |
* prepend it as a GstRegistryChunk in the provided list.
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
*/
|
|
Packit |
f546b1 |
gboolean
|
|
Packit |
f546b1 |
_priv_gst_registry_chunks_save_plugin (GList ** list, GstRegistry * registry,
|
|
Packit |
f546b1 |
GstPlugin * plugin)
|
|
Packit |
f546b1 |
{
|
|
Packit |
f546b1 |
GstRegistryChunkPluginElement *pe;
|
|
Packit |
f546b1 |
GstRegistryChunk *chk;
|
|
Packit |
f546b1 |
GList *plugin_features = NULL;
|
|
Packit |
f546b1 |
GList *walk;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
pe = g_slice_new (GstRegistryChunkPluginElement);
|
|
Packit |
f546b1 |
chk =
|
|
Packit |
f546b1 |
gst_registry_chunks_make_data (pe,
|
|
Packit |
f546b1 |
sizeof (GstRegistryChunkPluginElement));
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
pe->file_size = plugin->file_size;
|
|
Packit |
f546b1 |
pe->file_mtime = plugin->file_mtime;
|
|
Packit |
f546b1 |
pe->nfeatures = 0;
|
|
Packit |
f546b1 |
pe->n_deps = 0;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* pack external deps */
|
|
Packit |
f546b1 |
for (walk = plugin->priv->deps; walk != NULL; walk = walk->next) {
|
|
Packit |
f546b1 |
if (!gst_registry_chunks_save_plugin_dep (list, walk->data)) {
|
|
Packit |
f546b1 |
GST_ERROR ("Could not save external plugin dependency, aborting.");
|
|
Packit |
f546b1 |
goto fail;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
++pe->n_deps;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* pack plugin features */
|
|
Packit |
f546b1 |
plugin_features =
|
|
Packit |
f546b1 |
gst_registry_get_feature_list_by_plugin (registry, plugin->desc.name);
|
|
Packit |
f546b1 |
for (walk = plugin_features; walk; walk = g_list_next (walk), pe->nfeatures++) {
|
|
Packit |
f546b1 |
GstPluginFeature *feature = GST_PLUGIN_FEATURE (walk->data);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
if (!gst_registry_chunks_save_feature (list, feature)) {
|
|
Packit |
f546b1 |
GST_ERROR ("Can't fill plugin feature, aborting.");
|
|
Packit |
f546b1 |
goto fail;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
gst_plugin_feature_list_free (plugin_features);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* pack cache data */
|
|
Packit |
f546b1 |
if (plugin->priv->cache_data) {
|
|
Packit |
f546b1 |
gchar *cache_str = gst_structure_to_string (plugin->priv->cache_data);
|
|
Packit |
f546b1 |
gst_registry_chunks_save_string (list, cache_str);
|
|
Packit |
f546b1 |
} else {
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list, "");
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* pack plugin element strings */
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list,
|
|
Packit |
f546b1 |
(plugin->desc.release_datetime) ? plugin->desc.release_datetime : "");
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list, plugin->desc.origin);
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list, plugin->desc.package);
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list, plugin->desc.source);
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list, plugin->desc.license);
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list, plugin->desc.version);
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list, plugin->filename);
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list, plugin->desc.description);
|
|
Packit |
f546b1 |
gst_registry_chunks_save_const_string (list, plugin->desc.name);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
*list = g_list_prepend (*list, chk);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
GST_DEBUG ("Found %d features in plugin \"%s\"", pe->nfeatures,
|
|
Packit |
f546b1 |
plugin->desc.name);
|
|
Packit |
f546b1 |
return TRUE;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* Errors */
|
|
Packit |
f546b1 |
fail:
|
|
Packit |
f546b1 |
gst_plugin_feature_list_free (plugin_features);
|
|
Packit |
f546b1 |
g_slice_free (GstRegistryChunk, chk);
|
|
Packit |
f546b1 |
g_slice_free (GstRegistryChunkPluginElement, pe);
|
|
Packit |
f546b1 |
return FALSE;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/*
|
|
Packit |
f546b1 |
* gst_registry_chunks_load_pad_template:
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* Make a new GstStaticPadTemplate from current GstRegistryChunkPadTemplate
|
|
Packit |
f546b1 |
* structure.
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* Returns: new GstStaticPadTemplate
|
|
Packit |
f546b1 |
*/
|
|
Packit |
f546b1 |
static gboolean
|
|
Packit |
f546b1 |
gst_registry_chunks_load_pad_template (GstElementFactory * factory, gchar ** in,
|
|
Packit |
f546b1 |
gchar * end)
|
|
Packit |
f546b1 |
{
|
|
Packit |
f546b1 |
GstRegistryChunkPadTemplate *pt;
|
|
Packit |
f546b1 |
GstStaticPadTemplate *template = NULL;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
align (*in);
|
|
Packit |
f546b1 |
GST_DEBUG ("Reading/casting for GstRegistryChunkPadTemplate at address %p",
|
|
Packit |
f546b1 |
*in);
|
|
Packit |
f546b1 |
unpack_element (*in, pt, GstRegistryChunkPadTemplate, end, fail);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
template = g_slice_new (GstStaticPadTemplate);
|
|
Packit |
f546b1 |
template->presence = pt->presence;
|
|
Packit |
f546b1 |
template->direction = (GstPadDirection) pt->direction;
|
|
Packit |
f546b1 |
template->static_caps.caps = NULL;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* unpack pad template strings */
|
|
Packit |
f546b1 |
unpack_const_string (*in, template->name_template, end, fail);
|
|
Packit |
f546b1 |
unpack_const_string (*in, template->static_caps.string, end, fail);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
__gst_element_factory_add_static_pad_template (factory, template);
|
|
Packit |
f546b1 |
GST_DEBUG ("Added pad_template %s", template->name_template);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
return TRUE;
|
|
Packit |
f546b1 |
fail:
|
|
Packit |
f546b1 |
GST_INFO ("Reading pad template failed");
|
|
Packit |
f546b1 |
if (template)
|
|
Packit |
f546b1 |
g_slice_free (GstStaticPadTemplate, template);
|
|
Packit |
f546b1 |
return FALSE;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/*
|
|
Packit |
f546b1 |
* gst_registry_chunks_load_feature:
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* Make a new GstPluginFeature from current binary plugin feature structure
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* Returns: new GstPluginFeature
|
|
Packit |
f546b1 |
*/
|
|
Packit |
f546b1 |
static gboolean
|
|
Packit |
f546b1 |
gst_registry_chunks_load_feature (GstRegistry * registry, gchar ** in,
|
|
Packit |
f546b1 |
gchar * end, GstPlugin * plugin)
|
|
Packit |
f546b1 |
{
|
|
Packit |
f546b1 |
GstRegistryChunkPluginFeature *pf = NULL;
|
|
Packit |
f546b1 |
GstPluginFeature *feature = NULL;
|
|
Packit |
f546b1 |
const gchar *const_str, *type_name;
|
|
Packit |
f546b1 |
const gchar *feature_name;
|
|
Packit |
f546b1 |
const gchar *plugin_name;
|
|
Packit |
f546b1 |
gchar *str;
|
|
Packit |
f546b1 |
GType type;
|
|
Packit |
f546b1 |
guint i;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
plugin_name = plugin->desc.name;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* unpack plugin feature strings */
|
|
Packit |
f546b1 |
unpack_string_nocopy (*in, type_name, end, fail);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
if (G_UNLIKELY (!type_name)) {
|
|
Packit |
f546b1 |
GST_ERROR ("No feature type name");
|
|
Packit |
f546b1 |
return FALSE;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* unpack more plugin feature strings */
|
|
Packit |
f546b1 |
unpack_string_nocopy (*in, feature_name, end, fail);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
GST_DEBUG ("Plugin '%s' feature '%s' typename : '%s'", plugin_name,
|
|
Packit |
f546b1 |
feature_name, type_name);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
if (G_UNLIKELY (!(type = g_type_from_name (type_name)))) {
|
|
Packit |
f546b1 |
GST_ERROR ("Unknown type from typename '%s' for plugin '%s'", type_name,
|
|
Packit |
f546b1 |
plugin_name);
|
|
Packit |
f546b1 |
return FALSE;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
if (G_UNLIKELY ((feature = g_object_new (type, NULL)) == NULL)) {
|
|
Packit |
f546b1 |
GST_ERROR ("Can't create feature from type");
|
|
Packit |
f546b1 |
return FALSE;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
gst_plugin_feature_set_name (feature, feature_name);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
if (G_UNLIKELY (!GST_IS_PLUGIN_FEATURE (feature))) {
|
|
Packit |
f546b1 |
GST_ERROR ("typename : '%s' is not a plugin feature", type_name);
|
|
Packit |
f546b1 |
goto fail;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
if (GST_IS_ELEMENT_FACTORY (feature)) {
|
|
Packit |
f546b1 |
GstRegistryChunkElementFactory *ef;
|
|
Packit |
f546b1 |
guint n;
|
|
Packit |
f546b1 |
GstElementFactory *factory = GST_ELEMENT_FACTORY_CAST (feature);
|
|
Packit |
f546b1 |
gchar *str;
|
|
Packit |
f546b1 |
const gchar *meta_data_str;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
align (*in);
|
|
Packit |
f546b1 |
GST_LOG ("Reading/casting for GstRegistryChunkElementFactory at address %p",
|
|
Packit |
f546b1 |
*in);
|
|
Packit |
f546b1 |
unpack_element (*in, ef, GstRegistryChunkElementFactory, end, fail);
|
|
Packit |
f546b1 |
pf = (GstRegistryChunkPluginFeature *) ef;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* unpack element factory strings */
|
|
Packit |
f546b1 |
unpack_string_nocopy (*in, meta_data_str, end, fail);
|
|
Packit |
f546b1 |
if (meta_data_str && *meta_data_str) {
|
|
Packit |
f546b1 |
factory->metadata = gst_structure_from_string (meta_data_str, NULL);
|
|
Packit |
f546b1 |
if (!factory->metadata) {
|
|
Packit |
f546b1 |
GST_ERROR
|
|
Packit |
f546b1 |
("Error when trying to deserialize structure for metadata '%s'",
|
|
Packit |
f546b1 |
meta_data_str);
|
|
Packit |
f546b1 |
goto fail;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
n = ef->npadtemplates;
|
|
Packit |
f546b1 |
GST_DEBUG ("Element factory : npadtemplates=%d", n);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* load pad templates */
|
|
Packit |
f546b1 |
for (i = 0; i < n; i++) {
|
|
Packit |
f546b1 |
if (G_UNLIKELY (!gst_registry_chunks_load_pad_template (factory, in,
|
|
Packit |
f546b1 |
end))) {
|
|
Packit |
f546b1 |
GST_ERROR ("Error while loading binary pad template");
|
|
Packit |
f546b1 |
goto fail;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* load uritypes */
|
|
Packit |
f546b1 |
if (G_UNLIKELY ((n = ef->nuriprotocols))) {
|
|
Packit |
f546b1 |
GST_DEBUG ("Reading %d UriTypes at address %p", n, *in);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
align (*in);
|
|
Packit |
f546b1 |
factory->uri_type = *((guint *) * in);
|
|
Packit |
f546b1 |
*in += sizeof (factory->uri_type);
|
|
Packit |
f546b1 |
/*unpack_element(*in, &factory->uri_type, factory->uri_type, end, fail); */
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
factory->uri_protocols = g_new0 (gchar *, n + 1);
|
|
Packit |
f546b1 |
for (i = 0; i < n; i++) {
|
|
Packit |
f546b1 |
unpack_string (*in, str, end, fail);
|
|
Packit |
f546b1 |
factory->uri_protocols[i] = str;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
/* load interfaces */
|
|
Packit |
f546b1 |
if (G_UNLIKELY ((n = ef->ninterfaces))) {
|
|
Packit |
f546b1 |
GST_DEBUG ("Reading %d Interfaces at address %p", n, *in);
|
|
Packit |
f546b1 |
for (i = 0; i < n; i++) {
|
|
Packit |
f546b1 |
unpack_string_nocopy (*in, const_str, end, fail);
|
|
Packit |
f546b1 |
__gst_element_factory_add_interface (factory, const_str);
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
} else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
|
|
Packit |
f546b1 |
GstRegistryChunkTypeFindFactory *tff;
|
|
Packit |
f546b1 |
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
align (*in);
|
|
Packit |
f546b1 |
GST_DEBUG
|
|
Packit |
f546b1 |
("Reading/casting for GstRegistryChunkPluginFeature at address %p",
|
|
Packit |
f546b1 |
*in);
|
|
Packit |
f546b1 |
unpack_element (*in, tff, GstRegistryChunkTypeFindFactory, end, fail);
|
|
Packit |
f546b1 |
pf = (GstRegistryChunkPluginFeature *) tff;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* load typefinder caps */
|
|
Packit |
f546b1 |
unpack_string_nocopy (*in, const_str, end, fail);
|
|
Packit |
f546b1 |
if (const_str != NULL && *const_str != '\0')
|
|
Packit |
f546b1 |
factory->caps = gst_caps_from_string (const_str);
|
|
Packit |
f546b1 |
else
|
|
Packit |
f546b1 |
factory->caps = NULL;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* load extensions */
|
|
Packit |
f546b1 |
if (tff->nextensions) {
|
|
Packit |
f546b1 |
GST_DEBUG ("Reading %d Typefind extensions at address %p",
|
|
Packit |
f546b1 |
tff->nextensions, *in);
|
|
Packit |
f546b1 |
factory->extensions = g_new0 (gchar *, tff->nextensions + 1);
|
|
Packit |
f546b1 |
/* unpack in reverse order to maintain the correct order */
|
|
Packit |
f546b1 |
for (i = tff->nextensions; i > 0; i--) {
|
|
Packit |
f546b1 |
unpack_string (*in, str, end, fail);
|
|
Packit |
f546b1 |
factory->extensions[i - 1] = str;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
} else if (GST_IS_DEVICE_PROVIDER_FACTORY (feature)) {
|
|
Packit |
f546b1 |
GstRegistryChunkDeviceProviderFactory *dmf;
|
|
Packit |
f546b1 |
GstDeviceProviderFactory *factory = GST_DEVICE_PROVIDER_FACTORY (feature);
|
|
Packit |
f546b1 |
const gchar *meta_data_str;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
align (*in);
|
|
Packit |
f546b1 |
GST_DEBUG
|
|
Packit |
f546b1 |
("Reading/casting for GstRegistryChunkPluginFeature at address %p",
|
|
Packit |
f546b1 |
*in);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
unpack_element (*in, dmf, GstRegistryChunkDeviceProviderFactory, end, fail);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
pf = (GstRegistryChunkPluginFeature *) dmf;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* unpack element factory strings */
|
|
Packit |
f546b1 |
unpack_string_nocopy (*in, meta_data_str, end, fail);
|
|
Packit |
f546b1 |
if (meta_data_str && *meta_data_str) {
|
|
Packit |
f546b1 |
factory->metadata = gst_structure_from_string (meta_data_str, NULL);
|
|
Packit |
f546b1 |
if (!factory->metadata) {
|
|
Packit |
f546b1 |
GST_ERROR
|
|
Packit |
f546b1 |
("Error when trying to deserialize structure for metadata '%s'",
|
|
Packit |
f546b1 |
meta_data_str);
|
|
Packit |
f546b1 |
goto fail;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
} else if (GST_IS_TRACER_FACTORY (feature)) {
|
|
Packit |
f546b1 |
align (*in);
|
|
Packit |
f546b1 |
GST_DEBUG
|
|
Packit |
f546b1 |
("Reading/casting for GstRegistryChunkPluginFeature at address %p",
|
|
Packit |
f546b1 |
*in);
|
|
Packit |
f546b1 |
unpack_element (*in, pf, GstRegistryChunkPluginFeature, end, fail);
|
|
Packit |
f546b1 |
} else if (GST_IS_DYNAMIC_TYPE_FACTORY (feature)) {
|
|
Packit |
f546b1 |
GstRegistryChunkDynamicTypeFactory *tmp;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
align (*in);
|
|
Packit |
f546b1 |
unpack_element (*in, tmp, GstRegistryChunkDynamicTypeFactory, end, fail);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
pf = (GstRegistryChunkPluginFeature *) tmp;
|
|
Packit |
f546b1 |
} else {
|
|
Packit |
f546b1 |
GST_WARNING ("unhandled factory type : %s", G_OBJECT_TYPE_NAME (feature));
|
|
Packit |
f546b1 |
goto fail;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
feature->rank = pf->rank;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
feature->plugin_name = plugin_name;
|
|
Packit |
f546b1 |
feature->plugin = plugin;
|
|
Packit |
f546b1 |
g_object_add_weak_pointer ((GObject *) plugin,
|
|
Packit |
f546b1 |
(gpointer *) & feature->plugin);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
gst_registry_add_feature (registry, feature);
|
|
Packit |
f546b1 |
GST_DEBUG ("Added feature %s, plugin %p %s", GST_OBJECT_NAME (feature),
|
|
Packit |
f546b1 |
plugin, plugin_name);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
return TRUE;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* Errors */
|
|
Packit |
f546b1 |
fail:
|
|
Packit |
f546b1 |
GST_INFO ("Reading plugin feature failed");
|
|
Packit |
f546b1 |
if (feature) {
|
|
Packit |
f546b1 |
if (GST_IS_OBJECT (feature))
|
|
Packit |
f546b1 |
gst_object_unref (feature);
|
|
Packit |
f546b1 |
else
|
|
Packit |
f546b1 |
g_object_unref (feature);
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
return FALSE;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
static gchar **
|
|
Packit |
f546b1 |
gst_registry_chunks_load_plugin_dep_strv (gchar ** in, gchar * end, guint n)
|
|
Packit |
f546b1 |
{
|
|
Packit |
f546b1 |
gchar **arr;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
if (n == 0)
|
|
Packit |
f546b1 |
return NULL;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
arr = g_new0 (gchar *, n + 1);
|
|
Packit |
f546b1 |
while (n > 0) {
|
|
Packit |
f546b1 |
unpack_string (*in, arr[n - 1], end, fail);
|
|
Packit |
f546b1 |
--n;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
return arr;
|
|
Packit |
f546b1 |
fail:
|
|
Packit |
f546b1 |
GST_INFO ("Reading plugin dependency strings failed");
|
|
Packit |
f546b1 |
g_strfreev (arr);
|
|
Packit |
f546b1 |
return NULL;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
static gboolean
|
|
Packit |
f546b1 |
gst_registry_chunks_load_plugin_dep (GstPlugin * plugin, gchar ** in,
|
|
Packit |
f546b1 |
gchar * end)
|
|
Packit |
f546b1 |
{
|
|
Packit |
f546b1 |
GstPluginDep *dep;
|
|
Packit |
f546b1 |
GstRegistryChunkDep *d;
|
|
Packit |
f546b1 |
gchar **s;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
align (*in);
|
|
Packit |
f546b1 |
GST_LOG_OBJECT (plugin, "Unpacking GstRegistryChunkDep from %p", *in);
|
|
Packit |
f546b1 |
unpack_element (*in, d, GstRegistryChunkDep, end, fail);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
dep = g_slice_new (GstPluginDep);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
dep->env_hash = d->env_hash;
|
|
Packit |
f546b1 |
dep->stat_hash = d->stat_hash;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
dep->flags = (GstPluginDependencyFlags) d->flags;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
dep->names = gst_registry_chunks_load_plugin_dep_strv (in, end, d->n_names);
|
|
Packit |
f546b1 |
dep->paths = gst_registry_chunks_load_plugin_dep_strv (in, end, d->n_paths);
|
|
Packit |
f546b1 |
dep->env_vars =
|
|
Packit |
f546b1 |
gst_registry_chunks_load_plugin_dep_strv (in, end, d->n_env_vars);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
plugin->priv->deps = g_list_append (plugin->priv->deps, dep);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
GST_DEBUG_OBJECT (plugin, "Loaded external plugin dependency from registry: "
|
|
Packit |
f546b1 |
"env_hash: %08x, stat_hash: %08x", dep->env_hash, dep->stat_hash);
|
|
Packit |
f546b1 |
for (s = dep->env_vars; s != NULL && *s != NULL; ++s)
|
|
Packit |
f546b1 |
GST_LOG_OBJECT (plugin, " evar: %s", *s);
|
|
Packit |
f546b1 |
for (s = dep->paths; s != NULL && *s != NULL; ++s)
|
|
Packit |
f546b1 |
GST_LOG_OBJECT (plugin, " path: %s", *s);
|
|
Packit |
f546b1 |
for (s = dep->names; s != NULL && *s != NULL; ++s)
|
|
Packit |
f546b1 |
GST_LOG_OBJECT (plugin, " name: %s", *s);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
return TRUE;
|
|
Packit |
f546b1 |
fail:
|
|
Packit |
f546b1 |
GST_INFO ("Reading plugin dependency failed");
|
|
Packit |
f546b1 |
return FALSE;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/*
|
|
Packit |
f546b1 |
* _priv_gst_registry_chunks_load_plugin:
|
|
Packit |
f546b1 |
*
|
|
Packit |
f546b1 |
* Make a new GstPlugin from current GstRegistryChunkPluginElement structure
|
|
Packit |
f546b1 |
* and add it to the GstRegistry. Return an offset to the next
|
|
Packit |
f546b1 |
* GstRegistryChunkPluginElement structure.
|
|
Packit |
f546b1 |
*/
|
|
Packit |
f546b1 |
gboolean
|
|
Packit |
f546b1 |
_priv_gst_registry_chunks_load_plugin (GstRegistry * registry, gchar ** in,
|
|
Packit |
f546b1 |
gchar * end, GstPlugin ** out_plugin)
|
|
Packit |
f546b1 |
{
|
|
Packit |
f546b1 |
#ifndef GST_DISABLE_GST_DEBUG
|
|
Packit |
f546b1 |
gchar *start = *in;
|
|
Packit |
f546b1 |
#endif
|
|
Packit |
f546b1 |
GstRegistryChunkPluginElement *pe;
|
|
Packit |
f546b1 |
const gchar *cache_str = NULL;
|
|
Packit |
f546b1 |
GstPlugin *plugin = NULL;
|
|
Packit |
f546b1 |
guint i, n;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
align (*in);
|
|
Packit |
f546b1 |
GST_LOG ("Reading/casting for GstRegistryChunkPluginElement at address %p",
|
|
Packit |
f546b1 |
*in);
|
|
Packit |
f546b1 |
unpack_element (*in, pe, GstRegistryChunkPluginElement, end, fail);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* TODO: also set GST_PLUGIN_FLAG_CONST */
|
|
Packit |
f546b1 |
GST_OBJECT_FLAG_SET (plugin, GST_PLUGIN_FLAG_CACHED);
|
|
Packit |
f546b1 |
plugin->file_mtime = pe->file_mtime;
|
|
Packit |
f546b1 |
plugin->file_size = pe->file_size;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* unpack plugin element strings */
|
|
Packit |
f546b1 |
unpack_const_string (*in, plugin->desc.name, end, fail);
|
|
Packit |
f546b1 |
unpack_const_string (*in, plugin->desc.description, end, fail);
|
|
Packit |
f546b1 |
unpack_string (*in, plugin->filename, end, fail);
|
|
Packit |
f546b1 |
unpack_const_string (*in, plugin->desc.version, end, fail);
|
|
Packit |
f546b1 |
unpack_const_string (*in, plugin->desc.license, end, fail);
|
|
Packit |
f546b1 |
unpack_const_string (*in, plugin->desc.source, end, fail);
|
|
Packit |
f546b1 |
unpack_const_string (*in, plugin->desc.package, end, fail);
|
|
Packit |
f546b1 |
unpack_const_string (*in, plugin->desc.origin, end, fail);
|
|
Packit |
f546b1 |
unpack_const_string (*in, plugin->desc.release_datetime, end, fail);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
GST_LOG ("read strings for name='%s'", plugin->desc.name);
|
|
Packit |
f546b1 |
GST_LOG (" desc.description='%s'", plugin->desc.description);
|
|
Packit |
f546b1 |
GST_LOG (" filename='%s'", plugin->filename);
|
|
Packit |
f546b1 |
GST_LOG (" desc.version='%s'", plugin->desc.version);
|
|
Packit |
f546b1 |
GST_LOG (" desc.license='%s'", plugin->desc.license);
|
|
Packit |
f546b1 |
GST_LOG (" desc.source='%s'", plugin->desc.source);
|
|
Packit |
f546b1 |
GST_LOG (" desc.package='%s'", plugin->desc.package);
|
|
Packit |
f546b1 |
GST_LOG (" desc.origin='%s'", plugin->desc.origin);
|
|
Packit |
f546b1 |
GST_LOG (" desc.datetime=%s", plugin->desc.release_datetime);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
if (plugin->desc.release_datetime[0] == '\0')
|
|
Packit |
f546b1 |
plugin->desc.release_datetime = NULL;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* unpack cache data */
|
|
Packit |
f546b1 |
unpack_string_nocopy (*in, cache_str, end, fail);
|
|
Packit |
f546b1 |
if (cache_str != NULL && *cache_str != '\0')
|
|
Packit |
f546b1 |
plugin->priv->cache_data = gst_structure_from_string (cache_str, NULL);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* If the license string is 'BLACKLIST', mark this as a blacklisted
|
|
Packit |
f546b1 |
* plugin */
|
|
Packit |
f546b1 |
if (strcmp (plugin->desc.license, "BLACKLIST") == 0)
|
|
Packit |
f546b1 |
GST_OBJECT_FLAG_SET (plugin, GST_PLUGIN_FLAG_BLACKLISTED);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
plugin->basename = g_path_get_basename (plugin->filename);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* Takes ownership of plugin */
|
|
Packit |
f546b1 |
gst_registry_add_plugin (registry, plugin);
|
|
Packit |
f546b1 |
n = pe->nfeatures;
|
|
Packit |
f546b1 |
GST_DEBUG ("Added plugin '%s' plugin with %d features from binary registry",
|
|
Packit |
f546b1 |
plugin->desc.name, n);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* Load plugin features */
|
|
Packit |
f546b1 |
for (i = 0; i < n; i++) {
|
|
Packit |
f546b1 |
if (G_UNLIKELY (!gst_registry_chunks_load_feature (registry, in, end,
|
|
Packit |
f546b1 |
plugin))) {
|
|
Packit |
f546b1 |
GST_ERROR ("Error while loading binary feature for plugin '%s'",
|
|
Packit |
f546b1 |
GST_STR_NULL (plugin->desc.name));
|
|
Packit |
f546b1 |
gst_registry_remove_plugin (registry, plugin);
|
|
Packit |
f546b1 |
goto fail;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* Load external plugin dependencies */
|
|
Packit |
f546b1 |
for (i = 0; i < pe->n_deps; ++i) {
|
|
Packit |
f546b1 |
if (G_UNLIKELY (!gst_registry_chunks_load_plugin_dep (plugin, in, end))) {
|
|
Packit |
f546b1 |
GST_ERROR_OBJECT (plugin, "Could not read external plugin dependency "
|
|
Packit |
f546b1 |
"for plugin '%s'", GST_STR_NULL (plugin->desc.name));
|
|
Packit |
f546b1 |
gst_registry_remove_plugin (registry, plugin);
|
|
Packit |
f546b1 |
goto fail;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
if (out_plugin)
|
|
Packit |
f546b1 |
*out_plugin = plugin;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
return TRUE;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* Errors */
|
|
Packit |
f546b1 |
fail:
|
|
Packit |
f546b1 |
GST_INFO ("Reading plugin failed after %u bytes", (guint) (end - start));
|
|
Packit |
f546b1 |
return FALSE;
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
void
|
|
Packit |
f546b1 |
_priv_gst_registry_chunks_save_global_header (GList ** list,
|
|
Packit |
f546b1 |
GstRegistry * registry, guint32 filter_env_hash)
|
|
Packit |
f546b1 |
{
|
|
Packit |
f546b1 |
GstRegistryChunkGlobalHeader *hdr;
|
|
Packit |
f546b1 |
GstRegistryChunk *chk;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
hdr = g_slice_new (GstRegistryChunkGlobalHeader);
|
|
Packit |
f546b1 |
chk = gst_registry_chunks_make_data (hdr,
|
|
Packit |
f546b1 |
sizeof (GstRegistryChunkGlobalHeader));
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
hdr->filter_env_hash = filter_env_hash;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
*list = g_list_prepend (*list, chk);
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
GST_LOG ("Saved global header (filter_env_hash=0x%08x)", filter_env_hash);
|
|
Packit |
f546b1 |
}
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
gboolean
|
|
Packit |
f546b1 |
_priv_gst_registry_chunks_load_global_header (GstRegistry * registry,
|
|
Packit |
f546b1 |
gchar ** in, gchar * end, guint32 * filter_env_hash)
|
|
Packit |
f546b1 |
{
|
|
Packit |
f546b1 |
GstRegistryChunkGlobalHeader *hdr;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
align (*in);
|
|
Packit |
f546b1 |
GST_LOG ("Reading/casting for GstRegistryChunkGlobalHeader at %p", *in);
|
|
Packit |
f546b1 |
unpack_element (*in, hdr, GstRegistryChunkGlobalHeader, end, fail);
|
|
Packit |
f546b1 |
*filter_env_hash = hdr->filter_env_hash;
|
|
Packit |
f546b1 |
return TRUE;
|
|
Packit |
f546b1 |
|
|
Packit |
f546b1 |
/* Errors */
|
|
Packit |
f546b1 |
fail:
|
|
Packit |
f546b1 |
GST_WARNING ("Reading global header failed");
|
|
Packit |
f546b1 |
return FALSE;
|
|
Packit |
f546b1 |
}
|