[SOLVED] Determine whether a channel was bridged

Hi. In a hangup handler, is there a way to determine whether a channel was ever bridged? BRIDGEPEER variable is cleared by this point.

I need this because Asterisk creates empty recording files even if MixMonitor was started with “b” option. I want to delete recordings for channels that were not bridged.

You could have your MONITOR_EXEC script remove empty files.

Does MONITOR_EXEC work with MixMonitor? I don’t see it in docs.

You can pass a command to MixMonitor according to the docs for 13.


I got confused with MONITOR_EXEC that’s for regular monitor sorry.

Hm, but again, how will I know if the channel was bridged? In most cases, MixMonitor will end as a result of channel being hung up.

Right, but you can test the state of the file in the script you execute from MixMonitor.

This is just an example of testing the file in bash.

if [[ -s $ASTMONDIR/$FILENAME.wav ]]
                echo "File exists and is not empty";
                echo "File is empty";

The problem is, the file is not zero-size. Asterisk writes something, probably file headers, and the content certainly depends on the audio format. Examining that is not trivial. There has to be an easier solution.

I’ve resolved it by marking both channels in pre-bridge handler (AEL code):


Now I can test the bridged variable in hangup handler of either channel.

1 Like