|
16 | 16 | * You should have received a copy of the GNU Lesser General Public License |
17 | 17 | * version 3 along with this work. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 | */ |
19 | | - |
20 | 19 | package org.freedesktop.gstreamer.interfaces; |
21 | 20 |
|
22 | 21 | import java.util.List; |
|
25 | 24 | import org.freedesktop.gstreamer.lowlevel.GstAPI.GstCallback; |
26 | 25 |
|
27 | 26 | import com.sun.jna.Pointer; |
| 27 | +import java.util.ArrayList; |
| 28 | +import org.freedesktop.gstreamer.glib.GObject; |
| 29 | +import org.freedesktop.gstreamer.lowlevel.GlibAPI; |
28 | 30 |
|
29 | 31 | import static org.freedesktop.gstreamer.lowlevel.GstColorBalanceAPI.GSTCOLORBALANCE_API; |
30 | 32 |
|
31 | 33 | public class ColorBalance extends GstInterface { |
32 | | - /** |
33 | | - * Wraps the {@link Element} in a <tt>ColorBalance</tt> interface |
34 | | - * |
35 | | - * @param element |
36 | | - * the element to use as a <tt>ColorBalance</tt> |
37 | | - * @return a <tt>ColorBalance</tt> for the element |
38 | | - */ |
39 | | - public static final ColorBalance wrap(Element element) { |
40 | | - return new ColorBalance(element); |
41 | | - } |
42 | 34 |
|
43 | | - /** |
44 | | - * Creates a new ColorBalance instance |
45 | | - * |
46 | | - * @param element |
47 | | - * the element that implements the ColorBalance interface |
48 | | - */ |
49 | | - private ColorBalance(Element element) { |
50 | | - super(element, GSTCOLORBALANCE_API.gst_color_balance_get_type()); |
51 | | - } |
| 35 | + /** |
| 36 | + * Wraps the {@link Element} in a <tt>ColorBalance</tt> interface |
| 37 | + * |
| 38 | + * @param element the element to use as a <tt>ColorBalance</tt> |
| 39 | + * @return a <tt>ColorBalance</tt> for the element |
| 40 | + */ |
| 41 | + public static final ColorBalance wrap(Element element) { |
| 42 | + return new ColorBalance(element); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Creates a new ColorBalance instance |
| 47 | + * |
| 48 | + * @param element the element that implements the ColorBalance interface |
| 49 | + */ |
| 50 | + private ColorBalance(Element element) { |
| 51 | + super(element, GSTCOLORBALANCE_API.gst_color_balance_get_type()); |
| 52 | + } |
52 | 53 |
|
53 | | - /** |
54 | | - * Retrieves a list of ColorBalanceChannels from the ColorBalance |
55 | | - * |
56 | | - * @return a list of color balance channels available on this device |
57 | | - */ |
58 | | - public List<ColorBalanceChannel> getChannelList() { |
59 | | - return objectList(GSTCOLORBALANCE_API.gst_color_balance_list_channels(this), |
60 | | - new ListElementCreator<ColorBalanceChannel>() { |
61 | | - public ColorBalanceChannel create(Pointer pointer) { |
62 | | - return channelFor(pointer, true); |
63 | | - } |
64 | | - }); |
65 | | - } |
| 54 | + /** |
| 55 | + * Retrieves a list of ColorBalanceChannels from the ColorBalance |
| 56 | + * |
| 57 | + * @return a list of color balance channels available on this device |
| 58 | + */ |
| 59 | + public List<ColorBalanceChannel> getChannelList() { |
| 60 | + |
| 61 | + GlibAPI.GList glist = GSTCOLORBALANCE_API.gst_color_balance_list_channels(this); |
| 62 | + List<ColorBalanceChannel> list = new ArrayList<>(); |
| 63 | + GlibAPI.GList next = glist; |
| 64 | + while (next != null) { |
| 65 | + if (next.data != null) { |
| 66 | + list.add(channelFor(next.data, true)); |
| 67 | + } |
| 68 | + next = next.next(); |
| 69 | + } |
| 70 | + return list; |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Retrieves a ColorBalanceChannel for the given Pointer |
| 75 | + * |
| 76 | + * @param pointer |
| 77 | + * @param needRef |
| 78 | + * @return a ColorBalanceChannel instance |
| 79 | + */ |
| 80 | + private final ColorBalanceChannel channelFor(Pointer pointer, |
| 81 | + boolean needRef) { |
| 82 | + return new ColorBalanceChannel(this, pointer, needRef, true); |
| 83 | + } |
66 | 84 |
|
67 | | - /** |
68 | | - * Retrieves a ColorBalanceChannel for the given Pointer |
69 | | - * |
70 | | - * @param pointer |
71 | | - * @param needRef |
72 | | - * @return a ColorBalanceChannel instance |
73 | | - */ |
74 | | - private final ColorBalanceChannel channelFor(Pointer pointer, |
75 | | - boolean needRef) { |
76 | | - return new ColorBalanceChannel(this, pointer, needRef, true); |
77 | | - } |
| 85 | + /** |
| 86 | + * Signal emitted when color balance value changed |
| 87 | + * |
| 88 | + * @see #connect(VALUE_CHANGED) |
| 89 | + * @see #disconnect(VALUE_CHANGED) |
| 90 | + */ |
| 91 | + public static interface VALUE_CHANGED { |
78 | 92 |
|
79 | | - /** |
80 | | - * Signal emitted when color balance value changed |
81 | | - * |
82 | | - * @see #connect(VALUE_CHANGED) |
83 | | - * @see #disconnect(VALUE_CHANGED) |
84 | | - */ |
85 | | - public static interface VALUE_CHANGED { |
86 | | - /** |
87 | | - * Called when the color balance channel value changes |
88 | | - */ |
89 | | - public void colorBalanceValueChanged(ColorBalance colorBalance, |
90 | | - ColorBalanceChannel channel, int value); |
91 | | - } |
| 93 | + /** |
| 94 | + * Called when the color balance channel value changes |
| 95 | + */ |
| 96 | + public void colorBalanceValueChanged(ColorBalance colorBalance, |
| 97 | + ColorBalanceChannel channel, int value); |
| 98 | + } |
92 | 99 |
|
93 | | - /** |
94 | | - * Add a listener for norm-changed messages. |
95 | | - * |
96 | | - * @param listener |
97 | | - * the listener to be called when the norm changes |
98 | | - */ |
99 | | - public void connect(final VALUE_CHANGED listener) { |
100 | | - element.connect(VALUE_CHANGED.class, listener, new GstCallback() { |
101 | | - @SuppressWarnings("unused") |
102 | | - public boolean callback(Pointer colorBalance, ColorBalanceChannel channel, int value) { |
103 | | - listener.colorBalanceValueChanged(ColorBalance.this, channel, value); |
104 | | - return true; |
105 | | - } |
106 | | - }); |
107 | | - } |
| 100 | + /** |
| 101 | + * Add a listener for norm-changed messages. |
| 102 | + * |
| 103 | + * @param listener the listener to be called when the norm changes |
| 104 | + */ |
| 105 | + public void connect(final VALUE_CHANGED listener) { |
| 106 | + element.connect(VALUE_CHANGED.class, listener, new GstCallback() { |
| 107 | + @SuppressWarnings("unused") |
| 108 | + public boolean callback(Pointer colorBalance, ColorBalanceChannel channel, int value) { |
| 109 | + listener.colorBalanceValueChanged(ColorBalance.this, channel, value); |
| 110 | + return true; |
| 111 | + } |
| 112 | + }); |
| 113 | + } |
108 | 114 |
|
109 | | - /** |
110 | | - * Disconnect the listener for norm-changed messages. |
111 | | - * |
112 | | - * @param listener |
113 | | - * the listener that was registered to receive the message. |
114 | | - */ |
115 | | - public void disconnect(VALUE_CHANGED listener) { |
116 | | - element.disconnect(VALUE_CHANGED.class, listener); |
117 | | - } |
| 115 | + /** |
| 116 | + * Disconnect the listener for norm-changed messages. |
| 117 | + * |
| 118 | + * @param listener the listener that was registered to receive the message. |
| 119 | + */ |
| 120 | + public void disconnect(VALUE_CHANGED listener) { |
| 121 | + element.disconnect(VALUE_CHANGED.class, listener); |
| 122 | + } |
118 | 123 |
|
119 | 124 | } |
0 commit comments