FreeSWITCH API常用手册

 

FreeSWITCHAPI

 

 

 

西安睿智电子科技有限公司

地址:陕西省西安市碑林区太白北路太白星座1115室

电话:02968711800

网址:www.verycc.com

                                  

                                                       

acl,<ip><list_name>,Comparean ip to an acl list,mod_commands

检测IP与当前访问控制列表

alias,[add|stickyadd]<alias> <command> | del [<alias>|*]

Alias,mod_commands banner,,Return thesystem banner,mod_commands

别名

bg_system,<command>,

Execute a system command in thebackground,mod_commands

后台执行系统命令

bgapi,<command>[<arg>],

Execute an api command in athread,mod_commands

后台执行API命令

break,<uuid>[all],uuid_break,mod_commands

桥接命令

cdr_csv,parameters,cdr_csvcontrols,mod_cdr_csv

csv格式的CDR()

chat,<proto>|<from>|<to>|<message>|[<content-type>],chat,mod_dptools

发送消息

coalesce,[^^<delim>]<value1>,<value2>,...,

Return first nonemptyparameter,mod_commands

返回第一个非空参数

complete,add<word>|del [<word>|*],Complete,mod_commands

 

cond,<expr>? <true val> : <false val>,Evaluate a conditional,mod_commands

求表达式的值

conference,,Conferencemodule commands,mod_conference

console,loglevel[level]|colorize [on|toggle|off],Console,mod_console

调试日志级别

console_complete,<line>,,mod_commands

 

console_complete_xml,<line>,,mod_commands

 

create_uuid,<uuid><other_uuid>,Createa uuid,mod_commands

创建uuid

db,[insert|delete|select|exists|count|list]/<realm>/<key>/<value>

db get/set,mod_db

获取、设置数据库

db_cache,status,Managedb cache,mod_commands

管理数据库缓存

domain_data,<domain>[var|param|attr] <name>,

Find domain data,mod_commands

查找域名数据

domain_exists,<domain>,Check if a domainexists,mod_commands

检测域名是否存在

echo,<data>,Echo,mod_commands

 

enum,,ENUM,mod_enum

escape,<data>,Escape a string,mod_commands

转义字符串

eval,[uuid:<uuid>]<expression>,eval(noop),mod_commands

 

event_channel_broadcast,<channel><json>,Broadcast,mod_commands

事件广播

event_sink,<webdata>,event_sink,mod_event_socket

 

expand,[uuid:<uuid>]<cmd> <args>

Execute an api with variableexpansion,mod_commands

 

expr,<expr>,Eval an expression,mod_expr

 

fifo,list|list_verbose|count|debug|status|has_outbound|importance[<fifo name>]|reparse [del_all],Return data about a fifo,mod_fifo

 

fifo_add_outbound,<node><url> [<priority>],

Add outbound members to a fifo,mod_fifo

 

fifo_check_bridge,<uuid>|<outbound_id>,check if uuid is in abridge,mod_fifo

 

fifo_member,[add<fifo_name> <originate_string> [<simo_count>][<timeout>] [<lag>] [<expires>] [<taking_calls>] | del<fifo_name> <originate_string>],Add members to a fifo,mod_fifo

 

file_exists,<file>,Check if a file exists onserver,mod_commands

 

find_user_xml,<key><user> <domain>,Finda user,mod_commands

 

fsctl,[recover|send_sighup|hupall|pause[inbound|outbound]|resume [inbound|outbound]|shutdown[cancel|elegant|asap|now|restart]|sps|sps_peak_reset|sync_clock|sync_clock_when_idle|reclaim_mem|max_sessions|min_dtmf_duration[num]|max_dtmf_duration [num]|default_dtmf_duration [num]|min_idle_cpu|loglevel[level]|debug_level [level]],

FS control messages,mod_commands

 

getcputime,[reset],Gets CPU time in milliseconds

 

(user,kernel),mod_commands

getenv,<name>,getenv,mod_commands

 

gethost,,gethostbyname,mod_commands

 

