From: <en...@ke...> - 2007-01-15 12:19:11
|
CVS Root: /cvs/gstreamer Module: gstreamer Changes by: ensonic Date: Mon Jan 15 2007 12:18:58 UTC Log message: * gst/gstregistrybinary.c: (gst_registry_binary_write), (gst_registry_binary_initialize_magic), (gst_registry_binary_save_string), (gst_registry_binary_make_data), (gst_registry_binary_save_pad_template), (gst_registry_binary_save_feature), (gst_registry_binary_save_plugin), (gst_registry_binary_write_cache), (gst_registry_binary_check_magic), (gst_registry_binary_load_pad_template), (gst_registry_binary_load_feature), (gst_registry_binary_load_plugin), (gst_registry_binary_read_cache): * gst/gstregistrybinary.h: use glib types, cleanup comments, impement interfaces and uri-types Modified files: . : ChangeLog gst : gstregistrybinary.c gstregistrybinary.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/ChangeLog.diff?r1=1.3010&r2=1.3011 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstregistrybinary.c.diff?r1=1.1&r2=1.2 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstregistrybinary.h.diff?r1=1.1&r2=1.2 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gstreamer/ChangeLog,v retrieving revision 1.3010 retrieving revision 1.3011 diff -u -d -r1.3010 -r1.3011 --- ChangeLog 13 Jan 2007 10:33:41 -0000 1.3010 +++ ChangeLog 15 Jan 2007 12:18:46 -0000 1.3011 @@ -1,3 +1,20 @@ +2007-01-15 Stefan Kost <en...@us...> + + * gst/gstregistrybinary.c: (gst_registry_binary_write), + (gst_registry_binary_initialize_magic), + (gst_registry_binary_save_string), (gst_registry_binary_make_data), + (gst_registry_binary_save_pad_template), + (gst_registry_binary_save_feature), + (gst_registry_binary_save_plugin), + (gst_registry_binary_write_cache), + (gst_registry_binary_check_magic), + (gst_registry_binary_load_pad_template), + (gst_registry_binary_load_feature), + (gst_registry_binary_load_plugin), + (gst_registry_binary_read_cache): + * gst/gstregistrybinary.h: + use glib types, cleanup comments, impement interfaces and uri-types 2007-01-13 Andy Wingo <wi...@po...> * gst/gstpad.c (gst_pad_get_range, gst_pad_pull_range): Allow Index: gstregistrybinary.c RCS file: /cvs/gstreamer/gstreamer/gst/gstregistrybinary.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- gstregistrybinary.c 11 Jan 2007 13:45:51 -0000 1.1 +++ gstregistrybinary.c 15 Jan 2007 12:18:46 -0000 1.2 @@ -23,11 +23,13 @@ /* FIXME: * - Add random key to libgstreamer during build and only accept registry, - * if key matches + * if key matches (or is the version check enough) * - handle cases where we can't mmap * - keep registry binary blob and reference strings * (need const flags in GstPlugin, etc.) * - why do we collect a list of binary chunks and not write immediately + * - because we need to process subchunks, before we can set e.g. nr_of_items + * in parnt chunk * - need more robustness * - don't parse beyond mem-block size * - include md5-sum ? @@ -131,6 +133,26 @@ } /* + * gst_registry_binary_save_data: + * + * Store some data in a binary chunk. + * Returns: the initialized chunk + */ +inline static GstBinaryChunk * +gst_registry_binary_make_data (gpointer data, gulong size) +{ + GstBinaryChunk *chunk; + chunk = g_malloc (sizeof (GstBinaryChunk)); + chunk->data = data; + chunk->size = size; + chunk->flags = GST_BINARY_REGISTRY_FLAG_NONE; + chunk->align = TRUE; + return chunk; +} +/* * gst_registry_binary_save_pad_template: * * Store pad_templates in binary chunks. @@ -145,12 +167,7 @@ GstBinaryChunk *chk; pt = g_malloc (sizeof (GstBinaryPadTemplate)); - chk = g_malloc (sizeof (GstBinaryChunk)); - - chk->data = pt; - chk->size = sizeof (GstBinaryPadTemplate); - chk->flags = GST_BINARY_REGISTRY_FLAG_NONE; - chk->align = TRUE; + chk = gst_registry_binary_make_data (pt, sizeof (GstBinaryPadTemplate)); pt->presence = template->presence; pt->direction = template->direction; @@ -186,19 +203,44 @@ } pf = g_malloc (sizeof (GstBinaryPluginFeature)); - chk->data = pf; - chk->size = sizeof (GstBinaryPluginFeature); + chk = gst_registry_binary_make_data (pf, sizeof (GstBinaryPluginFeature)); pf->rank = feature->rank; - pf->npadtemplates = pf->ninterfaces = pf->nuritypes = 0; + pf->npadtemplates = pf->ninterfaces = pf->nuriprotocols = 0; if (GST_IS_ELEMENT_FACTORY (feature)) { GstElementFactory *factory = GST_ELEMENT_FACTORY (feature); + /* save interfaces */ + for (walk = factory->interfaces; walk; + walk = g_list_next (walk), pf->ninterfaces++) { + gst_registry_binary_save_string (list, (gchar *) walk->data); + } + GST_DEBUG ("Saved %d Interfaces", pf->ninterfaces); + /* save uritypes */ + if (GST_URI_TYPE_IS_VALID (factory->uri_type)) { + if (factory->uri_protocols) { + GstBinaryChunk *subchk; + gchar **protocol; + subchk = + gst_registry_binary_make_data (&factory->uri_type, + sizeof (factory->uri_type)); + subchk->flags = GST_BINARY_REGISTRY_FLAG_CONST; + protocol = factory->uri_protocols; + while (*protocol) { + gst_registry_binary_save_string (list, *protocol++); + pf->nuriprotocols++; + } + *list = g_list_prepend (*list, subchk); + GST_DEBUG ("Saved %d UriTypes", pf->nuriprotocols); + } else { + g_warning ("GStreamer feature '%s' is URI handler but does not provide" + " any protocols it can handle", feature->name); + } /* save pad-templates */ for (walk = factory->staticpadtemplates; walk; walk = g_list_next (walk), pf->npadtemplates++) { @@ -215,15 +257,20 @@ gst_registry_binary_save_string (list, factory->details.description); gst_registry_binary_save_string (list, factory->details.klass); gst_registry_binary_save_string (list, factory->details.longname); + } else if (GST_IS_TYPE_FIND_FACTORY (feature)) { + /* FIXME: save typefind */ +#ifndef GST_DISABLE_INDEX + else if (GST_IS_INDEX_FACTORY (feature)) { + /* FIXME: save indexers */ + } +#endif /* pack plugin feature strings */ gst_registry_binary_save_string (list, feature->name); gst_registry_binary_save_string (list, (gchar *) type_name); *list = g_list_prepend (*list, chk); - /* FIXME: save interfaces and uritypes */ return TRUE; /* Errors */ @@ -249,12 +296,7 @@ GList *walk; pe = g_malloc (sizeof (GstBinaryPluginElement)); - chk->data = pe; - chk->size = sizeof (GstBinaryPluginElement); + chk = gst_registry_binary_make_data (pe, sizeof (GstBinaryPluginElement)); pe->file_size = plugin->file_size; pe->file_mtime = plugin->file_mtime; @@ -502,7 +544,7 @@ { GstBinaryPluginFeature *pf; GstPluginFeature *feature; - gchar *type_name; + gchar *type_name = NULL, *str; GType type; guint i; @@ -557,26 +599,47 @@ goto fail; } } - } - gst_registry_add_feature (registry, feature); - GST_DEBUG ("Added feature %s", feature->name); + /* load uritypes */ + if (pf->nuriprotocols) { + GST_DEBUG ("Reading %d UriTypes at address %p", pf->nuriprotocols, *in); - /* FIXME: handle interfaces and uritypes */ -#if 0 - for (i = 0; i < pf->ninterfaces; i++) { - // read string - __gst_element_factory_add_interface (factory, s); + align32 (*in); + factory->uri_type = *((guint *) * in); + *in += sizeof (factory->uri_type); + //unpack_element(*in, &factory->uri_type, factory->uri_type); + factory->uri_protocols = g_new0 (gchar *, pf->nuriprotocols + 1); + for (i = 0; i < pf->nuriprotocols; i++) { + unpack_string (*in, str); + factory->uri_protocols[i] = str; + /* load interfaces */ + GST_DEBUG ("Reading %d Interfaces at address %p", pf->ninterfaces, *in); + for (i = 0; i < pf->ninterfaces; i++) { + unpack_string (*in, str); + __gst_element_factory_add_interface (factory, str); + g_free (str); + /* FIXME: load typefind */ - for (i = 0; i < pf->nuritypes; i++) { - add_to_char_array (&factory->uri_protocols, s); + /* FIXME: load indexers */ #endif + gst_registry_add_feature (registry, feature); + GST_DEBUG ("Added feature %s", feature->name); + g_free (type_name); fail: if (GST_IS_OBJECT (feature)) gst_object_unref (feature); else @@ -718,7 +781,6 @@ return TRUE; /* empty file, this is not an error */ for (; ((size_t) in + sizeof (GstBinaryPluginElement)) < (size_t) contents + size;) { Index: gstregistrybinary.h RCS file: /cvs/gstreamer/gstreamer/gst/gstregistrybinary.h,v --- gstregistrybinary.h 11 Jan 2007 13:45:51 -0000 1.1 +++ gstregistrybinary.h 15 Jan 2007 12:18:46 -0000 1.2 @@ -81,8 +81,8 @@ typedef struct _GstBinaryRegistryMagic - char magic[GST_MAGIC_BINARY_REGISTRY_LEN]; - char version[GST_MAGIC_BINARY_VERSION_LEN]; + gchar magic[GST_MAGIC_BINARY_REGISTRY_LEN]; + gchar version[GST_MAGIC_BINARY_VERSION_LEN]; } GstBinaryRegistryMagic; @@ -94,76 +94,67 @@ GST_BINARY_REGISTRY_FLAG_CONST = 1 }; -/* GstBinaryChunk: + * GstBinaryChunk: * Header for binary blobs */ typedef struct _GstBinaryChunk - void *data; - unsigned int size; - unsigned int flags; + gpointer data; + guint size; + guint flags; gboolean align; } GstBinaryChunk; -/* A structure containing (staticely) every information needed for a plugin -** -** Notes : -** "nfeatures" is used to say how many GstBinaryPluginFeature structures we will have -** right after the structure itself. -*/ + * GstBinaryPluginElement: + * @nfeatures: says how many GstBinaryPluginFeature structures we will have + * right after the structure itself. + * A structure containing (staticely) every information needed for a plugin typedef struct _GstBinaryPluginElement - unsigned long file_size; - unsigned long file_mtime; + gulong file_size; + gulong file_mtime; - unsigned int nfeatures; + guint nfeatures; } GstBinaryPluginElement; -/* A structure containing the plugin features -** Note : -** "npadtemplates" is used to store the number of GstBinaryPadTemplate structures following the structure itself. -** "ninterfaces" is used to store the number of GstBinaryInterface structures following the structure itself. -** "nuritypes" is used to store the number of GstBinaryUriType structures following the structure itself. + * GstBinaryPluginFeature: + * @npadtemplates: stores the number of GstBinaryPadTemplate structures + * following the structure + * @ninterfaces: stores the number of interface names following the structure + * @nuriprotocols: stores the number of protocol strings following the structure + * A structure containing the plugin features typedef struct _GstBinaryPluginFeature - unsigned long rank; + gulong rank; - unsigned int npadtemplates; - unsigned int ninterfaces; - unsigned int nuritypes; + guint npadtemplates; + guint ninterfaces; + guint nuriprotocols; } GstBinaryPluginFeature; -/* -** A structure containing the static pad templates of a plugin feature + * GstBinaryPadTemplate: + * A structure containing the static pad templates of a plugin feature typedef struct _GstBinaryPadTemplate - int direction; /* Either 0:"sink" or 1:"src" */ + guint direction; /* Either 0:"sink" or 1:"src" */ GstPadPresence presence; } GstBinaryPadTemplate; -/* -** A very simple structure defining the plugin feature interface string -//#define GST_BINARY_REGISTRY_INTERFACE_INTERFACE_LEN (512) -typedef struct _GstBinaryInterface -{ - //char interface[GST_BINARY_REGISTRY_INTERFACE_INTERFACE_LEN]; - unsigned long size; -} GstBinaryInterface; -/* Uri Type */ -typedef struct _GstBinaryUriType - GstURIType type; /* GST_URI_SINK / GST_URI_SRC */ - unsigned long nuriprotocols; -} GstBinaryUriType; /* Function prototypes */ gboolean gst_registry_binary_write_cache(GstRegistry *registry, const char *location); |