[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "telephone-events" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Fri Jul 8 08:58:11 CDT 2011
branch "telephone-events" has been updated
via 6fed3a431208755055ab5a0cb697e8777e5a221c (commit)
via da5441b188e598254eb9d2cab3334341dec56f8e (commit)
via 866381522f6a26c53e5395989ea8ee433c0e9d59 (commit)
via c93b75ba3affcf73ae553eb1a1913e92d40ff4fe (commit)
via 5c240c011c171b75972122011149a30185945e04 (commit)
via 33e084958ef7f2b355feb8f585d7a95c0a6ac94c (commit)
via c10b4677e95ed80276fd8b712e394c98c8692794 (commit)
from a815ad12e32d57dc4ece7488fe72ce0e82f5e4d9 (commit)
Summary of changes:
config/SipConfigurator.py | 14 +++++
.../SipSessionManager/SipConfigurationIf.ice | 18 ++++++
src/PJSipSessionModule.cpp | 47 +++++++++++++---
src/SipConfiguration.cpp | 10 +++
src/SipEndpoint.cpp | 5 ++
src/SipEndpoint.h | 6 ++-
src/SipSession.cpp | 60 ++++++++++++++++++++
7 files changed, 151 insertions(+), 9 deletions(-)
- Log -----------------------------------------------------------------
commit 6fed3a431208755055ab5a0cb697e8777e5a221c
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Jul 7 17:09:59 2011 -0500
Asterisk will look for "d=" in addition to "Signal=" so we're doing it too.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 388a108..516984f 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -1022,13 +1022,18 @@ char PJSipSessionModule::getDTMFInfoSignal(pjsip_msg_body *body)
char *data = static_cast<char *>(body->data);
std::string dataStr(data, body->len);
std::string signalStr("Signal=");
+ std::string altSignalStr("d=");
std::stringstream err;
size_t signalPos = dataStr.find(signalStr);
if (signalPos == std::string::npos)
{
- err << "Couldn't find " << signalStr << " in DTMF INFO body";
- throw DTMFInfoException(err.str());
+ signalPos = dataStr.find(altSignalStr);
+ if (signalPos == std::string::npos)
+ {
+ err << "Couldn't find " << signalStr << " or " << altSignalStr << " in DTMF INFO body";
+ throw DTMFInfoException(err.str());
+ }
}
//The pending draft for DTMF via INFO mandates a single space after
commit da5441b188e598254eb9d2cab3334341dec56f8e
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Jul 7 17:08:25 2011 -0500
Detect flash via incoming INFO.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index f13410c..388a108 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -926,7 +926,15 @@ public:
SuspendableWorkResult initial(const SuspendableWorkListenerPtr& workListener)
{
- EndDTMFPtr indication(new EndDTMF(mDTMF, mDuration));
+ TelephonyIndicationPtr indication;
+ if (mDTMF == '!')
+ {
+ indication = new EndDTMF(mDTMF, mDuration);
+ }
+ else
+ {
+ indication = new FlashedIndication();
+ }
std::vector<SessionListenerPrx> listeners = mSession->getListeners();
for (std::vector<SessionListenerPrx>::iterator iter = listeners.begin();
iter != listeners.end(); ++iter)
@@ -1029,7 +1037,8 @@ char PJSipSessionModule::getDTMFInfoSignal(pjsip_msg_body *body)
size_t signalValuePos = dataStr.find_first_not_of(' ', signalPos + signalStr.size());
char retSignal = dataStr.at(signalValuePos);
- std::string validDTMF("1234567890#*ABCD");
+ //'!' is used by some endpoints to indicate a flash
+ std::string validDTMF("1234567890#*ABCD!");
if (!validDTMF.find(retSignal))
{
err << "Signal '" << retSignal << "' is not a valid DTMF signal";
commit 866381522f6a26c53e5395989ea8ee433c0e9d59
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Jul 7 15:54:53 2011 -0500
Adjust the configurator to set DTMF.
Add Info-Package header to outbound DTMF INFO.
diff --git a/config/SipConfigurator.py b/config/SipConfigurator.py
index 7db7217..836ffbd 100755
--- a/config/SipConfigurator.py
+++ b/config/SipConfigurator.py
@@ -153,6 +153,20 @@ class SipSectionVisitors(Configurator.SectionVisitors):
transformer = TLSProtocolMethodTransformer(config)
mapper.map('tlsprotocolmethod', item, 'protocolMethod', 'crypto', transformer.get, None)
+ class DTMFMethodTransformer():
+ def __init__(self, config):
+ self.config = config
+ def get(self, section, item):
+ if self.config.get(section, item) == 'info':
+ return AsteriskSCF.Configuration.SipSessionManager.V1.SipDTMFOption.INFO
+ if self.config.get(section, item) == 'rfc4733' or self.config.get(section.item) == 'rfc2833':
+ return AsteriskSCF.Configuration.SipSessionManager.V1.SipDTMFOption.RFC4733
+ if self.config.get(section, item) == 'inband':
+ return AsteriskSCF.Configuration.SipSessionManager.V1.SipDTMFOption.Inband
+
+ transformer = DTMFMethodTransformer(config)
+ mapper.map('dtmfmethod', item, 'dtmfmethod', 'dtmf', transformer.get, AsteriskSCF.Configuration.SipSessionManager.V1.SipDTMFOption.RFC4733)
+
for option in config.options(section):
mapper.execute(group, section, option)
mapper.finish(group)
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index cc943b2..145a5d7 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -481,6 +481,10 @@ public:
{
sendDTMFInfo(endDTMF);
}
+ else
+ {
+ lg(Debug) << "Not using INFO";
+ }
}
else
{
@@ -515,7 +519,13 @@ private:
return; //yo!
}
- //XXX We need to add Info-Package header here...
+ pj_str_t infoPackage;
+ pj_cstr(&infoPackage, "Info-Package");
+ pj_str_t infoPackageVal;
+ pj_cstr(&infoPackageVal, "dtmf");
+ pjsip_generic_string_hdr *infoPackageHdr = pjsip_generic_string_hdr_create(tdata->pool, &infoPackage, &infoPackageVal);
+
+ pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) infoPackageHdr);
pj_str_t type;
pj_cstr(&type, "application");
commit c93b75ba3affcf73ae553eb1a1913e92d40ff4fe
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Jul 7 14:52:47 2011 -0500
Send INFO only if an endpoint is configured for it.
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 71683bc..cc943b2 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -476,9 +476,11 @@ public:
}
else if ((endDTMF = AsteriskSCF::SessionCommunications::V1::EndDTMFPtr::dynamicCast(mIndication)))
{
- // XXX We need an endpoint option to determine the type of DTMF to use.
-
- sendDTMFInfo(endDTMF);
+ SipEndpointConfig &config = mImplPriv->mEndpoint->getConfig();
+ if (config.sessionConfig.dtmf == AsteriskSCF::Configuration::SipSessionManager::V1::INFO)
+ {
+ sendDTMFInfo(endDTMF);
+ }
}
else
{
commit 5c240c011c171b75972122011149a30185945e04
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Jul 7 14:43:42 2011 -0500
Add code to set the DTMF method for SIP endpoints.
diff --git a/slice/AsteriskSCF/Configuration/SipSessionManager/SipConfigurationIf.ice b/slice/AsteriskSCF/Configuration/SipSessionManager/SipConfigurationIf.ice
index 849992d..a4d352c 100644
--- a/slice/AsteriskSCF/Configuration/SipSessionManager/SipConfigurationIf.ice
+++ b/slice/AsteriskSCF/Configuration/SipSessionManager/SipConfigurationIf.ice
@@ -383,6 +383,24 @@ module V1
SipAllowableCallDirection secureTransport = Disabled;
};
+ /**
+ * Methods of transporting DTMF via SIP
+ */
+ enum SipDTMFOption
+ {
+ Inband,
+ RFC4733,
+ INFO,
+ };
+
+ /**
+ * Denotes the method by which we will send DTMF to an endpoint
+ */
+ class SipDTMFItem extends SipConfigurationItem
+ {
+ SipDTMFOption dtmf = RFC4733;
+ };
+
/**
* Group of configuration items related to a UDP transport
*/
diff --git a/src/SipConfiguration.cpp b/src/SipConfiguration.cpp
index a9ed619..1c841da 100644
--- a/src/SipConfiguration.cpp
+++ b/src/SipConfiguration.cpp
@@ -204,6 +204,11 @@ class EndpointConfigHelper : public boost::enable_shared_from_this<EndpointConfi
mUpdates.push_back(boost::bind(&EndpointConfigHelper::updateTransport, mConfig, transport));
};
+ void visitSipDTMFItem(const SipDTMFItemPtr& dtmf)
+ {
+ mUpdates.push_back(boost::bind(&EndpointConfigHelper::updateDTMF, mConfig, dtmf));
+ };
+
private:
UpdateCommandList mUpdates;;
@@ -278,6 +283,11 @@ public:
mEndpoint->setSecureTransport(translateCallDirection(transport->secureTransport));
}
+ void updateDTMF(const SipDTMFItemPtr& dtmf)
+ {
+ mEndpoint->setDTMFMethod(dtmf->dtmf);
+ }
+
void updated(const UpdateCommandList& updates)
{
//
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 2a6af1a..80fd0c3 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -136,6 +136,11 @@ void SipEndpoint::setSecureTransport(enum Direction direction)
mImplPriv->mConfig.transportConfig.secureTransport = direction;
}
+void SipEndpoint::setDTMFMethod(AsteriskSCF::Configuration::SipSessionManager::V1::SipDTMFOption dtmf)
+{
+ mImplPriv->mConfig.sessionConfig.dtmf = dtmf;
+}
+
void SipEndpoint::setRTPOverIPv6(bool enabled)
{
mImplPriv->mConfig.sessionConfig.rtpOverIPv6 = enabled;
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index cb91a66..796429b 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -32,6 +32,7 @@
#include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.h>
#include <AsteriskSCF/Media/MediaIf.h>
#include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
+#include <AsteriskSCF/Configuration/SipSessionManager/SipConfigurationIf.h>
#include "SipSession.h"
@@ -45,7 +46,6 @@ namespace SipSessionManager
class SipEndpointFactory;
class SipSession;
typedef IceUtil::Handle<SipSession> SipSessionPtr;
-
/**
* General purpose direction enumeration.
* Useful for detemining policies regarding
@@ -141,6 +141,9 @@ public:
// Whether we are using IPv6 for media transport
// or not.
bool rtpOverIPv6;
+ // The method by which we will transmit
+ // DTMF to an endpoint
+ AsteriskSCF::Configuration::SipSessionManager::V1::SipDTMFOption dtmf;
};
/**
@@ -254,6 +257,7 @@ public:
void setCallDirection(enum Direction);
void setSecureTransport(enum Direction);
void setRTPOverIPv6(bool);
+ void setDTMFMethod(AsteriskSCF::Configuration::SipSessionManager::V1::SipDTMFOption dtmf);
private:
/**
commit 33e084958ef7f2b355feb8f585d7a95c0a6ac94c
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Jul 7 13:16:37 2011 -0500
Add support for sending INFO DTMF if we receive an endDTMF indication.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index e19ba49..f13410c 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -926,7 +926,7 @@ public:
SuspendableWorkResult initial(const SuspendableWorkListenerPtr& workListener)
{
- DTMFEndedPtr indication(new DTMFEnded(mDTMF, mDuration));
+ EndDTMFPtr indication(new EndDTMF(mDTMF, mDuration));
std::vector<SessionListenerPrx> listeners = mSession->getListeners();
for (std::vector<SessionListenerPrx>::iterator iter = listeners.begin();
iter != listeners.end(); ++iter)
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 972b5b0..71683bc 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -429,6 +429,8 @@ public:
AsteriskSCF::SessionCommunications::V1::ProgressIndicationPtr Progress;
AsteriskSCF::SessionCommunications::V1::RingIndicationPtr Ring;
AsteriskSCF::SessionCommunications::V1::UnholdIndicationPtr Unhold;
+ AsteriskSCF::SessionCommunications::V1::BeginDTMFPtr beginDTMF;
+ AsteriskSCF::SessionCommunications::V1::EndDTMFPtr endDTMF;
pjsip_tx_data *packet = NULL;
pj_status_t status = -1;
@@ -468,6 +470,16 @@ public:
lg(Debug) << "Processing a Unhold indication";
status = pjsip_inv_reinvite(mImplPriv->mInviteSession, NULL, NULL, &packet);
}
+ else if ((beginDTMF = AsteriskSCF::SessionCommunications::V1::BeginDTMFPtr::dynamicCast(mIndication)))
+ {
+ // XXX Since the only DTMF support we have is INFO, we won't get any beginDTMF indications. Sorry.
+ }
+ else if ((endDTMF = AsteriskSCF::SessionCommunications::V1::EndDTMFPtr::dynamicCast(mIndication)))
+ {
+ // XXX We need an endpoint option to determine the type of DTMF to use.
+
+ sendDTMFInfo(endDTMF);
+ }
else
{
lg(Error) << "Unknown indication received";
@@ -484,6 +496,42 @@ public:
}
private:
+
+ void sendDTMFInfo(const AsteriskSCF::SessionCommunications::V1::EndDTMFPtr& endDTMF)
+ {
+ pjsip_method infoMethod;
+ pj_str_t infoStr;
+ pj_cstr(&infoStr, "INFO");
+ pjsip_method_init_np(&infoMethod, &infoStr);
+
+ pjsip_tx_data *tdata;
+ pj_status_t status;
+ status = pjsip_dlg_create_request(mImplPriv->mInviteSession->dlg, &infoMethod, -1, &tdata);
+
+ if (status != PJ_SUCCESS)
+ {
+ return; //yo!
+ }
+
+ //XXX We need to add Info-Package header here...
+
+ pj_str_t type;
+ pj_cstr(&type, "application");
+ pj_str_t subtype;
+ pj_cstr(&subtype, "dtmf-relay");
+ std::stringstream bodyText;
+ bodyText << "Signal= " << endDTMF->digit
+ << "\r\nDuration= " << endDTMF->duration << "\r\n\r\n";
+ pj_str_t bodyStr;
+ pj_cstr(&bodyStr, bodyText.str().c_str());
+
+ pjsip_msg_body *body = pjsip_msg_body_create(tdata->pool, &type, &subtype, &bodyStr);
+
+ tdata->msg->body = body;
+
+ pjsip_dlg_send_request(mImplPriv->mInviteSession->dlg, tdata, -1, NULL);
+ }
+
AsteriskSCF::SessionCommunications::V1::AMD_Session_indicatePtr mCb;
AsteriskSCF::SessionCommunications::V1::IndicationPtr mIndication;
boost::shared_ptr<SipSessionPriv> mImplPriv;
commit c10b4677e95ed80276fd8b712e394c98c8692794
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Jul 7 09:14:33 2011 -0500
Add indication call to INFO DTMF processing.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 066bfc9..e19ba49 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -919,15 +919,29 @@ public:
pjsip_inv_session *inv,
pjsip_transaction *tsx,
pjsip_tx_data *tdata,
+ const SipSessionPtr& session,
char dtmf,
int duration)
- : mInv(inv), mTsx(tsx), mTdata(tdata), mDTMF(dtmf), mDuration(duration) { }
+ : mInv(inv), mTsx(tsx), mTdata(tdata), mSession(session), mDTMF(dtmf), mDuration(duration) { }
SuspendableWorkResult initial(const SuspendableWorkListenerPtr& workListener)
{
- //XXX We need to send an indicated() operation to our session listeners.
- //There's not a DTMF indication defined at the moment, so I'll withhold
- //that until I have defined such a method.
+ DTMFEndedPtr indication(new DTMFEnded(mDTMF, mDuration));
+ std::vector<SessionListenerPrx> listeners = mSession->getListeners();
+ for (std::vector<SessionListenerPrx>::iterator iter = listeners.begin();
+ iter != listeners.end(); ++iter)
+ {
+ try
+ {
+ SipAMICallbackPtr cb(new SipAMICallback(0, mSession, this, false, true));
+ Ice::CallbackPtr d = Ice::newCallback(cb, &SipAMICallback::callback);
+ (*iter)->begin_indicated(mSession->getSessionProxy(), indication, mSession->getCookies(), d);
+ }
+ catch (const Ice::Exception &ex)
+ {
+ lg(Error) << "Ice exception when attempting to send DTMF indication: " << ex.what();
+ }
+ }
pjsip_dlg_send_response(mInv->dlg, mTsx, mTdata);
}
@@ -936,6 +950,7 @@ private:
pjsip_inv_session *mInv;
pjsip_transaction *mTsx;
pjsip_tx_data *mTdata;
+ SipSessionPtr mSession;
char mDTMF;
int mDuration;
};
@@ -1088,7 +1103,9 @@ void PJSipSessionModule::handleInfo(pjsip_inv_session *inv, pjsip_rx_data *rdata
pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
pjsip_tx_data *tdata;
pjsip_dlg_create_response(inv->dlg, rdata, 200, NULL, &tdata);
- enqueueSessionWork(new HandleInfoDTMFOperation(inv, tsx, tdata, dtmf, duration), inv);
+ PJSipSessionModInfo *sessionModInfo = static_cast<PJSipSessionModInfo*>(inv->mod_data[mModule.id]);
+ SipSessionPtr session = sessionModInfo->getSessionPtr();
+ enqueueSessionWork(new HandleInfoDTMFOperation(inv, tsx, tdata, session, dtmf, duration), inv);
return;
}
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list