summaryrefslogtreecommitdiff
path: root/gst/gstxml.c
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2001-01-30 23:53:04 +0000
committerWim Taymans <wim.taymans@gmail.com>2001-01-30 23:53:04 +0000
commit1a5cfae0f635408e4d2e7d155ef90ecf4f45609a (patch)
treeded3dfe549c568126f2fc5ea61c1b02f767efb5f /gst/gstxml.c
parent6873d31fed213566cfa4230a017b5b76e2d6aaa2 (diff)
Added a first attempt for XML embedding in the main core XML.
Original commit message from CVS: Added a first attempt for XML embedding in the main core XML. Objects will emit a signal that a user app can connect to in order to insert its XML into the tree. You can catch the object_loaded signal in GstXML to parse the user supplied XML data in the stream. The object_loaded signal is implemented with a custom made class signal. All GstObject classes now automatically create a GstSignalObject that serves as a proxy to the user app when an object is loaded. All objects are currently responsible to emit the class signal themselves. runxml and createxml serve as an example how the XML hooks can be used to insert and retrieve custom XML tags.
Diffstat (limited to 'gst/gstxml.c')
-rw-r--r--gst/gstxml.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/gst/gstxml.c b/gst/gstxml.c
index 6f92516f7..876ecf70b 100644
--- a/gst/gstxml.c
+++ b/gst/gstxml.c
@@ -27,14 +27,14 @@
enum {
OBJECT_LOADED,
- OBJECT_SAVED,
LAST_SIGNAL
};
-
static void gst_xml_class_init (GstXMLClass *klass);
static void gst_xml_init (GstXML *xml);
+static void gst_xml_object_loaded (GstObject *private, GstObject *object, xmlNodePtr self, gpointer data);
+
static GstObjectClass *parent_class = NULL;
static guint gst_xml_signals[LAST_SIGNAL] = { 0 };
@@ -74,12 +74,6 @@ gst_xml_class_init (GstXMLClass *klass)
gtk_marshal_NONE__POINTER_POINTER, GTK_TYPE_NONE, 2,
GST_TYPE_OBJECT, GTK_TYPE_POINTER);
- gst_xml_signals[OBJECT_SAVED] =
- gtk_signal_new ("object_saved", GTK_RUN_LAST, gtkobject_class->type,
- GTK_SIGNAL_OFFSET (GstXMLClass, object_saved),
- gtk_marshal_NONE__POINTER_POINTER, GTK_TYPE_NONE, 2,
- GST_TYPE_OBJECT, GTK_TYPE_POINTER);
-
gtk_object_class_add_signals (gtkobject_class, gst_xml_signals, LAST_SIGNAL);
}
@@ -123,15 +117,15 @@ gst_xml_write (GstElement *element)
doc->xmlRootNode = xmlNewDocNode (doc, ns, "gstreamer", NULL);
- elementnode = xmlNewChild (doc->xmlRootNode, NULL, "element", NULL);
+ elementnode = xmlNewChild (doc->xmlRootNode, ns, "element", NULL);
gst_object_save_thyself (GST_OBJECT (element), elementnode);
return doc;
}
-static gboolean
-gst_xml_real_parse (GstXML *xml, xmlDocPtr doc, const guchar *root)
+gboolean
+gst_xml_parse_doc (GstXML *xml, xmlDocPtr doc, const guchar *root)
{
xmlNodePtr field, cur;
xmlNsPtr ns;
@@ -151,6 +145,9 @@ gst_xml_real_parse (GstXML *xml, xmlDocPtr doc, const guchar *root)
return FALSE;
}
+ gst_class_signal_connect (GST_OBJECT_CLASS (GTK_OBJECT (xml)->klass),
+ "object_loaded", gst_xml_object_loaded, xml);
+
xml->ns = ns;
field = cur->xmlChildrenNode;
@@ -200,7 +197,7 @@ gst_xml_parse_file (GstXML *xml, const guchar *fname, const guchar *root)
return FALSE;
}
- return gst_xml_real_parse (xml, doc, root);
+ return gst_xml_parse_doc (xml, doc, root);
}
/**
@@ -223,20 +220,18 @@ gst_xml_parse_memory (GstXML *xml, guchar *buffer, guint size, const gchar *root
doc = xmlParseMemory (buffer, size);
- return gst_xml_real_parse (xml, doc, root);
+ return gst_xml_parse_doc (xml, doc, root);
}
-void
-gst_xml_object_loaded (GstXML *xml, GstObject *object, xmlNodePtr self)
+static void
+gst_xml_object_loaded (GstObject *private, GstObject *object, xmlNodePtr self, gpointer data)
{
+ GstXML *xml = GST_XML (data);
+
+ // FIXME check that this element was created from the same xmlDocPtr...
gtk_signal_emit (GTK_OBJECT (xml), gst_xml_signals[OBJECT_LOADED], object, self);
}
-void
-gst_xml_object_saved (GstXML *xml, GstObject *object, xmlNodePtr self)
-{
- gtk_signal_emit (GTK_OBJECT (xml), gst_xml_signals[OBJECT_SAVED], object, self);
-}
/**
* gst_xml_get_topelements:
* @xml: The GstXML to get the elements from