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