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 Create a control-source. Lets use an interpolation control-source:
50 csource = gst_interpolation_control_source_new ();
51 g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
54 Now we need to assign the control-source to the gobject property. One
55 control source can only be assigned to one property.
58 gst_object_add_control_binding (object, gst_direct_control_binding_new (object, "prop1", csource));
61 This control-source takes new property values from a list of time-stamped
62 parameter changes. The source can e.g. fill gaps by smoothing parameter
63 changes. This behaviour can be configured by setting the
67 Now we can set some control points. These are time-stamped GValues.
68 The values become active when the timestamp is reached. They still stay
69 in the list. If e.g. the pipeline runs a loop (using a segmented seek),
70 the control-curve gets repeated as well. Other control-sources have
71 different functions to specify the control-changes over time.
74 gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,0 * GST_SECOND, value1);
75 gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,1 * GST_SECOND, value2);
78 Now everything is ready to play. One final note - the controller subsystem
79 has a builtin live-mode. Even though a property has a control-source
80 assigned one can change the GObject property through the
81 <function>g_object_set()</function>.
82 This is highly useful when binding the GObject properties to GUI widgets.
83 When the user adjusts the value with the widget, one can set the GObject
84 property and this remains active until the next programmed control-source
85 value overrides it. This also works with smoothed parameters. It might not
86 work for control-sources that constantly update the property (e.g. the lfo