diff --git a/configure.ac b/configure.ac index de87617..e16821a 100644 --- a/configure.ac +++ b/configure.ac @@ -151,6 +151,7 @@ dnl ORTP_STATIC to tell ortp not to export its variable with dllexport, as if we LIBS="$LIBS -lws2" mingw_found=yes mingw32ce_found=yes + build_tests=no ;; *mingw*) CFLAGS="$CFLAGS -DINET6 -DORTP_INET6 -D_WIN32_WINNT=0x0501 -DORTP_STATIC" @@ -188,6 +189,8 @@ fi AM_CONDITIONAL(BUILD_MACOSX, test x$macosx_found = xyes) +AM_CONDITIONAL(BUILD_TESTS,test x$build_tests != xno) + AC_CONFIG_COMMANDS([libtool-hacking],[ if test "$mingw_found" = "yes" ; then echo "Hacking libtool to work with mingw..." @@ -695,17 +698,6 @@ this check. fi fi - -AC_ARG_ENABLE(tests_enabled, - [ --disable-tests Disable compilation of tests], - [case "${enableval}" in - yes) tests_enabled=true ;; - no) tests_enabled=false ;; - *) AC_MSG_ERROR(bad value ${enableval} for --disable-tests) ;; - esac],[tests_enabled=false]) -AM_CONDITIONAL(ENABLE_TESTS, test x$tests_enabled = xyes) - - dnl ################################################## dnl # Check for doxygen dnl ################################################## diff --git a/include/mediastreamer2/allfilters.h b/include/mediastreamer2/allfilters.h index fd11723..02128f4 100644 --- a/include/mediastreamer2/allfilters.h +++ b/include/mediastreamer2/allfilters.h @@ -127,9 +127,7 @@ typedef enum MSFilterId{ MS_AAL2_G726_40_DEC_ID, MS_AAL2_G726_32_DEC_ID, MS_AAL2_G726_24_DEC_ID, - MS_AAL2_G726_16_DEC_ID, - MS_L16_ENC_ID, - MS_L16_DEC_ID + MS_AAL2_G726_16_DEC_ID } MSFilterId; diff --git a/include/mediastreamer2/dtmfgen.h b/include/mediastreamer2/dtmfgen.h index 17a89fb..cea83ba 100644 --- a/include/mediastreamer2/dtmfgen.h +++ b/include/mediastreamer2/dtmfgen.h @@ -38,7 +38,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. **/ struct _MSDtmfGenCustomTone{ int duration; /**silence=0; s->default_amplitude=0.5; s->amplitude=(s->default_amplitude*0.7*32767); + s->interval=0; f->data=s; } @@ -154,6 +156,7 @@ static int dtmfgen_put(MSFilter *f, void *arg){ s->silence=0; s->amplitude=s->default_amplitude*32767*0.7; s->dtmf=dtmf[0]; + s->interval=0; ms_filter_unlock(f); return 0; } @@ -161,15 +164,19 @@ static int dtmfgen_put(MSFilter *f, void *arg){ static int dtmfgen_play_tone(MSFilter *f, void *arg){ DtmfGenState *s=(DtmfGenState*)f->data; MSDtmfGenCustomTone *def=(MSDtmfGenCustomTone*)arg; - ms_message("Playing tone of frequency %i, duration=%i, amplitude=%f",def->frequency,def->duration,def->amplitude); + if (def->interval > 0) + ms_message("Playing tones of frequencies %i - %i, duration=%i, amplitude=%f with interval %i",def->lowfreq,def->highfreq,def->duration,def->amplitude, def->interval); + else + ms_message("Playing tone of frequencies %i - %i, duration=%i, amplitude=%f",def->lowfreq,def->highfreq,def->duration,def->amplitude); ms_filter_lock(f); s->pos=0; s->dur=(s->rate*def->duration)/1000; - s->lowfreq=((float)def->frequency)/(float)s->rate; - s->highfreq=0; + s->lowfreq=((float)def->lowfreq)/(float)s->rate; + s->highfreq=((float)def->highfreq)/(float)s->rate; s->silence=0; s->amplitude=((float)def->amplitude)* 0.7*32767.0; s->dtmf='?'; + s->interval=def->interval; ms_filter_unlock(f); return 0; @@ -179,6 +186,7 @@ static int dtmfgen_start(MSFilter *f, void *arg){ if (dtmfgen_put(f,arg)==0){ DtmfGenState *s=(DtmfGenState*)f->data; s->dur=5*s->rate; + s->interval=0; return 0; } return -1; @@ -191,6 +199,7 @@ static int dtmfgen_stop(MSFilter *f, void *arg){ if (s->posdur=min_duration; else s->dur=0; + s->interval=0; ms_filter_unlock(f); return 0; } @@ -220,8 +229,12 @@ static void write_dtmf(DtmfGenState *s , int16_t *sample, int nsamples){ } if (s->pos>=s->dur){ s->pos=0; - s->dtmf=0; - s->silence=TRAILLING_SILENCE; + if (s->interval > 0) { + s->silence=s->interval; + } else { + s->dtmf=0; + s->silence=TRAILLING_SILENCE; + } } } @@ -257,9 +270,12 @@ static void dtmfgen_process(MSFilter *f){ } }else{ s->nosamples_time=0; - s->silence=0; + if (s->interval > 0) { + s->silence-=f->ticker->interval; + if (s->silence<0) s->silence=0; + } else s->silence=0; while((m=ms_queue_get(f->inputs[0]))!=NULL){ - if (s->dtmf!=0){ + if (s->dtmf!=0 && s->silence==0){ nsamples=(m->b_wptr-m->b_rptr)/2; write_dtmf(s, (int16_t*)m->b_rptr,nsamples); } diff --git a/src/l16.c b/src/l16.c deleted file mode 100644 index 7022309..0000000 --- a/src/l16.c +++ /dev/null @@ -1,198 +0,0 @@ -/* -mediastreamer2 library - modular sound and video processing and streaming -Copyright (C) 2011 Belledonne Communications SARL -Author: Simon Morlat - -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 - -struct EncState { - uint32_t ts; - int ptime; - int rate; - int nbytes; - MSBufferizer *bufferizer; -}; - -static void enc_init(MSFilter *f) -{ - struct EncState *s=(struct EncState*)ms_new(struct EncState,1); - s->ts=0; - s->bufferizer=ms_bufferizer_new(); - s->ptime = 20; - s->rate=8000; - f->data=s; -}; - -static void enc_uninit(MSFilter *f) -{ - struct EncState *s=(struct EncState*)f->data; - ms_bufferizer_destroy(s->bufferizer); - ms_free(s); - f->data = 0; -}; - -static void enc_preprocess(MSFilter *f){ - struct EncState *s=(struct EncState*)f->data; - s->nbytes=(2*s->rate*s->ptime)/1000; -} - -static void enc_process(MSFilter *f) -{ - struct EncState *s=(struct EncState*)f->data; - - ms_bufferizer_put_from_queue(s->bufferizer,f->inputs[0]); - - while(ms_bufferizer_get_avail(s->bufferizer)>=s->nbytes) { - mblk_t *om=allocb(s->nbytes,0); - om->b_wptr+=ms_bufferizer_read(s->bufferizer,om->b_wptr,s->nbytes); - mblk_set_timestamp_info(om,s->ts); - ms_queue_put(f->outputs[0],om); - s->ts += s->nbytes/2; - } -}; - -static void set_ptime(struct EncState *s, int value){ - if (value>0 && value<=100){ - s->ptime=value; - } -} - -static int enc_add_attr(MSFilter *f, void *arg) -{ - const char *fmtp=(const char*)arg; - struct EncState *s=(struct EncState*)f->data; - if(strstr(fmtp,"ptime:")) - set_ptime(s,atoi(fmtp+6)); - - return 0; -}; - -static int enc_add_fmtp(MSFilter *f, void *arg){ - const char *fmtp=(const char*)arg; - struct EncState *s=(struct EncState*)f->data; - char tmp[16]={0}; - if (fmtp_get_value(fmtp,"ptime",tmp,sizeof(tmp))){ - set_ptime(s,atoi(tmp)); - } - return 0; -} - -static int enc_set_sr(MSFilter *f, void *arg){ - struct EncState *s=(struct EncState*)f->data; - s->rate=*(int*)arg; - return 0; -} - -static MSFilterMethod enc_methods[]={ - { MS_FILTER_ADD_ATTR , enc_add_attr}, - { MS_FILTER_ADD_FMTP , enc_add_fmtp}, - { MS_FILTER_SET_SAMPLE_RATE , enc_set_sr }, - { 0 , NULL } -}; - -#ifdef _MSC_VER - -MSFilterDesc ms_l16_enc_desc={ - MS_L16_ENC_ID, - "MSL16Enc", - "L16 dummy encoder", - MS_FILTER_ENCODER, - "l16", - 1, - 1, - enc_init, - enc_preprocess, - enc_process, - NULL, - enc_uninit, - enc_methods -}; - -#else - -MSFilterDesc ms_l16_enc_desc={ - .id = MS_L16_ENC_ID, - .name = "MSL16Enc", - .text = "L16 dummy encoder", - .category = MS_FILTER_ENCODER, - .enc_fmt = "l16", - .ninputs = 1, - .noutputs = 1, - .init = enc_init, - .preprocess = enc_preprocess, - .process = enc_process, - .uninit = enc_uninit, - .methods = enc_methods -}; -#endif - - - -static void dec_init(MSFilter *f){ -}; - -static void dec_uninit(MSFilter *f){ -}; - -static void dec_process(MSFilter *f) -{ - mblk_t *im; - - while((im=ms_queue_get(f->inputs[0]))) { - ms_queue_put(f->outputs[0],im); - } -}; - -#ifdef _MSC_VER - -MSFilterDesc ms_l16_dec_desc={ - MS_L16_DEC_ID, - "MSL16Dec", - "L16 dummy decoder", - MS_FILTER_DECODER, - "l16", - 1, - 1, - dec_init, - NULL, - dec_process, - NULL, - dec_uninit, - NULL -}; - -#else - -MSFilterDesc ms_l16_dec_desc={ - .id = MS_L16_DEC_ID, - .name = "MSL16Dec", - .text = "L16 dummy decoder", - .category = MS_FILTER_DECODER, - .enc_fmt = "l16", - .ninputs = 1, - .noutputs = 1, - .init = dec_init, - .process = dec_process, - .uninit = dec_uninit -}; - -#endif - - -MS_FILTER_DESC_EXPORT(ms_l16_dec_desc) -MS_FILTER_DESC_EXPORT(ms_l16_enc_desc) diff --git a/src/videoout.c b/src/videoout.c index 3cb599b..6705466 100644 --- a/src/videoout.c +++ b/src/videoout.c @@ -398,7 +398,9 @@ static int sdl_poll_event(MSDisplay *obj, MSDisplayEvent *ev){ SdlDisplay *wd = (SdlDisplay*)obj->data; SDL_Event event; if (wd->sdl_screen==NULL) return -1; + ms_mutex_lock(&wd->sdl_mutex); if (SDL_PollEvent(&event)){ + ms_mutex_unlock(&wd->sdl_mutex); switch(event.type){ case SDL_VIDEORESIZE: ev->evtype=MS_DISPLAY_RESIZE_EVENT; @@ -412,7 +414,7 @@ static int sdl_poll_event(MSDisplay *obj, MSDisplayEvent *ev){ return 0; break; } - } + }else ms_mutex_unlock(&wd->sdl_mutex); return -1; } diff --git a/tests/Makefile.am b/tests/Makefile.am index aa5506a..8c7f817 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -if ENABLE_TESTS +if BUILD_TESTS noinst_PROGRAMS=echo ring mtudiscover bench tones diff --git a/tests/tones.c b/tests/tones.c index 5008147..5a2c94a 100644 --- a/tests/tones.c +++ b/tests/tones.c @@ -64,7 +64,8 @@ int main(int argc, char *argv[]){ MSToneDetectorDef expected_tone; char dtmf='*'; - tone.frequency=2000; + tone.lowfreq=2000; + tone.highfreq=0; tone.duration=400; tone.amplitude=0.6; @@ -85,7 +86,8 @@ int main(int argc, char *argv[]){ ms_sleep(1); ms_filter_call_method(gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone); ms_sleep(1); - tone.frequency=1500; + tone.lowfreq=1500; + tone.highfreq=0; tone.amplitude=1.0; ms_filter_call_method(gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone); ms_sleep(1);