mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-16 05:16:36 +00:00
d2c3b2087d
Original commit message from CVS: conversion to docbook-xml. i don't have to ask that this be testing, because not ionly is it perfect, but i'm sure you folks will learn that on your own :-)
90 lines
2.5 KiB
XML
90 lines
2.5 KiB
XML
<chapter id="cha-utility">
|
|
<title>Utility functions</title>
|
|
<para>
|
|
while you can use the regular g_object_getv () function to
|
|
query the value of an object property, <application>GStreamer</application>
|
|
provides some easy wrappers for this common operation.
|
|
</para>
|
|
<para>
|
|
Instead of writing the following Gtk+ code to query the GTK_STRING value
|
|
of an object:
|
|
</para>
|
|
<programlisting>
|
|
GtkArg arg;
|
|
guchar *value;
|
|
|
|
arg.name = argname;
|
|
g_object_getv (G_OBJECT (object), 1, &arg);
|
|
value = GTK_VALUE_STRING (arg);
|
|
</programlisting>
|
|
<para>
|
|
You can also use:
|
|
</para>
|
|
<programlisting>
|
|
value = gst_util_get_string_arg (object, argname);
|
|
</programlisting>
|
|
<para>
|
|
These convenience functions exist for the following types:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
gint: with gst_util_get_int_arg ();
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
gboolean: with gst_util_get_bool_arg ();
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
glong: with gst_util_get_long_arg ();
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
gfloat: with gst_util_get_float_arg ();
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
gdouble: with gst_util_get_double_arg ();
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
guchar*: with gst_util_get_string_arg ();
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
gpointer: with gst_util_get_pointer_arg ();
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
<para>
|
|
One usually sets object properties using g_object_set (). The problem with this
|
|
method is that you need to know the type of the property. A convenience function,
|
|
gst_utils_set_object_arg () is therefore provided so that you can always set
|
|
the property with a string value. for example:
|
|
</para>
|
|
<programlisting>
|
|
gst_util_set_object_arg (someobject, "int_property", "1000");
|
|
</programlisting>
|
|
<para>
|
|
Will do The Right Thing(tm), converting the string to the type of the property when
|
|
needed.
|
|
</para>
|
|
|
|
<para>
|
|
There is also another utility function that can be used to dump a block
|
|
of memory on the console. This function is very usefull for plugin
|
|
developers. The function will dump size bytes of the memory pointed
|
|
to by mem.
|
|
</para>
|
|
<programlisting>
|
|
void gst_util_dump_mem (guchar *mem, guint size);
|
|
</programlisting>
|
|
|
|
</chapter>
|