当前位置:网站首页>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
边栏推荐
- Difficulty calculation of Ethereum classic
- 报错--解决core-js/modules/es.error.cause.js报错
- ROS rviz_ Satellite function package visualizes GNSS track and uses satellite map
- Note that JPA uses a custom VO to receive jpql query results
- Yolov5 adds a small target detection layer
- MySQL common functions
- 慢内容广告:品牌增长的长线主义
- Failed to start component [StandardEngine[Catalina]. StandardHost[localhost]]
- Slow content advertising: the long-term principle of brand growth
- Shell script one click deployment (MySQL)
猜你喜欢

YYGH-BUG-03

AutoCAD C polyline self intersection detection

Example of MVVM framework based on kotlin+jetpack

图片按日期批量导入WPS表格

FPGA - 7 Series FPGA selectio -08- oserdese2 of advanced logic resources

What are the advantages of e-mail marketing? Why do sellers of shopline independent station attach so much importance to it?

fpm工具安装

How the third-party libraries in cocoapod reference local header files

Independent station sellers are using the five e-mail marketing skills, do you know?

Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance
随机推荐
搭建你jmeter+jenkins+ant
Deleting MySQL under Linux
ThreadLocal
AutoCAD C # Polyline Small Sharp angle Detection
lombok @EqualsAndHashCode 注解如何让对象.equals()方法只比较部分属性
Alibaba cloud SMS service (Complete Guide), SMS sending function implementation.
How to add live chat in your Shopify store?
Linux MySQL implements root user login without password
【Paper Reading-3D Detection】Fully Convolutional One-Stage 3D Object Detection on LiDAR Range Images
借助nz-pagination中的let-total解析ng-template
Taobao seo training video course [22 lectures]
FPGA - 7 Series FPGA selectio -07- iserdese2 of advanced logic resources
fpm工具安装
YYGH-BUG-03
Parsing ng template with let total in NZ Pagination
Select trigger event from easyUI drop-down box
ROS rviz_satellite功能包可视化GNSS轨迹,卫星地图的使用
eyebeam高级设置
选拔赛题目代码
CAD secondary development +nettopologysuite+pgis reference multi version DLL