diff --git a/Makefile.am b/Makefile.am index 3bf9cbd048..739bd29ecb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -310,6 +310,7 @@ library_include_HEADERS = \ src/include/switch_jitterbuffer.h \ src/include/switch_estimators.h \ src/include/switch_rtcp_frame.h \ + src/include/switch_spandsp.h \ src/include/switch_stun.h \ src/include/switch_nat.h \ src/include/switch_log.h \ @@ -385,6 +386,7 @@ libfreeswitch_la_SOURCES = \ src/switch_ivr_say.c \ src/switch_ivr_menu.c \ src/switch_ivr.c \ + src/switch_spandsp.c \ src/switch_stun.c \ src/switch_nat.c \ src/switch_log.c \ diff --git a/build/modmake.rules.in b/build/modmake.rules.in index dbce9bd48e..7f880b86f9 100644 --- a/build/modmake.rules.in +++ b/build/modmake.rules.in @@ -188,7 +188,7 @@ $(MODNAME).o: $(MODDIR)/$(SOURCEFILE) \ $(switch_srcdir)/src/include/switch_event.h $(switch_srcdir)/src/include/switch_resample.h \ $(switch_srcdir)/src/include/switch_ivr.h $(switch_srcdir)/src/include/switch_rtp.h \ $(switch_srcdir)/src/include/switch_stun.h $(switch_srcdir)/src/include/switch_log.h \ - $(switch_srcdir)/src/include/switch_xml.h + $(switch_srcdir)/src/include/switch_xml.h $(switch_srcdir)/src/include/switch_spandsp.h @echo Compiling $<... if test -f "$(CSOURCEFILE)" -o -f "$(MODDIR)/$(CSOURCEFILE)"; then \ if test ! -z $(VERBOSE) ; then echo $(COMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< ; fi ;\ @@ -211,7 +211,7 @@ $(MODNAME).lo: $(MODDIR)/$(SOURCEFILE) \ $(switch_srcdir)/src/include/switch_event.h $(switch_srcdir)/src/include/switch_resample.h \ $(switch_srcdir)/src/include/switch_ivr.h $(switch_srcdir)/src/include/switch_rtp.h \ $(switch_srcdir)/src/include/switch_stun.h $(switch_srcdir)/src/include/switch_log.h \ - $(switch_srcdir)/src/include/switch_xml.h + $(switch_srcdir)/src/include/switch_xml.h $(switch_srcdir)/src/include/switch_spandsp.h @echo Compiling $<... if test -f "$(CSOURCEFILE)" -o -f "$(MODDIR)/$(CSOURCEFILE)"; then \ if test ! -z $(VERBOSE) ; then echo $(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< ; fi ;\ @@ -261,6 +261,8 @@ $(switch_srcdir)/src/include/switch_ivr.h: $(switch_srcdir)/src/include/switch_rtp.h: +$(switch_srcdir)/src/include/switch_spandsp.h: + $(switch_srcdir)/src/include/switch_stun.h: $(switch_srcdir)/src/include/switch_log.h: diff --git a/libs/.gitignore b/libs/.gitignore index 5a83438d92..355bae9a6d 100644 --- a/libs/.gitignore +++ b/libs/.gitignore @@ -793,4 +793,5 @@ mariadb-connector-c-*/ mariadb-connector-c-* /spandsp*/ /spandsp* -win32/spandsp/spandsp.h \ No newline at end of file +win32/spandsp/spandsp.h +win32/spandsp/win32 \ No newline at end of file diff --git a/src/include/private/switch_apr_pvt.h b/src/include/private/switch_apr_pvt.h new file mode 100644 index 0000000000..ae4dc9c995 --- /dev/null +++ b/src/include/private/switch_apr_pvt.h @@ -0,0 +1,66 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005-2021, Anthony Minessale II + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Anthony Minessale II + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Anthony Minessale II + * Andrey Volk + * + * + * switch_apr_pvt.h - APR + * + */ + +#ifndef __SWITCH_APR_PVT_H__ +#define __SWITCH_APR_PVT_H__ + +/* for apr_pool_create and apr_pool_destroy */ +/* functions only used in this file so not exposed */ +#include + +/* for apr_hash_make, apr_hash_pool_get, apr_hash_set */ +/* functions only used in this file so not exposed */ +#include + +/* for apr_pvsprintf */ +/* function only used in this file so not exposed */ +#include + +/* for apr_initialize and apr_terminate */ +/* function only used in this file so not exposed */ +#include + +#include + +#endif // __SWITCH_APR_PVT_H__ + +/* 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: + */ diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h index aece2e7e17..af6a4f53bd 100644 --- a/src/include/private/switch_core_pvt.h +++ b/src/include/private/switch_core_pvt.h @@ -32,32 +32,12 @@ * this file does not exist!!!! * */ -#define SPANDSP_NO_TIFF 1 -#include "spandsp.h" #include "switch_profile.h" #ifndef WIN32 #include #endif -/* for apr_pool_create and apr_pool_destroy */ -/* functions only used in this file so not exposed */ -#include - -/* for apr_hash_make, apr_hash_pool_get, apr_hash_set */ -/* functions only used in this file so not exposed */ -#include - -/* for apr_pvsprintf */ -/* function only used in this file so not exposed */ -#include - -/* for apr_initialize and apr_terminate */ -/* function only used in this file so not exposed */ -#include - -#include - #ifdef HAVE_MLOCKALL #include #endif @@ -175,7 +155,7 @@ struct switch_core_session { switch_log_level_t loglevel; uint32_t soft_lock; switch_ivr_dmachine_t *dmachine[2]; - plc_state_t *plc; + switch_plc_state_t *plc; switch_media_handle_t *media_handle; uint32_t decoder_errors; diff --git a/src/include/switch.h b/src/include/switch.h index 461914c93b..b7bae46c0e 100644 --- a/src/include/switch.h +++ b/src/include/switch.h @@ -112,6 +112,7 @@ #include "switch_platform.h" #include "switch_types.h" #include "switch_apr.h" +#include "switch_spandsp.h" #include "switch_mprintf.h" #include "switch_core_db.h" #include "switch_dso.h" diff --git a/src/include/switch_spandsp.h b/src/include/switch_spandsp.h new file mode 100644 index 0000000000..1818a00825 --- /dev/null +++ b/src/include/switch_spandsp.h @@ -0,0 +1,54 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005-2014, Anthony Minessale II + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Anthony Minessale II + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Anthony Minessale II + * Andrey Volk + * + * switch_spandsp.h -- SpanDSP includes header + * + */ +#ifndef SWITCH_SPANDSP_H +#define SWITCH_SPANDSP_H + +SWITCH_BEGIN_EXTERN_C + +SWITCH_DECLARE(switch_plc_state_t *) switch_plc_init(switch_plc_state_t *s); +SWITCH_DECLARE(int) switch_plc_free(switch_plc_state_t *s); +SWITCH_DECLARE(int) switch_plc_rx(switch_plc_state_t *s, int16_t amp[], int len); +SWITCH_DECLARE(int) switch_plc_fillin(switch_plc_state_t *s, int16_t amp[], int len); + +SWITCH_END_EXTERN_C +#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: + */ diff --git a/src/include/switch_types.h b/src/include/switch_types.h index bb06cfa0ea..b8405511d8 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -2324,6 +2324,7 @@ typedef int switch_os_socket_t; #endif typedef struct apr_pool_t switch_memory_pool_t; +typedef void* switch_plc_state_t; typedef uint16_t switch_port_t; typedef uint8_t switch_payload_t; typedef struct switch_app_log switch_app_log_t; diff --git a/src/switch.c b/src/switch.c index d10994c4c2..2f5274099e 100644 --- a/src/switch.c +++ b/src/switch.c @@ -49,6 +49,7 @@ #endif #include +#include "private/switch_apr_pvt.h" #include "private/switch_core_pvt.h" /* pid filename: Stores the process id of the freeswitch process */ diff --git a/src/switch_core.c b/src/switch_core.c index 50ce348c95..4953964a38 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -41,6 +41,7 @@ #include #include #include +#include "private/switch_apr_pvt.h" #include "private/switch_core_pvt.h" #include #include diff --git a/src/switch_core_io.c b/src/switch_core_io.c index 13054b5b08..9931f0f3ef 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -422,7 +422,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi if (is_cng) { if (session->plc) { - plc_fillin(session->plc, session->raw_read_frame.data, read_frame->codec->implementation->decoded_bytes_per_packet / 2); + switch_plc_fillin(session->plc, session->raw_read_frame.data, read_frame->codec->implementation->decoded_bytes_per_packet / 2); is_cng = 0; flag &= ~SFF_CNG; } else { @@ -470,7 +470,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi if (!switch_test_flag(read_frame->codec, SWITCH_CODEC_FLAG_HAS_PLC) && (switch_channel_test_flag(session->channel, CF_JITTERBUFFER_PLC) || switch_channel_test_flag(session->channel, CF_CNG_PLC)) && !session->plc) { - session->plc = plc_init(NULL); + session->plc = switch_plc_init(NULL); } if (!switch_test_flag(read_frame->codec, SWITCH_CODEC_FLAG_HAS_PLC) && session->plc && switch_test_flag(read_frame, SFF_PLC)) { @@ -519,10 +519,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi if (status == SWITCH_STATUS_SUCCESS && session->read_impl.number_of_channels == 1) { if (session->plc) { if (switch_test_flag(read_frame, SFF_PLC)) { - plc_fillin(session->plc, session->raw_read_frame.data, session->raw_read_frame.datalen / 2); + switch_plc_fillin(session->plc, session->raw_read_frame.data, session->raw_read_frame.datalen / 2); switch_clear_flag(read_frame, SFF_PLC); } else { - plc_rx(session->plc, session->raw_read_frame.data, session->raw_read_frame.datalen / 2); + switch_plc_rx(session->plc, session->raw_read_frame.data, session->raw_read_frame.datalen / 2); } } } diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 087a151570..0b337082b8 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -40,6 +40,8 @@ #include #include +#include + static switch_t38_options_t * switch_core_media_process_udptl(switch_core_session_t *session, sdp_session_t *sdp, sdp_media_t *m); static void switch_core_media_find_zrtp_hash(switch_core_session_t *session, sdp_session_t *sdp); static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *session, const char *codec_string, sdp_session_t *sdp, switch_sdp_type_t sdp_type); diff --git a/src/switch_core_memory.c b/src/switch_core_memory.c index 3685956257..f005a9245e 100644 --- a/src/switch_core_memory.c +++ b/src/switch_core_memory.c @@ -33,6 +33,7 @@ */ #include +#include "private/switch_apr_pvt.h" #include "private/switch_core_pvt.h" //#define DEBUG_ALLOC diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 147900e784..32139ac98a 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -1585,7 +1585,7 @@ SWITCH_DECLARE(void) switch_core_session_perform_destroy(switch_core_session_t * switch_mutex_unlock(runtime.session_hash_mutex); if ((*session)->plc) { - plc_free((*session)->plc); + switch_plc_free((*session)->plc); (*session)->plc = NULL; } diff --git a/src/switch_spandsp.c b/src/switch_spandsp.c new file mode 100644 index 0000000000..397717da93 --- /dev/null +++ b/src/switch_spandsp.c @@ -0,0 +1,65 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005-2015, Anthony Minessale II + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/F + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Michael Jerris + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Michael Jerris + * Andrey Volk + * + * switch_spandsp.c -- spandsp wrappers and extensions + * + */ + +#include + +#define SPANDSP_NO_TIFF 1 +#include "spandsp.h" + +SWITCH_DECLARE(switch_plc_state_t *) switch_plc_init(switch_plc_state_t *s) { + return (switch_plc_state_t *)plc_init((plc_state_t *)s); +} + +SWITCH_DECLARE(int) switch_plc_free(switch_plc_state_t *s) { + return plc_free((plc_state_t *)s); +} + +SWITCH_DECLARE(int) switch_plc_fillin(switch_plc_state_t *s, int16_t amp[], int len) { + return plc_fillin((plc_state_t *)s, amp, len); +} + +SWITCH_DECLARE(int) switch_plc_rx(switch_plc_state_t* s, int16_t amp[], int len) +{ + return plc_rx((plc_state_t*)s, amp, len); +} + + +/* 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: + */ diff --git a/src/switch_time.c b/src/switch_time.c index fc94b48ee4..182d9ad6bd 100644 --- a/src/switch_time.c +++ b/src/switch_time.c @@ -33,6 +33,7 @@ #include #include +#include "private/switch_apr_pvt.h" #include "private/switch_core_pvt.h" #ifdef HAVE_TIMERFD_CREATE diff --git a/src/switch_utils.c b/src/switch_utils.c index 107d1a8643..d869ddfda4 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -33,6 +33,7 @@ */ #include +#include "private/switch_apr_pvt.h" #ifndef WIN32 #include #if defined(HAVE_SYS_TIME_H) && defined(HAVE_SYS_RESOURCE_H) diff --git a/tests/unit/.gitignore b/tests/unit/.gitignore index 4c7b7466c4..470c5ded12 100644 --- a/tests/unit/.gitignore +++ b/tests/unit/.gitignore @@ -48,3 +48,6 @@ Makefile conf/*/ conf_playsay/*/ conf_async/*/ +x64 +win32 +*.vcxproj.user \ No newline at end of file diff --git a/w32/Library/FreeSwitchCore.2017.vcxproj b/w32/Library/FreeSwitchCore.2017.vcxproj index 9d7098ee5e..68450d79dd 100644 --- a/w32/Library/FreeSwitchCore.2017.vcxproj +++ b/w32/Library/FreeSwitchCore.2017.vcxproj @@ -407,6 +407,7 @@ if not exist "$(OutDir)fonts" xcopy "$(SolutionDir)fonts\*.*" "$(OutDir)fonts\" + @@ -742,6 +743,7 @@ if not exist "$(OutDir)fonts" xcopy "$(SolutionDir)fonts\*.*" "$(OutDir)fonts\" +