global_getvar,<var>,Get global var,mod_commands

 

global_setvar,<var>=<value>[=<value2>],Setglobal var,mod_commands

 

group,[insert|delete|call]:<groupname>:<url>,group [insert|delete|call],mod_db

 

group_call,<group>[@<domain>],

Generate a dial string to call a group,mod_commands

 

hash,[insert|delete|select]/<realm>/<key>/<value>,hashget/set,mod_hash

 

hash_dump,all|limit|db[<realm>],dump hash/limit_hash data (used for synchronization),mod_hash

 

hash_remote,list|kill[name]|rescan,hash remote,mod_hash

 

help,,Show help for all the apicommands,mod_commands

 

host_lookup,<hostname>,Lookup host,mod_commands

 

hostname,,Returnthe system hostname,mod_commands

 

httapi,[debug_on|debug_off],HT-TAPIHypertext Telephony API,mod_httapi

 

hupall,<cause>[<var> <value>] [<var2> <value2>],hupall,mod_commands

 

in_group,<user>[@<domain>]<group_name>

Determine if a user is in agroup,mod_commands

 

interface_ip,[auto|ipv4|ipv6]<ifname>

Return the primary IP of aninterface,mod_commands

 

is_lan_addr,<ip>,See if an ip is a lan addr,mod_commands

 

json,JSON,JSONAPI,mod_commands

 

limit_hash_usage,<realm><id>,

Deprecated: gets the usage count of alimited resource,mod_commands

 

limit_interval_reset,<backend><realm> <resource>,

Reset the interval counter for a limited resource,mod_commands

 

limit_reset,<backend>,Reset the counters of a limitbackend,mod_commands

 

limit_status,<backend>,Get the status of a limitbackend,mod_commands

 

limit_usage,<backend><realm> <id>

Get the usage count of a limited resource,mod_commands

 

list_users,[group<group>] [domain <domain>] [user <user>] [context<context>]

List Users configured inDirectory,mod_commands

 

load,<mod_name>,Load Module,mod_commands

 

local_stream,<show|start|reload|stop|hup><local_stream_name>

manage local streams,mod_local_stream

 

log,<level><message>,Log,mod_commands

 

lua,<script>,run a script as an apifunction,mod_lua

 

luarun,<script>,run a script,mod_lua

 

md5,<data>,Return md5 hash,mod_commands

 

module_exists,<module>,Check if module exists,mod_commands

 

msleep,<milliseconds>,Sleep Nmilliseconds,mod_commands

 

msrp,debug<on|off>|restart,MSRPFunctions,mod_commands

 

nat_map,[status|republish|reinit]| [add|del] <port> [tcp|udp] [static]

Manage NAT,mod_commands

 

opus_debug,<on|off>,Set OPUS Debug,mod_opus

 

originate,<callurl> <exten>|&<application_name>(<app_args>)[<dialplan>] [<context>] [<cid_name>] [<cid_num>][<timeout_sec>]

Originate a call,mod_commands

 

page,(var1=val1,var2=val2)<var1=val1,var2=val2><chan1>[:_:<chanN>]

Send a file as a page,mod_dptools

 

pause,<uuid><on|off>,Pausemedia on a channel,mod_commands

 

presence,[in|out]<user> <rpid> <message>,presence,mod_dptools

 

quote_shell_arg,<data>

Quote/escape a string for use on shellcommand line,mod_commands

 

reg_url,<user>@<realm>,,mod_commands

 

regex,<data>|<pattern>[|<subststring>][n|b]

Evaluate a regex,mod_commands

 

reload,[-f]<mod_name>,Reloadmodule,mod_commands

 

reloadacl,,Reload XML,mod_commands

 

reloadxml,,Reload XML,mod_commands

 

replace,<data>|<string1>|<string2>,Replace a string,mod_commands

 

say_string,<module_name>[.<ext>]<lang>[.<ext>] <say_type> <say_method>[<say_gender>] <text>,,mod_commands

 

sched_api,[+@]<time><group_name> <command_string>[&]

