2000-12-28 22:12:02 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
|
|
|
* gstxml.c: XML save/restore of pipelines
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2005-10-15 16:01:57 +00:00
|
|
|
|
2005-08-31 14:08:45 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstxml
|
|
|
|
* @short_description: XML save/restore operations of pipelines
|
|
|
|
*
|
2005-11-14 15:15:43 +00:00
|
|
|
* GStreamer pipelines can be saved to xml files using gst_xml_write_file().
|
|
|
|
* They can be loaded back using gst_xml_parse_doc() / gst_xml_parse_file() /
|
|
|
|
* gst_xml_parse_memory().
|
|
|
|
* Additionally one can load saved pipelines into the gst-editor to inspect the
|
|
|
|
* graph.
|
|
|
|
*
|
2008-10-10 15:38:06 +00:00
|
|
|
* #GstElement implementations need to override the save_thyself() and
|
|
|
|
* restore_thyself() virtual functions of #GstObject.
|
2005-08-31 14:08:45 +00:00
|
|
|
*/
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-28 22:12:02 +00:00
|
|
|
#include "gst_private.h"
|
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
#include "gstxml.h"
|
2004-02-03 03:31:26 +00:00
|
|
|
#include "gstmarshal.h"
|
2003-06-29 14:05:49 +00:00
|
|
|
#include "gstinfo.h"
|
2001-01-08 22:08:40 +00:00
|
|
|
#include "gstbin.h"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-01-29 00:06:02 +00:00
|
|
|
OBJECT_LOADED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_xml_class_init (GstXMLClass * klass);
|
|
|
|
static void gst_xml_init (GstXML * xml);
|
2006-08-21 14:03:33 +00:00
|
|
|
static void gst_xml_dispose (GObject * object);
|
2000-09-24 22:45:48 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_xml_object_loaded (GstObject * private, GstObject * object,
|
|
|
|
xmlNodePtr self, gpointer data);
|
2001-01-30 23:53:04 +00:00
|
|
|
|
2000-09-24 22:45:48 +00:00
|
|
|
static GstObjectClass *parent_class = NULL;
|
2001-01-29 00:06:02 +00:00
|
|
|
static guint gst_xml_signals[LAST_SIGNAL] = { 0 };
|
2000-09-24 22:45:48 +00:00
|
|
|
|
2009-04-04 08:20:36 +00:00
|
|
|
G_DEFINE_TYPE (GstXML, gst_xml, GST_TYPE_OBJECT);
|
2000-09-24 22:45:48 +00:00
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_class_init (GstXMLClass * klass)
|
2000-12-25 01:33:06 +00:00
|
|
|
{
|
2009-04-04 08:20:36 +00:00
|
|
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2006-04-08 20:57:31 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2006-08-21 14:03:33 +00:00
|
|
|
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_xml_dispose);
|
|
|
|
|
2005-08-15 16:57:34 +00:00
|
|
|
/* FIXME G_TYPE_POINTER should be GType of xmlNodePtr
|
|
|
|
* (ensonic) can't be fixed, as libxml does not use GObject (unfortunately)
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* GstXML::object-loaded:
|
|
|
|
* @xml: the xml persistence instance
|
|
|
|
* @object: the object that has been loaded
|
|
|
|
* @xml_node: the related xml_node pointer to the document tree
|
|
|
|
*
|
|
|
|
* Signals that a new object has been deserialized.
|
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
gst_xml_signals[OBJECT_LOADED] =
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_new ("object-loaded", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstXMLClass, object_loaded), NULL,
|
|
|
|
NULL, gst_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2, GST_TYPE_OBJECT,
|
|
|
|
G_TYPE_POINTER);
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2000-09-24 22:45:48 +00:00
|
|
|
}
|
|
|
|
|
2001-01-21 23:20:46 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_init (GstXML * xml)
|
2000-12-25 01:33:06 +00:00
|
|
|
{
|
2001-01-29 00:06:02 +00:00
|
|
|
xml->topelements = NULL;
|
|
|
|
}
|
|
|
|
|
2006-08-21 14:03:33 +00:00
|
|
|
static void
|
|
|
|
gst_xml_dispose (GObject * object)
|
|
|
|
{
|
2006-08-21 15:19:40 +00:00
|
|
|
GstXML *xml = GST_XML (object);
|
|
|
|
|
|
|
|
g_list_foreach (xml->topelements, (GFunc) gst_object_unref, NULL);
|
|
|
|
g_list_free (xml->topelements);
|
|
|
|
xml->topelements = NULL;
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
2006-08-21 14:03:33 +00:00
|
|
|
}
|
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
/**
|
|
|
|
* gst_xml_new:
|
|
|
|
*
|
|
|
|
* Create a new GstXML parser object.
|
|
|
|
*
|
|
|
|
* Returns: a pointer to a new GstXML object.
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GstXML *
|
2001-01-29 00:06:02 +00:00
|
|
|
gst_xml_new (void)
|
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
return GST_XML (g_object_new (GST_TYPE_XML, NULL));
|
2000-09-24 22:45:48 +00:00
|
|
|
}
|
|
|
|
|
2000-03-27 19:53:43 +00:00
|
|
|
/**
|
|
|
|
* gst_xml_write:
|
|
|
|
* @element: The element to write out
|
|
|
|
*
|
2001-01-10 09:15:00 +00:00
|
|
|
* Converts the given element into an XML presentation.
|
2000-03-27 19:53:43 +00:00
|
|
|
*
|
|
|
|
* Returns: a pointer to an XML document
|
|
|
|
*/
|
2001-01-21 23:20:46 +00:00
|
|
|
xmlDocPtr
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_write (GstElement * element)
|
2000-12-25 01:33:06 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
xmlDocPtr doc;
|
2001-01-29 00:06:02 +00:00
|
|
|
xmlNodePtr elementnode;
|
2003-06-09 12:28:06 +00:00
|
|
|
xmlNsPtr gst_ns;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
GCC 4 fixen.
Original commit message from CVS:
2005-05-04 Andy Wingo <wingo@pobox.com>
* check/Makefile.am:
* docs/gst/tmpl/gstatomic.sgml:
* docs/gst/tmpl/gstplugin.sgml:
* gst/base/gstbasesink.c: (gst_basesink_activate):
* gst/base/gstbasesrc.c: (gst_basesrc_class_init),
(gst_basesrc_init), (gst_basesrc_set_dataflow_funcs),
(gst_basesrc_query), (gst_basesrc_set_property),
(gst_basesrc_get_property), (gst_basesrc_check_get_range),
(gst_basesrc_activate):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c: (gst_base_transform_sink_activate),
(gst_base_transform_src_activate):
* gst/elements/gstelements.c:
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init),
(gst_fakesrc_set_property), (gst_fakesrc_get_property):
* gst/elements/gsttee.c: (gst_tee_sink_activate):
* gst/elements/gsttypefindelement.c: (find_element_get_length),
(gst_type_find_element_checkgetrange),
(gst_type_find_element_activate):
* gst/gstbin.c: (gst_bin_save_thyself), (gst_bin_restore_thyself):
* gst/gstcaps.c: (gst_caps_do_simplify), (gst_caps_save_thyself),
(gst_caps_load_thyself):
* gst/gstelement.c: (gst_element_pads_activate),
(gst_element_save_thyself), (gst_element_restore_thyself):
* gst/gstpad.c: (gst_pad_load_and_link), (gst_pad_save_thyself),
(gst_ghost_pad_save_thyself), (gst_pad_check_pull_range):
* gst/gstpad.h:
* gst/gstxml.c: (gst_xml_write), (gst_xml_parse_doc),
(gst_xml_parse_file), (gst_xml_parse_memory),
(gst_xml_get_element), (gst_xml_make_element):
* gst/indexers/gstfileindex.c: (gst_file_index_load),
(_file_index_id_save_xml), (gst_file_index_commit):
* gst/registries/gstlibxmlregistry.c: (read_string), (read_uint),
(read_enum), (load_pad_template), (load_feature), (load_plugin),
(load_paths):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_caps),
(gst_dp_packet_from_event), (gst_dp_caps_from_packet):
* tools/gst-complete.c: (main):
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_element_properties_info):
* tools/gst-launch.c: (xmllaunch_parse_cmdline):
* tools/gst-xmlinspect.c: (print_element_properties):
GCC 4 fixen.
2005-05-04 21:29:44 +00:00
|
|
|
doc = xmlNewDoc ((xmlChar *) "1.0");
|
2000-01-30 09:03:00 +00:00
|
|
|
|
GCC 4 fixen.
Original commit message from CVS:
2005-05-04 Andy Wingo <wingo@pobox.com>
* check/Makefile.am:
* docs/gst/tmpl/gstatomic.sgml:
* docs/gst/tmpl/gstplugin.sgml:
* gst/base/gstbasesink.c: (gst_basesink_activate):
* gst/base/gstbasesrc.c: (gst_basesrc_class_init),
(gst_basesrc_init), (gst_basesrc_set_dataflow_funcs),
(gst_basesrc_query), (gst_basesrc_set_property),
(gst_basesrc_get_property), (gst_basesrc_check_get_range),
(gst_basesrc_activate):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c: (gst_base_transform_sink_activate),
(gst_base_transform_src_activate):
* gst/elements/gstelements.c:
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init),
(gst_fakesrc_set_property), (gst_fakesrc_get_property):
* gst/elements/gsttee.c: (gst_tee_sink_activate):
* gst/elements/gsttypefindelement.c: (find_element_get_length),
(gst_type_find_element_checkgetrange),
(gst_type_find_element_activate):
* gst/gstbin.c: (gst_bin_save_thyself), (gst_bin_restore_thyself):
* gst/gstcaps.c: (gst_caps_do_simplify), (gst_caps_save_thyself),
(gst_caps_load_thyself):
* gst/gstelement.c: (gst_element_pads_activate),
(gst_element_save_thyself), (gst_element_restore_thyself):
* gst/gstpad.c: (gst_pad_load_and_link), (gst_pad_save_thyself),
(gst_ghost_pad_save_thyself), (gst_pad_check_pull_range):
* gst/gstpad.h:
* gst/gstxml.c: (gst_xml_write), (gst_xml_parse_doc),
(gst_xml_parse_file), (gst_xml_parse_memory),
(gst_xml_get_element), (gst_xml_make_element):
* gst/indexers/gstfileindex.c: (gst_file_index_load),
(_file_index_id_save_xml), (gst_file_index_commit):
* gst/registries/gstlibxmlregistry.c: (read_string), (read_uint),
(read_enum), (load_pad_template), (load_feature), (load_plugin),
(load_paths):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_caps),
(gst_dp_packet_from_event), (gst_dp_caps_from_packet):
* tools/gst-complete.c: (main):
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_element_properties_info):
* tools/gst-launch.c: (xmllaunch_parse_cmdline):
* tools/gst-xmlinspect.c: (print_element_properties):
GCC 4 fixen.
2005-05-04 21:29:44 +00:00
|
|
|
doc->xmlRootNode = xmlNewDocNode (doc, NULL, (xmlChar *) "gstreamer", NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
gst_ns =
|
GCC 4 fixen.
Original commit message from CVS:
2005-05-04 Andy Wingo <wingo@pobox.com>
* check/Makefile.am:
* docs/gst/tmpl/gstatomic.sgml:
* docs/gst/tmpl/gstplugin.sgml:
* gst/base/gstbasesink.c: (gst_basesink_activate):
* gst/base/gstbasesrc.c: (gst_basesrc_class_init),
(gst_basesrc_init), (gst_basesrc_set_dataflow_funcs),
(gst_basesrc_query), (gst_basesrc_set_property),
(gst_basesrc_get_property), (gst_basesrc_check_get_range),
(gst_basesrc_activate):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c: (gst_base_transform_sink_activate),
(gst_base_transform_src_activate):
* gst/elements/gstelements.c:
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init),
(gst_fakesrc_set_property), (gst_fakesrc_get_property):
* gst/elements/gsttee.c: (gst_tee_sink_activate):
* gst/elements/gsttypefindelement.c: (find_element_get_length),
(gst_type_find_element_checkgetrange),
(gst_type_find_element_activate):
* gst/gstbin.c: (gst_bin_save_thyself), (gst_bin_restore_thyself):
* gst/gstcaps.c: (gst_caps_do_simplify), (gst_caps_save_thyself),
(gst_caps_load_thyself):
* gst/gstelement.c: (gst_element_pads_activate),
(gst_element_save_thyself), (gst_element_restore_thyself):
* gst/gstpad.c: (gst_pad_load_and_link), (gst_pad_save_thyself),
(gst_ghost_pad_save_thyself), (gst_pad_check_pull_range):
* gst/gstpad.h:
* gst/gstxml.c: (gst_xml_write), (gst_xml_parse_doc),
(gst_xml_parse_file), (gst_xml_parse_memory),
(gst_xml_get_element), (gst_xml_make_element):
* gst/indexers/gstfileindex.c: (gst_file_index_load),
(_file_index_id_save_xml), (gst_file_index_commit):
* gst/registries/gstlibxmlregistry.c: (read_string), (read_uint),
(read_enum), (load_pad_template), (load_feature), (load_plugin),
(load_paths):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_caps),
(gst_dp_packet_from_event), (gst_dp_caps_from_packet):
* tools/gst-complete.c: (main):
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_element_properties_info):
* tools/gst-launch.c: (xmllaunch_parse_cmdline):
* tools/gst-xmlinspect.c: (print_element_properties):
GCC 4 fixen.
2005-05-04 21:29:44 +00:00
|
|
|
xmlNewNs (doc->xmlRootNode,
|
|
|
|
(xmlChar *) "http://gstreamer.net/gst-core/1.0/", (xmlChar *) "gst");
|
2004-03-13 15:27:01 +00:00
|
|
|
|
GCC 4 fixen.
Original commit message from CVS:
2005-05-04 Andy Wingo <wingo@pobox.com>
* check/Makefile.am:
* docs/gst/tmpl/gstatomic.sgml:
* docs/gst/tmpl/gstplugin.sgml:
* gst/base/gstbasesink.c: (gst_basesink_activate):
* gst/base/gstbasesrc.c: (gst_basesrc_class_init),
(gst_basesrc_init), (gst_basesrc_set_dataflow_funcs),
(gst_basesrc_query), (gst_basesrc_set_property),
(gst_basesrc_get_property), (gst_basesrc_check_get_range),
(gst_basesrc_activate):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c: (gst_base_transform_sink_activate),
(gst_base_transform_src_activate):
* gst/elements/gstelements.c:
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init),
(gst_fakesrc_set_property), (gst_fakesrc_get_property):
* gst/elements/gsttee.c: (gst_tee_sink_activate):
* gst/elements/gsttypefindelement.c: (find_element_get_length),
(gst_type_find_element_checkgetrange),
(gst_type_find_element_activate):
* gst/gstbin.c: (gst_bin_save_thyself), (gst_bin_restore_thyself):
* gst/gstcaps.c: (gst_caps_do_simplify), (gst_caps_save_thyself),
(gst_caps_load_thyself):
* gst/gstelement.c: (gst_element_pads_activate),
(gst_element_save_thyself), (gst_element_restore_thyself):
* gst/gstpad.c: (gst_pad_load_and_link), (gst_pad_save_thyself),
(gst_ghost_pad_save_thyself), (gst_pad_check_pull_range):
* gst/gstpad.h:
* gst/gstxml.c: (gst_xml_write), (gst_xml_parse_doc),
(gst_xml_parse_file), (gst_xml_parse_memory),
(gst_xml_get_element), (gst_xml_make_element):
* gst/indexers/gstfileindex.c: (gst_file_index_load),
(_file_index_id_save_xml), (gst_file_index_commit):
* gst/registries/gstlibxmlregistry.c: (read_string), (read_uint),
(read_enum), (load_pad_template), (load_feature), (load_plugin),
(load_paths):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_caps),
(gst_dp_packet_from_event), (gst_dp_caps_from_packet):
* tools/gst-complete.c: (main):
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_element_properties_info):
* tools/gst-launch.c: (xmllaunch_parse_cmdline):
* tools/gst-xmlinspect.c: (print_element_properties):
GCC 4 fixen.
2005-05-04 21:29:44 +00:00
|
|
|
elementnode = xmlNewChild (doc->xmlRootNode, gst_ns, (xmlChar *) "element",
|
|
|
|
NULL);
|
2001-01-29 00:06:02 +00:00
|
|
|
|
|
|
|
gst_object_save_thyself (GST_OBJECT (element), elementnode);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
return doc;
|
|
|
|
}
|
2000-09-24 22:45:48 +00:00
|
|
|
|
2002-01-11 01:48:17 +00:00
|
|
|
/**
|
|
|
|
* gst_xml_write_file:
|
|
|
|
* @element: The element to write out
|
|
|
|
* @out: an open file, like stdout
|
|
|
|
*
|
|
|
|
* Converts the given element into XML and writes the formatted XML to an open
|
|
|
|
* file.
|
|
|
|
*
|
|
|
|
* Returns: number of bytes written on success, -1 otherwise.
|
|
|
|
*/
|
|
|
|
gint
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_write_file (GstElement * element, FILE * out)
|
2002-01-11 01:48:17 +00:00
|
|
|
{
|
|
|
|
xmlDocPtr cur;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-01-11 07:21:26 +00:00
|
|
|
#ifdef HAVE_LIBXML2
|
2002-01-11 01:48:17 +00:00
|
|
|
xmlOutputBufferPtr buf;
|
2002-01-11 07:21:26 +00:00
|
|
|
#endif
|
2004-03-13 15:27:01 +00:00
|
|
|
const char *encoding;
|
2002-01-11 01:48:17 +00:00
|
|
|
xmlCharEncodingHandlerPtr handler = NULL;
|
|
|
|
int indent;
|
|
|
|
gboolean ret;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-01-11 01:48:17 +00:00
|
|
|
cur = gst_xml_write (element);
|
2004-03-13 15:27:01 +00:00
|
|
|
if (!cur)
|
|
|
|
return -1;
|
|
|
|
|
2002-01-11 01:48:17 +00:00
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
encoding = (const char *) cur->encoding;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-01-11 01:48:17 +00:00
|
|
|
if (encoding != NULL) {
|
|
|
|
xmlCharEncoding enc;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-01-11 01:48:17 +00:00
|
|
|
enc = xmlParseCharEncoding (encoding);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-01-11 01:48:17 +00:00
|
|
|
if (cur->charset != XML_CHAR_ENCODING_UTF8) {
|
|
|
|
xmlGenericError (xmlGenericErrorContext,
|
2004-03-15 19:27:17 +00:00
|
|
|
"xmlDocDump: document not in UTF8\n");
|
2002-01-11 01:48:17 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (enc != XML_CHAR_ENCODING_UTF8) {
|
|
|
|
handler = xmlFindCharEncodingHandler (encoding);
|
|
|
|
if (handler == NULL) {
|
2004-03-15 19:27:17 +00:00
|
|
|
xmlFree ((char *) cur->encoding);
|
|
|
|
cur->encoding = NULL;
|
2002-01-11 01:48:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-01-11 01:48:17 +00:00
|
|
|
buf = xmlOutputBufferCreateFile (out, handler);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-01-11 01:48:17 +00:00
|
|
|
indent = xmlIndentTreeOutput;
|
|
|
|
xmlIndentTreeOutput = 1;
|
2004-03-13 15:27:01 +00:00
|
|
|
ret = xmlSaveFormatFileTo (buf, cur, NULL, 1);
|
2002-01-11 01:48:17 +00:00
|
|
|
xmlIndentTreeOutput = indent;
|
|
|
|
#else
|
2002-01-11 16:05:06 +00:00
|
|
|
/* apparently this doesn't return anything in libxml1 */
|
|
|
|
xmlDocDump (out, cur);
|
|
|
|
ret = 1;
|
2002-01-11 01:48:17 +00:00
|
|
|
#endif
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-01-11 01:48:17 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2001-01-31 20:27:00 +00:00
|
|
|
/**
|
|
|
|
* gst_xml_parse_doc:
|
|
|
|
* @xml: a pointer to a GstXML object
|
|
|
|
* @doc: a pointer to an xml document to parse
|
|
|
|
* @root: The name of the root object to build
|
|
|
|
*
|
|
|
|
* Fills the GstXML object with the elements from the
|
|
|
|
* xmlDocPtr.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success, FALSE otherwise
|
|
|
|
*/
|
2001-01-30 23:53:04 +00:00
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_parse_doc (GstXML * xml, xmlDocPtr doc, const guchar * root)
|
2000-12-16 17:12:28 +00:00
|
|
|
{
|
2001-01-29 00:06:02 +00:00
|
|
|
xmlNodePtr field, cur;
|
|
|
|
xmlNsPtr ns;
|
2000-09-24 22:45:48 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
cur = xmlDocGetRootElement (doc);
|
2001-01-29 00:06:02 +00:00
|
|
|
if (cur == NULL) {
|
2004-03-13 15:27:01 +00:00
|
|
|
g_warning ("gstxml: empty document\n");
|
|
|
|
return FALSE;
|
2001-01-29 00:06:02 +00:00
|
|
|
}
|
GCC 4 fixen.
Original commit message from CVS:
2005-05-04 Andy Wingo <wingo@pobox.com>
* check/Makefile.am:
* docs/gst/tmpl/gstatomic.sgml:
* docs/gst/tmpl/gstplugin.sgml:
* gst/base/gstbasesink.c: (gst_basesink_activate):
* gst/base/gstbasesrc.c: (gst_basesrc_class_init),
(gst_basesrc_init), (gst_basesrc_set_dataflow_funcs),
(gst_basesrc_query), (gst_basesrc_set_property),
(gst_basesrc_get_property), (gst_basesrc_check_get_range),
(gst_basesrc_activate):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c: (gst_base_transform_sink_activate),
(gst_base_transform_src_activate):
* gst/elements/gstelements.c:
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init),
(gst_fakesrc_set_property), (gst_fakesrc_get_property):
* gst/elements/gsttee.c: (gst_tee_sink_activate):
* gst/elements/gsttypefindelement.c: (find_element_get_length),
(gst_type_find_element_checkgetrange),
(gst_type_find_element_activate):
* gst/gstbin.c: (gst_bin_save_thyself), (gst_bin_restore_thyself):
* gst/gstcaps.c: (gst_caps_do_simplify), (gst_caps_save_thyself),
(gst_caps_load_thyself):
* gst/gstelement.c: (gst_element_pads_activate),
(gst_element_save_thyself), (gst_element_restore_thyself):
* gst/gstpad.c: (gst_pad_load_and_link), (gst_pad_save_thyself),
(gst_ghost_pad_save_thyself), (gst_pad_check_pull_range):
* gst/gstpad.h:
* gst/gstxml.c: (gst_xml_write), (gst_xml_parse_doc),
(gst_xml_parse_file), (gst_xml_parse_memory),
(gst_xml_get_element), (gst_xml_make_element):
* gst/indexers/gstfileindex.c: (gst_file_index_load),
(_file_index_id_save_xml), (gst_file_index_commit):
* gst/registries/gstlibxmlregistry.c: (read_string), (read_uint),
(read_enum), (load_pad_template), (load_feature), (load_plugin),
(load_paths):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_caps),
(gst_dp_packet_from_event), (gst_dp_caps_from_packet):
* tools/gst-complete.c: (main):
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_element_properties_info):
* tools/gst-launch.c: (xmllaunch_parse_cmdline):
* tools/gst-xmlinspect.c: (print_element_properties):
GCC 4 fixen.
2005-05-04 21:29:44 +00:00
|
|
|
ns = xmlSearchNsByHref (doc, cur,
|
|
|
|
(xmlChar *) "http://gstreamer.net/gst-core/1.0/");
|
2001-01-29 00:06:02 +00:00
|
|
|
if (ns == NULL) {
|
2004-03-13 15:27:01 +00:00
|
|
|
g_warning ("gstxml: document of wrong type, core namespace not found\n");
|
2001-01-29 00:06:02 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
GCC 4 fixen.
Original commit message from CVS:
2005-05-04 Andy Wingo <wingo@pobox.com>
* check/Makefile.am:
* docs/gst/tmpl/gstatomic.sgml:
* docs/gst/tmpl/gstplugin.sgml:
* gst/base/gstbasesink.c: (gst_basesink_activate):
* gst/base/gstbasesrc.c: (gst_basesrc_class_init),
(gst_basesrc_init), (gst_basesrc_set_dataflow_funcs),
(gst_basesrc_query), (gst_basesrc_set_property),
(gst_basesrc_get_property), (gst_basesrc_check_get_range),
(gst_basesrc_activate):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c: (gst_base_transform_sink_activate),
(gst_base_transform_src_activate):
* gst/elements/gstelements.c:
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init),
(gst_fakesrc_set_property), (gst_fakesrc_get_property):
* gst/elements/gsttee.c: (gst_tee_sink_activate):
* gst/elements/gsttypefindelement.c: (find_element_get_length),
(gst_type_find_element_checkgetrange),
(gst_type_find_element_activate):
* gst/gstbin.c: (gst_bin_save_thyself), (gst_bin_restore_thyself):
* gst/gstcaps.c: (gst_caps_do_simplify), (gst_caps_save_thyself),
(gst_caps_load_thyself):
* gst/gstelement.c: (gst_element_pads_activate),
(gst_element_save_thyself), (gst_element_restore_thyself):
* gst/gstpad.c: (gst_pad_load_and_link), (gst_pad_save_thyself),
(gst_ghost_pad_save_thyself), (gst_pad_check_pull_range):
* gst/gstpad.h:
* gst/gstxml.c: (gst_xml_write), (gst_xml_parse_doc),
(gst_xml_parse_file), (gst_xml_parse_memory),
(gst_xml_get_element), (gst_xml_make_element):
* gst/indexers/gstfileindex.c: (gst_file_index_load),
(_file_index_id_save_xml), (gst_file_index_commit):
* gst/registries/gstlibxmlregistry.c: (read_string), (read_uint),
(read_enum), (load_pad_template), (load_feature), (load_plugin),
(load_paths):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_caps),
(gst_dp_packet_from_event), (gst_dp_caps_from_packet):
* tools/gst-complete.c: (main):
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_element_properties_info):
* tools/gst-launch.c: (xmllaunch_parse_cmdline):
* tools/gst-xmlinspect.c: (print_element_properties):
GCC 4 fixen.
2005-05-04 21:29:44 +00:00
|
|
|
if (strcmp ((char *) cur->name, "gstreamer")) {
|
2004-03-13 15:27:01 +00:00
|
|
|
g_warning ("gstxml: XML file is in wrong format\n");
|
2001-01-29 00:06:02 +00:00
|
|
|
return FALSE;
|
2000-09-24 22:45:48 +00:00
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_class_signal_connect (GST_OBJECT_CLASS (G_OBJECT_GET_CLASS (xml)),
|
2006-10-06 14:46:04 +00:00
|
|
|
"object_loaded", (gpointer) gst_xml_object_loaded, xml);
|
2001-01-30 23:53:04 +00:00
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
xml->ns = ns;
|
2000-09-27 19:33:10 +00:00
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
field = cur->xmlChildrenNode;
|
2001-01-21 23:20:46 +00:00
|
|
|
|
2000-09-27 19:33:10 +00:00
|
|
|
while (field) {
|
GCC 4 fixen.
Original commit message from CVS:
2005-05-04 Andy Wingo <wingo@pobox.com>
* check/Makefile.am:
* docs/gst/tmpl/gstatomic.sgml:
* docs/gst/tmpl/gstplugin.sgml:
* gst/base/gstbasesink.c: (gst_basesink_activate):
* gst/base/gstbasesrc.c: (gst_basesrc_class_init),
(gst_basesrc_init), (gst_basesrc_set_dataflow_funcs),
(gst_basesrc_query), (gst_basesrc_set_property),
(gst_basesrc_get_property), (gst_basesrc_check_get_range),
(gst_basesrc_activate):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c: (gst_base_transform_sink_activate),
(gst_base_transform_src_activate):
* gst/elements/gstelements.c:
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init),
(gst_fakesrc_set_property), (gst_fakesrc_get_property):
* gst/elements/gsttee.c: (gst_tee_sink_activate):
* gst/elements/gsttypefindelement.c: (find_element_get_length),
(gst_type_find_element_checkgetrange),
(gst_type_find_element_activate):
* gst/gstbin.c: (gst_bin_save_thyself), (gst_bin_restore_thyself):
* gst/gstcaps.c: (gst_caps_do_simplify), (gst_caps_save_thyself),
(gst_caps_load_thyself):
* gst/gstelement.c: (gst_element_pads_activate),
(gst_element_save_thyself), (gst_element_restore_thyself):
* gst/gstpad.c: (gst_pad_load_and_link), (gst_pad_save_thyself),
(gst_ghost_pad_save_thyself), (gst_pad_check_pull_range):
* gst/gstpad.h:
* gst/gstxml.c: (gst_xml_write), (gst_xml_parse_doc),
(gst_xml_parse_file), (gst_xml_parse_memory),
(gst_xml_get_element), (gst_xml_make_element):
* gst/indexers/gstfileindex.c: (gst_file_index_load),
(_file_index_id_save_xml), (gst_file_index_commit):
* gst/registries/gstlibxmlregistry.c: (read_string), (read_uint),
(read_enum), (load_pad_template), (load_feature), (load_plugin),
(load_paths):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_caps),
(gst_dp_packet_from_event), (gst_dp_caps_from_packet):
* tools/gst-complete.c: (main):
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_element_properties_info):
* tools/gst-launch.c: (xmllaunch_parse_cmdline):
* tools/gst-xmlinspect.c: (print_element_properties):
GCC 4 fixen.
2005-05-04 21:29:44 +00:00
|
|
|
if (!strcmp ((char *) field->name, "element") && (field->ns == xml->ns)) {
|
2000-12-16 17:12:28 +00:00
|
|
|
GstElement *element;
|
2001-01-21 23:20:46 +00:00
|
|
|
|
2002-01-11 15:49:47 +00:00
|
|
|
element = gst_xml_make_element (field, NULL);
|
2000-12-16 17:12:28 +00:00
|
|
|
|
|
|
|
xml->topelements = g_list_prepend (xml->topelements, element);
|
2000-09-27 19:33:10 +00:00
|
|
|
}
|
|
|
|
field = field->next;
|
|
|
|
}
|
|
|
|
|
2000-12-16 17:12:28 +00:00
|
|
|
xml->topelements = g_list_reverse (xml->topelements);
|
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
return TRUE;
|
2000-09-24 22:45:48 +00:00
|
|
|
}
|
|
|
|
|
GCC 4 fixen.
Original commit message from CVS:
2005-05-04 Andy Wingo <wingo@pobox.com>
* check/Makefile.am:
* docs/gst/tmpl/gstatomic.sgml:
* docs/gst/tmpl/gstplugin.sgml:
* gst/base/gstbasesink.c: (gst_basesink_activate):
* gst/base/gstbasesrc.c: (gst_basesrc_class_init),
(gst_basesrc_init), (gst_basesrc_set_dataflow_funcs),
(gst_basesrc_query), (gst_basesrc_set_property),
(gst_basesrc_get_property), (gst_basesrc_check_get_range),
(gst_basesrc_activate):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c: (gst_base_transform_sink_activate),
(gst_base_transform_src_activate):
* gst/elements/gstelements.c:
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init),
(gst_fakesrc_set_property), (gst_fakesrc_get_property):
* gst/elements/gsttee.c: (gst_tee_sink_activate):
* gst/elements/gsttypefindelement.c: (find_element_get_length),
(gst_type_find_element_checkgetrange),
(gst_type_find_element_activate):
* gst/gstbin.c: (gst_bin_save_thyself), (gst_bin_restore_thyself):
* gst/gstcaps.c: (gst_caps_do_simplify), (gst_caps_save_thyself),
(gst_caps_load_thyself):
* gst/gstelement.c: (gst_element_pads_activate),
(gst_element_save_thyself), (gst_element_restore_thyself):
* gst/gstpad.c: (gst_pad_load_and_link), (gst_pad_save_thyself),
(gst_ghost_pad_save_thyself), (gst_pad_check_pull_range):
* gst/gstpad.h:
* gst/gstxml.c: (gst_xml_write), (gst_xml_parse_doc),
(gst_xml_parse_file), (gst_xml_parse_memory),
(gst_xml_get_element), (gst_xml_make_element):
* gst/indexers/gstfileindex.c: (gst_file_index_load),
(_file_index_id_save_xml), (gst_file_index_commit):
* gst/registries/gstlibxmlregistry.c: (read_string), (read_uint),
(read_enum), (load_pad_template), (load_feature), (load_plugin),
(load_paths):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_caps),
(gst_dp_packet_from_event), (gst_dp_caps_from_packet):
* tools/gst-complete.c: (main):
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_element_properties_info):
* tools/gst-launch.c: (xmllaunch_parse_cmdline):
* tools/gst-xmlinspect.c: (print_element_properties):
GCC 4 fixen.
2005-05-04 21:29:44 +00:00
|
|
|
/* FIXME 0.9: Why guchar*? */
|
2001-01-21 23:20:46 +00:00
|
|
|
/**
|
2001-01-29 00:06:02 +00:00
|
|
|
* gst_xml_parse_file:
|
2001-01-31 20:27:00 +00:00
|
|
|
* @xml: a pointer to a GstXML object
|
2001-01-21 23:20:46 +00:00
|
|
|
* @fname: The filename with the xml description
|
|
|
|
* @root: The name of the root object to build
|
|
|
|
*
|
2001-01-31 20:27:00 +00:00
|
|
|
* Fills the GstXML object with the corresponding elements from
|
2001-01-21 23:20:46 +00:00
|
|
|
* the XML file fname. Optionally it will only build the element from
|
|
|
|
* the element node root (if it is not NULL). This feature is useful
|
|
|
|
* if you only want to build a specific element from an XML file
|
2001-01-31 20:27:00 +00:00
|
|
|
* but not the pipeline it is embedded in.
|
2001-01-21 23:20:46 +00:00
|
|
|
*
|
2002-01-18 22:44:19 +00:00
|
|
|
* Pass "-" as fname to read from stdin. You can also pass a URI
|
|
|
|
* of any format that libxml supports, including http.
|
|
|
|
*
|
2001-01-29 00:06:02 +00:00
|
|
|
* Returns: TRUE on success, FALSE otherwise
|
2001-01-21 23:20:46 +00:00
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_parse_file (GstXML * xml, const guchar * fname, const guchar * root)
|
2001-01-21 23:20:46 +00:00
|
|
|
{
|
|
|
|
xmlDocPtr doc;
|
2006-08-21 15:19:40 +00:00
|
|
|
gboolean ret;
|
2001-01-21 23:20:46 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (fname != NULL, FALSE);
|
2001-01-21 23:20:46 +00:00
|
|
|
|
GCC 4 fixen.
Original commit message from CVS:
2005-05-04 Andy Wingo <wingo@pobox.com>
* check/Makefile.am:
* docs/gst/tmpl/gstatomic.sgml:
* docs/gst/tmpl/gstplugin.sgml:
* gst/base/gstbasesink.c: (gst_basesink_activate):
* gst/base/gstbasesrc.c: (gst_basesrc_class_init),
(gst_basesrc_init), (gst_basesrc_set_dataflow_funcs),
(gst_basesrc_query), (gst_basesrc_set_property),
(gst_basesrc_get_property), (gst_basesrc_check_get_range),
(gst_basesrc_activate):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c: (gst_base_transform_sink_activate),
(gst_base_transform_src_activate):
* gst/elements/gstelements.c:
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init),
(gst_fakesrc_set_property), (gst_fakesrc_get_property):
* gst/elements/gsttee.c: (gst_tee_sink_activate):
* gst/elements/gsttypefindelement.c: (find_element_get_length),
(gst_type_find_element_checkgetrange),
(gst_type_find_element_activate):
* gst/gstbin.c: (gst_bin_save_thyself), (gst_bin_restore_thyself):
* gst/gstcaps.c: (gst_caps_do_simplify), (gst_caps_save_thyself),
(gst_caps_load_thyself):
* gst/gstelement.c: (gst_element_pads_activate),
(gst_element_save_thyself), (gst_element_restore_thyself):
* gst/gstpad.c: (gst_pad_load_and_link), (gst_pad_save_thyself),
(gst_ghost_pad_save_thyself), (gst_pad_check_pull_range):
* gst/gstpad.h:
* gst/gstxml.c: (gst_xml_write), (gst_xml_parse_doc),
(gst_xml_parse_file), (gst_xml_parse_memory),
(gst_xml_get_element), (gst_xml_make_element):
* gst/indexers/gstfileindex.c: (gst_file_index_load),
(_file_index_id_save_xml), (gst_file_index_commit):
* gst/registries/gstlibxmlregistry.c: (read_string), (read_uint),
(read_enum), (load_pad_template), (load_feature), (load_plugin),
(load_paths):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_caps),
(gst_dp_packet_from_event), (gst_dp_caps_from_packet):
* tools/gst-complete.c: (main):
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_element_properties_info):
* tools/gst-launch.c: (xmllaunch_parse_cmdline):
* tools/gst-xmlinspect.c: (print_element_properties):
GCC 4 fixen.
2005-05-04 21:29:44 +00:00
|
|
|
doc = xmlParseFile ((char *) fname);
|
2001-01-21 23:20:46 +00:00
|
|
|
|
|
|
|
if (!doc) {
|
2004-03-13 15:27:01 +00:00
|
|
|
g_warning ("gstxml: XML file \"%s\" could not be read\n", fname);
|
2001-01-29 00:06:02 +00:00
|
|
|
return FALSE;
|
2001-01-21 23:20:46 +00:00
|
|
|
}
|
|
|
|
|
2006-08-21 15:19:40 +00:00
|
|
|
ret = gst_xml_parse_doc (xml, doc, root);
|
|
|
|
|
|
|
|
xmlFreeDoc (doc);
|
|
|
|
return ret;
|
2001-01-21 23:20:46 +00:00
|
|
|
}
|
|
|
|
|
2005-08-15 16:57:34 +00:00
|
|
|
/* FIXME 0.9: guchar* */
|
2001-01-21 23:20:46 +00:00
|
|
|
/**
|
2001-01-29 00:06:02 +00:00
|
|
|
* gst_xml_parse_memory:
|
2001-01-31 20:27:00 +00:00
|
|
|
* @xml: a pointer to a GstXML object
|
2001-01-21 23:20:46 +00:00
|
|
|
* @buffer: a pointer to the in memory XML buffer
|
|
|
|
* @size: the size of the buffer
|
|
|
|
* @root: the name of the root objects to build
|
|
|
|
*
|
2001-01-31 20:27:00 +00:00
|
|
|
* Fills the GstXML object with the corresponding elements from
|
2001-01-21 23:20:46 +00:00
|
|
|
* an in memory XML buffer.
|
|
|
|
*
|
2001-01-31 20:27:00 +00:00
|
|
|
* Returns: TRUE on success
|
2001-01-21 23:20:46 +00:00
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_parse_memory (GstXML * xml, guchar * buffer, guint size,
|
|
|
|
const gchar * root)
|
2001-01-21 23:20:46 +00:00
|
|
|
{
|
|
|
|
xmlDocPtr doc;
|
2006-08-21 15:19:40 +00:00
|
|
|
gboolean ret;
|
2001-01-21 23:20:46 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (buffer != NULL, FALSE);
|
2001-01-21 23:20:46 +00:00
|
|
|
|
GCC 4 fixen.
Original commit message from CVS:
2005-05-04 Andy Wingo <wingo@pobox.com>
* check/Makefile.am:
* docs/gst/tmpl/gstatomic.sgml:
* docs/gst/tmpl/gstplugin.sgml:
* gst/base/gstbasesink.c: (gst_basesink_activate):
* gst/base/gstbasesrc.c: (gst_basesrc_class_init),
(gst_basesrc_init), (gst_basesrc_set_dataflow_funcs),
(gst_basesrc_query), (gst_basesrc_set_property),
(gst_basesrc_get_property), (gst_basesrc_check_get_range),
(gst_basesrc_activate):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c: (gst_base_transform_sink_activate),
(gst_base_transform_src_activate):
* gst/elements/gstelements.c:
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init),
(gst_fakesrc_set_property), (gst_fakesrc_get_property):
* gst/elements/gsttee.c: (gst_tee_sink_activate):
* gst/elements/gsttypefindelement.c: (find_element_get_length),
(gst_type_find_element_checkgetrange),
(gst_type_find_element_activate):
* gst/gstbin.c: (gst_bin_save_thyself), (gst_bin_restore_thyself):
* gst/gstcaps.c: (gst_caps_do_simplify), (gst_caps_save_thyself),
(gst_caps_load_thyself):
* gst/gstelement.c: (gst_element_pads_activate),
(gst_element_save_thyself), (gst_element_restore_thyself):
* gst/gstpad.c: (gst_pad_load_and_link), (gst_pad_save_thyself),
(gst_ghost_pad_save_thyself), (gst_pad_check_pull_range):
* gst/gstpad.h:
* gst/gstxml.c: (gst_xml_write), (gst_xml_parse_doc),
(gst_xml_parse_file), (gst_xml_parse_memory),
(gst_xml_get_element), (gst_xml_make_element):
* gst/indexers/gstfileindex.c: (gst_file_index_load),
(_file_index_id_save_xml), (gst_file_index_commit):
* gst/registries/gstlibxmlregistry.c: (read_string), (read_uint),
(read_enum), (load_pad_template), (load_feature), (load_plugin),
(load_paths):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_caps),
(gst_dp_packet_from_event), (gst_dp_caps_from_packet):
* tools/gst-complete.c: (main):
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_element_properties_info):
* tools/gst-launch.c: (xmllaunch_parse_cmdline):
* tools/gst-xmlinspect.c: (print_element_properties):
GCC 4 fixen.
2005-05-04 21:29:44 +00:00
|
|
|
doc = xmlParseMemory ((char *) buffer, size);
|
2001-01-21 23:20:46 +00:00
|
|
|
|
2006-08-21 15:19:40 +00:00
|
|
|
ret = gst_xml_parse_doc (xml, doc, (const xmlChar *) root);
|
|
|
|
|
|
|
|
xmlFreeDoc (doc);
|
|
|
|
return ret;
|
2001-01-29 00:06:02 +00:00
|
|
|
}
|
|
|
|
|
2001-01-30 23:53:04 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_object_loaded (GstObject * private, GstObject * object, xmlNodePtr self,
|
|
|
|
gpointer data)
|
2001-01-29 00:06:02 +00:00
|
|
|
{
|
2001-01-30 23:53:04 +00:00
|
|
|
GstXML *xml = GST_XML (data);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
/* FIXME check that this element was created from the same xmlDocPtr... */
|
2009-10-03 20:08:54 +00:00
|
|
|
g_signal_emit (xml, gst_xml_signals[OBJECT_LOADED], 0, object, self);
|
2001-01-21 23:20:46 +00:00
|
|
|
}
|
|
|
|
|
2000-12-16 17:12:28 +00:00
|
|
|
/**
|
|
|
|
* gst_xml_get_topelements:
|
|
|
|
* @xml: The GstXML to get the elements from
|
|
|
|
*
|
2006-08-29 10:49:03 +00:00
|
|
|
* Retrieve a list of toplevel elements.
|
2000-12-16 17:12:28 +00:00
|
|
|
*
|
2006-08-29 10:49:03 +00:00
|
|
|
* Returns: a GList of top-level elements. The caller does not own a copy
|
|
|
|
* of the list and must not free or modify the list. The caller also does not
|
|
|
|
* own a reference to any of the elements in the list and should obtain its own
|
|
|
|
* reference using gst_object_ref() if necessary.
|
2000-12-16 17:12:28 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GList *
|
|
|
|
gst_xml_get_topelements (GstXML * xml)
|
2000-12-16 17:12:28 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (xml != NULL, NULL);
|
|
|
|
|
|
|
|
return xml->topelements;
|
|
|
|
}
|
|
|
|
|
2006-08-21 15:19:40 +00:00
|
|
|
/* FIXME 0.11: why is the arg guchar* instead of gchar*? */
|
2000-09-24 22:45:48 +00:00
|
|
|
/**
|
|
|
|
* gst_xml_get_element:
|
|
|
|
* @xml: The GstXML to get the element from
|
2006-10-28 15:42:29 +00:00
|
|
|
* @name: The name of element to retrieve
|
2000-09-24 22:45:48 +00:00
|
|
|
*
|
2001-01-21 23:20:46 +00:00
|
|
|
* This function is used to get a pointer to the GstElement corresponding
|
|
|
|
* to name in the pipeline description. You would use this if you have
|
2000-09-24 22:45:48 +00:00
|
|
|
* to do anything to the element after loading.
|
|
|
|
*
|
2006-08-21 15:19:40 +00:00
|
|
|
* Returns: a pointer to a new GstElement, caller owns returned reference.
|
2000-09-24 22:45:48 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GstElement *
|
|
|
|
gst_xml_get_element (GstXML * xml, const guchar * name)
|
2000-12-16 17:12:28 +00:00
|
|
|
{
|
2000-09-27 19:33:10 +00:00
|
|
|
GstElement *element;
|
2001-01-08 22:08:40 +00:00
|
|
|
GList *topelements;
|
2000-09-24 22:45:48 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (xml != NULL, NULL);
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2000-09-24 22:45:48 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_DEBUG ("gstxml: getting element \"%s\"", name);
|
2000-09-27 19:33:10 +00:00
|
|
|
|
2001-01-08 22:08:40 +00:00
|
|
|
topelements = gst_xml_get_topelements (xml);
|
2000-09-24 22:45:48 +00:00
|
|
|
|
2001-01-08 22:08:40 +00:00
|
|
|
while (topelements) {
|
|
|
|
GstElement *top = GST_ELEMENT (topelements->data);
|
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_DEBUG ("gstxml: getting element \"%s\"", name);
|
GCC 4 fixen.
Original commit message from CVS:
2005-05-04 Andy Wingo <wingo@pobox.com>
* check/Makefile.am:
* docs/gst/tmpl/gstatomic.sgml:
* docs/gst/tmpl/gstplugin.sgml:
* gst/base/gstbasesink.c: (gst_basesink_activate):
* gst/base/gstbasesrc.c: (gst_basesrc_class_init),
(gst_basesrc_init), (gst_basesrc_set_dataflow_funcs),
(gst_basesrc_query), (gst_basesrc_set_property),
(gst_basesrc_get_property), (gst_basesrc_check_get_range),
(gst_basesrc_activate):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c: (gst_base_transform_sink_activate),
(gst_base_transform_src_activate):
* gst/elements/gstelements.c:
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init),
(gst_fakesrc_set_property), (gst_fakesrc_get_property):
* gst/elements/gsttee.c: (gst_tee_sink_activate):
* gst/elements/gsttypefindelement.c: (find_element_get_length),
(gst_type_find_element_checkgetrange),
(gst_type_find_element_activate):
* gst/gstbin.c: (gst_bin_save_thyself), (gst_bin_restore_thyself):
* gst/gstcaps.c: (gst_caps_do_simplify), (gst_caps_save_thyself),
(gst_caps_load_thyself):
* gst/gstelement.c: (gst_element_pads_activate),
(gst_element_save_thyself), (gst_element_restore_thyself):
* gst/gstpad.c: (gst_pad_load_and_link), (gst_pad_save_thyself),
(gst_ghost_pad_save_thyself), (gst_pad_check_pull_range):
* gst/gstpad.h:
* gst/gstxml.c: (gst_xml_write), (gst_xml_parse_doc),
(gst_xml_parse_file), (gst_xml_parse_memory),
(gst_xml_get_element), (gst_xml_make_element):
* gst/indexers/gstfileindex.c: (gst_file_index_load),
(_file_index_id_save_xml), (gst_file_index_commit):
* gst/registries/gstlibxmlregistry.c: (read_string), (read_uint),
(read_enum), (load_pad_template), (load_feature), (load_plugin),
(load_paths):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_caps),
(gst_dp_packet_from_event), (gst_dp_caps_from_packet):
* tools/gst-complete.c: (main):
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_element_properties_info):
* tools/gst-launch.c: (xmllaunch_parse_cmdline):
* tools/gst-xmlinspect.c: (print_element_properties):
GCC 4 fixen.
2005-05-04 21:29:44 +00:00
|
|
|
if (!strcmp (GST_ELEMENT_NAME (top), (char *) name)) {
|
2006-08-21 15:19:40 +00:00
|
|
|
return GST_ELEMENT_CAST (gst_object_ref (top));
|
2004-03-13 15:27:01 +00:00
|
|
|
} else {
|
2001-01-08 22:08:40 +00:00
|
|
|
if (GST_IS_BIN (top)) {
|
GCC 4 fixen.
Original commit message from CVS:
2005-05-04 Andy Wingo <wingo@pobox.com>
* check/Makefile.am:
* docs/gst/tmpl/gstatomic.sgml:
* docs/gst/tmpl/gstplugin.sgml:
* gst/base/gstbasesink.c: (gst_basesink_activate):
* gst/base/gstbasesrc.c: (gst_basesrc_class_init),
(gst_basesrc_init), (gst_basesrc_set_dataflow_funcs),
(gst_basesrc_query), (gst_basesrc_set_property),
(gst_basesrc_get_property), (gst_basesrc_check_get_range),
(gst_basesrc_activate):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c: (gst_base_transform_sink_activate),
(gst_base_transform_src_activate):
* gst/elements/gstelements.c:
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init),
(gst_fakesrc_set_property), (gst_fakesrc_get_property):
* gst/elements/gsttee.c: (gst_tee_sink_activate):
* gst/elements/gsttypefindelement.c: (find_element_get_length),
(gst_type_find_element_checkgetrange),
(gst_type_find_element_activate):
* gst/gstbin.c: (gst_bin_save_thyself), (gst_bin_restore_thyself):
* gst/gstcaps.c: (gst_caps_do_simplify), (gst_caps_save_thyself),
(gst_caps_load_thyself):
* gst/gstelement.c: (gst_element_pads_activate),
(gst_element_save_thyself), (gst_element_restore_thyself):
* gst/gstpad.c: (gst_pad_load_and_link), (gst_pad_save_thyself),
(gst_ghost_pad_save_thyself), (gst_pad_check_pull_range):
* gst/gstpad.h:
* gst/gstxml.c: (gst_xml_write), (gst_xml_parse_doc),
(gst_xml_parse_file), (gst_xml_parse_memory),
(gst_xml_get_element), (gst_xml_make_element):
* gst/indexers/gstfileindex.c: (gst_file_index_load),
(_file_index_id_save_xml), (gst_file_index_commit):
* gst/registries/gstlibxmlregistry.c: (read_string), (read_uint),
(read_enum), (load_pad_template), (load_feature), (load_plugin),
(load_paths):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_caps),
(gst_dp_packet_from_event), (gst_dp_caps_from_packet):
* tools/gst-complete.c: (main):
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_element_properties_info):
* tools/gst-launch.c: (xmllaunch_parse_cmdline):
* tools/gst-xmlinspect.c: (print_element_properties):
GCC 4 fixen.
2005-05-04 21:29:44 +00:00
|
|
|
element = gst_bin_get_by_name (GST_BIN (top), (gchar *) name);
|
2001-01-08 22:08:40 +00:00
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
if (element)
|
|
|
|
return element;
|
2001-01-08 22:08:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
topelements = g_list_next (topelements);
|
|
|
|
}
|
|
|
|
return NULL;
|
2000-09-24 22:45:48 +00:00
|
|
|
}
|
2002-01-11 15:49:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_xml_make_element:
|
|
|
|
* @cur: the xml node
|
|
|
|
* @parent: the parent of this object when it's loaded
|
|
|
|
*
|
|
|
|
* Load the element from the XML description
|
|
|
|
*
|
|
|
|
* Returns: the new element
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GstElement *
|
|
|
|
gst_xml_make_element (xmlNodePtr cur, GstObject * parent)
|
2002-01-11 15:49:47 +00:00
|
|
|
{
|
|
|
|
xmlNodePtr children = cur->xmlChildrenNode;
|
|
|
|
GstElement *element;
|
GCC 4 fixen.
Original commit message from CVS:
2005-05-04 Andy Wingo <wingo@pobox.com>
* check/Makefile.am:
* docs/gst/tmpl/gstatomic.sgml:
* docs/gst/tmpl/gstplugin.sgml:
* gst/base/gstbasesink.c: (gst_basesink_activate):
* gst/base/gstbasesrc.c: (gst_basesrc_class_init),
(gst_basesrc_init), (gst_basesrc_set_dataflow_funcs),
(gst_basesrc_query), (gst_basesrc_set_property),
(gst_basesrc_get_property), (gst_basesrc_check_get_range),
(gst_basesrc_activate):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c: (gst_base_transform_sink_activate),
(gst_base_transform_src_activate):
* gst/elements/gstelements.c:
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init),
(gst_fakesrc_set_property), (gst_fakesrc_get_property):
* gst/elements/gsttee.c: (gst_tee_sink_activate):
* gst/elements/gsttypefindelement.c: (find_element_get_length),
(gst_type_find_element_checkgetrange),
(gst_type_find_element_activate):
* gst/gstbin.c: (gst_bin_save_thyself), (gst_bin_restore_thyself):
* gst/gstcaps.c: (gst_caps_do_simplify), (gst_caps_save_thyself),
(gst_caps_load_thyself):
* gst/gstelement.c: (gst_element_pads_activate),
(gst_element_save_thyself), (gst_element_restore_thyself):
* gst/gstpad.c: (gst_pad_load_and_link), (gst_pad_save_thyself),
(gst_ghost_pad_save_thyself), (gst_pad_check_pull_range):
* gst/gstpad.h:
* gst/gstxml.c: (gst_xml_write), (gst_xml_parse_doc),
(gst_xml_parse_file), (gst_xml_parse_memory),
(gst_xml_get_element), (gst_xml_make_element):
* gst/indexers/gstfileindex.c: (gst_file_index_load),
(_file_index_id_save_xml), (gst_file_index_commit):
* gst/registries/gstlibxmlregistry.c: (read_string), (read_uint),
(read_enum), (load_pad_template), (load_feature), (load_plugin),
(load_paths):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_caps),
(gst_dp_packet_from_event), (gst_dp_caps_from_packet):
* tools/gst-complete.c: (main):
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_element_properties_info):
* tools/gst-launch.c: (xmllaunch_parse_cmdline):
* tools/gst-xmlinspect.c: (print_element_properties):
GCC 4 fixen.
2005-05-04 21:29:44 +00:00
|
|
|
gchar *name = NULL;
|
|
|
|
gchar *type = NULL;
|
2002-01-11 15:49:47 +00:00
|
|
|
|
|
|
|
/* first get the needed tags to construct the element */
|
|
|
|
while (children) {
|
GCC 4 fixen.
Original commit message from CVS:
2005-05-04 Andy Wingo <wingo@pobox.com>
* check/Makefile.am:
* docs/gst/tmpl/gstatomic.sgml:
* docs/gst/tmpl/gstplugin.sgml:
* gst/base/gstbasesink.c: (gst_basesink_activate):
* gst/base/gstbasesrc.c: (gst_basesrc_class_init),
(gst_basesrc_init), (gst_basesrc_set_dataflow_funcs),
(gst_basesrc_query), (gst_basesrc_set_property),
(gst_basesrc_get_property), (gst_basesrc_check_get_range),
(gst_basesrc_activate):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c: (gst_base_transform_sink_activate),
(gst_base_transform_src_activate):
* gst/elements/gstelements.c:
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init),
(gst_fakesrc_set_property), (gst_fakesrc_get_property):
* gst/elements/gsttee.c: (gst_tee_sink_activate):
* gst/elements/gsttypefindelement.c: (find_element_get_length),
(gst_type_find_element_checkgetrange),
(gst_type_find_element_activate):
* gst/gstbin.c: (gst_bin_save_thyself), (gst_bin_restore_thyself):
* gst/gstcaps.c: (gst_caps_do_simplify), (gst_caps_save_thyself),
(gst_caps_load_thyself):
* gst/gstelement.c: (gst_element_pads_activate),
(gst_element_save_thyself), (gst_element_restore_thyself):
* gst/gstpad.c: (gst_pad_load_and_link), (gst_pad_save_thyself),
(gst_ghost_pad_save_thyself), (gst_pad_check_pull_range):
* gst/gstpad.h:
* gst/gstxml.c: (gst_xml_write), (gst_xml_parse_doc),
(gst_xml_parse_file), (gst_xml_parse_memory),
(gst_xml_get_element), (gst_xml_make_element):
* gst/indexers/gstfileindex.c: (gst_file_index_load),
(_file_index_id_save_xml), (gst_file_index_commit):
* gst/registries/gstlibxmlregistry.c: (read_string), (read_uint),
(read_enum), (load_pad_template), (load_feature), (load_plugin),
(load_paths):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_caps),
(gst_dp_packet_from_event), (gst_dp_caps_from_packet):
* tools/gst-complete.c: (main):
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_element_properties_info):
* tools/gst-launch.c: (xmllaunch_parse_cmdline):
* tools/gst-xmlinspect.c: (print_element_properties):
GCC 4 fixen.
2005-05-04 21:29:44 +00:00
|
|
|
if (!strcmp ((char *) children->name, "name")) {
|
|
|
|
name = (gchar *) xmlNodeGetContent (children);
|
|
|
|
} else if (!strcmp ((char *) children->name, "type")) {
|
|
|
|
type = (gchar *) xmlNodeGetContent (children);
|
2002-01-11 15:49:47 +00:00
|
|
|
}
|
|
|
|
children = children->next;
|
|
|
|
}
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
g_return_val_if_fail (type != NULL, NULL);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_CAT_INFO (GST_CAT_XML, "loading \"%s\" of type \"%s\"", name, type);
|
2002-01-11 15:49:47 +00:00
|
|
|
|
2002-04-11 20:35:18 +00:00
|
|
|
element = gst_element_factory_make (type, name);
|
2002-01-11 15:49:47 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (element != NULL, NULL);
|
|
|
|
|
2004-08-17 09:16:42 +00:00
|
|
|
g_free (type);
|
|
|
|
g_free (name);
|
|
|
|
|
2002-01-11 15:49:47 +00:00
|
|
|
/* ne need to set the parent on this object bacause the pads */
|
2003-01-08 22:45:46 +00:00
|
|
|
/* will go through the hierarchy to link to their peers */
|
2006-06-30 13:17:46 +00:00
|
|
|
if (parent) {
|
|
|
|
if (GST_IS_BIN (parent)) {
|
|
|
|
gst_bin_add (GST_BIN (parent), element);
|
|
|
|
} else {
|
|
|
|
gst_object_set_parent (GST_OBJECT (element), parent);
|
|
|
|
}
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-01-11 15:49:47 +00:00
|
|
|
gst_object_restore_thyself (GST_OBJECT (element), cur);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-01-11 15:49:47 +00:00
|
|
|
return element;
|
|
|
|
}
|