当前位置:网站首页>Freeswitch sets the maximum call duration
Freeswitch sets the maximum call duration
2022-06-28 06:24:00 【Be realistic】

summary
freeswitch As open source VOIP Soft switch , Yes, after fs Every phone call should have enough control .
In a telephone call , Call duration is an important data , In the actual use process of the customer , There will be various scenario requirements for call duration .
Discussion in this document fs How to set the maximum call duration , And analyze from the perspective of source code fs Implementation principle of .
Environmental Science
centos:CentOS release 7.0 (Final) Or above
freeswitch:v1.8.7
GCC:4.8.5
Hang up regularly
freeswitch Provides APP Interface “sched_hangup”, Help users to realize the function of hanging up regularly , To meet the requirement of setting the maximum call duration .
The method is simple to use , according to fs Official documents of , The call format is as follows .
// Call format in dial plan
<action application="sched_hangup" data="[+]<time>[ <hangup_cause>]"/>
// As API Interface call format
sched_hangup [+]<time> <uuid>[ <hangup_cause>]"
// example ,C++ Code
// Set the maximum call duration , Default 55 second
ptmp = switch_core_get_variable("max_duration");
max_duration = (ptmp? ptmp: "+55");
if (SWITCH_STATUS_SUCCESS != switch_core_session_execute_application(session, "sched_hangup", max_duration))
{
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
"sched_hangup failed, max_duration = %s\n", max_duration);
}
// example , Dial plan
<action application="sched_hangup" data="+55 allotted_timeout"/>
<action application="sched_hangup" data="+55"/>
<action application="sched_hangup" data="55"/>
In the dial plan example above , The parameters of the three call methods are different , But the actual test results are the same .
This is different from the official interface document .
Time in seconds.
If used with + then the call will be hung up after that number of seconds.
If used without + then the given value is considered the number of seconds since the epoch, 1970-01-01 00:00:00 UTC
Interface description ,“sched_hangup +55” and “sched_hangup 55” The results should be different .
Let's look in the source code to see what special processing has been done .
Source code
sched_hangup The interface code is in mod_dptools modular , The logic is simple , Processing parameters , call “switch_ivr_schedule_hangup” Interface .
In the process of processing parameters , For parameters 1 in “+” Processing of number , The code is as follows
int sec = atol(argv[0] + 1);
if (*argv[0] == '+') {
when = switch_epoch_time_now(NULL) + sec;
} else {
when = atol(argv[0]);
}
// After processing ,when The value of is ”now+55” and “55”
switch_ivr_schedule_hangup The interface code is in “switch_ivr_async.c” in , Interface “switch_scheduler_add_task” Created a scheduled task , The logic of a scheduled task is to hang up a specified call .
In the above logic , There is no special processing involving execution time , only “switch_scheduler_add_task” Create a task interface , This interface is described in the previous article “freeswitch Task engine implementation analysis ” There is a detailed introduction to .
//switch_scheduler_add_task, Special handling of task execution time , Less than now be +now
if (task_runtime < now) {
container->task.repeat = (uint32_t)task_runtime;
task_runtime += now;
}
After that , above “sched_hangup” in call “+55” and “55” The results of the two parameters are unified .
summary
freeswitch There are many practical functions and code flow in the function interface part of , Suitable for fs Development reference for in-depth customization requirements .
Finally, put a sketch , Easy to understand . The data structure and processing of scheduled tasks are actually more complex than this .

Empty as usual
Be serious
边栏推荐
- What is the e-commerce conversion rate so abstract?
- ImportError: cannot import name 'ensure_ dir_ Possible solutions for exists'
- Alert pop-up processing in Web Automation
- death_satan/hyperf-validate
- Apple MDM bypass jailfree bypass MDM configuration lock free
- OpenSCAP 简介
- AttributeError: 'callable_ iterator' object has no attribute 'next'
- Teach you how to use UCOS
- easyui下拉框选中触发事件
- mysql常用函数
猜你喜欢

How popular are FB and WhatsApp mass messages in 2022?

AutoCAD C# 多段线自相交检测

Promotion intégrale et ordre des octets de fin de taille

mac下安装多个版本php并且进行管理

fpm工具安装

Slow content advertising: the long-term principle of brand growth

FPGA - 7 Series FPGA selectio -09- io of advanced logic resources_ FIFO

三极管驱动无刷电机

Uni app wechat applet sharing function

Linux MySQL implements root user login without password
随机推荐
FPGA - 7系列 FPGA SelectIO -07- 高级逻辑资源之ISERDESE2
ThreadLocal
fpm工具安装
SQL and list de duplication
Enum
Deep learning 19 loss functions
How to add live chat in your Shopify store?
JSP
Freeswitch使用originate转dialplan
4~20mA输入/0~5V输出的I/V转换电路
重载,重写的区别,抽象类,接口的区别
MySQL (I) - Installation
报错--解决core-js/modules/es.error.cause.js报错
Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
慢内容广告:品牌增长的长线主义
阿里云短信服务(完整指南),短信发送功能实现。
Lombok @equalsandhashcode annotation how to make objects The equals () method compares only some attributes
MySQL common functions
Working principle of es9023 audio decoding chip
Mosaic data enhanced mosaic