Schedule an api command,mod_commands

 

sched_broadcast,[[+]<time>|@time]<uuid> <path> [aleg|bleg|both],Schedule a broadcast event to a runningcall,mod_commands

 

sched_del,<task_id>|<group_id>,Delete a scheduledtask,mod_commands

 

sched_hangup,[+]<time><uuid> [<cause>],Schedule a running call to hangup,mod_commands

 

sched_transfer,[+]<time><uuid> <extension> [<dialplan>] [<context>],Schedule atransfer for a running call,mod_commands

 

show,codec|endpoint|application|api|dialplan|file|timer|calls[count]|channels [count|like <matchstring>]|calls|detailed_calls|bridged_calls|detailed_bridged_calls|aliases|complete|chat|management|modules|nat_map|say|interfaces|interface_types|tasks|limits|status,Showvarious reports,mod_commands

 

shutdown,,Shutdown,mod_commands

 

sofia,<cmd><args>,Sofia Controls,mod_sofia

 

sofia_contact,[profile/]<user>@<domain>,SofiaContacts,mod_sofia

 

sofia_count_reg,[profile/]<user>@<domain>,CountSofia registration,mod_sofia

 

sofia_dig,<url>,SIPDIG,mod_sofia

 

sofia_gateway_data,<gateway_name>[ivar|ovar|var] <name>,Get data from a sofia gateway,mod_sofia

 

sofia_presence_data,[list|status|rpid|user_agent][profile/]<user>@domain,

Sofia PresenceData,mod_sofia

 

sofia_username_of,[profile/]<user>@<domain>,

Sofia UsernameLookup,mod_sofia spandsp_start_tone_detect,<uuid> <name>,Start backgroundtone detection with cadence,mod_spandsp

spandsp_stop_tone_detect,<uuid>,

Stop backgroundtone detection with cadence,mod_spandsp

 

sql_escape,<string>,Escapea string to prevent sql injection,mod_commands

 

start_tdd_detect,<uuid>,

Start backgroundtdd detection,mod_spandsp status,,Show current status,mod_commands

stop_tdd_detect,<uuid>,Stopbackground tdd detection,mod_spandsp

 

strepoch,<string>,Converta date string into epoch time,mod_dptools

 

strftime,<format_string>,strftime,mod_dptools

 

strftime_tz,<timezone_name>[<epoch>|][format string],

Displayformatted time of timezone,mod_commands

 

strmicroepoch,<string>,Converta date string into micoepoch time,mod_dptools

 

stun,<stun_server>[:port][<source_ip>[:<source_port]],

Execute STUN lookup,mod_commandsswitchname,,Return the switch name,mod_commands

 

system,<command>,Executea system command,mod_commands

 

time_test,<mss>[count],Show time jitter,mod_commands

 

timer_test,<10|20|40|60|120>[<1..200>] [<timer_name>],Exercise FS timer,mod_commands

 

tone_detect,<uuid><key> <tone_spec> [<flags> <timeout> <app><args> <hits>],

Start tonedetection on a channel,mod_commands

 

unload,[-f]<mod_name>,Unload module,mod_commands

 

unsched_api,<task_id>,Unschedulean api command,mod_commands

 

uptime,[us|ms|s|m|h|d|microseconds|milliseconds|seconds|minutes|hours|days],

Showuptime,mod_commands

 

url_decode,<string>,Urldecode a string,mod_commands

 

url_encode,<string>,Urlencode a string,mod_commands

 

user_data,<user>@<domain>[var|param|attr] <name>,

Find userdata,mod_commands

 

user_exists,<key><user> <domain>,Find a user,mod_commands

 

uuid_answer,<uuid>,answer,mod_commands

 

uuid_audio,<uuid>[start [read|write] [mute|level <level>]|stop],uuid_audio,mod_commands

 

uuid_break,<uuid>[all],Break out of media sent to channel,mod_commands

 

uuid_bridge,,Bridgecall legs,mod_commands

 

uuid_broadcast,<uuid><path> [aleg|bleg|holdb|both],

Execute dialplanapplication,mod_commands

 

uuid_buglist,<uuid>,Listmedia bugs on a session,mod_commands

 

uuid_capture_text,<uuid><on|off>,start/stop capture_text,mod_commands

 

uuid_chat,<uuid><text>,Send a chat message,mod_commands

 

uuid_codec_debug,<uuid>audio|video <level>,Send codec a debug message,mod_commands

 

uuid_codec_param,<uuid>audio|video read|write <param> <val>,

Send codec aparam,mod_commands

 

uuid_debug_media,<uuid><read|write|both|vread|vwrite|vboth|all> <on|off>,

Debugmedia,mod_commands

 

uuid_deflect,<uuid><uri>,Send a deflect,mod_commands

 

uuid_displace,<uuid>[start|stop] <path> [<limit>] [mux],Displace audio,mod_commands

 

uuid_display,<uuid><display>,Update phone display,mod_commands

 

uuid_drop_dtmf,<uuid>[on | off ] [ mask_digits <digits> | mask_file <file>],

Drop all DTMF orreplace it with a mask,mod_commands

 

uuid_dual_transfer,<uuid><A-dest-exten>[/<A-dialplan>][/<A-context>]<B-dest-exten>

[/<B-dialplan>][/<B-context>],Transfera session and its partner,mod_commands

 

uuid_dump,<uuid>[format],Dump session vars,mod_commands

 

uuid_early_ok,<uuid>,stopignoring early media,mod_commands

 

uuid_exists,<uuid>,Checkif a uuid exists,mod_commands

 

uuid_fileman,<uuid><cmd>:<val>,Manage session audio,mod_commands

 

uuid_flush_dtmf,<uuid>,Flushdtmf on a given uuid,mod_commands

 

uuid_getvar,<uuid><var>,Get a variable from a channel,mod_commands

 

uuid_hold,[off|toggle]<uuid> [<display>],Place call on hold,mod_commands

 

uuid_jitterbuffer,<uuid>[0|<min_msec>[:<max_msec>]],uuid_jitterbuffer,mod_commands

 

uuid_kill,<uuid>[cause],Kill channel,mod_commands

 

uuid_limit,<uuid><backend> <realm> <resource> [<max>[/interval]] [number[dialplan [context]]],Increase limit resource,mod_commands

 

uuid_limit_release,<uuid><backend> [realm] [resource],Release limit resource,mod_commands

 

uuid_limit_release,<uuid><backend> [realm] [resource],Release limit resource,mod_commands

 

uuid_loglevel,<uuid><level>,Set loglevel on session,mod_commands

 

uuid_media,[off]<uuid>,Reinvite FS in or out of media path,mod_commands

 

uuid_media_3p,[off]<uuid>,Reinvite FS in or out of media path using 3pcc,mod_commands

 

uuid_media_reneg,<uuid>[<codec_string>],Media negotiation,mod_commands

 

uuid_msrp_send,<msg>,sendmsrp text,mod_commands

 

uuid_outgoing_answer,<uuid>,Answeroutgoing channel,mod_commands

 

uuid_park,<uuid>,Parkchannel,mod_commands

 

uuid_pause,<uuid><on|off>,Pause media on a channel,mod_commands

 

uuid_phone_event,<uuid>,Sendan event to the phone,mod_commands

 

uuid_pre_answer,<uuid>,pre_answer,mod_commands

 

uuid_preprocess,<>,Pre-processChannel,mod_commands

 

uuid_record,<uuid>[start|stop|mask|unmask] <path> [<limit>],Record sessionaudio,mod_commands

 

uuid_recovery_refresh,<uuid><uri>,Send a recovery_refresh,mod_commands

 

uuid_recv_dtmf,<uuid><dtmf_data>,Receive dtmf digits,mod_commands

 

uuid_redirect,<uuid><uri>,Send a redirect,mod_commands

 

uuid_ring_ready,<uuid>[queued],Sending ringing to a channel,mod_commands

 

uuid_send_dtmf,<uuid><dtmf_data>,Send dtmf digits,mod_commands

 

uuid_send_info,<uuid>[<mime_type> <mime_subtype>] <message>,

Send info to theendpoint,mod_commands

 

uuid_send_message,<uuid><message>,Send MESSAGE to the endpoint,mod_commands

 

uuid_send_tdd,<uuid><text>,send tdd data to a uuid,mod_spandsp

 

uuid_send_text,<uuid><text>,Send text in real-time,mod_commands

 

uuid_session_heartbeat,<uuid>[sched] [0|<seconds>],uuid_session_heartbeat,mod_commands

 

uuid_set_media_stats,<uuid>,Setmedia stats,mod_commands

 

uuid_setvar,<uuid><var> [value],Set a variable,mod_commands

 

uuid_setvar_multi,<uuid><var>=<value>;<var>=<value>...,

Set multiplevariables,mod_commands

 

uuid_simplify,<uuid>,Tryto cut out of a call path / attended xfer,mod_commands

 

uuid_transfer,<uuid>[-bleg|-both] <dest-exten> [<dialplan>] [<context>],

Transfer asession,mod_commands

 

uuid_video_bitrate,<uuid><bitrate>,Send video bitrate req.,mod_commands

 

uuid_video_refresh,<uuid>[auto|manual],Send video refresh.,mod_commands

 

uuid_write_png,,graban image from a call,mod_png

 

uuid_xfer_zombie,<uuid>,AllowA leg to hangup and continue originating,mod_commands

 

uuid_zombie_exec,<uuid>,Setzombie_exec flag on the specified uuid,mod_commands

 

valet_info,[<lotname>],Valet Parking Info,mod_valet_parking

 

version,[short],Version,mod_commands

 

verto,syntax,VertoAPI,mod_verto

verto_contact,user@domain,Generatea verto endpoint dialstring,mod_verto

 

vm_boxcount,[profile/]<user>@<domain>[|[new|saved|new-urgent|

saved-urgent|all]],vm_boxcount,mod_voicemail

 

vm_delete,<id>@<domain>[/profile][<uuid>],vm_delete,mod_voicemail

 

vm_fsdb_auth_login,<profile><domain> <user> <password>,vm_fsdb_auth_login,mod_voicemail

 

vm_fsdb_msg_count,<format><profile> <domain> <user><folder>,vm_fsdb_msg_count,mod_voicemail

 

vm_fsdb_msg_delete,<profile><domain> <user> <uuid>,vm_fsdb_msg_delete,mod_voicemail

 

vm_fsdb_msg_email,<profile><domain> <user> <uuid><email>,vm_fsdb_msg_email,mod_voicemail

 

vm_fsdb_msg_forward,<profile><domain> <user> <uuid> <dst_domain> <dst_user>[prepend_file_location],vm_fsdb_msg_forward,mod_voicemail

 

vm_fsdb_msg_get,<format><profile> <domain> <user><uuid>,vm_fsdb_msg_get,mod_voicemail

 

vm_fsdb_msg_list,<format><profile> <domain> <user> <folder> <filter>[msg-order = ASC | DESC],vm_fsdb_msg_list,mod_voicemail

 

vm_fsdb_msg_purge,<profile><domain> <user>,vm_fsdb_msg_purge,mod_voicemail

 

vm_fsdb_msg_save,<profile><domain> <user> <uuid>,vm_fsdb_msg_save,mod_voicemail

 

vm_fsdb_msg_undelete,<profile><domain> <user> <uuid>,vm_fsdb_msg_undelete,mod_voicemail

 

vm_fsdb_pref_greeting_get,<format><profile> <domain> <user>[slot],vm_fsdb_pref_greeting_get,mod_voicemail

 

vm_fsdb_pref_greeting_set,<profile><domain> <user> <slot> [file-path],vm_fsdb_pref_greeting_set,mod_voicemail

 

vm_fsdb_pref_password_set,<profile><domain> <user><password>,vm_fsdb_pref_password_set,mod_voicemail

 

vm_fsdb_pref_recname_set,<profile><domain> <user> <file-path>,vm_fsdb_pref_recname_set,mod_voicemail

 

vm_inject,[group=<group>[@domain]|domain=<domain>|<box>[@<domain>]]<sound_file> [<cid_num>] [<cid_name>],vm_inject,mod_voicemail

 

vm_list,<id>@<domain>[/profile][xml],vm_list,mod_voicemail

 

vm_prefs,[profile/]<user>@<domain>[|[name_path|greeting_path|password]],vm_prefs,mod_voicemail

 

vm_read,<id>@<domain>[/profile]<read|unread> [<uuid>],vm_read,mod_voicemail

 

voicemail,rss[<host> <port> <uri> <user> <domain>] |[load|unload|reload] <profile> [reloadxml],voicemail,mod_voicemail

 

voicemail_inject,[group=<group>[@domain]|domain=<domain>|<box>

[@<domain>]]<sound_file> [<cid_num>][<cid_name>],voicemail_inject,mod_voicemail

 

xml_flush_cache,<id><key> <val>,Clear xml cache,mod_commands

 

xml_locate,[root| <section> <tag> <tag_attr_name> <tag_attr_val>],Findsome xml,mod_commands

 

xml_wrap,<command><args>,Wrap another api command in xml,mod_commands

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
FreeSWITCH提供了Java API,允许Java开发人员在Java应用程序中集成FreeSWITCH的功能。使用Java API,您可以在Java应用程序中实现以下功能: 1. 发起呼叫并进行呼叫控制,如拨号、挂机、保持、转移等。 2. 处理媒体,如播放音频、录制音频、实时音频处理等。 3. 监听事件并做出相应的响应,如处理呼叫事件、媒体事件等。 4. 访问FreeSWITCH的配置文件和状态信息。 在Java应用程序中使用FreeSWITCH Java API需要以下步骤: 1. 下载FreeSWITCH Java API的jar包,并将其添加到Java应用程序的classpath中。 2. 创建FreeSWITCH连接对象,并连接到FreeSWITCH服务器。 3. 创建呼叫对象并发起呼叫。 4. 处理呼叫事件和媒体事件。 5. 断开与FreeSWITCH服务器的连接。 以下是一个使用FreeSWITCH Java API实现呼叫控制和媒体处理的示例代码: ```java import org.freeswitch.esl.client.inbound.Client; import org.freeswitch.esl.client.inbound.InboundConnectionFailure; import org.freeswitch.esl.client.internal.Context; import org.freeswitch.esl.client.internal.IModEslApi.EventFormat; import org.freeswitch.esl.client.transport.message.EslMessage; public class FreeSwitchApiTest { public static void main(String[] args) throws InboundConnectionFailure { Client client = new Client(); client.connect("localhost", 8021, "ClueCon", 10); Context context = new Context(); context.addEvent("CHANNEL_ANSWER CHANNEL_HANGUP_COMPLETE CUSTOM"); client.addEventListener(context); String uuid = client.originate("sofia/internal/1000", "1001", "playback", "/var/lib/freeswitch/sounds/music/8000/suite-espanola-op47-leyenda.wav", "true"); while (true) { EslMessage message = client.getEventChannel().readEvent(EventFormat.PLAIN); if (message == null) { break; } String eventName = message.getEventName(); switch (eventName) { case "CHANNEL_ANSWER": System.out.println("Channel answered, UUID: " + message.getEventHeaders().get("Unique-ID")); break; case "CHANNEL_HANGUP_COMPLETE": System.out.println("Channel hangup, UUID: " + message.getEventHeaders().get("Unique-ID")); break; case "CUSTOM": String customEventName = message.getEventHeaders().get("Event-Subclass"); System.out.println("Custom event received, name: " + customEventName); break; default: break; } } client.close(); } } ``` 这个例子中,我们使用FreeSWITCH Java API发起了一个呼叫,播放了一个音频文件,并处理了呼叫事件和自定义事件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值