added hermes

Original commit message from CVS:
added hermes
parent 854a7e0a
......@@ -473,9 +473,10 @@ GST_CHECK_CONFIGPROG(GNOME_VFS, gnome-config vfs)
])
dnl *** gsm ***
translit(dnm, m, l) AM_CONDITIONAL(USE_LIBGSM, true)
GST_CHECK_FEATURE(LIBGSM, [GSM library], gsmenc gsmdec, [
GST_CHECK_LIBHEADER(LIBGSM, gsm, gsm_create, , gsm/gsm.h, LIBGSM_LIBS="-lgsm")
translit(dnm, m, l) AM_CONDITIONAL(USE_GSM, true)
GST_CHECK_FEATURE(GSM, [GSM library], gsmenc gsmdec, [
GST_CHECK_LIBHEADER(GSM, gsm, gsm_create, , gsm/gsm.h, GSM_LIBS="-lgsm")
AC_SUBST(GSM_LIBS)
])
dnl *** Hermes ***
......@@ -1076,6 +1077,8 @@ ext/cdparanoia/Makefile
ext/dvdread/Makefile
ext/esd/Makefile
ext/flac/Makefile
ext/gsm/Makefile
ext/hermes/Makefile
ext/lame/Makefile
ext/mad/Makefile
ext/mpeg2dec/Makefile
......
......@@ -52,12 +52,24 @@ endif
FESTIVAL_DIR=
## endif
if USE_GSM
GSM_DIR=gsm
else
GSM_DIR=
endif
if USE_FLAC
FLAC_DIR=flac
else
FLAC_DIR=
endif
if USE_HERMES
HERMES_DIR=hermes
else
HERMES_DIR=
endif
if USE_LAME
LAME_DIR=lame
else
......@@ -90,9 +102,9 @@ endif
SUBDIRS=$(A52_DIR) $(AALIB_DIR) $(ALSA_DIR) $(AUDIOFILE_DIR) \
$(AVIFILE_DIR) $(CDPARANOIA_DIR) $(DVDREAD_DIR) $(ESD_DIR) \
$(FESTIVAL_DIR) $(FLAC_DIR) \
$(FESTIVAL_DIR) $(FLAC_DIR) $(GSM_DIR) $(HERMES_DIR) \
$(LAME_DIR) $(MAD_DIR) $(MPEG2DEC_DIR) \
$(SDL_DIR) $(VORBIS_DIR)
DIST_SUBDIRS=a52 aalib alsa avifile audiofile cdparanoia dvdread esd \
festival flac lame mad mpeg2dec sdl vorbis
festival flac gsm hermes lame mad mpeg2dec sdl vorbis
plugindir = $(libdir)/gst
plugin_LTLIBRARIES = libgstgsm.la
libgstgsm_la_SOURCES = gstgsm.c gstgsmdec.c gstgsmenc.c
libgstgsm_la_LIBADD = $(GSM_LIBS)
libgstgsm_la_CFLAGS = $(GST_CFLAGS)
noinst_HEADERS = gstgsmenc.h gstgsmdec.h
#check_PROGRAMS = test
#test_CFLAGS = $(GSM_CFLAGS)
#test_LDADD = $(GSM_LIBS) $(top_srcdir)/gst/libgst.la
#test_SOURCES = test.c
/* Gnome-Streamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "gstgsmdec.h"
#include "gstgsmenc.h"
/* elementfactory information */
extern GstElementDetails gst_gsmdec_details;
extern GstElementDetails gst_gsmenc_details;
GstPadTemplate *gsmdec_src_template, *gsmdec_sink_template;
GstPadTemplate *gsmenc_src_template, *gsmenc_sink_template;
GST_CAPS_FACTORY (gsm_caps_factory,
GST_CAPS_NEW (
"gsm_gsm",
"audio/x-gsm",
"rate", GST_PROPS_INT_RANGE (4000, 48000)
)
)
GST_CAPS_FACTORY (raw_caps_factory,
GST_CAPS_NEW (
"gsm_raw",
"audio/raw",
"format", GST_PROPS_STRING ("int"),
"law", GST_PROPS_INT (0),
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_INT (16),
"depth", GST_PROPS_INT (16),
"rate", GST_PROPS_INT_RANGE (4000, 48000),
"channels", GST_PROPS_INT (1)
)
)
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
GstElementFactory *dec, *enc;
GstCaps *raw_caps, *gsm_caps;
/* create an elementfactory for the gsmdec element */
enc = gst_elementfactory_new("gsmenc",GST_TYPE_GSMENC,
&gst_gsmenc_details);
g_return_val_if_fail(enc != NULL, FALSE);
raw_caps = GST_CAPS_GET (raw_caps_factory);
gsm_caps = GST_CAPS_GET (gsm_caps_factory);
/* register sink pads */
gsmenc_sink_template = gst_padtemplate_new ("sink", GST_PAD_SINK,
GST_PAD_ALWAYS,
raw_caps, NULL);
gst_elementfactory_add_padtemplate (enc, gsmenc_sink_template);
/* register src pads */
gsmenc_src_template = gst_padtemplate_new ("src", GST_PAD_SRC,
GST_PAD_ALWAYS,
gsm_caps, NULL);
gst_elementfactory_add_padtemplate (enc, gsmenc_src_template);
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (enc));
/* create an elementfactory for the gsmdec element */
dec = gst_elementfactory_new("gsmdec",GST_TYPE_GSMDEC,
&gst_gsmdec_details);
g_return_val_if_fail(dec != NULL, FALSE);
/* register sink pads */
gsmdec_sink_template = gst_padtemplate_new ("sink", GST_PAD_SINK,
GST_PAD_ALWAYS,
gsm_caps, NULL);
gst_elementfactory_add_padtemplate (dec, gsmdec_sink_template);
/* register src pads */
gsmdec_src_template = gst_padtemplate_new ("src", GST_PAD_SRC,
GST_PAD_ALWAYS,
raw_caps, NULL);
gst_elementfactory_add_padtemplate (dec, gsmdec_src_template);
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (dec));
return TRUE;
}
GstPluginDesc plugin_desc = {
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gsm",
plugin_init
};
/* Gnome-Streamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include "gstgsmdec.h"
extern GstPadTemplate *gsmdec_src_template, *gsmdec_sink_template;
/* elementfactory information */
GstElementDetails gst_gsmdec_details = {
"gsm audio decoder",
"Filter/Decoder/Audio",
".gsm",
VERSION,
"Wim Taymans <wim.taymans@chello.be>",
"(C) 2000",
};
/* GSMDec signals and args */
enum {
/* FILL ME */
LAST_SIGNAL
};
enum {
ARG_0,
/* FILL ME */
};
static void gst_gsmdec_class_init (GstGSMDec *klass);
static void gst_gsmdec_init (GstGSMDec *gsmdec);
static void gst_gsmdec_chain (GstPad *pad, GstBuffer *buf);
static void gst_gsmdec_newcaps (GstPad *pad, GstCaps *caps);
static GstElementClass *parent_class = NULL;
//static guint gst_gsmdec_signals[LAST_SIGNAL] = { 0 };
GType
gst_gsmdec_get_type(void) {
static GType gsmdec_type = 0;
if (!gsmdec_type) {
static const GTypeInfo gsmdec_info = {
sizeof(GstGSMDecClass), NULL,
NULL,
(GClassInitFunc)gst_gsmdec_class_init,
NULL,
NULL,
sizeof(GstGSMDec),
0,
(GInstanceInitFunc)gst_gsmdec_init,
};
gsmdec_type = g_type_register_static(GST_TYPE_ELEMENT, "GstGSMDec", &gsmdec_info, 0);
}
return gsmdec_type;
}
static void
gst_gsmdec_class_init (GstGSMDec *klass)
{
GstElementClass *gstelement_class;
gstelement_class = (GstElementClass*)klass;
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
}
static void
gst_gsmdec_init (GstGSMDec *gsmdec)
{
GST_DEBUG (0,"gst_gsmdec_init: initializing\n");
/* create the sink and src pads */
gsmdec->sinkpad = gst_pad_new_from_template (gsmdec_sink_template, "sink");
gst_element_add_pad (GST_ELEMENT (gsmdec), gsmdec->sinkpad);
gst_pad_set_chain_function (gsmdec->sinkpad, gst_gsmdec_chain);
gst_pad_set_newcaps_function (gsmdec->sinkpad, gst_gsmdec_newcaps);
gsmdec->srcpad = gst_pad_new_from_template (gsmdec_src_template, "src");
gst_element_add_pad (GST_ELEMENT (gsmdec), gsmdec->srcpad);
gsmdec->state = gsm_create ();
gsmdec->bufsize = 0;
}
static void
gst_gsmdec_newcaps (GstPad *pad, GstCaps *caps)
{
GstGSMDec *gsmdec;
gsmdec = GST_GSMDEC (gst_pad_get_parent (pad));
gst_pad_set_caps (gsmdec->srcpad, GST_CAPS_NEW (
"gsm_raw",
"audio/raw",
"format", GST_PROPS_STRING ("int"),
"law", GST_PROPS_INT (0),
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_INT (16),
"depth", GST_PROPS_INT (16),
"rate", GST_PROPS_INT (gst_caps_get_int (caps, "rate")),
"channels", GST_PROPS_INT (1)
));
}
static void
gst_gsmdec_chain (GstPad *pad, GstBuffer *buf)
{
GstGSMDec *gsmdec;
gsm_byte *data;
guint size;
g_return_if_fail(pad != NULL);
g_return_if_fail(GST_IS_PAD(pad));
g_return_if_fail(buf != NULL);
//g_return_if_fail(GST_IS_BUFFER(buf));
gsmdec = GST_GSMDEC (gst_pad_get_parent (pad));
data = (gsm_byte*) GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
if (gsmdec->bufsize && (gsmdec->bufsize + size >= 33)) {
GstBuffer *outbuf;
memcpy (gsmdec->buffer + gsmdec->bufsize, data, (33 - gsmdec->bufsize) * sizeof (gsm_byte));
outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = g_malloc (160 * sizeof (gsm_signal));
GST_BUFFER_SIZE (outbuf) = 160 * sizeof (gsm_signal);
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 ();
GST_BUFFER_DATA (outbuf) = g_malloc (160 * sizeof (gsm_signal));
GST_BUFFER_SIZE (outbuf) = 160 * sizeof (gsm_signal);
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;
}
gst_buffer_unref(buf);
}
/* Gnome-Streamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_GSMDEC_H__
#define __GST_GSMDEC_H__
#include <config.h>
#include <gst/gst.h>
#include <gsm/gsm.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GST_TYPE_GSMDEC \
(gst_gsmdec_get_type())
#define GST_GSMDEC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GSMDEC,GstGSMDec))
#define GST_GSMDEC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GSMDEC,GstGSMDec))
#define GST_IS_GSMDEC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GSMDEC))
#define GST_IS_GSMDEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GSMDEC))
typedef struct _GstGSMDec GstGSMDec;
typedef struct _GstGSMDecClass GstGSMDecClass;
struct _GstGSMDec {
GstElement element;
/* pads */
GstPad *sinkpad,*srcpad;
gsm state;
gsm_byte buffer[33];
gint bufsize;
};
struct _GstGSMDecClass {
GstElementClass parent_class;
};
GType gst_gsmdec_get_type(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GST_GSMDEC_H__ */
/* Gnome-Streamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include "gstgsmenc.h"
extern GstPadTemplate *gsmenc_src_template, *gsmenc_sink_template;
/* elementfactory information */
GstElementDetails gst_gsmenc_details = {
"gsm audio encoder",
"Filter/Encoder/Audio",
".gsm",
VERSION,
"Wim Taymans <wim.taymans@chello.be>",
"(C) 2000",
};
/* GSMEnc signals and args */
enum {
FRAME_ENCODED,
/* FILL ME */
LAST_SIGNAL
};
enum {
ARG_0,
/* FILL ME */
};
static void gst_gsmenc_class_init (GstGSMEnc *klass);
static void gst_gsmenc_init (GstGSMEnc *gsmenc);
static void gst_gsmenc_chain (GstPad *pad,GstBuffer *buf);
static void gst_gsmenc_newcaps (GstPad *pad, GstCaps *caps);
static GstElementClass *parent_class = NULL;
static guint gst_gsmenc_signals[LAST_SIGNAL] = { 0 };
GType
gst_gsmenc_get_type (void)
{
static GType gsmenc_type = 0;
if (!gsmenc_type) {
static const GTypeInfo gsmenc_info = {
sizeof (GstGSMEncClass),
NULL,
NULL,
(GClassInitFunc) gst_gsmenc_class_init,
NULL,
NULL,
sizeof (GstGSMEnc),
0,
(GInstanceInitFunc) gst_gsmenc_init,
};
gsmenc_type = g_type_register_static (GST_TYPE_ELEMENT, "GstGSMEnc", &gsmenc_info, 0);
}
return gsmenc_type;
}
static void
gst_gsmenc_class_init (GstGSMEnc *klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass*) klass;
gstelement_class = (GstElementClass*) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gst_gsmenc_signals[FRAME_ENCODED] =
g_signal_new ("frame_encoded", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstGSMEncClass, frame_encoded), NULL, NULL,
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}
static void
gst_gsmenc_init (GstGSMEnc *gsmenc)
{
/* create the sink and src pads */
gsmenc->sinkpad = gst_pad_new_from_template (gsmenc_sink_template, "sink");
gst_element_add_pad (GST_ELEMENT (gsmenc), gsmenc->sinkpad);
gst_pad_set_chain_function (gsmenc->sinkpad, gst_gsmenc_chain);
gst_pad_set_newcaps_function (gsmenc->sinkpad, gst_gsmenc_newcaps);
gsmenc->srcpad = gst_pad_new_from_template (gsmenc_src_template, "src");
gst_element_add_pad (GST_ELEMENT (gsmenc), gsmenc->srcpad);
gsmenc->state = gsm_create ();
gsmenc->bufsize = 0;
gsmenc->next_ts = 0;
gsmenc->rate = 8000;
}
static void
gst_gsmenc_newcaps (GstPad *pad, GstCaps *caps)
{
GstGSMEnc *gsmenc;
gsmenc = GST_GSMENC (gst_pad_get_parent (pad));
gsmenc->rate = gst_caps_get_int (caps, "rate");
gst_pad_set_caps (gsmenc->srcpad, GST_CAPS_NEW (
"gsm_gsm",
"audio/x-gsm",
"rate", GST_PROPS_INT (gsmenc->rate)
));
}
static void
gst_gsmenc_chain (GstPad *pad, GstBuffer *buf)
{
GstGSMEnc *gsmenc;
gsm_signal *data;
guint size;
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (buf != NULL);
gsmenc = GST_GSMENC (GST_OBJECT_PARENT (pad));
data = (gsm_signal*) GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf) / sizeof (gsm_signal);
if (gsmenc->bufsize && (gsmenc->bufsize + size >= 160)) {
GstBuffer *outbuf;
memcpy (gsmenc->buffer + gsmenc->bufsize, data, (160 - gsmenc->bufsize) * sizeof (gsm_signal));
outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = g_malloc (33 * sizeof (gsm_byte));
GST_BUFFER_SIZE (outbuf) = 33 * sizeof (gsm_byte);
gsm_encode (gsmenc->state, gsmenc->buffer, (gsm_byte *) GST_BUFFER_DATA (outbuf));
GST_BUFFER_TIMESTAMP (outbuf) = gsmenc->next_ts;
gst_pad_push (gsmenc->srcpad, outbuf);
gsmenc->next_ts += (160.0 / gsmenc->rate) * 1000000;
size -= (160 - gsmenc->bufsize);
data += (160 - gsmenc->bufsize);
gsmenc->bufsize = 0;
}
while (size >= 160) {
GstBuffer *outbuf;
outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = g_malloc (33 * sizeof (gsm_byte));
GST_BUFFER_SIZE (outbuf) = 33 * sizeof (gsm_byte);
gsm_encode (gsmenc->state, data, (gsm_byte *) GST_BUFFER_DATA (outbuf));
GST_BUFFER_TIMESTAMP (outbuf) = gsmenc->next_ts;
gst_pad_push (gsmenc->srcpad, outbuf);
gsmenc->next_ts += (160.0 / gsmenc->rate) * 1000000;
size -= 160;
data += 160;
}
if (size) {
memcpy (gsmenc->buffer + gsmenc->bufsize, data, size * sizeof (gsm_signal));
gsmenc->bufsize += size;
}
gst_buffer_unref(buf);
}
/* Gnome-Streamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_GSMENC_H__
#define __GST_GSMENC_H__
#include <config.h>
#include <gst/gst.h>
#include <gsm/gsm.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GST_TYPE_GSMENC \
(gst_gsmenc_get_type())
#define GST_GSMENC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GSMENC,GstGSMEnc))
#define GST_GSMENC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GSMENC,GstGSMEnc))
#define GST_IS_GSMENC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GSMENC))
#define GST_IS_GSMENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GSMENC))
typedef struct _GstGSMEnc GstGSMEnc;
typedef struct _GstGSMEncClass GstGSMEncClass;
struct _GstGSMEnc {
GstElement element;
/* pads */
GstPad *sinkpad,*srcpad;
gsm state;
gsm_signal buffer[160];
gint bufsize;
guint64 next_ts;
gint rate;
};
struct _GstGSMEncClass {
GstElementClass parent_class;
/* signals */
void (*frame_encoded) (GstElement *element);
};
GType gst_gsmenc_get_type(void);