Do not autoanswer if an analog or BRI goes off-hook.

Put the proper dial tones (and silences).


git-svn-id: http://yate.null.ro/svn/yate/trunk@2504 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2009-03-02 18:49:45 +00:00
parent f9f7a3ab86
commit 1050299bf2
1 changed files with 12 additions and 9 deletions

View File

@ -45,7 +45,7 @@ function setState($newstate)
$state = $newstate; $state = $newstate;
$m = new Yate("chan.attach"); $m = new Yate("chan.attach");
$m->params["id"] = $ourcallid; $m->params["id"] = $ourcallid;
$m->params["source"] = "tone/specdial"; $m->params["source"] = "tone/dial";
$m->params["consumer"] = "wave/record/-"; $m->params["consumer"] = "wave/record/-";
$m->params["maxlen"] = 320000; $m->params["maxlen"] = 320000;
$m->params["notify"] = $ourcallid; $m->params["notify"] = $ourcallid;
@ -69,7 +69,7 @@ function setState($newstate)
case "routing": case "routing":
$m = new Yate("chan.attach"); $m = new Yate("chan.attach");
$m->params["id"] = $ourcallid; $m->params["id"] = $ourcallid;
$m->params["source"] = "wave/play/-"; $m->params["source"] = "tone/noise";
$m->params["consumer"] = "wave/record/-"; $m->params["consumer"] = "wave/record/-";
$m->params["maxlen"] = 320000; $m->params["maxlen"] = 320000;
$m->params["notify"] = $ourcallid; $m->params["notify"] = $ourcallid;
@ -137,7 +137,7 @@ function gotDTMF($dtmf)
routeTo($collect); routeTo($collect);
} }
function endRoute($callto,$ok,$err) function endRoute($callto,$ok,$err,$params)
{ {
global $partycallid; global $partycallid;
global $num; global $num;
@ -145,6 +145,7 @@ function endRoute($callto,$ok,$err)
if ($ok) { if ($ok) {
Yate::Output("Overlapped got route: '$callto' for '$collect'"); Yate::Output("Overlapped got route: '$callto' for '$collect'");
$m = new Yate("chan.masquerade"); $m = new Yate("chan.masquerade");
$m->params = $params;
$m->params["message"] = "call.execute"; $m->params["message"] = "call.execute";
$m->params["id"] = $partycallid; $m->params["id"] = $partycallid;
$m->params["callto"] = $callto; $m->params["callto"] = $callto;
@ -175,16 +176,18 @@ while ($state != "") {
$partycallid = $ev->GetValue("id"); $partycallid = $ev->GetValue("id");
$ev->params["targetid"] = $ourcallid; $ev->params["targetid"] = $ourcallid;
$num = $ev->GetValue("caller"); $num = $ev->GetValue("caller");
$autoanswer = ($ev->GetValue("called") != "off-hook");
$ev->handled = true; $ev->handled = true;
// we must ACK this message before dispatching a call.answered // we must ACK this message before dispatching a call.answered
$ev->Acknowledge(); $ev->Acknowledge();
// we already ACKed this message // we already ACKed this message
$ev = false; $ev = false;
if ($autoanswer) {
$m = new Yate("call.answered"); $m = new Yate("call.answered");
$m->params["id"] = $ourcallid; $m->params["id"] = $ourcallid;
$m->params["targetid"] = $partycallid; $m->params["targetid"] = $partycallid;
$m->Dispatch(); $m->Dispatch();
}
setState("prompt"); setState("prompt");
break; break;
@ -212,7 +215,7 @@ while ($state != "") {
break; break;
case "answer": case "answer":
if ($ev->name == "call.route") if ($ev->name == "call.route")
endRoute($ev->retval,$ev->handled,$ev->GetValue("error")); endRoute($ev->retval,$ev->handled,$ev->GetValue("error"),$ev->params);
break; break;
} }
} }