Commit 70182390 authored by Simon Morlat's avatar Simon Morlat

first commit of msamr, mediastreamer2 amr plugin.

parents
INSTALL
aclocal.m4
*~
configure
Makefile.in
Makefile
build-aux
m4
autom4te.cache
*.o
*.lo
*.la
config.log
config.status
.deps
.libs
libtool
Simon Morlat <simon.morlat@linphone.org>
This diff is collapsed.
SUBDIRS=src
#!/bin/sh
#AM_VERSION="1.10"
if ! type aclocal-$AM_VERSION 1>/dev/null 2>&1; then
# automake-1.10 (recommended) is not available on Fedora 8
AUTOMAKE=automake
ACLOCAL=aclocal
else
ACLOCAL=aclocal-${AM_VERSION}
AUTOMAKE=automake-${AM_VERSION}
fi
if test -f /opt/local/bin/glibtoolize ; then
# darwin
LIBTOOLIZE=/opt/local/bin/glibtoolize
else
LIBTOOLIZE=libtoolize
fi
if test -d /opt/local/share/aclocal ; then
ACLOCAL_ARGS="-I /opt/local/share/aclocal"
fi
echo "Generating build scripts in msamr..."
set -x
$LIBTOOLIZE --copy --force
$ACLOCAL $ACLOCAL_ARGS
#autoheader
$AUTOMAKE --force-missing --add-missing --copy
autoconf
# process this file with autoconf to produce a configure script.
AC_INIT([msamr],[0.0.1])
# require at least this autoconf version
AC_PREREQ(2.64)
# set up the directory structure
AC_CONFIG_SRCDIR([src/msamr.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
# initialize automake
AM_INIT_AUTOMAKE([tar-ustar])
# initialize libtool
LT_INIT([disable-static])
# check for libraries that have pkg-config files installed
PKG_CHECK_MODULES(ORTP, ortp >= 0.16.0)
PKG_CHECK_MODULES(MEDIASTREAMER, mediastreamer >= 2.0.0)
PKG_CHECK_MODULES(OPENCORE_AMRNB, opencore-amrnb >= 0.1.2)
# create the following files from their .in counterparts
AC_CONFIG_FILES([
Makefile
src/Makefile
])
AC_OUTPUT
plugindir = $(libdir)/mediastreamer/plugins
plugin_LTLIBRARIES=libmsamr.la
libmsamr_la_SOURCES=msamr.c
libmsamr_la_CFLAGS = $(MEDIASTREAMER_CFLAGS) $(OPENCORE_AMRNB_CFLAGS)
libmsamr_la_LIBADD = $(MEDIASTREAMER_LIBS) $(OPENCORE_AMRNB_LIBS)
libmsamr_la_LDFLAGS = -module
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2010 Simon MORLAT
Belledonne Communications SARL, All rights reserved.
simon.morlat@linphone.org
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <mediastreamer2/msfilter.h>
#include <opencore-amrnb/interf_dec.h>
#include <opencore-amrnb/interf_enc.h>
/*
Class A total speech
Index Mode bits bits
----------------------------------------
0 AMR 4.75 42 95
1 AMR 5.15 49 103
2 AMR 5.9 55 118
3 AMR 6.7 58 134
4 AMR 7.4 61 148
5 AMR 7.95 75 159
6 AMR 10.2 65 204
7 AMR 12.2 81 244
8 AMR SID 39 39
*/
static const int amr_frame_sizes[]={
12,
13,
15,
17,
19,
20,
26,
31,
5,
0
};
static void dec_init(MSFilter *f){
f->data=Decoder_Interface_init();
}
#define toc_get_f(toc) ((toc) >> 7)
#define toc_get_index(toc) ((toc>>3) & 0xf)
static int toc_list_check(uint8_t *tl, size_t buflen){
int s=1;
while(toc_get_f(*tl)){
tl++;
s++;
if (s>buflen){
return -1;
}
}
return s;
}
static void dec_process(MSFilter *f){
static const int nsamples=160;
mblk_t *im,*om;
uint8_t *tocs;
int toclen;
uint8_t tmp[32];
while((im=ms_queue_get(f->inputs[0]))!=NULL){
int sz=msgdsize(im);
int i;
if (sz<2){
freemsg(im);
continue;
}
/*skip payload header, ignore CMR */
im->b_rptr++;
/*see the number of TOCs :*/
tocs=im->b_rptr;
toclen=toc_list_check(tocs,sz);
if (toclen==-1){
ms_warning("Bad AMR toc list");
freemsg(im);
continue;
}
im->b_rptr+=toclen;
/*iterate through frames, following the toc list*/
for(i=0;i<toclen;++i){
int framesz=amr_frame_sizes[toc_get_index(tocs[i])];
if (im->b_rptr+framesz>=im->b_wptr){
ms_warning("Truncated amr frame");
break;
}
tmp[0]=tocs[i];
memcpy(&tmp[1],im->b_rptr,framesz);
om=allocb(nsamples*2,0);
Decoder_Interface_Decode(f->data,tmp,(short*)om->b_wptr,0);
om->b_wptr+=nsamples*2;
im->b_rptr+=framesz;
ms_queue_put(f->outputs[0],om);
}
freemsg(im);
}
}
static void dec_uninit(MSFilter *f){
Decoder_Interface_exit(f->data);
}
static MSFilterDesc dec_desc={
.name="MSAmrDec",
.text="AMR narrowband decode based on OpenCore codec.",
.category=MS_FILTER_DECODER,
.ninputs=1,
.noutputs=1,
.init=dec_init,
.process=dec_process,
.uninit=dec_uninit
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment