mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-15 22:01:27 +00:00
1a5cfae0f6
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.
58 lines
1.2 KiB
C
58 lines
1.2 KiB
C
#include <stdlib.h>
|
|
#include <gst/gst.h>
|
|
|
|
gboolean playing;
|
|
|
|
static void
|
|
xml_loaded (GstXML *xml, GstObject *object, xmlNodePtr self, gpointer data)
|
|
{
|
|
xmlNodePtr children = self->xmlChildrenNode;
|
|
|
|
while (children) {
|
|
if (!strcmp (children->name, "comment")) {
|
|
xmlNodePtr nodes = children->xmlChildrenNode;
|
|
|
|
while (nodes) {
|
|
if (!strcmp (nodes->name, "text")) {
|
|
gchar *name = g_strdup (xmlNodeGetContent (nodes));
|
|
g_print ("object %s loaded with comment '%s'\n",
|
|
gst_object_get_name (object), name);
|
|
}
|
|
nodes = nodes->next;
|
|
}
|
|
}
|
|
children = children->next;
|
|
}
|
|
}
|
|
|
|
int main(int argc,char *argv[])
|
|
{
|
|
GstXML *xml;
|
|
GstElement *bin;
|
|
gboolean ret;
|
|
|
|
gst_init(&argc,&argv);
|
|
|
|
xml = gst_xml_new ();
|
|
|
|
//g_print ("%p\n", xml);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (xml), "object_loaded", xml_loaded, xml);
|
|
|
|
ret = gst_xml_parse_file(xml, "xmlTest.gst", NULL);
|
|
g_assert (ret == TRUE);
|
|
|
|
bin = gst_xml_get_element(xml, "bin");
|
|
g_assert (bin != NULL);
|
|
|
|
gst_element_set_state(bin, GST_STATE_PLAYING);
|
|
|
|
playing = TRUE;
|
|
|
|
while (gst_bin_iterate(GST_BIN(bin)));
|
|
|
|
gst_element_set_state(bin, GST_STATE_NULL);
|
|
|
|
exit(0);
|
|
}
|
|
|