I have created a freeswitch kernel research and exchange group, 45211986. welcome to join us. In addition, we provide the SIP-based communication server and client solution to develop the SIP/IMS video client, supports access to the SIP Softswitch, IMS core network, voice, video, and instant communication functions, and video formats such as h263, h264, and MPEG4
Soft encoding soft decoding: provides hardware codec interface connection, and provides servers. If you are interested, contact me.
Freeswtich supports compiling dialplan in Lua, Perl, PHP and other script languages, similar to AGI in Asterisk. But freeswitch is more lightweight, and its XML format dialplan handwriting is indeed troublesome. mod_perl is implemented
Perl writes dialplan interfaces, that is, we can use Perl to call the APIS provided by freeswich to write our own business logic, especially when you want
Introducing business-related data in dialplan, such as querying databases and interacting with third-party business platforms (such as JSON and XML formats) is a good choice to use Perl.
Method:
1. Call the Perl script in XML dialplan
Create the dialplan/default/demo_perl.pl file.
Content:
When the call number is 4001, this process is executed. The function is to play a voice file to the user, then verify the settings and obtain the channel variable API.
<include><extension name="perl_demo"> <condition field="destination_number" expression="^4001$"> <action application="answer"/> <action application="perl" data="demo_perl.pl" /> </condition></extension></include>
APP Perl provides mod_perl APIs and executes demo_perl.pl scripts.
The content of this file is as follows:
#!/usr/bin/perluse strict;our $session;freeswitch::console_log("info", "Perl dialplan demo\n");my ($string) = @_;#print "\n\n".Dumper(\@_)."\n\n";my $id = $session->get_uuid();freeswitch::console_log("info", " uuid $id\n");#### set and get variable$session->setVariable("lidp_name", "lidp");my $name = $session->getVariable("lidp_name");freeswitch::console_log("info", " lidp_name = $name\n");$session->execute("playback", "/var/lib/asterisk/moh/macroform-cold_day.wav");$session->hangup();return 1;
If you want to know the functions provided by mod_perl, you can use this command to list them:
grep -o -P "^(\*[^=]+|############# Class.+)" freeswitch.pm
....