2020 */
2121
2222package org .freedesktop .gstreamer ;
23+
2324import java .util .List ;
2425
26+ import com .sun .jna .Pointer ;
27+
2528import org .freedesktop .gstreamer .lowlevel .GstAPI .GErrorStruct ;
2629import org .freedesktop .gstreamer .lowlevel .GstAPI .GstCallback ;
27- import org .freedesktop .gstreamer .lowlevel .GstBinAPI ;
28- import org .freedesktop .gstreamer .lowlevel .GstNative ;
29- import org .freedesktop .gstreamer .lowlevel .GstParseAPI ;
3030import org .freedesktop .gstreamer .lowlevel .GstTypes ;
31- import org .freedesktop .gstreamer .lowlevel .annotations .CallerOwnsReturn ;
3231
33- import com .sun .jna .Pointer ;
32+ import static org .freedesktop .gstreamer .lowlevel .GstBinAPI .GSTBIN_API ;
33+ import static org .freedesktop .gstreamer .lowlevel .GstParseAPI .GSTPARSE_API ;
3434
3535/**
3636 * Base class and element that can contain other elements.
6161public class Bin extends Element {
6262 public static final String GST_NAME = "bin" ;
6363 public static final String GTYPE_NAME = "GstBin" ;
64-
65- private static interface API extends GstBinAPI , GstParseAPI {
66- @ CallerOwnsReturn Pointer ptr_gst_pipeline_new (String name );
67- }
68- private static final API gst = GstNative .load (API .class );
6964
7065 public static final int DEBUG_GRAPH_SHOW_MEDIA_TYPE = (1 <<0 );
7166 public static final int DEBUG_GRAPH_SHOW_CAPS_DETAILS = (1 <<1 );
@@ -81,15 +76,15 @@ public Bin(Initializer init) {
8176 * Creates a new Bin with a unique name.
8277 */
8378 public Bin () {
84- this (initializer (gst .ptr_gst_bin_new (null ), false ));
79+ this (initializer (GSTBIN_API .ptr_gst_bin_new (null ), false ));
8580 }
8681
8782 /**
8883 * Creates a new Bin with the given name.
8984 * @param name The Name to assign to the new Bin
9085 */
9186 public Bin (String name ) {
92- this (initializer (gst .ptr_gst_bin_new (name ), false ));
87+ this (initializer (GSTBIN_API .ptr_gst_bin_new (name ), false ));
9388 }
9489
9590 /**
@@ -104,7 +99,7 @@ public Bin(String name) {
10499 */
105100 public static Bin launch (String binDecription , boolean ghostUnlinkedPads ) {
106101 Pointer [] err = { null };
107- Bin bin = gst .gst_parse_bin_from_description (binDecription , ghostUnlinkedPads , err );
102+ Bin bin = GSTPARSE_API .gst_parse_bin_from_description (binDecription , ghostUnlinkedPads , err );
108103 if (bin == null ) {
109104 throw new GstException (new GError (new GErrorStruct (err [0 ])));
110105 }
@@ -125,7 +120,7 @@ public static Bin launch(String binDecription, boolean ghostUnlinkedPads) {
125120 * will not accept the element.
126121 */
127122 public boolean add (Element element ) {
128- return gst .gst_bin_add (this , element );
123+ return GSTBIN_API .gst_bin_add (this , element );
129124 }
130125
131126 /**
@@ -135,7 +130,7 @@ public boolean add(Element element) {
135130 * @see Bin#add(Element)
136131 */
137132 public void addMany (Element ... elements ) {
138- gst .gst_bin_add_many (this , elements );
133+ GSTBIN_API .gst_bin_add_many (this , elements );
139134 }
140135
141136 /**
@@ -150,7 +145,7 @@ public void addMany(Element... elements) {
150145 * @return true if the element was successfully removed
151146 */
152147 public boolean remove (Element element ) {
153- return gst .gst_bin_remove (this , element );
148+ return GSTBIN_API .gst_bin_remove (this , element );
154149 }
155150
156151 /**
@@ -159,7 +154,7 @@ public boolean remove(Element element) {
159154 * @param elements The list {@link Element} to remove
160155 */
161156 public void removeMany (Element ... elements ) {
162- gst .gst_bin_remove_many (this , elements );
157+ GSTBIN_API .gst_bin_remove_many (this , elements );
163158 }
164159
165160 private List <Element > elementList (Pointer iter ) {
@@ -171,7 +166,7 @@ private List<Element> elementList(Pointer iter) {
171166 * @return The List of {@link Element}s.
172167 */
173168 public List <Element > getElements () {
174- return elementList (gst .gst_bin_iterate_elements (this ));
169+ return elementList (GSTBIN_API .gst_bin_iterate_elements (this ));
175170 }
176171 /**
177172 * Gets an a list of the elements in this bin in topologically
@@ -180,7 +175,7 @@ public List<Element> getElements() {
180175 * @return The List of {@link Element}s.
181176 */
182177 public List <Element > getElementsSorted () {
183- return elementList (gst .gst_bin_iterate_sorted (this ));
178+ return elementList (GSTBIN_API .gst_bin_iterate_sorted (this ));
184179 }
185180
186181 /**
@@ -192,23 +187,23 @@ public List<Element> getElementsSorted() {
192187 * @return The List of {@link Element}s.
193188 */
194189 public List <Element > getElementsRecursive () {
195- return elementList (gst .gst_bin_iterate_recurse (this ));
190+ return elementList (GSTBIN_API .gst_bin_iterate_recurse (this ));
196191 }
197192
198193 /**
199194 * Retrieve a list of the sink {@link Element}s contained in the Bin.
200195 * @return The List of sink {@link Element}s.
201196 */
202197 public List <Element > getSinks () {
203- return elementList (gst .gst_bin_iterate_sinks (this ));
198+ return elementList (GSTBIN_API .gst_bin_iterate_sinks (this ));
204199 }
205200
206201 /**
207202 * Retrieve a list of the source {@link Element}s contained in the Bin.
208203 * @return The List of source {@link Element}s.
209204 */
210205 public List <Element > getSources () {
211- return elementList (gst .gst_bin_iterate_sources (this ));
206+ return elementList (GSTBIN_API .gst_bin_iterate_sources (this ));
212207 }
213208
214209 /**
@@ -219,7 +214,7 @@ public List<Element> getSources() {
219214 * @return The {@link Element} if found, else null.
220215 */
221216 public Element getElementByName (String name ) {
222- return gst .gst_bin_get_by_name (this , name );
217+ return GSTBIN_API .gst_bin_get_by_name (this , name );
223218 }
224219
225220 /**
@@ -229,7 +224,7 @@ public Element getElementByName(String name) {
229224 * @return The {@link Element} if found, else null.
230225 */
231226 public Element getElementByNameRecurseUp (String name ) {
232- return gst .gst_bin_get_by_name_recurse_up (this , name );
227+ return GSTBIN_API .gst_bin_get_by_name_recurse_up (this , name );
233228 }
234229
235230 /**
@@ -239,7 +234,7 @@ public Element getElementByNameRecurseUp(String name) {
239234 * @return The {@link Element} that implements the interface.
240235 */
241236 public <T extends Element > T getElementByInterface (Class <T > iface ) {
242- return iface .cast (gst .gst_bin_get_by_interface (this , GstTypes .typeFor (iface )));
237+ return iface .cast (GSTBIN_API .gst_bin_get_by_interface (this , GstTypes .typeFor (iface )));
243238 }
244239
245240 /**
@@ -266,9 +261,9 @@ public void debugToDotFile(int details, String fileName) {
266261 */
267262 public void debugToDotFile (int details , String fileName , boolean timestampFileName ) {
268263 if (timestampFileName )
269- gst ._gst_debug_bin_to_dot_file_with_ts (this , details , fileName );
264+ GSTBIN_API ._gst_debug_bin_to_dot_file_with_ts (this , details , fileName );
270265 else
271- gst .gst_debug_bin_to_dot_file (this , details , fileName );
266+ GSTBIN_API .gst_debug_bin_to_dot_file (this , details , fileName );
272267 }
273268
274269 /**
0 commit comments