[asterisk-commits] branch mattf/asterisk-wideband - r7393 /team/mattf/asterisk-wideband/codecs/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Dec 8 12:41:01 CST 2005


Author: mattf
Date: Thu Dec  8 12:41:00 2005
New Revision: 7393

URL: http://svn.digium.com/view/asterisk?rev=7393&view=rev
Log:
Add resampling codec

Added:
    team/mattf/asterisk-wideband/codecs/codec_resample.c
Modified:
    team/mattf/asterisk-wideband/codecs/Makefile

Modified: team/mattf/asterisk-wideband/codecs/Makefile
URL: http://svn.digium.com/view/asterisk/team/mattf/asterisk-wideband/codecs/Makefile?rev=7393&r1=7392&r2=7393&view=diff
==============================================================================
--- team/mattf/asterisk-wideband/codecs/Makefile (original)
+++ team/mattf/asterisk-wideband/codecs/Makefile Thu Dec  8 12:41:00 2005
@@ -68,9 +68,9 @@
   CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
 endif
 
-CODECS+=$(MODG723) $(MODSPEEX) $(MODILBC) codec_gsm.so codec_lpc10.so  \
+CODECS+=$(MODG723) $(MODSPEEX) $(MODILBC) codec_resample.so codec_lpc10.so  \
         codec_adpcm.so codec_ulaw.so codec_alaw.so codec_a_mu.so \
-	codec_g726.so
+	codec_g726.so codec_resample.so
 
 all: depend $(CODECS)
 
@@ -118,6 +118,9 @@
 codec_lpc10.so: codec_lpc10.o $(LIBLPC10)
 	$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(LIBLPC10) -lm
 
+codec_resample.so: codec_resample.o
+	$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
+
 %.so : %.o
 	$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
 

Added: team/mattf/asterisk-wideband/codecs/codec_resample.c
URL: http://svn.digium.com/view/asterisk/team/mattf/asterisk-wideband/codecs/codec_resample.c?rev=7393&view=auto
==============================================================================
--- team/mattf/asterisk-wideband/codecs/codec_resample.c (added)
+++ team/mattf/asterisk-wideband/codecs/codec_resample.c Thu Dec  8 12:41:00 2005
@@ -1,0 +1,148 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 1999 - 2005, Digium, Inc.
+ *
+ * Matthew Fredrickson <creslin at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 7221 $")
+
+#include "asterisk/lock.h"
+#include "asterisk/logger.h"
+#include "asterisk/module.h"
+#include "asterisk/translate.h"
+#include "asterisk/channel.h"
+
+AST_MUTEX_DEFINE_STATIC(localuser_lock);
+static int localusecnt = 0;
+
+struct ast_translator_pvt {
+	struct ast_frame f;
+	char offset[AST_FRIENDLY_OFFSET];
+	short outbuf[16000];
+	short buf[16000];
+	short lastsample;
+	int tail;
+};
+
+static struct ast_frame * lin8to16_frameout(struct ast_translator_pvt *tmp)
+{
+	return NULL;
+}
+
+static int lin8to16_framein(struct ast_translator_pvt *tmp, struct ast_frame *f)
+{
+	return 0;
+}
+
+static struct ast_translator_pvt * lin8to16_new(void)
+{
+	return NULL;
+}
+
+static struct ast_frame *lin8to16_sample(void)
+{
+	return NULL;
+}
+
+static void lin8to16_destroy(struct ast_translator_pvt *pvt)
+{
+	return;
+}
+
+static struct ast_translator lin8to16 =
+{
+		"lin8tolin16",
+		AST_FORMAT_SLINEAR,
+		AST_FORMAT_SLINEAR16,
+		lin8to16_new,
+		lin8to16_framein,
+		lin8to16_frameout,
+		lin8to16_destroy,
+		lin8to16_sample,
+};
+
+static struct ast_frame * lin16to8_frameout(struct ast_translator_pvt *tmp)
+{
+	return NULL;
+}
+
+static int lin16to8_framein(struct ast_translator_pvt *tmp, struct ast_frame *f)
+{
+	return 0;
+}
+
+static struct ast_translator_pvt * lin16to8_new(void)
+{
+	return NULL;
+}
+
+static struct ast_frame *lin16to8_sample(void)
+{
+	return NULL;
+}
+
+static void lin16to8_destroy(struct ast_translator_pvt *pvt)
+{
+	return;
+}
+
+static struct ast_translator lin16to8 =
+{
+		"lin16tolin8",
+		AST_FORMAT_SLINEAR,
+		AST_FORMAT_SLINEAR16,
+		lin16to8_new,
+		lin16to8_framein,
+		lin16to8_frameout,
+		lin16to8_destroy,
+		lin16to8_sample,
+};
+
+int reload(void)
+{
+	return 0;
+}
+
+int unload_module(void)
+{
+	int res;
+
+	ast_mutex_lock(&localuser_lock);
+	if (localusecnt) {
+		res = -1;
+	} else {
+		ast_unregister_translator(&lin8to16);
+		ast_unregister_translator(&lin16to8);
+		res = 0;
+	}
+	ast_mutex_unlock(&localuser_lock);
+	return res;
+}
+
+int load_module(void)
+{
+	int res;
+
+	res = ast_register_translator(&lin8to16);
+	if (!res)
+		res = ast_register_translator(&lin16to8);
+	else
+		ast_unregister_translator(&lin8to16);
+	localusecnt = 0;
+
+	return res;
+}



More information about the asterisk-commits mailing list