How to get the channel ID string during call

Hi everyone,

I would like to use the mixmonitor command to record calls between peer A and peer B by issuing the command using AMI. The problem is that I don’t know how to get the channel during the call. The channel argument must be passed to mixmonitor. All I have is the peer name, e.g. bob. The command ‘core show channels’ lists the channel’s string as ‘SIP/peer-[number]’, e.g. ‘SIP/bob-00000042’. Having only the peer name, how can I get the ‘SIP/peer-[number]’ channel string dynamically during a call so I can pass it to mixmonitor?

Thanks

Use the event that you use to detect that the channel is up.

I am not sure how to do it? Which command please?

‘CoreShowChannels’ is listing all channels. I need to be able to get a specific channel, not the whole list. All I have is the peer name.

Thanks

A peer may have multiple calls up from it so as a result you have to somehow make that association yourself, Asterisk can’t know which one you really mean.

There is no command. Asterisk will send events to AMI unsolicited.

Yes but at least could I just have the list of the dynamic channel ID’s associated with a specific peer? As I said, ‘CoreShowChannels’ is listing the channels for all peers.

Thanks

There is no command to do that. People who use AMI generally want to be much more aware of which calls are in progress.

I think you may need to step back and say what you are really trying to do, as AMI may be the wrong solution.

Again, I need that dynamic channel ID to monitor (record) a call programmatically. What commands should my SIP client send to AMI to retrieve the dynamic channel ID of an ongoing call, so my client could pass that channel ID as an argument to the MixMonitor command to start recording the call?

Thanks

What I am trying to do is simply to be able to record an ongoing call, preferably by issuing an AMI command(s) from the SIP client…

AMI and SIP are different protocols. SIP peers can be both client and server in the same call. AMI is really intended for third party control, whereas your requirement is for first party control.

The normal way of invoking recording from a SP phone is use DTMF and features.conf.

If you really want to use AMI, and there is only ever one call per device, you could set the current channel for the device into a global variable named after the device.

2 Likes

Thank you very much!