mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
docs/manual/highlevel-xml.xml: Fix XML example code. Fixes #472714.
Original commit message from CVS: * docs/manual/highlevel-xml.xml: Fix XML example code. Fixes #472714.
This commit is contained in:
parent
851eaad606
commit
d845f192ae
2 changed files with 32 additions and 46 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2007-09-05 Wim Taymans <wim.taymans@gmail.com>
|
||||||
|
|
||||||
|
* docs/manual/highlevel-xml.xml:
|
||||||
|
Fix XML example code. Fixes #472714.
|
||||||
|
|
||||||
2007-09-05 Wim Taymans <wim.taymans@gmail.com>
|
2007-09-05 Wim Taymans <wim.taymans@gmail.com>
|
||||||
|
|
||||||
* libs/gst/base/gstbasesink.c: (gst_base_sink_preroll_queue_flush),
|
* libs/gst/base/gstbasesink.c: (gst_base_sink_preroll_queue_flush),
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
<chapter id="chapter-xml">
|
<chapter id="chapter-xml">
|
||||||
<title>XML in <application>GStreamer</application></title>
|
<title>XML in <application>GStreamer</application></title>
|
||||||
<para>
|
<para>
|
||||||
<application>GStreamer</application> uses XML to store and load
|
<application>GStreamer</application> can use XML to store and load
|
||||||
its pipeline definitions. XML is also used internally to manage the
|
its pipeline definitions.
|
||||||
plugin registry. The plugin registry is a file that contains the definition
|
|
||||||
of all the plugins <application>GStreamer</application> knows about to have
|
|
||||||
quick access to the specifics of the plugins.
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
@ -19,7 +16,7 @@
|
||||||
<para>
|
<para>
|
||||||
We create a simple pipeline and write it to stdout with
|
We create a simple pipeline and write it to stdout with
|
||||||
gst_xml_write_file (). The following code constructs an MP3 player
|
gst_xml_write_file (). The following code constructs an MP3 player
|
||||||
pipeline with two threads and then writes out the XML both to stdout
|
pipeline and then writes out the XML both to stdout
|
||||||
and to a file. Use this program with one argument: the MP3 file on disk.
|
and to a file. Use this program with one argument: the MP3 file on disk.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
@ -33,9 +30,8 @@ gboolean playing;
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
GstElement *filesrc, *osssink, *queue, *queue2, *decode;
|
GstElement *filesrc, *osssink, *decode;
|
||||||
GstElement *bin;
|
GstElement *pipeline;
|
||||||
GstElement *thread, *thread2;
|
|
||||||
|
|
||||||
gst_init (&argc,&argv);
|
gst_init (&argc,&argv);
|
||||||
|
|
||||||
|
@ -44,24 +40,15 @@ main (int argc, char *argv[])
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a new thread to hold the elements */
|
/* create a new pipeline to hold the elements */
|
||||||
thread = gst_element_factory_make ("thread", "thread");
|
pipeline = gst_element_factory_make ("pipeline", "pipeline");
|
||||||
g_assert (thread != NULL);
|
g_assert (pipeline != NULL);
|
||||||
thread2 = gst_element_factory_make ("thread", "thread2");
|
|
||||||
g_assert (thread2 != NULL);
|
|
||||||
|
|
||||||
/* create a new bin to hold the elements */
|
|
||||||
bin = gst_bin_new ("bin");
|
|
||||||
g_assert (bin != NULL);
|
|
||||||
|
|
||||||
/* create a disk reader */
|
/* create a disk reader */
|
||||||
filesrc = gst_element_factory_make ("filesrc", "disk_source");
|
filesrc = gst_element_factory_make ("filesrc", "disk_source");
|
||||||
g_assert (filesrc != NULL);
|
g_assert (filesrc != NULL);
|
||||||
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
|
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
|
||||||
|
|
||||||
queue = gst_element_factory_make ("queue", "queue");
|
|
||||||
queue2 = gst_element_factory_make ("queue", "queue2");
|
|
||||||
|
|
||||||
/* and an audio sink */
|
/* and an audio sink */
|
||||||
osssink = gst_element_factory_make ("osssink", "play_audio");
|
osssink = gst_element_factory_make ("osssink", "play_audio");
|
||||||
g_assert (osssink != NULL);
|
g_assert (osssink != NULL);
|
||||||
|
@ -69,22 +56,16 @@ main (int argc, char *argv[])
|
||||||
decode = gst_element_factory_make ("mad", "decode");
|
decode = gst_element_factory_make ("mad", "decode");
|
||||||
g_assert (decode != NULL);
|
g_assert (decode != NULL);
|
||||||
|
|
||||||
/* add objects to the main bin */
|
/* add objects to the main pipeline */
|
||||||
gst_bin_add_many (GST_BIN (bin), filesrc, queue, NULL);
|
gst_bin_add_many (GST_BIN (pipeline), filesrc, decode, osssink, NULL);
|
||||||
|
|
||||||
gst_bin_add_many (GST_BIN (thread), decode, queue2, NULL);
|
gst_element_link_many (filesrc, decode, osssink, NULL);
|
||||||
|
|
||||||
gst_bin_add (GST_BIN (thread2), osssink);
|
/* write the pipeline to stdout */
|
||||||
|
gst_xml_write_file (GST_ELEMENT (pipeline), stdout);
|
||||||
gst_element_link_many (filesrc, queue, decode, queue2, osssink, NULL);
|
|
||||||
|
|
||||||
gst_bin_add_many (GST_BIN (bin), thread, thread2, NULL);
|
|
||||||
|
|
||||||
/* write the bin to stdout */
|
|
||||||
gst_xml_write_file (GST_ELEMENT (bin), stdout);
|
|
||||||
|
|
||||||
/* write the bin to a file */
|
/* write the bin to a file */
|
||||||
gst_xml_write_file (GST_ELEMENT (bin), fopen ("xmlTest.gst", "w"));
|
gst_xml_write_file (GST_ELEMENT (pipeline), fopen ("xmlTest.gst", "w"));
|
||||||
|
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
@ -94,7 +75,7 @@ main (int argc, char *argv[])
|
||||||
The most important line is:
|
The most important line is:
|
||||||
</para>
|
</para>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
gst_xml_write_file (GST_ELEMENT (bin), stdout);
|
gst_xml_write_file (GST_ELEMENT (pipeline), stdout);
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
gst_xml_write_file () will turn the given element into an xmlDocPtr that
|
gst_xml_write_file () will turn the given element into an xmlDocPtr that
|
||||||
|
@ -125,7 +106,7 @@ int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
GstXML *xml;
|
GstXML *xml;
|
||||||
GstElement *bin;
|
GstElement *pipeline;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
gst_init (&argc, &argv);
|
gst_init (&argc, &argv);
|
||||||
|
@ -135,14 +116,14 @@ main(int argc, char *argv[])
|
||||||
ret = gst_xml_parse_file(xml, "xmlTest.gst", NULL);
|
ret = gst_xml_parse_file(xml, "xmlTest.gst", NULL);
|
||||||
g_assert (ret == TRUE);
|
g_assert (ret == TRUE);
|
||||||
|
|
||||||
bin = gst_xml_get_element (xml, "bin");
|
pipeline = gst_xml_get_element (xml, "pipeline");
|
||||||
g_assert (bin != NULL);
|
g_assert (pipeline != NULL);
|
||||||
|
|
||||||
gst_element_set_state (bin, GST_STATE_PLAYING);
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
|
|
||||||
while (gst_bin_iterate(GST_BIN(bin)));
|
g_sleep (4);
|
||||||
|
|
||||||
gst_element_set_state (bin, GST_STATE_NULL);
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
|
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
@ -186,9 +167,9 @@ xmlNsPtr ns;
|
||||||
...
|
...
|
||||||
ns = xmlNewNs (NULL, "http://gstreamer.net/gst-test/1.0/", "test");
|
ns = xmlNewNs (NULL, "http://gstreamer.net/gst-test/1.0/", "test");
|
||||||
...
|
...
|
||||||
thread = gst_element_factory_make ("thread", "thread");
|
pipeline = gst_element_factory_make ("pipeline", "pipeline");
|
||||||
g_signal_connect (G_OBJECT (thread), "object_saved",
|
g_signal_connect (G_OBJECT (pipeline), "object_saved",
|
||||||
G_CALLBACK (object_saved), g_strdup ("decoder thread"));
|
G_CALLBACK (object_saved), g_strdup ("decoder pipeline"));
|
||||||
...
|
...
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
|
@ -212,13 +193,13 @@ object_saved (GstObject *object, xmlNodePtr parent, gpointer data)
|
||||||
<programlisting>
|
<programlisting>
|
||||||
...
|
...
|
||||||
<gst:element>
|
<gst:element>
|
||||||
<gst:name>thread</gst:name>
|
<gst:name>pipeline</gst:name>
|
||||||
<gst:type>thread</gst:type>
|
<gst:type>pipeline</gst:type>
|
||||||
<gst:version>0.1.0</gst:version>
|
<gst:version>0.1.0</gst:version>
|
||||||
...
|
...
|
||||||
</gst:children>
|
</gst:children>
|
||||||
<test:comment>
|
<test:comment>
|
||||||
<test:text>decoder thread</test:text>
|
<test:text>decoder pipeline</test:text>
|
||||||
</test:comment>
|
</test:comment>
|
||||||
</gst:element>
|
</gst:element>
|
||||||
...
|
...
|
||||||
|
|
Loading…
Reference in a new issue