This PDF is generated from authoritative online content, and
is provided for convenience only. This PDF cannot be used
for legal purposes. For authoritative understanding of what
is and is not supported, always use the online content. To
copy code samples, always use the online content.
Asterisk as a Media Server
Integration Reference Manual
8/27/2024
Asterisk as a Media Server
Contents
1 Asterisk as a Media Server
1.1 Con@guring Asterisk
1.2 Con@guring DN Objects
Asterisk as a Media Server
Integration Reference Manual 2
In order for Asterisk to work as a media server integrated with SIP Server, you must enhanced the
Asterisk dialing plan with several Genesys macros and global variables as described in this section.
Conguring Asterisk
Dialing Plan Global Variables
You must add the following list of global variables to the [globals] section of the Asterisk dialing
plan.
SIP_PREFIX=.*sip:.*@.*:[0-9]+.*
DIG_PRMT_REGEX=silence/1?[0-9]
FIND_CLT_REGEX=${SIP_PREFIX}play=[ ]*(music/collect).*
FIND_PLY_REGEX=${SIP_PREFIX}play=[ ]*([^>\;]*)[>\;].*
FIND_REP_REGEX=${SIP_PREFIX}repeat=[ ]*([^>\;]*)[>\;].*
FIND_REC_REGEX=${SIP_PREFIX}record=[ ]*([^>\;]*)[>\;].*
FIND_COF_REGEX=.*sip:conf=(.*)@.*:[0-9]+.*
DEFAULT_FILE_TO_PLAY= /var/lib/asterisk/moh/fpm-calm-river
Variable DEFAULT_FILE_TO_PLAY points to the default music @le that is played for the Genesys
treatments. In the example, above it refers to the voice @le, which comes with Asterisk (if Asterisk is
installed in the standard directory). You can change this reference to any other @le in the actual
deployment.
Dialing Plan Macro to Perform Genesys Treatments
You must add this treatment to the Asterisk dialing plan to perform Genesys treatments.
[macro-treatment]
;
; ${ARG1} - SIP_HEADER(To)
;
; IF treatment == CollectDigits
;
exten => s, 1, Answer
exten => s, 2, Set(collect=$["${ARG1}":"${FIND_PLY_REGEX}"])
exten => s, 3, GotoIf($[$["${collect}"="music/collect"] | $["${collect}"="music/
silence"]] ? 15 : 20)
exten => s, 15, macro(get-digits,${collect})
exten => s, 16, Goto(s,99)
;
; ELSE IF treatment == record
;
exten => s, 20, Set(rec_file=$["${ARG1}":"${FIND_REC_REGEX}"])
exten => s, 21, Set(ply_file=$["${ARG1}":"${FIND_PLY_REGEX}"])
exten => s, 22, GotoIf($[${LEN(${rec_file})} != 0] ? 30 : 40)
;
; Recording Treatment
exten => s, 30, GotoIf($[${LEN(${ply_file})} = 0] ? 32 : 31)
Asterisk as a Media Server
Integration Reference Manual 3
exten => s, 31, Playback(${ply_file}) ;
exten => s, 32, Record(genesys-rec-${rec_file}.wav) ;can't detect|report dtmf
exten => s, 33, Goto(s,98)
;
; ELSE
; Play treatment
exten => s, 40, GotoIf($[${LEN(${ply_file})} = 0] ? 41 : 43)
exten => s, 41, Set(ply_file=${DEFAULT_FILE_TO_PLAY})
exten => s, 42, Goto(s,44)
exten => s, 43, Set(ply_count=$["${ARG1}":"${FIND_REP_REGEX}"])
exten => s, 44, GotoIf($[$[${LEN(${ply_count})} = 0] | $["$ply_count" = "forever"]]?
50 : 60)
; Playback forever
exten => s, 50, Playback(${ply_file})
exten => s, 51, GotoIf($[${PLAYBACKSTATUS}=FAILED] ? 52 : 50) ;Goto(s, 50)
exten => s, 52, Goto(s, 99)
; Counted playback
; here probably possible to use background()
exten => s, 60, Playback(${ply_file}) ; Playback
exten => s, 61, Set(ply_count=$[${ply_count} - 1])
exten => s, 62, GotoIf($[$[${ply_count} > 0] & $[${PLAYBACKSTATUS} = SUCCESS]] ? 61 :
98)
exten => s, 98, Hangup
exten => s, 99, NoOp(end-withot-hagup)
Dialing Plan Macro to Collect DTMF Digits
You must add this treatment to the Asterisk dialing plan to collect DTMF digits. Replace <COLLECT-
MESSAGE-PLACEHOLDER> in the macros below with the name of the @le to play to announce digit
collection.
[macro-get-digits]
exten => s,1, GotoIf($[$[${ARG1}=music/collect] | $[${ARG1}=music/silence]] ? 2 : 3)
exten => s,2, Set(ARG1=silence/2)
exten => s,3,Read(dncdigits,<COLLECT-MESSAGE-PLACEHOLDER>,1,s)
exten => s,4,SendText(Signal=${dncdigits})
exten => s,5, Goto(macro-get-digits,s,3)
Dialing Plan Macro to Create a Conference
You must add this treatment to the Asterisk dialing plan to organize a conference using the Asterisk
MeetMe application.
[macro-conf]
exten => s, 1, Set(conf_id=$["${ARG1}":"${FIND_COF_REGEX}"])
exten => s, 2, NoOp(${ARG1})
exten => s, 3, GotoIf($[${LEN(${conf_id})} != 0] ? 4 : 20)
exten => s, 4, Set(rec_file=$["${ARG1}":"${FIND_REC_REGEX}"])
exten => s, 5, GotoIf($[${LEN(${rec_file})} != 0] ? 6 : 8)
exten => s, 6, MeetMe(${conf_id},drq)
exten => s, 7, Goto(s,20)
exten => s, 8, MeetMe(${conf_id},dq)
exten => s, 20, NoOp()
Asterisk as a Media Server
Integration Reference Manual 4
Integrating Genesys Macros into the Dialing Plan
The Asterisk dialing plan all macros provided above. This section suggests one possible way to do
that. Add the following macro in the dialing plan:
[moh_conf_treatment]
include => macro-treatment
exten => annc, 1, macro(treatment,${SIP_HEADER(To)})
exten => _co[n]f=., 1, macro(conf,${SIP_HEADER(To)})
You must include this macro into the context used to process agent calls. If there is no special context
created for this purpose, you must include macro into the default dialing plan context.
[default]
include => moh_conf_treatment
Media Files
Media @les used for the Genesys treatments should be placed into the standard Asterisk sounds
directory. The default location of this directory is:
/var/lib/asterisk/sounds
Call recordings created by Asterisk are also stored in this directory. There are two types of recordings,
which can be activated by SIP Server:
Regular (proxy mode)
Emergency
By default, names of the recordings made in regular mode are pre@xed with genesys-rec. Names
of the emergency recordings start with the meetme-conf-rec pre@x. In both cases, the name pre@x is
followed by a conference ID.
Conguring DN Objects
SIP Server utilizes media services through the DNs of type Voice over IP Service con@gured under
the Switch object. The Voice over IP Service DNs have a service-type con@guration option,
which de@nes the kind of service this DN can provide. SIP Server selects an appropriate DN when the
client application requests a media service.
When you use Asterisk as a media server for SIP Server, you should con@gure the Voice over IP
Service DNs with the following service-type values in the SIP Server Switch object:
mcu
treatment
recorder
music
For information about con@guring DNs for di?erent types of services, see the "SIP Device
Asterisk as a Media Server
Integration Reference Manual 5
Con@guration" topic of the SIP Server Deployment Guide.
Asterisk as a Media Server
Integration Reference Manual 6