Added support for delivering Caller ID over analog FXS MGCP gateways.

git-svn-id: http://voip.null.ro/svn/yate@4188 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2011-03-16 23:31:07 +00:00
parent f265f745f3
commit 1fd0dc1670
3 changed files with 41 additions and 4 deletions

View File

@ -4,6 +4,12 @@
; priority: int: Priority of the chan.rtp message handler
;priority=80
; tzoffset: int: Timezone offset from GMT in seconds for sending Caller ID
; Positive to go East, negative to go West
; Examples: CET=3600, EST=-18000
; This parameter is reloadable
;tzoffset=0
[engine]
; These parameters are used to initialize the MGCP Engine

View File

@ -71,7 +71,7 @@ public:
const char* called = 0)
{ m_caller = caller; m_callerName = callername; m_called = called; }
// Set the caller, callername and called parameters
void copyCall(Message& dest, bool privacy = false);
void copyCall(NamedList& dest, bool privacy = false);
// Fill a string with line status parameters
void statusParams(String& str);
// Fill a string with line status detail parameters
@ -680,7 +680,7 @@ void ModuleLine::processNotify(Message& msg)
}
// Set the caller, callername and called parameters
void ModuleLine::copyCall(Message& dest, bool privacy)
void ModuleLine::copyCall(NamedList& dest, bool privacy)
{
if (privacy)
dest.addParam("callerpres","restricted");
@ -1409,7 +1409,15 @@ AnalogChannel::AnalogChannel(ModuleLine* line, Message* msg, RecordTrigger recor
m_privacy = getPrivacy(*msg);
if (m_callsetup == AnalogLine::Before)
m_line->sendCallSetup(m_privacy);
m_line->sendEvent(SignallingCircuitEvent::RingBegin,AnalogLine::Dialing);
{
NamedList* params = 0;
NamedList callerId("");
if (m_callsetup != AnalogLine::NoCallSetup) {
params = &callerId;
m_line->copyCall(callerId,m_privacy);
}
m_line->sendEvent(SignallingCircuitEvent::RingBegin,AnalogLine::Dialing,params);
}
if (m_callsetup == AnalogLine::After)
m_dialTimer.interval(500);
break;

View File

@ -31,6 +31,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
using namespace TelEngine;
namespace { // anonymous
@ -300,6 +301,7 @@ YSIGFACTORY2(MGCPSpan);
static YMGCPEngine* s_engine = 0;
static MGCPEndpoint* s_endpoint = 0;
static String s_defaultEp;
static int s_tzOffset = 0;
static MGCPPlugin splugin;
static ObjList s_wrappers;
@ -1696,7 +1698,27 @@ bool MGCPCircuit::sendEvent(SignallingCircuitEvent::Type type, NamedList* params
setParams(*params);
return status(Connected,!params || params->getBoolValue("sync",true));
case SignallingCircuitEvent::RingBegin:
return fxs() && sendPending("L/rg");
if (fxs()) {
String s("L/rg");
if (params) {
String number = params->getValue("caller");
String name = params->getValue("callername");
if (number || name) {
MimeHeaderLine::addQuotes(number);
MimeHeaderLine::addQuotes(name);
int year;
unsigned int month,day,hour,minutes,seconds;
int tzo = params->getIntValue("tzoffset",s_tzOffset);
Time::toDateTime(Time::secNow()+tzo,year,month,day,hour,minutes,seconds);
char buf[16];
::snprintf(buf,sizeof(buf),"%02u/%02u/%02u/%02u",month,day,hour,minutes);
buf[sizeof(buf)-1] = '\0';
s << ",L/ci(" << buf << "," << number << "," << name << ")";
}
}
return sendPending(s);
}
return false;
case SignallingCircuitEvent::RingEnd:
return sendPending();
case SignallingCircuitEvent::Polarity:
@ -1956,6 +1978,7 @@ void MGCPPlugin::initialize()
Output("Initializing module MGCP Call Agent");
Configuration cfg(Engine::configFile("mgcpca"));
setup();
s_tzOffset = cfg.getIntValue("general","tzoffset",0);
NamedList* engSect = cfg.getSection("engine");
if (s_engine && engSect)
s_engine->initialize(*engSect);