From 4e2e8151b02b2f8b79bb8a126175abbdc1b4e86d Mon Sep 17 00:00:00 2001 From: Aron Podrigal Date: Tue, 30 Jan 2024 06:21:47 -0600 Subject: [PATCH 01/11] [mod_lua] Add Dbh:query_rows The added method, query_rows, allows the retrieval of rows from a database without the need for a callback function, it fetches the rows and returns 3 arguments as show below. ``` lua local success, rows, err = dbh:query_rows(sql) ``` This function performs better with large number of rows. Test results below 50k rows returned. dbh:query(sql, callback) - 0.335949 seconds dbh:query_rows(sql) - 0.253178 seconds --- src/mod/languages/mod_lua/freeswitch.i | 6 +++ src/mod/languages/mod_lua/freeswitch_lua.cpp | 56 ++++++++++++++++++++ src/mod/languages/mod_lua/freeswitch_lua.h | 2 + 3 files changed, 64 insertions(+) diff --git a/src/mod/languages/mod_lua/freeswitch.i b/src/mod/languages/mod_lua/freeswitch.i index 501b50fb48..96a5f8c722 100644 --- a/src/mod/languages/mod_lua/freeswitch.i +++ b/src/mod/languages/mod_lua/freeswitch.i @@ -61,6 +61,11 @@ %include "typemaps.i" %apply int *OUTPUT { int *len }; +%typemap(out) DbhQueryRowsReturn { + SWIG_arg += result; +} + + /** * tell swig to grok everything defined in these header files and * build all sorts of c wrappers and lua shadows of the c wrappers. @@ -115,6 +120,7 @@ class Dbh { bool connected(); bool test_reactive(char *test_sql, char *drop_sql = NULL, char *reactive_sql = NULL); bool query(char *sql, SWIGLUA_FN lua_fun); + DbhQueryRowsReturn query_rows(lua_State* L, char *sql); int affected_rows(); char *last_error(); void clear_error(); diff --git a/src/mod/languages/mod_lua/freeswitch_lua.cpp b/src/mod/languages/mod_lua/freeswitch_lua.cpp index 5d89aa28f9..2affbf7e88 100644 --- a/src/mod/languages/mod_lua/freeswitch_lua.cpp +++ b/src/mod/languages/mod_lua/freeswitch_lua.cpp @@ -482,6 +482,62 @@ bool Dbh::query(char *sql, SWIGLUA_FN lua_fun) return false; } +struct query_callback_data { + lua_State *L; + int stack_index; + int *row_num; +}; + +int query2_callback(void *pArg, int argc, char **argv, char **columnNames) +{ + struct query_callback_data *data = (struct query_callback_data *) pArg; + lua_State *tL = data->L; + lua_createtable(tL, 0, argc); + for (int i = 0; i < argc; i++) { + lua_pushstring(tL, argv[i]); + lua_setfield(tL, -2, switch_str_nil(columnNames[i])); + } + lua_rawseti(tL, data->stack_index + 2, (*data->row_num)++); + return 0; +} + +DbhQueryRowsReturn Dbh::query_rows(lua_State* L, char *sql) +{ + int stack_index = lua_gettop(L); + clear_error(); + lua_pushboolean(L, 0); // result success error: stack_index + 1 + lua_newtable(L); // the rows: stack_index + 2 + lua_pushnil(L); // error message if any: stack_index + 3 + + if (zstr(sql)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing SQL query.\n"); + lua_pushstring(L, "Missing SQL query."); + lua_replace(L, stack_index + 3); + return 3; + } + + if (dbh) { + int index = 1; + struct query_callback_data pData = {L, stack_index, &index}; + + if (switch_cache_db_execute_sql_callback(dbh, sql, query2_callback, &pData, &err) == SWITCH_STATUS_SUCCESS) { + // no errors + lua_pushboolean(L, 1); + lua_replace(L, stack_index + 1); + } else { + lua_pushstring(L, !zstr(err) ? err : "Failed to execute sql query"); + lua_replace(L, stack_index + 3); + } + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DBH NOT Connected.\n"); + lua_pushstring(L, "DBH NOT Connected."); + lua_replace(L, stack_index + 3); + } + + return 3; +} + + int Dbh::affected_rows() { if (dbh) { diff --git a/src/mod/languages/mod_lua/freeswitch_lua.h b/src/mod/languages/mod_lua/freeswitch_lua.h index c357916607..0cd1a64c32 100644 --- a/src/mod/languages/mod_lua/freeswitch_lua.h +++ b/src/mod/languages/mod_lua/freeswitch_lua.h @@ -28,6 +28,7 @@ typedef struct{ #define SWIGLUA_TABLE_GET(fn) {lua_pushvalue(fn.L,fn.idx);} +typedef int DbhQueryRowsReturn; namespace LUA { class Session:public CoreSession { @@ -76,6 +77,7 @@ namespace LUA { bool connected(); bool test_reactive(char *test_sql, char *drop_sql = NULL, char *reactive_sql = NULL); bool query(char *sql, SWIGLUA_FN lua_fun); + DbhQueryRowsReturn query_rows(lua_State* L, char *sql); int affected_rows(); char *last_error(); void clear_error(); From d6a7bb9ee57e9a3a03cde878ce097681d6a828f6 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Wed, 15 Jan 2025 15:59:23 +0300 Subject: [PATCH 02/11] [mod_lua] Fix hack.diff --- src/mod/languages/mod_lua/hack.diff | 54 +++++++++++++++++------------ 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/src/mod/languages/mod_lua/hack.diff b/src/mod/languages/mod_lua/hack.diff index 95ec620feb..779d4f5a8b 100644 --- a/src/mod/languages/mod_lua/hack.diff +++ b/src/mod/languages/mod_lua/hack.diff @@ -1,6 +1,6 @@ ---- mod_lua_wrap.cpp.old 2015-06-16 12:27:19.024000000 -0500 -+++ mod_lua_wrap.cpp 2015-06-16 12:34:51.540000000 -0500 -@@ -4242,7 +4242,7 @@ static int _wrap_Stream_read(lua_State* L) { +--- mod_lua_wrap.cpp.old 2025-01-15 13:22:48.705853645 +0000 ++++ mod_lua_wrap.cpp 2025-01-15 13:23:33.161847705 +0000 +@@ -4242,7 +4242,7 @@ } result = (char *)(arg1)->read(arg2); @@ -9,7 +9,7 @@ lua_pushnumber(L, (lua_Number) *arg2); SWIG_arg++; return SWIG_arg; -@@ -8304,7 +8304,7 @@ static int _wrap_new_Session__SWIG_0(lua_State* L) { +@@ -8336,7 +8336,7 @@ SWIG_check_num_args("LUA::Session::Session",0,0) result = (LUA::Session *)new LUA::Session(); @@ -18,7 +18,7 @@ return SWIG_arg; if(0) SWIG_fail; -@@ -8331,7 +8331,7 @@ static int _wrap_new_Session__SWIG_1(lua_State* L) { +@@ -8363,7 +8363,7 @@ } result = (LUA::Session *)new LUA::Session(arg1,arg2); @@ -27,7 +27,7 @@ return SWIG_arg; if(0) SWIG_fail; -@@ -8351,7 +8351,7 @@ static int _wrap_new_Session__SWIG_2(lua_State* L) { +@@ -8383,7 +8383,7 @@ if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("LUA::Session::Session",1,"char *"); arg1 = (char *)lua_tostring(L, 1); result = (LUA::Session *)new LUA::Session(arg1); @@ -36,7 +36,7 @@ return SWIG_arg; if(0) SWIG_fail; -@@ -8375,7 +8375,7 @@ static int _wrap_new_Session__SWIG_3(lua_State* L) { +@@ -8407,7 +8407,7 @@ } result = (LUA::Session *)new LUA::Session(arg1); @@ -45,7 +45,7 @@ return SWIG_arg; if(0) SWIG_fail; -@@ -9485,6 +9485,7 @@ static int _wrap_Dbh_test_reactive__SWIG_0(lua_State* L) { +@@ -9517,6 +9517,7 @@ arg2 = (char *)lua_tostring(L, 2); arg3 = (char *)lua_tostring(L, 3); arg4 = (char *)lua_tostring(L, 4); @@ -53,7 +53,7 @@ result = (bool)(arg1)->test_reactive(arg2,arg3,arg4); lua_pushboolean(L,(int)(result!=0)); SWIG_arg++; return SWIG_arg; -@@ -9516,6 +9516,7 @@ static int _wrap_Dbh_test_reactive__SWIG_1(lua_State* L) { +@@ -9547,6 +9548,7 @@ arg2 = (char *)lua_tostring(L, 2); arg3 = (char *)lua_tostring(L, 3); @@ -61,7 +61,7 @@ result = (bool)(arg1)->test_reactive(arg2,arg3); lua_pushboolean(L,(int)(result!=0)); SWIG_arg++; return SWIG_arg; -@@ -9543,6 +9544,7 @@ static int _wrap_Dbh_test_reactive__SWIG_2(lua_State* L) { +@@ -9574,6 +9576,7 @@ } arg2 = (char *)lua_tostring(L, 2); @@ -69,7 +69,7 @@ result = (bool)(arg1)->test_reactive(arg2); lua_pushboolean(L,(int)(result!=0)); SWIG_arg++; return SWIG_arg; -@@ -9672,6 +9673,7 @@ static int _wrap_Dbh_query(lua_State* L) { +@@ -9704,6 +9707,7 @@ (&arg3)->idx = 3; } } @@ -77,7 +77,15 @@ result = (bool)(arg1)->query(arg2,arg3); lua_pushboolean(L,(int)(result!=0)); SWIG_arg++; return SWIG_arg; -@@ -9695,7 +9697,7 @@ static int _wrap_Dbh_affected_rows(lua_State* L) { +@@ -9733,6 +9737,7 @@ + } + + arg3 = (char *)lua_tostring(L, 2); ++ switch_assert(arg1); + result = (arg1)->query_rows(arg2,arg3); + { + SWIG_arg += result; +@@ -9758,7 +9763,7 @@ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Dbh,0))){ SWIG_fail_ptr("Dbh_affected_rows",1,SWIGTYPE_p_LUA__Dbh); } @@ -86,7 +94,7 @@ result = (int)(arg1)->affected_rows(); lua_pushnumber(L, (lua_Number) result); SWIG_arg++; return SWIG_arg; -@@ -9719,7 +9721,7 @@ static int _wrap_Dbh_last_error(lua_State* L) { +@@ -9782,7 +9787,7 @@ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Dbh,0))){ SWIG_fail_ptr("Dbh_last_error",1,SWIGTYPE_p_LUA__Dbh); } @@ -95,7 +103,7 @@ result = (char *)(arg1)->last_error(); lua_pushstring(L,(const char *)result); SWIG_arg++; return SWIG_arg; -@@ -9742,7 +9744,7 @@ static int _wrap_Dbh_clear_error(lua_State* L) { +@@ -9805,7 +9810,7 @@ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Dbh,0))){ SWIG_fail_ptr("Dbh_clear_error",1,SWIGTYPE_p_LUA__Dbh); } @@ -104,7 +112,7 @@ (arg1)->clear_error(); return SWIG_arg; -@@ -9770,6 +9772,7 @@ static int _wrap_Dbh_load_extension(lua_State* L) { +@@ -9833,6 +9838,7 @@ } arg2 = (char *)lua_tostring(L, 2); @@ -112,7 +120,7 @@ result = (int)(arg1)->load_extension((char const *)arg2); lua_pushnumber(L, (lua_Number) result); SWIG_arg++; return SWIG_arg; -@@ -9869,6 +9872,7 @@ static int _wrap_JSON_decode(lua_State* L) { +@@ -9933,6 +9939,7 @@ } arg2 = (char *)lua_tostring(L, 2); @@ -120,7 +128,7 @@ result = (cJSON *)(arg1)->decode((char const *)arg2); { SWIG_arg += LUA::JSON::cJSON2LuaTable(L, result); -@@ -9902,6 +9906,7 @@ static int _wrap_JSON_encode(lua_State* L) { +@@ -9966,6 +9973,7 @@ (&arg2)->L = L; (&arg2)->idx = 2; } @@ -128,7 +136,7 @@ result = (arg1)->encode(arg2); lua_pushlstring(L,(&result)->data(),(&result)->size()); SWIG_arg++; return SWIG_arg; -@@ -9929,6 +9934,7 @@ static int _wrap_JSON_execute__SWIG_0(lua_State* L) { +@@ -9993,6 +10001,7 @@ } arg2 = (char *)lua_tostring(L, 2); @@ -136,7 +144,7 @@ result = (cJSON *)(arg1)->execute((char const *)arg2); { SWIG_arg += LUA::JSON::cJSON2LuaTable(L, result); -@@ -9962,6 +9968,7 @@ static int _wrap_JSON_execute__SWIG_1(lua_State* L) { +@@ -10026,6 +10035,7 @@ (&arg2)->L = L; (&arg2)->idx = 2; } @@ -144,7 +152,7 @@ result = (cJSON *)(arg1)->execute(arg2); { SWIG_arg += LUA::JSON::cJSON2LuaTable(L, result); -@@ -10046,6 +10053,7 @@ static int _wrap_JSON_execute2__SWIG_0(lua_State* L) { +@@ -10110,6 +10120,7 @@ } arg2 = (char *)lua_tostring(L, 2); @@ -152,7 +160,7 @@ result = (arg1)->execute2((char const *)arg2); lua_pushlstring(L,(&result)->data(),(&result)->size()); SWIG_arg++; return SWIG_arg; -@@ -10076,6 +10084,7 @@ static int _wrap_JSON_execute2__SWIG_1(lua_State* L) { +@@ -10140,6 +10151,7 @@ (&arg2)->L = L; (&arg2)->idx = 2; } @@ -160,7 +168,7 @@ result = (arg1)->execute2(arg2); lua_pushlstring(L,(&result)->data(),(&result)->size()); SWIG_arg++; return SWIG_arg; -@@ -10156,6 +10165,7 @@ static int _wrap_JSON_encode_empty_table_as_object(lua_State* L) { +@@ -10220,6 +10232,7 @@ } arg2 = (lua_toboolean(L, 2)!=0); @@ -168,7 +176,7 @@ (arg1)->encode_empty_table_as_object(arg2); return SWIG_arg; -@@ -10182,6 +10192,7 @@ static int _wrap_JSON_return_unformatted_json(lua_State* L) { +@@ -10246,6 +10259,7 @@ } arg2 = (lua_toboolean(L, 2)!=0); From 7d2befa5fa5f9ef18bfe40b7dc6f7a646f2a469e Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Wed, 15 Jan 2025 16:29:59 +0300 Subject: [PATCH 03/11] [mod_lua] reswig --- src/mod/languages/mod_lua/mod_lua_wrap.cpp | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/mod/languages/mod_lua/mod_lua_wrap.cpp b/src/mod/languages/mod_lua/mod_lua_wrap.cpp index 93ba825557..e40b50a348 100644 --- a/src/mod/languages/mod_lua/mod_lua_wrap.cpp +++ b/src/mod/languages/mod_lua/mod_lua_wrap.cpp @@ -9720,6 +9720,38 @@ fail: } +static int _wrap_Dbh_query_rows(lua_State* L) { + int SWIG_arg = 0; + LUA::Dbh *arg1 = (LUA::Dbh *) 0 ; + lua_State *arg2 = (lua_State *) 0 ; + char *arg3 = (char *) 0 ; + DbhQueryRowsReturn result; + + arg2 = L; + SWIG_check_num_args("LUA::Dbh::query_rows",2,2) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Dbh::query_rows",1,"LUA::Dbh *"); + if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("LUA::Dbh::query_rows",2,"char *"); + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Dbh,0))){ + SWIG_fail_ptr("Dbh_query_rows",1,SWIGTYPE_p_LUA__Dbh); + } + + arg3 = (char *)lua_tostring(L, 2); + switch_assert(arg1); + result = (arg1)->query_rows(arg2,arg3); + { + SWIG_arg += result; + } + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + static int _wrap_Dbh_affected_rows(lua_State* L) { int SWIG_arg = 0; LUA::Dbh *arg1 = (LUA::Dbh *) 0 ; @@ -9839,6 +9871,7 @@ static swig_lua_method swig_Dbh_methods[]= { { "connected", _wrap_Dbh_connected}, { "test_reactive", _wrap_Dbh_test_reactive}, { "query", _wrap_Dbh_query}, + { "query_rows", _wrap_Dbh_query_rows}, { "affected_rows", _wrap_Dbh_affected_rows}, { "last_error", _wrap_Dbh_last_error}, { "clear_error", _wrap_Dbh_clear_error}, From 083e6ae80f67e0c8545f07d91481f6c4c0c992e8 Mon Sep 17 00:00:00 2001 From: Aron Podrigal Date: Wed, 15 Jan 2025 14:03:07 -0600 Subject: [PATCH 04/11] [mod_curl] Fix off-by-one error in argument limit checks. refs: #2727 --- src/mod/applications/mod_curl/mod_curl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mod/applications/mod_curl/mod_curl.c b/src/mod/applications/mod_curl/mod_curl.c index 82b38d42a9..cae06bdb30 100644 --- a/src/mod/applications/mod_curl/mod_curl.c +++ b/src/mod/applications/mod_curl/mod_curl.c @@ -898,7 +898,7 @@ SWITCH_STANDARD_APP(curl_app_function) if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { if (argc == 0) { switch_goto_status(SWITCH_STATUS_SUCCESS, usage); - } else if (argc >= MOD_CURL_MAX_ARGS) { + } else if (argc > MOD_CURL_MAX_ARGS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Max args exceeded: %d\n", MOD_CURL_MAX_ARGS); switch_goto_status(SWITCH_STATUS_FALSE, done); } @@ -1021,7 +1021,7 @@ SWITCH_STANDARD_API(curl_function) if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { if (argc < 1) { switch_goto_status(SWITCH_STATUS_SUCCESS, usage); - } else if (argc >= MOD_CURL_MAX_ARGS) { + } else if (argc > MOD_CURL_MAX_ARGS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Max args exceeded: %d\n", MOD_CURL_MAX_ARGS); switch_goto_status(SWITCH_STATUS_FALSE, done); } From e600ab66a75eb5db3a0bb03fefe4b070b7bd8853 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Mon, 23 Dec 2024 21:29:05 +0300 Subject: [PATCH 05/11] [mod_theora] Remove from tree --- build/modules.conf.in | 1 - build/modules.conf.most | 1 - configure.ac | 1 - debian/bootstrap.sh | 2 - debian/control-modules | 4 - freeswitch.spec | 13 +--- src/mod/codecs/mod_theora/Makefile.am | 8 -- src/mod/codecs/mod_theora/mod_theora.c | 102 ------------------------- 8 files changed, 1 insertion(+), 131 deletions(-) delete mode 100644 src/mod/codecs/mod_theora/Makefile.am delete mode 100644 src/mod/codecs/mod_theora/mod_theora.c diff --git a/build/modules.conf.in b/build/modules.conf.in index d30c5f0177..4ce889c3ae 100755 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -61,7 +61,6 @@ codecs/mod_g729 codecs/mod_opus #codecs/mod_silk #codecs/mod_siren -#codecs/mod_theora #databases/mod_mariadb databases/mod_pgsql dialplans/mod_dialplan_asterisk diff --git a/build/modules.conf.most b/build/modules.conf.most index 40a61c8daa..b0c6cf5673 100755 --- a/build/modules.conf.most +++ b/build/modules.conf.most @@ -60,7 +60,6 @@ codecs/mod_ilbc codecs/mod_opus codecs/mod_silk codecs/mod_siren -codecs/mod_theora #databases/mod_mariadb databases/mod_pgsql dialplans/mod_dialplan_asterisk diff --git a/configure.ac b/configure.ac index 7474353205..579af2795e 100755 --- a/configure.ac +++ b/configure.ac @@ -2156,7 +2156,6 @@ AC_CONFIG_FILES([Makefile src/mod/codecs/mod_silk/Makefile src/mod/codecs/mod_siren/Makefile src/mod/codecs/mod_skel_codec/Makefile - src/mod/codecs/mod_theora/Makefile src/mod/databases/mod_mariadb/Makefile src/mod/databases/mod_pgsql/Makefile src/mod/dialplans/mod_dialplan_asterisk/Makefile diff --git a/debian/bootstrap.sh b/debian/bootstrap.sh index ce5adea315..2938661c50 100755 --- a/debian/bootstrap.sh +++ b/debian/bootstrap.sh @@ -688,7 +688,6 @@ Depends: \${misc:Depends}, freeswitch (= \${binary:Version}), freeswitch-mod-opus (= \${binary:Version}), freeswitch-mod-silk (= \${binary:Version}), freeswitch-mod-spandsp (= \${binary:Version}), - freeswitch-mod-theora (= \${binary:Version}), Suggests: freeswitch-mod-ilbc (= \${binary:Version}), freeswitch-mod-siren (= \${binary:Version}) @@ -711,7 +710,6 @@ Depends: \${misc:Depends}, freeswitch (= \${binary:Version}), freeswitch-mod-opus-dbg (= \${binary:Version}), freeswitch-mod-silk-dbg (= \${binary:Version}), freeswitch-mod-spandsp-dbg (= \${binary:Version}), - freeswitch-mod-theora-dbg (= \${binary:Version}), Suggests: freeswitch-mod-ilbc-dbg (= \${binary:Version}), freeswitch-mod-siren-dbg (= \${binary:Version}) diff --git a/debian/control-modules b/debian/control-modules index 101fab9e08..3a9aa9c5b6 100755 --- a/debian/control-modules +++ b/debian/control-modules @@ -308,10 +308,6 @@ Module: codecs/mod_skel_codec Description: Adds mod_skel_codec Adds mod_skel_codec. -Module: codecs/mod_theora -Description: mod_theora - Adds mod_theora. - Module: codecs/mod_yuv Description: Adds mod_yuv Adds mod_yuv. diff --git a/freeswitch.spec b/freeswitch.spec index 1d98356588..55d094f127 100755 --- a/freeswitch.spec +++ b/freeswitch.spec @@ -683,14 +683,6 @@ see http://www.polycom.com/usa/en/company/about_us/technology/siren_g7221/siren_ and http://www.polycom.com/usa/en/company/about_us/technology/siren14_g7221c/siren14_g7221c.html At the time of this packaging, Polycom does not charge for licensing. -%package codec-theora -Summary: Theora Video Codec support for FreeSWITCH open source telephony platform -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description codec-theora -Theora Video Codec support for FreeSWITCH open source telephony platform. - ###################################################################################################################### # FreeSWITCH Database Modules ###################################################################################################################### @@ -1242,7 +1234,7 @@ ASR_TTS_MODULES="asr_tts/mod_flite asr_tts/mod_pocketsphinx asr_tts/mod_tts_comm ###################################################################################################################### CODECS_MODULES="codecs/mod_amr codecs/mod_amrwb codecs/mod_bv codecs/mod_codec2 codecs/mod_g723_1 \ codecs/mod_g729 codecs/mod_ilbc codecs/mod_opus codecs/mod_silk \ - codecs/mod_siren codecs/mod_theora" + codecs/mod_siren" # ###################################################################################################################### @@ -1947,9 +1939,6 @@ fi %files codec-siren %{MODINSTDIR}/mod_siren.so* -%files codec-theora -%{MODINSTDIR}/mod_theora.so* - ###################################################################################################################### # # FreeSWITCH Database Modules diff --git a/src/mod/codecs/mod_theora/Makefile.am b/src/mod/codecs/mod_theora/Makefile.am deleted file mode 100644 index 1226a05a73..0000000000 --- a/src/mod/codecs/mod_theora/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -include $(top_srcdir)/build/modmake.rulesam -MODNAME=mod_theora - -mod_LTLIBRARIES = mod_theora.la -mod_theora_la_SOURCES = mod_theora.c -mod_theora_la_CFLAGS = $(AM_CFLAGS) -mod_theora_la_LIBADD = $(switch_builddir)/libfreeswitch.la -mod_theora_la_LDFLAGS = -avoid-version -module -no-undefined -shared diff --git a/src/mod/codecs/mod_theora/mod_theora.c b/src/mod/codecs/mod_theora/mod_theora.c deleted file mode 100644 index e1733d44fc..0000000000 --- a/src/mod/codecs/mod_theora/mod_theora.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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 - * - * - * mod_theora.c -- THEORA Video Codec - * - */ - -#include - -SWITCH_MODULE_LOAD_FUNCTION(mod_theora_load); -SWITCH_MODULE_DEFINITION(mod_theora, mod_theora_load, NULL, NULL); - -static switch_status_t switch_theora_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings) -{ - int encoding, decoding; - - encoding = (flags & SWITCH_CODEC_FLAG_ENCODE); - decoding = (flags & SWITCH_CODEC_FLAG_DECODE); - - if (!(encoding || decoding)) { - return SWITCH_STATUS_FALSE; - } else { - if (codec->fmtp_in) { - codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in); - } - return SWITCH_STATUS_SUCCESS; - } -} - -static switch_status_t switch_theora_encode(switch_codec_t *codec, - switch_codec_t *other_codec, - void *decoded_data, - uint32_t decoded_data_len, - uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, - unsigned int *flag) -{ - return SWITCH_STATUS_FALSE; -} - -static switch_status_t switch_theora_decode(switch_codec_t *codec, - switch_codec_t *other_codec, - void *encoded_data, - uint32_t encoded_data_len, - uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, - unsigned int *flag) -{ - return SWITCH_STATUS_FALSE; -} - -static switch_status_t switch_theora_destroy(switch_codec_t *codec) -{ - return SWITCH_STATUS_SUCCESS; -} - -SWITCH_MODULE_LOAD_FUNCTION(mod_theora_load) -{ - switch_codec_interface_t *codec_interface; - /* connect my internal structure to the blank pointer passed to me */ - *module_interface = switch_loadable_module_create_module_interface(pool, modname); - SWITCH_ADD_CODEC(codec_interface, "THEORA Video (passthru)"); - switch_core_codec_add_implementation(pool, codec_interface, - SWITCH_CODEC_TYPE_VIDEO, 99, "THEORA", NULL, 90000, 90000, 0, - 0, 0, 0, 0, 1, 1, switch_theora_init, switch_theora_encode, switch_theora_decode, switch_theora_destroy); - /* indicate that the module should continue to be loaded */ - return SWITCH_STATUS_SUCCESS; -} - -/* 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: - */ From 74c64339556362ab70e99976a90aca54e31b2c27 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Tue, 24 Dec 2024 14:46:13 +0300 Subject: [PATCH 06/11] [mod_yaml] Remove from tree --- Makefile.am | 4 - build/modules.conf.in | 1 - build/modules.conf.most | 1 - .../autoload_configs/modules.conf.xml | 2 - .../vanilla/autoload_configs/modules.conf.xml | 2 - conf/vanilla/yaml/extensions.yaml | 4 - conf/vanilla/yaml/mod_yaml.yaml | 6 - configure.ac | 4 - debian/bootstrap.sh | 2 - debian/control-modules | 5 - src/mod/languages/mod_yaml/Makefile.am | 18 - src/mod/languages/mod_yaml/mod_yaml.c | 529 ------------------ 12 files changed, 578 deletions(-) delete mode 100644 conf/vanilla/yaml/extensions.yaml delete mode 100644 conf/vanilla/yaml/mod_yaml.yaml delete mode 100644 src/mod/languages/mod_yaml/Makefile.am delete mode 100644 src/mod/languages/mod_yaml/mod_yaml.c diff --git a/Makefile.am b/Makefile.am index 09574caa6c..840d114c65 100644 --- a/Makefile.am +++ b/Makefile.am @@ -588,10 +588,6 @@ libs/srtp/libsrtp.la: libs/srtp libs/srtp/.update $(SRTP_SRC) ## ## helper targets ## -yaml-files: - @echo `mkdir $(DESTDIR)$(confdir)/yaml 2>/dev/null` - $(INSTALL) -m 644 $(switch_srcdir)/conf/default/yaml/*.yaml $(DESTDIR)$(confdir)/yaml - vm-sync: test -d $(DESTDIR)$(confdir) || $(mkinstalldirs) $(DESTDIR)$(confdir) test -d $(DESTDIR)$(confdir)/lang || $(mkinstalldirs) $(DESTDIR)$(confdir)/lang diff --git a/build/modules.conf.in b/build/modules.conf.in index 4ce889c3ae..07830a2615 100755 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -108,7 +108,6 @@ languages/mod_lua #languages/mod_python #languages/mod_python3 #languages/mod_v8 -#languages/mod_yaml loggers/mod_console #loggers/mod_graylog2 loggers/mod_logfile diff --git a/build/modules.conf.most b/build/modules.conf.most index b0c6cf5673..18278732a4 100755 --- a/build/modules.conf.most +++ b/build/modules.conf.most @@ -103,7 +103,6 @@ languages/mod_managed languages/mod_perl languages/mod_python3 #languages/mod_v8 -languages/mod_yaml loggers/mod_console loggers/mod_graylog2 loggers/mod_logfile diff --git a/conf/insideout/autoload_configs/modules.conf.xml b/conf/insideout/autoload_configs/modules.conf.xml index f03dfb749c..267ff4b602 100755 --- a/conf/insideout/autoload_configs/modules.conf.xml +++ b/conf/insideout/autoload_configs/modules.conf.xml @@ -6,8 +6,6 @@ - - diff --git a/conf/vanilla/autoload_configs/modules.conf.xml b/conf/vanilla/autoload_configs/modules.conf.xml index 6363e233cb..ad37dc9b15 100755 --- a/conf/vanilla/autoload_configs/modules.conf.xml +++ b/conf/vanilla/autoload_configs/modules.conf.xml @@ -6,8 +6,6 @@ - - diff --git a/conf/vanilla/yaml/extensions.yaml b/conf/vanilla/yaml/extensions.yaml deleted file mode 100644 index f74fcf2e3d..0000000000 --- a/conf/vanilla/yaml/extensions.yaml +++ /dev/null @@ -1,4 +0,0 @@ -default: - ${destination_number} =~ (9664): - set: foo=bar - playback: ${hold_music} diff --git a/conf/vanilla/yaml/mod_yaml.yaml b/conf/vanilla/yaml/mod_yaml.yaml deleted file mode 100644 index 65f1b05dda..0000000000 --- a/conf/vanilla/yaml/mod_yaml.yaml +++ /dev/null @@ -1,6 +0,0 @@ -settings: -#look for foo.conf.yaml when foo.conf is looked for in the xml - bind_config: true - - - diff --git a/configure.ac b/configure.ac index 579af2795e..0013e481eb 100755 --- a/configure.ac +++ b/configure.ac @@ -1330,9 +1330,6 @@ PKG_CHECK_MODULES([SQLITE], [sqlite3 >= 3.6.20]) PKG_CHECK_MODULES([CURL], [libcurl >= 7.19]) PKG_CHECK_MODULES([PCRE], [libpcre >= 7.8]) PKG_CHECK_MODULES([SPEEX], [speex >= 1.2rc1 speexdsp >= 1.2rc1]) -PKG_CHECK_MODULES([YAML], [yaml-0.1 >= 0.1.4],[ - AM_CONDITIONAL([HAVE_YAML],[true])],[ - AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_YAML],[false])]) PKG_CHECK_MODULES([LDNS], [libldns-fs >= 1.6.6],[ AM_CONDITIONAL([HAVE_LDNS],[true])],[ PKG_CHECK_MODULES([LDNS], [libldns >= 1.6.6],[ @@ -2204,7 +2201,6 @@ AC_CONFIG_FILES([Makefile src/mod/languages/mod_python/Makefile src/mod/languages/mod_python3/Makefile src/mod/languages/mod_v8/Makefile - src/mod/languages/mod_yaml/Makefile src/mod/languages/mod_basic/Makefile src/mod/loggers/mod_console/Makefile src/mod/loggers/mod_graylog2/Makefile diff --git a/debian/bootstrap.sh b/debian/bootstrap.sh index 2938661c50..3700891c20 100755 --- a/debian/bootstrap.sh +++ b/debian/bootstrap.sh @@ -655,7 +655,6 @@ Depends: \${misc:Depends}, freeswitch (= \${binary:Version}), freeswitch-mod-lua (= \${binary:Version}), freeswitch-mod-perl (= \${binary:Version}), freeswitch-mod-python3 (= \${binary:Version}), - freeswitch-mod-yaml (= \${binary:Version}), freeswitch-mod-console (= \${binary:Version}), freeswitch-mod-logfile (= \${binary:Version}), freeswitch-mod-syslog (= \${binary:Version}), @@ -873,7 +872,6 @@ Depends: \${misc:Depends}, freeswitch (= \${binary:Version}), freeswitch-mod-lua-dbg (= \${binary:Version}), freeswitch-mod-perl-dbg (= \${binary:Version}), freeswitch-mod-python3-dbg (= \${binary:Version}), - freeswitch-mod-yaml-dbg (= \${binary:Version}), freeswitch-mod-console-dbg (= \${binary:Version}), freeswitch-mod-logfile-dbg (= \${binary:Version}), freeswitch-mod-syslog-dbg (= \${binary:Version}), diff --git a/debian/control-modules b/debian/control-modules index 3a9aa9c5b6..9229654cb7 100755 --- a/debian/control-modules +++ b/debian/control-modules @@ -558,11 +558,6 @@ Description: mod_v8 Adds mod_v8. Build-Depends: git, libv8-6.1-dev -Module: languages/mod_yaml -Description: mod_yaml - Adds mod_yaml. -Build-Depends: libyaml-dev, libglib2.0-dev - ## mod/loggers Module: loggers/mod_console diff --git a/src/mod/languages/mod_yaml/Makefile.am b/src/mod/languages/mod_yaml/Makefile.am deleted file mode 100644 index 9d02a0fbc1..0000000000 --- a/src/mod/languages/mod_yaml/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -include $(top_srcdir)/build/modmake.rulesam -MODNAME=mod_yaml - -if HAVE_YAML - -mod_LTLIBRARIES = mod_yaml.la -mod_yaml_la_SOURCES = mod_yaml.c -mod_yaml_la_CFLAGS = $(AM_CFLAGS) -mod_yaml_la_CPPFLAGS = $(AM_CPPFLAGS) $(YAML_CFLAGS) -mod_yaml_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(YAML_LIBS) -mod_yaml_la_LDFLAGS = -avoid-version -module -no-undefined -shared - -else -install: error -all: error -error: - $(error You must install libyaml-dev to build mod_yaml) -endif diff --git a/src/mod/languages/mod_yaml/mod_yaml.c b/src/mod/languages/mod_yaml/mod_yaml.c deleted file mode 100644 index 4c824e7137..0000000000 --- a/src/mod/languages/mod_yaml/mod_yaml.c +++ /dev/null @@ -1,529 +0,0 @@ -/* - * 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 - - * - * mod_yaml.c -- YAML Module - * - */ -#include -#include - -SWITCH_MODULE_LOAD_FUNCTION(mod_yaml_load); -SWITCH_MODULE_DEFINITION(mod_yaml, mod_yaml_load, NULL, NULL); - -static void print_error(yaml_parser_t *parser) -{ - switch (parser->error) { - case YAML_MEMORY_ERROR: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory error: Not enough memory for parsing\n"); - break; - - case YAML_READER_ERROR: - if (parser->problem_value != -1) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Reader error: %s: #%X at %d\n", parser->problem, - parser->problem_value, (int) parser->problem_offset); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Reader error: %s at %d\n", parser->problem, (int) parser->problem_offset); - } - break; - - case YAML_SCANNER_ERROR: - if (parser->context) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Scanner error: %s at line %d, column %d\n" - "%s at line %d, column %d\n", parser->context, - (int) parser->context_mark.line + 1, (int) parser->context_mark.column + 1, - parser->problem, (int) parser->problem_mark.line + 1, (int) parser->problem_mark.column + 1); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Scanner error: %s at line %d, column %d\n", - parser->problem, (int) parser->problem_mark.line + 1, (int) parser->problem_mark.column + 1); - } - break; - - case YAML_PARSER_ERROR: - if (parser->context) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parser error: %s at line %d, column %d\n" - "%s at line %d, column %d\n", parser->context, - (int) parser->context_mark.line + 1, (int) parser->context_mark.column + 1, - parser->problem, (int) parser->problem_mark.line + 1, (int) parser->problem_mark.column + 1); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parser error: %s at line %d, column %d\n", - parser->problem, (int) parser->problem_mark.line + 1, (int) parser->problem_mark.column + 1); - } - break; - - default: - /* Couldn't happen. */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Internal error\n"); - break; - } -} - - -static switch_xml_t parse_file(FILE * input, const char *file_name) -{ - yaml_parser_t parser; - yaml_event_t event = { 0 }; - char *scalar_data; - int done = 0; - int depth = 0; - char name[128] = ""; - char value[128] = ""; - char category[128] = ""; - int nv = 0, p_off = 0; - switch_xml_t xml, param, top, current = NULL; - - yaml_parser_initialize(&parser); - yaml_parser_set_input_file(&parser, input); - - - if (!(xml = switch_xml_new("document"))) { - return NULL; - } - - switch_xml_set_attr_d(xml, "type", "freeswitch/xml"); - current = switch_xml_add_child_d(xml, "section", 0); - switch_xml_set_attr_d(current, "name", "configuration"); - - top = switch_xml_add_child_d(current, "configuration", 0); - switch_xml_set_attr_d(top, "name", file_name); - - while (!done) { - if (!yaml_parser_parse(&parser, &event)) { - print_error(&parser); - break; - } else { - switch (event.type) { - case YAML_MAPPING_START_EVENT: - depth++; - break; - case YAML_MAPPING_END_EVENT: - depth--; - break; - case YAML_STREAM_END_EVENT: - done = 1; - break; - case YAML_SCALAR_EVENT: - scalar_data = (char *) event.data.scalar.value; - switch (depth) { - case 1: - if (!(current = switch_xml_add_child_d(top, scalar_data, depth - 1))) { - done = 1; - } - switch_set_string(category, scalar_data); - nv = 0; - p_off = 0; - break; - case 2: - if (current) { - if (nv == 0) { - switch_set_string(name, scalar_data); - nv++; - } else { - switch_set_string(value, scalar_data); - param = switch_xml_add_child_d(current, "param", p_off++); - switch_xml_set_attr_d_buf(param, "name", name); - switch_xml_set_attr_d(param, "value", scalar_data); - nv = 0; - } - } - break; - } - - break; - default: - break; - } - } - - yaml_event_delete(&event); - } - - yaml_parser_delete(&parser); - - if (input) { - fclose(input); - } -#ifdef DEBUG_XML - if (xml) { - char *foo = switch_xml_toxml(xml, SWITCH_FALSE); - printf("%s\n", foo); - free(foo); - } -#endif - - return xml; - -} - -static switch_xml_t yaml_fetch(const char *section, - const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params, void *user_data) -{ - char *path; - FILE *input; - switch_xml_t xml = NULL; - - path = switch_mprintf("%s/yaml/%s.yaml", SWITCH_GLOBAL_dirs.conf_dir, key_value); - if ((input = fopen(path, "r"))) { - xml = parse_file(input, key_value); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "cannot open %s\n", path); - } - - switch_safe_free(path); - return xml; -} - - -static switch_caller_extension_t *parse_dp(FILE * input, switch_core_session_t *session, switch_caller_profile_t *caller_profile) -{ - yaml_parser_t parser; - yaml_event_t event = { 0 }; - char *scalar_data; - int done = 0; - int depth = 0; - char name[128] = ""; - char value[128] = ""; - char category[128] = ""; - char *last_field = NULL; - int nv = 0; - switch_caller_extension_t *extension = NULL; - switch_channel_t *channel = switch_core_session_get_channel(session); - int context_hit = 0; - int proceed = 0; - switch_regex_t *re = NULL; - int ovector[30]; - int parens = 0; - - if (!caller_profile) { - if (!(caller_profile = switch_channel_get_caller_profile(channel))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Obtaining Profile!\n"); - return NULL; - } - } - - if (!caller_profile->context) { - caller_profile->context = "default"; - } - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Processing %s->%s@%s\n", - caller_profile->caller_id_name, caller_profile->destination_number, caller_profile->context); - - yaml_parser_initialize(&parser); - yaml_parser_set_input_file(&parser, input); - - while (!done) { - if (!yaml_parser_parse(&parser, &event)) { - print_error(&parser); - break; - } else { - switch (event.type) { - case YAML_MAPPING_START_EVENT: - depth++; - break; - case YAML_MAPPING_END_EVENT: - depth--; - break; - case YAML_STREAM_END_EVENT: - done = 1; - break; - case YAML_SCALAR_EVENT: - scalar_data = (char *) event.data.scalar.value; - switch (depth) { - case 1: - switch_set_string(category, scalar_data); - context_hit = (!strcasecmp(category, caller_profile->context)); - nv = 0; - break; - case 2: - if (context_hit) { - char *field = switch_core_session_strdup(session, scalar_data); - char *p, *e, *expression = NULL, *field_expanded = NULL, *expression_expanded = NULL; - const char *field_data = NULL; - - parens = 0; - proceed = 0; - switch_regex_safe_free(re); - - if ((p = strstr(field, "=~"))) { - *p = '\0'; - e = p - 1; - while (*e == ' ') { - *e-- = '\0'; - } - e = p + 2; - while (*e == ' ') { - *e++ = '\0'; - } - expression = e; - } - - if (field && expression) { - if ((expression_expanded = switch_channel_expand_variables(channel, expression)) == expression) { - expression_expanded = NULL; - } else { - expression = expression_expanded; - } - - if (strchr(field, '$')) { - if ((field_expanded = switch_channel_expand_variables(channel, field)) == field) { - field_expanded = NULL; - field_data = field; - } else { - field_data = field_expanded; - } - } else { - field_data = switch_caller_get_field_by_name(caller_profile, field); - } - if (!field_data) { - field_data = ""; - } - switch_safe_free(last_field); - last_field = strdup(field_data); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "test conditions %s(%s) =~ /%s/\n", field, field_data, expression); - if (!(proceed = switch_regex_perform(field_data, expression, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Regex mismatch\n"); - } - - if (strchr(expression, '(')) { - parens++; - } - - switch_safe_free(field_expanded); - switch_safe_free(expression_expanded); - } - } - break; - case 3: - if (nv == 0) { - if (!strcasecmp(scalar_data, "exit")) { - yaml_event_delete(&event); - goto end; - } - switch_set_string(name, scalar_data); - nv++; - } else { - switch_set_string(value, scalar_data); - nv = 0; - if (proceed) { - uint32_t len = 0; - char *substituted = NULL; - char *app_data; - - - if (!extension) { - extension = switch_caller_extension_new(session, "YAML", caller_profile->destination_number); - switch_assert(extension); - } - - if (parens) { - len = (uint32_t) (strlen(value) + strlen(last_field) + 10) * proceed; - switch_zmalloc(substituted, len); - switch_perform_substitution(re, proceed, value, last_field, substituted, len, ovector); - app_data = substituted; - } else { - app_data = value; - } - - switch_caller_extension_add_application(session, extension, name, app_data); - switch_safe_free(substituted); - } - } - break; - } - - break; - default: - break; - } - } - - yaml_event_delete(&event); - } - - end: - - switch_safe_free(last_field); - switch_regex_safe_free(re); - yaml_parser_delete(&parser); - - if (input) { - fclose(input); - } -#ifdef DEBUG_XML - if (xml) { - char *foo = switch_xml_toxml(xml, SWITCH_FALSE); - printf("%s\n", foo); - free(foo); - } -#endif - - return extension; - -} - -SWITCH_STANDARD_DIALPLAN(yaml_dialplan_hunt) -{ - switch_caller_extension_t *extension = NULL; - char *alt_path = (char *) arg; - char *path = NULL; - FILE *input; - - if (!zstr(alt_path)) { - path = strdup(alt_path); - } else { - path = switch_mprintf("%s/yaml/extensions.yaml", SWITCH_GLOBAL_dirs.conf_dir); - } - - if ((input = fopen(path, "r"))) { - extension = parse_dp(input, session, caller_profile); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s\n", path); - } - - switch_safe_free(path); - return extension; -} - - -static switch_status_t do_config(void) -{ - yaml_parser_t parser; - yaml_event_t event = { 0 }; - char *path; - const char *cfg = "mod_yaml.yaml"; - FILE *input; - switch_status_t status = SWITCH_STATUS_FALSE; - char *scalar_data; - int done = 0; - int depth = 0; - char name[128] = ""; - char value[128] = ""; - char category[128] = ""; - int nv = 0; - - path = switch_mprintf("%s/yaml/%s", SWITCH_GLOBAL_dirs.conf_dir, cfg); - - if (!(input = fopen(path, "r"))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s\n", path); - goto end; - } - - yaml_parser_initialize(&parser); - yaml_parser_set_input_file(&parser, input); - - while (!done) { - if (!yaml_parser_parse(&parser, &event)) { - print_error(&parser); - break; - } else { - switch (event.type) { - case YAML_MAPPING_START_EVENT: - depth++; - break; - case YAML_MAPPING_END_EVENT: - depth--; - break; - case YAML_STREAM_END_EVENT: - done = 1; - break; - case YAML_SCALAR_EVENT: - scalar_data = (char *) event.data.scalar.value; - switch (depth) { - case 1: - switch_set_string(category, scalar_data); - nv = 0; - break; - case 2: - if (nv == 0) { - switch_set_string(name, scalar_data); - nv++; - } else { - switch_set_string(value, scalar_data); - if (!strcasecmp(category, "settings")) { - if (!strcasecmp(name, "bind_config") && switch_true_buf(value)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Binding To XML Config\n"); - switch_xml_bind_search_function(yaml_fetch, switch_xml_parse_section_string("config"), NULL); - } - } - nv = 0; - } - break; - } - - break; - default: - break; - } - } - - yaml_event_delete(&event); - } - - yaml_parser_delete(&parser); - status = SWITCH_STATUS_SUCCESS; - - end: - - if (input) { - fclose(input); - } - - switch_safe_free(path); - - return status; - -} - -SWITCH_MODULE_LOAD_FUNCTION(mod_yaml_load) -{ - switch_dialplan_interface_t *dp_interface; - - /* connect my internal structure to the blank pointer passed to me */ - *module_interface = switch_loadable_module_create_module_interface(pool, modname); - - if (do_config() != SWITCH_STATUS_SUCCESS) { - return SWITCH_STATUS_TERM; - } - - SWITCH_ADD_DIALPLAN(dp_interface, "YAML", yaml_dialplan_hunt); - - /* indicate that the module should continue to be loaded */ - return SWITCH_STATUS_SUCCESS; -} - - -/* 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: - */ From b3cdc8a7837bfe338e81541a3cffcd41d4d50534 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Wed, 25 Dec 2024 01:37:23 +0300 Subject: [PATCH 07/11] [mod_oreka] Remove from tree --- build/modules.conf.in | 1 - build/modules.conf.most | 1 - conf/vanilla/autoload_configs/oreka.conf.xml | 13 - configure.ac | 1 - debian/bootstrap.sh | 3 - debian/control-modules | 5 - freeswitch.spec | 1 - src/mod/applications/mod_oreka/Makefile.am | 8 - src/mod/applications/mod_oreka/mod_oreka.c | 786 ------------------- 9 files changed, 819 deletions(-) delete mode 100644 conf/vanilla/autoload_configs/oreka.conf.xml delete mode 100644 src/mod/applications/mod_oreka/Makefile.am delete mode 100644 src/mod/applications/mod_oreka/mod_oreka.c diff --git a/build/modules.conf.in b/build/modules.conf.in index 07830a2615..f555509c0d 100755 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -29,7 +29,6 @@ applications/mod_httapi #applications/mod_memcache #applications/mod_mongo #applications/mod_nibblebill -#applications/mod_oreka #applications/mod_osp #applications/mod_prefix #applications/mod_redis diff --git a/build/modules.conf.most b/build/modules.conf.most index 18278732a4..f968a7bdd4 100755 --- a/build/modules.conf.most +++ b/build/modules.conf.most @@ -29,7 +29,6 @@ applications/mod_lcr applications/mod_memcache applications/mod_mongo applications/mod_nibblebill -applications/mod_oreka #applications/mod_osp applications/mod_prefix applications/mod_redis diff --git a/conf/vanilla/autoload_configs/oreka.conf.xml b/conf/vanilla/autoload_configs/oreka.conf.xml deleted file mode 100644 index 29eabd5c29..0000000000 --- a/conf/vanilla/autoload_configs/oreka.conf.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - diff --git a/configure.ac b/configure.ac index 0013e481eb..20d1ad3aa7 100755 --- a/configure.ac +++ b/configure.ac @@ -2118,7 +2118,6 @@ AC_CONFIG_FILES([Makefile src/mod/applications/mod_memcache/Makefile src/mod/applications/mod_mongo/Makefile src/mod/applications/mod_nibblebill/Makefile - src/mod/applications/mod_oreka/Makefile src/mod/applications/mod_osp/Makefile src/mod/applications/mod_prefix/Makefile src/mod/applications/mod_random/Makefile diff --git a/debian/bootstrap.sh b/debian/bootstrap.sh index 3700891c20..2b1487a6c8 100755 --- a/debian/bootstrap.sh +++ b/debian/bootstrap.sh @@ -529,7 +529,6 @@ Recommends: freeswitch-mod-http-cache (= \${binary:Version}), freeswitch-mod-lcr (= \${binary:Version}), freeswitch-mod-nibblebill (= \${binary:Version}), - freeswitch-mod-oreka (= \${binary:Version}), freeswitch-mod-pgsql (= \${binary:Version}), freeswitch-mod-redis (= \${binary:Version}), freeswitch-mod-sms (= \${binary:Version}), @@ -610,7 +609,6 @@ Depends: \${misc:Depends}, freeswitch (= \${binary:Version}), freeswitch-mod-lcr (= \${binary:Version}), freeswitch-mod-memcache (= \${binary:Version}), freeswitch-mod-nibblebill (= \${binary:Version}), - freeswitch-mod-oreka (= \${binary:Version}), freeswitch-mod-mariadb (= \${binary:Version}), freeswitch-mod-pgsql (= \${binary:Version}), freeswitch-mod-png (= \${binary:Version}), @@ -829,7 +827,6 @@ Depends: \${misc:Depends}, freeswitch (= \${binary:Version}), freeswitch-mod-lcr-dbg (= \${binary:Version}), freeswitch-mod-memcache-dbg (= \${binary:Version}), freeswitch-mod-nibblebill-dbg (= \${binary:Version}), - freeswitch-mod-oreka-dbg (= \${binary:Version}), freeswitch-mod-mariadb-dbg (= \${binary:Version}), freeswitch-mod-pgsql-dbg (= \${binary:Version}), freeswitch-mod-png-dbg (= \${binary:Version}), diff --git a/debian/control-modules b/debian/control-modules index 9229654cb7..74f36d4ff2 100755 --- a/debian/control-modules +++ b/debian/control-modules @@ -149,11 +149,6 @@ Description: Nibblebill This module allows for real-time accounting of a cash balance and using that information for call routing. -Module: applications/mod_oreka -Description: Media recording with Oreka - This module provides media recording with the Oreka cross-platfor - audio stream recording and retrieval system. - Module: applications/mod_osp Description: Open Settlement Protocol This module adds support for the Open Settlement Protocol (OSP). diff --git a/freeswitch.spec b/freeswitch.spec index 55d094f127..540b33b05f 100755 --- a/freeswitch.spec +++ b/freeswitch.spec @@ -1701,7 +1701,6 @@ fi %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/msrp.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/nibblebill.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/opal.conf.xml -%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/oreka.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/osp.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/pocketsphinx.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/post_load_modules.conf.xml diff --git a/src/mod/applications/mod_oreka/Makefile.am b/src/mod/applications/mod_oreka/Makefile.am deleted file mode 100644 index 446f5183d6..0000000000 --- a/src/mod/applications/mod_oreka/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -include $(top_srcdir)/build/modmake.rulesam -MODNAME=mod_oreka - -mod_LTLIBRARIES = mod_oreka.la -mod_oreka_la_SOURCES = mod_oreka.c -mod_oreka_la_CFLAGS = $(AM_CFLAGS) -mod_oreka_la_LIBADD = $(switch_builddir)/libfreeswitch.la -mod_oreka_la_LDFLAGS = -avoid-version -module -no-undefined -shared diff --git a/src/mod/applications/mod_oreka/mod_oreka.c b/src/mod/applications/mod_oreka/mod_oreka.c deleted file mode 100644 index 560c34f6c6..0000000000 --- a/src/mod/applications/mod_oreka/mod_oreka.c +++ /dev/null @@ -1,786 +0,0 @@ -/* - * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2011, 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 / Oreka Recording Module - * - * The Initial Developer of the Original Code is - * Moises Silva - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Moises Silva - * - * mod_oreka -- Module for Media Recording with Oreka - * - */ - -#include -#include - -static const char SIP_OREKA_HEADER_PREFIX[] = "oreka_sip_h_"; -#define OREKA_PRIVATE "_oreka_" -#define OREKA_BUG_NAME_READ "oreka_read" -#define OREKA_BUG_NAME_WRITE "oreka_write" -#define SIP_OREKA_HEADER_PREFIX_LEN (sizeof(SIP_OREKA_HEADER_PREFIX)-1) - -SWITCH_MODULE_LOAD_FUNCTION(mod_oreka_load); -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_oreka_shutdown); -SWITCH_MODULE_DEFINITION(mod_oreka, mod_oreka_load, mod_oreka_shutdown, NULL); - -typedef struct oreka_session_s { - switch_core_session_t *session; - switch_port_t read_rtp_port; - switch_port_t write_rtp_port; - switch_rtp_t *read_rtp_stream; - switch_rtp_t *write_rtp_stream; - switch_codec_implementation_t read_impl; - switch_codec_implementation_t write_impl; - uint32_t read_cnt; - uint32_t write_cnt; - switch_media_bug_t *read_bug; - switch_event_t *invite_extra_headers; - switch_event_t *bye_extra_headers; - int usecnt; - switch_audio_resampler_t *read_resampler; - switch_audio_resampler_t *write_resampler; - int mux_streams; -} oreka_session_t; - -static struct { - char local_ipv4_str[256]; - char sip_server_addr_str[256]; - char sip_server_ipv4_str[256]; - int sip_server_port; - switch_sockaddr_t *sip_server_addr; - switch_socket_t *sip_socket; - pid_t our_pid; - int mux_streams; -} globals; - -typedef enum { - FS_OREKA_START, - FS_OREKA_STOP -} oreka_recording_status_t; - -typedef enum { - FS_OREKA_READ, - FS_OREKA_WRITE -} oreka_stream_type_t; - -static int oreka_write_udp(oreka_session_t *oreka, switch_stream_handle_t *udp) -{ - switch_size_t udplen = udp->data_len; - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oreka->session), SWITCH_LOG_DEBUG, "Oreka SIP Packet:\n%s", (const char *)udp->data); - switch_socket_sendto(globals.sip_socket, globals.sip_server_addr, 0, (void *)udp->data, &udplen); - if (udplen != udp->data_len) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oreka->session), SWITCH_LOG_ERROR, "Failed to write SIP Packet of len %zd (wrote=%zd)", - udp->data_len, udplen); - } - return 0; -} - -static int oreka_tear_down_rtp(oreka_session_t *oreka, oreka_stream_type_t type) -{ - if (type == FS_OREKA_READ && oreka->read_rtp_stream) { - switch_rtp_release_port(globals.local_ipv4_str, oreka->read_rtp_port); - switch_rtp_destroy(&oreka->read_rtp_stream); - oreka->read_rtp_port = 0; - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oreka->session), SWITCH_LOG_DEBUG, "Destroyed read rtp\n"); - } else if (oreka->write_rtp_stream) { - switch_rtp_release_port(globals.local_ipv4_str, oreka->write_rtp_port); - switch_rtp_destroy(&oreka->write_rtp_stream); - oreka->write_rtp_port = 0; - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oreka->session), SWITCH_LOG_DEBUG, "Destroyed write rtp\n"); - } - return 0; -} - -static int oreka_setup_rtp(oreka_session_t *oreka, oreka_stream_type_t type) -{ - switch_port_t rtp_port = 0; - switch_rtp_flag_t flags[SWITCH_RTP_FLAG_INVALID] = {0}; - switch_rtp_t *rtp_stream = NULL; - switch_codec_implementation_t *codec_impl = NULL; - switch_status_t status = SWITCH_STATUS_SUCCESS; - int res = 0; - const char *err = "unknown error"; - const char *type_str = type == FS_OREKA_READ ? "read" : "write"; - - - if (type == FS_OREKA_READ) { - status = switch_core_session_get_read_impl(oreka->session, &oreka->read_impl); - codec_impl = &oreka->read_impl; - } else { - status = switch_core_session_get_write_impl(oreka->session, &oreka->write_impl); - codec_impl = &oreka->write_impl; - } - - if (status != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No %s codec implementation available!\n", type_str); - res = -1; - goto done; - } - - if (!(rtp_port = switch_rtp_request_port(globals.local_ipv4_str))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to allocate %s RTP port for IP %s\n", type_str, globals.local_ipv4_str); - res = -1; - goto done; - } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Allocated %s port %d for local IP %s, destination IP %s\n", type_str, - rtp_port, globals.local_ipv4_str, globals.sip_server_ipv4_str); - rtp_stream = switch_rtp_new(globals.local_ipv4_str, rtp_port, - globals.sip_server_ipv4_str, rtp_port, - 0, /* PCMU IANA*/ - codec_impl->samples_per_packet, - codec_impl->microseconds_per_packet, - flags, NULL, &err, switch_core_session_get_pool(oreka->session), 0, 0); - if (!rtp_stream) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create %s RTP stream at %s:%d: %s\n", - type_str, globals.local_ipv4_str, rtp_port, err); - res = -1; - goto done; - } - - switch_rtp_intentional_bugs(rtp_stream, RTP_BUG_SEND_LINEAR_TIMESTAMPS); - - -done: - if (res == -1) { - if (rtp_port) { - switch_rtp_release_port(globals.local_ipv4_str, rtp_port); - } - if (rtp_stream) { - switch_rtp_destroy(&rtp_stream); - } - } else { - if (type == FS_OREKA_READ) { - oreka->read_rtp_stream = rtp_stream; - oreka->read_rtp_port = rtp_port; - } else { - oreka->write_rtp_stream = rtp_stream; - oreka->write_rtp_port = rtp_port; - } - } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Successfully created %s RTP stream at %s:%d at %dms@%dHz\n", - type_str, globals.local_ipv4_str, rtp_port, codec_impl->microseconds_per_packet/1000, codec_impl->samples_per_second); - return res; -} - -static void save_extra_headers(switch_event_t *extra_headers, switch_channel_t *channel) -{ - switch_event_header_t *ei = NULL; - for (ei = switch_channel_variable_first(channel); - ei; - ei = ei->next) { - const char *name = ei->name; - char *value = ei->value; - if (!strncasecmp(name, SIP_OREKA_HEADER_PREFIX, SIP_OREKA_HEADER_PREFIX_LEN)) { - switch_event_add_header_string(extra_headers, SWITCH_STACK_BOTTOM, name, value); - } - } - switch_channel_variable_last(channel); - - /* Remove the custom header variables that were saved */ - for (ei = extra_headers->headers; - ei; - ei = ei->next) { - char *varname = ei->name; - switch_channel_set_variable(channel, varname, NULL); - } -} - -static switch_event_t *get_extra_headers(oreka_session_t *oreka, oreka_recording_status_t status) -{ - switch_event_t *extra_headers = NULL; - switch_channel_t *channel = NULL; - switch_core_session_t *session = oreka->session; - - channel = switch_core_session_get_channel(session); - if (status == FS_OREKA_START) { - if (!oreka->invite_extra_headers) { - switch_event_create_subclass(&oreka->invite_extra_headers, SWITCH_EVENT_CLONE, NULL); - switch_assert(oreka->invite_extra_headers); - save_extra_headers(oreka->invite_extra_headers, channel); - } - extra_headers = oreka->invite_extra_headers; - } else if (status == FS_OREKA_STOP) { - if (!oreka->bye_extra_headers) { - switch_event_create_subclass(&oreka->bye_extra_headers, SWITCH_EVENT_CLONE, NULL); - switch_assert(oreka->bye_extra_headers); - save_extra_headers(oreka->bye_extra_headers, channel); - } - extra_headers = oreka->bye_extra_headers; - } - return extra_headers; -} - -static void oreka_destroy(oreka_session_t *oreka) -{ - oreka->usecnt--; - if (!oreka->usecnt) { - if (oreka->invite_extra_headers) { - switch_event_destroy(&oreka->invite_extra_headers); - } - if (oreka->bye_extra_headers) { - switch_event_destroy(&oreka->bye_extra_headers); - } - /* Actual memory for the oreka session was taken from the switch core session pool, the core will take care of it */ - } -} - -static int oreka_send_sip_message(oreka_session_t *oreka, oreka_recording_status_t status, oreka_stream_type_t type) -{ - switch_stream_handle_t sip_header = { 0 }; - switch_stream_handle_t sdp = { 0 }; - switch_stream_handle_t udp_packet = { 0 }; - switch_caller_profile_t *caller_profile = NULL; - switch_channel_t *channel = NULL; - switch_event_t *extra_headers = NULL; - switch_event_header_t *ei = NULL; - switch_core_session_t *session = oreka->session; - const char *method = status == FS_OREKA_START ? "INVITE" : "BYE"; - const char *session_uuid = switch_core_session_get_uuid(oreka->session); - const char *caller_id_number = NULL; - const char *caller_id_name = NULL; - const char *callee_id_number = NULL; - const char *callee_id_name = NULL; - int rc = 0; - - channel = switch_core_session_get_channel(session); - - SWITCH_STANDARD_STREAM(sip_header); - SWITCH_STANDARD_STREAM(sdp); - SWITCH_STANDARD_STREAM(udp_packet); - - extra_headers = get_extra_headers(oreka, status); - - caller_profile = switch_channel_get_caller_profile(channel); - - /* Get caller meta data */ - caller_id_number = switch_caller_get_field_by_name(caller_profile, "caller_id_number"); - - caller_id_name = switch_caller_get_field_by_name(caller_profile, "caller_id_name"); - if (zstr(caller_id_name)) { - caller_id_name = caller_id_number; - } - - callee_id_number = switch_caller_get_field_by_name(caller_profile, "callee_id_number"); - if (zstr(callee_id_number)) { - callee_id_number = switch_caller_get_field_by_name(caller_profile, "destination_number"); - } - - callee_id_name = switch_caller_get_field_by_name(caller_profile, "callee_id_name"); - if (zstr(callee_id_name)) { - callee_id_name = callee_id_number; - } - - /* Setup the RTP */ - if (status == FS_OREKA_START) { - if (oreka_setup_rtp(oreka, type)) { - rc = -1; - goto done; - } - } - - if (status == FS_OREKA_STOP) { - oreka_tear_down_rtp(oreka, type); - } - - /* Fill in the SDP first if this is the beginning */ - if (status == FS_OREKA_START) { - sdp.write_function(&sdp, "v=0\r\n"); - sdp.write_function(&sdp, "o=freeswitch %s 1 IN IP4 %s\r\n", session_uuid, globals.local_ipv4_str); - sdp.write_function(&sdp, "c=IN IP4 %s\r\n", globals.sip_server_ipv4_str); - sdp.write_function(&sdp, "s=Phone Recording (%s)\r\n", type == FS_OREKA_READ ? "RX" : "TX"); - sdp.write_function(&sdp, "i=FreeSWITCH Oreka Recorder (pid=%d)\r\n", globals.our_pid); - sdp.write_function(&sdp, "m=audio %d RTP/AVP 0\r\n", type == FS_OREKA_READ ? oreka->read_rtp_port : oreka->write_rtp_port); - sdp.write_function(&sdp, "a=rtpmap:0 PCMU/%d\r\n", type == FS_OREKA_READ - ? oreka->read_impl.samples_per_second : oreka->write_impl.samples_per_second); - } - - /* Request line */ - sip_header.write_function(&sip_header, "%s sip:%s@%s:5060 SIP/2.0\r\n", method, callee_id_name, globals.local_ipv4_str); - - /* Via */ - sip_header.write_function(&sip_header, "Via: SIP/2.0/UDP %s:5061;branch=z9hG4bK-%s\r\n", globals.local_ipv4_str, session_uuid); - - /* From */ - sip_header.write_function(&sip_header, "From: \r\n", caller_id_number, globals.local_ipv4_str); - - /* To */ - sip_header.write_function(&sip_header, "To: \r\n", callee_id_number, globals.local_ipv4_str); - - /* Call-ID */ - sip_header.write_function(&sip_header, "Call-ID: %s\r\n", session_uuid); - - /* CSeq */ - sip_header.write_function(&sip_header, "CSeq: 1 %s\r\n", method); - - /* Contact */ - sip_header.write_function(&sip_header, "Contact: sip:freeswitch@%s:5061\r\n", globals.local_ipv4_str); - - /* Max-Forwards */ - sip_header.write_function(&sip_header, "Max-Forwards: 70\r\n", method); - - /* Subject */ - sip_header.write_function(&sip_header, "Subject: %s %s recording of %s\r\n", - status == FS_OREKA_START ? "BEGIN": "END", - type == FS_OREKA_READ ? "RX" : "TX", caller_id_name); - - /* Add any custom extra headers */ - for (ei = extra_headers->headers; - ei; - ei = ei->next) { - const char *name = ei->name; - char *value = ei->value; - if (!strncasecmp(name, SIP_OREKA_HEADER_PREFIX, SIP_OREKA_HEADER_PREFIX_LEN)) { - const char *hname = name + SIP_OREKA_HEADER_PREFIX_LEN; - sip_header.write_function(&sip_header, "%s: %s\r\n", hname, value); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Adding custom oreka SIP header %s: %s\n", hname, value); - } - } - - if (status == FS_OREKA_START) { - /* Content-Type */ - sip_header.write_function(&sip_header, "Content-Type: application/sdp\r\n"); - - } - - /* Content-Length */ - sip_header.write_function(&sip_header, "Content-Length: %d\r\n", sdp.data_len); - - udp_packet.write_function(&udp_packet, "%s\r\n%s\n", sip_header.data, sdp.data); - - oreka_write_udp(oreka, &udp_packet); - -done: - if (sip_header.data) { - free(sip_header.data); - } - - if (sdp.data) { - free(sdp.data); - } - - if (udp_packet.data) { - free(udp_packet.data); - } - - if (status == FS_OREKA_STOP) { - oreka_destroy(oreka); - } - - return rc; -} - -static switch_bool_t oreka_audio_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type) -{ - oreka_session_t *oreka = user_data; - switch_core_session_t *session = oreka->session; - switch_frame_t pcmu_frame = { 0 }; - switch_frame_t *linear_frame, raw_frame = { 0 }; - uint8_t pcmu_data[SWITCH_RECOMMENDED_BUFFER_SIZE]; - uint8_t raw_data[SWITCH_RECOMMENDED_BUFFER_SIZE] = { 0 }; - uint8_t resample_data[SWITCH_RECOMMENDED_BUFFER_SIZE]; - uint32_t linear_len = 0; - uint32_t i = 0; - int16_t *linear_samples = NULL; - - - - if (type == SWITCH_ABC_TYPE_READ_REPLACE || type == SWITCH_ABC_TYPE_WRITE_REPLACE || type == SWITCH_ABC_TYPE_READ_PING) { - int16_t *data; - - if (type == SWITCH_ABC_TYPE_READ_REPLACE || type == SWITCH_ABC_TYPE_READ_PING) { - - if (type == SWITCH_ABC_TYPE_READ_REPLACE) { - linear_frame = switch_core_media_bug_get_read_replace_frame(bug); - } else { - switch_status_t status; - - raw_frame.data = raw_data; - raw_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE; - linear_frame = &raw_frame; - - status = switch_core_media_bug_read(bug, &raw_frame, SWITCH_FALSE); - if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) { - return SWITCH_TRUE; - } - } - - if (oreka->read_resampler) { - data = (int16_t *) linear_frame->data; - switch_resample_process(oreka->read_resampler, data, (int) linear_frame->datalen / 2); - linear_len = oreka->read_resampler->to_len * 2; - memcpy(resample_data, oreka->read_resampler->to, linear_len); - linear_samples = (int16_t *)resample_data; - } else { - linear_samples = linear_frame->data; - linear_len = linear_frame->datalen; - } - } - - if (type == SWITCH_ABC_TYPE_WRITE_REPLACE) { - linear_frame = switch_core_media_bug_get_write_replace_frame(bug); - - if (oreka->write_resampler) { - data = (int16_t *) linear_frame->data; - switch_resample_process(oreka->write_resampler, data, (int) linear_frame->datalen / 2); - linear_len = oreka->write_resampler->to_len * 2; - memcpy(resample_data, oreka->write_resampler->to, linear_len); - linear_samples = (int16_t *)resample_data; - } else { - linear_samples = linear_frame->data; - linear_len = linear_frame->datalen; - } - } - - /* convert the L16 frame into PCMU */ - memset(&pcmu_frame, 0, sizeof(pcmu_frame)); - for (i = 0; i < linear_len / sizeof(int16_t); i++) { - pcmu_data[i] = linear_to_ulaw(linear_samples[i]); - } - pcmu_frame.source = __SWITCH_FUNC__; - pcmu_frame.data = pcmu_data; - pcmu_frame.datalen = i; - pcmu_frame.payload = 0; - } - - switch (type) { - case SWITCH_ABC_TYPE_INIT: - { - switch_codec_implementation_t read_impl; - - switch_core_session_get_read_impl(session, &read_impl); - - if (read_impl.actual_samples_per_second != 8000) { - switch_resample_create(&oreka->read_resampler, - read_impl.actual_samples_per_second, - 8000, - 320, SWITCH_RESAMPLE_QUALITY, 1); - - switch_resample_create(&oreka->write_resampler, - read_impl.actual_samples_per_second, - 8000, - 320, SWITCH_RESAMPLE_QUALITY, 1); - } - - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Starting Oreka recording for audio stream\n"); - oreka_send_sip_message(oreka, FS_OREKA_START, FS_OREKA_READ); - if (!oreka->mux_streams) { - oreka_send_sip_message(oreka, FS_OREKA_START, FS_OREKA_WRITE); - } - } - break; - case SWITCH_ABC_TYPE_CLOSE: - { - if (oreka->mux_streams) { - int16_t *data; - - raw_frame.data = raw_data; - raw_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE; - - while (switch_core_media_bug_read(bug, &raw_frame, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) { - linear_frame = &raw_frame; - - - if (oreka->read_resampler) { - data = (int16_t *) linear_frame->data; - switch_resample_process(oreka->read_resampler, data, (int) linear_frame->datalen / 2); - linear_len = oreka->read_resampler->to_len * 2; - memcpy(resample_data, oreka->read_resampler->to, linear_len); - linear_samples = (int16_t *)resample_data; - } else { - linear_samples = linear_frame->data; - linear_len = linear_frame->datalen; - } - - memset(&pcmu_frame, 0, sizeof(pcmu_frame)); - for (i = 0; i < linear_len / sizeof(int16_t); i++) { - pcmu_data[i] = linear_to_ulaw(linear_samples[i]); - } - pcmu_frame.source = __SWITCH_FUNC__; - pcmu_frame.data = pcmu_data; - pcmu_frame.datalen = i; - pcmu_frame.payload = 0; - - switch_rtp_write_frame(oreka->read_rtp_stream, &pcmu_frame); - } - } - - - if (oreka->read_resampler) { - switch_resample_destroy(&oreka->read_resampler); - } - - if (oreka->write_resampler) { - switch_resample_destroy(&oreka->write_resampler); - } - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Stopping Oreka recording for audio stream\n"); - oreka_send_sip_message(oreka, FS_OREKA_STOP, FS_OREKA_READ); - if (!oreka->mux_streams) { - oreka_send_sip_message(oreka, FS_OREKA_STOP, FS_OREKA_WRITE); - } - } - break; - case SWITCH_ABC_TYPE_READ_REPLACE: - case SWITCH_ABC_TYPE_READ_PING: - { - if (pcmu_frame.datalen) { - if (switch_rtp_write_frame(oreka->read_rtp_stream, &pcmu_frame) > 0) { - oreka->read_cnt++; - if (oreka->read_cnt < 10) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Oreka wrote %u bytes! (read)\n", pcmu_frame.datalen); - } - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to write %u bytes! (read)\n", pcmu_frame.datalen); - } - } - } - break; - case SWITCH_ABC_TYPE_WRITE_REPLACE: - { - if (pcmu_frame.datalen) { - if (switch_rtp_write_frame(oreka->write_rtp_stream, &pcmu_frame) > 0) { - oreka->write_cnt++; - if (oreka->write_cnt < 10) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Oreka wrote %u bytes! (write)\n", pcmu_frame.datalen); - } - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to write %u bytes! (write)\n", pcmu_frame.datalen); - } - } - } - break; - default: - break; - } - - return SWITCH_TRUE; -} - - -SWITCH_STANDARD_APP(oreka_start_function) -{ - switch_status_t status; - switch_channel_t *channel = switch_core_session_get_channel(session); - oreka_session_t *oreka = NULL; - switch_media_bug_t *bug = NULL; - char *argv[6]; - int flags = 0; - char *lbuf = NULL; - const char *var; - - if ((oreka = (oreka_session_t *) switch_channel_get_private(channel, OREKA_PRIVATE))) { - if (!zstr(data) && !strcasecmp(data, "stop")) { - switch_channel_set_private(channel, OREKA_PRIVATE, NULL); - if (oreka->read_bug) { - switch_core_media_bug_remove(session, &oreka->read_bug); - oreka->read_bug = NULL; - } - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Stopped oreka recorder\n"); - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot run oreka recording 2 times on the same session!\n"); - } - return; - } - - oreka = switch_core_session_alloc(session, sizeof(*oreka)); - switch_assert(oreka); - memset(oreka, 0, sizeof(*oreka)); - - oreka->mux_streams = globals.mux_streams; - - if ((var = switch_channel_get_variable(channel, "oreka_mux_streams"))) { - oreka->mux_streams = switch_true(var); - } - - if (data && (lbuf = switch_core_session_strdup(session, data)) - && switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) { -#if 0 - if (!strncasecmp(argv[x], "server", sizeof("server"))) { - /* parse server=192.168.1.144 string */ - } -#endif - } - - oreka->session = session; - - if (oreka->mux_streams) { - flags = SMBF_READ_STREAM | SMBF_WRITE_STREAM | SMBF_READ_PING | SMBF_ANSWER_REQ; - } else { - flags = SMBF_READ_REPLACE | SMBF_WRITE_REPLACE | SMBF_ANSWER_REQ; - } - - status = switch_core_media_bug_add(session, OREKA_BUG_NAME_READ, NULL, oreka_audio_callback, oreka, 0, flags, &bug); - - if (status != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to attach oreka to media stream!\n"); - return; - } - oreka->read_bug = bug; - oreka->usecnt++; - bug = NULL; - oreka->usecnt++; - switch_channel_set_private(channel, OREKA_PRIVATE, oreka); - -} - -#define OREKA_XML_CONFIG "oreka.conf" -static int load_config(void) -{ - switch_xml_t cfg, xml, settings, param; - if (!(xml = switch_xml_open_cfg(OREKA_XML_CONFIG, &cfg, NULL))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open XML configuration '%s'\n", OREKA_XML_CONFIG); - return -1; - } - - if ((settings = switch_xml_child(cfg, "settings"))) { - for (param = switch_xml_child(settings, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - char *val = (char *) switch_xml_attr_soft(param, "value"); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found parameter %s=%s\n", var, val); - if (!strcasecmp(var, "sip-server-addr")) { - snprintf(globals.sip_server_addr_str, sizeof(globals.sip_server_addr_str), "%s", val); - } else if (!strcasecmp(var, "sip-server-port")) { - globals.sip_server_port = atoi(val); - } else if (!strcasecmp(var, "mux-all-streams")) { - globals.mux_streams = 1; - } - } - } - - switch_xml_free(xml); - return 0; -} - -SWITCH_MODULE_LOAD_FUNCTION(mod_oreka_load) -{ - switch_application_interface_t *app_interface = NULL; - int mask = 0; -#if 0 - switch_status_t status = SWITCH_STATUS_FALSE; - int x = 0; - switch_size_t len = 0; - switch_size_t ilen = 0; - char dummy_output[] = "Parangaricutirimicuaro"; - char dummy_input[sizeof(dummy_output)] = ""; - switch_sockaddr_t *from_addr = NULL; -#endif - - memset(&globals, 0, sizeof(globals)); - - if (load_config()) { - return SWITCH_STATUS_UNLOAD; - } - - if (zstr(globals.sip_server_addr_str)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No sip server address specified!\n"); - return SWITCH_STATUS_UNLOAD; - } - - if (!globals.sip_server_port) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No sip server port specified!\n"); - return SWITCH_STATUS_UNLOAD; - } - - //switch_sockaddr_info_get(&globals.sip_server_addr, "sigchld.sangoma.local", SWITCH_UNSPEC, 5080, 0, pool); - switch_sockaddr_info_get(&globals.sip_server_addr, globals.sip_server_addr_str, SWITCH_UNSPEC, globals.sip_server_port, 0, pool); - - if (!globals.sip_server_addr) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid sip server address specified: %s!\n", globals.sip_server_addr_str); - return SWITCH_STATUS_UNLOAD; - } - - if (switch_socket_create(&globals.sip_socket, switch_sockaddr_get_family(globals.sip_server_addr), SOCK_DGRAM, 0, pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create socket!\n"); - return SWITCH_STATUS_UNLOAD; - } - - switch_find_local_ip(globals.local_ipv4_str, sizeof(globals.local_ipv4_str), &mask, AF_INET); - switch_get_addr(globals.sip_server_ipv4_str, sizeof(globals.sip_server_ipv4_str), globals.sip_server_addr); - globals.our_pid = getpid(); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, - "Loading mod_oreka, sip_server_addr=%s, sip_server_ipv4_str=%s, sip_server_port=%d, local_ipv4_str=%s\n", - globals.sip_server_addr_str, globals.sip_server_ipv4_str, globals.sip_server_port, globals.local_ipv4_str); - -#if 0 - if (switch_socket_bind(globals.sip_socket, globals.sip_addr) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to bind to SIP address: %s!\n", strerror(errno)); - return SWITCH_STATUS_UNLOAD; - } -#endif - -#if 0 - len = sizeof(dummy_output); -#ifndef WIN32 - switch_socket_opt_set(globals.sip_socket, SWITCH_SO_NONBLOCK, TRUE); - - status = switch_socket_sendto(globals.sip_socket, globals.sip_addr, 0, (void *)dummy_output, &len); - if (status != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to send UDP message! (status=%d)\n", status); - } - - status = switch_sockaddr_create(&from_addr, pool); - if (status != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to creat socket address\n"); - } - - while (!ilen) { - ilen = sizeof(dummy_input); - status = switch_socket_recvfrom(from_addr, globals.sip_socket, 0, (void *)dummy_input, &ilen); - if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) { - break; - } - - if (++x > 1000) { - break; - } - - switch_cond_next(); - } - - switch_socket_opt_set(globals.sip_socket, SWITCH_SO_NONBLOCK, FALSE); -#endif -#endif - - *module_interface = switch_loadable_module_create_module_interface(pool, modname); - - SWITCH_ADD_APP(app_interface, "oreka_record", "Send media to Oreka recording server", "Send media to Oreka recording server", - oreka_start_function, "[stop]", SAF_NONE); - return SWITCH_STATUS_SUCCESS; -} - -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_oreka_shutdown) -{ - switch_socket_close(globals.sip_socket); - return SWITCH_STATUS_UNLOAD; -} - -/* 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: - */ From 6bad50d875622b6da15d7ecc65716eaa1b61e8ec Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Fri, 27 Dec 2024 19:37:47 +0300 Subject: [PATCH 08/11] [mod_clearmode] Remove from tree --- build/modules.conf.in | 1 - configure.ac | 1 - src/mod/codecs/mod_clearmode/Makefile.am | 8 -- src/mod/codecs/mod_clearmode/mod_clearmode.c | 107 ------------------- 4 files changed, 117 deletions(-) delete mode 100644 src/mod/codecs/mod_clearmode/Makefile.am delete mode 100644 src/mod/codecs/mod_clearmode/mod_clearmode.c diff --git a/build/modules.conf.in b/build/modules.conf.in index f555509c0d..6c1bb5b611 100755 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -51,7 +51,6 @@ codecs/mod_amr #codecs/mod_amrwb codecs/mod_b64 #codecs/mod_bv -#codecs/mod_clearmode #codecs/mod_codec2 #codecs/mod_com_g729 codecs/mod_g723_1 diff --git a/configure.ac b/configure.ac index 20d1ad3aa7..4345cecc91 100755 --- a/configure.ac +++ b/configure.ac @@ -2141,7 +2141,6 @@ AC_CONFIG_FILES([Makefile src/mod/codecs/mod_amrwb/Makefile src/mod/codecs/mod_b64/Makefile src/mod/codecs/mod_bv/Makefile - src/mod/codecs/mod_clearmode/Makefile src/mod/codecs/mod_codec2/Makefile src/mod/codecs/mod_com_g729/Makefile src/mod/codecs/mod_g723_1/Makefile diff --git a/src/mod/codecs/mod_clearmode/Makefile.am b/src/mod/codecs/mod_clearmode/Makefile.am deleted file mode 100644 index aa19cb3991..0000000000 --- a/src/mod/codecs/mod_clearmode/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -include $(top_srcdir)/build/modmake.rulesam -MODNAME=mod_clearmode - -mod_LTLIBRARIES = mod_clearmode.la -mod_clearmode_la_SOURCES = mod_clearmode.c -mod_clearmode_la_CFLAGS = $(AM_CFLAGS) -mod_clearmode_la_LIBADD = $(switch_builddir)/libfreeswitch.la -mod_clearmode_la_LDFLAGS = -avoid-version -module -no-undefined -shared diff --git a/src/mod/codecs/mod_clearmode/mod_clearmode.c b/src/mod/codecs/mod_clearmode/mod_clearmode.c deleted file mode 100644 index e2d3c8a094..0000000000 --- a/src/mod/codecs/mod_clearmode/mod_clearmode.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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 - * Brian West - * - * mod_clear.c -- CLEARMODE Passthru Codec - * - */ - -#include - -SWITCH_MODULE_LOAD_FUNCTION(mod_clearmode_load); -SWITCH_MODULE_DEFINITION(mod_clearmode, mod_clearmode_load, NULL, NULL); - -static switch_status_t switch_clearmode_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings) -{ - int encoding, decoding; - - encoding = (flags & SWITCH_CODEC_FLAG_ENCODE); - decoding = (flags & SWITCH_CODEC_FLAG_DECODE); - - if (!(encoding || decoding)) { - return SWITCH_STATUS_FALSE; - } else { - if (codec->fmtp_in) { - codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in); - } - return SWITCH_STATUS_SUCCESS; - } -} - -static switch_status_t switch_clearmode_encode(switch_codec_t *codec, - switch_codec_t *other_codec, - void *decoded_data, - uint32_t decoded_data_len, - uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, - unsigned int *flag) -{ - return SWITCH_STATUS_FALSE; -} - -static switch_status_t switch_clearmode_decode(switch_codec_t *codec, - switch_codec_t *other_codec, - void *encoded_data, - uint32_t encoded_data_len, - uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, - unsigned int *flag) -{ - return SWITCH_STATUS_FALSE; -} - -static switch_status_t switch_clearmode_destroy(switch_codec_t *codec) -{ - return SWITCH_STATUS_SUCCESS; -} - -SWITCH_MODULE_LOAD_FUNCTION(mod_clearmode_load) -{ - switch_codec_interface_t *codec_interface; - /* connect my internal structure to the blank pointer passed to me */ - *module_interface = switch_loadable_module_create_module_interface(pool, modname); - SWITCH_ADD_CODEC(codec_interface, "Clearmode (passthru)"); - switch_core_codec_add_implementation(pool, codec_interface, - SWITCH_CODEC_TYPE_AUDIO, 106, "CLEARMODE", NULL, 8000, 8000, 64000, - 20000, 160, 320, 320, 1, 1, - switch_clearmode_init, switch_clearmode_encode, switch_clearmode_decode, switch_clearmode_destroy); - switch_core_codec_add_implementation(pool, codec_interface, - SWITCH_CODEC_TYPE_AUDIO, 106, "CLEARMODE", NULL, 8000, 8000, 64000, - 30000, 240, 480, 480, 1, 1, - switch_clearmode_init, switch_clearmode_encode, switch_clearmode_decode, switch_clearmode_destroy); - /* indicate that the module should continue to be loaded */ - return SWITCH_STATUS_SUCCESS; -} - -/* 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: - */ From 96de8fd37734599d997bcb9fdd2b076d9cfb026e Mon Sep 17 00:00:00 2001 From: Aron Podrigal Date: Thu, 16 Jan 2025 10:13:31 -0600 Subject: [PATCH 09/11] [mod_timerfd] Fixed - continue timer loop after receiving a SIGSTOP When taking a snapshot of a machine which pauses the process, mod_timerfd exits and FreeSWITCH, causing all channels to wait indefinitely. Check `errno == EINTR` and continue the timer loop. --- src/mod/timers/mod_timerfd/mod_timerfd.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mod/timers/mod_timerfd/mod_timerfd.c b/src/mod/timers/mod_timerfd/mod_timerfd.c index bd07be8cdd..641bfba9c5 100644 --- a/src/mod/timers/mod_timerfd/mod_timerfd.c +++ b/src/mod/timers/mod_timerfd/mod_timerfd.c @@ -31,6 +31,7 @@ */ #include +#include #include #include @@ -228,8 +229,16 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_timerfd_runtime) do { r = epoll_wait(interval_poll_fd, e, sizeof(e) / sizeof(e[0]), 1000); - if (r < 0) + if (r < 0) { + /* if we had an interrupted system call due to process pause via SIGSTOP, do not exit the timer loop */ + if (errno == EINTR) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "epoll_wait interrupted by SIGINT, continue...\n"); + continue; + } + break; + } + for (i = 0; i < r; i++) { it = e[i].data.ptr; if ((e[i].events & EPOLLIN) && From 5cb74797fe996b706be1dc29d1096c7baefdfbfb Mon Sep 17 00:00:00 2001 From: Aron Podrigal Date: Fri, 17 Jan 2025 09:51:45 -0600 Subject: [PATCH 10/11] [mod_pgsql] err is now set correctly (dbh:last_error()) New function, `void pgsql_handle_set_error_if_not_set(switch_pgsql_handle_t *handle, char **err)` has been added to mod_pgsql module. This function is now called at several points where an error occurred but *err was not yet set. --- src/mod/databases/mod_pgsql/mod_pgsql.c | 29 ++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/mod/databases/mod_pgsql/mod_pgsql.c b/src/mod/databases/mod_pgsql/mod_pgsql.c index 89fdd710f6..1a5874e14c 100644 --- a/src/mod/databases/mod_pgsql/mod_pgsql.c +++ b/src/mod/databases/mod_pgsql/mod_pgsql.c @@ -106,6 +106,22 @@ char * pgsql_handle_get_error(switch_pgsql_handle_t *handle) return err_str; } +void pgsql_handle_set_error_if_not_set(switch_pgsql_handle_t *handle, char **err) +{ + char *err_str; + + if (err && !(*err)) { + err_str = pgsql_handle_get_error(handle); + + if (zstr(err_str)) { + switch_safe_free(err_str); + err_str = strdup((char *)"SQL ERROR!"); + } + + *err = err_str; + } +} + static int db_is_up(switch_pgsql_handle_t *handle) { int ret = 0; @@ -553,8 +569,15 @@ switch_status_t pgsql_handle_exec_detailed(const char *file, const char *func, i goto error; } - return pgsql_finish_results(handle); + if (pgsql_finish_results(handle) != SWITCH_STATUS_SUCCESS) { + goto error; + } + + return SWITCH_STATUS_SUCCESS; + error: + pgsql_handle_set_error_if_not_set(handle, err); + return SWITCH_STATUS_FALSE; } @@ -630,6 +653,7 @@ done: pgsql_free_result(&result); if (pgsql_finish_results(handle) != SWITCH_STATUS_SUCCESS) { + pgsql_handle_set_error_if_not_set(handle, err); sstatus = SWITCH_STATUS_FALSE; } @@ -638,6 +662,7 @@ done: error: pgsql_free_result(&result); + pgsql_handle_set_error_if_not_set(handle, err); return SWITCH_STATUS_FALSE; } @@ -1050,6 +1075,8 @@ switch_status_t pgsql_handle_callback_exec_detailed(const char *file, const char return SWITCH_STATUS_SUCCESS; error: + pgsql_handle_set_error_if_not_set(handle, err); + return SWITCH_STATUS_FALSE; } From 3b58ebc5f309708bde0ad26eef73e606144792f6 Mon Sep 17 00:00:00 2001 From: junction1153b Date: Mon, 20 Jan 2025 16:57:25 -0500 Subject: [PATCH 11/11] [mod_sofia] Update Polycom UA to recognize new Poly phones We observed that the new Poly phones (formerly known as Polycom) were not getting sent a SIP UPDATE in certain circumstances (example: retrieving a parked call, and therefore, Caller ID would not show the parked caller). I renamed Polycom to Poly which will catch all Poly AND Polycom UA's. I also added Acrobits, and Ringotel to extend such functionality to those UA's. There were also other minor compatibility issues with the new Poly phones which have been resolved with tweaking the UA recognition on the code. Co-authored-by: Joseph --- src/mod/endpoints/mod_sofia/mod_sofia.c | 8 +++++--- src/mod/endpoints/mod_sofia/sofia.c | 2 +- src/mod/endpoints/mod_sofia/sofia_presence.c | 2 +- src/mod/endpoints/mod_sofia/sofia_reg.c | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index c41ed9b2e3..086d6dd088 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -254,7 +254,7 @@ char *generate_pai_str(private_object_t *tech_pvt) callee_number = switch_sanitize_number(switch_core_session_strdup(session, callee_number)); callee_name = switch_sanitize_number(switch_core_session_strdup(session, callee_name)); - if (!zstr(callee_number) && (zstr(ua) || !switch_stristr("polycom", ua))) { + if (!zstr(callee_number) && (zstr(ua) || !switch_stristr("poly", ua))) { callee_number = switch_core_session_sprintf(session, "sip:%s@%s", callee_number, host); } @@ -2075,13 +2075,15 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), SIPTAG_PAYLOAD_STR(message), TAG_END()); } else if (update_allowed && ua && (switch_channel_var_true(tech_pvt->channel, "update_ignore_ua") || - switch_stristr("polycom", ua) || + switch_stristr("poly", ua) || (switch_stristr("aastra", ua) && !switch_stristr("Intelligate", ua)) || (switch_stristr("cisco/spa50", ua) || switch_stristr("cisco/spa525", ua)) || switch_stristr("cisco/spa30", ua) || switch_stristr("Fanvil", ua) || switch_stristr("Grandstream", ua) || + switch_stristr("Ringotel", ua) || + switch_stristr("Groundwire", ua) || switch_stristr("Yealink", ua) || switch_stristr("Mitel", ua) || switch_stristr("Panasonic", ua))) { @@ -2152,7 +2154,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi SIPTAG_PAYLOAD_STR(message), TAG_IF(!zstr(session_id_header), SIPTAG_HEADER_STR(session_id_header)), TAG_END()); - } else if (ua && switch_stristr("polycom", ua)) { + } else if (ua && switch_stristr("poly", ua)) { snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", msg->string_arg, tech_pvt->caller_profile->destination_number); nua_update(tech_pvt->nh, NUTAG_SESSION_TIMER(tech_pvt->session_timeout), diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index a370b52442..77e4750812 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -10476,7 +10476,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia (!is_tcp && !is_tls && (zstr(network_ip) || !switch_check_network_list_ip(network_ip, profile->local_network)) && profile->server_rport_level >= 2 && sip->sip_user_agent && sip->sip_user_agent->g_string && - (!strncasecmp(sip->sip_user_agent->g_string, "Polycom", 7) || !strncasecmp(sip->sip_user_agent->g_string, "KIRK Wireless Server", 20))) + (!strncasecmp(sip->sip_user_agent->g_string, "Poly", 4) || !strncasecmp(sip->sip_user_agent->g_string, "KIRK Wireless Server", 20))) ) { if (sip->sip_via) { const char *port = sip->sip_via->v_port; diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 48ad579411..151d6ec634 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -2501,7 +2501,7 @@ static char *gen_pidf(char *user_agent, char *id, char *url, char *open, char *r { char *ret = NULL; - if (switch_stristr("polycom", user_agent)) { + if (switch_stristr("poly", user_agent)) { *ct = "application/xpidf+xml"; /* If unknown/none prpid is provided, just show the user as online. */ diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index d9e04528a8..ccd42bf6ab 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -1661,7 +1661,7 @@ uint8_t sofia_reg_handle_register_token(nua_t *nua, sofia_profile_t *profile, nu if (!is_tcp && !is_tls && (zstr(network_ip) || !switch_check_network_list_ip(network_ip, profile->local_network)) && profile->server_rport_level >= 2 && sip->sip_user_agent && sip->sip_user_agent->g_string && - ( !strncasecmp(sip->sip_user_agent->g_string, "Polycom", 7) || + ( !strncasecmp(sip->sip_user_agent->g_string, "Poly", 4) || !strncasecmp(sip->sip_user_agent->g_string, "KIRK Wireless Server", 20) || !strncasecmp(sip->sip_user_agent->g_string, "ADTRAN_Total_Access", 19) )) { if (sip->sip_via) {