freeswitch透过模块写dialplan实践

本文介绍如何在freeswitch中通过模块实现dialplan功能。首先完成模块加载,然后在mod_book.c中添加代码实现电话拨出功能。通过`make install`编译安装模块,使用`reload mod_book`加载模块。最后,调用`originate user/1000 9999 book`拨号,观察控制台输出确认模块生效。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

书接上文,已经完成了模块的加载工作,为了使模块真正的有点作用,试图从模块中新增功能并加载到服务,使用api可以实现电话拨出。

在mod_book.c中,编辑如下:

#include<switch.h>

SWITCH_MODULE_LOAD_FUNCTION(mod_book_load);
SWITCH_MODULE_DEFINITION(mod_book,mod_book_load,NULL,NULL);

SWITCH_STANDARD_DIALPLAN(book_dialplan_hunt)
{
 switch_caller_extension_t *extension = NULL;
 switch_channel_t *channel = switch_core_session_get_channel(session);

 if(!caller_profile) {
 caller_profile = switch_channel_get_caller_profile(channel);
}

 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),SWITCH_LOG_INFO,
 "Procession %s <%s>->%s in context %s\n",
 caller_profile->caller_id_name,caller_profile->caller_id_number,
 caller_profile->destination_number,caller_profile->context);
 extension = switch_caller_extension_new(session,"book","book");
 
 if(!extension) abort();

 switch_caller_extension_add_application(session,extension,
 "lo
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值