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.ControlSource;
26 
27 private import gstreamer.ObjectGst;
28 private import gstreamerc.gstreamer;
29 public  import gstreamerc.gstreamertypes;
30 
31 
32 /**
33  * The #GstControlSource is a base class for control value sources that could
34  * be used to get timestamp-value pairs. A control source essentially is a
35  * function over time.
36  * 
37  * A #GstControlSource is used by first getting an instance of a specific
38  * control-source, creating a binding for the control-source to the target property
39  * of the element and then adding the binding to the element. The binding will
40  * convert the data types and value range to fit to the bound property.
41  * 
42  * For implementing a new #GstControlSource one has to implement
43  * #GstControlSourceGetValue and #GstControlSourceGetValueArray functions.
44  * These are then used by gst_control_source_get_value() and
45  * gst_control_source_get_value_array() to get values for specific timestamps.
46  */
47 public class ControlSource : ObjectGst
48 {
49 	/** the main Gtk struct */
50 	protected GstControlSource* gstControlSource;
51 
52 	/** Get the main Gtk struct */
53 	public GstControlSource* getControlSourceStruct(bool transferOwnership = false)
54 	{
55 		if (transferOwnership)
56 			ownedRef = false;
57 		return gstControlSource;
58 	}
59 
60 	/** the main Gtk struct as a void* */
61 	protected override void* getStruct()
62 	{
63 		return cast(void*)gstControlSource;
64 	}
65 
66 	protected override void setStruct(GObject* obj)
67 	{
68 		gstControlSource = cast(GstControlSource*)obj;
69 		super.setStruct(obj);
70 	}
71 
72 	/**
73 	 * Sets our main struct and passes it to the parent class.
74 	 */
75 	public this (GstControlSource* gstControlSource, bool ownedRef = false)
76 	{
77 		this.gstControlSource = gstControlSource;
78 		super(cast(GstObject*)gstControlSource, ownedRef);
79 	}
80 
81 
82 	/** */
83 	public static GType getType()
84 	{
85 		return gst_control_source_get_type();
86 	}
87 
88 	/**
89 	 * Gets the value for this #GstControlSource at a given timestamp.
90 	 *
91 	 * Params:
92 	 *     timestamp = the time for which the value should be returned
93 	 *     value = the value
94 	 *
95 	 * Returns: %FALSE if the value couldn't be returned, %TRUE otherwise.
96 	 */
97 	public bool getValue(GstClockTime timestamp, out double value)
98 	{
99 		return gst_control_source_get_value(gstControlSource, timestamp, &value) != 0;
100 	}
101 
102 	/**
103 	 * Gets an array of values for for this #GstControlSource. Values that are
104 	 * undefined contain NANs.
105 	 *
106 	 * Params:
107 	 *     timestamp = the first timestamp
108 	 *     interval = the time steps
109 	 *     nValues = the number of values to fetch
110 	 *     values = array to put control-values in
111 	 *
112 	 * Returns: %TRUE if the given array could be filled, %FALSE otherwise
113 	 */
114 	public bool getValueArray(GstClockTime timestamp, GstClockTime interval, double[] values)
115 	{
116 		return gst_control_source_get_value_array(gstControlSource, timestamp, interval, cast(uint)values.length, values.ptr) != 0;
117 	}
118 }