aboutsummaryrefslogtreecommitdiff
path: root/docs/manual/advanced-dparams.xml
blob: b7730af4c457a3ade60054c0443d58e664be310d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<chapter id="chapter-dparams">
  <title>Dynamic Controllable Parameters</title>
  
  <sect1 id="section-dparams-getting-started">
    <title>Getting Started</title>
    <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 impossible. 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>
    <para>
      This subsystem is contained within the
      <filename>gstcontroller</filename> library.
      You need to include the header in your application's source file:
    </para>
    <programlisting>
...
#include &lt;gst/gst.h&gt;
#include &lt;gst/controller/gstcontroller.h&gt;
...
    </programlisting>
    <para>
      Your application should link to the shared library <filename>gstreamer-controller</filename>.
    </para>
    <para>
      The <filename>gstreamer-controller</filename> library needs to be initialized
      when your application is run.  This can be done after the GStreamer
      library has been initialized.
    </para>
    <programlisting>
  ...
  gst_init (&amp;argc, &amp;argv);
  gst_controller_init (&amp;argc, &amp;argv);
  ...
    </programlisting>
  </sect1>
  
  <sect1 id="section-dparams-parameters">
    <title>Setting up parameter control</title>
    <para>
      Create a control-source. Lets use an interpolation control-source:
    </para>
    <programlisting>
  csource = gst_interpolation_control_source_new ();
  g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
    </programlisting>
    <para>
      Now we need to assign the control-source to the gobject property. One
      control source can only be assigned to one property.
    </para>
    <programlisting>
      gst_object_add_control_binding (object, gst_direct_control_binding_new (object, "prop1", csource));
    </programlisting>
    <para>
      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.
      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),
      the control-curve gets repeated as well. Other control-sources have
      different functions to specify the control-changes over time.
    </para>
    <programlisting>
  gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,0 * GST_SECOND, value1);
  gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,1 * GST_SECOND, value2);
    </programlisting>
    <para>
      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>.
      This is highly useful when binding the GObject properties to GUI widgets.
      When the user adjusts the value with the widget, one can set the GObject
      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).
    </para>
  </sect1>
  
</chapter>