phpasteriskagidialplan

Hangup an Asterisk call by pressing any keyboard key


I have be able to hangup an asterisk call (if it can be named "call") by pressing any keyboard button. Flow looks like this:

(Call file is copied to outbound directory) ->
Asterisk detects it and read call file ->
in call file there is instruction to run context "test" in dialplan ->
in context "test" there is instruction to run AGI(PHP) script ->
in AGI script there is command "EXEC PLAYBACK test_music"

Dialplan:

exten => s,1, Answer()
exten => s,n, agi(test_agi.agi)
exten => s,n, Hangup

AGI (test_agi.agi):

#!/usr/bin/php -q       
<?php
require'phpagi.php';    
set_time_limit(60);     
ob_implicit_flush(false);

# create file handles if needed
if (!defined('STDIN'))
{
   define('STDIN', fopen('php://stdin', 'r'));
}
if (!defined('STDOUT'))
{
    define('STDOUT', fopen('php://stdout', 'w'));
}
if (!defined('STDERR'))
{
   define('STDERR', fopen('php://stderr', 'w'));
}

fwrite(STDOUT, "EXEC PLAYBACK test_music '79#'\n"); //79# interruption marks

So as you can see, dialplan and AGI file are as simplest as may be. The point is I know only the way to allow playback to be interrupted by a DTMF digit (as in AGI code -comment above) by pressing digits on phone. But thats it.

Maybe someone know how to end a call (and stop playback of course) when any keyboard key is pressed?

Is it even possible?

Thanks for help!


Solution

  • On key pressed create http GET request to some script.

    In script use

    asterisk -rx "channel request hangup CHANNEL_NAME_HERE"
    

    Sure you need do some staff for track channel used by your station, for example via AMI events.