Some updates to the manual, mostly glib2 related.

Original commit message from CVS:
Some updates to the manual, mostly glib2 related.
This commit is contained in:
Wim Taymans 2001-07-07 11:34:54 +00:00
parent 5d2a56cd7c
commit 42297d86bd
14 changed files with 85 additions and 90 deletions

View file

@ -137,17 +137,17 @@
<programlisting> <programlisting>
// create the mp3player element // create the mp3player element
GstElement *mp3player = gst_elementfactory_make("mp3player","mp3player"); GstElement *mp3player = gst_elementfactory_make ("mp3player", "mp3player");
// set the source mp3 audio file // set the source mp3 audio file
gtk_object_set(GTK_OBJECT(mp3player), "location", "helloworld.mp3", NULL); g_object_set (G_OBJECT (mp3player), "location", "helloworld.mp3", NULL);
// start playback // start playback
gst_element_set_state(GST_ELEMENT(mp3player),GST_STATE_PLAYING); gst_element_set_state (GST_ELEMENT (mp3player), GST_STATE_PLAYING);
... ...
// pause playback // pause playback
gst_element_set_state(GST_ELEMENT(mp3player),GST_STATE_PAUSED); gst_element_set_state (GST_ELEMENT (mp3player), GST_STATE_PAUSED);
... ...
// stop // stop
gst_element_set_state(GST_ELEMENT(mp3player),GST_STATE_NULL); gst_element_set_state (GST_ELEMENT (mp3player), GST_STATE_NULL);
</programlisting> </programlisting>
Custom bins can be created with a plugin or an XML description. You will find more Custom bins can be created with a plugin or an XML description. You will find more

View file

@ -46,7 +46,7 @@ main(int argc, char *argv[])
src = gst_elementfactory_make ("disksrc", "src"); src = gst_elementfactory_make ("disksrc", "src");
g_return_val_if_fail (src != NULL, -1); g_return_val_if_fail (src != NULL, -1);
gtk_object_set (GTK_OBJECT (src), "location", argv[1], NULL); g_object_set (G_OBJECT (src), "location", argv[1], NULL);
parse = gst_elementfactory_make ("mpeg1parse", "parse"); parse = gst_elementfactory_make ("mpeg1parse", "parse");
g_return_val_if_fail (parse != NULL, -1); g_return_val_if_fail (parse != NULL, -1);
@ -54,11 +54,11 @@ main(int argc, char *argv[])
gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (src)); gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (src));
gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (parse)); gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (parse));
gtk_signal_connect (GTK_OBJECT (parse), "new_pad", g_signal_connectc (G_OBJECT (parse), "new_pad",
GTK_SIGNAL_FUNC (new_pad_created), pipeline); G_CALLBACK (new_pad_created), pipeline, FALSE);
gtk_signal_connect (GTK_OBJECT (src), "eos", g_signal_connectc (G_OBJECT (src), "eos",
GTK_SIGNAL_FUNC (eof), NULL); G_CALLBACK (eof), NULL, FALSE);
gst_pad_connect (gst_element_get_pad (src, "src"), gst_pad_connect (gst_element_get_pad (src, "src"),
gst_element_get_pad (parse, "sink")); gst_element_get_pad (parse, "sink"));
@ -83,8 +83,8 @@ main(int argc, char *argv[])
'new_pad' that we connected to the mpeg1parser using: 'new_pad' that we connected to the mpeg1parser using:
</para> </para>
<programlisting> <programlisting>
gtk_signal_connect (GTK_OBJECT (parse), "new_pad", g_signal_connectc (G_OBJECT (parse), "new_pad",
GTK_SIGNAL_FUNC (new_pad_created), pipeline); G_CALLBACK (new_pad_created), pipeline, FALSE);
</programlisting> </programlisting>
<para> <para>
When an elementary stream has been detected in the system stream, When an elementary stream has been detected in the system stream,
@ -191,7 +191,7 @@ new_pad_created (GstElement *parse, GstPad *pad, GstElement *pipeline)
gst_element_get_pad (video_thread, "sink")); gst_element_get_pad (video_thread, "sink"));
// set up thread state and kick things off // set up thread state and kick things off
gtk_object_set (GTK_OBJECT (video_thread), "create_thread", TRUE, NULL); g_object_set (G_OBJECT (video_thread), "create_thread", TRUE, NULL);
g_print ("setting to READY state\n"); g_print ("setting to READY state\n");
gst_element_set_state (GST_ELEMENT (video_thread), GST_STATE_READY); gst_element_set_state (GST_ELEMENT (video_thread), GST_STATE_READY);
} }

