[Freeswitch-users] voicemail flow

Michael Collins msc at freeswitch.org
Tue Nov 20 23:35:43 MSK 2012


This question is a bit broad, but I'll add some info that I hope is useful.

When mod_voicemail.c is first loaded (or when it is re-loaded) then it will
read from voicemail.conf.xml to get its base configuration. That
configuration file defines voicemail "profiles" that can be used. The
example configuration provides a "default" profile that defines things like
the menu keys, skip greeting key, operator extension, etc. This "default"
value corresponds to this line from conf/dialplan/default.xml where the
Local_Extension sends a call to voicemail:

 <action application="bridge" data="loopback/app=voicemail:default
${domain_name} ${dialed_extension}"/>

You could define other profiles if you so desire and then give them other
names.

The sounds.xml and tts.xml files both accomplish the same thing: they
define phrase macros that get played while a caller is connected to
voicemail. The sounds.xml file uses the pre-recorded sound files to stitch
together phrases whereas tts.xml uses a text-to-speech engine to accomplish
the same purpose. There really is no reason to use tts.xml unless you need
a voice or language where recordings are not available but for which you do
have a TTS engine.

The best way to see what's happening with mod_voicemail is to watch the
console debug log while you dial in and check your voicemail. The console
log will display what's going on. You'll notice that by far you see things
like "switch_ivr_play_say.c" and "switch_rtp.c". Consider this snippet of
me logging in to mailbox 1001:

