Added fax tone detection to MGCP and ability to override the request string.

git-svn-id: http://voip.null.ro/svn/yate@4269 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2011-04-06 14:38:26 +00:00
parent d989155215
commit 1eb153a8ab
3 changed files with 31 additions and 4 deletions

View File

@ -177,9 +177,16 @@
; Normally the default bearer is not set so a B: line is added when needed
;bearer=
; req_dtmf: keyword: When to request DTMF notification from gateway
; req_fax: bool: Request Fax Tone detection from gateway
;req_fax=yes
; req_evts: string: Requested Events in MGCP format, overrides default
; Default depends on endpoint configuration and fax setting
;req_evts=
; req_dtmf: keyword: When to request DTMF and fax notification from gateway
; Allowed values:
; none - do not request to be notified about DTMF events
; none - do not request to be notified about DTMF and fax events
; once - emit RQNT once when connecting the circuit (default)
; more - emit RQNT on connection and after each notification received
;req_dtmf=once

View File

@ -162,7 +162,7 @@ private:
bool m_fxo;
bool m_fxs;
RqntType m_rqntType;
const char* m_rqntStr;
String m_rqntStr;
String m_notify;
String m_address;
String m_version;
@ -884,7 +884,7 @@ MGCPSpan::MGCPSpan(const NamedList& params, const char* name, const MGCPEpInfo&
break;
case AnalogLine::FXS:
m_fxs = true;
m_rqntStr = "L/hu(N),D/[0-9#*](N)";
m_rqntStr = "L/hu(N)," + m_rqntStr;
break;
default:
break;
@ -968,6 +968,9 @@ bool MGCPSpan::init(const NamedList& params)
m_sdpForward = config->getBoolValue("forward_sdp",false);
m_bearer = lookup(config->getIntValue("bearer",s_dict_payloads,-1),s_dict_gwbearerinfo);
m_rqntType = (RqntType)config->getIntValue("req_dtmf",s_dict_rqnt,RqntOnce);
if (config->getBoolValue("req_fax",true))
m_rqntStr.append("G/ft(N)",",");
m_rqntStr = config->getValue("req_evts",m_rqntStr);
bool clear = config->getBoolValue("clearconn",false);
m_circuits = new MGCPCircuit*[m_count];
unsigned int i;
@ -1821,6 +1824,13 @@ bool MGCPCircuit::processNotify(const String& package, const String& event, cons
if (event.length() == 1)
return enqueueEvent(SignallingCircuitEvent::Dtmf,fullName,event);
}
else if (package == "G") {
if (mySpan()->rqntType() == MGCPSpan::RqntMore)
sendRequest(0,mySpan()->rqntStr());
// Generic events
if (event &= "ft")
return enqueueEvent(SignallingCircuitEvent::GenericTone,"fax");
}
return false;
}

View File

@ -1496,6 +1496,16 @@ void SigChannel::evCircuit(SignallingEvent* event)
case SignallingCircuitEvent::Disconnected:
hangup("nomedia");
break;
case SignallingCircuitEvent::GenericTone:
if (*ev == "fax") {
bool inband = ev->getBoolValue("inband");
Message* msg = message("call.fax",false,true);
msg->setParam("detected",(inband ? "inband" : "signal"));
plugin.copySigMsgParams(*msg,event,&s_noPrefixParams);
Engine::enqueue(msg);
break;
}
// fall through
default:
Debug(this,DebugStub,"Unhandled circuit event '%s' type=%d [%p]",
ev->c_str(),ev->type(),this);