Skip to content

Commit eafe3eb

Browse files
Merge pull request #63 from lafoletc/Bin
Add interfaces DEEP_ELEMENT_ADDED and DEEP_ELEMENT_REMOVED to Bin
2 parents aa0dd4e + 384bbdf commit eafe3eb

File tree

1 file changed

+87
-4
lines changed

1 file changed

+87
-4
lines changed

src/org/freedesktop/gstreamer/Bin.java

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

0 commit comments

Comments
 (0)