2004-12-15 07:30:55 +00:00
|
|
|
<chapter id="chapter-dparams">
|
2006-01-30 21:11:38 +00:00
|
|
|
<title>Dynamic Controllable Parameters</title>
|
2010-07-12 07:50:53 +00:00
|
|
|
|
2010-07-12 12:39:00 +00:00
|
|
|
<sect1 id="section-dparams-getting-started">
|
|
|
|
<title>Getting Started</title>
|
2010-07-12 07:50:53 +00:00
|
|
|
<para>
|
|
|
|
The controller subsystem offers a lightweight way to adjust gobject
|
|
|
|
properties over stream-time. Normaly these properties are changed using
|
|
|
|
<function>g_object_set()</function>. Timing those calls reliably so that
|
|
|
|
the changes affect certain stream times is close to imposible. The
|
|
|
|
controller takes time into account. It works by attaching control-sources
|
|
|
|
to properties. Control-sources can provide new values for the properties
|
|
|
|
for a given timestamp. At run-time the elements continously pull values
|
|
|
|
changes for the current stream-time. GStreamer includes a few different
|
|
|
|
control-sources, but applications can define their own by subclassing.
|
|
|
|
</para>
|
2006-01-30 21:11:38 +00:00
|
|
|
<para>
|
|
|
|
This subsystem is contained within the
|
2006-01-31 16:56:28 +00:00
|
|
|
<filename>gstcontroller</filename> library.
|
2004-12-15 07:30:55 +00:00
|
|
|
You need to include the header in your application's source file:
|
|
|
|
</para>
|
|
|
|
<programlisting>
|
|
|
|
...
|
|
|
|
#include <gst/gst.h>
|
2006-01-30 21:11:38 +00:00
|
|
|
#include <gst/controller/gstcontroller.h>
|
2004-12-15 07:30:55 +00:00
|
|
|
...
|
|
|
|
</programlisting>
|
|
|
|
<para>
|
2006-01-30 21:11:38 +00:00
|
|
|
Your application should link to the shared library <filename>gstreamer-controller</filename>.
|
2004-12-15 07:30:55 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2006-01-30 21:11:38 +00:00
|
|
|
The <filename>gstreamer-controller</filename> library needs to be initialized
|
2004-12-15 07:30:55 +00:00
|
|
|
when your application is run. This can be done after the the GStreamer
|
|
|
|
library has been initialized.
|
|
|
|
</para>
|
|
|
|
<programlisting>
|
|
|
|
...
|
2006-01-31 16:56:28 +00:00
|
|
|
gst_init (&argc, &argv);
|
|
|
|
gst_controller_init (&argc, &argv);
|
2004-12-15 07:30:55 +00:00
|
|
|
...
|
|
|
|
</programlisting>
|
|
|
|
</sect1>
|
2006-01-30 21:11:38 +00:00
|
|
|
|
|
|
|
<sect1 id="section-dparams-parameters">
|
2006-01-31 16:56:28 +00:00
|
|
|
<title>Setting up parameter control</title>
|
2004-12-15 07:30:55 +00:00
|
|
|
<para>
|
2006-01-31 16:56:28 +00:00
|
|
|
The first step is to select the parameters that should be controlled.
|
|
|
|
This returns a controller object that is needed to further adjust the
|
|
|
|
behaviour.
|
2004-12-15 07:30:55 +00:00
|
|
|
</para>
|
|
|
|
<programlisting>
|
2006-12-19 15:06:42 +00:00
|
|
|
controller = gst_object_control_properties(object, "prop1", "prop2",...);
|
2004-12-15 07:30:55 +00:00
|
|
|
</programlisting>
|
|
|
|
<para>
|
2010-07-12 07:50:53 +00:00
|
|
|
Next we attach a control-source to each parameter. Lets use an
|
|
|
|
interpolation control-source:
|
2004-12-15 07:30:55 +00:00
|
|
|
</para>
|
|
|
|
<programlisting>
|
2010-07-12 07:50:53 +00:00
|
|
|
csource = gst_interpolation_control_source_new ();
|
|
|
|
gst_interpolation_control_source_set_interpolation_mode(csource, GST_INTERPOLATE_LINEAR);
|
2004-12-15 07:30:55 +00:00
|
|
|
</programlisting>
|
|
|
|
<para>
|
2010-07-12 07:50:53 +00:00
|
|
|
This control-source takes new property values from a list of time-stamped
|
|
|
|
parameter changes. The source can e.g. fill gaps by smoothing parameter
|
|
|
|
changes. This behaviour can be configured by setting the
|
|
|
|
interpolation-mode.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Now we can set some control points. These are time-stamped GValues.
|
2006-01-30 21:11:38 +00:00
|
|
|
The values become active when the timestamp is reached. They still stay
|
|
|
|
in the list. If e.g. the pipeline runs a loop (using a segmented seek),
|
2010-07-12 07:50:53 +00:00
|
|
|
the control-curve gets repeated as well. Other control-sources have
|
|
|
|
different functions to specify the control-changes over time.
|
|
|
|
</para>
|
|
|
|
<programlisting>
|
|
|
|
gst_interpolation_control_source_set (csource, 0 * GST_SECOND, value1);
|
|
|
|
gst_interpolation_control_source_set (csource, 1 * GST_SECOND, value2);
|
|
|
|
</programlisting>
|
|
|
|
<para>
|
|
|
|
Finally we need to assign the control-source to the gobject property. One
|
|
|
|
control source can only be assigned to one property.
|
2004-12-15 07:30:55 +00:00
|
|
|
</para>
|
|
|
|
<programlisting>
|
2010-07-12 07:50:53 +00:00
|
|
|
gst_controller_set_control_source (controller, "prop1", csource);
|
2004-12-15 07:30:55 +00:00
|
|
|
</programlisting>
|
|
|
|
<para>
|
2010-07-12 07:50:53 +00:00
|
|
|
Now everything is ready to play. One final note - the controller subsystem
|
|
|
|
has a builtin live-mode. Even though a property has a control-source
|
|
|
|
assigned one can change the GObject property through the
|
|
|
|
<function>g_object_set()</function>.
|
2006-01-30 21:11:38 +00:00
|
|
|
This is highly useful when binding the GObject properties to GUI widgets.
|
2010-07-01 18:58:09 +00:00
|
|
|
When the user adjusts the value with the widget, one can set the GObject
|
2010-07-12 07:50:53 +00:00
|
|
|
property and this remains active until the next programmed control-source
|
|
|
|
value overrides it. This also works with smoothed parameters. It might not
|
|
|
|
work for control-sources that constantly update the property (e.g. the lfo
|
|
|
|
control-source).
|
2004-12-15 07:30:55 +00:00
|
|
|
</para>
|
|
|
|
</sect1>
|
|
|
|
|
|
|
|
</chapter>
|