View file

@ -21,8 +21,8 @@
<programlisting> <programlisting>
... ...
/* now it's time to get the parser */ /* now it's time to get the parser */
parse = gst_elementfactory_make("mp3parse","parse"); parse = gst_elementfactory_make ("mp3parse", "parse");
decoder = gst_elementfactory_make("mpg123","decoder"); decoder = gst_elementfactory_make ("mpg123", "decoder");
... ...
</programlisting> </programlisting>
@ -158,7 +158,7 @@ struct _GstType {
<programlisting> <programlisting>
guint16 id; guint16 id;
id = gst_type_find_by_mime("audio/mpeg"); id = gst_type_find_by_mime ("audio/mpeg");
</programlisting> </programlisting>
<para> <para>
This function will return 0 if the type was not known. This function will return 0 if the type was not known.
@ -174,7 +174,7 @@ struct _GstType {
<programlisting> <programlisting>
GstType *type; GstType *type;
type = gst_type_find_by_id(id); type = gst_type_find_by_id (id);
</programlisting> </programlisting>
<para> <para>
This function will return NULL if the id was associated with This function will return NULL if the id was associated with
@ -191,7 +191,7 @@ struct _GstType {
<programlisting> <programlisting>
guint16 id; guint16 id;
id = gst_type_find_by_ext(".mp3"); id = gst_type_find_by_ext (".mp3");
</programlisting> </programlisting>
<para> <para>
This function will return 0 if the extension was not known. This function will return 0 if the extension was not known.
@ -211,7 +211,7 @@ struct _GstType {
<programlisting> <programlisting>
GList *list; GList *list;
list = gst_type_gst_srcs(id); list = gst_type_gst_srcs (id);
</programlisting> </programlisting>
<para> <para>
@ -220,7 +220,7 @@ struct _GstType {
<programlisting> <programlisting>
GList *list; GList *list;
list = gst_type_gst_sinks(id); list = gst_type_gst_sinks (id);
</programlisting> </programlisting>
<para> <para>
When you have a list of elements, you can simply take the first When you have a list of elements, you can simply take the first
@ -269,7 +269,7 @@ struct _GstType {
<programlisting> <programlisting>
GList *list; GList *list;
list = gst_type_gst_sink_to_src(sourceid, sinkid); list = gst_type_gst_sink_to_src (sourceid, sinkid);
</programlisting> </programlisting>
<para> <para>
This piece of code will give you the elements needed to construct This piece of code will give you the elements needed to construct
@ -293,7 +293,7 @@ struct _GstType {
// obtain the factory // obtain the factory
factory = ... factory = ...
element = gst_elementfactory_create(factory, "name"); element = gst_elementfactory_create (factory, "name");
</programlisting> </programlisting>
<para> <para>
This way, you do not have to create elements by name which This way, you do not have to create elements by name which

View file

@ -38,8 +38,8 @@
<sect2 id="sec-goals-object"> <sect2 id="sec-goals-object">
<title>Object oriented</title> <title>Object oriented</title>
<para> <para>
Adhere as much as possible to the GTK+ object model. A programmer familiar Adhere as much as possible to the glib2.0 object model. A programmer familiar
with GTK+ will be confortable with GStreamer. with glib2 and GTK+ will be confortable with GStreamer.
</para> </para>
<para> <para>
GStreamer uses the mechanism of signals and object arguments. GStreamer uses the mechanism of signals and object arguments.
@ -53,7 +53,7 @@
<sect2 id="sec-goals-extensible"> <sect2 id="sec-goals-extensible">
<title>Extensible</title> <title>Extensible</title>
<para> <para>
All GStreamer Objects can be extended using the GTK+ inheritance methods. All GStreamer Objects can be extended using the glib2 inheritance methods.
</para> </para>
<para> <para>
All plugins are loaded dynamically and can be extended and upgraded All plugins are loaded dynamically and can be extended and upgraded
@ -65,7 +65,7 @@
<title>Allow binary only plugins</title> <title>Allow binary only plugins</title>
<para> <para>
plugins are shared libraries that are loaded at runtime. since all the plugins are shared libraries that are loaded at runtime. since all the
properties of the plugin can be set using the GtkObject arguments, there properties of the plugin can be set using the GObject properties, there
is no need to have any header files installed for the plugins. is no need to have any header files installed for the plugins.
</para> </para>
<para> <para>

View file

@ -67,8 +67,8 @@
The first chapter of the book gives you an overview of <application>GStreamer</application> The first chapter of the book gives you an overview of <application>GStreamer</application>
design goals. Chapter 2 rapidly covers the basics of <application>GStreamer</application> design goals. Chapter 2 rapidly covers the basics of <application>GStreamer</application>
programming. In chapter 3 we will move on to the examples. programming. In chapter 3 we will move on to the examples.
Since <application>GStreamer</application> adheres to the GTK+ programming model, the reader is Since <application>GStreamer</application> adheres to the GTK+/glib2 programming model, the reader is
assumed to understand the basics of GTK+. assumed to understand the basics of GTK+ and the glib2.0 object model.
For a gentle introduction to GTK+, you may wish to read the <emphasis>GTK+ For a gentle introduction to GTK+, you may wish to read the <emphasis>GTK+
Tutorial</emphasis> or Eric Harlow's book <emphasis>Developing Linux Tutorial</emphasis> or Eric Harlow's book <emphasis>Developing Linux
Applications with GTK+ and GDK</emphasis>. Applications with GTK+ and GDK</emphasis>.

View file

@ -36,7 +36,7 @@ main (int argc, char *argv[])
/* create a disk reader */ /* create a disk reader */
disksrc = gst_elementfactory_make ("disksrc", "disk_source"); disksrc = gst_elementfactory_make ("disksrc", "disk_source");
gtk_object_set (GTK_OBJECT (disksrc),"location", argv[1], NULL); g_object_set (G_OBJECT (disksrc), "location", argv[1], NULL);
/* now it's time to get the parser */ /* now it's time to get the parser */
parse = gst_elementfactory_make ("mp3parse", "parse"); parse = gst_elementfactory_make ("mp3parse", "parse");
@ -127,13 +127,13 @@ main (int argc, char *argv[])
<para> <para>
We then create a disk source element. The disk source element is able to We then create a disk source element. The disk source element is able to
read from a file. We use the standard GTK+ argument mechanism to set read from a file. We use the standard GObject property mechanism to set
a property of the element: the file to read from. a property of the element: the file to read from.
</para> </para>
<programlisting> <programlisting>
/* create a disk reader */ /* create a disk reader */
disksrc = gst_elementfactory_make ("disksrc", "disk_source"); disksrc = gst_elementfactory_make ("disksrc", "disk_source");
gtk_object_set (GTK_OBJECT (disksrc),"location", argv[1], NULL); g_object_set (G_OBJECT (disksrc), "location", argv[1], NULL);
</programlisting> </programlisting>
<note> <note>
<para> <para>

View file

@ -52,9 +52,9 @@ main (int argc, char *argv[])
/* create a disk reader */ /* create a disk reader */
disksrc = gst_elementfactory_make ("disksrc", "disk_source"); disksrc = gst_elementfactory_make ("disksrc", "disk_source");
gtk_object_set (GTK_OBJECT (disksrc), "location", argv[1], NULL); g_object_set (G_OBJECT (disksrc), "location", argv[1], NULL);
gtk_signal_connect (GTK_OBJECT (disksrc), "eos", g_signal_connectc (G_OBJECT (disksrc), "eos",
GTK_SIGNAL_FUNC (eos), NULL); G_CALLBACK (eos), NULL, FALSE);
/* and an audio sink */ /* and an audio sink */
audiosink = gst_elementfactory_make ("audiosink", "play_audio"); audiosink = gst_elementfactory_make ("audiosink", "play_audio");

View file

@ -105,7 +105,7 @@ main(int argc, char *argv[])
... ...
mpeg2parser = gst_elementfactory_make ("mpeg2parse", "mpeg2parse"); mpeg2parser = gst_elementfactory_make ("mpeg2parse", "mpeg2parse");
gtk_signal_connect (GTK_OBJECT (mpeg2parser), "new_pad", pad_connect_func, pipeline); g_signal_connectc (G_OBJECT (mpeg2parser), "new_pad", pad_connect_func, pipeline, FALSE);
... ...
// start the pipeline // start the pipeline
@ -411,7 +411,7 @@ GstProps* gst_props_new (const gchar *firstname, ...);
</para> </para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
All of the above values can be given with a list too using: All of the above values can be given with a list too, using:
<itemizedlist> <itemizedlist>
<listitem> <listitem>
<para> <para>

View file

@ -117,29 +117,29 @@ video_00! (mpeg2dec ! videosink)
#include &lt;stdlib.h&gt; #include &lt;stdlib.h&gt;
int int
main(int argc, char *argv[]) main (int argc, char *argv[])
{ {
GstElement *pipeline; GstElement *pipeline;
char **argvn; char **argvn;
gchar *cmdline; gchar *cmdline;
int i; int i;
gst_init(&amp;argc,&amp;argv); gst_init (&amp;argc, &amp;argv);
pipeline = gst_pipeline_new("launch"); pipeline = gst_pipeline_new ("launch");
// make a null-terminated version of argv // make a null-terminated version of argv
argvn = g_new0(char *,argc); argvn = g_new0 (char *,argc);
memcpy(argvn,argv+1,sizeof(char*)*(argc-1)); memcpy (argvn, argv+1, sizeof (char*) * (argc-1));
// join the argvs together // join the argvs together
cmdline = g_strjoinv(" ",argvn); cmdline = g_strjoinv (" ", argvn);
// free the null-terminated argv // free the null-terminated argv
g_free(argvn); g_free (argvn);
gst_parse_launch(cmdline,pipeline); gst_parse_launch (cmdline, pipeline);
fprintf(stderr,"RUNNING pipeline\n"); fprintf(stderr,"RUNNING pipeline\n");
gst_element_set_state(pipeline,GST_STATE_PLAYING); gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (1) while (1)
gst_bin_iterate (GST_BIN (pipeline)); gst_bin_iterate (GST_BIN (pipeline));

View file

@ -29,11 +29,11 @@
<para> <para>
The standard <application>GStreamer</application> queue implementation has some The standard <application>GStreamer</application> queue implementation has some
properties that can be changed using the gtk_objet_set () method. To set the properties that can be changed using the g_objet_set () method. To set the
maximum number of buffers that can be queued to 30, do: maximum number of buffers that can be queued to 30, do:
</para> </para>
<programlisting> <programlisting>
gtk_object_set (GTK_OBJECT (queue), "max_level", 30, NULL); g_object_set (G_OBJECT (queue), "max_level", 30, NULL);
</programlisting> </programlisting>
<para> <para>
@ -81,9 +81,9 @@ main (int argc, char *argv[])
/* create a disk reader */ /* create a disk reader */
disksrc = gst_elementfactory_make ("disksrc", "disk_source"); disksrc = gst_elementfactory_make ("disksrc", "disk_source");
g_assert (disksrc != NULL); g_assert (disksrc != NULL);
gtk_object_set (GTK_OBJECT (disksrc), "location", argv[1], NULL); g_object_set (G_OBJECT (disksrc), "location", argv[1], NULL);
gtk_signal_connect (GTK_OBJECT (disksrc), "eos", g_signal_connectc (G_OBJECT (disksrc), "eos",
GTK_SIGNAL_FUNC (eos), thread); G_CALLBACK (eos), thread, FALSE);
queue = gst_elementfactory_make ("queue", "queue"); queue = gst_elementfactory_make ("queue", "queue");
@ -114,8 +114,6 @@ main (int argc, char *argv[])
gst_bin_add (GST_BIN (bin), thread); gst_bin_add (GST_BIN (bin), thread);
/* make it ready */
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY);
/* start playing */ /* start playing */
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING); gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);

View file

@ -94,9 +94,9 @@ main (int argc, char *argv[])
/* create a disk reader */ /* create a disk reader */
disksrc = gst_elementfactory_make ("disksrc", "disk_source"); disksrc = gst_elementfactory_make ("disksrc", "disk_source");
g_assert (disksrc != NULL); g_assert (disksrc != NULL);
gtk_object_set (GTK_OBJECT (disksrc), "location", argv[1], NULL); g_object_set (G_OBJECT (disksrc), "location", argv[1], NULL);
gtk_signal_connect (GTK_OBJECT (disksrc), "eos", g_signal_connectc (G_OBJECT (disksrc), "eos",
GTK_SIGNAL_FUNC (eos), thread); G_CALLBACK (eos), thread, FALSE);
/* and an audio sink */ /* and an audio sink */
audiosink = gst_elementfactory_make ("audiosink", "play_audio"); audiosink = gst_elementfactory_make ("audiosink", "play_audio");

View file

@ -61,44 +61,44 @@ main(int argc, char *argv[])
{ {
GstElement *bin, *disksrc, *typefind; GstElement *bin, *disksrc, *typefind;
gst_init(&amp;argc,&amp;argv); gst_init (&amp;argc, &amp;argv);
if (argc != 2) { if (argc != 2) {
g_print("usage: &percnt;s &lt;filename&gt;\n", argv[0]); g_print ("usage: &percnt;s &lt;filename&gt;\n", argv[0]);
exit(-1); exit (-1);
} }
/* create a new bin to hold the elements */ /* create a new bin to hold the elements */
bin = gst_bin_new("bin"); bin = gst_bin_new ("bin");
g_assert(bin != NULL); g_assert (bin != NULL);
/* create a disk reader */ /* create a disk reader */
disksrc = gst_elementfactory_make("disksrc", "disk_source"); disksrc = gst_elementfactory_make ("disksrc", "disk_source");
g_assert(disksrc != NULL); g_assert (disksrc != NULL);
gtk_object_set(GTK_OBJECT(disksrc),"location", argv[1],NULL); g_object_set (G_OBJECT (disksrc), "location", argv[1], NULL);
/* create the typefind element */ /* create the typefind element */
typefind = gst_elementfactory_make("typefind", "typefind"); typefind = gst_elementfactory_make ("typefind", "typefind");
g_assert(typefind != NULL); g_assert (typefind != NULL);
/* add objects to the main pipeline */ /* add objects to the main pipeline */
gst_bin_add(GST_BIN(bin), disksrc); gst_bin_add (GST_BIN (bin), disksrc);
gst_bin_add(GST_BIN(bin), typefind); gst_bin_add (GST_BIN (bin), typefind);
gtk_signal_connect (GTK_OBJECT (typefind), "have_type", g_signal_connectc (G_OBJECT (typefind), "have_type",
type_found, NULL); G_CALLBACK (type_found), NULL, FALSE);
gst_pad_connect(gst_element_get_pad(disksrc,"src"), gst_pad_connect (gst_element_get_pad (disksrc, "src"),
gst_element_get_pad(typefind,"sink")); gst_element_get_pad (typefind, "sink"));
/* start playing */ /* start playing */
gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING); gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
gst_bin_iterate(GST_BIN(bin)); gst_bin_iterate (GST_BIN (bin));
gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL); gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
exit(0); exit (0);
} }
</programlisting> </programlisting>
<para> <para>

View file

@ -1,7 +1,7 @@
<chapter id="cha-utility"> <chapter id="cha-utility">
<title>Utility functions</title> <title>Utility functions</title>
<para> <para>
while you can use the regular gtk_object_getv () function to while you can use the regular g_object_getv () function to
query the value of an object property, <application>GStreamer</application> query the value of an object property, <application>GStreamer</application>
provides some easy wrappers for this common operation. provides some easy wrappers for this common operation.
</para> </para>
@ -14,7 +14,7 @@
guchar *value; guchar *value;
arg.name = argname; arg.name = argname;
gtk_object_getv (GTK_OBJECT (object), 1, &amp;arg); g_object_getv (G_OBJECT (object), 1, &amp;arg);
value = GTK_VALUE_STRING (arg); value = GTK_VALUE_STRING (arg);
</programlisting> </programlisting>
<para> <para>
@ -61,11 +61,6 @@
gpointer: with gst_util_get_pointer_arg (); gpointer: with gst_util_get_pointer_arg ();
</para> </para>
</listitem> </listitem>
<listitem>
<para>
GtkWidget*: with gst_util_get_widget_arg ();
</para>
</listitem>
</itemizedlist> </itemizedlist>
</para> </para>
<para> <para>
@ -75,7 +70,7 @@
to by mem. to by mem.
</para> </para>
<programlisting> <programlisting>
void gst_util_dump_mem(guchar *mem, guint size); void gst_util_dump_mem (guchar *mem, guint size);
</programlisting> </programlisting>
</chapter> </chapter>

View file

@ -55,7 +55,7 @@ main (int argc, char *argv[])
/* create a disk reader */ /* create a disk reader */
disksrc = gst_elementfactory_make ("disksrc", "disk_source"); disksrc = gst_elementfactory_make ("disksrc", "disk_source");
g_assert (disksrc != NULL); g_assert (disksrc != NULL);
gtk_object_set (GTK_OBJECT (disksrc), "location", argv[1], NULL); g_object_set (G_OBJECT (disksrc), "location", argv[1], NULL);
queue = gst_elementfactory_make ("queue", "queue"); queue = gst_elementfactory_make ("queue", "queue");
queue2 = gst_elementfactory_make ("queue", "queue2"); queue2 = gst_elementfactory_make ("queue", "queue2");
@ -195,8 +195,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_elementfactory_make("thread", "thread"); thread = gst_elementfactory_make ("thread", "thread");
gtk_signal_connect (GTK_OBJECT (thread), "object_saved", object_saved, g_strdup ("decoder thread")); g_signal_connectc (G_OBJECT (thread), "object_saved",
G_CALLBACK (object_saved), g_strdup ("decoder thread"), FALSE);
... ...
</programlisting> </programlisting>
<para> <para>
@ -209,8 +210,8 @@ object_saved (GstObject *object, xmlNodePtr parent, gpointer data)
{ {
xmlNodePtr child; xmlNodePtr child;
child = xmlNewChild(parent, ns, "comment", NULL); child = xmlNewChild (parent, ns, "comment", NULL);
xmlNewChild(child, ns, "text", (gchar *)data); xmlNewChild (child, ns, "text", (gchar *)data);
} }
</programlisting> </programlisting>
<para> <para>
@ -245,9 +246,10 @@ object_saved (GstObject *object, xmlNodePtr parent, gpointer data)
<programlisting> <programlisting>
xml = gst_xml_new (); xml = gst_xml_new ();
gtk_signal_connect (GTK_OBJECT (xml), "object_loaded", xml_loaded, xml); g_signal_connectc (G_OBJECT (xml), "object_loaded",
G_CALLBACK (xml_loaded), xml);
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);
</programlisting> </programlisting>