Module use_case_play_file

Use-Case-Play-File is an example of a application which employs Idefisk as a interface to the Asterisk PBX.

Copyright © 2005-2006 Ericsson

Version: 1.0

Behaviour: gen_server.

Authors: Freek Sanders (freekisanders@gmail.com) [web site: http://www.freeksanders.tk].

Description

Use-Case-Play-File is an example of a application which employs Idefisk as a interface to the Asterisk PBX. Use-Case-Play-File is started by the Idefisk-Supervisor (see idefisk_supervisor) and communicates with a given Ext-Ast-Interface instance through its process id. Use-Case-Play-File uses Use-Case-Call (see use_case_call) to keep an intern record of created calls, legs and resources, as well as to receive messages.

Use Case Actions

Use-Case-Play-File is used to provide a Personal Greeting Service. A Personal Greeting Service entails that when a user calls a number, a sound file is played to him instead of the standard phone tones. The playing of the file continues untill the called party picks up, or a time-out occurs. The played sound file is based on the one that is being called. The matching of called telephone numbers to sound files which are to be played is set in the idefisk.conf file. When a user calls a number registered by the Asterisk PBX, a incoming call is generated, and the incoming_call/3 function is called (see use_case_play_file:incoming_call/3). As a reaction, the use case reserves a resource, and creates a new leg. When the resource has been reserved, it is attached to the incoming leg, after which the sound file is played. When the new leg is created, it is routed. If the resource stops playing, the file is played again. If the routed leg answers, the resource is stopped, detached and released. After this, both legs are attached, and a conversation between them can be started. If the routed leg does not answer after a certain time, the incoming call is released.


idefisk.conf Configuration

Set asterisk_ext_module to 'use_case_play_file' : {asterisk_ext_module, use_case_play_file}
Set asterisk_ext_module_start to 'true' : {asterisk_ext_module_start, true}
Set asterisk_ext_module_args to the following : {asterisk_ext_module_args, [NrFileMatchArr::nr_file_match_arr, DefaultFile::file(), NrDestMatchArr::nr_dest_match_arr, DefaultDest::destination()]}


(see the type definitions below)
More info about the format:

example:
[
[{"7900","ScorpionsWindofChange.mp3"},{"7929","blue-eyed-polar-bear"}],
"tt-monkeys",
[{"7900","195.169.102.69/9000161249034"},{"7929","195.169.102.69/9000161242704"}],
"195.169.102.69/9000161249034"
]


Final Note

Use-Case-Play-File has been implemented using the gen-server behaviour. This means that all function calls returning 'ok' (see below) are gen_server casts, which carry out their function asynchronously. An 'ok' does not mean success. If a function has success or not can only be derived from side-effects and messages printed to the command line.

For more information about the flow of events and an explanation of terms see ext_ast_interface.

Data Types

destination()

destination() = string()

file()

file() = gsm_file() | mp3_file()

gsm_file()

gsm_file() = string() | new_gsm_file()

mp3_file()

mp3_file() = string()

mp3_file always ends with ".mp3".

new_file()

new_file() = string() | new_gsm_file()

new_file always starts with "&".

new_gsm_file()

new_gsm_file() = new_file() | nil()

nr_dest_match()

nr_dest_match() = {Number::string(), Dest::destination()}

nr_dest_match_arr()

nr_dest_match_arr() = [nr_dest_match()]

nr_file_match()

nr_file_match() = {Number::string(), File::file()}

nr_file_match_arr()

nr_file_match_arr() = [nr_file_match()]

Function Index

call_msg/3A incoming call message.
die/0Destroys the use case.
get_item/3*
incoming_call/3A new caller has been detected by Asterisk.
leg_msg/5A incoming leg message.
resource_msg/5A incoming resource message.

Function Details

call_msg/3

call_msg(CallId::integer(), CallPid::pid(), Msg::string()) -> ok

A incoming call message.

Introduced in: 0.2

die/0

die() -> ok

Destroys the use case.

Introduced in: 0.2

get_item/3 *

get_item(Nr, Default, T) -> term()

incoming_call/3

incoming_call(CallId::integer(), OrigAddr::string(), DestAddr::string()) -> F::function()

A new caller has been detected by Asterisk. Ext-Ast-Interface alerts the use case to a incoming call. A incoming call means that both a call with id CallId and a leg with id 1 have been created.

Introduced in: 0.2

leg_msg/5

leg_msg(CallId::integer(), CallPid::pid(), LegId::integer(), LegPid::pid(), Msg::string()) -> ok

A incoming leg message.

Introduced in: 0.2

resource_msg/5

resource_msg(CallId::integer(), CallPid::pid(), RsrcId::integer(), RsrcPid::pid(), Msg::string()) -> ok

A incoming resource message.

Introduced in: 0.2