diff --git a/conf.d/mgcpca.conf.sample b/conf.d/mgcpca.conf.sample index 2e05df4e..7a48eb1b 100644 --- a/conf.d/mgcpca.conf.sample +++ b/conf.d/mgcpca.conf.sample @@ -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 diff --git a/modules/server/mgcpca.cpp b/modules/server/mgcpca.cpp index 60416fe6..de847f21 100644 --- a/modules/server/mgcpca.cpp +++ b/modules/server/mgcpca.cpp @@ -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; } diff --git a/modules/server/ysigchan.cpp b/modules/server/ysigchan.cpp index eed100f1..b1f8a661 100644 --- a/modules/server/ysigchan.cpp +++ b/modules/server/ysigchan.cpp @@ -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);