- Java锁的逻辑(结合对象头和ObjectMonitor)
- 还在用饼状图?来瞧瞧这些炫酷的百分比可视化新图形(附代码实现)⛵
- 自动注册实体类到EntityFrameworkCore上下文,并适配ABP及ABPVNext
- 基于Sklearn机器学习代码实战
#define SWITCH_MODULE_LOAD_ARGS (switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) #define SWITCH_MODULE_RUNTIME_ARGS (void) #define SWITCH_MODULE_SHUTDOWN_ARGS (void) typedef switch_status_t ( * switch_module_load_t) SWITCH_MODULE_LOAD_ARGS; typedef switch_status_t ( * switch_module_runtime_t) SWITCH_MODULE_RUNTIME_ARGS; typedef switch_status_t ( * switch_module_shutdown_t) SWITCH_MODULE_SHUTDOWN_ARGS; #define SWITCH_MODULE_LOAD_FUNCTION(name) switch_status_t name SWITCH_MODULE_LOAD_ARGS #define SWITCH_MODULE_RUNTIME_FUNCTION(name) switch_status_t name SWITCH_MODULE_RUNTIME_ARGS #define SWITCH_MODULE_SHUTDOWN_FUNCTION(name) switch_status_t name SWITCH_MODULE_SHUTDOWN_ARGS
typedef struct switch_loadable_module_function_table { int switch_api_version; switch_module_load_t load; switch_module_shutdown_t shutdown; switch_module_runtime_t runtime; switch_module_flag_t flags; } switch_loadable_module_function_table_t; #define SWITCH_MODULE_DEFINITION_EX(name, load, shutdown, runtime, flags) \ static const char modname[] = #name ; \ SWITCH_MOD_DECLARE_DATA switch_loadable_module_function_table_t name##_module_interface = { \ SWITCH_API_VERSION, \ load, \ shutdown, \ runtime, \ flags \ } #define SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime) \ SWITCH_MODULE_DEFINITION_EX(name, load, shutdown, runtime, SMODF_NONE)
switch_loadable_module_load_module => switch_loadable_module_load_module_ex => switch_loadable_module_load_file => switch_loadable_module_process => switch_core_launch_thread => switch_loadable_module_exec
void *switch_dso_data_sym(switch_dso_lib_t lib, const char *sym, char ** err) { void *addr = dlsym(lib, sym); if (! addr) { char *err_str = NULL; dlerror(); if (!(addr = dlsym(lib, sym))) { err_str = ( char * )dlerror(); } if (err_str) { *err = strdup(err_str); } } return addr; }
static void *SWITCH_THREAD_FUNC switch_loadable_module_exec(switch_thread_t *thread, void * obj) { switch_status_t status = SWITCH_STATUS_SUCCESS; switch_core_thread_session_t *ts = obj; switch_loadable_module_t *module = ts->objs[ 0 ]; int restarts; switch_assert(thread != NULL); switch_assert(module != NULL); for (restarts = 0 ; status != SWITCH_STATUS_TERM && !module->shutting_down; restarts++ ) { status = module-> switch_module_runtime(); } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, " Thread ended for %s\n " , module->module_interface-> module_name); if (ts-> pool) { switch_memory_pool_t *pool = ts-> pool; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, " Destroying Pool for %s\n " , module->module_interface-> module_name); switch_core_destroy_memory_pool( & pool); } switch_thread_exit(thread, 0 ); return NULL; }
函数调用链如下:
main => switch_core_init_and_modload => switch_core_init => switch_loadable_module_init => switch_loadable_module_load_module
switch_loadable_module_load_module_ex( "" , " CORE_SOFTTIMER_MODULE " , SWITCH_FALSE, SWITCH_FALSE, & err, SWITCH_LOADABLE_MODULE_TYPE_COMMON, event_hash); switch_loadable_module_load_module_ex( "" , " CORE_PCM_MODULE " , SWITCH_FALSE, SWITCH_FALSE, & err, SWITCH_LOADABLE_MODULE_TYPE_COMMON, event_hash); switch_loadable_module_load_module_ex( "" , " CORE_SPEEX_MODULE " , SWITCH_FALSE, SWITCH_FALSE, &err, SWITCH_LOADABLE_MODULE_TYPE_COMMON, event_hash);
main => switch_core_init_and_modload => switch_core_init => switch_xml_init => switch_xml_open_root => XML_OPEN_ROOT_FUNCTION
if (!SWITCH_GLOBAL_filenames.conf_name && (SWITCH_GLOBAL_filenames.conf_name = ( char *) malloc (BUFSIZE))) { switch_snprintf(SWITCH_GLOBAL_filenames.conf_name, BUFSIZE, " %s " , " freeswitch.xml " ); }
static switch_xml_open_root_function_t XML_OPEN_ROOT_FUNCTION = (switch_xml_open_root_function_t)__switch_xml_open_root; SWITCH_DECLARE_NONSTD(switch_xml_t) __switch_xml_open_root(uint8_t reload, const char **err, void * user_data) { char path_buf[ 1024 ]; uint8_t errcnt = 0 ; switch_xml_t new_main, r = NULL; if (MAIN_XML_ROOT) { if (! reload) { r = switch_xml_root(); goto done; } } switch_snprintf(path_buf, sizeof (path_buf), " %s%s%s " , SWITCH_GLOBAL_dirs.conf_dir, SWITCH_PATH_SEPARATOR, SWITCH_GLOBAL_filenames.conf_name); if ((new_main = switch_xml_parse_file(path_buf))) { *err = switch_xml_error(new_main); switch_copy_string(not_so_threadsafe_error_buffer, *err, sizeof (not_so_threadsafe_error_buffer)); *err = not_so_threadsafe_error_buffer; if (!zstr(* err)) { switch_xml_free(new_main); new_main = NULL; errcnt ++ ; } else { *err = " Success " ; switch_xml_set_root(new_main); } } else { *err = " Cannot Open log directory or XML Root! " ; errcnt ++ ; } if (errcnt == 0 ) { r = switch_xml_root(); } done: return r; }
< section name ="configuration" description ="Various Configuration" > < X-PRE-PROCESS cmd ="include" data ="autoload_configs/*.xml" /> </ section >
fs_cli => load ... => SWITCH_STANDARD_API(load_function) => switch_loadable_module_load_module
fs_cli => reload ... => SWITCH_STANDARD_API(reload_function) => switch_loadable_module_unload_module
=> switch_loadable_module_load_module
struct switch_loadable_module { char * key; char * filename; int perm; switch_loadable_module_interface_t * module_interface; switch_dso_lib_t lib; switch_module_load_t switch_module_load; switch_module_runtime_t switch_module_runtime; switch_module_shutdown_t switch_module_shutdown; switch_memory_pool_t * pool; switch_status_t status; switch_thread_t * thread; switch_bool_t shutting_down; switch_loadable_module_type_t type; }; typedef struct switch_loadable_module switch_loadable_module_t;
struct switch_loadable_module_interface { /* ! the name of the module */ const char * module_name; /* ! the table of endpoints the module has implemented */ switch_endpoint_interface_t * endpoint_interface; /* ! the table of timers the module has implemented */ switch_timer_interface_t * timer_interface; /* ! the table of dialplans the module has implemented */ switch_dialplan_interface_t * dialplan_interface; /* ! the table of codecs the module has implemented */ switch_codec_interface_t * codec_interface; /* ! the table of applications the module has implemented */ switch_application_interface_t * application_interface; /* ! the table of chat applications the module has implemented */ switch_chat_application_interface_t * chat_application_interface; /* ! the table of api functions the module has implemented */ switch_api_interface_t * api_interface; /* ! the table of json api functions the module has implemented */ switch_json_api_interface_t * json_api_interface; /* ! the table of file formats the module has implemented */ switch_file_interface_t * file_interface; /* ! the table of speech interfaces the module has implemented */ switch_speech_interface_t * speech_interface; /* ! the table of directory interfaces the module has implemented */ switch_directory_interface_t * directory_interface; /* ! the table of chat interfaces the module has implemented */ switch_chat_interface_t * chat_interface; /* ! the table of say interfaces the module has implemented */ switch_say_interface_t * say_interface; /* ! the table of asr interfaces the module has implemented */ switch_asr_interface_t * asr_interface; /* ! the table of management interfaces the module has implemented */ switch_management_interface_t * management_interface; /* ! the table of limit interfaces the module has implemented */ switch_limit_interface_t * limit_interface; /* ! the table of database interfaces the module has implemented */ switch_database_interface_t * database_interface; switch_thread_rwlock_t * rwlock; int refs; switch_memory_pool_t * pool; }; typedef struct switch_loadable_module_interface switch_loadable_module_interface_t;
SWITCH_DECLARE(switch_loadable_module_interface_t *) switch_loadable_module_create_module_interface(switch_memory_pool_t *pool, const char * name) { switch_loadable_module_interface_t * mod; mod = switch_core_alloc(pool, sizeof (switch_loadable_module_interface_t)); switch_assert(mod != NULL); mod ->pool = pool; mod ->module_name = switch_core_strdup(mod-> pool, name); switch_thread_rwlock_create( &mod->rwlock, mod-> pool); return mod; }
*module_interface = switch_loadable_module_create_module_interface(pool, modname); rtc_endpoint_interface = switch_loadable_module_create_interface(* module_interface, SWITCH_ENDPOINT_INTERFACE); rtc_endpoint_interface ->interface_name = " rtc " ; rtc_endpoint_interface ->io_routines = & rtc_io_routines; rtc_endpoint_interface ->state_handler = & rtc_event_handlers; rtc_endpoint_interface ->recover_callback = rtc_recover_callback;
SWITCH_DECLARE( void *) switch_loadable_module_create_interface(switch_loadable_module_interface_t * mod, switch_module_interface_name_t iname) { switch (iname) { case SWITCH_ENDPOINT_INTERFACE: ALLOC_INTERFACE(endpoint) case SWITCH_TIMER_INTERFACE: ALLOC_INTERFACE(timer) case SWITCH_DIALPLAN_INTERFACE: ALLOC_INTERFACE(dialplan) case SWITCH_CODEC_INTERFACE: ALLOC_INTERFACE(codec) case SWITCH_APPLICATION_INTERFACE: ALLOC_INTERFACE(application) case SWITCH_CHAT_APPLICATION_INTERFACE: ALLOC_INTERFACE(chat_application) case SWITCH_API_INTERFACE: ALLOC_INTERFACE(api) case SWITCH_JSON_API_INTERFACE: ALLOC_INTERFACE(json_api) case SWITCH_FILE_INTERFACE: ALLOC_INTERFACE(file) case SWITCH_SPEECH_INTERFACE: ALLOC_INTERFACE(speech) case SWITCH_DIRECTORY_INTERFACE: ALLOC_INTERFACE(directory) case SWITCH_CHAT_INTERFACE: ALLOC_INTERFACE(chat) case SWITCH_SAY_INTERFACE: ALLOC_INTERFACE(say) case SWITCH_ASR_INTERFACE: ALLOC_INTERFACE(asr) case SWITCH_MANAGEMENT_INTERFACE: ALLOC_INTERFACE(management) case SWITCH_LIMIT_INTERFACE: ALLOC_INTERFACE(limit) case SWITCH_DATABASE_INTERFACE: ALLOC_INTERFACE(database) default : switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, " Invalid Module Type!\n " ); return NULL; } }
struct switch_endpoint_interface { /* ! the interface's name */ const char * interface_name; /* ! channel abstraction methods */ switch_io_routines_t * io_routines; /* ! state machine methods */ switch_state_handler_table_t * state_handler; /* ! private information */ void * private_info; switch_thread_rwlock_t * rwlock; int refs; switch_mutex_t * reflock; /* parent */ switch_loadable_module_interface_t * parent; /* to facilitate linking */ struct switch_endpoint_interface * next; switch_core_recover_callback_t recover_callback; }; typedef struct switch_endpoint_interface switch_endpoint_interface_t;
struct switch_io_routines { /* ! creates an outgoing session from given session, caller profile */ switch_io_outgoing_channel_t outgoing_channel; /* ! read a frame from a session */ switch_io_read_frame_t read_frame; /* ! write a frame to a session */ switch_io_write_frame_t write_frame; /* ! send a kill signal to the session's channel */ switch_io_kill_channel_t kill_channel; /* ! send a string of DTMF digits to a session's channel */ switch_io_send_dtmf_t send_dtmf; /* ! receive a message from another session */ switch_io_receive_message_t receive_message; /* ! queue a message for another session */ switch_io_receive_event_t receive_event; /* ! change a sessions channel state */ switch_io_state_change_t state_change; /* ! read a video frame from a session */ switch_io_read_video_frame_t read_video_frame; /* ! write a video frame to a session */ switch_io_write_video_frame_t write_video_frame; /* ! read a video frame from a session */ switch_io_read_text_frame_t read_text_frame; /* ! write a video frame to a session */ switch_io_write_text_frame_t write_text_frame; /* ! change a sessions channel run state */ switch_io_state_run_t state_run; /* ! get sessions jitterbuffer */ switch_io_get_jb_t get_jb; void *padding[ 10 ]; }; typedef struct switch_io_routines switch_io_routines_t;
struct switch_state_handler_table { /* ! executed when the state changes to init */ switch_state_handler_t on_init; /* ! executed when the state changes to routing */ switch_state_handler_t on_routing; /* ! executed when the state changes to execute */ switch_state_handler_t on_execute; /* ! executed when the state changes to hangup */ switch_state_handler_t on_hangup; /* ! executed when the state changes to exchange_media */ switch_state_handler_t on_exchange_media; /* ! executed when the state changes to soft_execute */ switch_state_handler_t on_soft_execute; /* ! executed when the state changes to consume_media */ switch_state_handler_t on_consume_media; /* ! executed when the state changes to hibernate */ switch_state_handler_t on_hibernate; /* ! executed when the state changes to reset */ switch_state_handler_t on_reset; /* ! executed when the state changes to park */ switch_state_handler_t on_park; /* ! executed when the state changes to reporting */ switch_state_handler_t on_reporting; /* ! executed when the state changes to destroy */ switch_state_handler_t on_destroy; int flags; void *padding[ 10 ]; }; typedef struct switch_state_handler_table switch_state_handler_table_t;
case CS_ROUTING: /* Look for a dialplan and find something to do */ STATE_MACRO(routing, " ROUTING " ); break ; case CS_RESET: /* Reset */ STATE_MACRO(reset, " RESET " ); break ; /* These other states are intended for prolonged durations so we do not signal lock for them */ case CS_EXECUTE: /* Execute an Operation */ STATE_MACRO(execute, " EXECUTE " ); break ; case CS_EXCHANGE_MEDIA: /* loop all data back to source */ STATE_MACRO(exchange_media, " EXCHANGE_MEDIA " ); break ; case CS_SOFT_EXECUTE: /* send/recieve data to/from another channel */ STATE_MACRO(soft_execute, " SOFT_EXECUTE " ); break ; case CS_PARK: /* wait in limbo */ STATE_MACRO(park, " PARK " ); break ; case CS_CONSUME_MEDIA: /* wait in limbo */ STATE_MACRO(consume_media, " CONSUME_MEDIA " ); break ; case CS_HIBERNATE: /* sleep */ STATE_MACRO(hibernate, " HIBERNATE " ); break ;
2)修改文件名 。
4)修改编译选项 。
。
。
7)安装模块 。
8)加载模块 。
c风格endpoint模块编译及运行效果视频:
关注微信公众号(聊聊博文,文末可扫码)后回复 2023052801 获取。 。
c++风格endpoint模块编译及运行效果视频:
关注微信公众号(聊聊博文,文末可扫码)后回复 2023052802 获取。 。
本文涉及源码和文件,可以从如下途径获取:
关注微信公众号(聊聊博文,文末可扫码)后回复 20230528 获取.
。
最后此篇关于FreeSWITCH添加自定义endpoint的文章就讲到这里了,如果你想了解更多关于FreeSWITCH添加自定义endpoint的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我正在使用 winsock 和 C++ 来设置服务器应用程序。我遇到的问题是对 listen 的调用会导致第一次机会异常。我想通常这些可以忽略(?),但我发现其他人也有同样的问题,它导致应用程序偶尔挂
我对 Wireguard 的理解是服务器和客户端的接口(interface)(虽然看起来听不清?)每个都有自己的 .conf 文件。例如,考虑以下 .conf 文件。 [Interface] Priv
如何将多个实体从客户端传递到 Google Cloud Endpoint? 例如,传递单个实体很容易在服务器的 Endpoint api 源文件中完成: public class SomeEndpoi
我试图建立一个路径来将文件从一个目录复制到另一个目录。但不是使用:从(文件://源目录)到(文件://目标目录)我想做这样的事情: from(direct:start) .to(direct:do
我有一个非常小的网站,在 Azure 上以共享托管配置运行。我上面有一堆涉及打开套接字的网络代码,所有这些代码都成功运行。 我编写了一些发送 ping 的代码,但抛出了 PingException,内
我试图了解如何将 Cloud Endpoints 与自定义身份验证结合使用。从文档中我了解到它从 securityDefinitions 开始: securityDefinitions: yo
我在理解有关此文档的过程中遇到了一些麻烦。位于 ... https://developers.google.com/appengine/docs/java/endpoints/consume_js 具
我一直在尝试在生成的 Endpoint 类中创建一些新方法,但发现了这种奇怪的行为:我可以向生成的类添加一个方法,但我无法添加其中两个方法,无论我选择这两个方法中的哪一个添加。这是我生成的类的代码,我
azure 中的“输入端点”和“内部端点”是什么?如何创建新的“输入端点”? &如何将数据发送到“输入端点”? 输入端点端口 65400 端口是什么? 最佳答案 输入端点是云服务和 Internet
首先,对您可能犯的语法错误表示歉意。我的英语不是很好。 我是 Spring 新手,我正在尝试创建基本身份验证安全性。 我正在尝试配置一个端点具有公共(public)访问权限,而其他端点则具有用户访问权
我试图让图标部分包含我自己的图标,而不是通过尝试猴子补丁 ApiConfigGenerator.get_descriptor_defaults 来谷歌搜索图标。不幸的是,当发现文档完成时,这些将被忽略
我正在尝试跟随初学者到 WCF 页面上的演示视频 MSDN . 第一个视频或多或少地工作得很好。我现在接近第二个视频的结尾。我使用的是 VS2010/.NET 4.0,而视频似乎使用的是 VS2008
这个问题完全来自我在这里问过(并得到回答)的相关问题:Error when trying to retrieve a single entity 据我了解,要使用已提供的辅助方法以外的属性(例如 'i
WSL1 没有问题。我想升级到 WSL 2。 当我尝试升级到 wsl2 时,命令行失败。我试图删除 Ubuntu 并重新安装它,没有区别。 虚拟机平台处于事件状态。 Windows 内部版本号:190
我有一个代理lambda函数的AWS api。我目前使用不同的端点和单独的 lambda 函数: api.com/getData --> getData api.com/addData --> add
我正在构建一个 Chrome 应用,我真的希望它能够通过云端点与我的服务器进行通信,但有两个问题我不确定如何克服: Google apis javascript 库是一个外部脚本,我无法在 Chrom
我正在我的 gke 集群上运行 kubernetes 1.9.4 我有两个 pod,gate,它正在尝试连接到 coolapp,它们都是用 elixir 编写的 我正在使用libcluster连接我的
阅读Where to place the Asynctask in the Application和 http://android-developers.blogspot.com/2009/05/pa
我不清楚 @Named 在 Google Cloud Endpoints 中的用途。文档说: This annotation indicates the name of the parameter i
我正在关注 Getting Started guide对于使用 Maven 的 Java 中的 Google Cloud Endpoints,我无法使用 API Explorer 访问我的端点。 尽管
我是一名优秀的程序员,十分优秀!