[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "session-decorator" created.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Jun 28 17:58:57 CDT 2011
branch "session-decorator" has been created
at 59ccbfc493c091ebfe6d2a71d61026d9abf5a77c (commit)
- Log -----------------------------------------------------------------
commit 59ccbfc493c091ebfe6d2a71d61026d9abf5a77c
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Jun 28 17:58:26 2011 -0500
Add initial support for calling out to decorators.
Right now, we will call out and retrieve them, but we haven't implemented
the method of actually adding new hooks yet.
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 2a6af1a..06b5d2e 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -189,7 +189,8 @@ AsteriskSCF::SessionCommunications::V1::SessionPrx SipEndpoint::createSession(co
}
SipSessionPtr session = new SipSession(mImplPriv->mAdapter, this, destination, listener, mImplPriv->mManager,
- mImplPriv->mServiceLocator, mImplPriv->mReplica, mImplPriv->mConfig.sessionConfig.rtpOverIPv6, true);
+ mImplPriv->mServiceLocator, mImplPriv->mReplica, mImplPriv->mConfig.sessionConfig.rtpOverIPv6, true,
+ mImplPriv->mEndpointFactory->getDecorators());
mImplPriv->mSessions.push_back(session);
std::cout << "And now we're returing a session proxy..." << std::endl;
return session->getSessionProxy();
@@ -198,7 +199,8 @@ AsteriskSCF::SessionCommunications::V1::SessionPrx SipEndpoint::createSession(co
AsteriskSCF::SipSessionManager::SipSessionPtr SipEndpoint::createSession(const std::string& destination)
{
SipSessionPtr session = new SipSession(mImplPriv->mAdapter, this, destination, 0, mImplPriv->mManager,
- mImplPriv->mServiceLocator, mImplPriv->mReplica, mImplPriv->mConfig.sessionConfig.rtpOverIPv6, false);
+ mImplPriv->mServiceLocator, mImplPriv->mReplica, mImplPriv->mConfig.sessionConfig.rtpOverIPv6, false,
+ mImplPriv->mEndpointFactory->getDecorators());
mImplPriv->mSessions.push_back(session);
return session;
}
@@ -209,7 +211,8 @@ AsteriskSCF::SipSessionManager::SipSessionPtr SipEndpoint::createSession(const s
const AsteriskSCF::Media::V1::StreamSinkSeq& sinks)
{
SipSessionPtr session = new SipSession(mImplPriv->mAdapter, this, destination, sessionid, mediaid, mediasession,
- sources, sinks, mImplPriv->mManager, mImplPriv->mServiceLocator, mImplPriv->mReplica, false);
+ sources, sinks, mImplPriv->mManager, mImplPriv->mServiceLocator, mImplPriv->mReplica, false,
+ mImplPriv->mEndpointFactory->getDecorators());
mImplPriv->mSessions.push_back(session);
return session;
}
diff --git a/src/SipEndpointFactory.cpp b/src/SipEndpointFactory.cpp
index 61349c9..ff5b6b3 100644
--- a/src/SipEndpointFactory.cpp
+++ b/src/SipEndpointFactory.cpp
@@ -60,6 +60,10 @@ void SipEndpointFactory::generateRoutingDestinations(AsteriskSCF::Core::Routing:
destinations.push_back((*iter)->getName());
}
}
+AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq SipEndpointFactory::getDecorators()
+{
+ return mHooks;
+}
}; // end SipSessionManager
}; // end AsteriskSCF
diff --git a/src/SipEndpointFactory.h b/src/SipEndpointFactory.h
index d16637f..f29e8dc 100644
--- a/src/SipEndpointFactory.h
+++ b/src/SipEndpointFactory.h
@@ -21,6 +21,7 @@
#include <boost/enable_shared_from_this.hpp>
#include <AsteriskSCF/Core/Endpoint/EndpointIf.h>
+#include <AsteriskSCF/SessionCommunications/SessionCommunicationsExtensionPointsIf.h>
namespace AsteriskSCF
{
@@ -47,6 +48,8 @@ public:
SipEndpointPtr findByName(const std::string& endpointName);
void generateRoutingDestinations(AsteriskSCF::Core::Routing::V1::RegExSeq&);
+
+ AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq getDecorators();
private:
/**
* A pointer to the object adapter that endpoints will be added to.
@@ -72,6 +75,11 @@ private:
* A pointer to the replica information.
*/
AsteriskSCF::System::Component::V1::ReplicaPtr mReplica;
+
+ /**
+ * All the registered session decorator hooks
+ */
+ AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq mHooks;
};
}; // end SipSessionManager
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 972b5b0..35a1285 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -314,13 +314,51 @@ void SipSession::initializePJSIPStructs()
setInviteSession(inviteSession);
}
+void SipSession::setSessionProxy(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks)
+{
+ AsteriskSCF::SessionCommunications::V1::SessionPrx us =
+ AsteriskSCF::SessionCommunications::V1::SessionPrx::uncheckedCast(mImplPriv->mAdapter->addWithUUID(this));
+
+ bool decoratorSet = false;
+ for (AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq::const_iterator iter = hooks.begin();
+ iter != hooks.end(); ++iter)
+ {
+ AsteriskSCF::SessionCommunications::V1::SessionPrx decorator;
+ AsteriskSCF::System::Hook::V1::HookResult result;
+
+ try
+ {
+ result = (*iter)->decorateSession(us, decorator);
+ }
+ catch (const Ice::Exception& ex)
+ {
+ lg(Warning) << "Exception caught while trying to set a decorator: " << ex.what();
+ //XXX Probably should remove this hook from the list...
+ continue;
+ }
+
+ if (result.status == AsteriskSCF::System::Hook::V1::Succeeded)
+ {
+ mImplPriv->mSessionProxy = decorator;
+ decoratorSet = true;
+ break;
+ }
+ }
+
+ if (!decoratorSet)
+ {
+ mImplPriv->mSessionProxy = us;
+ }
+}
+
/**
* Default constructor.
*/
SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPtr& endpoint,
const std::string& destination, const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
PJSipManager *manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
- const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool ipv6, bool isUAC)
+ const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool ipv6, bool isUAC,
+ const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks)
: mImplPriv(new SipSessionPriv(adapter, endpoint, destination, manager, serviceLocator, replica))
{
if (listener != 0)
@@ -328,8 +366,7 @@ SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPt
mImplPriv->mListeners.push_back(listener);
}
- mImplPriv->mSessionProxy =
- AsteriskSCF::SessionCommunications::V1::SessionPrx::uncheckedCast(adapter->addWithUUID(this));
+ setSessionProxy(hooks);
mImplPriv->mMediaSession = new SipMediaSession(this);
mImplPriv->mMediaSessionProxy =
@@ -354,11 +391,11 @@ SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPt
const Ice::Identity& mediaid, const AsteriskSCF::Media::V1::SessionPrx& mediasession,
const AsteriskSCF::Media::V1::StreamSourceSeq& sources, const AsteriskSCF::Media::V1::StreamSinkSeq& sinks,
PJSipManager *manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
- const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool isUAC)
+ const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool isUAC,
+ const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks)
: mImplPriv(new SipSessionPriv(adapter, endpoint, destination, manager, serviceLocator, replica))
{
- mImplPriv->mSessionProxy =
- AsteriskSCF::SessionCommunications::V1::SessionPrx::uncheckedCast(adapter->add(this, sessionid));
+ setSessionProxy(hooks);
mImplPriv->mMediaSession = new SipMediaSession(this);
mImplPriv->mMediaSessionProxy =
diff --git a/src/SipSession.h b/src/SipSession.h
index f670454..d3d838a 100644
--- a/src/SipSession.h
+++ b/src/SipSession.h
@@ -30,6 +30,7 @@
#include <AsteriskSCF/Core/Endpoint/EndpointIf.h>
#include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.h>
+#include <AsteriskSCF/SessionCommunications/SessionCommunicationsExtensionPointsIf.h>
#include <AsteriskSCF/Media/MediaIf.h>
#include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
#include <AsteriskSCF/System/Component/ReplicaIf.h>
@@ -98,14 +99,16 @@ public:
const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&, PJSipManager *manager,
const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
const AsteriskSCF::System::Component::V1::ReplicaPtr& replica,
- bool ipv6, bool isUAC);
+ bool ipv6, bool isUAC,
+ const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks);
SipSession(const Ice::ObjectAdapterPtr&, const SipEndpointPtr&, const std::string&, const Ice::Identity&,
const Ice::Identity&, const AsteriskSCF::Media::V1::SessionPrx&,
const AsteriskSCF::Media::V1::StreamSourceSeq&, const AsteriskSCF::Media::V1::StreamSinkSeq&,
PJSipManager *manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
const AsteriskSCF::System::Component::V1::ReplicaPtr& replica,
- bool isUAC);
+ bool isUAC,
+ const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks);
bool operator==(const SipSession &other) const;
@@ -155,6 +158,8 @@ public:
const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&,
const Ice::Current&);
+ void setSessionProxy(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks);
+
void hold(const Ice::Current&);
void progress(const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr&, const Ice::Current&);
void removeListener(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&, const Ice::Current&);
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list