2000-08-22 21:18:18 +00:00
|
|
|
<chapter id="cha-utility">
|
|
|
|
<title>Utility functions</title>
|
|
|
|
<para>
|
2001-07-07 11:34:54 +00:00
|
|
|
while you can use the regular g_object_getv () function to
|
2001-01-16 23:35:22 +00:00
|
|
|
query the value of an object property, <application>GStreamer</application>
|
|
|
|
provides some easy wrappers for this common operation.
|
2000-08-22 21:18:18 +00:00
|
|
|
</para>
|
2001-01-16 23:35:22 +00:00
|
|
|
<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;
|
2001-07-07 11:34:54 +00:00
|
|
|
g_object_getv (G_OBJECT (object), 1, &arg);
|
2001-01-16 23:35:22 +00:00
|
|
|
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>
|
2001-07-07 15:10:29 +00:00
|
|
|
<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>
|
|
|
|
|
2001-01-16 23:35:22 +00:00
|
|
|
<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>
|
2001-07-07 11:34:54 +00:00
|
|
|
void gst_util_dump_mem (guchar *mem, guint size);
|
2001-01-16 23:35:22 +00:00
|
|
|
</programlisting>
|
2000-08-22 21:18:18 +00:00
|
|
|
|
|
|
|
</chapter>
|