1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gstreamer.ControlBinding;
26 
27 private import gobject.ObjectG;
28 private import gobject.Value;
29 private import gstreamer.ObjectGst;
30 private import gstreamer.c.functions;
31 public  import gstreamer.c.types;
32 public  import gstreamerc.gstreamertypes;
33 
34 
35 /**
36  * A base class for value mapping objects that attaches control sources to gobject
37  * properties. Such an object is taking one or more #GstControlSource instances,
38  * combines them and maps the resulting value to the type and value range of the
39  * bound property.
40  */
41 public class ControlBinding : ObjectGst
42 {
43 	/** the main Gtk struct */
44 	protected GstControlBinding* gstControlBinding;
45 
46 	/** Get the main Gtk struct */
47 	public GstControlBinding* getControlBindingStruct(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return gstControlBinding;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected override void* getStruct()
56 	{
57 		return cast(void*)gstControlBinding;
58 	}
59 
60 	/**
61 	 * Sets our main struct and passes it to the parent class.
62 	 */
63 	public this (GstControlBinding* gstControlBinding, bool ownedRef = false)
64 	{
65 		this.gstControlBinding = gstControlBinding;
66 		super(cast(GstObject*)gstControlBinding, ownedRef);
67 	}
68 
69 
70 	/** */
71 	public static GType getType()
72 	{
73 		return gst_control_binding_get_type();
74 	}
75 
76 	/**
77 	 * Gets a number of #GValues for the given controlled property starting at the
78 	 * requested time. The array @values need to hold enough space for @n_values of
79 	 * #GValue.
80 	 *
81 	 * This function is useful if one wants to e.g. draw a graph of the control
82 	 * curve or apply a control curve sample by sample.
83 	 *
84 	 * Params:
85 	 *     timestamp = the time that should be processed
86 	 *     interval = the time spacing between subsequent values
87 	 *     values = array to put control-values in
88 	 *
89 	 * Returns: %TRUE if the given array could be filled, %FALSE otherwise
90 	 */
91 	public bool getGValueArray(GstClockTime timestamp, GstClockTime interval, Value[] values)
92 	{
93 		GValue[] valuesArray = new GValue[values.length];
94 		for ( int i = 0; i < values.length; i++ )
95 		{
96 			valuesArray[i] = *(values[i].getValueStruct());
97 		}
98 
99 		return gst_control_binding_get_g_value_array(gstControlBinding, timestamp, interval, cast(uint)values.length, valuesArray.ptr) != 0;
100 	}
101 
102 	/**
103 	 * Gets the value for the given controlled property at the requested time.
104 	 *
105 	 * Params:
106 	 *     timestamp = the time the control-change should be read from
107 	 *
108 	 * Returns: the GValue of the property at the given time,
109 	 *     or %NULL if the property isn't controlled.
110 	 */
111 	public Value getValue(GstClockTime timestamp)
112 	{
113 		auto p = gst_control_binding_get_value(gstControlBinding, timestamp);
114 
115 		if(p is null)
116 		{
117 			return null;
118 		}
119 
120 		return ObjectG.getDObject!(Value)(cast(GValue*) p, true);
121 	}
122 
123 	/**
124 	 * Gets a number of values for the given controlled property starting at the
125 	 * requested time. The array @values need to hold enough space for @n_values of
126 	 * the same type as the objects property's type.
127 	 *
128 	 * This function is useful if one wants to e.g. draw a graph of the control
129 	 * curve or apply a control curve sample by sample.
130 	 *
131 	 * The values are unboxed and ready to be used. The similar function
132 	 * gst_control_binding_get_g_value_array() returns the array as #GValues and is
133 	 * more suitable for bindings.
134 	 *
135 	 * Params:
136 	 *     timestamp = the time that should be processed
137 	 *     interval = the time spacing between subsequent values
138 	 *     values = array to put control-values in
139 	 *
140 	 * Returns: %TRUE if the given array could be filled, %FALSE otherwise
141 	 */
142 	public bool getValueArray(GstClockTime timestamp, GstClockTime interval, void*[] values)
143 	{
144 		return gst_control_binding_get_value_array(gstControlBinding, timestamp, interval, cast(uint)values.length, values.ptr) != 0;
145 	}
146 
147 	/**
148 	 * Check if the control binding is disabled.
149 	 *
150 	 * Returns: %TRUE if the binding is inactive
151 	 */
152 	public bool isDisabled()
153 	{
154 		return gst_control_binding_is_disabled(gstControlBinding) != 0;
155 	}
156 
157 	/**
158 	 * This function is used to disable a control binding for some time, i.e.
159 	 * gst_object_sync_values() will do nothing.
160 	 *
161 	 * Params:
162 	 *     disabled = boolean that specifies whether to disable the controller
163 	 *         or not.
164 	 */
165 	public void setDisabled(bool disabled)
166 	{
167 		gst_control_binding_set_disabled(gstControlBinding, disabled);
168 	}
169 
170 	/**
171 	 * Sets the property of the @object, according to the #GstControlSources that
172 	 * handle them and for the given timestamp.
173 	 *
174 	 * If this function fails, it is most likely the application developers fault.
175 	 * Most probably the control sources are not setup correctly.
176 	 *
177 	 * Params:
178 	 *     object = the object that has controlled properties
179 	 *     timestamp = the time that should be processed
180 	 *     lastSync = the last time this was called
181 	 *
182 	 * Returns: %TRUE if the controller value could be applied to the object
183 	 *     property, %FALSE otherwise
184 	 */
185 	public bool syncValues(ObjectGst object, GstClockTime timestamp, GstClockTime lastSync)
186 	{
187 		return gst_control_binding_sync_values(gstControlBinding, (object is null) ? null : object.getObjectGstStruct(), timestamp, lastSync) != 0;
188 	}
189 }