@@ -391,6 +391,17 @@ public static interface EVENT_PROBE {
391391 public PadProbeReturn eventReceived (Pad pad , Event event );
392392 }
393393
394+ /**
395+ * Signal emitted when new data is available on the {@link Pad}
396+ *
397+ * @see #addDataProbe(DATA_PROBE)
398+ * @see #removeDataProbe(DATA_PROBE)
399+ */
400+ public static interface DATA_PROBE {
401+ public PadProbeReturn dataReceived (Pad pad , Buffer buffer );
402+ }
403+
404+
394405 /**
395406 * Add a listener for the <code>have-data</code> signal on this {@link Pad}
396407 *
@@ -518,6 +529,36 @@ protected void disconnect() {
518529 public void removeEventProbe (EVENT_PROBE listener ) {
519530 removeCallback (EVENT_PROBE .class , listener );
520531 }
532+
533+
534+ public synchronized void addDataProbe (final DATA_PROBE listener ) {
535+
536+ final GstPadAPI .PadProbeCallback probe = new GstPadAPI .PadProbeCallback () {
537+ public PadProbeReturn callback (Pad pad , GstPadProbeInfo probeInfo , Pointer user_data ) {
538+ if ((probeInfo .padProbeType & GstPadAPI .GST_PAD_PROBE_TYPE_BUFFER ) != 0 ) {
539+ Buffer buffer = GSTPAD_API .gst_pad_probe_info_get_buffer (probeInfo );
540+ return listener .dataReceived (pad , buffer );
541+ }
542+
543+ //We have to negate the return value to keep consistency with gstreamer's API
544+ return PadProbeReturn .OK ;
545+ }
546+ };
547+
548+ GCallback cb = new GCallback (GSTPAD_API .gst_pad_add_probe (this , GstPadAPI .GST_PAD_PROBE_TYPE_BUFFER , probe , null , null ), probe ) {
549+ @ Override
550+ protected void disconnect () {
551+ GSTPAD_API .gst_pad_remove_probe (Pad .this , id );
552+ }
553+ };
554+
555+ addCallback (DATA_PROBE .class , listener , cb );
556+ }
557+
558+ public void removeDataProbe (DATA_PROBE listener ) {
559+ removeCallback (DATA_PROBE .class , listener );
560+ }
561+
521562
522563 /**
523564 * Sends the event to this pad.
@@ -612,4 +653,29 @@ public FlowReturn getRange(long offset, int size, Buffer[] buffer) {
612653 public FlowReturn pullRange (long offset , int size , Buffer [] buffer ) {
613654 return GSTPAD_API .gst_pad_pull_range (this , offset , size , buffer );
614655 }
656+
657+
658+
659+ /**
660+ * Pushes a buffer to the peer of pad .
661+ * This function will call installed block probes before triggering any
662+ * installed data probes.
663+ *
664+ * The function proceeds calling gst_pad_chain() on the peer pad and returns
665+ * the value from that function. If pad has no peer, GST_FLOW_NOT_LINKED
666+ * will be returned.
667+ *
668+ * In all cases, success or failure, the caller loses its reference to
669+ * buffer after calling this function.
670+ *
671+ * @param buffer
672+ * the GstBuffer to push returns GST_FLOW_ERROR if not. [transfer full]
673+ * @return
674+ * a GstFlowReturn from the peer pad.
675+ *
676+ * MT safe.
677+ */
678+ public FlowReturn push (final Buffer buffer ) {
679+ return GSTPAD_API .gst_pad_push (this , buffer );
680+ }
615681}
0 commit comments