IMPORT From Bridged Local Channels Not Importing.

Home » Asterisk Users » IMPORT From Bridged Local Channels Not Importing.
Asterisk Users 2 Comments

Hi All

I have some users that can access outside world telephone number. They have external numbers to be reached as well.

Due to internal policy restrictions, they are not allowed to dial each other internal numbers. I Can’t change that.

When an internal user dials the external number for another internal user, I Dial(Local/…) the second user.

So I end up with two channels:
SIP/origin to Local/dest_ext_num;1
and Local/dest_ext_num;2 to SIP/destination

When the call is hung up (h extension), I need to grab the stats of both legs (SIP/origin and SIP/destination) of the call, so I use:

${RTPAUDIOQOS}

to grab the origin leg stats and

Set(MyDESTCH=${CUT(CDR(dstchannel),\;,1)}\;2)
Set(DESTCH=${IMPORT(${MyDESTCH},BRIDGEPEER)})
Set(STATS=${IMPORT(${DESTCH},CHANNEL(rtpqos,audio,all))})

to grab the stats for destination leg.

MyDESTCH is correctly set to “Local/dest_ext_num;2”
DESTCH receives “SIP/destination”
But STATS is “”

What am I missing here?
Is there a smarter way for grabbing these?

Another questions: when the call is hung, in which context is “h extension” run?
Always originator? Always destination? Depends on what?
What about in this scenario I describe (four contexts involved)?

Environment is: asterisk -V

Asterisk 11.7.0~dfsg-1ubuntu1 running on Ubuntu 14.04.5 LTS

Thanx for your time. Cheers

Ethy

2 thoughts on - IMPORT From Bridged Local Channels Not Importing.

  • You cannot get information from a channel that no longer exists. SIP/destination almost certainly no longer exists when the h exten runs on SIP/origin.

    I would suggest using hangup handlers [1]. Add a hangup handler to SIP/origin and SIP/destination. The handler will run on the respective channel when it hangs up. These two channels will hang up at different times so you can only get the current channel’s information. If you have to process both channel’s information then you are going to have to do that after both channels have hung up.

    Always originator? Always destination? Depends on what?

    In your case, the h exten is run by SIP/origin and Local/dest_ext_num;2. These channels executed dialplan when the call was originally placed. The h exten runs on the respective channel in the last context the channel executed dialplan. This is usually at the Dial application.

    Richard

    [1] https://wiki.asterisk.org/wiki/display/AST/Hangup+Handlers