2012-11-20 12:09:05.286038 [DEBUG] switch_rtp.c:3606 Correct ip/port
confirmed.
EXECUTE sofia/internal/1001 at 10.15.64.229 voicemail(check default
10.15.64.229)
2012-11-20 12:09:06.206030 [DEBUG] switch_ivr_play_say.c:67 No language
specified - Using [en]
2012-11-20 12:09:06.446031 [DEBUG] switch_ivr_play_say.c:67 No language
specified - Using [en]
2012-11-20 12:09:06.446031 [DEBUG] switch_ivr_play_say.c:244 Handle
play-file:[voicemail/vm-enter_id.wav] (en:en)
2012-11-20 12:09:06.446031 [DEBUG] switch_ivr_play_say.c:1309 Codec
Activated L16 at 16000hz 1 channels 20ms
2012-11-20 12:09:08.406030 [DEBUG] switch_ivr_play_say.c:1682 done playing
file /usr/local/freeswitch/sounds/en/us/callie/voicemail/vm-enter_id.wav
2012-11-20 12:09:08.526030 [DEBUG] switch_ivr_play_say.c:244 Handle say:[#]
(en:en)
2012-11-20 12:09:08.526030 [DEBUG] switch_ivr_play_say.c:1309 Codec
Activated L16 at 16000hz 1 channels 20ms
2012-11-20 12:09:09.186029 [DEBUG] switch_ivr_play_say.c:1682 done playing
file file_string://ascii/35.wav
2012-11-20 12:09:09.366029 [DEBUG] switch_rtp.c:3809 RTP RECV DTMF 1:1440
2012-11-20 12:09:09.786028 [DEBUG] switch_rtp.c:3809 RTP RECV DTMF 0:1120
2012-11-20 12:09:09.986027 [DEBUG] switch_rtp.c:3809 RTP RECV DTMF 0:1120
2012-11-20 12:09:10.526029 [DEBUG] switch_rtp.c:3809 RTP RECV DTMF 1:1280
2012-11-20 12:09:11.166034 [DEBUG] switch_rtp.c:3809 RTP RECV DTMF #:1040
2012-11-20 12:09:11.166034 [DEBUG] switch_ivr_play_say.c:67 No language
specified - Using [en]
2012-11-20 12:09:11.166034 [DEBUG] switch_ivr_play_say.c:244 Handle
play-file:[voicemail/vm-enter_pass.wav] (en:en)
2012-11-20 12:09:11.166034 [DEBUG] switch_ivr_play_say.c:1309 Codec
Activated L16 at 16000hz 1 channels 20ms
2012-11-20 12:09:13.106029 [DEBUG] switch_ivr_play_say.c:1682 done playing
file /usr/local/freeswitch/sounds/en/us/callie/voicemail/vm-enter_pass.wav
2012-11-20 12:09:13.226027 [DEBUG] switch_ivr_play_say.c:244 Handle say:[#]
(en:en)
2012-11-20 12:09:13.226027 [DEBUG] switch_ivr_play_say.c:1309 Codec
Activated L16 at 16000hz 1 channels 20ms
2012-11-20 12:09:13.886031 [DEBUG] switch_ivr_play_say.c:1682 done playing
file file_string://ascii/35.wav
2012-11-20 12:09:14.086030 [DEBUG] switch_rtp.c:3809 RTP RECV DTMF 1:1280
2012-11-20 12:09:14.586029 [DEBUG] switch_rtp.c:3809 RTP RECV DTMF 0:1280
2012-11-20 12:09:14.746031 [DEBUG] switch_rtp.c:3809 RTP RECV DTMF 0:800
2012-11-20 12:09:15.306037 [DEBUG] switch_rtp.c:3809 RTP RECV DTMF 1:1200
2012-11-20 12:09:15.766043 [DEBUG] switch_rtp.c:3809 RTP RECV DTMF #:1200

Notice that there's no reference to "mod_voicemail.c" in there. That's
because mod_voicemail uses FS core APIs to perform basic functions like
playing sound files and collecting digits from the caller. That's ok - once
you get into the source code you'll start to see the connection. I'll get
you started. Open up src/mod/application/mod_voicemail/mod_voicemail.c and
find the function named "voicemail_check_main" near line 1850. When you log
in to check your voicemail this function controls the whole session from
the time you log in to the time you hang up. The switch statement near line
1903 checks the state and acts accordingly. Look at all the case statements
- they handle the various states, like "this person needs to log in"
(VM_CHECK_AUTH) or "play the messages in this folder"
(VM_CHECK_PLAY_MESSAGES).

I'm afraid I can't really go into any more detail without spending a lot of
time going line-by-line and translating the source code into plain-language
equivalents. However, I think you'll find that you are quite capable doing
this with a little practice and a lot of test calls. The FreeSWITCH source
code is extremely clean and in many cases is self-documenting. Many non-C
programmers are able to discern what a piece of code is doing simply by
looking at it and observing what it does when a call is in progress. Here's
a tip: you can add your own debug print lines to the code and recompile and
reload mod_voicemail. Look for places in the code where you see occurrences
of "switch_log_printf" and I think you'll be able to figure it out.

Last tip: to recompile mod_voicemail (or any other module) just go to the
root of the freeswitch source and type:
make mod_voicemail-install

That's it! Then go to fs_cli and type "reload mod_voicemail" and you're
ready to try out your changes.

I hope this helps all those who are curious about diving into the code.
It's not too scary as long as you don't mess with it on a production
machine. ;)

-Michael

P.S. - If you want to learn more about phrase macros then I highly
recommend chapter six of the original FreeSWITCH book. I cover part of the
sounds.xml phrase file, specifically the macro that handles pluralizing the
phrase "you have x new message(s)".



On Tue, Nov 20, 2012 at 8:18 AM, Archana Venugopan
<a.venugopan at mundio.com>wrote:

>  Hi,****
>
> ** **
>
> While dialing voicemail, mod_voicemail.c file plays the primary role. I
> know it considers sounds.xml,tts.xml(/usr/local/freeswitch/conf/lang/en/vm)
> and voicemail.conf.xml (/usr/local/freeswitch/conf/autoload_configs).****
>
> ** **
>
> Once the c file is hit after that what happens and how the flow goes? Can
> anyone please explain? As am not that good in C, I don’t understand the
> flow.****
>
> ** **
>
> Thanks.****
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> 
> 
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>


-- 
Michael S Collins
Twitter: @mercutioviz
http://www.FreeSWITCH.org
http://www.ClueCon.com
http://www.OSTAG.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20121120/863e793b/attachment-0001.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list