1 <chapter id="chapter-dparams">
2 <title>Dynamic Controllable Parameters</title>
4 <sect1 id="section-dparams-getting-started">
5 <title>Getting Started</title>
7 The controller subsystem offers a lightweight way to adjust gobject
8 properties over stream-time. Normaly these properties are changed using
9 <function>g_object_set()</function>. Timing those calls reliably so that
10 the changes affect certain stream times is close to impossible. The
11 controller takes time into account. It works by attaching control-sources
12 to properties. Control-sources can provide new values for the properties
13 for a given timestamp. At run-time the elements continously pull values
14 changes for the current stream-time. GStreamer includes a few different
15 control-sources, but applications can define their own by subclassing.
18 This subsystem is contained within the
19 <filename>gstcontroller</filename> library.
20 You need to include the header in your application's source file:
24 #include <gst/gst.h>
25 #include <gst/controller/gstcontroller.h>
29 Your application should link to the shared library <filename>gstreamer-controller</filename>.
32 The <filename>gstreamer-controller</filename> library needs to be initialized
33 when your application is run. This can be done after the GStreamer
34 library has been initialized.
38 gst_init (&argc, &argv);
39 gst_controller_init (&argc, &argv);
44 <sect1 id="section-dparams-parameters">
45 <title>Setting up parameter control</title>
47 The first step is to select the parameters that should be controlled.
48 This returns a controller object that is needed to further adjust the
52 controller = gst_object_control_properties(object, "prop1", "prop2",...);
55 Next we attach a control-source to each parameter. Lets use an
56 interpolation control-source:
59 csource = gst_interpolation_control_source_new ();
60 gst_interpolation_control_source_set_interpolation_mode(csource, GST_INTERPOLATE_LINEAR);
63 Now we need to assign the control-source to the gobject property. One
64 control source can only be assigned to one property.
67 gst_controller_set_control_source (controller, "prop1", csource);
70 This control-source takes new property values from a list of time-stamped
71 parameter changes. The source can e.g. fill gaps by smoothing parameter
72 changes. This behaviour can be configured by setting the
76 Now we can set some control points. These are time-stamped GValues.
77 The values become active when the timestamp is reached. They still stay
78 in the list. If e.g. the pipeline runs a loop (using a segmented seek),
79 the control-curve gets repeated as well. Other control-sources have
80 different functions to specify the control-changes over time.
83 gst_interpolation_control_source_set (csource, 0 * GST_SECOND, value1);
84 gst_interpolation_control_source_set (csource, 1 * GST_SECOND, value2);
87 Now everything is ready to play. One final note - the controller subsystem
88 has a builtin live-mode. Even though a property has a control-source
89 assigned one can change the GObject property through the
90 <function>g_object_set()</function>.
91 This is highly useful when binding the GObject properties to GUI widgets.
92 When the user adjusts the value with the widget, one can set the GObject
93 property and this remains active until the next programmed control-source
94 value overrides it. This also works with smoothed parameters. It might not
95 work for control-sources that constantly update the property (e.g. the lfo