Cisco as5400 can't play promt to leg_incoming

Version 1
    This document was generated from CDN thread

    Created by: Marat Rabidinov on 29-09-2010 04:38:13 AM
    Tcl script makes call to redirect number.
    If destination line is busy, tcl script must play promt before record.
    I need that rtp flows around the cisco as5400 and when destination is busy or down, rtp flow through cisco as5400, and tcl script can play promt in leg_incoming. But client on originate phone doesn't hear anything.
    Media file is g711ulaw codec.
     
    proc init { } {

            global beep ani dnis password param status creditTime ExtNum callinfo rtp_through

            set param(interruptPrompt) true
            set param(abortKey) *
            set param(terminationKey) #
            set param(dialPlan) true

            set callinfo(alertTime) 15

            set rtp_through 0

            if { [infotag get cfg_avpair_exists aaa-password] } {
                    set password [infotag get cfg_avpair aaa-password]
                    puts "DEBUG: Password for aaa - $password"
            } else {
                    set password "123"
                    puts "DEBUG: Password for aaa set default - $password"
            }
    }

    proc act_Setup { } {
            puts "DEBUG: Start act_Setup"
            global beep ani dnis password param status creditTime ExtNum rtp_through

            set ani [infotag get leg_ani]
            set dnis [infotag get leg_dnis]

            aaa authorize $dnis $password $ani $dnis leg_all
            puts "DEBUG: Stop act_Setup"
    }

    proc act_Authorized { } {
            puts "DEBUG: Start act_Authorized"
            global beep ani dnis password param status creditTime ExtNum callinfo rtp_through

            set status [infotag get evt_status]
            if { $status == "ao_000" } {
                    puts "DEBUG: Authorization success"
                    set creditTime [infotag get aaa_avpair h323-credit-time]
                    set ExtNum [infotag get aaa_avpair h323-redirect-number]
                    leg proceeding leg_incoming
                    leg setup $ExtNum callinfo leg_incoming
                    fsm setstate PLACECALL
            } else {
                    puts "DEBUG: Authorization failed, status - $status"
                    act_Cleanup
            }
            puts "DEBUG: Stop act_Authorized"
    }

    proc act_CallSetupDone { } {
            puts "DEBUG: Start act_CallSetupDone"
            global beep ani dnis password param status creditTime ExtNum rtp_through

            set status [infotag get evt_status]
            if { $status == "ls_000" } {
                    puts "DEBUG: Credit Time = $creditTime"
                    timer start leg_timer $creditTime leg_incoming
            } else {
                    leg connect leg_incoming
                    puts "DEBUG: Play Promt before Record"
                    media play leg_incoming %s1000 flash:welcome.au
                    fsm setstate RECORD
            }
            puts "DEBUG: Stop act_CallSetupDone"
    }

    proc act_Record { } {
            global dnis

            set recordInfo(codec) g711ulaw
            set recordInfo(finalSilence) 0
            set recordInfo(dtmfTerm) enable
            set recordInfo(maxDuration) 30000
            set recordInfo(fileFormat) au
            set recordInfo(beep) beep

            set filename $dnis

            media record leg_incoming -p recordInfo -m %b tftp://172.0.21.1/$filename
            fsm setstate CALLDISCONNECT
    }

    proc act_Cleanup { } {
            puts "DEBUG: Start act_Cleanup"
            set status [infotag get evt_status]
            puts "DEBUG: Status - $status"
            call close
            puts "DEBUG: Stop act_Cleanup"
    }

    requiredversion 2.0
    init

    # State Machine
    set fsm(any_state,ev_disconnected) "act_Cleanup same_state"
    set fsm(CALL_INIT,ev_setup_indication) "act_Setup AUTHORIZATION"
    set fsm(AUTHORIZATION,ev_authorize_done) "act_Authorized PLACECALL"
    set fsm(RECORD,ev_media_done) "act_Record CALLDISCONNECT"
    set fsm(PLACECALL,ev_setup_done) "act_CallSetupDone CALLACTIVE"
    set fsm(CALLACTIVE,ev_disconnected) "act_Cleanup CALLDISCONNECT"
    set fsm(CALLACTIVE,ev_leg_timer) "act_Cleanup same_state"
    set fsm(CALLDISCONNECT,ev_media_done) "act_Cleanup same_state"
    set fsm(CALLDISCONNECT,ev_disconnect_done) "act_Cleanup same_state"
    set fsm(CALLDISCONNECT,ev_leg_timer) "act_Cleanup same_state"
    set fsm(CALLDISCONNECT,ev_recorder) "act_Cleanup same_state"

    fsm define fsm CALL_INIT
     
    P.S. Sorry, for my poor English.

    Subject: RE: Cisco as5400 can't play promt to leg_incoming
    Replied by: Raghavendra Gutty Veeranagappa on 29-09-2010 06:28:00 AM
    Hi Marat Rabidinov,
     
    looks like leg connect is not issued before leg setup, please check status code is "ls_007" in callSetupDone procedure when destination is busy
     
    please provide logs by enabling below debugs
    Deb voip application tclcommands
    Deb voip application states
    Deb voip application script
    deb voip app media
     
    Thanks,
    Raghavendra

    Subject: RE: Cisco as5400 can't play promt to leg_incoming
    Replied by: Marat Rabidinov on 30-09-2010 04:12:27 AM
    Hi Raghavendra

    looks like leg connect is not issued before leg setup,


    Yes, I don't want to leg connect leg_incoming before place call, because then RTP will flow through Cisco AS5400.
     
    My deployment model is:


    Phone1 -----PTSN
                       |
                       |
                Softswitch ----H323 trunk-----Cisco AS5400.
                       |
                       |
    Phone2-----PTSN



     
    Cisco as5400 is used just for AAA, TCL scripting because Softswitch can't do it.
    And RTP must flow just Phone1 ------- Softswitch -------- Phone2, exclude Cisco as5400 - when call active. It's working.
    I have it working now.
     
    I need:
    RTP flow through the Cisco as5400, just when Phone2 is down or busy, and Cisco as5400 plays promt to Phone1 before record.
    That's why I try "leg connect leg_incoming" when status is not ls_000:
     
     1
     2           if { $status == "ls_000" } {
     3                   puts "DEBUG: Credit Time = $creditTime"
     4                   timer start leg_timer $creditTime leg_incoming
     5           } else {
     6                   leg connect leg_incoming
     7                   puts "DEBUG: Play Promt before Record"
     8                   media play leg_incoming %s1000 flash:welcome.au
     9                   fsm setstate RECORD
    10           }


     
    Log is attached.
     
    Thanks

    Subject: RE: Cisco as5400 can't play promt to leg_incoming
    Replied by: Raghavendra Gutty Veeranagappa on 30-09-2010 07:06:31 AM
    Hi Marat Rabidinov,
     
    Thanks for sharing the logs, from the logs we found that codec is not specified for the dial-peer
    please check below sample to specify the codec to dial-peer
     
    dial-peer voice 10 voip
    destination-pattern 3¿
    session target ipv4:<ipaddress>
    codec g711ulaw
    no vad
     
     
    Thanks,
    Raghavendra

    Subject: RE: Cisco as5400 can't play promt to leg_incoming
    Replied by: Marat Rabidinov on 30-09-2010 03:29:02 PM
    Hi Marat Rabidinov,
     
    Thanks for sharing the logs, from the logs we found that codec is not specified for the dial-peer
    please check below sample to specify the codec to dial-peer
     
    dial-peer voice 10 voip
    destination-pattern 3¿
    session target ipv4:<ipaddress>
    codec g711ulaw
    no vad
     
     
    Thanks,
    Raghavendra

    Thank you for assist!
    I edited config:
     1
     2dial-peer voice 400 voip
     3 destination-pattern ......
     4 voice-class h323 5
     5 session target ipv4:192.168.201.2
     6 codec g711ulaw
     7 no vad
     8 
     9dial-peer voice 150 voip
    10 service important_call
    11 rtp payload-type cisco-codec-fax-ack 124
    12 rtp payload-type nte 97
    13 voice-class aaa 1
    14 session target ipv4:192.168.201.2
    15 incoming called-number 906979
    16 dtmf-relay rtp-nte
    17 codec g711ulaw
    18 no vad

    But it keeps a silent. If I insert into script "leg connect leg_incoming" before
    1
    2                leg proceeding leg_incoming
    3                leg setup $ExtNum callinfo leg_incoming

    Everything is fine. I can hear promt before record. But then rtp will flow through the Cisco as5400, and it will waste system resource of Cisco as5400. It will be irrationally, because active call can flow around the cisco as5400, and it will work.

    Subject: RE: Cisco as5400 can't play promt to leg_incoming
    Replied by: Yaw-Ming Chen on 30-09-2010 04:00:21 PM
    Maybe you can try
     
    leg proceeding leg_incoming
    leg connect leg_incoming

    leg setup $ExtNum callinfo
     
    Do the leg setup without providing incoming leg to destiation for interworking.
     
    But later you need to do "connection create" you you need to bridge two legs. Looks like you don't need to bridge two legs.
     
    Thanks !

    Subject: RE: Cisco as5400 can't play promt to leg_incoming
    Replied by: Marat Rabidinov on 30-09-2010 05:48:57 PM
    Maybe you can try
     
    leg proceeding leg_incoming
    leg connect leg_incoming

    leg setup $ExtNum callinfo
     
    Do the leg setup without providing incoming leg to destiation for interworking.
     
    But later you need to do "connection create" you you need to bridge two legs. Looks like you don't need to bridge two legs.
     
    Thanks !

    In this case, when call will be active RTP traffic will flow through Cisco as5400. But, as I said before, if call active - rtp must flow exclude the cisco as5400 ( Phone1 ---- Softswitch ---- Phone2).
     
    My question is:
    "How can I connect to leg_incoming after:
    leg setup $ExtNum callinfo leg_incoming - if destination phone (phone2) will be down or busy, and script will get status not ls_000.
    In my script:
            if { $status == "ls_000" } {
                    puts "DEBUG: Credit Time = $creditTime"
                    timer start leg_timer $creditTime leg_incoming
            } else {
                    leg connect leg_incoming

                    puts "DEBUG: Play Promt before Record"
                    media play leg_incoming %s1000 flash:welcome.au
                    fsm setstate RECORD
            }
     
    But I cant hear promt.
     

    Subject: RE: Cisco as5400 can't play promt to leg_incoming
    Replied by: Yaw-Ming Chen on 30-09-2010 06:00:27 PM
    Just like to clarify that when you use leg setup $ExtNum callinfo  the RTP still go thru ?
     
    Note this is no leg_incoming in setup.
     
    Thanks !