Skip to content

Commit 5d9c531

Browse files
committed
Add interfaces DEEP_ELEMENT_ADDED and DEEP_ELEMENT_REMOVED to Bin
1 parent 2f09960 commit 5d9c531

File tree

1 file changed

+83
-4
lines changed

1 file changed

+83
-4
lines changed

src/org/freedesktop/gstreamer/Bin.java

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2016 Christophe Lafolet
23
* Copyright (c) 2009 Levente Farkas
34
* Copyright (C) 2007 Wayne Meissner
45
* Copyright (C) 1999,2000 Erik Walthinsen <[email protected]>
@@ -21,16 +22,16 @@
2122

2223
package org.freedesktop.gstreamer;
2324

24-
import java.util.List;
25+
import static org.freedesktop.gstreamer.lowlevel.GstBinAPI.GSTBIN_API;
26+
import static org.freedesktop.gstreamer.lowlevel.GstParseAPI.GSTPARSE_API;
2527

26-
import com.sun.jna.Pointer;
28+
import java.util.List;
2729

2830
import org.freedesktop.gstreamer.lowlevel.GstAPI.GErrorStruct;
2931
import org.freedesktop.gstreamer.lowlevel.GstAPI.GstCallback;
3032
import org.freedesktop.gstreamer.lowlevel.GstTypes;
3133

32-
import static org.freedesktop.gstreamer.lowlevel.GstBinAPI.GSTBIN_API;
33-
import static org.freedesktop.gstreamer.lowlevel.GstParseAPI.GSTPARSE_API;
34+
import com.sun.jna.Pointer;
3435

3536
/**
3637
* Base class and element that can contain other elements.
@@ -294,6 +295,7 @@ public void callback(Bin bin, Element elem) {
294295
}
295296
});
296297
}
298+
297299
/**
298300
* Disconnect the listener for the <code>element-added</code> signal
299301
*
@@ -340,6 +342,83 @@ public void disconnect(ELEMENT_REMOVED listener) {
340342
disconnect(ELEMENT_REMOVED.class, listener);
341343
}
342344

345+
/**
346+
* Signal emitted when an {@link Element} is added to sub-bin of this {@link Bin}
347+
*
348+
* @see #connect(DEEP_ELEMENT_ADDED)
349+
* @see #disconnect(DEEP_ELEMENT_ADDED)
350+
*/
351+
public static interface DEEP_ELEMENT_ADDED {
352+
/**
353+
* Called when an {@link Element} is added to a {@link Bin}
354+
*
355+
* @param bin the Bin
356+
* @param sub_bin the Bin the element was added to.
357+
* @param element the {@link Element} that was added.
358+
*/
359+
public void elementAdded(Bin bin, Bin sub_bin, Element element);
360+
}
361+
/**
362+
* Add a listener for the <code>deep-element-added</code> signal on this Bin
363+
*
364+
* @param listener The listener to be called when an {@link Element} is added.
365+
*/
366+
public void connect(final DEEP_ELEMENT_ADDED listener) {
367+
connect(DEEP_ELEMENT_ADDED.class, listener, new GstCallback() {
368+
@SuppressWarnings("unused")
369+
public void callback(Bin bin, Bin sub_bin, Element elem) {
370+
listener.elementAdded(bin, sub_bin, elem);
371+
}
372+
});
373+
}
374+
375+
/**
376+
* Disconnect the listener for the <code>deep-element-added</code> signal
377+
*
378+
* @param listener The listener that was registered to receive the signal.
379+
*/
380+
public void disconnect(DEEP_ELEMENT_ADDED listener) {
381+
disconnect(DEEP_ELEMENT_ADDED.class, listener);
382+
}
383+
384+
/**
385+
* Signal emitted when an {@link Element} is removed from sub-bin of this {@link Bin}
386+
*
387+
* @see #connect(ELEMENT_REMOVED)
388+
* @see #disconnect(ELEMENT_REMOVED)
389+
*/
390+
public static interface DEEP_ELEMENT_REMOVED {
391+
/**
392+
* Called when an {@link Element} is removed from a {@link Bin}
393+
*
394+
* @param bin the Bin
395+
* @param sub_bin the Bin the element was removed from.
396+
* @param element the {@link Element} that was removed.
397+
*/
398+
public void elementRemoved(Bin bin, Bin sub_bin, Element element);
399+
}
400+
/**
401+
* Add a listener for the <code>deep-element-removed</code> signal on this Bin
402+
*
403+
* @param listener The listener to be called when an {@link Element} is removed.
404+
*/
405+
public void connect(final DEEP_ELEMENT_REMOVED listener) {
406+
connect(DEEP_ELEMENT_REMOVED.class, listener, new GstCallback() {
407+
@SuppressWarnings("unused")
408+
public void callback(Bin bin, Bin sub_bin, Element elem) {
409+
listener.elementRemoved(bin, sub_bin, elem);
410+
}
411+
});
412+
}
413+
/**
414+
* Disconnect the listener for the <code>deep-element-removed</code> signal
415+
*
416+
* @param listener The listener that was registered to receive the signal.
417+
*/
418+
public void disconnect(DEEP_ELEMENT_REMOVED listener) {
419+
disconnect(DEEP_ELEMENT_REMOVED.class, listener);
420+
}
421+
343422
/**
344423
* Signal emitted when an {@link Element} has latency
345424
*

0 commit comments

Comments
 (0)