[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "route_async" created.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Thu Dec 23 01:40:17 UTC 2010
branch "route_async" has been created
at 5b6eafb85e9f71fc32b9befd618b177888abbbed (commit)
- Log -----------------------------------------------------------------
commit 5b6eafb85e9f71fc32b9befd618b177888abbbed
Author: Ken Hunt <ken.hunt at digium.com>
Date: Mon Dec 20 21:46:04 2010 -0600
Changes for amd/ami tags on routing operations.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5a2e7ff..413cab4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -81,7 +81,6 @@ asterisk_scf_component_add_file(SipStateReplicator SipStateReplicator.h)
#asterisk_scf_component_add_file(SipStateReplicator SipStateReplicator.cpp)
asterisk_scf_component_add_ice_libraries(SipStateReplicator IceStorm)
-asterisk_scf_component_add_boost_libraries(SipStateReplicator thread date_time)
asterisk_scf_component_build_icebox(SipStateReplicator)
target_link_libraries(SipStateReplicator logging-client)
diff --git a/src/SipSessionManagerEndpointLocator.cpp b/src/SipSessionManagerEndpointLocator.cpp
index ff2439c..3fd8679 100644
--- a/src/SipSessionManagerEndpointLocator.cpp
+++ b/src/SipSessionManagerEndpointLocator.cpp
@@ -26,7 +26,14 @@ namespace AsteriskSCF
namespace SipSessionManager
{
-AsteriskSCF::Core::Endpoint::V1::EndpointSeq SipSessionManagerEndpointLocator::lookup(const ::std::string& destination, const Ice::Current&)
+/**
+ * Provide lookup capability to the Asterisk SCF system for endpoints that this component mananges. This
+ * operation is typically invoked by the routing service.
+ *
+ * Note: This interface is shared by the Routing Service, which is why it's specified as AMD. However, we aren't currently
+ * using any asynchrounous features in forming our reply.
+ */
+void SipSessionManagerEndpointLocator::lookup_async(const ::AsteriskSCF::Core::Routing::V1::AMD_EndpointLocator_lookupPtr& cb, const ::std::string& destination, const ::Ice::Current&)
{
AsteriskSCF::Core::Endpoint::V1::EndpointSeq endpoints;
SipEndpointPtr endpoint = mEndpointFactory->findByName(destination);
@@ -34,9 +41,12 @@ AsteriskSCF::Core::Endpoint::V1::EndpointSeq SipSessionManagerEndpointLocator::l
if (endpoint != 0)
{
endpoints.push_back(endpoint->getEndpointProxy());
+ cb->ice_response(endpoints);
+ return;
}
-
- return endpoints;
+
+ cb->ice_exception(::AsteriskSCF::Core::Routing::V1::DestinationNotFoundException(destination));
+
}
}; // end SipSessionManager
diff --git a/src/SipSessionManagerEndpointLocator.h b/src/SipSessionManagerEndpointLocator.h
index e1e74c5..84dfb0a 100644
--- a/src/SipSessionManagerEndpointLocator.h
+++ b/src/SipSessionManagerEndpointLocator.h
@@ -41,7 +41,7 @@ public: // Overrides of EndpointLocator
* The Routing Service will call this method when it needs to lookup an endpoint that
* we have indicated that we are managing.
*/
- virtual ::AsteriskSCF::Core::Endpoint::V1::EndpointSeq lookup(const ::std::string& destination, const ::Ice::Current& = ::Ice::Current());
+ virtual void lookup_async(const ::AsteriskSCF::Core::Routing::V1::AMD_EndpointLocator_lookupPtr& cb, const ::std::string& destination, const ::Ice::Current& = ::Ice::Current());
private:
/**
commit 85469f206455ec5f19481e6fc25b9600614b4a6c
Author: Ken Hunt <ken.hunt at digium.com>
Date: Fri Dec 3 14:20:33 2010 -0600
Manage boost link options in CMake.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 413cab4..5a2e7ff 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -81,6 +81,7 @@ asterisk_scf_component_add_file(SipStateReplicator SipStateReplicator.h)
#asterisk_scf_component_add_file(SipStateReplicator SipStateReplicator.cpp)
asterisk_scf_component_add_ice_libraries(SipStateReplicator IceStorm)
+asterisk_scf_component_add_boost_libraries(SipStateReplicator thread date_time)
asterisk_scf_component_build_icebox(SipStateReplicator)
target_link_libraries(SipStateReplicator logging-client)
commit 99d7471b6dd6acdbe5260ebe9f9d03fa0577b162
Author: David M. Lee <dlee at digium.com>
Date: Mon Nov 29 09:03:54 2010 -0600
ProxyWrapper -> SmartProxy
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 15cb230..413cab4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -41,7 +41,7 @@ asterisk_scf_component_add_file(SipSessionManager SipStateReplicator.h)
asterisk_scf_component_add_ice_libraries(SipSessionManager IceStorm)
-asterisk_scf_component_add_boost_libraries(SipSessionManager thread core)
+asterisk_scf_component_add_boost_libraries(SipSessionManager core)
if(NOT logger_dir)
message(FATAL_ERROR "The logger directory could not be found ${logger_dir}")
@@ -74,14 +74,13 @@ asterisk_scf_component_add_slice(SipStateReplicator MediaRTPIf)
#permanent of changes and assumes the directories are
#structured in the way that gitall structures them.
include_directories(${utils_dir}/StateReplicator/src)
-include_directories(${utils_dir}/ProxyWrapper/src)
+include_directories(${utils_dir}/SmartProxy/src)
asterisk_scf_component_add_file(SipStateReplicator SipStateReplicatorApp.cpp)
asterisk_scf_component_add_file(SipStateReplicator SipStateReplicator.h)
#asterisk_scf_component_add_file(SipStateReplicator SipStateReplicator.cpp)
asterisk_scf_component_add_ice_libraries(SipStateReplicator IceStorm)
-asterisk_scf_component_add_boost_libraries(SipStateReplicator thread)
asterisk_scf_component_build_icebox(SipStateReplicator)
target_link_libraries(SipStateReplicator logging-client)
diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index 4270766..8d299d7 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -72,9 +72,9 @@ PJSipManager::PJSipManager(Ice::PropertiesPtr props)
void PJSipManager::registerSessionModule(pjsip_endpoint *endpt,
boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
- AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
+ AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
- AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
+ AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
AsteriskSCF::System::Component::V1::ReplicaPtr replica
)
{
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index 7cc5220..6340407 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -26,7 +26,7 @@
#include <boost/shared_ptr.hpp>
#include "PJSipSessionModule.h"
#include "PJSipLoggingModule.h"
-#include "ProxyWrapper.h"
+#include "SmartProxy.h"
namespace AsteriskSCF
{
@@ -68,9 +68,9 @@ public:
*/
void registerSessionModule(pjsip_endpoint *endpt,
boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
- AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
+ AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
- AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
+ AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
AsteriskSCF::System::Component::V1::ReplicaPtr replica
);
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index ef5c165..270849d 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -27,7 +27,7 @@
#include "SipSession.h"
#include "PJSipModule.h"
#include "ReplicaIf.h"
-#include "ProxyWrapper.h"
+#include "SmartProxy.h"
namespace AsteriskSCF
{
@@ -57,9 +57,9 @@ class PJSipSessionModule : public PJSipModule
{
public:
PJSipSessionModule(pjsip_endpoint *endpt, boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
- AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
+ AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
- AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
+ AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
AsteriskSCF::System::Component::V1::ReplicaPtr replica);
pj_status_t load(pjsip_endpoint *endpoint);
pj_status_t start();
@@ -89,9 +89,9 @@ private:
pjsip_ua_init_param mUaParam;
const std::string mName;
boost::shared_ptr<SipEndpointFactory> mEndpointFactory;
- AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> mSessionRouter;
+ AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> mSessionRouter;
AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx mServiceLocator;
- AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> mStateReplicator;
+ AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> mStateReplicator;
AsteriskSCF::System::Component::V1::ReplicaPtr mReplica;
};
diff --git a/src/PJSipSessionModuleConstruction.cpp b/src/PJSipSessionModuleConstruction.cpp
index 14f1fe5..e6cebaf 100644
--- a/src/PJSipSessionModuleConstruction.cpp
+++ b/src/PJSipSessionModuleConstruction.cpp
@@ -93,9 +93,9 @@ static pjsip_dialog *uaOnDialogForked(pjsip_dialog *first_set, pjsip_rx_data *rd
PJSipSessionModule::PJSipSessionModule(pjsip_endpoint *endpt,
boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
- AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
+ AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
- AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
+ AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
AsteriskSCF::System::Component::V1::ReplicaPtr replica)
: mName(moduleName), mEndpointFactory(endpointFactoryPtr),
mSessionRouter(sessionRouter), mServiceLocator(serviceLocator),
diff --git a/src/SipSessionManagerApp.cpp b/src/SipSessionManagerApp.cpp
index 74348e5..e185bba 100644
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@ -38,7 +38,7 @@
#include "PJSipManager.h"
#include "SipSession.h"
#include "SipStateReplicator.h"
-#include "ProxyWrapper.h"
+#include "SmartProxy.h"
using namespace std;
using namespace AsteriskSCF::SipSessionManager;
@@ -48,7 +48,7 @@ using namespace AsteriskSCF::Core::Discovery::V1;
using namespace AsteriskSCF::System::Component::V1;
using namespace AsteriskSCF::System::Logging;
using namespace AsteriskSCF::SessionCommunications::V1;
-using namespace AsteriskSCF::ProxyWrapper;
+using namespace AsteriskSCF::SmartProxy;
namespace
{
@@ -118,9 +118,9 @@ private:
SipStateReplicatorListenerPrx mReplicatorListenerProxy;
boost::shared_ptr<SipEndpointFactory> mEndpointFactory;
ServiceLocatorPrx mServiceLocator;
- AsteriskSCF::ProxyWrapper::ProxyWrapper<SipStateReplicatorPrx> mStateReplicator;
- AsteriskSCF::ProxyWrapper::ProxyWrapper<SessionRouterPrx> mSessionRouter;
- AsteriskSCF::ProxyWrapper::ProxyWrapper<LocatorRegistryPrx> mRoutingServiceLocatorRegistry;
+ AsteriskSCF::SmartProxy::SmartProxy<SipStateReplicatorPrx> mStateReplicator;
+ AsteriskSCF::SmartProxy::SmartProxy<SessionRouterPrx> mSessionRouter;
+ AsteriskSCF::SmartProxy::SmartProxy<LocatorRegistryPrx> mRoutingServiceLocatorRegistry;
boost::shared_ptr<SipSessionManagerEventPublisher> mEventPublisher;
Routing::V1::EndpointLocatorPtr mEndpointLocator;
};
@@ -357,7 +357,7 @@ void SipSessionManager::locateRoutingService()
ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
genericparams->category = Routing::V1::RoutingServiceLocatorRegistryDiscoveryCategory;
- AsteriskSCF::ProxyWrapper::ProxyWrapper<LocatorRegistryPrx> pw(mServiceLocator, genericparams);
+ AsteriskSCF::SmartProxy::SmartProxy<LocatorRegistryPrx> pw(mServiceLocator, genericparams, lg);
mRoutingServiceLocatorRegistry = pw;
}
@@ -374,7 +374,7 @@ void SipSessionManager::locateStateReplicator()
try
{
- AsteriskSCF::ProxyWrapper::ProxyWrapper<SipStateReplicatorPrx> pw(mServiceLocator, replicatorParams);
+ AsteriskSCF::SmartProxy::SmartProxy<SipStateReplicatorPrx> pw(mServiceLocator, replicatorParams, lg);
mStateReplicator = pw;
}
catch (...)
@@ -411,7 +411,7 @@ void SipSessionManager::locateSessionRouter()
ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
genericparams->category = Routing::V1::SessionRouterDiscoveryCategory;
- AsteriskSCF::ProxyWrapper::ProxyWrapper<SessionRouterPrx> pw(mServiceLocator, genericparams);
+ AsteriskSCF::SmartProxy::SmartProxy<SessionRouterPrx> pw(mServiceLocator, genericparams, lg);
mSessionRouter = pw;
}
commit 194e0aec2c80aa29bc392bdd75ee0939ea913bc6
Merge: 35690a8 99760a2
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Dec 2 09:13:40 2010 -0600
Merge branch 'master' of git.asterisk.org:asterisk-scf/release/sip
commit 99760a24dfcb9a04125215f114c93a746a9ff78e
Author: Darren Sessions <dsessions at digium.com>
Date: Thu Dec 2 08:53:02 2010 -0600
Added missing virtual destructor (PJSipModule)
diff --git a/src/PJSipModule.h b/src/PJSipModule.h
index c2d5034..2134ae3 100644
--- a/src/PJSipModule.h
+++ b/src/PJSipModule.h
@@ -47,6 +47,7 @@ public:
pjsip_module &getModule() { return mModule; };
protected:
PJSipModule() { }
+ virtual ~PJSipModule() { }
pjsip_module mModule;
private:
const std::string mName;
commit 35690a88a5eb3b1b3489ca00bcc7a9113dd164ea
Author: Mark Michelson <mmichelson at digium.com>
Date: Fri Nov 19 09:58:32 2010 -0600
Make Kevin's suggested change regarding renaming the callback member.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 654f67e..3f64de1 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -52,7 +52,7 @@ class RouteSessionCallback : public IceUtil::Shared
public:
RouteSessionCallback(pjsip_inv_session *inv_session, pjsip_tx_data *tdata)
: mInvSession(inv_session), mTData(tdata) { }
- void routeSessionCB(const Ice::AsyncResultPtr& r)
+ void callback(const Ice::AsyncResultPtr& r)
{
SessionRouterPrx router = SessionRouterPrx::uncheckedCast(r->getProxy());
try
@@ -461,7 +461,7 @@ void PJSipSessionModule::handleNewInvite(pjsip_rx_data *rdata)
{
// If this is not an attended transfer we can just route the session as normally
RouteSessionCallbackPtr cb = new RouteSessionCallback(inv_session, tdata);
- Ice::CallbackPtr d = Ice::newCallback(cb, &RouteSessionCallback::routeSessionCB);
+ Ice::CallbackPtr d = Ice::newCallback(cb, &RouteSessionCallback::callback);
mSessionRouter->begin_routeSession(session->getSessionProxy(), destination, d);
}
}
commit 478517fdad6acf1bd1fb59679f6428e27f8bfdf3
Author: Mark Michelson <mmichelson at digium.com>
Date: Fri Nov 19 09:56:24 2010 -0600
Address dlee's comments on Crucible.
I removed the cookie class entirely, and instead moved the
data that had been on the cookie previously into the callback
class. This also implicitly handles his comment regarding the
downcast of the cookie that was happening in the callback.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 68b8ec7..654f67e 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -47,41 +47,33 @@ using namespace AsteriskSCF::SessionCommunications::V1;
using namespace AsteriskSCF::Media::V1;
using namespace AsteriskSCF::SIP::V1;
-class RouteSessionCookie : public Ice::LocalObject
-{
-public:
- RouteSessionCookie(pjsip_inv_session *inv_session, pjsip_tx_data *tdata)
- : mInvSession(inv_session), mTData(tdata) { }
- pjsip_inv_session *mInvSession;
- pjsip_tx_data *mTData;
-};
-
-typedef IceUtil::Handle<RouteSessionCookie> RouteSessionCookiePtr;
-
class RouteSessionCallback : public IceUtil::Shared
{
public:
+ RouteSessionCallback(pjsip_inv_session *inv_session, pjsip_tx_data *tdata)
+ : mInvSession(inv_session), mTData(tdata) { }
void routeSessionCB(const Ice::AsyncResultPtr& r)
{
SessionRouterPrx router = SessionRouterPrx::uncheckedCast(r->getProxy());
- RouteSessionCookiePtr cookie = RouteSessionCookiePtr::dynamicCast(r->getCookie());
try
{
router->end_routeSession(r);
}
catch (const DestinationNotFoundException &)
{
- pjsip_inv_end_session(cookie->mInvSession, 404, NULL, &cookie->mTData);
- pjsip_inv_send_msg(cookie->mInvSession, cookie->mTData);
+ pjsip_inv_end_session(mInvSession, 404, NULL, &mTData);
+ pjsip_inv_send_msg(mInvSession, mTData);
}
catch (...)
{
- pjsip_inv_end_session(cookie->mInvSession, 500, NULL, &cookie->mTData);
- pjsip_inv_send_msg(cookie->mInvSession, cookie->mTData);
+ pjsip_inv_end_session(mInvSession, 500, NULL, &mTData);
+ pjsip_inv_send_msg(mInvSession, mTData);
}
}
+private:
+ pjsip_inv_session *mInvSession;
+ pjsip_tx_data *mTData;
};
-
typedef IceUtil::Handle<RouteSessionCallback> RouteSessionCallbackPtr;
PJSipSessionModInfo::PJSipSessionModInfo(pjsip_inv_session *inv_session,
@@ -468,10 +460,9 @@ void PJSipSessionModule::handleNewInvite(pjsip_rx_data *rdata)
else
{
// If this is not an attended transfer we can just route the session as normally
- RouteSessionCallbackPtr cb = new RouteSessionCallback();
+ RouteSessionCallbackPtr cb = new RouteSessionCallback(inv_session, tdata);
Ice::CallbackPtr d = Ice::newCallback(cb, &RouteSessionCallback::routeSessionCB);
- RouteSessionCookiePtr cookie = new RouteSessionCookie(inv_session, tdata);
- mSessionRouter->begin_routeSession(session->getSessionProxy(), destination, d, cookie);
+ mSessionRouter->begin_routeSession(session->getSessionProxy(), destination, d);
}
}
catch (const Ice::CommunicatorDestroyedException &)
commit aff455f2325eaeccf88893db4ed650d5062272ba
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Nov 18 10:45:48 2010 -0600
Use "const" qualifier for new exception catching blocks added in this branch.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 317e86d..68b8ec7 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -69,7 +69,7 @@ public:
{
router->end_routeSession(r);
}
- catch (DestinationNotFoundException &)
+ catch (const DestinationNotFoundException &)
{
pjsip_inv_end_session(cookie->mInvSession, 404, NULL, &cookie->mTData);
pjsip_inv_send_msg(cookie->mInvSession, cookie->mTData);
@@ -474,7 +474,7 @@ void PJSipSessionModule::handleNewInvite(pjsip_rx_data *rdata)
mSessionRouter->begin_routeSession(session->getSessionProxy(), destination, d, cookie);
}
}
- catch (Ice::CommunicatorDestroyedException &)
+ catch (const Ice::CommunicatorDestroyedException &)
{
// Everything else doesn't really map so they just become internal server errors
pjsip_inv_end_session(inv_session, 500, NULL, &tdata);
commit b962dd79ee29ad9a06c680b0dbe588104629b98b
Merge: 390e088 694d39c
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Nov 16 17:33:33 2010 -0600
Merge branch 'master' into ami-route
commit 390e088c122ac31e79531fa887db0e5989662aa5
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Nov 16 17:20:10 2010 -0600
Create the PJSipManager before creating our communicator.
This ensures that pjlib is initialized prior to our threadhook being called.
Otherwise, client-side threads (used in AMI callbacks) will not be registered
with pjlib properly because the initialization would wipe them out.
diff --git a/src/SipSessionManagerApp.cpp b/src/SipSessionManagerApp.cpp
index 239fa42..fe93dcf 100644
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@ -488,6 +488,10 @@ void SipSessionManager::initialize(const std::string appName, const Ice::Communi
{
mAppName = appName;
+ // Initialize PJSIP
+ mPJSipManager = new PJSipManager(ic->getProperties());
+ lg(Debug) << "Created PJSIP manager";
+
//As nice as it is of IceBox to provide us with a communicator,
//we're going to create our own so that we can provide it with a threadhook.
//Yes, this could be done via a plugin, but this is easier. Go away.
@@ -497,10 +501,6 @@ void SipSessionManager::initialize(const std::string appName, const Ice::Communi
mCommunicator = Ice::initialize(id);
- // Initialize PJSIP
- mPJSipManager = new PJSipManager(mCommunicator->getProperties());
- lg(Debug) << "Created PJSIP manager";
-
// Create the global adapter.
mGlobalAdapter = mCommunicator->createObjectAdapter("SipSessionManagerAdapter");
lg(Debug) << "Created global object adapter";
commit 694d39c2f6d9bd8aac2a49263c24d12a7fd81300
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Mon Nov 15 18:06:22 2010 -0600
Fix up a few comments for accuracy.
diff --git a/src/SipSessionManagerApp.cpp b/src/SipSessionManagerApp.cpp
index 239fa42..2d6c152 100644
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@ -76,7 +76,8 @@ public:
mLocalAdapter = 0;
}
-public: // Overrides of IceBox::Service
+public:
+ // Overloads of IceBox::Service
virtual void start(const string& name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq& args);
virtual void stop();
@@ -554,7 +555,7 @@ void SipSessionManager::initialize(const std::string appName, const Ice::Communi
}
/**
- * Overload of the Ice::Application::run method.
+ * Overload of the IceBox::Service::start method.
*/
void SipSessionManager::start(const string& name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq& args)
{
@@ -588,6 +589,9 @@ void SipSessionManager::start(const string& name, const Ice::CommunicatorPtr& ic
}
}
+/**
+ * Overload of the IceBox::Service::stop method.
+ */
void SipSessionManager::stop()
{
// Remove our interfaces from the service locator.
commit b98a7cf0216ccd1744ad524fd7241b2fc48772c9
Author: Mark Michelson <mmichelson at digium.com>
Date: Mon Nov 15 16:04:32 2010 -0600
Fix up some tab/space inconsistency.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 5b2823a..317e86d 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -468,9 +468,9 @@ void PJSipSessionModule::handleNewInvite(pjsip_rx_data *rdata)
else
{
// If this is not an attended transfer we can just route the session as normally
- RouteSessionCallbackPtr cb = new RouteSessionCallback();
- Ice::CallbackPtr d = Ice::newCallback(cb, &RouteSessionCallback::routeSessionCB);
- RouteSessionCookiePtr cookie = new RouteSessionCookie(inv_session, tdata);
+ RouteSessionCallbackPtr cb = new RouteSessionCallback();
+ Ice::CallbackPtr d = Ice::newCallback(cb, &RouteSessionCallback::routeSessionCB);
+ RouteSessionCookiePtr cookie = new RouteSessionCookie(inv_session, tdata);
mSessionRouter->begin_routeSession(session->getSessionProxy(), destination, d, cookie);
}
}
commit 6a99b4f89401d3b3a26c06bbeadfd6ba0524c5d5
Author: Mark Michelson <mmichelson at digium.com>
Date: Mon Nov 15 15:32:13 2010 -0600
make routeSession use AMI.
diff --git a/slice b/slice
index df22de4..0c62939 160000
--- a/slice
+++ b/slice
@@ -1 +1 @@
-Subproject commit df22de4cdfa237ab7cbabbc8af895de73f554a9a
+Subproject commit 0c629393e2f05dc0ed43bcc6305880949df36289
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index e770b81..5b2823a 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -47,6 +47,43 @@ using namespace AsteriskSCF::SessionCommunications::V1;
using namespace AsteriskSCF::Media::V1;
using namespace AsteriskSCF::SIP::V1;
+class RouteSessionCookie : public Ice::LocalObject
+{
+public:
+ RouteSessionCookie(pjsip_inv_session *inv_session, pjsip_tx_data *tdata)
+ : mInvSession(inv_session), mTData(tdata) { }
+ pjsip_inv_session *mInvSession;
+ pjsip_tx_data *mTData;
+};
+
+typedef IceUtil::Handle<RouteSessionCookie> RouteSessionCookiePtr;
+
+class RouteSessionCallback : public IceUtil::Shared
+{
+public:
+ void routeSessionCB(const Ice::AsyncResultPtr& r)
+ {
+ SessionRouterPrx router = SessionRouterPrx::uncheckedCast(r->getProxy());
+ RouteSessionCookiePtr cookie = RouteSessionCookiePtr::dynamicCast(r->getCookie());
+ try
+ {
+ router->end_routeSession(r);
+ }
+ catch (DestinationNotFoundException &)
+ {
+ pjsip_inv_end_session(cookie->mInvSession, 404, NULL, &cookie->mTData);
+ pjsip_inv_send_msg(cookie->mInvSession, cookie->mTData);
+ }
+ catch (...)
+ {
+ pjsip_inv_end_session(cookie->mInvSession, 500, NULL, &cookie->mTData);
+ pjsip_inv_send_msg(cookie->mInvSession, cookie->mTData);
+ }
+ }
+};
+
+typedef IceUtil::Handle<RouteSessionCallback> RouteSessionCallbackPtr;
+
PJSipSessionModInfo::PJSipSessionModInfo(pjsip_inv_session *inv_session,
SipSessionPtr session)
:
@@ -431,17 +468,13 @@ void PJSipSessionModule::handleNewInvite(pjsip_rx_data *rdata)
else
{
// If this is not an attended transfer we can just route the session as normally
- mSessionRouter->routeSession(session->getSessionProxy(), destination);
+ RouteSessionCallbackPtr cb = new RouteSessionCallback();
+ Ice::CallbackPtr d = Ice::newCallback(cb, &RouteSessionCallback::routeSessionCB);
+ RouteSessionCookiePtr cookie = new RouteSessionCookie(inv_session, tdata);
+ mSessionRouter->begin_routeSession(session->getSessionProxy(), destination, d, cookie);
}
}
- catch (AsteriskSCF::Core::Routing::V1::DestinationNotFoundException&)
- {
- // Destination not found is special since we can actually map it to a good response code, 404
- pjsip_inv_end_session(inv_session, 404, NULL, &tdata);
- pjsip_inv_send_msg(inv_session, tdata);
- return;
- }
- catch (...)
+ catch (Ice::CommunicatorDestroyedException &)
{
// Everything else doesn't really map so they just become internal server errors
pjsip_inv_end_session(inv_session, 500, NULL, &tdata);
commit 359f65acbf5d6fe09fe981994321bab50a1c94a6
Author: David M. Lee <dlee at digium.com>
Date: Mon Nov 15 14:03:38 2010 -0600
Updated indentation to match the style guide.
diff --git a/src/PJSipDummyModule.h b/src/PJSipDummyModule.h
index ebf7444..02b64fe 100644
--- a/src/PJSipDummyModule.h
+++ b/src/PJSipDummyModule.h
@@ -23,16 +23,16 @@ namespace SipChannelService
class PJSipDummyModule : public PJSipModule
{
public:
- PJSipDummyModule(pjsip_endpoint *endpt);
- pj_status_t load(pjsip_endpoint *endpoint);
- pj_status_t start();
- pj_status_t stop();
- pj_status_t unload();
- pj_bool_t on_rx_request(pjsip_rx_data *rdata);
- pj_bool_t on_rx_response(pjsip_rx_data *rdata);
- pj_status_t on_tx_request(pjsip_tx_data *tdata);
- pj_status_t on_tx_response(pjsip_tx_data *tdata);
- void on_tsx_state(pjsip_transaction *tsx, pjsip_event *event);
+ PJSipDummyModule(pjsip_endpoint *endpt);
+ pj_status_t load(pjsip_endpoint *endpoint);
+ pj_status_t start();
+ pj_status_t stop();
+ pj_status_t unload();
+ pj_bool_t on_rx_request(pjsip_rx_data *rdata);
+ pj_bool_t on_rx_response(pjsip_rx_data *rdata);
+ pj_status_t on_tx_request(pjsip_tx_data *tdata);
+ pj_status_t on_tx_response(pjsip_tx_data *tdata);
+ void on_tsx_state(pjsip_transaction *tsx, pjsip_event *event);
};
};
diff --git a/src/PJSipDummyModuleConstruction.cpp b/src/PJSipDummyModuleConstruction.cpp
index 81299c1..623b3bf 100644
--- a/src/PJSipDummyModuleConstruction.cpp
+++ b/src/PJSipDummyModuleConstruction.cpp
@@ -29,68 +29,68 @@ static PJSipDummyModule *dummyModule;
static pj_status_t dummyLoad(pjsip_endpoint *endpoint)
{
- return dummyModule->load(endpoint);
+ return dummyModule->load(endpoint);
}
static pj_status_t dummyStart()
{
- return dummyModule->unload();
+ return dummyModule->unload();
}
static pj_status_t dummyStop()
{
- return dummyModule->stop();
+ return dummyModule->stop();
}
static pj_status_t dummyUnload()
{
- return dummyModule->unload();
+ return dummyModule->unload();
}
static pj_bool_t dummyOnRxRequest(pjsip_rx_data *rdata)
{
- return dummyModule->on_rx_request(rdata);
+ return dummyModule->on_rx_request(rdata);
}
static pj_bool_t dummyOnRxResponse(pjsip_rx_data *rdata)
{
- return dummyModule->on_rx_response(rdata);
+ return dummyModule->on_rx_response(rdata);
}
static pj_bool_t dummyOnTxRequest(pjsip_tx_data *tdata)
{
- return dummyModule->on_tx_request(tdata);
+ return dummyModule->on_tx_request(tdata);
}
static pj_status_t dummyOnTxResponse(pjsip_tx_data *tdata)
{
- return dummyModule->on_tx_response(tdata);
+ return dummyModule->on_tx_response(tdata);
}
static void dummyOnTsxState(pjsip_transaction *tsx, pjsip_event *event)
{
- return dummyModule->on_tsx_state(tsx, event);
+ return dummyModule->on_tsx_state(tsx, event);
}
PJSipDummyModule::PJSipDummyModule(pjsip_endpoint *endpt)
{
- dummyModule = this;
- char name[] = "Dummy Module";
- mModule.name = pj_str(name);
- mModule.priority = PJSIP_MOD_PRIORITY_APPLICATION;
- /* Note that not all PJSIP module callbacks are required.
- * If you don't wish to have one defined, feel free to set
- * it NULL in this listing and remove the corresponding
- * static function above.
- */
- mModule.load = dummyLoad;
- mModule.start = dummyStart;
- mModule.stop = dummyStop;
- mModule.unload = dummyUnload;
- mModule.on_rx_request = dummyOnRxRequest;
- mModule.on_rx_response = dummyOnRxResponse;
- mModule.on_tx_request = dummyOnTxRequest;
- mModule.on_tx_response = dummyOnTxResponse;
- mModule.on_tsx_state = dummyOnTsxState;
- pjsip_endpt_register_module(endpt, &mModule);
+ dummyModule = this;
+ char name[] = "Dummy Module";
+ mModule.name = pj_str(name);
+ mModule.priority = PJSIP_MOD_PRIORITY_APPLICATION;
+ /* Note that not all PJSIP module callbacks are required.
+ * If you don't wish to have one defined, feel free to set
+ * it NULL in this listing and remove the corresponding
+ * static function above.
+ */
+ mModule.load = dummyLoad;
+ mModule.start = dummyStart;
+ mModule.stop = dummyStop;
+ mModule.unload = dummyUnload;
+ mModule.on_rx_request = dummyOnRxRequest;
+ mModule.on_rx_response = dummyOnRxResponse;
+ mModule.on_tx_request = dummyOnTxRequest;
+ mModule.on_tx_response = dummyOnTxResponse;
+ mModule.on_tsx_state = dummyOnTsxState;
+ pjsip_endpt_register_module(endpt, &mModule);
}
diff --git a/src/PJSipLoggingModule.cpp b/src/PJSipLoggingModule.cpp
index 74fae5b..f5f8b8b 100644
--- a/src/PJSipLoggingModule.cpp
+++ b/src/PJSipLoggingModule.cpp
@@ -32,50 +32,50 @@ namespace SipSessionManager
pj_status_t PJSipLoggingModule::load(pjsip_endpoint *endpt)
{
- return PJ_SUCCESS;
+ return PJ_SUCCESS;
}
pj_status_t PJSipLoggingModule::start()
{
- return PJ_SUCCESS;
+ return PJ_SUCCESS;
}
pj_status_t PJSipLoggingModule::stop()
{
- return PJ_SUCCESS;
+ return PJ_SUCCESS;
}
pj_status_t PJSipLoggingModule::unload()
{
- return PJ_SUCCESS;
+ return PJ_SUCCESS;
}
pj_bool_t PJSipLoggingModule::on_rx_request(pjsip_rx_data *rdata)
{
- lg(Debug) << "Incoming SIP request" << std::endl;
- lg(Debug) << rdata->pkt_info.packet << std::endl;
- return PJ_FALSE;
+ lg(Debug) << "Incoming SIP request" << std::endl;
+ lg(Debug) << rdata->pkt_info.packet << std::endl;
+ return PJ_FALSE;
}
pj_bool_t PJSipLoggingModule::on_rx_response(pjsip_rx_data *rdata)
{
- lg(Debug) << "Incoming SIP response" << std::endl;
- lg(Debug) << rdata->pkt_info.packet << std::endl;
- return PJ_FALSE;
+ lg(Debug) << "Incoming SIP response" << std::endl;
+ lg(Debug) << rdata->pkt_info.packet << std::endl;
+ return PJ_FALSE;
}
pj_status_t PJSipLoggingModule::on_tx_request(pjsip_tx_data *tdata)
{
- lg(Debug) << "Outgoing SIP request" << std::endl;
- lg(Debug) << tdata->buf.start << std::endl;
- return PJ_SUCCESS;
+ lg(Debug) << "Outgoing SIP request" << std::endl;
+ lg(Debug) << tdata->buf.start << std::endl;
+ return PJ_SUCCESS;
}
pj_status_t PJSipLoggingModule::on_tx_response(pjsip_tx_data *tdata)
{
- lg(Debug) << "Outgoing SIP response" << std::endl;
- lg(Debug) << tdata->buf.start << std::endl;
- return PJ_SUCCESS;
+ lg(Debug) << "Outgoing SIP response" << std::endl;
+ lg(Debug) << tdata->buf.start << std::endl;
+ return PJ_SUCCESS;
}
void PJSipLoggingModule::on_tsx_state(pjsip_transaction *tsx, pjsip_event *event)
diff --git a/src/PJSipLoggingModule.h b/src/PJSipLoggingModule.h
index dcfce4c..043187e 100644
--- a/src/PJSipLoggingModule.h
+++ b/src/PJSipLoggingModule.h
@@ -27,16 +27,16 @@ namespace SipSessionManager
class PJSipLoggingModule : public PJSipModule
{
public:
- PJSipLoggingModule(pjsip_endpoint *endpt);
- pj_status_t load(pjsip_endpoint *endpoint);
- pj_status_t start();
- pj_status_t stop();
- pj_status_t unload();
- pj_bool_t on_rx_request(pjsip_rx_data *rdata);
- pj_bool_t on_rx_response(pjsip_rx_data *rdata);
- pj_status_t on_tx_request(pjsip_tx_data *tdata);
- pj_status_t on_tx_response(pjsip_tx_data *tdata);
- void on_tsx_state(pjsip_transaction *tsx, pjsip_event *event);
+ PJSipLoggingModule(pjsip_endpoint *endpt);
+ pj_status_t load(pjsip_endpoint *endpoint);
+ pj_status_t start();
+ pj_status_t stop();
+ pj_status_t unload();
+ pj_bool_t on_rx_request(pjsip_rx_data *rdata);
+ pj_bool_t on_rx_response(pjsip_rx_data *rdata);
+ pj_status_t on_tx_request(pjsip_tx_data *tdata);
+ pj_status_t on_tx_response(pjsip_tx_data *tdata);
+ void on_tsx_state(pjsip_transaction *tsx, pjsip_event *event);
};
};
diff --git a/src/PJSipLoggingModuleConstruction.cpp b/src/PJSipLoggingModuleConstruction.cpp
index 06e5475..99960a3 100644
--- a/src/PJSipLoggingModuleConstruction.cpp
+++ b/src/PJSipLoggingModuleConstruction.cpp
@@ -26,70 +26,70 @@ static PJSipLoggingModule *loggingModule;
static pj_status_t loggingLoad(pjsip_endpoint *endpoint)
{
- return loggingModule->load(endpoint);
+ return loggingModule->load(endpoint);
}
static pj_status_t loggingStart()
{
- return loggingModule->unload();
+ return loggingModule->unload();
}
static pj_status_t loggingStop()
{
- return loggingModule->stop();
+ return loggingModule->stop();
}
static pj_status_t loggingUnload()
{
- return loggingModule->unload();
+ return loggingModule->unload();
}
static pj_bool_t loggingOnRxRequest(pjsip_rx_data *rdata)
{
- return loggingModule->on_rx_request(rdata);
+ return loggingModule->on_rx_request(rdata);
}
static pj_bool_t loggingOnRxResponse(pjsip_rx_data *rdata)
{
- return loggingModule->on_rx_response(rdata);
+ return loggingModule->on_rx_response(rdata);
}
static pj_bool_t loggingOnTxRequest(pjsip_tx_data *tdata)
{
- return loggingModule->on_tx_request(tdata);
+ return loggingModule->on_tx_request(tdata);
}
static pj_status_t loggingOnTxResponse(pjsip_tx_data *tdata)
{
- return loggingModule->on_tx_response(tdata);
+ return loggingModule->on_tx_response(tdata);
}
static void loggingOnTsxState(pjsip_transaction *tsx, pjsip_event *event)
{
- return loggingModule->on_tsx_state(tsx, event);
+ return loggingModule->on_tsx_state(tsx, event);
}
PJSipLoggingModule::PJSipLoggingModule(pjsip_endpoint *endpt)
{
- loggingModule = this;
- char name[] = "Logging Module";
- mModule.name = pj_str(name);
- // This is the highest priority module. We do this
- // so that on outgoing messages, the transport information
- // will have been filled in by the transport layer. This way
- // what we log is exactly the same as what goes out over the
- // wire.
- mModule.priority = 0;
- mModule.load = loggingLoad;
- mModule.start = loggingStart;
- mModule.stop = loggingStop;
- mModule.unload = loggingUnload;
- mModule.on_rx_request = loggingOnRxRequest;
- mModule.on_rx_response = loggingOnRxResponse;
- mModule.on_tx_request = loggingOnTxRequest;
- mModule.on_tx_response = loggingOnTxResponse;
- mModule.on_tsx_state = loggingOnTsxState;
- pjsip_endpt_register_module(endpt, &mModule);
+ loggingModule = this;
+ char name[] = "Logging Module";
+ mModule.name = pj_str(name);
+ // This is the highest priority module. We do this
+ // so that on outgoing messages, the transport information
+ // will have been filled in by the transport layer. This way
+ // what we log is exactly the same as what goes out over the
+ // wire.
+ mModule.priority = 0;
+ mModule.load = loggingLoad;
+ mModule.start = loggingStart;
+ mModule.stop = loggingStop;
+ mModule.unload = loggingUnload;
+ mModule.on_rx_request = loggingOnRxRequest;
+ mModule.on_rx_response = loggingOnRxResponse;
+ mModule.on_tx_request = loggingOnTxRequest;
+ mModule.on_tx_response = loggingOnTxResponse;
+ mModule.on_tsx_state = loggingOnTsxState;
+ pjsip_endpt_register_module(endpt, &mModule);
}
};
diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index 083911e..4270766 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -33,110 +33,110 @@ namespace SipSessionManager
static void *monitorThread(void *endpt)
{
- pjsip_endpoint *endpoint = static_cast<pjsip_endpoint *> (endpt);
- for (;;)
- {
- // No timeout is a bad idea in the long run, but for now,
- // let's just go with it.
- pjsip_endpt_handle_events(endpoint, NULL);
- }
-
- return NULL;
+ pjsip_endpoint *endpoint = static_cast<pjsip_endpoint *> (endpt);
+ for (;;)
+ {
+ // No timeout is a bad idea in the long run, but for now,
+ // let's just go with it.
+ pjsip_endpt_handle_events(endpoint, NULL);
+ }
+
+ return NULL;
}
PJSipManager::PJSipManager(Ice::PropertiesPtr props)
{
- pj_status_t status = pj_init();
- if (status != PJ_SUCCESS)
- {
- lg(Error) << "Failed to Initialize PJSIP";
- }
- // The third parameter is just copied from
- // example code from PJLIB. This can be adjusted
- // if necessary.
- pj_caching_pool_init(&mCachingPool, NULL, 1024 * 1024);
- pjsip_endpt_create(&mCachingPool.factory, "SIP", &mEndpoint);
- setTransports(mEndpoint, props);
- mMemoryPool = pj_pool_create(&mCachingPool.factory, "SIP", 1024, 1024, NULL);
- if (!mMemoryPool)
- {
- lg(Error) << "Failed to create a memory pool";
- }
- status = pj_thread_create(mMemoryPool, "SIP", (pj_thread_proc *) &monitorThread,
- mEndpoint, PJ_THREAD_DEFAULT_STACK_SIZE, 0, &mPjThread);
- if (status != PJ_SUCCESS)
- {
- lg(Error) << "Failed to create SIP maintenance thread";
- }
+ pj_status_t status = pj_init();
+ if (status != PJ_SUCCESS)
+ {
+ lg(Error) << "Failed to Initialize PJSIP";
+ }
+ // The third parameter is just copied from
+ // example code from PJLIB. This can be adjusted
+ // if necessary.
+ pj_caching_pool_init(&mCachingPool, NULL, 1024 * 1024);
+ pjsip_endpt_create(&mCachingPool.factory, "SIP", &mEndpoint);
+ setTransports(mEndpoint, props);
+ mMemoryPool = pj_pool_create(&mCachingPool.factory, "SIP", 1024, 1024, NULL);
+ if (!mMemoryPool)
+ {
+ lg(Error) << "Failed to create a memory pool";
+ }
+ status = pj_thread_create(mMemoryPool, "SIP", (pj_thread_proc *) &monitorThread,
+ mEndpoint, PJ_THREAD_DEFAULT_STACK_SIZE, 0, &mPjThread);
+ if (status != PJ_SUCCESS)
+ {
+ lg(Error) << "Failed to create SIP maintenance thread";
+ }
}
void PJSipManager::registerSessionModule(pjsip_endpoint *endpt,
- boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
- AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
- AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
- AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
- AsteriskSCF::System::Component::V1::ReplicaPtr replica
- )
+ boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
+ AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
+ AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
+ AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
+ AsteriskSCF::System::Component::V1::ReplicaPtr replica
+ )
{
- mSessionModule = new PJSipSessionModule(endpt, endpointFactoryPtr, sessionRouter,
- serviceLocator, stateReplicator, replica);
+ mSessionModule = new PJSipSessionModule(endpt, endpointFactoryPtr, sessionRouter,
+ serviceLocator, stateReplicator, replica);
}
void PJSipManager::registerLoggingModule(pjsip_endpoint *endpt)
{
- mLoggingModule = new PJSipLoggingModule(endpt);
+ mLoggingModule = new PJSipLoggingModule(endpt);
}
pjsip_endpoint *PJSipManager::getEndpoint()
{
- return mEndpoint;
+ return mEndpoint;
}
PJSipSessionModule *PJSipManager::getSessionModule()
{
- return mSessionModule;
+ return mSessionModule;
}
PJSipLoggingModule *PJSipManager::getLoggingModule()
{
- return mLoggingModule;
+ return mLoggingModule;
}
bool PJSipManager::setTransports(pjsip_endpoint *endpoint, Ice::PropertiesPtr props)
{
- //XXX We'll also want to allow for TCP and TLS-specific
- //addresses to be specified.
- pj_sockaddr udpAddr;
- pj_status_t status;
- std::string udpBindAddr = props->getPropertyWithDefault("Sip.Transport.UdpBindAddr", "0.0.0.0:5060");
- pj_str_t udpString;
- pj_cstr(&udpString, udpBindAddr.c_str());
- //UNSPEC family means "you figure out the address family, pjlib!"
- pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &udpString, &udpAddr);
- if (udpAddr.addr.sa_family == pj_AF_INET())
- {
- //XXX The fourth parameter should probably be controlled through
- //configuration. PJSIP reference says it should be the number of
- //processors on the machine.
- //
- status = pjsip_udp_transport_start(endpoint, &udpAddr.ipv4, NULL, 2, &mUdpTransport);
- if (status != PJ_SUCCESS)
- {
- lg(Error) << "Failed to create IPv4 UDP transport. DANG!";
- }
- }
- else if (udpAddr.addr.sa_family == pj_AF_INET6())
- {
- status = pjsip_udp_transport_start6(endpoint, &udpAddr.ipv6, NULL, 2, &mUdpTransport);
- if (status != PJ_SUCCESS)
- {
- lg(Error) << "Failed to create IPv4 UDP transport. DANG!";
- }
- }
- //XXX Note that TCP and TLS stuff should be done here. Also note that
- //currently PJSIP does not have functions for starting IPv6 TCP or
- //TLS transports, so we'll have to modify the code to allow for it.
- return true;
+ //XXX We'll also want to allow for TCP and TLS-specific
+ //addresses to be specified.
+ pj_sockaddr udpAddr;
+ pj_status_t status;
+ std::string udpBindAddr = props->getPropertyWithDefault("Sip.Transport.UdpBindAddr", "0.0.0.0:5060");
+ pj_str_t udpString;
+ pj_cstr(&udpString, udpBindAddr.c_str());
+ //UNSPEC family means "you figure out the address family, pjlib!"
+ pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &udpString, &udpAddr);
+ if (udpAddr.addr.sa_family == pj_AF_INET())
+ {
+ //XXX The fourth parameter should probably be controlled through
+ //configuration. PJSIP reference says it should be the number of
+ //processors on the machine.
+ //
+ status = pjsip_udp_transport_start(endpoint, &udpAddr.ipv4, NULL, 2, &mUdpTransport);
+ if (status != PJ_SUCCESS)
+ {
+ lg(Error) << "Failed to create IPv4 UDP transport. DANG!";
+ }
+ }
+ else if (udpAddr.addr.sa_family == pj_AF_INET6())
+ {
+ status = pjsip_udp_transport_start6(endpoint, &udpAddr.ipv6, NULL, 2, &mUdpTransport);
+ if (status != PJ_SUCCESS)
+ {
+ lg(Error) << "Failed to create IPv4 UDP transport. DANG!";
+ }
+ }
+ //XXX Note that TCP and TLS stuff should be done here. Also note that
+ //currently PJSIP does not have functions for starting IPv6 TCP or
+ //TLS transports, so we'll have to modify the code to allow for it.
+ return true;
}
}; //End namespace SipSessionManager
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index b9d1e5a..7cc5220 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -45,51 +45,51 @@ namespace SipSessionManager
class PJSipManager
{
public:
- PJSipManager(Ice::PropertiesPtr props);
- /**
- * Get a handle to the PJSipEndpoint for operations
- * that may require it
- */
- pjsip_endpoint *getEndpoint();
+ PJSipManager(Ice::PropertiesPtr props);
+ /**
+ * Get a handle to the PJSipEndpoint for operations
+ * that may require it
+ */
+ pjsip_endpoint *getEndpoint();
- /**
- * Get a reference to the PJSIP session module
- */
- PJSipSessionModule *getSessionModule();
+ /**
+ * Get a reference to the PJSIP session module
+ */
+ PJSipSessionModule *getSessionModule();
- /**
- * Get a reference to the PJSIP logging module
- */
- PJSipLoggingModule *getLoggingModule();
+ /**
+ * Get a reference to the PJSIP logging module
+ */
+ PJSipLoggingModule *getLoggingModule();
- /**
- * Register the PJSipSessionModule, responsible
- * for basic call handling
- */
- void registerSessionModule(pjsip_endpoint *endpt,
- boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
- AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
- AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
- AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
- AsteriskSCF::System::Component::V1::ReplicaPtr replica
- );
+ /**
+ * Register the PJSipSessionModule, responsible
+ * for basic call handling
+ */
+ void registerSessionModule(pjsip_endpoint *endpt,
+ boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
+ AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
+ AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
+ AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
+ AsteriskSCF::System::Component::V1::ReplicaPtr replica
+ );
- /**
- * Register the PJSipLoggingModule, responsible
- * for logging incoming and outgoing SIP messages
- */
- void registerLoggingModule(pjsip_endpoint *endpt);
+ /**
+ * Register the PJSipLoggingModule, responsible
+ * for logging incoming and outgoing SIP messages
+ */
+ void registerLoggingModule(pjsip_endpoint *endpt);
private:
- static PJSipManager *mInstance;
- pjsip_endpoint *mEndpoint;
- PJSipSessionModule *mSessionModule;
- PJSipLoggingModule *mLoggingModule;
- pj_thread_t *mPjThread;
- pj_caching_pool mCachingPool;
- pj_pool_t *mMemoryPool;
- pjsip_transport *mUdpTransport;
+ static PJSipManager *mInstance;
+ pjsip_endpoint *mEndpoint;
+ PJSipSessionModule *mSessionModule;
+ PJSipLoggingModule *mLoggingModule;
+ pj_thread_t *mPjThread;
+ pj_caching_pool mCachingPool;
+ pj_pool_t *mMemoryPool;
+ pjsip_transport *mUdpTransport;
- bool setTransports(pjsip_endpoint *endpoint, Ice::PropertiesPtr props);
+ bool setTransports(pjsip_endpoint *endpoint, Ice::PropertiesPtr props);
};
}; //End namespace SipSessionManager
diff --git a/src/PJSipModule.cpp b/src/PJSipModule.cpp
index ba4de0a..0b92ec6 100644
--- a/src/PJSipModule.cpp
+++ b/src/PJSipModule.cpp
@@ -37,15 +37,15 @@ const int URI_SIZE = 64;
PJSipDialogModInfo::PJSipDialogModInfo(pjsip_dialog *dialog) : mDialogState(new SipDialogStateItem) , mNeedsReplication(true), mNeedsRemoval(false)
{
- //XXX Is there a way to tell ICE to make the default
- //constructor for SipStateItem set key?
- mDialogState->key = IceUtil::generateUUID();
- updateDialogState(dialog);
+ //XXX Is there a way to tell ICE to make the default
+ //constructor for SipStateItem set key?
+ mDialogState->key = IceUtil::generateUUID();
+ updateDialogState(dialog);
}
PJSipDialogModInfo::~PJSipDialogModInfo()
{
- mDialogState = 0;
+ mDialogState = 0;
}
/**
@@ -58,100 +58,100 @@ PJSipDialogModInfo::~PJSipDialogModInfo()
*/
void PJSipDialogModInfo::updateDialogState(pjsip_dialog *dialog)
{
- mDialogState->mCallId = std::string(pj_strbuf(&dialog->call_id->id), pj_strlen(&dialog->call_id->id));
- mDialogState->mIsDialogEstablished = dialog->state == PJSIP_DIALOG_STATE_ESTABLISHED ? true : false;
- mDialogState->mIsSecure = dialog->secure == PJ_TRUE ? true : false;
-
- mDialogState->mLocalCSeq = dialog->local.cseq;
- mDialogState->mLocalTag = std::string(pj_strbuf(&dialog->local.info->tag), pj_strlen(&dialog->local.info->tag));
- char localUri[URI_SIZE];
- pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, dialog->local.info->uri, localUri, sizeof(localUri));
- mDialogState->mLocalUri = localUri;
-
- mDialogState->mRemoteCSeq = dialog->remote.cseq;
- mDialogState->mRemoteTag = std::string(pj_strbuf(&dialog->remote.info->tag), pj_strlen(&dialog->remote.info->tag));
- char remoteUri[URI_SIZE];
- pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, dialog->remote.info->uri, remoteUri, sizeof(remoteUri));
- mDialogState->mRemoteUri = remoteUri;
-
- //This is a place where the whole "only change what you need" optimization
- //will come in super-handy since we have to erase and rebuild the route set
- //every time. My recollection is that the route set can only be established
- //in the first transaction of a dialog so this is purdy wasteful.
- mDialogState->mRouteSet.erase(mDialogState->mRouteSet.begin(), mDialogState->mRouteSet.end());
- for (pjsip_route_hdr *hdr_iter = dialog->route_set.next; hdr_iter != &dialog->route_set; hdr_iter = hdr_iter->next)
- {
- char routeUri[URI_SIZE];
- pjsip_uri_print(PJSIP_URI_IN_ROUTING_HDR, hdr_iter->name_addr.uri, routeUri, sizeof(routeUri));
-
- //XXX I need to see the order in which the route set is represented
- //in a pjsip dialog. push_back could be completely incorrect here,
- //or it may only be correct depending on whether we're the UAC or UAS.
- //Also, for now we're ignoring the optional display name portion of URIs
- //in the route set. They're not strictly necessary for routing calls correctly.
- mDialogState->mRouteSet.push_back(routeUri);
- }
- //XXX I'm not 100% sure how to get the transport from a pjsip_dialog, so for now,
- //I'll just hardcode this as UDP until we start wanting to actually implement
- //other transports.
- mDialogState->mTransport = "UDP";
- mNeedsReplication = true;
+ mDialogState->mCallId = std::string(pj_strbuf(&dialog->call_id->id), pj_strlen(&dialog->call_id->id));
+ mDialogState->mIsDialogEstablished = dialog->state == PJSIP_DIALOG_STATE_ESTABLISHED ? true : false;
+ mDialogState->mIsSecure = dialog->secure == PJ_TRUE ? true : false;
+
+ mDialogState->mLocalCSeq = dialog->local.cseq;
+ mDialogState->mLocalTag = std::string(pj_strbuf(&dialog->local.info->tag), pj_strlen(&dialog->local.info->tag));
+ char localUri[URI_SIZE];
+ pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, dialog->local.info->uri, localUri, sizeof(localUri));
+ mDialogState->mLocalUri = localUri;
+
+ mDialogState->mRemoteCSeq = dialog->remote.cseq;
+ mDialogState->mRemoteTag = std::string(pj_strbuf(&dialog->remote.info->tag), pj_strlen(&dialog->remote.info->tag));
+ char remoteUri[URI_SIZE];
+ pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, dialog->remote.info->uri, remoteUri, sizeof(remoteUri));
+ mDialogState->mRemoteUri = remoteUri;
+
+ //This is a place where the whole "only change what you need" optimization
+ //will come in super-handy since we have to erase and rebuild the route set
+ //every time. My recollection is that the route set can only be established
+ //in the first transaction of a dialog so this is purdy wasteful.
+ mDialogState->mRouteSet.erase(mDialogState->mRouteSet.begin(), mDialogState->mRouteSet.end());
+ for (pjsip_route_hdr *hdr_iter = dialog->route_set.next; hdr_iter != &dialog->route_set; hdr_iter = hdr_iter->next)
+ {
+ char routeUri[URI_SIZE];
+ pjsip_uri_print(PJSIP_URI_IN_ROUTING_HDR, hdr_iter->name_addr.uri, routeUri, sizeof(routeUri));
+
+ //XXX I need to see the order in which the route set is represented
+ //in a pjsip dialog. push_back could be completely incorrect here,
+ //or it may only be correct depending on whether we're the UAC or UAS.
+ //Also, for now we're ignoring the optional display name portion of URIs
+ //in the route set. They're not strictly necessary for routing calls correctly.
+ mDialogState->mRouteSet.push_back(routeUri);
+ }
+ //XXX I'm not 100% sure how to get the transport from a pjsip_dialog, so for now,
+ //I'll just hardcode this as UDP until we start wanting to actually implement
+ //other transports.
+ mDialogState->mTransport = "UDP";
+ mNeedsReplication = true;
}
PJSipTransactionModInfo::PJSipTransactionModInfo(pjsip_transaction *transaction) : mTransactionState(new SipTransactionStateItem), mNeedsReplication(true), mNeedsRemoval(false)
{
- mTransactionState->key = IceUtil::generateUUID();
- updateTransactionState(transaction);
+ mTransactionState->key = IceUtil::generateUUID();
+ updateTransactionState(transaction);
}
PJSipTransactionModInfo::~PJSipTransactionModInfo()
{
- mTransactionState = 0;
+ mTransactionState = 0;
}
void PJSipTransactionModInfo::updateTransactionState(pjsip_transaction *transaction)
{
- mTransactionState->mBranch = std::string(pj_strbuf(&transaction->branch), pj_strlen(&transaction->branch));
- mTransactionState->mIsClient = (transaction->role == PJSIP_ROLE_UAC || transaction->role == PJSIP_UAC_ROLE) ? true : false;
- mTransactionState->mCurrentState = transactionStateTranslate(transaction->state);
- mNeedsReplication = true;
+ mTransactionState->mBranch = std::string(pj_strbuf(&transaction->branch), pj_strlen(&transaction->branch));
+ mTransactionState->mIsClient = (transaction->role == PJSIP_ROLE_UAC || transaction->role == PJSIP_UAC_ROLE) ? true : false;
+ mTransactionState->mCurrentState = transactionStateTranslate(transaction->state);
+ mNeedsReplication = true;
}
TransactionState PJSipTransactionModInfo::transactionStateTranslate(pjsip_tsx_state_e state)
{
- TransactionState retState;
- switch (state)
- {
- case PJSIP_TSX_STATE_NULL:
- retState = TransactionStateNull;
- break;
- case PJSIP_TSX_STATE_CALLING:
- retState = TransactionStateCalling;
- break;
- case PJSIP_TSX_STATE_TRYING:
- retState = TransactionStateTrying;
- break;
- case PJSIP_TSX_STATE_PROCEEDING:
- retState = TransactionStateProceeding;
- break;
- case PJSIP_TSX_STATE_COMPLETED:
- retState = TransactionStateCompleted;
- break;
- case PJSIP_TSX_STATE_CONFIRMED:
- retState = TransactionStateConfirmed;
- break;
- case PJSIP_TSX_STATE_TERMINATED:
- retState = TransactionStateTerminated;
- break;
- case PJSIP_TSX_STATE_DESTROYED:
- retState = TransactionStateDestroyed;
- break;
- default:
- lg(Error) << "Unknown PJSIP Transaction state encountered: " << state;
- retState = TransactionStateNull;
- break;
- }
- return retState;
+ TransactionState retState;
+ switch (state)
+ {
+ case PJSIP_TSX_STATE_NULL:
+ retState = TransactionStateNull;
+ break;
+ case PJSIP_TSX_STATE_CALLING:
+ retState = TransactionStateCalling;
+ break;
+ case PJSIP_TSX_STATE_TRYING:
+ retState = TransactionStateTrying;
+ break;
+ case PJSIP_TSX_STATE_PROCEEDING:
+ retState = TransactionStateProceeding;
+ break;
+ case PJSIP_TSX_STATE_COMPLETED:
+ retState = TransactionStateCompleted;
+ break;
+ case PJSIP_TSX_STATE_CONFIRMED:
+ retState = TransactionStateConfirmed;
+ break;
+ case PJSIP_TSX_STATE_TERMINATED:
+ retState = TransactionStateTerminated;
+ break;
+ case PJSIP_TSX_STATE_DESTROYED:
+ retState = TransactionStateDestroyed;
+ break;
+ default:
+ lg(Error) << "Unknown PJSIP Transaction state encountered: " << state;
+ retState = TransactionStateNull;
+ break;
+ }
+ return retState;
}
};
diff --git a/src/PJSipModule.h b/src/PJSipModule.h
index d96aa76..c2d5034 100644
--- a/src/PJSipModule.h
+++ b/src/PJSipModule.h
@@ -35,45 +35,45 @@ using namespace AsteriskSCF::SIP::V1;
class PJSipModule
{
public:
- virtual pj_status_t load(pjsip_endpoint *endpoint) = 0;
- virtual pj_status_t start() = 0;
- virtual pj_status_t stop() = 0;
- virtual pj_status_t unload() = 0;
- virtual pj_bool_t on_rx_request(pjsip_rx_data *rdata) = 0;
- virtual pj_bool_t on_rx_response(pjsip_rx_data *rdata) = 0;
- virtual pj_status_t on_tx_request(pjsip_tx_data *tdata) = 0;
- virtual pj_status_t on_tx_response(pjsip_tx_data *tdata) = 0;
- virtual void on_tsx_state(pjsip_transaction *tsx, pjsip_event *event) = 0;
- pjsip_module &getModule() { return mModule; };
+ virtual pj_status_t load(pjsip_endpoint *endpoint) = 0;
+ virtual pj_status_t start() = 0;
+ virtual pj_status_t stop() = 0;
+ virtual pj_status_t unload() = 0;
+ virtual pj_bool_t on_rx_request(pjsip_rx_data *rdata) = 0;
+ virtual pj_bool_t on_rx_response(pjsip_rx_data *rdata) = 0;
+ virtual pj_status_t on_tx_request(pjsip_tx_data *tdata) = 0;
+ virtual pj_status_t on_tx_response(pjsip_tx_data *tdata) = 0;
+ virtual void on_tsx_state(pjsip_transaction *tsx, pjsip_event *event) = 0;
+ pjsip_module &getModule() { return mModule; };
protected:
- PJSipModule() { }
- pjsip_module mModule;
+ PJSipModule() { }
+ pjsip_module mModule;
private:
- const std::string mName;
+ const std::string mName;
};
class PJSipDialogModInfo
{
public:
- PJSipDialogModInfo(pjsip_dialog *dialog);
- ~PJSipDialogModInfo();
- void updateDialogState(pjsip_dialog *dialog);
- SipDialogStateItemPtr mDialogState;
- bool mNeedsReplication;
- bool mNeedsRemoval;
+ PJSipDialogModInfo(pjsip_dialog *dialog);
+ ~PJSipDialogModInfo();
+ void updateDialogState(pjsip_dialog *dialog);
+ SipDialogStateItemPtr mDialogState;
+ bool mNeedsReplication;
+ bool mNeedsRemoval;
};
class PJSipTransactionModInfo
{
public:
- PJSipTransactionModInfo(pjsip_transaction *transaction);
- ~PJSipTransactionModInfo();
- void updateTransactionState(pjsip_transaction *transaction);
- SipTransactionStateItemPtr mTransactionState;
- bool mNeedsReplication;
- bool mNeedsRemoval;
+ PJSipTransactionModInfo(pjsip_transaction *transaction);
+ ~PJSipTransactionModInfo();
+ void updateTransactionState(pjsip_transaction *transaction);
+ SipTransactionStateItemPtr mTransactionState;
+ bool mNeedsReplication;
+ bool mNeedsRemoval;
private:
- TransactionState transactionStateTranslate(pjsip_tsx_state_e state);
+ TransactionState transactionStateTranslate(pjsip_tsx_state_e state);
};
}; //end namespace SipSessionManager
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 64567d6..e770b81 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -48,603 +48,603 @@ using namespace AsteriskSCF::Media::V1;
using namespace AsteriskSCF::SIP::V1;
PJSipSessionModInfo::PJSipSessionModInfo(pjsip_inv_session *inv_session,
- SipSessionPtr session)
- :
- mSessionState(new SipSessionStateItem),
- mInviteState(new SipInviteSessionStateItem),
- mNeedsReplication(true),
- mNeedsRemoval(false),
- mSession(session)
+ SipSessionPtr session)
+ :
+ mSessionState(new SipSessionStateItem),
+ mInviteState(new SipInviteSessionStateItem),
+ mNeedsReplication(true),
+ mNeedsRemoval(false),
+ mSession(session)
{
- mSessionState->key = IceUtil::generateUUID();
- mInviteState->key = IceUtil::generateUUID();
- mSessionState->mSessionId = mSessionState->key;
- mInviteState->mSessionId = mSessionState->key;
- updateSessionState(inv_session);
+ mSessionState->key = IceUtil::generateUUID();
+ mInviteState->key = IceUtil::generateUUID();
+ mSessionState->mSessionId = mSessionState->key;
+ mInviteState->mSessionId = mSessionState->key;
+ updateSessionState(inv_session);
}
PJSipSessionModInfo::~PJSipSessionModInfo()
{
- if (mSession)
- {
- mSession->destroy();
- mSession = 0;
- }
+ if (mSession)
+ {
+ mSession->destroy();
+ mSession = 0;
+ }
}
void PJSipSessionModInfo::updateSessionState(pjsip_inv_session *inv_session)
{
- boost::unique_lock<boost::shared_mutex> lock(mLock);
- if (mSession)
- {
- mSessionState->mEndpointName = mSession->getEndpoint()->getName();
- mSessionState->mSessionObjectId = mSession->getSessionProxy()->ice_getIdentity();
- mSessionState->mMediaSessionObjectId = mSession->getMediaSessionProxy()->ice_getIdentity();
- mSessionState->mSources = mSession->getSources();
- mSessionState->mSinks = mSession->getSinks();
- mSessionState->mMediaSession = mSession->getHiddenMediaSession();
- mSessionState->mListeners = mSession->getListeners();
- try
- {
- Ice::Current current;
- mSessionState->mBridge = mSession->getBridge(current);
- }
- catch (...)
- {
- mSessionState->mBridge = 0;
- }
- }
-
- //Now we get stuff from the inv_session itself.
- mInviteState->mCancelling = inv_session->cancelling == PJ_TRUE ? true : false;
- mInviteState->mPendingCancel = inv_session->pending_cancel == PJ_TRUE ? true : false;
- mInviteState->mCause = inv_session->cause;
- mInviteState->mCauseText = std::string(pj_strbuf(&inv_session->cause_text), pj_strlen(&inv_session->cause_text));
- mInviteState->mNotify = inv_session->notify == PJ_TRUE ? true : false;
- mInviteState->mLastAckCseq = inv_session->last_ack_cseq;
- mInviteState->mCurrentState = inviteStateTranslate(inv_session->state);
- mNeedsReplication = true;
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ if (mSession)
+ {
+ mSessionState->mEndpointName = mSession->getEndpoint()->getName();
+ mSessionState->mSessionObjectId = mSession->getSessionProxy()->ice_getIdentity();
+ mSessionState->mMediaSessionObjectId = mSession->getMediaSessionProxy()->ice_getIdentity();
+ mSessionState->mSources = mSession->getSources();
+ mSessionState->mSinks = mSession->getSinks();
+ mSessionState->mMediaSession = mSession->getHiddenMediaSession();
+ mSessionState->mListeners = mSession->getListeners();
+ try
+ {
+ Ice::Current current;
+ mSessionState->mBridge = mSession->getBridge(current);
+ }
+ catch (...)
+ {
+ mSessionState->mBridge = 0;
+ }
+ }
+
+ //Now we get stuff from the inv_session itself.
+ mInviteState->mCancelling = inv_session->cancelling == PJ_TRUE ? true : false;
+ mInviteState->mPendingCancel = inv_session->pending_cancel == PJ_TRUE ? true : false;
+ mInviteState->mCause = inv_session->cause;
+ mInviteState->mCauseText = std::string(pj_strbuf(&inv_session->cause_text), pj_strlen(&inv_session->cause_text));
+ mInviteState->mNotify = inv_session->notify == PJ_TRUE ? true : false;
+ mInviteState->mLastAckCseq = inv_session->last_ack_cseq;
+ mInviteState->mCurrentState = inviteStateTranslate(inv_session->state);
+ mNeedsReplication = true;
}
SipSessionPtr PJSipSessionModInfo::getSessionPtr()
{
- return mSession;
+ return mSession;
}
void PJSipSessionModInfo::setSessionPtr(SipSessionPtr sessionPtr)
{
- mSession = sessionPtr;
+ mSession = sessionPtr;
}
InviteSessionState PJSipSessionModInfo::inviteStateTranslate(pjsip_inv_state state)
{
- InviteSessionState retState;
- switch (state)
- {
- case PJSIP_INV_STATE_NULL:
- retState = InviteSessionStateNull;
- break;
- case PJSIP_INV_STATE_CALLING:
- retState = InviteSessionStateCalling;
- break;
- case PJSIP_INV_STATE_INCOMING:
- retState = InviteSessionStateIncoming;
- break;
- case PJSIP_INV_STATE_EARLY:
- retState = InviteSessionStateEarly;
- break;
- case PJSIP_INV_STATE_CONNECTING:
- retState = InviteSessionStateConnecting;
- break;
- case PJSIP_INV_STATE_CONFIRMED:
- retState = InviteSessionStateConfirmed;
- break;
- case PJSIP_INV_STATE_DISCONNECTED:
- retState = InviteSessionStateDisconnected;
- break;
- default:
- lg(Warning) << "Unknwon PJSIP INVITE state encountered: " << state;
- retState = InviteSessionStateNull;
- break;
- }
- return retState;
+ InviteSessionState retState;
+ switch (state)
+ {
+ case PJSIP_INV_STATE_NULL:
+ retState = InviteSessionStateNull;
+ break;
+ case PJSIP_INV_STATE_CALLING:
+ retState = InviteSessionStateCalling;
+ break;
+ case PJSIP_INV_STATE_INCOMING:
+ retState = InviteSessionStateIncoming;
+ break;
+ case PJSIP_INV_STATE_EARLY:
+ retState = InviteSessionStateEarly;
+ break;
+ case PJSIP_INV_STATE_CONNECTING:
+ retState = InviteSessionStateConnecting;
+ break;
+ case PJSIP_INV_STATE_CONFIRMED:
+ retState = InviteSessionStateConfirmed;
+ break;
+ case PJSIP_INV_STATE_DISCONNECTED:
+ retState = InviteSessionStateDisconnected;
+ break;
+ default:
+ lg(Warning) << "Unknwon PJSIP INVITE state encountered: " << state;
+ retState = InviteSessionStateNull;
+ break;
+ }
+ return retState;
}
void PJSipSessionModule::replicateState(PJSipDialogModInfo *dlgInfo, PJSipTransactionModInfo *tsxInfo,
- PJSipSessionModInfo *sessionInfo)
+ PJSipSessionModInfo *sessionInfo)
{
- SipStateItemSeq setItems;
- Ice::StringSeq removeItems;
-
- lg(Debug) << "========== Begin State Replication Dump ==========";
-
- if (dlgInfo)
- {
- lg(Debug) << "--- Begin Dialog " << dlgInfo->mDialogState->key;
- lg(Debug) << "Callid: " << dlgInfo->mDialogState->mCallId;
- lg(Debug) << "Is Dialog Established: " << dlgInfo->mDialogState->mIsDialogEstablished;
- lg(Debug) << "Is Secure: " << dlgInfo->mDialogState->mIsSecure;
- lg(Debug) << "Local CSeq: " << dlgInfo->mDialogState->mLocalCSeq;
- lg(Debug) << "Local URI: " << dlgInfo->mDialogState->mLocalUri;
- lg(Debug) << "Remote CSeq: " << dlgInfo->mDialogState->mRemoteCSeq;
- lg(Debug) << "Remote URI: " << dlgInfo->mDialogState->mRemoteUri;
- lg(Debug) << "Transport: " << dlgInfo->mDialogState->mTransport;
- lg(Debug) << "UAC Has 2xx: " << dlgInfo->mDialogState->mUacHas2xx;
- lg(Debug) << "Is Uac: " << dlgInfo->mDialogState->mIsUac;
- if (dlgInfo->mNeedsRemoval == true)
- {
- lg(Debug) << "Removing dialog";
- removeItems.push_back(dlgInfo->mDialogState->key);
- }
- else if (dlgInfo->mNeedsReplication == true)
- {
- lg(Debug) << "Replicating dialog";
- setItems.push_back(dlgInfo->mDialogState);
- dlgInfo->mNeedsReplication = false;
- }
- lg(Debug) << "--- End Dialog " << dlgInfo->mDialogState->key;
- }
- if (sessionInfo)
- {
- boost::shared_lock<boost::shared_mutex> lock(sessionInfo->mLock);
- lg(Debug) << "--- Begin Session " << sessionInfo->mSessionState->key;
- lg(Debug) << "Endpoint name: " << sessionInfo->mSessionState->mEndpointName;
- lg(Debug) << "Session object identity: " << sessionInfo->mSessionState->mSessionObjectId.name;
- lg(Debug) << "Media session object identity: " << sessionInfo->mSessionState->mMediaSessionObjectId.name;
- lg(Debug) << "Media session: " << sessionInfo->mSessionState->mMediaSession;
- lg(Debug) << "Bridge: " << sessionInfo->mSessionState->mBridge;
- lg(Debug) << "--- Begin Invite Session " << sessionInfo->mInviteState->key;
- lg(Debug) << "Current state: " << sessionInfo->mInviteState->mCurrentState;
- lg(Debug) << "Cancelling: " << sessionInfo->mInviteState->mCancelling;
- lg(Debug) << "Pending cancel: " << sessionInfo->mInviteState->mPendingCancel;
- lg(Debug) << "Cause: " << sessionInfo->mInviteState->mCause;
- lg(Debug) << "Cause text: " << sessionInfo->mInviteState->mCauseText;
- lg(Debug) << "Notify: " << sessionInfo->mInviteState->mNotify;
- lg(Debug) << "Last Ack CSeq: " << sessionInfo->mInviteState->mLastAckCseq;
- if (sessionInfo->mNeedsRemoval == true)
- {
- removeItems.push_back(sessionInfo->mInviteState->key);
- removeItems.push_back(sessionInfo->mSessionState->key);
- lg(Debug) << "Removing session and invite session";
- }
- else if (sessionInfo->mNeedsReplication == true)
- {
- setItems.push_back(sessionInfo->mInviteState);
- setItems.insert(setItems.begin(), sessionInfo->mSessionState);
- sessionInfo->mNeedsReplication = false;
- lg(Debug) << "Replicating session and invite session";
- }
- lg(Debug) << "--- End Session and Invite Session";
- }
- if (tsxInfo)
- {
- if (tsxInfo->mNeedsRemoval == true)
- {
- removeItems.push_back(tsxInfo->mTransactionState->key);
- }
- else if (tsxInfo->mNeedsReplication == true)
- {
- setItems.push_back(tsxInfo->mTransactionState);
- tsxInfo->mNeedsReplication = false;
- }
- }
- lg(Debug) << "========== End State Replication Dump ==========";
- if (mReplica->isActive() == true)
- {
- if (setItems.size() != 0 && mStateReplicator)
- {
- Ice::ObjectPrx oneway;
- try
- {
- oneway = mStateReplicator->ice_oneway();
- }
- catch (const Ice::NoEndpointException&)
- {
- lg(Error) << "No endpoint for oneway invocation of setState() for state replication." << std::endl;
- }
-
- AsteriskSCF::SIP::V1::SipStateReplicatorPrx oneWayStateReplicator = AsteriskSCF::SIP::V1::SipStateReplicatorPrx::uncheckedCast(oneway);
-
- try
- {
- oneWayStateReplicator->setState(setItems);
- }
- catch (const Ice::TwowayOnlyException&)
- {
- lg(Error) << "setState() is not oneway." << std::endl;
- }
- }
-
- if (removeItems.size() != 0 && mStateReplicator)
- {
- Ice::ObjectPrx oneway;
- try
- {
- oneway = mStateReplicator->ice_oneway();
- }
- catch (const Ice::NoEndpointException&)
- {
- lg(Error) << "No endpoint for oneway invocation of removeState() for state replication." << std::endl;
- }
-
- AsteriskSCF::SIP::V1::SipStateReplicatorPrx oneWayStateReplicator = AsteriskSCF::SIP::V1::SipStateReplicatorPrx::uncheckedCast(oneway);
-
- try
- {
- oneWayStateReplicator->removeState(removeItems);
- }
- catch (const Ice::TwowayOnlyException&)
- {
- lg(Error) << "removeState() is not oneway." << std::endl;
- }
- }
- }
+ SipStateItemSeq setItems;
+ Ice::StringSeq removeItems;
+
+ lg(Debug) << "========== Begin State Replication Dump ==========";
+
+ if (dlgInfo)
+ {
+ lg(Debug) << "--- Begin Dialog " << dlgInfo->mDialogState->key;
+ lg(Debug) << "Callid: " << dlgInfo->mDialogState->mCallId;
+ lg(Debug) << "Is Dialog Established: " << dlgInfo->mDialogState->mIsDialogEstablished;
+ lg(Debug) << "Is Secure: " << dlgInfo->mDialogState->mIsSecure;
+ lg(Debug) << "Local CSeq: " << dlgInfo->mDialogState->mLocalCSeq;
+ lg(Debug) << "Local URI: " << dlgInfo->mDialogState->mLocalUri;
+ lg(Debug) << "Remote CSeq: " << dlgInfo->mDialogState->mRemoteCSeq;
+ lg(Debug) << "Remote URI: " << dlgInfo->mDialogState->mRemoteUri;
+ lg(Debug) << "Transport: " << dlgInfo->mDialogState->mTransport;
+ lg(Debug) << "UAC Has 2xx: " << dlgInfo->mDialogState->mUacHas2xx;
+ lg(Debug) << "Is Uac: " << dlgInfo->mDialogState->mIsUac;
+ if (dlgInfo->mNeedsRemoval == true)
+ {
+ lg(Debug) << "Removing dialog";
+ removeItems.push_back(dlgInfo->mDialogState->key);
+ }
+ else if (dlgInfo->mNeedsReplication == true)
+ {
+ lg(Debug) << "Replicating dialog";
+ setItems.push_back(dlgInfo->mDialogState);
+ dlgInfo->mNeedsReplication = false;
+ }
+ lg(Debug) << "--- End Dialog " << dlgInfo->mDialogState->key;
+ }
+ if (sessionInfo)
+ {
+ boost::shared_lock<boost::shared_mutex> lock(sessionInfo->mLock);
+ lg(Debug) << "--- Begin Session " << sessionInfo->mSessionState->key;
+ lg(Debug) << "Endpoint name: " << sessionInfo->mSessionState->mEndpointName;
+ lg(Debug) << "Session object identity: " << sessionInfo->mSessionState->mSessionObjectId.name;
+ lg(Debug) << "Media session object identity: " << sessionInfo->mSessionState->mMediaSessionObjectId.name;
+ lg(Debug) << "Media session: " << sessionInfo->mSessionState->mMediaSession;
+ lg(Debug) << "Bridge: " << sessionInfo->mSessionState->mBridge;
+ lg(Debug) << "--- Begin Invite Session " << sessionInfo->mInviteState->key;
+ lg(Debug) << "Current state: " << sessionInfo->mInviteState->mCurrentState;
+ lg(Debug) << "Cancelling: " << sessionInfo->mInviteState->mCancelling;
+ lg(Debug) << "Pending cancel: " << sessionInfo->mInviteState->mPendingCancel;
+ lg(Debug) << "Cause: " << sessionInfo->mInviteState->mCause;
+ lg(Debug) << "Cause text: " << sessionInfo->mInviteState->mCauseText;
+ lg(Debug) << "Notify: " << sessionInfo->mInviteState->mNotify;
+ lg(Debug) << "Last Ack CSeq: " << sessionInfo->mInviteState->mLastAckCseq;
+ if (sessionInfo->mNeedsRemoval == true)
+ {
+ removeItems.push_back(sessionInfo->mInviteState->key);
+ removeItems.push_back(sessionInfo->mSessionState->key);
+ lg(Debug) << "Removing session and invite session";
+ }
+ else if (sessionInfo->mNeedsReplication == true)
+ {
+ setItems.push_back(sessionInfo->mInviteState);
+ setItems.insert(setItems.begin(), sessionInfo->mSessionState);
+ sessionInfo->mNeedsReplication = false;
+ lg(Debug) << "Replicating session and invite session";
+ }
+ lg(Debug) << "--- End Session and Invite Session";
+ }
+ if (tsxInfo)
+ {
+ if (tsxInfo->mNeedsRemoval == true)
+ {
+ removeItems.push_back(tsxInfo->mTransactionState->key);
+ }
+ else if (tsxInfo->mNeedsReplication == true)
+ {
+ setItems.push_back(tsxInfo->mTransactionState);
+ tsxInfo->mNeedsReplication = false;
+ }
+ }
+ lg(Debug) << "========== End State Replication Dump ==========";
+ if (mReplica->isActive() == true)
+ {
+ if (setItems.size() != 0 && mStateReplicator)
+ {
+ Ice::ObjectPrx oneway;
+ try
+ {
+ oneway = mStateReplicator->ice_oneway();
+ }
+ catch (const Ice::NoEndpointException&)
+ {
+ lg(Error) << "No endpoint for oneway invocation of setState() for state replication." << std::endl;
+ }
+
+ AsteriskSCF::SIP::V1::SipStateReplicatorPrx oneWayStateReplicator = AsteriskSCF::SIP::V1::SipStateReplicatorPrx::uncheckedCast(oneway);
+
+ try
+ {
+ oneWayStateReplicator->setState(setItems);
+ }
+ catch (const Ice::TwowayOnlyException&)
+ {
+ lg(Error) << "setState() is not oneway." << std::endl;
+ }
+ }
+
+ if (removeItems.size() != 0 && mStateReplicator)
+ {
+ Ice::ObjectPrx oneway;
+ try
+ {
+ oneway = mStateReplicator->ice_oneway();
+ }
+ catch (const Ice::NoEndpointException&)
+ {
+ lg(Error) << "No endpoint for oneway invocation of removeState() for state replication." << std::endl;
+ }
+
+ AsteriskSCF::SIP::V1::SipStateReplicatorPrx oneWayStateReplicator = AsteriskSCF::SIP::V1::SipStateReplicatorPrx::uncheckedCast(oneway);
+
+ try
+ {
+ oneWayStateReplicator->removeState(removeItems);
+ }
+ catch (const Ice::TwowayOnlyException&)
+ {
+ lg(Error) << "removeState() is not oneway." << std::endl;
+ }
+ }
+ }
}
pj_status_t PJSipSessionModule::load(pjsip_endpoint *endpt)
{
- return PJ_SUCCESS;
+ return PJ_SUCCESS;
... 45328 lines suppressed ...
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list