summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sourceforge.net>2008-10-09 10:01:37 +0000
committerStefan Kost <ensonic@users.sourceforge.net>2008-10-09 10:01:37 +0000
commitf92e6bd51571e5f4b9c3bb1b117db1d3f29d8feb (patch)
treeb0d386a8e7ab78da8d4c53bcee704f47e9d2c17c /ext
parentef8649e92e897abd7d40b1da92939309e2b47245 (diff)
downloadgstreamer-plugins-bad-f92e6bd51571e5f4b9c3bb1b117db1d3f29d8feb.tar.gz
ext/amrwb/gstamrwbenc.*: Pass the discont flag from the input buffer on to the output buffer in the AMR encoder.
Original commit message from CVS: * ext/amrwb/gstamrwbenc.c: * ext/amrwb/gstamrwbenc.h: Pass the discont flag from the input buffer on to the output buffer in the AMR encoder.
Diffstat (limited to 'ext')
-rw-r--r--ext/amrwb/gstamrwbenc.c23
-rw-r--r--ext/amrwb/gstamrwbenc.h1
2 files changed, 22 insertions, 2 deletions
diff --git a/ext/amrwb/gstamrwbenc.c b/ext/amrwb/gstamrwbenc.c
index 6551b67bd..caf2adb74 100644
--- a/ext/amrwb/gstamrwbenc.c
+++ b/ext/amrwb/gstamrwbenc.c
@@ -279,6 +279,14 @@ gst_amrwbenc_chain (GstPad * pad, GstBuffer * buffer)
goto done;
}
+ /* discontinuity clears adapter, FIXME, maybe we can set some
+ * encoder flag to mask the discont. */
+ if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) {
+ gst_adapter_clear (amrwbenc->adapter);
+ amrwbenc->ts = 0;
+ amrwbenc->discont = TRUE;
+ }
+
if (GST_BUFFER_TIMESTAMP_IS_VALID (buffer))
amrwbenc->ts = GST_BUFFER_TIMESTAMP (buffer);
@@ -295,7 +303,13 @@ gst_amrwbenc_chain (GstPad * pad, GstBuffer * buffer)
GST_BUFFER_DURATION (out) = GST_SECOND * L_FRAME16k /
(amrwbenc->rate * amrwbenc->channels);
GST_BUFFER_TIMESTAMP (out) = amrwbenc->ts;
- amrwbenc->ts += GST_BUFFER_DURATION (out);
+ if (amrwbenc->ts != -1) {
+ amrwbenc->ts += GST_BUFFER_DURATION (out);
+ }
+ if (amrwbenc->discont) {
+ GST_BUFFER_FLAG_SET (out, GST_BUFFER_FLAG_DISCONT);
+ amrwbenc->discont = FALSE;
+ }
gst_buffer_set_caps (out, gst_pad_get_caps (amrwbenc->srcpad));
data = (guint8 *) gst_adapter_peek (amrwbenc->adapter, buffer_size);
@@ -308,7 +322,9 @@ gst_amrwbenc_chain (GstPad * pad, GstBuffer * buffer)
gst_adapter_flush (amrwbenc->adapter, buffer_size);
GST_BUFFER_SIZE (out) = outsize;
- ret = gst_pad_push (amrwbenc->srcpad, out);
+ /* play */
+ if ((ret = gst_pad_push (amrwbenc->srcpad, out)) != GST_FLOW_OK)
+ break;
}
done:
@@ -332,7 +348,10 @@ gst_amrwbenc_state_change (GstElement * element, GstStateChange transition)
return GST_STATE_CHANGE_FAILURE;
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
+ amrwbenc->rate = 0;
+ amrwbenc->channels = 0;
amrwbenc->ts = 0;
+ amrwbenc->discont = FALSE;
gst_adapter_clear (amrwbenc->adapter);
break;
default:
diff --git a/ext/amrwb/gstamrwbenc.h b/ext/amrwb/gstamrwbenc.h
index 1f3fa2d00..034a5bed1 100644
--- a/ext/amrwb/gstamrwbenc.h
+++ b/ext/amrwb/gstamrwbenc.h
@@ -47,6 +47,7 @@ struct _GstAmrwbEnc {
/* pads */
GstPad *sinkpad, *srcpad;
guint64 ts;
+ gboolean discont;
GstAdapter *adapter;