2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Support PJSIP channels in Asterisk

This commit is contained in:
Adam Zammit
2024-03-22 13:53:12 +11:00
parent 4f9df1d392
commit e669ac261e

View File

@@ -102,14 +102,14 @@ class voip {
$chans = array(); $chans = array();
foreach ($c as $s) foreach ($c as $s)
{ {
if(preg_match("{Event: Status.*Channel: ((SIP/|IAX2/)[0-9a-zA-Z-]+).*BridgedChannel: ((SIP/|IAX2/)[/0-9a-zA-Z-]+)}is",$s,$regs)) if(preg_match("{Event: Status.*Channel: ((SIP/|PJSIP/|IAX2/)[0-9a-zA-Z-]+).*BridgedChannel: ((SIP/|PJSIP/|IAX2/)[/0-9a-zA-Z-]+)}is",$s,$regs))
{ {
//print T_("Channel: SIP/") . $regs[1] . " BridgedChannel " . $regs[2] . "\n"; //print T_("Channel: SIP/") . $regs[1] . " BridgedChannel " . $regs[2] . "\n";
$ccs = explode('-',$regs[1]); $ccs = explode('-',$regs[1]);
$chan = $ccs[0]; $chan = $ccs[0];
$chans[$chan] = array($regs[1],$regs[3]); $chans[$chan] = array($regs[1],$regs[3]);
} }
else if(preg_match("{Event: Status.*Channel: ((SIP/|IAX2/)[0-9a-zA-Z-]+)}is",$s,$regs)) else if(preg_match("{Event: Status.*Channel: ((SIP/|PJSIP/|IAX2/)[0-9a-zA-Z-]+)}is",$s,$regs))
{ {
//print T_("Channel: ") . $regs[1] . "\n"; //print T_("Channel: ") . $regs[1] . "\n";
$ccs = explode('-', $regs[1]); $ccs = explode('-', $regs[1]);
@@ -545,7 +545,7 @@ class voipWatch extends voip {
/** /**
* The call is ringing * The call is ringing
*/ */
if (preg_match("{Event: DialBegin.*Channel: ((SIP/|IAX2/)[0-9]+)}is",$line,$regs)) if (preg_match("{Event: DialBegin.*Channel: ((SIP/|PJSIP/|IAX2/)[0-9]+)}is",$line,$regs))
{ {
list($call_id,$case_id) = $this->getCallId($regs[1]); list($call_id,$case_id) = $this->getCallId($regs[1]);
if ($call_id != 0) if ($call_id != 0)
@@ -557,7 +557,7 @@ class voipWatch extends voip {
/** /**
* The call has been answered * The call has been answered
*/ */
else if (preg_match("{Event: Bridge.*Channel1: ((SIP/|IAX2/)[0-9]+)}is",$line,$regs)) else if (preg_match("{Event: Bridge.*Channel: ((SIP/|PJSIP/|IAX2/)[0-9]+)}is",$line,$regs))
{ {
list($call_id,$case_id) = $this->getCallId($regs[1]); list($call_id,$case_id) = $this->getCallId($regs[1]);
if ($call_id != 0) if ($call_id != 0)
@@ -569,7 +569,7 @@ class voipWatch extends voip {
/** /**
* The call has been hung up * The call has been hung up
*/ */
else if (preg_match("{Event: Hangup.*Channel: ((SIP/|IAX2/)[0-9]+).*Cause: ([0-9]+)}is",$line,$regs)) else if (preg_match("{Event: Hangup.*Channel: ((SIP/|PJSIP/|IAX2/)[0-9]+).*Cause: ([0-9]+)}is",$line,$regs))
{ {
list($call_id,$case_id) = $this->getCallId($regs[1]); list($call_id,$case_id) = $this->getCallId($regs[1]);
// print_r($regs); // print_r($regs);
@@ -591,21 +591,39 @@ class voipWatch extends voip {
/** /**
* The status of an extension has changed to unregistered * The status of an extension has changed to unregistered
*/ */
else if (preg_match("{Event: PeerStatus.*Peer: ((SIP/|IAX2/)[0-9]+).*PeerStatus: Unregistered}is",$line,$regs)) else if (preg_match("{Event: PeerStatus.*Peer: ((SIP/|PJSIP/|IAX2/)[0-9]+).*PeerStatus: Unregistered}is",$line,$regs))
{ {
print T_("Unregistered") . T_(" Extension ") . $regs[1] . "\n"; print T_("Unregistered") . T_(" Extension ") . $regs[1] . "\n";
$this->setExtensionStatus($regs[1],false); $this->setExtensionStatus($regs[1],false);
} }
/** /**
* The status of an extension has changed to unreachable
*/
else if (preg_match("{Event: PeerStatus.*Peer: ((SIP/|PJSIP/|IAX2/)[0-9]+).*PeerStatus: Unreachable}is",$line,$regs))
{
print T_("Unreachable") . T_(" Extension ") . $regs[1] . "\n";
$this->setExtensionStatus($regs[1],false);
}
/**
* The status of an extension has changed to registered * The status of an extension has changed to registered
*/ */
else if (preg_match("{Event: PeerStatus.*Peer: ((SIP/|IAX2/)[0-9]+).*PeerStatus: Registered}is",$line,$regs)) else if (preg_match("{Event: PeerStatus.*Peer: ((SIP/|PJSIP/|IAX2/)[0-9]+).*PeerStatus: Registered}is",$line,$regs))
{ {
print T_("Registered") . T_(" Extension ") . $regs[1] . "\n"; print T_("Registered") . T_(" Extension ") . $regs[1] . "\n";
$this->setExtensionStatus($regs[1],true); $this->setExtensionStatus($regs[1],true);
} }
/**
* The status of an extension has changed to reachable
*/
else if (preg_match("{Event: PeerStatus.*Peer: ((SIP/|PJSIP/|IAX2/)[0-9]+).*PeerStatus: Reachable}is",$line,$regs))
{
print T_("Reachable") . T_(" Extension ") . $regs[1] . "\n";
$this->setExtensionStatus($regs[1],true);
}
//print $line . "\n\n"; //print $line . "\n\n";
$line = ""; $line = "";
} }