From 054842ca82815daecbe34d9bd5c86f4e6d649555 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Mon, 18 Feb 2008 13:51:34 +0000 Subject: [PATCH] configure.ac: Require CVS of core for new API in collectpads. Original commit message from CVS: * configure.ac: Require CVS of core for new API in collectpads. * gst/adder/gstadder.c: Use new API to make adder sparse stream aware. --- ChangeLog | 8 ++++++++ configure.ac | 2 +- gst/adder/gstadder.c | 55 +++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 83e39ce..92b5f46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-02-18 Stefan Kost + + * configure.ac: + Require CVS of core for new API in collectpads. + + * gst/adder/gstadder.c: + Use new API to make adder sparse stream aware. + 2008-02-18 Wim Taymans * gst/playback/gstplaybin2.c: (pad_added_cb), (pad_removed_cb), diff --git a/configure.ac b/configure.ac index c12068d..15ab88f 100644 --- a/configure.ac +++ b/configure.ac @@ -54,7 +54,7 @@ dnl AS_LIBTOOL_TAGS AM_PROG_LIBTOOL dnl *** required versions of GStreamer stuff *** -GST_REQ=0.10.15.1 +GST_REQ=0.10.17.1 dnl *** autotools stuff **** diff --git a/gst/adder/gstadder.c b/gst/adder/gstadder.c index 1b6c7c7..f7ee290 100644 --- a/gst/adder/gstadder.c +++ b/gst/adder/gstadder.c @@ -701,6 +701,7 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data) GstBuffer *outbuf; GstFlowReturn ret; gpointer outbytes; + gboolean empty = TRUE; adder = GST_ADDER (user_data); @@ -724,18 +725,22 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data) GstCollectData *data; guint8 *bytes; guint len; + GstBuffer *inbuf; data = (GstCollectData *) collected->data; - /* get pointer to copy size bytes */ - len = gst_collect_pads_read (pads, data, &bytes, size); - /* length 0 means EOS or an empty buffer so we still need to flush in + /* get a subbuffer of size bytes */ + inbuf = gst_collect_pads_take_buffer (pads, data, size); + /* NULL means EOS or an empty buffer so we still need to flush in * case of an empty buffer. */ - if (len == 0) { + if (inbuf == NULL) { GST_LOG_OBJECT (adder, "channel %p: no bytes available", data); goto next; } + bytes = GST_BUFFER_DATA (inbuf); + len = GST_BUFFER_SIZE (inbuf); + if (outbuf == NULL) { GST_LOG_OBJECT (adder, "channel %p: making output buffer of %d bytes", data, size); @@ -746,23 +751,37 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data) outbytes = GST_BUFFER_DATA (outbuf); gst_buffer_set_caps (outbuf, GST_PAD_CAPS (adder->srcpad)); - /* clear if we are only going to fill a partial buffer */ - if (G_UNLIKELY (size > len)) - memset (outbytes, 0, size); + if (!GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP)) { + /* clear if we are only going to fill a partial buffer */ + if (G_UNLIKELY (size > len)) + memset (outbytes, 0, size); - GST_LOG_OBJECT (adder, "channel %p: copying %d bytes from data %p", - data, len, bytes); + GST_LOG_OBJECT (adder, "channel %p: copying %d bytes from data %p", + data, len, bytes); - /* and copy the data into it */ - memcpy (outbytes, bytes, len); + /* and copy the data into it */ + memcpy (outbytes, bytes, len); + empty = FALSE; + } else { + GST_LOG_OBJECT (adder, "channel %p: zeroing %d bytes from data %p", + data, len, bytes); + memset (outbytes, 0, size); + } } else { - GST_LOG_OBJECT (adder, "channel %p: mixing %d bytes from data %p", - data, len, bytes); - /* other buffers, need to add them */ - adder->func ((gpointer) outbytes, (gpointer) bytes, len); + if (!GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP)) { + GST_LOG_OBJECT (adder, "channel %p: mixing %d bytes from data %p", + data, len, bytes); + /* other buffers, need to add them */ + adder->func ((gpointer) outbytes, (gpointer) bytes, len); + empty = FALSE; + } else { + GST_LOG_OBJECT (adder, "channel %p: skipping %d bytes from data %p", + data, len, bytes); + } } next: - gst_collect_pads_flush (pads, data, len); + if (inbuf) + gst_buffer_unref (inbuf); } /* can only happen when no pads to collect or all EOS */ @@ -810,6 +829,10 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data) GST_BUFFER_DURATION (outbuf) = adder->timestamp - GST_BUFFER_TIMESTAMP (outbuf); + /* if we only processed silence, mark output again as silence */ + if (empty) + GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP); + /* send it out */ GST_LOG_OBJECT (adder, "pushing outbuf, timestamp %" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf))); -- 2.7.4