freeswitch 通话录音及通话记录

1、接听后开始录音

dialplan/default.xml

      <action application="set" data="RECORD_APPEND=true"/> 
      <action application="set" data="RECORD_COPYRIGHT=(c) 2020"/>  
      <action application="set" data="RECORD_SOFTWARE=FreeSWITCH"/>
      <action application="set" data="RECORD_ARTIST=FreeSWITCH"/> 
      <action application="set" data="RECORD_COMMENT=FreeSWITCH"/> 
      <action application="set" data="RECORD_DATE=${strftime(%Y-%m-%d %H:%M)}"/>  
      <action application="set" data="RECORD_STEREO=true"/>
      <action application="set" data="enable_file_write_buffering=false"/>
      <action application="set" data="media_bug_answer_req=true"/>
      
      <action application="set" data="record_relative_dir=${strftime(%Y-%m-%d)}"/>
      <action application="set" data="record_file=${caller_id_number}.${strftime(%Y-%m-%d-%H-%M-%S)}.wav"/>
      <action application="system" data="/bin/mkdir -m 755 -p $${recordings_dir}/${record_relative_dir}"/>
      <action application="export" data="execute_on_answer=record_session $${recordings_dir}/${record_relative_dir}/${record_file}" />

RECORD_APPEND 如果不开启,双方同时说话录音会有问题

/bin/mkdir -m 755 -p $${recordings_dir}/${record_relative_dir}

使用这个命令来创建根据日期归档的录音文件,同时设置目录权限755,避免后面其他应用访问出现权限问题

execute_on_answer=record_session $${recordings_dir}/${record_relative_dir}/${record_file}

这一段用来指示在对方应答后开始录音,并且指定录音文件路径

2、通话记录通过mod_xml_cdr上传

autoload_configs/modules.conf.xml

<load module="mod_xml_cdr"/>

配置要上传的api

autoload_configs/xml_cdr.conf.xml

<param name="url" value="https://xxxx/call/callRecordApi/create"/>

开启模块, 需要在控制台加载模块

freeswitch@VM-8-4-centos> load mod_xml_cdr
+OK Reloading XML
-ERR [Module already loaded]

3、关联录音文件和通话记录

在freeswitch服务器上搭建一个nginx静态网站

在网站root目录创建一个软连接,指向录音文件目录

ln -s /var/log/freeswitch/recording recording

前面设置的通话记录接口可以接受xml记录里面的variables里面的录音文件路径,保存记录时添加上freeswitch服务器的域名或者ip就可以获取直接访问到录音文件的链接了。

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注