mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 08:17:01 +00:00
Gsmdec ported to 0.9. Tested with filesrc ! gsmdec ! alsasink and osssink.
Original commit message from CVS: Gsmdec ported to 0.9. Tested with filesrc ! gsmdec ! alsasink and osssink.
This commit is contained in:
parent
4de70b1520
commit
efbe7fb694
5 changed files with 65 additions and 77 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2005-09-23 Edgard Lima <edgard.lima@indt.org.br>
|
||||||
|
|
||||||
|
* ext/gsm/Makefile.am:
|
||||||
|
* ext/gsm/gstgsm.c:
|
||||||
|
* ext/gsm/gstgsmdec.c:
|
||||||
|
* PORTED_09:
|
||||||
|
Gsmdec ported to 0.9.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
2005-09-22 Arwed v. Merkatz <v.merkatz@gmx.net>
|
2005-09-22 Arwed v. Merkatz <v.merkatz@gmx.net>
|
||||||
|
|
||||||
* configure.ac:
|
* configure.ac:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
When porting a plugin start with 0.8 CVS head, not the old code in this module. There are many bugfixes which have gone into 0.8 which you want to keep.
|
When porting a plugin start with 0.8 CVS head, not the old code in this module. There are many bugfixes which have gone into 0.8 which you want to keep.
|
||||||
|
|
||||||
List of ported plugins (update when you commit a ported plugin):
|
List of ported plugins (update when you commit a ported plugin):
|
||||||
|
gsmdec (alima)
|
||||||
sdl (alima)
|
sdl (alima)
|
||||||
speed (fcarvalho)
|
speed (fcarvalho)
|
||||||
gsmenc (fcarvalho)
|
gsmenc (fcarvalho)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
plugin_LTLIBRARIES = libgstgsm.la
|
plugin_LTLIBRARIES = libgstgsm.la
|
||||||
|
|
||||||
libgstgsm_la_SOURCES = gstgsm.c gstgsmenc.c
|
libgstgsm_la_SOURCES = gstgsm.c gstgsmenc.c gstgsmdec.c
|
||||||
libgstgsm_la_CFLAGS = $(GST_CFLAGS) $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
|
libgstgsm_la_CFLAGS = $(GST_CFLAGS) $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
|
||||||
libgstgsm_la_LIBADD = $(GSM_LIBS) $(GST_PLUGINS_BASE_LIBS) \
|
libgstgsm_la_LIBADD = $(GSM_LIBS) $(GST_PLUGINS_BASE_LIBS) \
|
||||||
-lgstaudio-@GST_MAJORMINOR@
|
-lgstaudio-@GST_MAJORMINOR@
|
||||||
libgstgsm_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
libgstgsm_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||||
|
|
||||||
noinst_HEADERS = gstgsmenc.h
|
noinst_HEADERS = gstgsmenc.h gstgsmdec.h
|
||||||
|
|
|
@ -29,11 +29,9 @@ plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
if (!gst_element_register (plugin, "gsmenc", GST_RANK_NONE, GST_TYPE_GSMENC))
|
if (!gst_element_register (plugin, "gsmenc", GST_RANK_NONE, GST_TYPE_GSMENC))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
/*
|
|
||||||
if (!gst_element_register (plugin, "gsmdec", GST_RANK_PRIMARY,
|
if (!gst_element_register (plugin, "gsmdec", GST_RANK_PRIMARY,
|
||||||
GST_TYPE_GSMDEC))
|
GST_TYPE_GSMDEC))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
*/
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ static void gst_gsmdec_base_init (gpointer g_class);
|
||||||
static void gst_gsmdec_class_init (GstGSMDec * klass);
|
static void gst_gsmdec_class_init (GstGSMDec * klass);
|
||||||
static void gst_gsmdec_init (GstGSMDec * gsmdec);
|
static void gst_gsmdec_init (GstGSMDec * gsmdec);
|
||||||
|
|
||||||
static void gst_gsmdec_chain (GstPad * pad, GstData * _data);
|
static GstFlowReturn gst_gsmdec_chain (GstPad * pad, GstBuffer * buffer);
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
|
|
||||||
|
@ -143,89 +143,67 @@ gst_gsmdec_init (GstGSMDec * gsmdec)
|
||||||
gsmdec->next_of = 0;
|
gsmdec->next_of = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static GstFlowReturn
|
||||||
gst_gsmdec_chain (GstPad * pad, GstData * _data)
|
gst_gsmdec_chain (GstPad * pad, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
GstGSMDec *gsmdec;
|
GstGSMDec *gsmdec;
|
||||||
|
|
||||||
g_return_if_fail (pad != NULL);
|
|
||||||
g_return_if_fail (GST_IS_PAD (pad));
|
|
||||||
g_return_if_fail (_data != NULL);
|
|
||||||
|
|
||||||
gsmdec = GST_GSMDEC (gst_pad_get_parent (pad));
|
gsmdec = GST_GSMDEC (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
if (GST_IS_EVENT (_data)) {
|
gsm_byte *data = (gsm_byte *) GST_BUFFER_DATA (buf);
|
||||||
GstEvent *event = GST_EVENT (_data);
|
guint size = GST_BUFFER_SIZE (buf);
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
if (gsmdec->bufsize && (gsmdec->bufsize + size >= 33)) {
|
||||||
case GST_EVENT_EOS:{
|
GstBuffer *outbuf;
|
||||||
gst_element_set_eos (GST_ELEMENT (gsmdec));
|
|
||||||
gst_pad_push (gsmdec->srcpad, _data);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case GST_EVENT_DISCONTINUOUS:{
|
|
||||||
/* drop the discontinuity */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:{
|
|
||||||
gst_pad_event_default (pad, event);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else if (GST_IS_BUFFER (_data)) {
|
|
||||||
GstBuffer *buf = GST_BUFFER (_data);
|
|
||||||
gsm_byte *data = (gsm_byte *) GST_BUFFER_DATA (buf);
|
|
||||||
guint size = GST_BUFFER_SIZE (buf);
|
|
||||||
|
|
||||||
if (gsmdec->bufsize && (gsmdec->bufsize + size >= 33)) {
|
memcpy (gsmdec->buffer + gsmdec->bufsize, data,
|
||||||
GstBuffer *outbuf;
|
(33 - gsmdec->bufsize) * sizeof (gsm_byte));
|
||||||
|
|
||||||
memcpy (gsmdec->buffer + gsmdec->bufsize, data,
|
outbuf = gst_buffer_new_and_alloc (160 * sizeof (gsm_signal));
|
||||||
(33 - gsmdec->bufsize) * sizeof (gsm_byte));
|
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));
|
||||||
|
|
||||||
outbuf = gst_buffer_new_and_alloc (160 * sizeof (gsm_signal));
|
gsmdec->next_ts += 20 * GST_MSECOND;
|
||||||
GST_BUFFER_TIMESTAMP (outbuf) = gsmdec->next_ts;
|
gsmdec->next_of += 160;
|
||||||
GST_BUFFER_DURATION (outbuf) = 20 * GST_MSECOND;
|
|
||||||
GST_BUFFER_OFFSET (outbuf) = gsmdec->next_of;
|
|
||||||
GST_BUFFER_OFFSET_END (outbuf) = gsmdec->next_of + 160 - 1;
|
|
||||||
gsmdec->next_ts += 20 * GST_MSECOND;
|
|
||||||
gsmdec->next_of += 160;
|
|
||||||
|
|
||||||
gsm_decode (gsmdec->state, gsmdec->buffer,
|
gsm_decode (gsmdec->state, gsmdec->buffer,
|
||||||
(gsm_signal *) GST_BUFFER_DATA (outbuf));
|
(gsm_signal *) GST_BUFFER_DATA (outbuf));
|
||||||
|
|
||||||
gst_pad_push (gsmdec->srcpad, GST_DATA (outbuf));
|
gst_pad_push (gsmdec->srcpad, outbuf);
|
||||||
|
|
||||||
size -= (33 - gsmdec->bufsize);
|
size -= (33 - gsmdec->bufsize);
|
||||||
data += (33 - gsmdec->bufsize);
|
data += (33 - gsmdec->bufsize);
|
||||||
gsmdec->bufsize = 0;
|
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;
|
|
||||||
gsmdec->next_ts += 20 * GST_MSECOND;
|
|
||||||
gsmdec->next_of += 160;
|
|
||||||
|
|
||||||
gsm_decode (gsmdec->state, data, (gsm_signal *) GST_BUFFER_DATA (outbuf));
|
|
||||||
gst_pad_push (gsmdec->srcpad, GST_DATA (outbuf));
|
|
||||||
|
|
||||||
size -= 33;
|
|
||||||
data += 33;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (size) {
|
|
||||||
memcpy (gsmdec->buffer + gsmdec->bufsize, data, size * sizeof (gsm_byte));
|
|
||||||
gsmdec->bufsize += size;
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_buffer_unref (buf);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
gsm_decode (gsmdec->state, data, (gsm_signal *) GST_BUFFER_DATA (outbuf));
|
||||||
|
gst_pad_push (gsmdec->srcpad, outbuf);
|
||||||
|
|
||||||
|
size -= 33;
|
||||||
|
data += 33;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size) {
|
||||||
|
memcpy (gsmdec->buffer + gsmdec->bufsize, data, size * sizeof (gsm_byte));
|
||||||
|
gsmdec->bufsize += size;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue