分享

freeswitch 命令

 hginvent 2014-01-14

FreeSwitch支持三种Media处理模式:Default, Media Proxy 和 Bypass

     Default 模式: media flows through FS, full processing options。

      Proxy 模式: media flows through FS, no media processing options。不能录音,也不能从FS originate。
                设置Proxy 模式的方法:
                Set proxy_media=true before the bridge.
<action application="set" data="proxy_media=true"/>

Alternatively, configure the SIP profile to use proxy media by default:

<param name="inbound-proxy-media" value="true"/>

(see example in conf/sip_profiles/internal.xml)

      Bypass模式: media flows around FS directly between endpoints, no media processing options。

http://wiki./wiki/Mod_commands

show

Display various reports

Usage: show <item> where <item> is:
 codec
 endpoint
 application
 api
 dialplan
 file
 timer
 calls [count]
 channels [count|like <match string>]
 calls
 detailed_calls
 bridged_calls
 detailed_bridged_calls
 aliases
 complete
 chat
 management
 modules
 nat_map
 say
 interfaces
 interface_types
 tasks
 limits

Tips For Showing Calls and Channels

The best way to get an understanding of all of the show calls/channels is to actually try them out. Recently (Sept 2011) there have been some additions to the show family:

  • show detailed_calls
  • show bridged_calls
  • show detailed_bridged_calls

shutdown

Stop the FreeSWITCH program. This only works from the CLI, as an API call, you should be using 'fsctl shutdown'

Warning! Shutdown from the CLI ignores arguments and exits immediately!

Usage: fsctl shutdown [cancel|elegant|asap|restart|now]
  • cancel - discontinue a previous shutdown request.
  • elegant - wait for all traffic to stop; do not prevent new traffic.
  • asap - wait for all traffic to stop; do not allow new traffic.
  • restart - restart FreeSWITCH immediately following the shutdown.
  • now - shutdown FreeSWITCH immediately.

Call Management Commands

break

Deprecated. See uuid_break.

create_uuid

Creates a new UUID and returns it as a string.

Usage: create_uuid

originate

Originate a new call.

   Usage: originate <call_url> <exten>|&<application_name>(<app_args>) 
   [<dialplan>] [<context>] [<cid_name>] [<cid_num>] [<timeout_sec>]


Parameters:

  • <call_url> URL you are calling. 
    For more info on sofia SIP URL syntax see: FreeSwitch Endpoint Sofia
  • Destination, one of:
    • <exten> Destination number to enter dialplan with
    • &<application_name>(<app_args>)
      • "&" indicates what follows is an application name, not an exten
      • (<app_args>) is optional (not all applications require parameters, eg park)
      • Here is a list of valid application names that can be used here: 
        park, bridge, javascript/lua/perl, playback (remove mod_native_file), and many others.
      • Note: Use single quotes to pass arguments with spaces, e.g. '&lua(test.lua arg1 arg2)'
      • Note: There is no space between & and the application name
  • <dialplan> Defaults to 'XML' if not specified.
  • <context> Defaults to 'default' if not specified.
  • <cid_name> CallerID name.
  • <cid_num> CallerID number.
  • <timeout_sec> Timeout in seconds.

Options:

These options can be used in curly braces, example: "originate {ignore_early_media=true}sofia/example/user 8334".

Options must be separated by ',', Example: "originate {ignore_early_media=true,originate_timeout=2}sofia/example/user 8334"

  • group_confirm_key
  • group_confirm_file
  • forked_dial
  • fail_on_single_reject
  • ignore_early_media
  • return_ring_ready
  • originate_retries
  • originate_retry_sleep_ms
  • origination_caller_id_name
  • origination_caller_id_number
  • originate_timeout
  • sip_auto_answer

Description of originate's related variables

Examples: So you can call a locally registered sip endpoint 300 and park the call like so (Note that the "example" profile used here must be the one your local user you want to call is registered to)

   originate sofia/example/300%pbx.internal &park()

or you could instead connect a remote sip endpoint to extension 8600

   originate sofia/example/300@foo.com 8600

or you could instead connect a remote SIP endpoint to another remote extension

   originate sofia/example/300@foo.com &bridge(sofia/example/400@bar.com)

