提交 3ccf1704 authored 作者: Dragos Oancea's avatar Dragos Oancea

FS-9825: Added AMR-WB transcoding capabilities (in both Bandwidth Efficient and…

FS-9825: Added AMR-WB transcoding capabilities (in both Bandwidth Efficient and Octet Aligned modes)
上级 7884bee0
...@@ -831,6 +831,10 @@ PKG_CHECK_MODULES([AMR], [opencore-amrnb >= 0.1.0],[ ...@@ -831,6 +831,10 @@ PKG_CHECK_MODULES([AMR], [opencore-amrnb >= 0.1.0],[
AM_CONDITIONAL([HAVE_AMR],[true])],[ AM_CONDITIONAL([HAVE_AMR],[true])],[
AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_AMR],[false])]) AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_AMR],[false])])
PKG_CHECK_MODULES([AMRWB], [opencore-amrwb >= 0.1.0 vo-amrwbenc >= 0.1.0],[
AM_CONDITIONAL([HAVE_AMRWB],[true])],[
AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_AMRWB],[false])])
AC_CHECK_LIB(apr-1, apr_pool_mutex_set, use_system_apr=yes, use_system_apr=no) AC_CHECK_LIB(apr-1, apr_pool_mutex_set, use_system_apr=yes, use_system_apr=no)
AM_CONDITIONAL([SYSTEM_APR],[test "${use_system_apr}" = "yes"]) AM_CONDITIONAL([SYSTEM_APR],[test "${use_system_apr}" = "yes"])
AC_CHECK_LIB(aprutil-1, apr_queue_pop_timeout, use_system_aprutil=yes, use_system_aprutil=no) AC_CHECK_LIB(aprutil-1, apr_queue_pop_timeout, use_system_aprutil=yes, use_system_aprutil=no)
...@@ -1934,7 +1938,6 @@ AM_CONDITIONAL(ISMAC, [test `uname -s` = Darwin]) ...@@ -1934,7 +1938,6 @@ AM_CONDITIONAL(ISMAC, [test `uname -s` = Darwin])
AM_CONDITIONAL(ISFREEBSD, [test `uname -s` = FreeBSD]) AM_CONDITIONAL(ISFREEBSD, [test `uname -s` = FreeBSD])
AM_CONDITIONAL(IS64BITLINUX, [test `uname -m` = x86_64]) AM_CONDITIONAL(IS64BITLINUX, [test `uname -m` = x86_64])
AM_CONDITIONAL(HAVE_AMRWB, [ test -d ${switch_srcdir}/libs/amrwb ])
AM_CONDITIONAL(HAVE_G723_1, [ test -d ${switch_srcdir}/libs/libg723_1 ]) AM_CONDITIONAL(HAVE_G723_1, [ test -d ${switch_srcdir}/libs/libg723_1 ])
AM_CONDITIONAL(HAVE_G729, [ test -d ${switch_srcdir}/libs/libg729 ]) AM_CONDITIONAL(HAVE_G729, [ test -d ${switch_srcdir}/libs/libg729 ])
......
LEGAL.
Please bear in mind that the software, as modified by Athonet, implements
functions for the AMR standard, which are covered by third parties' essential patents.
To the best of Athonet's knowledge, such essential patent rights holders are:
Nokia, Orange, Acacia (now VoiceAge) and Ericsson.
ATHONET HEREBY DISCLAIMS ANY AND ALL LIABILITY IN CASE YOUR USE,
MODIFICATION, COPY OR FURTHER DISTRIBUTION OF THE SOFTWARE, AS
MODIFIED BY ATHONET, INFRINGES IN ANY WAY THIRD PARTY'S INTELLECTUAL PROPERTY RIGHTS.
THIS DISCLAIMER SHALL NOT PREJUDICE ANY OTHER LIMITATION OF LIABILITY
INCLUDED IN THE APPLICABLE LICENSE.
include $(top_srcdir)/build/modmake.rulesam include $(top_srcdir)/build/modmake.rulesam
MODNAME=mod_amrwb MODNAME=mod_amrwb
AMRWB_DIR=$(switch_srcdir)/libs/amrwb
AMRWB_BUILDDIR=$(switch_builddir)/libs/amrwb
AMRWB_A=$(AMRWB_BUILDDIR)/libamrwb.a
mod_LTLIBRARIES = mod_amrwb.la mod_LTLIBRARIES = mod_amrwb.la
mod_amrwb_la_SOURCES = mod_amrwb.c if HAVE_AMRWB
mod_amrwb_la_SOURCES = mod_amrwb.c bitshift.c amrwb_be.c
else
mod_amrwb_la_SOURCES = mod_amrwb.c
endif
mod_amrwb_la_CFLAGS = $(AM_CFLAGS) mod_amrwb_la_CFLAGS = $(AM_CFLAGS)
mod_amrwb_la_LIBADD = $(switch_builddir)/libfreeswitch.la mod_amrwb_la_LIBADD = $(switch_builddir)/libfreeswitch.la
mod_amrwb_la_LDFLAGS = -avoid-version -module -no-undefined -shared mod_amrwb_la_LDFLAGS = -avoid-version -module -no-undefined -shared
if HAVE_AMRWB if HAVE_AMRWB
BUILT_SOURCES= $(AMRWB_A) # install AMRWB libraries: opencore-amrwb (decoder) and vo-amrwbenc (encoder) - check README
mod_amrwb_la_CFLAGS += -I$(AMRWB_DIR) mod_amrwb_la_CFLAGS += $(AMRWB_CFLAGS)
mod_amrwb_la_LIBADD += $(AMRWB_A) mod_amrwb_la_LIBADD += $(AMRWB_LIBS)
else else
mod_amrwb_la_CFLAGS += -DAMRWB_PASSTHROUGH mod_amrwb_la_CFLAGS += -DAMRWB_PASSTHROUGH
endif endif
......
Tested with mobile devices (VOLTE) :
Samsung S6 Edge, iPhone, Samsung Note4, Samsung S6
Tested with SIP clients :
Linphone, pjsip
INSTALL
1. install AMRWB libraries
libopencore-amrwb-dev - Adaptive Multi-Rate - Wideband speech codec - development files
libopencore-amrwb0 - Adaptive Multi-Rate - Wideband speech codec - shared library
libopencore-amrwb0-dbg - Adaptive Multi-Rate - Wideband speech codec - debugging symbols
libvo-amrwbenc-dev - VisualOn AMR-WB encoder library (development files)
libvo-amrwbenc0 - VisualOn AMR-WB encoder library
vo-amrwbenc-dbg - VisualOn AMR-WB encoder library (debugging symbols)
apt-get install libopencore-amrwb-dev libopencore-amrwb0 libopencore-amrwb0-dbg libvo-amrwbenc-dev libvo-amrwbenc0 vo-amrwbenc-dbg
This was tested on Debian 8.
2. copy files dec_if.h and enc_if.h in the directory with the sourcecode (mod_amrwb).
cp /usr/include/opencore-amrwb/dec_if.h .
cp /usr/include/vo-amrwbenc/enc_if.h .
3. make, make install
/*
* Copyright (c) 2016, Athonet (www.athonet.com)
* Dragos Oancea <dragos.oancea@athonet.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __AMRWB_BE_H__
#include "bitshift.h"
#include "amrwb_be.h"
extern const int switch_amrwb_frame_sizes[];
/* Bandwidth Efficient AMR-WB */
/* https://tools.ietf.org/html/rfc4867#page-17 */
/* this works the same as in AMR NB*/
extern switch_bool_t switch_amrwb_pack_be(unsigned char *shift_buf, int n)
{
uint8_t save_toc, ft;
save_toc = shift_buf[1];
/* we must convert OA TOC -> BE TOC */
/* OA TOC
0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
|F| FT |Q|P1|P2|
+-+-+-+-+-+-+-+-+
F (1 bit): see definition in Section 4.3.2.
FT (4 bits, unsigned integer): see definition in Section 4.3.2.
Q (1 bit): see definition in Section 4.3.2.
P bits: padding bits, MUST be set to zero, and MUST be ignored on reception.
*/
/* BE TOC:
0 1 2 3 4 5
+-+-+-+-+-+-+
|F| FT |Q|
+-+-+-+-+-+-+
F = 0 , FT = XXXX , Q = 1
eg: Frame Types (FT): ftp://www.3gpp.org/tsg_sa/TSG_SA/TSGS_04/Docs/PDF/SP-99253.pdf - table 1a
*/
ft = save_toc >> 3 ; /* drop Q, P1, P2 */
ft &= ~(1 << 5); /* clear - will mark just 1 frame - bit F */
/* we only encode one frame, so bit 0 of TOC will be 0 */
shift_buf[0] |= (ft >> 1); /* first 3 bits of FT */
switch_amr_array_lshift(6, shift_buf+1, n);
/*make sure we clear the bit - it will be used as padding of the trailing byte */
shift_buf[1] |= 1 << 6; /* set bit Q instead of P1 */
if (( ft >> 0 ) & 1) {
/* set last bit of TOC instead of P2 */
shift_buf[1] |= 1 << 7;
} else {
/* reset last bit of TOC instead of P2 */
shift_buf[1] &= ~(1 << 7);
}
return SWITCH_TRUE;
}
extern switch_bool_t switch_amrwb_unpack_be(unsigned char *encoded_buf, uint8_t *tmp, int encoded_len)
{
int framesz, index, ft;
uint8_t shift_tocs[2] = {0x00, 0x00};
uint8_t *shift_buf;
memcpy(shift_tocs, encoded_buf, 2);
/* shift for BE */
switch_amr_array_lshift(4, shift_tocs, 2);
ft = shift_tocs[0] >> 3;
ft &= ~(1 << 5); /* Frame Type*/
shift_buf = encoded_buf + 1; /* skip CMR */
/* shift for BE */
switch_amr_array_lshift(2, shift_buf, encoded_len - 1);
/* get frame size */
index = ((shift_tocs[0] >> 3) & 0x0f);
if (index > 10) {
return SWITCH_FALSE;
}
framesz = switch_amrwb_frame_sizes[index];
tmp[0] = shift_tocs[0]; /* save TOC */
memcpy(&tmp[1], shift_buf, framesz);
return SWITCH_TRUE;
}
#endif
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* Copyright (c) 2016, Athonet (www.athonet.com)
* Dragos Oancea <dragos.oancea@athonet.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __AMRWB_BE_H__
#define __AMRWB_BE_H__
/* Bandwidth Efficient AMR-WB */
extern switch_bool_t switch_amrwb_pack_be(unsigned char *shift_buf, int n);
extern switch_bool_t switch_amrwb_unpack_be(unsigned char *encoded_buf, uint8_t *tmp, int encoded_len);
#endif
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* Copyright (c) 2016, Athonet (www.athonet.com)
* Paolo Missiaggia <paolo.missiaggia@athonet.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __BITSHIFT_H__
#include "bitshift.h"
/*
* LEFT shift of an entire array of N bits, with N included between 0 and 8
*/
extern int switch_amr_array_lshift(uint8_t lshift, uint8_t *buf, int a_len)
{
int i = 0;
uint8_t first_byte;
uint8_t second_byte;
if (!buf || !a_len)
return (-1);
if ((lshift < 0) || (lshift > 8))
return (-1);
first_byte = 0xFF >> lshift;
second_byte = ~first_byte;
for (i = 1; i < a_len; i++) {
buf[i - 1] = ((buf[i - 1] & first_byte) << lshift) |
((buf[i] & second_byte) >> (8 - lshift));
}
i--;
buf[i] = ((buf[i] & first_byte) << lshift);
return (0);
}
#endif
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* Copyright (c) 2016, Athonet (www.athonet.com)
* Paolo Missiaggia <paolo.missiaggia@athonet.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __BITSHIFT_H__
#define __BITSHIFT_H__
#include "switch.h"
/*
* LEFT shift of an entire array of N bits, with N included between 0 and 8
*/
extern int switch_amr_array_lshift(uint8_t lshift, uint8_t *buf, int a_len);
#endif
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论