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 gstreamerc.gstreamer;
31 public  import gstreamerc.gstreamertypes;
32 
33 
34 /**
35  * A base class for value mapping objects that attaches control sources to gobject
36  * properties. Such an object is taking one or more #GstControlSource instances,
37  * combines them and maps the resulting value to the type and value range of the
38  * bound property.
39  */
40 public class ControlBinding : ObjectGst
41 {
42 	/** the main Gtk struct */
43 	protected GstControlBinding* gstControlBinding;
44 
45 	/** Get the main Gtk struct */
46 	public GstControlBinding* getControlBindingStruct()
47 	{
48 		return gstControlBinding;
49 	}
50 
51 	/** the main Gtk struct as a void* */
52 	protected override void* getStruct()
53 	{
54 		return cast(void*)gstControlBinding;
55 	}
56 
57 	protected override void setStruct(GObject* obj)
58 	{
59 		gstControlBinding = cast(GstControlBinding*)obj;
60 		super.setStruct(obj);
61 	}
62 
63 	/**
64 	 * Sets our main struct and passes it to the parent class.
65 	 */
66 	public this (GstControlBinding* gstControlBinding, bool ownedRef = false)
67 	{
68 		this.gstControlBinding = gstControlBinding;
69 		super(cast(GstObject*)gstControlBinding, ownedRef);
70 	}
71 
72 	/**
73 	 */
74 
75 	public static GType getType()
76 	{
77 		return gst_control_binding_get_type();
78 	}
79 
80 	/**
81 	 * Gets a number of #GValues for the given controlled property starting at the
82 	 * requested time. The array @values need to hold enough space for @n_values of
83 	 * #GValue.
84 	 *
85 	 * This function is useful if one wants to e.g. draw a graph of the control
86 	 * curve or apply a control curve sample by sample.
87 	 *
88 	 * Params:
89 	 *     timestamp = the time that should be processed
90 	 *     interval = the time spacing between subsequent values
91 	 *     nValues = the number of values
92 	 *     values = array to put control-values in
93 	 *
94 	 * Return: %TRUE if the given array could be filled, %FALSE otherwise
95 	 */
96 	public bool getGValueArray(GstClockTime timestamp, GstClockTime interval, Value[] values)
97 	{
98 		GValue[] valuesArray = new GValue[values.length];
99 		for ( int i = 0; i < values.length; i++ )
100 		{
101 			valuesArray[i] = *(values[i].getValueStruct());
102 		}
103 		
104 		return gst_control_binding_get_g_value_array(gstControlBinding, timestamp, interval, cast(uint)values.length, valuesArray.ptr) != 0;
105 	}
106 
107 	/**
108 	 * Gets the value for the given controlled property at the requested time.
109 	 *
110 	 * Params:
111 	 *     timestamp = the time the control-change should be read from
112 	 *
113 	 * Return: the GValue of the property at the given time,
114 	 *     or %NULL if the property isn't controlled.
115 	 */
116 	public Value getValue(GstClockTime timestamp)
117 	{
118 		auto p = gst_control_binding_get_value(gstControlBinding, timestamp);
119 		
120 		if(p is null)
121 		{
122 			return null;
123 		}
124 		
125 		return ObjectG.getDObject!(Value)(cast(GValue*) p);
126 	}
127 
128 	/**
129 	 * Gets a number of values for the given controlled property starting at the
130 	 * requested time. The array @values need to hold enough space for @n_values of
131 	 * the same type as the objects property's type.
132 	 *
133 	 * This function is useful if one wants to e.g. draw a graph of the control
134 	 * curve or apply a control curve sample by sample.
135 	 *
136 	 * The values are unboxed and ready to be used. The similar function
137 	 * gst_control_binding_get_g_value_array() returns the array as #GValues and is
138 	 * more suitable for bindings.
139 	 *
140 	 * Params:
141 	 *     timestamp = the time that should be processed
142 	 *     interval = the time spacing between subsequent values
143 	 *     nValues = the number of values
144 	 *     values = array to put control-values in
145 	 *
146 	 * Return: %TRUE if the given array could be filled, %FALSE otherwise
147 	 */
148 	public bool getValueArray(GstClockTime timestamp, GstClockTime interval, void*[] values)
149 	{
150 		return gst_control_binding_get_value_array(gstControlBinding, timestamp, interval, cast(uint)values.length, values.ptr) != 0;
151 	}
152 
153 	/**
154 	 * Check if the control binding is disabled.
155 	 *
156 	 * Return: %TRUE if the binding is inactive
157 	 */
158 	public bool isDisabled()
159 	{
160 		return gst_control_binding_is_disabled(gstControlBinding) != 0;
161 	}
162 
163 	/**
164 	 * This function is used to disable a control binding for some time, i.e.
165 	 * gst_object_sync_values() will do nothing.
166 	 *
167 	 * Params:
168 	 *     disabled = boolean that specifies whether to disable the controller
169 	 *         or not.
170 	 */
171 	public void setDisabled(bool disabled)
172 	{
173 		gst_control_binding_set_disabled(gstControlBinding, disabled);
174 	}
175 
176 	/**
177 	 * Sets the property of the @object, according to the #GstControlSources that
178 	 * handle them and for the given timestamp.
179 	 *
180 	 * If this function fails, it is most likely the application developers fault.
181 	 * Most probably the control sources are not setup correctly.
182 	 *
183 	 * Params:
184 	 *     object = the object that has controlled properties
185 	 *     timestamp = the time that should be processed
186 	 *     lastSync = the last time this was called
187 	 *
188 	 * Return: %TRUE if the controller value could be applied to the object
189 	 *     property, %FALSE otherwise
190 	 */
191 	public bool syncValues(ObjectGst object, GstClockTime timestamp, GstClockTime lastSync)
192 	{
193 		return gst_control_binding_sync_values(gstControlBinding, (object is null) ? null : object.getObjectGstStruct(), timestamp, lastSync) != 0;
194 	}
195 }