Commit 1da46bd4 authored by Sandrine Avakian's avatar Sandrine Avakian

Adding v16 make files and creating v16 audio filter.

parent bf4f672f
......@@ -82,6 +82,7 @@ cmake_dependent_option(ENABLE_OSS "Enable OSS support." YES "ENABLE_SOUND;LINUX_
cmake_dependent_option(ENABLE_PORTAUDIO "Enable portaudio native support." NO "ENABLE_SOUND" NO)
cmake_dependent_option(ENABLE_PULSEAUDIO "Enable pulseaudio support." YES "ENABLE_SOUND" NO)
option(ENABLE_GSM "Build mediastreamer2 with the GSM codec." YES)
option(ENABLE_BV16 "Build mediastreamer2 with the BV16 codec." YES)
option(ENABLE_OPUS "Build mediastreamer2 with the OPUS codec." YES)
cmake_dependent_option(ENABLE_RESAMPLE "Build mediastreamer2 with the resampling capability." YES "ENABLE_SPEEX" NO)
option(ENABLE_SPEEX "Build mediastreamer2 with the SPEEX codec." YES)
......@@ -206,6 +207,13 @@ if(ENABLE_GSM)
set(ENABLE_GSM OFF CACHE BOOL "Build mediastreamer2 with the GSM codec." FORCE)
endif()
endif()
if(ENABLE_BV16)
find_package(BV16)
if(NOT BV16_FOUND)
message(WARNING "Could not find BV16 library, mediastreamer2 will be compiled without the BV16 codec.")
set(ENABLE_BV16 OFF CACHE BOOL "Build mediastreamer2 with the BV16 codec." FORCE)
endif()
endif()
if(ENABLE_OPUS)
find_package(Opus)
if(NOT OPUS_FOUND)
......
############################################################################
# FindBroadVoice16.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# 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.
#
############################################################################
#
# - Find the bv16 include file and library
#
# BV16_FOUND - system has bv16
# BV16_INCLUDE_DIRS - the bv16 include directory
# BV16_LIBRARIES - The libraries needed to use bv16
set(_BV16_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
find_path(BV16_INCLUDE_DIRS
NAMES bv16/bv16.h
HINTS _BV16_ROOT_PATHS
PATH_SUFFIXES include
)
if(BV16_INCLUDE_DIRS)
set(HAVE_BV16_BV16_H 1)
endif()
find_library(BV16_LIBRARIES
NAMES bv16
HINTS _BV16_ROOT_PATHS
PATH_SUFFIXES bin lib
)
# if(BV16_LIBRARIES)
# find_library(LIBM
# NAMES m
# HINTS _BV16_ROOT_PATHS
# PATH_SUFFIXES bin lib
# )
# if(LIBM)
# list(APPEND BV16_LIBRARIES ${LIBM})
# endif()
# endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(bv16
DEFAULT_MSG
BV16_INCLUDE_DIRS BV16_LIBRARIES HAVE_BV16_BV16_H
)
mark_as_advanced(BV16_INCLUDE_DIRS BV16_LIBRARIES HAVE_BV16_BV16_H)
......@@ -150,7 +150,9 @@ typedef enum MSFilterId{
MS_RTT_4103_SOURCE_ID,
MS_RTT_4103_SINK_ID,
MS_MEDIACODEC_H264_DEC_ID,
MS_MEDIACODEC_H264_ENC_ID
MS_MEDIACODEC_H264_ENC_ID,
MS_BV16_DEC_ID,
MS_BV16_ENC_ID
} MSFilterId;
......
......@@ -200,6 +200,9 @@ endif()
if(GSM_FOUND)
list(APPEND VOIP_SOURCE_FILES_C audiofilters/gsm.c)
endif()
if(BV16_FOUND)
list(APPEND VOIP_SOURCE_FILES_C audiofilters/bv16.c)
endif()
if(OPUS_FOUND)
list(APPEND VOIP_SOURCE_FILES_C audiofilters/msopus.c)
endif()
......@@ -407,6 +410,9 @@ endif()
if(SPEEX_FOUND)
list(APPEND VOIP_LIBS ${SPEEX_LIBRARIES})
endif()
if(BV16_FOUND)
list(APPEND VOIP_LIBS ${BV16_LIBRARIES})
endif()
if(ALSA_FOUND)
list(APPEND VOIP_LIBS ${ALSA_LIBRARIES})
endif()
......
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2006 Simon MORLAT (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 <bv16/typedef.h>
#include <bv16/bv16cnst.h>
#include <bv16/bvcommon.h>
#include <bv16/bv16strct.h>
#include <bv16/bv16.h>
#ifdef _MSC_VER
#include <malloc.h>
#define alloca _alloca
#endif
typedef struct EncState{
struct BV16_Encoder_State state;
uint32_t ts; // timestamp
int ptime;
int maxptime;
MSBufferizer *bufferizer;
} EncState;
static int set_ptime(MSFilter *f, int ptime){
EncState *s=(EncState*)f->data;
if (ptime<10 || ptime>140) return -1;
s->ptime = ptime;
ms_message("MSBV16Enc: got ptime=%i using [%i]",ptime,s->ptime);
return 0;
}
static int enc_add_fmtp(MSFilter *f, void *arg){
const char *fmtp=(const char *)arg;
char tmp[30];
if (fmtp_get_value(fmtp,"ptime",tmp,sizeof(tmp))){
return set_ptime(f,atoi(tmp));
}
return 0;
}
static int enc_add_attr(MSFilter *f, void *arg){
const char *attr=(const char *)arg;
if (strstr(attr,"ptime:")!=NULL){
int ptime = atoi(attr+6);
return set_ptime(f,ptime);
}
return 0;
}
static int enc_get_sample_rate(MSFilter *f, void *arg) {
MS_UNUSED(f);
*((int *)arg) = 8000;
return 0;
}
static int get_channels(MSFilter *f, void *arg) {
*((int *)arg) = 1;
return 0;
}
static void enc_init(MSFilter *f){
EncState *s=(EncState *)ms_new(EncState,1);
Reset_BV16_Encoder(&(s->state));
s->ts=0;
s->ptime=0;
s->maxptime = 0;
s->bufferizer=ms_bufferizer_new();
f->data=s;
}
static void enc_uninit(MSFilter *f){
EncState *s=(EncState*)f->data;
ms_bufferizer_destroy(s->bufferizer);
ms_free(s);
}
static void enc_process(MSFilter *f){
// EncState *s=(EncState*)f->data;
// mblk_t *im;
// unsigned int unitary_buff_size = sizeof(int16_t)*160;
// unsigned int buff_size = unitary_buff_size*s->ptime/20;
// int16_t* buff;
// unsigned int offset;
//
// while((im=ms_queue_get(f->inputs[0]))!=NULL){
// ms_bufferizer_put(s->bufferizer,im);
// }
// while(ms_bufferizer_get_avail(s->bufferizer) >= buff_size) {
// mblk_t *om=allocb((33*s->ptime)/20,0);
// buff = (int16_t *)alloca(buff_size);
// ms_bufferizer_read(s->bufferizer,(uint8_t*)buff,buff_size);
//
// for (offset=0;offset<buff_size;offset+=unitary_buff_size) {
// bv16_encode(s->state,(bv16_signal*)&buff[offset/sizeof(int16_t)],(bv16_byte*)om->b_wptr);
// om->b_wptr+=33;
// }
// ms_bufferizer_fill_current_metas(s->bufferizer, om);
// mblk_set_timestamp_info(om,s->ts);
// ms_queue_put(f->outputs[0],om);
// s->ts+=buff_size/sizeof(int16_t)/*sizeof(buf)/2*/;
}
static MSFilterMethod enc_methods[]={
{MS_FILTER_ADD_FMTP ,enc_add_fmtp},
{MS_FILTER_ADD_ATTR ,enc_add_attr},
{MS_FILTER_GET_SAMPLE_RATE ,enc_get_sample_rate },
{ 0 , NULL }
};
#ifdef _MSC_VER
MSFilterDesc ms_bv16_enc_desc={
MS_BV16_ENC_ID,
"MSBv16Enc",
N_("The BV16 full-rate codec"),
MS_FILTER_ENCODER,
"bv16",
1,
1,
enc_init,
NULL,
enc_process,
NULL,
enc_uninit,
enc_methods
};
#else
MSFilterDesc ms_bv16_enc_desc={
.id=MS_BV16_ENC_ID,
.name="MSBv16Enc",
.text=N_("The BV16 full-rate codec"),
.category=MS_FILTER_ENCODER,
.enc_fmt="bv16",
.ninputs=1,
.noutputs=1,
.init=enc_init,
.process=enc_process,
.uninit=enc_uninit,
.methods = enc_methods
};
#endif
static void dec_init(MSFilter *f){
Reset_BV16_Decoder((struct BV16_Decoder_State *)f->data);
}
static void dec_uninit(MSFilter *f){
Reset_BV16_Decoder((struct BV16_Decoder_State *)f->data);
}
static void dec_process(MSFilter *f){
// gsm s=(gsm)f->data;
// mblk_t *im;
// mblk_t *om;
// const int frsz=160*2;
// while((im=ms_queue_get(f->inputs[0]))!=NULL){
// for (;(im->b_wptr-im->b_rptr)>=33;im->b_rptr+=33) {
// om=allocb(frsz,0);
// mblk_meta_copy(im, om);
// if (gsm_decode(s,(gsm_byte*)im->b_rptr,(gsm_signal*)om->b_wptr)<0){
// ms_warning("gsm_decode error!");
// freemsg(om);
// }else{
// om->b_wptr+=frsz;
// ms_queue_put(f->outputs[0],om);
// }
// }
// freemsg(im);
// }
}
static int dec_get_sample_rate(MSFilter *f, void *arg) {
MS_UNUSED(f);
*((int *)arg) = 8000;
return 0;
}
static MSFilterMethod dec_methods[] = {
{ MS_FILTER_GET_SAMPLE_RATE, dec_get_sample_rate },
{ 0, NULL }
};
#ifdef _MSC_VER
MSFilterDesc ms_bv16_dec_desc={
MS_BV16_DEC_ID,
"MSBv16Dec",
N_("The BV16 codec"),
MS_FILTER_DECODER,
"bv16",
1,
1,
dec_init,
NULL,
dec_process,
NULL,
dec_uninit,
dec_methods
};
#else
MSFilterDesc ms_bv16_dec_desc={
.id=MS_BV16_DEC_ID,
.name="MSBv16Dec",
.text=N_("The BV16 codec"),
.category=MS_FILTER_DECODER,
.enc_fmt="bv16",
.ninputs=1,
.noutputs=1,
.init=dec_init,
.process=dec_process,
.uninit=dec_uninit,
.methods=dec_methods
};
#endif
MS_FILTER_DESC_EXPORT(ms_bv16_dec_desc)
MS_FILTER_DESC_EXPORT(ms_bv16_enc_desc)
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