or you could even run a javascript application test.js

   originate sofia/example/1000@somewhere.com &javascript(test.js)

To run a javascript with arguments you must surround it in quotes.

   originate sofia/example/1000@somewhere.com '&javascript(test.js myArg1 myArg2)'

Setting channel variables before doing the originate

   originate {ignore_early_media=true}sofia/mydomain.com/18005551212@1.2.3.4 15555551212

Setting variable to send to another FS box during originate

   originate {sip_h_X-varA=111,sip_h_X-varB=222}sofia/mydomain.com/18005551212@1.2.3.4 15555551212

Note: you can set any channel variable, even custom ones. Use single quotes to enclose values with spaces, commas, etc.

   originate {my_own_var=my_value}sofia/mydomain.com/that.ext@1.2.3.4 15555551212
   originate {my_own_var='my value'}sofia/mydomain.com/that.ext@1.2.3.4 15555551212

If you need to fake the ringback to the originated endpoint try this:

   originate {ringback=\'%(2000,4000,440.0,480.0)\'}sofia/example/300@foo.com &bridge(sofia/example/400@bar.com)

If you need to make originate return immediately when the channel is in "Ring-Ready" state try this:

   originate {return_ring_ready=true}sofia/gateway/someprovider/919246461929 &socket(127.0.0.1:8082 async full)

see here for more info on return_ring_ready

You can even set music on hold for the ringback if you want:

   originate {ringback=\'/path/to/music.wav\'}sofia/gateway/name/number &bridge(sofia/gateway/name/othernumber)

You can originate a call in the background (asynchronously) and playback a message with a 60 second timeout.

   bgapi originate {ignore_early_media=true,originate_timeout=60}sofia/gateway/name/number &playback(message)

You can specify the UUID of an originated call by doing the following:

  • Use create_uuid to generate a UUID to use.
  • This will allow you to kill an originated call before it is answered by using uuid_kill.
  • If you specify origination_uuid it will remain the UUID for answered call leg for the whole session.
    originate {origination_uuid=...}user/100@domain.name.com

Here's an example of originating a call to the echo conference (an external sip URL) and bridging it to a local user's phone:

   originate sofia/internal/9996@conference. &bridge(user/105@default)

Here's an example of originating a call to an extension in a different context than 'default' (required for the FreePBX which uses context_1, context_2, etc.):

   originate sofia/internal/2001@foo.com 3001 xml context_3

You can also originate to multiple extensions as follows:

   originate user/1001,user/1002,user/1003 &park()

To put an outbound call into a conference at early media, either of these will work (they are effectively the same thing)

   originate sofia/example/300@foo.com &conference(conf_uuid-TEST_CON)
   originate sofia/example/300@foo.com conference:conf_uuid-TEST_CON inline
   
      ( See Misc._Dialplan_Tools_InlineDialplan for more detail on 'inline' Dialplans )

An example of using loopback and inline on the A-leg can be found here

pause

Pause <uuid> media

Usage: pause <uuid> <on|off>

uuid_answer

Answer a channel

Usage: uuid_answer <uuid>

uuid_audio

Adjust the audio levels on a channel or mute (read/write) via a media bug.

Usage: uuid_audio <uuid> [start [read|write] [mute|level <level>]|stop]

level is in the range from -4 to 4, 0 being the default value.

uuid_break

Break out of media being sent to a channel. For example, if an audio file is being played to a channel, issuing uuid_break will discontinue the media and the call will move on in the dialplan, script, or whatever is controlling the call.

Usage: uuid_break <uuid> [all]

If the all flag is used then all audio files/prompts/etc. that are queued up to be played to the channel will be removed, whereas without the all flag only the currently playing file will be discontinued.


uuid_bridge

Bridge two call legs together.

Usage: uuid_bridge <uuid> <other_uuid>

uuid_bridge needs atleast any one leg to be answered.

uuid_broadcast

Execute an arbitrary dialplan application on a specific uuid. If a filename is specified then it is played into the channel(s). To execute an application use "app::args" syntax.

Usage: uuid_broadcast <uuid> <path> [aleg|bleg|both]

Execute an application on a chosen leg(s) with optional hangup afterwards:

Usage: uuid_broadcast <uuid> app[![hangup_cause]]::args [aleg|bleg|both]

Examples:

 uuid_broadcast 336889f2-1868-11de-81a9-3f4acc8e505e sorry.wav both
 uuid_broadcast 336889f2-1868-11de-81a9-3f4acc8e505e say::en\snumber\spronounced\s12345 aleg
 uuid_broadcast 336889f2-1868-11de-81a9-3f4acc8e505e say!::en\snumber\spronounced\s12345 aleg
 uuid_broadcast 336889f2-1868-11de-81a9-3f4acc8e505e say!user_busy::en\snumber\spronounced\s12345 aleg
 uuid_broadcast 336889f2-1868-11de-81a9-3f4acc8e505e playback!user_busy::sorry.wav aleg

uuid_buglist

List the media bugs on channel

Usage: uuid_buglist <uuid>

uuid_chat

Send a chat message.

-USAGE: <uuid> <text>

If the endpoint associated with the session <uuid> has a receive_event handler, this message gets sent to that session and is interpreted as an instant message.

uuid_debug_media

The command was uuid_debug_audio, been changed into the current name when video options was added.

Debug media

Usage:

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

Use "read" or "write" for the audio direction to debug, or "both" for both direction. And prefix with v for video.

Read Format

"R %s b=%4ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n"

where the values are:

  • switch_channel_get_name(switch_core_session_get_channel(session)),
  • (long) bytes,
  • my_host, switch_sockaddr_get_port(rtp_session->local_addr),
  • old_host, rtp_session->remote_port,
  • tx_host, switch_sockaddr_get_port(rtp_session->from_addr),
  • rtp_session->recv_msg.header.pt,
  • ntohl(rtp_session->recv_msg.header.ts),
  • rtp_session->recv_msg.header.m

Write Format

"W %s b=%4ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n"

where the values are:

  • switch_channel_get_name(switch_core_session_get_channel(session)),
  • (long) bytes,
  • my_host, switch_sockaddr_get_port(rtp_session->local_addr),
  • old_host, rtp_session->remote_port,
  • tx_host, switch_sockaddr_get_port(rtp_session->from_addr),
  • send_msg->header.pt,
  • ntohl(send_msg->header.ts),
  • send_msg->header.m);

uuid_deflect

Deflect an answered SIP call off of FreeSWITCH by sending the REFER method

Usage: uuid_deflect <uuid> <sip URL>

uuid_deflect waits for the final response from the far end to be reported. It returns the sip fragment from that response as the text in the FreeSWITCH response to uuid_deflect. If the far end reports the REFER was successful, then FreeSWITCH will issue a bye on the channel.

Example:

  uuid_deflect 0c9520c4-58e7-40c4-b7e3-819d72a98614 sip:info@example.net

Response:

  Content-Type: api/response
  Content-Length: 30
  +OK:SIP/2.0 486 Busy Here

uuid_displace

Displace the audio for the target <uuid> with the specified audio <file>.

Parameters:

  • uuid = Unique ID of this call (see 'show channels')
  • start|stop = Start/Stop this action
  • file = path to an audio source (wav, shout, etc...)
  • limit = number of seconds before terminating the displacement
  • mux = cause the original audio to be mixed together with 'file', i.e. you can still converse with the other party while the file is playing

Usage: uuid_displace <uuid> [start|stop] <file> [<limit>] [mux]

Examples:

cli> uuid_displace 1a152be6-2359-11dc-8f1e-4d36f239dfb5 start /sounds/test.wav 60
cli> uuid_displace 1a152be6-2359-11dc-8f1e-4d36f239dfb5 stop /sounds/test.wav

uuid_display

Updates the display on a phone if the phone supports this. This works on some SIP phones right now including Polycom and Snom.

-USAGE: <uuid> [<display>]

This command makes the phone re-negotiate the codec. The SIP -> RTP Packet Size should be 0.020. If it is set to 0.030 on the SPA series phones it causes a DTMF lag. When DTMF keys are pressed on the phone they are can be seen on the fs_cli 4-6 seconds late.

uuid_dual_transfer

Transfer each leg of a call to different destinations.

 -USAGE: <uuid> <A-dest-exten>[/<A-dialplan>][/<A-context>] <B-dest-exten>[/<B-dialplan>][/<B-context>]

uuid_dump

Dumps all variable values for a session.

Usage: uuid_dump <uuid> [format]

Format options: XML (any others?)

uuid_early_ok

Stops the process of ignoring early media, i.e. if ignore_early_media=true it stops ignoring early media and responds normally.

Usage: uuid_early_ok <uuid>

uuid_exists

Checks whether a given UUID exists.

Usage: uuid_exists <uuid>

uuid_flush_dtmf

Flush queued DTMF digits

Usage: uuid_flush_dtmf <uuid>

uuid_fileman

Manage the audio being played into a channel from a sound file

Usage: uuid_fileman <uuid> <cmd:val>

Commands are:

  • speed:<+[step]>|<-[step]>
  • volume:<+[step]>|<-[step]>
  • pause
  • stop
  • truncate
  • restart
  • seek:<+[milliseconds]>|<-[milliseconds]> (1000ms is 1 second, 10000 for 10 seconds.)

Example to seek forward 30 seconds:

uuid_fileman 0171ded1-2c31-445a-bb19-c74c659b7d08 seek:+3000

(Or use the current channel via ${uuid}, e.g. in a bind_digit_action)

uuid_getvar

Get a variable from a channel.

Usage: uuid_getvar <uuid> <varname>

uuid_hold

Place a call on hold.

Usage:

uuid_hold <uuid>           place a call on hold
uuid_hold off <uuid>       switch off on hold
uuid_hold toggle <uuid>    toggles call-state based on current call-state

uuid_kill

Reset a specific <uuid> channel.

Usage: uuid_kill <uuid> [cause]

uuid_limit

Apply or change limit(s) on a specified uuid.

Usage: uuid_limit <uuid> <backend> <realm> <resource> [<max>[/interval]] [number [dialplan [context]]]

See also Limit

uuid_media

Reinvite FreeSWITCH out of the media path:

Usage: uuid_media [off] <uuid>

Reinvite FreeSWITCH back in:

Usage: uuid_media <uuid>

uuid_media_reneg

API command to tell a channel to send a re-invite with optional list of new codecs

Usage: uuid_media_reneg <uuid> <=><codec string>

Example: Adding the =PCMU makes the offered codec string absolute.

uuid_park

Park call

Usage: uuid_park <uuid>

uuid_preanswer

Preanswer a channel.

Usage: uuid_preanswer <uuid>

uuid_preprocess

Pre-process Channel

Usage: uuid_preprocess <>

uuid_recv_dtmf

Send DTMF digits to <uuid> set.

Usage: uuid_recv_dtmf <uuid> <dtmf digits>[@<tone_duration>]

Use the character w for a .5 second delay and the character W for a 1 second delay.

Default tone duration is 2000ms .

uuid_send_dtmf

Send DTMF digits.

Usage: uuid_send_dtmf <uuid> <dtmf digits>[@<tone_duration>]

Use the character w for a .5 second delay and the character W for a 1 second delay.

Default tone duration is 2000ms .

uuid_send_info

Send info to the endpoint

Usage:  uuid_send_info <uuid>

uuid_session_heartbeat

Usage: uuid_session_heartbeat <uuid> [sched] [0|<seconds>]

uuid_setvar

Set a variable on a channel. If value is omitted, the variable is unset.

Usage: uuid_setvar <uuid> <varname> [value]

uuid_setvar_multi

Set multiple vars on a channel.

Usage: uuid_setvar_multi <uuid> <varname>=<value>[;<varname>=<value>[;...]]

uuid_simplify

This command directs FreeSWITCH to remove itself from the SIP signaling path if it can safely do so

Usage:

uuid_simplify <uuid>

uuid_transfer

Transfers an existing call to a specific extension within a <dialplan> and <context>. Dialplan may be "xml" or "directory".

Usage:

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

The optional first argument will allow you to transfer both parties (-both) or only the party to whom <uuid> is talking.(-bleg)

NOTE: if the call has been bridged, and you want to transfer either sides of the call, then you will need to use <action application="set" data="hangup_after_bridge=false"/> (or the API equivalent). If it's not set, transfer doesn't really work as you'd expect, and leaves calls in limbo.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章