2002-09-27 18:34:33 +00:00
|
|
|
|
|
|
|
<!-- ############ chapter ############# -->
|
|
|
|
|
2004-01-28 15:51:14 +00:00
|
|
|
<chapter id="chapter-dparams">
|
2002-09-27 18:34:33 +00:00
|
|
|
<title>Supporting Dynamic Parameters</title>
|
2012-09-28 14:03:15 +00:00
|
|
|
<para>
|
|
|
|
Warning, this part describes 0.10 and is outdated.
|
|
|
|
</para>
|
2002-09-27 18:34:33 +00:00
|
|
|
<para>
|
|
|
|
Sometimes object properties are not powerful enough to control the
|
2006-01-31 16:56:28 +00:00
|
|
|
parameters that affect the behaviour of your element.
|
2010-02-08 03:42:01 +00:00
|
|
|
When this is the case you can mark these parameters as being Controllable.
|
|
|
|
Aware applications can use the controller subsystem to dynamically adjust
|
2006-01-31 16:56:28 +00:00
|
|
|
the property values over time.
|
2002-09-27 18:34:33 +00:00
|
|
|
</para>
|
|
|
|
|
2004-01-28 15:51:14 +00:00
|
|
|
<sect1 id="section-dparam-start">
|
2002-09-27 18:34:33 +00:00
|
|
|
<title>Getting Started</title>
|
|
|
|
|
|
|
|
<para>
|
2006-01-31 16:56:28 +00:00
|
|
|
The controller subsystem is contained within the
|
|
|
|
<filename>gstcontroller</filename> library. You need to include the header in
|
2002-09-27 18:34:33 +00:00
|
|
|
your element's source file:
|
|
|
|
</para>
|
|
|
|
<programlisting>
|
2006-01-31 16:56:28 +00:00
|
|
|
...
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gst/controller/gstcontroller.h>
|
|
|
|
...
|
2002-09-27 18:34:33 +00:00
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
<para>
|
2006-01-31 16:56:28 +00:00
|
|
|
Even though the <filename>gstcontroller</filename> library may be linked into
|
|
|
|
the host application, you should make sure it is initialized in your
|
2002-09-27 18:34:33 +00:00
|
|
|
<filename>plugin_init</filename> function:
|
|
|
|
</para>
|
|
|
|
<programlisting>
|
|
|
|
static gboolean
|
2006-01-31 16:56:28 +00:00
|
|
|
plugin_init (GstPlugin *plugin)
|
2002-09-27 18:34:33 +00:00
|
|
|
{
|
|
|
|
...
|
2006-01-31 16:56:28 +00:00
|
|
|
/* initialize library */
|
|
|
|
gst_controller_init (NULL, NULL);
|
2002-09-27 18:34:33 +00:00
|
|
|
...
|
|
|
|
}
|
|
|
|
</programlisting>
|
|
|
|
<para>
|
2013-06-01 12:22:22 +00:00
|
|
|
It makes no sense for all GObject parameter to be real-time controlled.
|
2006-01-31 16:56:28 +00:00
|
|
|
Therefore the next step is to mark controllable parameters.
|
|
|
|
This is done by using the special flag <constant>GST_PARAM_CONTROLLABLE</constant>.
|
|
|
|
when setting up GObject params in the <function>_class_init</function> method.
|
2002-09-27 18:34:33 +00:00
|
|
|
</para>
|
|
|
|
<programlisting>
|
2006-01-31 16:56:28 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_FREQ,
|
|
|
|
g_param_spec_double ("freq", "Frequency", "Frequency of test signal",
|
|
|
|
0.0, 20000.0, 440.0,
|
2008-03-22 14:56:17 +00:00
|
|
|
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
2002-09-27 18:34:33 +00:00
|
|
|
</programlisting>
|
|
|
|
|
2004-01-28 09:22:01 +00:00
|
|
|
</sect1>
|
2002-09-27 18:34:33 +00:00
|
|
|
|
2004-01-28 15:51:14 +00:00
|
|
|
<sect1 id="chapter-dparam-loop">
|
2002-09-27 18:34:33 +00:00
|
|
|
<title>The Data Processing Loop</title>
|
2006-02-02 11:24:19 +00:00
|
|
|
|
2002-09-27 18:34:33 +00:00
|
|
|
<para>
|
2006-02-02 11:24:19 +00:00
|
|
|
In the last section we learned how to mark GObject params as controllable.
|
|
|
|
Application developers can then queue parameter changes for these parameters.
|
|
|
|
The approach the controller subsystem takes is to make plugins responsible
|
|
|
|
for pulling the changes in. This requires just one action:
|
2002-09-27 18:34:33 +00:00
|
|
|
</para>
|
|
|
|
<programlisting>
|
2006-02-02 11:24:19 +00:00
|
|
|
gst_object_sync_values(element,timestamp);
|
2002-09-27 18:34:33 +00:00
|
|
|
</programlisting>
|
|
|
|
<para>
|
2006-02-02 11:24:19 +00:00
|
|
|
This call makes all parameter-changes for the given timestamp active by
|
|
|
|
adjusting the GObject properties of the element. Its up to the element to
|
|
|
|
determine the synchronisation rate.
|
2002-09-27 18:34:33 +00:00
|
|
|
</para>
|
2006-02-02 11:24:19 +00:00
|
|
|
|
|
|
|
<sect2 id="chapter-dparam-loop-video">
|
|
|
|
<title>The Data Processing Loop for Video Elements</title>
|
2002-09-27 18:34:33 +00:00
|
|
|
<para>
|
2010-02-08 03:42:01 +00:00
|
|
|
For video processing elements it is the best to synchronise for every frame.
|
2006-02-02 11:24:19 +00:00
|
|
|
That means one would add the <function>gst_object_sync_values()</function>
|
|
|
|
call described in the previous section to the data processing function of
|
|
|
|
the element.
|
2002-09-27 18:34:33 +00:00
|
|
|
</para>
|
2006-02-02 11:24:19 +00:00
|
|
|
</sect2>
|
|
|
|
|
|
|
|
<sect2 id="chapter-dparam-loop-audio">
|
|
|
|
<title>The Data Processing Loop for Audio Elements</title>
|
2002-09-27 18:34:33 +00:00
|
|
|
<para>
|
2006-02-02 11:24:19 +00:00
|
|
|
For audio processing elements the case is not as easy as for video
|
|
|
|
processing elements. The problem here is that audio has a much higher rate.
|
|
|
|
For PAL video one will e.g. process 25 full frames per second, but for
|
|
|
|
standard audio it will be 44100 samples.
|
|
|
|
It is rarely useful to synchronise controllable parameters that often.
|
|
|
|
The easiest solution is also to have just one synchronisation call per
|
2010-02-08 03:42:01 +00:00
|
|
|
buffer processing. This makes the control-rate depend on the buffer
|
2006-02-02 11:24:19 +00:00
|
|
|
size.
|
2002-09-27 18:34:33 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2006-02-02 11:24:19 +00:00
|
|
|
Elements that need a specific control-rate need to break their data
|
|
|
|
processing loop to synchronise every n-samples.
|
2002-09-27 18:34:33 +00:00
|
|
|
</para>
|
2004-01-28 09:22:01 +00:00
|
|
|
</sect2>
|
|
|
|
</sect1>
|
2002-09-27 18:34:33 +00:00
|
|
|
</chapter>
|