11/*
2+ * Copyright (c) 2016 Christophe Lafolet
23 * Copyright (c) 2010 DHoyt <[email protected] > 34 *
45 * This file is part of gstreamer-java.
2122import org .freedesktop .gstreamer .Bin ;
2223import org .freedesktop .gstreamer .Caps ;
2324import org .freedesktop .gstreamer .Element ;
25+ import org .freedesktop .gstreamer .ElementFactory ;
2426import org .freedesktop .gstreamer .Pad ;
27+ import org .freedesktop .gstreamer .Query ;
2528import org .freedesktop .gstreamer .lowlevel .GValueAPI .GValueArray ;
2629import org .freedesktop .gstreamer .lowlevel .GstAPI .GstCallback ;
30+ import org .freedesktop .gstreamer .lowlevel .IntegerEnum ;
2731
2832/**
2933 * Utility {@link org.gstreamer.Element} to automatically identify media stream types and hook
@@ -60,8 +64,7 @@ public static interface UNKNOWN_TYPE {
6064 /**
6165 * Adds a listener for the <code>unknown-type</code> signal
6266 *
63- * @param listener Listener to be called when a new {@link Pad} is encountered
64- * on the {@link Element}
67+ * @param listener Listener to be called
6568 */
6669 public void connect (final UNKNOWN_TYPE listener ) {
6770 connect (UNKNOWN_TYPE .class , listener , new GstCallback () {
@@ -94,8 +97,7 @@ public static interface AUTOPLUG_CONTINUE {
9497 /**
9598 * Adds a listener for the <code>autoplug-continue</code> signal
9699 *
97- * @param listener Listener to be called when a new {@link Pad} is encountered
98- * on the {@link Element}
100+ * @param listener Listener to be called
99101 */
100102 public void connect (final AUTOPLUG_CONTINUE listener ) {
101103 connect (AUTOPLUG_CONTINUE .class , listener , new GstCallback () {
@@ -133,8 +135,7 @@ public static interface AUTOPLUG_FACTORIES {
133135 /**
134136 * Adds a listener for the <code>autoplug-factories</code> signal
135137 *
136- * @param listener Listener to be called when a new {@link Pad} is encountered
137- * on the {@link Element}
138+ * @param listener Listener to be called
138139 */
139140 public void connect (final AUTOPLUG_FACTORIES listener ) {
140141 connect (AUTOPLUG_FACTORIES .class , listener , new GstCallback () {
@@ -173,8 +174,7 @@ public static interface AUTOPLUG_SORT {
173174 /**
174175 * Adds a listener for the <code>autoplug-sort</code> signal
175176 *
176- * @param listener Listener to be called when a new {@link Pad} is encountered
177- * on the {@link Element}
177+ * @param listener Listener to be called
178178 */
179179 public void connect (final AUTOPLUG_SORT listener ) {
180180 connect (AUTOPLUG_SORT .class , listener , new GstCallback () {
@@ -193,6 +193,100 @@ public void disconnect(AUTOPLUG_SORT listener) {
193193 disconnect (AUTOPLUG_SORT .class , listener );
194194 }
195195
196+ public enum GstAutoplugSelectResult implements IntegerEnum {
197+ GST_AUTOPLUG_SELECT_TRY (0 ),
198+ GST_AUTOPLUG_SELECT_EXPOSE (1 ),
199+ GST_AUTOPLUG_SELECT_SKIP (2 );
200+
201+ GstAutoplugSelectResult (final int value ) {
202+ this .value = value ;
203+ }
204+ /**
205+ * Gets the integer value of the enum.
206+ * @return The integer value for this enum.
207+ */
208+ @ Override
209+ public int intValue () {
210+ return value ;
211+ }
212+ private final int value ;
213+ }
214+
215+ /**
216+ * Once {@link DecodeBin} has found the possible ElementFactory objects to
217+ * try for caps on pad, this signal is emitted. The purpose of the signal is
218+ * for the application to perform additional filtering on the
219+ * element factory array.
220+ *
221+ * The callee should copy and modify factories.
222+ */
223+ public static interface AUTOPLUG_SELECT {
224+ /**
225+ * @param element The element which has the new Pad.
226+ * @param pad the new Pad.
227+ * @param caps the caps of the pad that cannot be resolved.
228+ * @param factories A GValueArray of possible GstElementFactory to use.
229+ */
230+ public GstAutoplugSelectResult autoplugSelect (final DecodeBin element , final Pad pad , final Caps caps , final ElementFactory factory );
231+ }
232+ /**
233+ * Adds a listener for the <code>autoplug-select</code> signal
234+ *
235+ * @param listener Listener to be called
236+ */
237+ public void connect (final AUTOPLUG_SELECT listener ) {
238+ connect (AUTOPLUG_SELECT .class , listener , new GstCallback () {
239+ @ SuppressWarnings ("unused" )
240+ public GstAutoplugSelectResult callback (final DecodeBin elem , final Pad pad , final Caps caps , final ElementFactory factory ) {
241+ return listener .autoplugSelect (elem , pad , caps , factory );
242+ }
243+ });
244+ }
245+ /**
246+ * Removes a listener for the <code>autoplug-select</code> signal
247+ *
248+ * @param listener The listener that was previously added.
249+ */
250+ public void disconnect (final AUTOPLUG_SELECT listener ) {
251+ disconnect (AUTOPLUG_SELECT .class , listener );
252+ }
253+
254+ /**
255+ * This signal is emitted whenever an autoplugged element that is not linked downstream yet and not exposed does a query.
256+ * It can be used to tell the element about the downstream supported caps for example..
257+ */
258+ public static interface AUTOPLUG_QUERY {
259+ /**
260+ * @param element the decodebin.
261+ * @param pad the pad.
262+ * @param child the child element doing the query
263+ * @param query the query.
264+ */
265+ public boolean autoplugQuery (DecodeBin element , Pad pad , Element child , Query query );
266+ }
267+
268+ /**
269+ * Adds a listener for the <code>autoplug-query</code> signal
270+ *
271+ * @param listener Listener to be called
272+ */
273+ public void connect (final AUTOPLUG_QUERY listener ) {
274+ connect (AUTOPLUG_QUERY .class , listener , new GstCallback () {
275+ @ SuppressWarnings ("unused" )
276+ public boolean callback (DecodeBin elem , Pad pad , Element child , Query query ) {
277+ return listener .autoplugQuery (elem , pad , child , query );
278+ }
279+ });
280+ }
281+ /**
282+ * Removes a listener for the <code>autoplug-query</code> signal
283+ *
284+ * @param listener The listener that was previously added.
285+ */
286+ public void disconnect (AUTOPLUG_QUERY listener ) {
287+ disconnect (AUTOPLUG_QUERY .class , listener );
288+ }
289+
196290 /**
197291 * This signal is emitted once {@link DecodeBin} has finished decoding all the data.
198292 */
@@ -205,8 +299,7 @@ public static interface DRAINED {
205299 /**
206300 * Adds a listener for the <code>drained</code> signal
207301 *
208- * @param listener Listener to be called when a new {@link Pad} is encountered
209- * on the {@link Element}
302+ * @param listener Listener to be called
210303 */
211304 public void connect (final DRAINED listener ) {
212305 connect (DRAINED .class , listener , new GstCallback () {
0 commit comments