summaryrefslogtreecommitdiffstats
path: root/ext/gsm/gstgsmdec.c
diff options
context:
space:
mode:
authorZeeshan Ali <zeenix@gmail.com>2005-10-25 16:12:03 +0000
committerZeeshan Ali <zeenix@gmail.com>2005-10-25 16:12:03 +0000
commit6510eef093ab1598b9c50c2b7e0c209fb2752742 (patch)
treeeaed15df84e749001c3af94c3ef8206f75ea9700 /ext/gsm/gstgsmdec.c
parent4d87f79f855df25112106445c2ec5917bc3ce40d (diff)
downloadgst-plugins-bad-6510eef093ab1598b9c50c2b7e0c209fb2752742.tar.gz
gst-plugins-bad-6510eef093ab1598b9c50c2b7e0c209fb2752742.tar.bz2
gst-plugins-bad-6510eef093ab1598b9c50c2b7e0c209fb2752742.zip
Over-writing Wim's gsm plugins (currently not working) with that from the farsight repo. Also made sure that they wor...
Original commit message from CVS: Over-writing Wim's gsm plugins (currently not working) with that from the farsight repo. Also made sure that they work with the RTP (de)payloader.
Diffstat (limited to 'ext/gsm/gstgsmdec.c')
-rw-r--r--ext/gsm/gstgsmdec.c92
1 files changed, 44 insertions, 48 deletions
diff --git a/ext/gsm/gstgsmdec.c b/ext/gsm/gstgsmdec.c
index f3ce9cf5..c2ff695d 100644
--- a/ext/gsm/gstgsmdec.c
+++ b/ext/gsm/gstgsmdec.c
@@ -1,5 +1,7 @@
-/* GStreamer
- * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+/*
+ * Farsight
+ * GStreamer GSM decoder
+ * Copyright (C) 2005 Philippe Khalaf <burger@speedy.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -25,12 +27,15 @@
#include "gstgsmdec.h"
+GST_DEBUG_CATEGORY (gsmdec_debug);
+#define GST_CAT_DEFAULT (gsmdec_debug)
+
/* elementfactory information */
GstElementDetails gst_gsmdec_details = {
"GSM audio decoder",
"Codec/Decoder/Audio",
"Decodes GSM encoded audio",
- "Wim Taymans <wim.taymans@chello.be>",
+ "Philippe Khalaf <burger@speedy.org>",
};
/* GSMDec signals and args */
@@ -42,15 +47,15 @@ enum
enum
{
+ /* FILL ME */
ARG_0
- /* FILL ME */
};
static void gst_gsmdec_base_init (gpointer g_class);
static void gst_gsmdec_class_init (GstGSMDec * klass);
static void gst_gsmdec_init (GstGSMDec * gsmdec);
-static GstFlowReturn gst_gsmdec_chain (GstPad * pad, GstBuffer * buffer);
+static GstFlowReturn gst_gsmdec_chain (GstPad * pad, GstBuffer * buf);
static GstElementClass *parent_class = NULL;
@@ -118,13 +123,13 @@ gst_gsmdec_class_init (GstGSMDec * klass)
gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
+
+ GST_DEBUG_CATEGORY_INIT (gsmdec_debug, "gsmdec", 0, "GSM Decoder");
}
static void
gst_gsmdec_init (GstGSMDec * gsmdec)
{
- GST_DEBUG ("gst_gsmdec_init: initializing");
-
/* create the sink and src pads */
gsmdec->sinkpad =
gst_pad_new_from_template (gst_static_pad_template_get
@@ -138,72 +143,63 @@ gst_gsmdec_init (GstGSMDec * gsmdec)
gst_element_add_pad (GST_ELEMENT (gsmdec), gsmdec->srcpad);
gsmdec->state = gsm_create ();
- gsmdec->bufsize = 0;
- gsmdec->next_ts = 0;
+ // turn on WAN49 handling
+ gint use_wav49 = 0;
+
+ gsm_option (gsmdec->state, GSM_OPT_WAV49, &use_wav49);
+
gsmdec->next_of = 0;
+ gsmdec->next_ts = 0;
}
static GstFlowReturn
gst_gsmdec_chain (GstPad * pad, GstBuffer * buf)
{
GstGSMDec *gsmdec;
+ gsm_byte *data;
+
+ g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR);
gsmdec = GST_GSMDEC (gst_pad_get_parent (pad));
+ g_return_val_if_fail (GST_IS_GSMDEC (gsmdec), GST_FLOW_ERROR);
- gsm_byte *data = (gsm_byte *) GST_BUFFER_DATA (buf);
- guint size = GST_BUFFER_SIZE (buf);
+ g_return_val_if_fail (GST_PAD_IS_LINKED (gsmdec->srcpad), GST_FLOW_ERROR);
- if (gsmdec->bufsize && (gsmdec->bufsize + size >= 33)) {
+ // do we have enough bytes to read a header
+ if (GST_BUFFER_SIZE (buf) >= 33) {
GstBuffer *outbuf;
- memcpy (gsmdec->buffer + gsmdec->bufsize, data,
- (33 - gsmdec->bufsize) * sizeof (gsm_byte));
-
outbuf = gst_buffer_new_and_alloc (160 * sizeof (gsm_signal));
- GST_BUFFER_TIMESTAMP (outbuf) = gsmdec->next_ts;
- GST_BUFFER_DURATION (outbuf) = 20 * GST_MSECOND;
- GST_BUFFER_OFFSET (outbuf) = gsmdec->next_of;
- GST_BUFFER_OFFSET_END (outbuf) = gsmdec->next_of + 160 - 1;
- gst_buffer_set_caps (outbuf, gst_pad_get_caps (gsmdec->srcpad));
+ // TODO take new segment in consideration, if not given restart
+ // timestamps at 0
+ if (GST_BUFFER_TIMESTAMP (buf) == GST_CLOCK_TIME_NONE) {
+ /* If we are not given any timestamp */
+ GST_BUFFER_TIMESTAMP (outbuf) = gsmdec->next_ts;
+ gsmdec->next_ts += 20 * GST_MSECOND;
+ }
+
+ else {
+ /* But if you insist on giving us a timestamp, you are welcome. */
+ GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
+ }
- gsmdec->next_ts += 20 * GST_MSECOND;
- gsmdec->next_of += 160;
-
- gsm_decode (gsmdec->state, gsmdec->buffer,
- (gsm_signal *) GST_BUFFER_DATA (outbuf));
-
- gst_pad_push (gsmdec->srcpad, outbuf);
-
- size -= (33 - gsmdec->bufsize);
- data += (33 - gsmdec->bufsize);
- gsmdec->bufsize = 0;
- }
-
- while (size >= 33) {
- GstBuffer *outbuf;
-
- outbuf = gst_buffer_new_and_alloc (160 * sizeof (gsm_signal));
- GST_BUFFER_TIMESTAMP (outbuf) = gsmdec->next_ts;
GST_BUFFER_DURATION (outbuf) = 20 * GST_MSECOND;
GST_BUFFER_OFFSET (outbuf) = gsmdec->next_of;
GST_BUFFER_OFFSET_END (outbuf) = gsmdec->next_of + 160 - 1;
gst_buffer_set_caps (outbuf, gst_pad_get_caps (gsmdec->srcpad));
-
- gsmdec->next_ts += 20 * GST_MSECOND;
gsmdec->next_of += 160;
+ data = (gsm_byte *) GST_BUFFER_DATA (buf);
gsm_decode (gsmdec->state, data, (gsm_signal *) GST_BUFFER_DATA (outbuf));
- gst_pad_push (gsmdec->srcpad, outbuf);
- size -= 33;
- data += 33;
+ GST_DEBUG ("Pushing buffer of size %d ts %" GST_TIME_FORMAT,
+ GST_BUFFER_SIZE (outbuf),
+ GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)));
+ //gst_util_dump_mem (GST_BUFFER_DATA(outbuf), GST_BUFFER_SIZE (outbuf));
+ gst_pad_push (gsmdec->srcpad, outbuf);
}
- if (size) {
- memcpy (gsmdec->buffer + gsmdec->bufsize, data, size * sizeof (gsm_byte));
- gsmdec->bufsize += size;
- }
+ gst_buffer_unref (buf);
return GST_FLOW_OK;
-
}