From bc36f1240f2ad6b31c7b9174080a54a0def01141 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Fri, 14 Jul 2017 21:44:38 +0000 Subject: [PATCH] removed unmaintained asterisk support, tweaked README to include Octave packages git-svn-id: https://svn.code.sf.net/p/freetel/code@3301 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/README | 55 ++- codec2-dev/asterisk-11/README.md | 19 - .../asterisk-11/asterisk-11.8.1-codec2.patch | 384 ------------------ .../asterisk-11.8.1-opus-codec2.patch | 384 ------------------ codec2-dev/asterisk/README | 109 ----- codec2-dev/asterisk/asterisk-codec2.patch | 68 ---- codec2-dev/asterisk/codec_codec2.c | 187 --------- codec2-dev/asterisk/ex_codec2.h | 28 -- codec2-dev/asterisk/make_asterisk_patch.sh | 11 - 9 files changed, 33 insertions(+), 1212 deletions(-) delete mode 100644 codec2-dev/asterisk-11/README.md delete mode 100644 codec2-dev/asterisk-11/asterisk-11.8.1-codec2.patch delete mode 100644 codec2-dev/asterisk-11/asterisk-11.8.1-opus-codec2.patch delete mode 100644 codec2-dev/asterisk/README delete mode 100644 codec2-dev/asterisk/asterisk-codec2.patch delete mode 100644 codec2-dev/asterisk/codec_codec2.c delete mode 100644 codec2-dev/asterisk/ex_codec2.h delete mode 100755 codec2-dev/asterisk/make_asterisk_patch.sh diff --git a/codec2-dev/README b/codec2-dev/README index 60f6d0de..7f9d8315 100644 --- a/codec2-dev/README +++ b/codec2-dev/README @@ -1,14 +1,17 @@ Codec 2 README -------------- -Codec 2 is an open source (LGPL licensed) speech codec for 3200 bit/s -and below. For more information please see: +Codec 2 is an open source (LGPL 2.1) low bit rate speech codec: http://rowetel.com/codec2.html -Also included is a FDMDV modem (README_fdmdv.txt), a coherent PSK -modem and an API for embedding FreeDV in other programs (see example -below). For more information on building Codec 2 see README.cmake +Also included: + + + FDMDV modem (README_fdmdv.txt) for HF channels + + Coherent PSK (cohpsk) for HF channels + + FSK modem (README_fsk.txt) for VHF channels + + an OFDM modem for HF channels (ofdm) + + the FreeDV API - a library for embedding FreeDV in other programs SVN Repository -------------- @@ -17,27 +20,17 @@ Check out the latest (development branch) code using: $ svn co https://svn.code.sf.net/p/freetel/code/codec2-dev codec2-dev -There are 3rd party GIT mirrors of Codec2 and FreeDV. Use Git at your -own risk. +There are unauthorised 3rd party GIT mirrors of Codec 2. GIT IS NOT SUPPORTED!!! All patches, support questions etc, need to be against the SVN repository above. -Please do not email me (David), or the codec2-dev mailing list -suggesting we change to Git. I get these emails every week. Really, -I understand the arguments, but am content with SVN for now. - Quickstart ---------- -Refer to INSTALL for more general building and installing instructions. - -NOTE: You may not have the necessary speex libraries installed. Some - distributions may have packages available - i.e. sudo apt-get install speex-* - alternatively, visit http://www.speex.org and follow the instructions +Also see INSTALL for more general building and installing instructions. 1/ Listen to Codec 2: @@ -121,7 +114,10 @@ Debugging Building Unit Tests ------------------- -The unittests are no longer built by default. To build them: +The unittests are no longer built by default. They require +libsamplerate and Speex. + +To build them: $ cd ~/codec2 $ rm -Rf build_linux && mkdir build_linux @@ -129,18 +125,33 @@ The unittests are no longer built by default. To build them: $ cmake -DCMAKE_BUILD_TYPE=Debug .. $ make - Directories ----------- - asterisk & - unmaintained Asterisk support - asterisk-11 cmake - cmake support files octave - Octave scripts used to support development script - shell scripts for playing and converting raw files src - C source code for Codec 2, FDMDV modem, COHPSK modem, FreeDV API raw - speech files in raw format (16 bits signed linear 8 kHz) - stm32 - Support for the STM32F4 microcontroller and SM1000 FreeDV Adaptor + stm32 - STM32F4 microcontroller and SM1000 FreeDV Adaptor unittest - unit test source code wav - speech files in wave file format +Octave Packages +--------------- + +To run the Octave scripts the following libraries are required: + +Package Name | Version | Installation directory +--------------+---------+----------------------- + control *| 2.6.2 | /usr/share/octave/packages/control-2.6.2 + general *| 1.3.4 | /usr/share/octave/packages/general-1.3.4 + parallel *| 2.2.0 | /usr/share/octave/packages/parallel-2.2.0 + plot *| 1.1.0 | /usr/share/octave/packages/plot-1.1.0 + signal *| 1.2.2 | /usr/share/octave/packages/signal-1.2.2 + specfun *| 1.1.0 | /usr/share/octave/packages/specfun-1.1.0 + +These can be installed using your systems package management system or +the Octave package management system. The version number of each +package is not important. + diff --git a/codec2-dev/asterisk-11/README.md b/codec2-dev/asterisk-11/README.md deleted file mode 100644 index 6f5b2442..00000000 --- a/codec2-dev/asterisk-11/README.md +++ /dev/null @@ -1,19 +0,0 @@ -#Asterisk 11 Codec 2 support -=========================== - -##Description -These patches add Codec 2 2400 support to Asterisk 11. -The following patches are provided: - -* asterisk-11.8.1-codec2.patch: plain Asterisk 11. -* asterisk-11.8.1-opus-codec2.patch: Asterisk patched with Meetecho's Opus codec support. - -##Building -Building and installing are integrated within Asterisk building environment. libcodec2 must be installed beforehand. - -##Credits -I've followed the example of [asterisk-opus](https://github.com/meetecho/asterisk-opus), by [@meetecho](https://github.com/meetecho), to adapt Codec2 Asterisk 1.8 patch to version 11. - -Many thanks to the [Codec2](http://www.rowetel.com/blog/codec2.html) team for developing such great codec! - -Developed by [Antonio Eugenio Burriel](https://github.com/aeburriel) diff --git a/codec2-dev/asterisk-11/asterisk-11.8.1-codec2.patch b/codec2-dev/asterisk-11/asterisk-11.8.1-codec2.patch deleted file mode 100644 index a2fa0db0..00000000 --- a/codec2-dev/asterisk-11/asterisk-11.8.1-codec2.patch +++ /dev/null @@ -1,384 +0,0 @@ -diff -urN asterisk-11.8.1-orig/build_tools/menuselect-deps.in asterisk-11.8.1-codec2/build_tools/menuselect-deps.in ---- asterisk-11.8.1-orig/build_tools/menuselect-deps.in 2013-04-11 21:59:35.000000000 +0200 -+++ asterisk-11.8.1-codec2/build_tools/menuselect-deps.in 2014-04-01 10:24:29.368859813 +0200 -@@ -4,6 +4,7 @@ - CRYPTO=@PBX_CRYPTO@ - BFD=@PBX_BFD@ - BISON=@PBX_BISON@ -+CODEC2=@PBX_CODEC2@ - CURL=@PBX_CURL@ - DAHDI=@PBX_DAHDI@ - DLADDR=@PBX_DLADDR@ -diff -urN asterisk-11.8.1-orig/codecs/codec_codec2.c asterisk-11.8.1-codec2/codecs/codec_codec2.c ---- asterisk-11.8.1-orig/codecs/codec_codec2.c 1970-01-01 01:00:00.000000000 +0100 -+++ asterisk-11.8.1-codec2/codecs/codec_codec2.c 2014-04-01 01:28:47.000000000 +0200 -@@ -0,0 +1,190 @@ -+/* -+ * Codec 2 module for Asterisk. -+ * -+ * Credit: codec_gsm.c used as a starting point. -+ * -+ * Copyright (C) 2012 Ed W and David Rowe -+ * -+ * 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. -+ */ -+ -+/*! \file -+ * -+ * \brief Translate between signed linear and Codec 2 -+ * -+ * \ingroup codecs -+ */ -+ -+/*** MODULEINFO -+ codec2 -+ core -+ ***/ -+ -+#include "asterisk.h" -+ -+#include "asterisk/translate.h" -+#include "asterisk/config.h" -+#include "asterisk/module.h" -+#include "asterisk/utils.h" -+ -+#include -+ -+#define BUFFER_SAMPLES 8000 -+#define CODEC2_SAMPLES 160 -+#define CODEC2_FRAME_LEN 6 -+ -+/* Sample frame data */ -+ -+#include "asterisk/slin.h" -+#include "ex_codec2.h" -+ -+struct codec2_translator_pvt { /* both codec2tolin and codec2togsm */ -+ struct CODEC2 *codec2; -+ int16_t buf[BUFFER_SAMPLES]; /* lintocodec2, temporary storage */ -+}; -+ -+static int codec2_new(struct ast_trans_pvt *pvt) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ -+ tmp->codec2 = codec2_create(CODEC2_MODE_2400); -+ if (!tmp) -+ return -1; -+ -+ return 0; -+} -+ -+/*! \brief decode and store in outbuf. */ -+static int codec2tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ int x; -+ int16_t *dst = pvt->outbuf.i16; -+ int flen = CODEC2_FRAME_LEN; -+ -+ for (x=0; x < f->datalen; x += flen) { -+ unsigned char *src; -+ int len; -+ len = CODEC2_SAMPLES; -+ src = f->data.ptr + x; -+ -+ codec2_decode(tmp->codec2, dst + pvt->samples, src); -+ -+ pvt->samples += CODEC2_SAMPLES; -+ pvt->datalen += 2 * CODEC2_SAMPLES; -+ } -+ return 0; -+} -+ -+/*! \brief store samples into working buffer for later decode */ -+static int lintocodec2_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ -+ if (pvt->samples + f->samples > BUFFER_SAMPLES) { -+ ast_log(LOG_WARNING, "Out of buffer space\n"); -+ return -1; -+ } -+ memcpy(tmp->buf + pvt->samples, f->data.ptr, f->datalen); -+ pvt->samples += f->samples; -+ return 0; -+} -+ -+/*! \brief encode and produce a frame */ -+static struct ast_frame *lintocodec2_frameout(struct ast_trans_pvt *pvt) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ int datalen = 0; -+ int samples = 0; -+ -+ /* We can't work on anything less than a frame in size */ -+ if (pvt->samples < CODEC2_SAMPLES) -+ return NULL; -+ while (pvt->samples >= CODEC2_SAMPLES) { -+ /* Encode a frame of data */ -+ codec2_encode(tmp->codec2, (unsigned char*)(pvt->outbuf.c + datalen), tmp->buf + samples); -+ datalen += CODEC2_FRAME_LEN; -+ samples += CODEC2_SAMPLES; -+ pvt->samples -= CODEC2_SAMPLES; -+ } -+ -+ /* Move the data at the end of the buffer to the front */ -+ if (pvt->samples) -+ memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2); -+ -+ return ast_trans_frameout(pvt, datalen, samples); -+} -+ -+static void codec2_destroy_stuff(struct ast_trans_pvt *pvt) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ if (tmp->codec2) -+ codec2_destroy(tmp->codec2); -+} -+ -+static struct ast_translator codec2tolin = { -+ .name = "codec2tolin", -+ .newpvt = codec2_new, -+ .framein = codec2tolin_framein, -+ .destroy = codec2_destroy_stuff, -+ .sample = codec2_sample, -+ .buffer_samples = BUFFER_SAMPLES, -+ .buf_size = BUFFER_SAMPLES * 2, -+ .desc_size = sizeof (struct codec2_translator_pvt ), -+}; -+ -+static struct ast_translator lintocodec2 = { -+ .name = "lintocodec2", -+ .newpvt = codec2_new, -+ .framein = lintocodec2_framein, -+ .frameout = lintocodec2_frameout, -+ .destroy = codec2_destroy_stuff, -+ .sample = slin8_sample, -+ .desc_size = sizeof (struct codec2_translator_pvt ), -+ .buf_size = (BUFFER_SAMPLES * CODEC2_FRAME_LEN + CODEC2_SAMPLES - 1)/CODEC2_SAMPLES, -+}; -+ -+/*! \brief standard module glue */ -+static int reload(void) -+{ -+ return AST_MODULE_LOAD_SUCCESS; -+} -+ -+static int unload_module(void) -+{ -+ int res; -+ -+ res = ast_unregister_translator(&lintocodec2); -+ if (!res) -+ res = ast_unregister_translator(&codec2tolin); -+ -+ return res; -+} -+ -+static int load_module(void) -+{ -+ int res; -+ -+ ast_format_set(&codec2tolin.src_format, AST_FORMAT_CODEC2, 0); -+ ast_format_set(&codec2tolin.dst_format, AST_FORMAT_SLINEAR, 0); -+ -+ ast_format_set(&lintocodec2.src_format, AST_FORMAT_SLINEAR, 0); -+ ast_format_set(&lintocodec2.dst_format, AST_FORMAT_CODEC2, 0); -+ -+ res = ast_register_translator(&codec2tolin); -+ if (!res) -+ res=ast_register_translator(&lintocodec2); -+ else -+ ast_unregister_translator(&codec2tolin); -+ if (res) -+ return AST_MODULE_LOAD_FAILURE; -+ return AST_MODULE_LOAD_SUCCESS; -+} -+ -+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Codec 2 Coder/Decoder", -+ .load = load_module, -+ .unload = unload_module, -+ .reload = reload, -+ ); -diff -urN asterisk-11.8.1-orig/codecs/ex_codec2.h asterisk-11.8.1-codec2/codecs/ex_codec2.h ---- asterisk-11.8.1-orig/codecs/ex_codec2.h 1970-01-01 01:00:00.000000000 +0100 -+++ asterisk-11.8.1-codec2/codecs/ex_codec2.h 2014-04-01 01:30:29.000000000 +0200 -@@ -0,0 +1,29 @@ -+/*! \file -+ * \brief 8-bit raw data -+ * -+ * Copyright (C) 2012, 2012 Ed W and David Rowe -+ * -+ * Distributed under the terms of the GNU General Public License -+ * -+ */ -+ -+static uint8_t ex_codec2[] = { -+ 0xea,0xca,0x14,0x85,0x91,0x78 -+}; -+ -+static struct ast_frame *codec2_sample(void) -+{ -+ static struct ast_frame f = { -+ .frametype = AST_FRAME_VOICE, -+ .datalen = sizeof(ex_codec2), -+ .samples = CODEC2_SAMPLES, -+ .mallocd = 0, -+ .offset = 0, -+ .src = __PRETTY_FUNCTION__, -+ .data.ptr = ex_codec2, -+ }; -+ -+ ast_format_set(&f.subclass.format, AST_FORMAT_CODEC2, 0); -+ -+ return &f; -+} -diff -urN asterisk-11.8.1-orig/configure.ac asterisk-11.8.1-codec2/configure.ac ---- asterisk-11.8.1-orig/configure.ac 2014-01-08 17:17:32.000000000 +0100 -+++ asterisk-11.8.1-codec2/configure.ac 2014-04-01 10:27:08.503390997 +0200 -@@ -384,6 +384,7 @@ - AST_EXT_LIB_SETUP([BKTR], [Stack Backtrace], [execinfo]) - AST_EXT_LIB_SETUP([BLUETOOTH], [Bluetooth], [bluetooth]) - AST_EXT_LIB_SETUP([CAP], [POSIX 1.e capabilities], [cap]) -+AST_EXT_LIB_SETUP([CODEC2], [Codec 2], [codec2]) - AST_EXT_LIB_SETUP([COROSYNC], [Corosync], [cpg]) - AST_EXT_LIB_SETUP_OPTIONAL([COROSYNC_CFG_STATE_TRACK], [A callback only in corosync 1.x], [COROSYNC], [cfg]) - AST_EXT_LIB_SETUP([CURSES], [curses], [curses]) -@@ -2116,6 +2117,8 @@ - - AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h]) - -+AST_EXT_LIB_CHECK([CODEC2], [codec2], [codec2_create], [codec2/codec2.h]) -+ - AST_EXT_LIB_CHECK([COROSYNC], [cpg], [cpg_join], [corosync/cpg.h], [-lcfg]) - AST_EXT_LIB_CHECK([COROSYNC_CFG_STATE_TRACK], [cfg], [corosync_cfg_state_track], [corosync/cfg.h], [-lcfg]) - -diff -urN asterisk-11.8.1-orig/include/asterisk/format.h asterisk-11.8.1-codec2/include/asterisk/format.h ---- asterisk-11.8.1-orig/include/asterisk/format.h 2012-07-13 20:41:07.000000000 +0200 -+++ asterisk-11.8.1-codec2/include/asterisk/format.h 2014-04-01 10:03:16.120355835 +0200 -@@ -101,6 +101,7 @@ - AST_FORMAT_SLINEAR192 = 27 + AST_FORMAT_TYPE_AUDIO, - AST_FORMAT_SPEEX32 = 28 + AST_FORMAT_TYPE_AUDIO, - AST_FORMAT_CELT = 29 + AST_FORMAT_TYPE_AUDIO, -+ AST_FORMAT_CODEC2 = 31 + AST_FORMAT_TYPE_AUDIO, - - /*! H.261 Video */ - AST_FORMAT_H261 = 1 + AST_FORMAT_TYPE_VIDEO, -diff -urN asterisk-11.8.1-orig/main/channel.c asterisk-11.8.1-codec2/main/channel.c ---- asterisk-11.8.1-orig/main/channel.c 2013-12-31 00:16:04.000000000 +0100 -+++ asterisk-11.8.1-codec2/main/channel.c 2014-04-01 10:06:55.659929991 +0200 -@@ -918,6 +918,8 @@ - AST_FORMAT_SILK, - /*! CELT supports crazy high sample rates */ - AST_FORMAT_CELT, -+ /* Codec 2 */ -+ AST_FORMAT_CODEC2, - /*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough - to use it */ - AST_FORMAT_LPC10, -diff -urN asterisk-11.8.1-orig/main/format.c asterisk-11.8.1-codec2/main/format.c ---- asterisk-11.8.1-orig/main/format.c 2013-06-12 04:25:23.000000000 +0200 -+++ asterisk-11.8.1-codec2/main/format.c 2014-04-01 10:11:05.319972320 +0200 -@@ -430,6 +430,9 @@ - /*! SpeeX Wideband (16kHz) Free Compression */ - case AST_FORMAT_SPEEX16: - return (1ULL << 33); -+ /*! Codec 2 (8KHz) */ -+ case AST_FORMAT_CODEC2: -+ return (1ULL << 35); - /*! Raw mu-law data (G.711) */ - case AST_FORMAT_TESTLAW: - return (1ULL << 47); -@@ -532,6 +535,9 @@ - /*! SpeeX Wideband (16kHz) Free Compression */ - case (1ULL << 33): - return ast_format_set(dst, AST_FORMAT_SPEEX16, 0); -+ /*! Codec 2 (8KHz) */ -+ case (1ULL << 35): -+ return ast_format_set(dst, AST_FORMAT_CODEC2, 0); - /*! Raw mu-law data (G.711) */ - case (1ULL << 47): - return ast_format_set(dst, AST_FORMAT_TESTLAW, 0); -@@ -1071,6 +1077,8 @@ - format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR48, 0), "slin48", 48000, "16 bit Signed Linear PCM (48kHz)", 960, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (48kHz) */ - format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR96, 0), "slin96", 96000, "16 bit Signed Linear PCM (96kHz)", 1920, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (96kHz) */ - format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR192, 0), "slin192", 192000, "16 bit Signed Linear PCM (192kHz)", 3840, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (192kHz) */ -+ /* Codec 2 */ -+ format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), "codec2", 8000, "Codec 2", 6, 20, 20, 20, 20, 0, 0); /*!< codec_codec2.c */ - - return 0; - } -diff -urN asterisk-11.8.1-orig/main/frame.c asterisk-11.8.1-codec2/main/frame.c ---- asterisk-11.8.1-orig/main/frame.c 2012-07-24 18:54:26.000000000 +0200 -+++ asterisk-11.8.1-codec2/main/frame.c 2014-04-01 10:13:35.626395684 +0200 -@@ -1083,6 +1083,10 @@ - /* TODO The assumes 20ms delivery right now, which is incorrect */ - samples = ast_format_rate(&f->subclass.format) / 50; - break; -+ /* Codec 2 */ -+ case AST_FORMAT_CODEC2: -+ samples = 160 * (f->datalen / 6); -+ break; - default: - ast_log(LOG_WARNING, "Unable to calculate samples for format %s\n", ast_getformatname(&f->subclass.format)); - } -@@ -1134,6 +1138,10 @@ - /* 48,000 samples per second at 64kbps is 8,000 bytes per second */ - len = (int) samples / ((float) 48000 / 8000); - break; -+ /* Codec 2 */ -+ case AST_FORMAT_CODEC2: -+ len = (samples / 160) * 6; -+ break; - default: - ast_log(LOG_WARNING, "Unable to calculate sample length for format %s\n", ast_getformatname(format)); - } -diff -urN asterisk-11.8.1-orig/main/rtp_engine.c asterisk-11.8.1-codec2/main/rtp_engine.c ---- asterisk-11.8.1-orig/main/rtp_engine.c 2013-12-18 00:35:07.000000000 +0100 -+++ asterisk-11.8.1-codec2/main/rtp_engine.c 2014-04-01 10:17:00.121681465 +0200 -@@ -2289,6 +2289,8 @@ - set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_SIREN7, 0), 0, "audio", "G7221", 16000); - set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_SIREN14, 0), 0, "audio", "G7221", 32000); - set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_G719, 0), 0, "audio", "G719", 48000); -+ /* Codec 2 */ -+ set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), 0, "audio", "CODEC2", 8000); - - /* Define the static rtp payload mappings */ - add_static_payload(0, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0), 0); -@@ -2330,6 +2332,8 @@ - add_static_payload(118, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR16, 0), 0); /* 16 Khz signed linear */ - add_static_payload(119, ast_format_set(&tmpfmt, AST_FORMAT_SPEEX32, 0), 0); - add_static_payload(121, NULL, AST_RTP_CISCO_DTMF); /* Must be type 121 */ -+ /* Codec 2 */ -+ add_static_payload(121, ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), 0); - - return 0; - } -diff -urN asterisk-11.8.1-orig/makeopts.in asterisk-11.8.1-codec2/makeopts.in ---- asterisk-11.8.1-orig/makeopts.in 2013-04-11 21:59:35.000000000 +0200 -+++ asterisk-11.8.1-codec2/makeopts.in 2014-04-01 10:28:49.424993462 +0200 -@@ -120,6 +120,9 @@ - BLUETOOTH_INCLUDE=@BLUETOOTH_INCLUDE@ - BLUETOOTH_LIB=@BLUETOOTH_LIB@ - -+CODEC2_INCLUDE=@CODEC2_INCLUDE@ -+CODEC2_LIB=@CODEC2_LIB@ -+ - CURL_INCLUDE=@CURL_INCLUDE@ - CURL_LIB=@CURL_LIB@ - -diff -urN asterisk-11.8.1-orig/res/res_rtp_asterisk.c asterisk-11.8.1-codec2/res/res_rtp_asterisk.c ---- asterisk-11.8.1-orig/res/res_rtp_asterisk.c 2014-02-27 22:39:30.000000000 +0100 -+++ asterisk-11.8.1-codec2/res/res_rtp_asterisk.c 2014-04-01 10:19:18.727901747 +0200 -@@ -2738,6 +2738,8 @@ - case AST_FORMAT_SIREN7: - case AST_FORMAT_SIREN14: - case AST_FORMAT_G719: -+ /* Codec 2 */ -+ case AST_FORMAT_CODEC2: - /* these are all frame-based codecs and cannot be safely run through - a smoother */ - break; diff --git a/codec2-dev/asterisk-11/asterisk-11.8.1-opus-codec2.patch b/codec2-dev/asterisk-11/asterisk-11.8.1-opus-codec2.patch deleted file mode 100644 index a90d3d60..00000000 --- a/codec2-dev/asterisk-11/asterisk-11.8.1-opus-codec2.patch +++ /dev/null @@ -1,384 +0,0 @@ -diff -urN asterisk-11.8.1-opus/build_tools/menuselect-deps.in asterisk-11.8.1-opus-codec2/build_tools/menuselect-deps.in ---- asterisk-11.8.1-opus/build_tools/menuselect-deps.in 2014-04-01 10:58:52.127106070 +0200 -+++ asterisk-11.8.1-opus-codec2/build_tools/menuselect-deps.in 2014-04-01 10:50:21.490079146 +0200 -@@ -4,6 +4,7 @@ - CRYPTO=@PBX_CRYPTO@ - BFD=@PBX_BFD@ - BISON=@PBX_BISON@ -+CODEC2=@PBX_CODEC2@ - CURL=@PBX_CURL@ - DAHDI=@PBX_DAHDI@ - DLADDR=@PBX_DLADDR@ -diff -urN asterisk-11.8.1-opus/codecs/codec_codec2.c asterisk-11.8.1-opus-codec2/codecs/codec_codec2.c ---- asterisk-11.8.1-opus/codecs/codec_codec2.c 1970-01-01 01:00:00.000000000 +0100 -+++ asterisk-11.8.1-opus-codec2/codecs/codec_codec2.c 2014-04-01 10:50:21.490079146 +0200 -@@ -0,0 +1,190 @@ -+/* -+ * Codec 2 module for Asterisk. -+ * -+ * Credit: codec_gsm.c used as a starting point. -+ * -+ * Copyright (C) 2012 Ed W and David Rowe -+ * -+ * 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. -+ */ -+ -+/*! \file -+ * -+ * \brief Translate between signed linear and Codec 2 -+ * -+ * \ingroup codecs -+ */ -+ -+/*** MODULEINFO -+ codec2 -+ core -+ ***/ -+ -+#include "asterisk.h" -+ -+#include "asterisk/translate.h" -+#include "asterisk/config.h" -+#include "asterisk/module.h" -+#include "asterisk/utils.h" -+ -+#include -+ -+#define BUFFER_SAMPLES 8000 -+#define CODEC2_SAMPLES 160 -+#define CODEC2_FRAME_LEN 6 -+ -+/* Sample frame data */ -+ -+#include "asterisk/slin.h" -+#include "ex_codec2.h" -+ -+struct codec2_translator_pvt { /* both codec2tolin and codec2togsm */ -+ struct CODEC2 *codec2; -+ int16_t buf[BUFFER_SAMPLES]; /* lintocodec2, temporary storage */ -+}; -+ -+static int codec2_new(struct ast_trans_pvt *pvt) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ -+ tmp->codec2 = codec2_create(CODEC2_MODE_2400); -+ if (!tmp) -+ return -1; -+ -+ return 0; -+} -+ -+/*! \brief decode and store in outbuf. */ -+static int codec2tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ int x; -+ int16_t *dst = pvt->outbuf.i16; -+ int flen = CODEC2_FRAME_LEN; -+ -+ for (x=0; x < f->datalen; x += flen) { -+ unsigned char *src; -+ int len; -+ len = CODEC2_SAMPLES; -+ src = f->data.ptr + x; -+ -+ codec2_decode(tmp->codec2, dst + pvt->samples, src); -+ -+ pvt->samples += CODEC2_SAMPLES; -+ pvt->datalen += 2 * CODEC2_SAMPLES; -+ } -+ return 0; -+} -+ -+/*! \brief store samples into working buffer for later decode */ -+static int lintocodec2_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ -+ if (pvt->samples + f->samples > BUFFER_SAMPLES) { -+ ast_log(LOG_WARNING, "Out of buffer space\n"); -+ return -1; -+ } -+ memcpy(tmp->buf + pvt->samples, f->data.ptr, f->datalen); -+ pvt->samples += f->samples; -+ return 0; -+} -+ -+/*! \brief encode and produce a frame */ -+static struct ast_frame *lintocodec2_frameout(struct ast_trans_pvt *pvt) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ int datalen = 0; -+ int samples = 0; -+ -+ /* We can't work on anything less than a frame in size */ -+ if (pvt->samples < CODEC2_SAMPLES) -+ return NULL; -+ while (pvt->samples >= CODEC2_SAMPLES) { -+ /* Encode a frame of data */ -+ codec2_encode(tmp->codec2, (unsigned char*)(pvt->outbuf.c + datalen), tmp->buf + samples); -+ datalen += CODEC2_FRAME_LEN; -+ samples += CODEC2_SAMPLES; -+ pvt->samples -= CODEC2_SAMPLES; -+ } -+ -+ /* Move the data at the end of the buffer to the front */ -+ if (pvt->samples) -+ memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2); -+ -+ return ast_trans_frameout(pvt, datalen, samples); -+} -+ -+static void codec2_destroy_stuff(struct ast_trans_pvt *pvt) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ if (tmp->codec2) -+ codec2_destroy(tmp->codec2); -+} -+ -+static struct ast_translator codec2tolin = { -+ .name = "codec2tolin", -+ .newpvt = codec2_new, -+ .framein = codec2tolin_framein, -+ .destroy = codec2_destroy_stuff, -+ .sample = codec2_sample, -+ .buffer_samples = BUFFER_SAMPLES, -+ .buf_size = BUFFER_SAMPLES * 2, -+ .desc_size = sizeof (struct codec2_translator_pvt ), -+}; -+ -+static struct ast_translator lintocodec2 = { -+ .name = "lintocodec2", -+ .newpvt = codec2_new, -+ .framein = lintocodec2_framein, -+ .frameout = lintocodec2_frameout, -+ .destroy = codec2_destroy_stuff, -+ .sample = slin8_sample, -+ .desc_size = sizeof (struct codec2_translator_pvt ), -+ .buf_size = (BUFFER_SAMPLES * CODEC2_FRAME_LEN + CODEC2_SAMPLES - 1)/CODEC2_SAMPLES, -+}; -+ -+/*! \brief standard module glue */ -+static int reload(void) -+{ -+ return AST_MODULE_LOAD_SUCCESS; -+} -+ -+static int unload_module(void) -+{ -+ int res; -+ -+ res = ast_unregister_translator(&lintocodec2); -+ if (!res) -+ res = ast_unregister_translator(&codec2tolin); -+ -+ return res; -+} -+ -+static int load_module(void) -+{ -+ int res; -+ -+ ast_format_set(&codec2tolin.src_format, AST_FORMAT_CODEC2, 0); -+ ast_format_set(&codec2tolin.dst_format, AST_FORMAT_SLINEAR, 0); -+ -+ ast_format_set(&lintocodec2.src_format, AST_FORMAT_SLINEAR, 0); -+ ast_format_set(&lintocodec2.dst_format, AST_FORMAT_CODEC2, 0); -+ -+ res = ast_register_translator(&codec2tolin); -+ if (!res) -+ res=ast_register_translator(&lintocodec2); -+ else -+ ast_unregister_translator(&codec2tolin); -+ if (res) -+ return AST_MODULE_LOAD_FAILURE; -+ return AST_MODULE_LOAD_SUCCESS; -+} -+ -+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Codec 2 Coder/Decoder", -+ .load = load_module, -+ .unload = unload_module, -+ .reload = reload, -+ ); -diff -urN asterisk-11.8.1-opus/codecs/ex_codec2.h asterisk-11.8.1-opus-codec2/codecs/ex_codec2.h ---- asterisk-11.8.1-opus/codecs/ex_codec2.h 1970-01-01 01:00:00.000000000 +0100 -+++ asterisk-11.8.1-opus-codec2/codecs/ex_codec2.h 2014-04-01 10:50:21.490079146 +0200 -@@ -0,0 +1,29 @@ -+/*! \file -+ * \brief 8-bit raw data -+ * -+ * Copyright (C) 2012, 2012 Ed W and David Rowe -+ * -+ * Distributed under the terms of the GNU General Public License -+ * -+ */ -+ -+static uint8_t ex_codec2[] = { -+ 0xea,0xca,0x14,0x85,0x91,0x78 -+}; -+ -+static struct ast_frame *codec2_sample(void) -+{ -+ static struct ast_frame f = { -+ .frametype = AST_FRAME_VOICE, -+ .datalen = sizeof(ex_codec2), -+ .samples = CODEC2_SAMPLES, -+ .mallocd = 0, -+ .offset = 0, -+ .src = __PRETTY_FUNCTION__, -+ .data.ptr = ex_codec2, -+ }; -+ -+ ast_format_set(&f.subclass.format, AST_FORMAT_CODEC2, 0); -+ -+ return &f; -+} -diff -urN asterisk-11.8.1-opus/configure.ac asterisk-11.8.1-opus-codec2/configure.ac ---- asterisk-11.8.1-opus/configure.ac 2014-04-01 10:58:52.143106352 +0200 -+++ asterisk-11.8.1-opus-codec2/configure.ac 2014-04-01 10:50:21.494079217 +0200 -@@ -384,6 +384,7 @@ - AST_EXT_LIB_SETUP([BKTR], [Stack Backtrace], [execinfo]) - AST_EXT_LIB_SETUP([BLUETOOTH], [Bluetooth], [bluetooth]) - AST_EXT_LIB_SETUP([CAP], [POSIX 1.e capabilities], [cap]) -+AST_EXT_LIB_SETUP([CODEC2], [Codec 2], [codec2]) - AST_EXT_LIB_SETUP([COROSYNC], [Corosync], [cpg]) - AST_EXT_LIB_SETUP_OPTIONAL([COROSYNC_CFG_STATE_TRACK], [A callback only in corosync 1.x], [COROSYNC], [cfg]) - AST_EXT_LIB_SETUP([CURSES], [curses], [curses]) -@@ -2117,6 +2118,8 @@ - - AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h]) - -+AST_EXT_LIB_CHECK([CODEC2], [codec2], [codec2_create], [codec2/codec2.h]) -+ - AST_EXT_LIB_CHECK([COROSYNC], [cpg], [cpg_join], [corosync/cpg.h], [-lcfg]) - AST_EXT_LIB_CHECK([COROSYNC_CFG_STATE_TRACK], [cfg], [corosync_cfg_state_track], [corosync/cfg.h], [-lcfg]) - -diff -urN asterisk-11.8.1-opus/include/asterisk/format.h asterisk-11.8.1-opus-codec2/include/asterisk/format.h ---- asterisk-11.8.1-opus/include/asterisk/format.h 2014-04-01 10:58:52.143106352 +0200 -+++ asterisk-11.8.1-opus-codec2/include/asterisk/format.h 2014-04-01 10:53:25.961351185 +0200 -@@ -103,6 +103,7 @@ - AST_FORMAT_CELT = 29 + AST_FORMAT_TYPE_AUDIO, - /*! Opus */ - AST_FORMAT_OPUS = 30 + AST_FORMAT_TYPE_AUDIO, -+ AST_FORMAT_CODEC2 = 31 + AST_FORMAT_TYPE_AUDIO, - - /*! H.261 Video */ - AST_FORMAT_H261 = 1 + AST_FORMAT_TYPE_VIDEO, -diff -urN asterisk-11.8.1-opus/main/channel.c asterisk-11.8.1-opus-codec2/main/channel.c ---- asterisk-11.8.1-opus/main/channel.c 2014-04-01 10:58:52.147106422 +0200 -+++ asterisk-11.8.1-opus-codec2/main/channel.c 2014-04-01 10:50:21.498079289 +0200 -@@ -920,6 +920,8 @@ - AST_FORMAT_SILK, - /*! CELT supports crazy high sample rates */ - AST_FORMAT_CELT, -+ /* Codec 2 */ -+ AST_FORMAT_CODEC2, - /*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough - to use it */ - AST_FORMAT_LPC10, -diff -urN asterisk-11.8.1-opus/main/format.c asterisk-11.8.1-opus-codec2/main/format.c ---- asterisk-11.8.1-opus/main/format.c 2014-04-01 10:58:52.147106422 +0200 -+++ asterisk-11.8.1-opus-codec2/main/format.c 2014-04-01 10:52:23.820250398 +0200 -@@ -433,6 +433,9 @@ - /*! Opus audio (8kHz, 16kHz, 24kHz, 48Khz) */ - case AST_FORMAT_OPUS: - return (1ULL << 34); -+ /*! Codec 2 (8KHz) */ -+ case AST_FORMAT_CODEC2: -+ return (1ULL << 35); - /*! Raw mu-law data (G.711) */ - case AST_FORMAT_TESTLAW: - return (1ULL << 47); -@@ -541,6 +544,9 @@ - /*! Opus audio (8kHz, 16kHz, 24kHz, 48Khz) */ - case (1ULL << 34): - return ast_format_set(dst, AST_FORMAT_OPUS, 0); -+ /*! Codec 2 (8KHz) */ -+ case (1ULL << 35): -+ return ast_format_set(dst, AST_FORMAT_CODEC2, 0); - /*! Raw mu-law data (G.711) */ - case (1ULL << 47): - return ast_format_set(dst, AST_FORMAT_TESTLAW, 0); -@@ -1090,6 +1096,8 @@ - format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_OPUS, 0), "opus", 48000, "Opus Codec", 10, 20, 60, 20, 20, 0, 0); /*!< codec_opus.c */ - /* VP8 (passthrough) */ - format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_VP8, 0), "vp8", 0, "VP8 Video", 0, 0, 0, 0 ,0 ,0, 0); /*!< Passthrough support, see format_h263.c */ -+ /* Codec 2 */ -+ format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), "codec2", 8000, "Codec 2", 6, 20, 20, 20, 20, 0, 0); /*!< codec_codec2.c */ - - return 0; - } -diff -urN asterisk-11.8.1-opus/main/frame.c asterisk-11.8.1-opus-codec2/main/frame.c ---- asterisk-11.8.1-opus/main/frame.c 2014-04-01 10:58:52.151106493 +0200 -+++ asterisk-11.8.1-opus-codec2/main/frame.c 2014-04-01 10:50:21.502079360 +0200 -@@ -1121,6 +1121,10 @@ - case AST_FORMAT_OPUS: - samples = opus_samples(f->data.ptr, f->datalen); - break; -+ /* Codec 2 */ -+ case AST_FORMAT_CODEC2: -+ samples = 160 * (f->datalen / 6); -+ break; - default: - ast_log(LOG_WARNING, "Unable to calculate samples for format %s\n", ast_getformatname(&f->subclass.format)); - } -@@ -1172,6 +1176,10 @@ - /* 48,000 samples per second at 64kbps is 8,000 bytes per second */ - len = (int) samples / ((float) 48000 / 8000); - break; -+ /* Codec 2 */ -+ case AST_FORMAT_CODEC2: -+ len = (samples / 160) * 6; -+ break; - default: - ast_log(LOG_WARNING, "Unable to calculate sample length for format %s\n", ast_getformatname(format)); - } -diff -urN asterisk-11.8.1-opus/main/rtp_engine.c asterisk-11.8.1-opus-codec2/main/rtp_engine.c ---- asterisk-11.8.1-opus/main/rtp_engine.c 2014-04-01 10:58:52.151106493 +0200 -+++ asterisk-11.8.1-opus-codec2/main/rtp_engine.c 2014-04-01 10:51:17.367071621 +0200 -@@ -2292,6 +2292,8 @@ - /* Opus and VP8 */ - set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_OPUS, 0), 0, "audio", "opus", 48000); - set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_VP8, 0), 0, "video", "VP8", 90000); -+ /* Codec 2 */ -+ set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), 0, "audio", "CODEC2", 8000); - - /* Define the static rtp payload mappings */ - add_static_payload(0, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0), 0); -@@ -2336,6 +2338,8 @@ - /* Opus and VP8 */ - add_static_payload(100, ast_format_set(&tmpfmt, AST_FORMAT_VP8, 0), 0); - add_static_payload(107, ast_format_set(&tmpfmt, AST_FORMAT_OPUS, 0), 0); -+ /* Codec 2 */ -+ add_static_payload(121, ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), 0); - - return 0; - } -diff -urN asterisk-11.8.1-opus/makeopts.in asterisk-11.8.1-opus-codec2/makeopts.in ---- asterisk-11.8.1-opus/makeopts.in 2014-04-01 10:58:52.151106493 +0200 -+++ asterisk-11.8.1-opus-codec2/makeopts.in 2014-04-01 10:50:21.538079999 +0200 -@@ -120,6 +120,9 @@ - BLUETOOTH_INCLUDE=@BLUETOOTH_INCLUDE@ - BLUETOOTH_LIB=@BLUETOOTH_LIB@ - -+CODEC2_INCLUDE=@CODEC2_INCLUDE@ -+CODEC2_LIB=@CODEC2_LIB@ -+ - CURL_INCLUDE=@CURL_INCLUDE@ - CURL_LIB=@CURL_LIB@ - -diff -urN asterisk-11.8.1-opus/res/res_rtp_asterisk.c asterisk-11.8.1-opus-codec2/res/res_rtp_asterisk.c ---- asterisk-11.8.1-opus/res/res_rtp_asterisk.c 2014-04-01 10:58:52.151106493 +0200 -+++ asterisk-11.8.1-opus-codec2/res/res_rtp_asterisk.c 2014-04-01 10:53:02.292932085 +0200 -@@ -2780,6 +2780,8 @@ - case AST_FORMAT_G719: - /* Opus */ - case AST_FORMAT_OPUS: -+ /* Codec 2 */ -+ case AST_FORMAT_CODEC2: - /* these are all frame-based codecs and cannot be safely run through - a smoother */ - break; diff --git a/codec2-dev/asterisk/README b/codec2-dev/asterisk/README deleted file mode 100644 index a2d3b512..00000000 --- a/codec2-dev/asterisk/README +++ /dev/null @@ -1,109 +0,0 @@ -README for codec2/asterisk -Asterisk Codec 2 support - -Test Configuration ------------------- - -Codec 2 is used to trunk calls between two Asterisk boxes: - - A - SIP phone - Asterisk A - Codec2 - Asterisk B - SIP Phone - B - -The two SIP phones are configured for mulaw. - -Building ---------- - -Asterisk must be patched so that the core understand Codec 2 frames. - -1/ First install Codec 2: - - david@cool:~$ svn co https://freetel.svn.sourceforge.net/svnroot/freetel/codec2-dev codec2-dev - david@cool:~/codec2-dev$ cd codec2-dev - david@cool:~/codec2-dev$ ./configure && make && sudo make install - david@bear:~/codec2-dev$ sudo ldconfig -v - david@cool:~/codec2-dev$ cd ~ - -2/ Then build Asterisk with Codec 2 support: - - david@cool:~$ tar xvzf asterisk-1.8.9.0.tar.gz - david@cool:~/asterisk-1.8.9.0$ patch -p4 < ~/codec2-dev/asterisk/asterisk-codec2.patch - david@cool:~/asterisk-1.8.9.0$ cp ~/codec2-dev/asterisk/codec_codec2.c . - david@cool:~/asterisk-1.8.9.0$ cp ~/codec2-dev/asterisk/ex_codec2.h ./codecs - david@cool:~/asterisk-1.8.9.0$ ./configure && make ASTLDFLAGS=-lcodec2 - david@cool:~/asterisk-1.8.9.0$ sudo make install - david@cool:~/asterisk-1.8.9.0$ sudo make samples - -3/ Add this to the end of sip.conf on Asterisk A: - - [6013] - type=friend - context=default - host=dynamic - user=6013 - secret=6013 - canreinvite=no - callerid=6013 - disallow=all - allow=ulaw - - [potato] - type=peer - username=potato - fromuser=potato - secret=password - context=default - disallow=all - dtmfmode=rfc2833 - callerid=server - canreinvite=no - host=cool - allow=codec2 - -3/ Add this to the end of sip.conf on Asterisk B: - - [6014] - type=friend - context=default - host=dynamic - user=6014 - secret=6014 - canreinvite=no - callerid=6014 - disallow=all - allow=ulaw - - [potato] - type=peer - username=potato - fromuser=potato - secret=password - context=default - disallow=all - dtmfmode=rfc2833 - callerid=server - canreinvite=no - host=bear - allow=codec2 - -4/ Here is the [default] section of extensions.conf on Asterisk B: - - [default] - - exten => 6013,1,Dial(SIP/potato/6013) - ; - ; By default we include the demo. In a production system, you - ; probably don't want to have the demo there. - ; - ;include => demo - -5/ After booting see if the codec2_codec2.so module is loaded with "core show translate" - -6/ To make a test call dial 6013 on the SIP phone connected to Asterisk B - -7/ If codec_codec2.so won't load and you see "can't find codec2_create" try: - - david@cool:~/asterisk-1.8.9.0$ touch codecs/codec_codec2.c - david@cool:~/asterisk-1.8.9.0$ make ASTLDFLAGS=-lcodec2 - david@cool:~/asterisk-1.8.9.0$ sudo cp codecs/codec_codec2.so /usr/lib/asterisk/modules - david@cool:~/asterisk-1.8.9.0$ sudo asterisk -vvvcn - diff --git a/codec2-dev/asterisk/asterisk-codec2.patch b/codec2-dev/asterisk/asterisk-codec2.patch deleted file mode 100644 index 53569ff9..00000000 --- a/codec2-dev/asterisk/asterisk-codec2.patch +++ /dev/null @@ -1,68 +0,0 @@ ---- /home/david/asterisk-1.8.9.0-orig/include/asterisk/frame.h 2011-12-23 05:08:46.000000000 +1030 -+++ /home/david/asterisk-1.8.9.0-codec2/include/asterisk/frame.h 2012-03-27 13:16:55.623452431 +1030 -@@ -299,6 +299,7 @@ - #define AST_FORMAT_G719 (1ULL << 32) - /*! SpeeX Wideband (16kHz) Free Compression */ - #define AST_FORMAT_SPEEX16 (1ULL << 33) -+#define AST_FORMAT_CODEC2 (1ULL << 34) - /*! Raw mu-law data (G.711) */ - #define AST_FORMAT_TESTLAW (1ULL << 47) - /*! Reserved bit - do not use */ ---- /home/david/asterisk-1.8.9.0-orig/main/frame.c 2010-06-18 02:53:43.000000000 +0930 -+++ /home/david/asterisk-1.8.9.0-codec2/main/frame.c 2012-03-28 15:16:16.975581316 +1030 -@@ -102,6 +102,7 @@ - { AST_FORMAT_ADPCM, "adpcm" , 8000, "ADPCM", 40, 10, 300, 10, 20 }, /*!< codec_adpcm.c */ - { AST_FORMAT_SLINEAR, "slin", 8000, "16 bit Signed Linear PCM", 160, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE }, /*!< Signed linear */ - { AST_FORMAT_LPC10, "lpc10", 8000, "LPC10", 7, 20, 20, 20, 20 }, /*!< codec_lpc10.c */ -+ { AST_FORMAT_CODEC2, "codec2", 8000, "Codec 2", 6, 20, 20, 20, 20 }, /*!< codec_codec2.c */ - { AST_FORMAT_G729A, "g729", 8000, "G.729A", 10, 10, 230, 10, 20, AST_SMOOTHER_FLAG_G729 }, /*!< Binary commercial distribution */ - { AST_FORMAT_SPEEX, "speex", 8000, "SpeeX", 10, 10, 60, 10, 20 }, /*!< codec_speex.c */ - { AST_FORMAT_SPEEX16, "speex16", 16000, "SpeeX 16khz", 10, 10, 60, 10, 20 }, /*!< codec_speex.c */ -@@ -1475,6 +1476,9 @@ - samples = 22 * 8; - samples += (((char *)(f->data.ptr))[7] & 0x1) * 8; - break; -+ case AST_FORMAT_CODEC2: -+ samples = 160 * (f->datalen / 6); -+ break; - case AST_FORMAT_ULAW: - case AST_FORMAT_ALAW: - case AST_FORMAT_TESTLAW: -@@ -1519,6 +1523,9 @@ - case AST_FORMAT_GSM: - len = (samples / 160) * 33; - break; -+ case AST_FORMAT_CODEC2: -+ len = (samples / 160) * 6; -+ break; - case AST_FORMAT_G729A: - len = samples / 8; - break; ---- /home/david/asterisk-1.8.9.0-orig/main/channel.c 2011-12-17 10:21:13.000000000 +1030 -+++ /home/david/asterisk-1.8.9.0-codec2/main/channel.c 2012-03-28 15:05:22.395293391 +1030 -@@ -1075,6 +1075,7 @@ - /*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough - to use it */ - AST_FORMAT_LPC10, -+ AST_FORMAT_CODEC2, - /*! G.729a is faster than 723 and slightly less expensive */ - AST_FORMAT_G729A, - /*! Down to G.723.1 which is proprietary but at least designed for voice */ ---- /home/david/asterisk-1.8.9.0-orig/main/rtp_engine.c 2011-12-30 01:43:03.000000000 +1030 -+++ /home/david/asterisk-1.8.9.0-codec2/main/rtp_engine.c 2012-03-28 16:42:02.880872891 +1030 -@@ -101,6 +101,7 @@ - {{1, AST_FORMAT_SLINEAR}, "audio", "L16", 8000}, - {{1, AST_FORMAT_SLINEAR16}, "audio", "L16", 16000}, - {{1, AST_FORMAT_LPC10}, "audio", "LPC", 8000}, -+ {{1, AST_FORMAT_CODEC2}, "audio", "CODEC2", 8000}, - {{1, AST_FORMAT_G729A}, "audio", "G729", 8000}, - {{1, AST_FORMAT_G729A}, "audio", "G729A", 8000}, - {{1, AST_FORMAT_G729A}, "audio", "G.729", 8000}, -@@ -178,6 +179,7 @@ - [117] = {1, AST_FORMAT_SPEEX16}, - [118] = {1, AST_FORMAT_SLINEAR16}, /* 16 Khz signed linear */ - [121] = {0, AST_RTP_CISCO_DTMF}, /* Must be type 121 */ -+ [121] = {1, AST_FORMAT_CODEC2}, - }; - - int ast_rtp_engine_register2(struct ast_rtp_engine *engine, struct ast_module *module) diff --git a/codec2-dev/asterisk/codec_codec2.c b/codec2-dev/asterisk/codec_codec2.c deleted file mode 100644 index ce043d05..00000000 --- a/codec2-dev/asterisk/codec_codec2.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Codec 2 module for Asterisk. - * - * Credit: codec_gsm.c used as a starting point. - * - * Copyright (C) 2012 Ed W and David Rowe - * - * 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. - */ - -/*! \file - * - * \brief Translate between signed linear and Codec 2 - * - * \ingroup codecs - */ - -/*** MODULEINFO - core - ***/ - -#include "asterisk.h" - -#include "asterisk/translate.h" -#include "asterisk/config.h" -#include "asterisk/module.h" -#include "asterisk/utils.h" - -#include - -#define BUFFER_SAMPLES 8000 -#define CODEC2_SAMPLES 160 -#define CODEC2_FRAME_LEN 6 - -/* Sample frame data */ - -#include "asterisk/slin.h" -#include "ex_codec2.h" - -struct codec2_translator_pvt { /* both codec2tolin and codec2togsm */ - struct CODEC2 *codec2; - int16_t buf[BUFFER_SAMPLES]; /* lintocodec2, temporary storage */ -}; - -static int codec2_new(struct ast_trans_pvt *pvt) -{ - struct codec2_translator_pvt *tmp = pvt->pvt; - - tmp->codec2 = codec2_create(CODEC2_MODE_2400); - if (!tmp->codec2) - return -1; - - return 0; -} - -/*! \brief decode and store in outbuf. */ -static int codec2tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) -{ - struct codec2_translator_pvt *tmp = pvt->pvt; - int x; - int16_t *dst = pvt->outbuf.i16; - int flen = CODEC2_FRAME_LEN; - - for (x=0; x < f->datalen; x += flen) { - unsigned char *src; - int len; - len = CODEC2_SAMPLES; - src = f->data.ptr + x; - - codec2_decode(tmp->codec2, dst + pvt->samples, src); - - pvt->samples += CODEC2_SAMPLES; - pvt->datalen += 2 * CODEC2_SAMPLES; - } - return 0; -} - -/*! \brief store samples into working buffer for later decode */ -static int lintocodec2_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) -{ - struct codec2_translator_pvt *tmp = pvt->pvt; - - if (pvt->samples + f->samples > BUFFER_SAMPLES) { - ast_log(LOG_WARNING, "Out of buffer space\n"); - return -1; - } - memcpy(tmp->buf + pvt->samples, f->data.ptr, f->datalen); - pvt->samples += f->samples; - return 0; -} - -/*! \brief encode and produce a frame */ -static struct ast_frame *lintocodec2_frameout(struct ast_trans_pvt *pvt) -{ - struct codec2_translator_pvt *tmp = pvt->pvt; - int datalen = 0; - int samples = 0; - - /* We can't work on anything less than a frame in size */ - if (pvt->samples < CODEC2_SAMPLES) - return NULL; - while (pvt->samples >= CODEC2_SAMPLES) { - /* Encode a frame of data */ - codec2_encode(tmp->codec2, (unsigned char*)(pvt->outbuf.c + datalen), tmp->buf + samples); - datalen += CODEC2_FRAME_LEN; - samples += CODEC2_SAMPLES; - pvt->samples -= CODEC2_SAMPLES; - } - - /* Move the data at the end of the buffer to the front */ - if (pvt->samples) - memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2); - - return ast_trans_frameout(pvt, datalen, samples); -} - -static void codec2_destroy_stuff(struct ast_trans_pvt *pvt) -{ - struct codec2_translator_pvt *tmp = pvt->pvt; - if (tmp->codec2) - codec2_destroy(tmp->codec2); -} - -static struct ast_translator codec2tolin = { - .name = "codec2tolin", - .srcfmt = AST_FORMAT_CODEC2, - .dstfmt = AST_FORMAT_SLINEAR, - .newpvt = codec2_new, - .framein = codec2tolin_framein, - .destroy = codec2_destroy_stuff, - .sample = codec2_sample, - .buffer_samples = BUFFER_SAMPLES, - .buf_size = BUFFER_SAMPLES * 2, - .desc_size = sizeof (struct codec2_translator_pvt ), -}; - -static struct ast_translator lintocodec2 = { - .name = "lintocodec2", - .srcfmt = AST_FORMAT_SLINEAR, - .dstfmt = AST_FORMAT_CODEC2, - .newpvt = codec2_new, - .framein = lintocodec2_framein, - .frameout = lintocodec2_frameout, - .destroy = codec2_destroy_stuff, - .sample = slin8_sample, - .desc_size = sizeof (struct codec2_translator_pvt ), - .buf_size = (BUFFER_SAMPLES * CODEC2_FRAME_LEN + CODEC2_SAMPLES - 1)/CODEC2_SAMPLES, -}; - -/*! \brief standard module glue */ -static int reload(void) -{ - return AST_MODULE_LOAD_SUCCESS; -} - -static int unload_module(void) -{ - int res; - - res = ast_unregister_translator(&lintocodec2); - if (!res) - res = ast_unregister_translator(&codec2tolin); - - return res; -} - -static int load_module(void) -{ - int res; - - res = ast_register_translator(&codec2tolin); - if (!res) - res=ast_register_translator(&lintocodec2); - else - ast_unregister_translator(&codec2tolin); - if (res) - return AST_MODULE_LOAD_FAILURE; - return AST_MODULE_LOAD_SUCCESS; -} - -AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Codec 2 Coder/Decoder", - .load = load_module, - .unload = unload_module, - .reload = reload, - ); diff --git a/codec2-dev/asterisk/ex_codec2.h b/codec2-dev/asterisk/ex_codec2.h deleted file mode 100644 index ac5782dd..00000000 --- a/codec2-dev/asterisk/ex_codec2.h +++ /dev/null @@ -1,28 +0,0 @@ -/*! \file - * \brief 8-bit raw data - * - * Copyright (C) 2012, 2012 Ed W and David Rowe - * - * Distributed under the terms of the GNU General Public License - * - */ - -static uint8_t ex_codec2[] = { - 0xea,0xca,0x14,0x85,0x91,0x78 -}; - -static struct ast_frame *codec2_sample(void) -{ - static struct ast_frame f = { - .frametype = AST_FRAME_VOICE, - .subclass.codec = AST_FORMAT_CODEC2, - .datalen = sizeof(ex_codec2), - .samples = CODEC2_SAMPLES, - .mallocd = 0, - .offset = 0, - .src = __PRETTY_FUNCTION__, - .data.ptr = ex_codec2, - }; - - return &f; -} diff --git a/codec2-dev/asterisk/make_asterisk_patch.sh b/codec2-dev/asterisk/make_asterisk_patch.sh deleted file mode 100755 index a642bf7f..00000000 --- a/codec2-dev/asterisk/make_asterisk_patch.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -# Create patch for Codec 2 support inside Asterisk - -ORIG=~/asterisk-1.8.9.0-orig -CODEC2=~/asterisk-1.8.9.0-codec2 -diff -ruN $ORIG/include/asterisk/frame.h $CODEC2/include/asterisk/frame.h > asterisk-codec2.patch -diff -ruN $ORIG/main/frame.c $CODEC2/main/frame.c >> asterisk-codec2.patch -diff -ruN $ORIG/main/channel.c $CODEC2/main/channel.c >> asterisk-codec2.patch -diff -ruN $ORIG/main/rtp_engine.c $CODEC2/main/rtp_engine.c >> asterisk-codec2.patch - - -- 2.25.1