Wait until the call is hung up, then finish recording

Hi everybody.

The problem I’m trying to solve is: accept the call on my 3G modem, start recording, wait until the other party hangs up and stop recording.

I’ve come to this a little ugly solution:

[dongle-incoming]
exten => _+X.,1,NoOp(Call from dongle {CALLERID}. Start call recording.) same => n,MixMonitor(/home/pi/recordings/{UNIQUEID}.wav)
same => n,answer()
same => n,Wait(86400)
same => n,StopMixMonitor()
same => n,NoOp(Call from dongle ${CALLERID} ended. Stop call recording.)
same => n,hangup()

As you see, I’ve put a Wait application (which basically waits for 24 hours), as I couldn’t find a better way to handle the hang-ups. I tried to use “hangup_handler_push” but I would get some Gosub errors.

I’m not an expert in Asterisk, so I’m not really sure what that is. How can I modify this config dialplan in order to handle hang-ups in a more “professional” way?

What is the purpose of this code? There is no second leg. Either you write something like a little app, or connect to some other phone. In both cases you do not need to explicitly call StopMixMonitor.

The purpose is to pick up a call and record it until the caller hangs up.

I’ve also just found the WaitUntil dialplan application, but haven’t seen any examples

In that case you do not need any special programming. Just call MixMonitor and the rest happens automatically.

This part is not needed, have you test it without it

Yes, I have. Asterisk immediately terminates the call after having picked it up

As I mentioned earlier, I have already done that. I was only curious if there is a more elegant way to implement the same thing

Yes you re right, I did not check your dial plan correctly , if remove same => n,Wait(86400) it will hang up the call almost immediately. Using wait app is fine only limitation is that you re limitting the call to 86400 seconds, which I think it is enough time, anyway there are many other ways, like sending the call to confbridge and record the conference, or also use record() app with the k option

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.