[asterisk-scf-commits] asterisk-scf/release/bridging.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Fri Sep 30 17:52:28 CDT 2011
branch "master" has been updated
via bf4b6cc530ddcf99d7177913073b97433cb3b5d5 (commit)
from 19496522bf61f9a2805b5e7fc895909634b9a50e (commit)
Summary of changes:
.../BridgeService/BridgeReplicatorIf.ice | 20 ++-
src/BridgeImpl.cpp | 334 +++++++++++++++++++-
src/BridgeImpl.h | 3 +
src/BridgeManagerImpl.cpp | 43 ++-
src/BridgeManagerImpl.h | 8 +-
src/BridgePartyIdExtensionPoint.cpp | 175 ++++++++++
src/BridgePartyIdExtensionPoint.h | 82 +++++
src/BridgeReplicatorStateListenerI.cpp | 2 +-
src/CMakeLists.txt | 2 +
src/Component.cpp | 20 ++-
src/SessionWrapper.cpp | 30 ++-
src/SessionWrapper.h | 16 +
12 files changed, 712 insertions(+), 23 deletions(-)
create mode 100644 src/BridgePartyIdExtensionPoint.cpp
create mode 100644 src/BridgePartyIdExtensionPoint.h
- Log -----------------------------------------------------------------
commit bf4b6cc530ddcf99d7177913073b97433cb3b5d5
Author: Ken Hunt <ken.hunt at digium.com>
Date: Fri Sep 30 17:41:46 2011 -0500
Support for Party Id modifying extension point.
diff --git a/slice/AsteriskSCF/Replication/BridgeService/BridgeReplicatorIf.ice b/slice/AsteriskSCF/Replication/BridgeService/BridgeReplicatorIf.ice
index 0eb53de..e360795 100644
--- a/slice/AsteriskSCF/Replication/BridgeService/BridgeReplicatorIf.ice
+++ b/slice/AsteriskSCF/Replication/BridgeService/BridgeReplicatorIf.ice
@@ -17,6 +17,7 @@
#include <Ice/BuiltinSequences.ice>
#include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.ice>
+#include <AsteriskSCF/SessionCommunications/SessionCommunicationsExtensionPointsIf.ice>
#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.ice>
#include <AsteriskSCF/Media/MediaIf.ice>
@@ -163,7 +164,17 @@ enum ServiceState
Destroyed
};
sequence<AsteriskSCF::SessionCommunications::V1::BridgeManagerListener*> BridgeManagerListenerSeq;
-
+
+/**
+ * Collection of party id hooks.
+ */
+class PartyIdHooks
+{
+ AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ReceivedConnectedLinePartyIdHookSeq receivedConnectedLineHooks;
+ AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ForwardingConnectedLinePartyIdHookSeq forwardingConnectedLineHooks;
+ AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ForwardingRedirectionsPartyIdHookSeq forwardingRedirectionsHooks;
+};
+
/**
* The bridge manager state.
**/
@@ -172,6 +183,7 @@ class BridgeManagerStateItem extends ReplicatedStateItem
ServiceState runningState;
AsteriskSCF::SessionCommunications::V1::BridgeListenerSeq defaultBridgeListeners;
BridgeManagerListenerSeq listeners;
+ PartyIdHooks partyIdExtensionPointHooks;
};
/**
@@ -200,6 +212,12 @@ class BridgeStateItem extends ReplicatedStateItem
MediaOperationReplicationPolicy mediaReplicationPolicy;
AsteriskSCF::SessionCommunications::V1::BridgeCookieDict cookies;
+
+ /**
+ * Since the hooks can change over time, each bridge gets
+ * its own snapshot of applicable hooks.
+ */
+ PartyIdHooks partyIdHookSet;
};
class BridgeListenerStateItem extends ReplicatedStateItem
diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index edcd46b..36ea2dd 100755
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -33,6 +33,7 @@
using namespace AsteriskSCF::System::Logging;
using namespace AsteriskSCF::SessionCommunications::V1;
using namespace AsteriskSCF::SessionCommunications::PartyIdentification::V1;
+using namespace AsteriskSCF::SessionCommunications::ExtensionPoints::V1;
using namespace AsteriskSCF::BridgeService;
using namespace AsteriskSCF::Replication::BridgeService::V1;
using namespace AsteriskSCF;
@@ -121,6 +122,11 @@ public:
void getAddSessionsTasks(QueuedTasks& tasks, const SessionSeq& sessions);
+ PartyIdHooksPtr getPartyIdHooks()
+ {
+ return mState->partyIdHookSet;
+ }
+
BridgeCookies getCookies()
{
BridgeCookies result;
@@ -131,6 +137,9 @@ public:
return result;
}
+ void updateConnectedLine(const SessionWrapperPtr& sourceSession, const ConnectedLinePtr& connectedLine);
+ void updateRedirections(const SessionWrapperPtr& sourceSession, const RedirectionsPtr& redirections);
+
private:
boost::shared_mutex mLock;
@@ -261,6 +270,273 @@ private:
};
typedef IceUtil::Handle<SessionsTracker> SessionsTrackerPtr;
+
+/**
+ * Forwards the redirection records for the specified session
+ * to every other session in the bridge. Applies the
+ * ForwardingRedirections hooks to the Redirections record
+ * in the process.
+ *
+ * Note: For now we forward the Redirections record
+ * (with possible hook modifications)
+ * without considering whether there are more than two
+ * sessions in the bridge.
+ */
+class ForwardRedirectionsUpdatedTask : public QueuedTask
+{
+public:
+ ForwardRedirectionsUpdatedTask(const BridgeImplPtr& bridge,
+ const SessionWrapperPtr& sourceSession,
+ const RedirectionsPtr& redirections,
+ const Logger& logger) :
+ QueuedTask("ForwardRedirectionsUpdatedTask"),
+ mBridge(bridge),
+ mSourceSession(sourceSession),
+ mRedirections(redirections),
+ mLogger(logger)
+ {
+ }
+
+protected:
+ bool executeImpl()
+ {
+ try
+ {
+ mLogger(Debug) << FUNLOG;
+
+ // Forward the ConnectedLine to each bridged session.
+ SessionSeq sessions = mBridge->getSessions()->getSessionSeq();
+ for(SessionSeq::iterator i = sessions.begin();
+ i != sessions.end(); ++i)
+ {
+ if ((*i)->ice_getIdentity() == mSourceSession->getSession()->ice_getIdentity())
+ {
+ continue;
+ }
+
+ SessionWrapperPtr destSessionWrapper = mBridge->getSessions()->getSession(*i);
+ forward(destSessionWrapper, mRedirections);
+ }
+
+ }
+ catch (const std::exception e)
+ {
+ mLogger(Debug) << FUNLOG << " : " << e.what();
+ }
+
+ return true;
+ }
+
+ void forward(const SessionWrapperPtr destinationSession, const RedirectionsPtr& redirections)
+ {
+ mLogger(Debug) << FUNLOG;
+
+ RedirectionsPtr currentRedirections = redirections;
+ RedirectionsPtr destSpecificRedirections = redirections;
+
+ PartyIdHooksPtr partyIdHooks = mBridge->getPartyIdHooks();
+
+ // Allow the ForwardingRedirectionsPartyId hooks to alter the Redirections record.
+ for(vector<ForwardingRedirectionsPartyIdHookPrx>::const_iterator i = partyIdHooks->forwardingRedirectionsHooks.begin();
+ i != partyIdHooks->forwardingRedirectionsHooks.end(); ++i)
+ {
+ try
+ {
+ // Apply this hook.
+ AsteriskSCF::System::Hook::V1::HookResult hookResult = (*i)->modifyForwardingRedirections(mSourceSession->getSession(),
+ destinationSession->getSession(),
+ currentRedirections, destSpecificRedirections);
+
+ if (hookResult.status == AsteriskSCF::System::Hook::V1::Succeeded)
+ {
+ currentRedirections = destSpecificRedirections;
+ }
+ }
+ catch(const std::exception& e)
+ {
+ mLogger(Warning) << FUNLOG << " : " << e.what();
+ }
+ }
+
+ // Forward the info via the SessionController for this session.
+ destinationSession->getSessionController()->updateRedirections(currentRedirections);
+ }
+
+private:
+ BridgeImplPtr mBridge;
+ SessionWrapperPtr mSourceSession;
+ RedirectionsPtr mRedirections;
+ Logger mLogger;
+};
+
+/**
+ * Sends the cached ConnectedLine info for the specified session
+ * to every other session in the bridge. Applies the
+ * ForwardingConnectedLine hooks to the ConnectedLine record
+ * in the process.
+ *
+ * Note: For now we forward the ConnectedLine record
+ * without considering whether there are more than two
+ * sessions in the bridge. The API may need a more complex
+ * class than ConnectedLine to push the state
+ * of more than one Session.
+ */
+class ForwardConnectedLineTask : public QueuedTask
+{
+public:
+ ForwardConnectedLineTask(const BridgeImplPtr& bridge,
+ const SessionWrapperPtr& sourceSession,
+ const Logger& logger) :
+ QueuedTask("ForwardConnectedLineTask"),
+ mBridge(bridge),
+ mSourceSession(sourceSession),
+ mLogger(logger)
+ {
+ }
+
+protected:
+ bool executeImpl()
+ {
+ try
+ {
+ mLogger(Debug) << FUNLOG;
+
+ ConnectedLinePtr currentConnectedLine;
+ bool isSet = mSourceSession->getConnectedLine(currentConnectedLine);
+
+ if (!isSet)
+ {
+ mLogger(Error) << "ConnectedLine not cached for forwarding. " ;
+ return true;
+ }
+
+ // Forward the ConnectedLine to each bridged session.
+ SessionSeq sessions = mBridge->getSessions()->getSessionSeq();
+ for(SessionSeq::iterator i = sessions.begin();
+ i != sessions.end(); ++i)
+ {
+ if ((*i)->ice_getIdentity() == mSourceSession->getSession()->ice_getIdentity())
+ {
+ continue;
+ }
+
+ SessionWrapperPtr destSessionWrapper = mBridge->getSessions()->getSession(*i);
+ forward(destSessionWrapper, currentConnectedLine);
+ }
+
+ }
+ catch (const std::exception e)
+ {
+ mLogger(Debug) << FUNLOG << " : " << e.what();
+ }
+
+ return true;
+ }
+
+ void forward(const SessionWrapperPtr destinationSession, const ConnectedLinePtr& connectedLine)
+ {
+ mLogger(Debug) << FUNLOG;
+
+ ConnectedLinePtr currentConnectedLine = connectedLine;
+ ConnectedLinePtr destSpecificConnectedLine = connectedLine;
+
+ PartyIdHooksPtr partyIdHooks = mBridge->getPartyIdHooks();
+
+ // Allow the ForwardingConnectedLinePartyId hooks to alter the ConnectedLine record.
+ for(vector<ForwardingConnectedLinePartyIdHookPrx>::const_iterator i = partyIdHooks->forwardingConnectedLineHooks.begin();
+ i != partyIdHooks->forwardingConnectedLineHooks.end(); ++i)
+ {
+ try
+ {
+ // Apply a hook
+ AsteriskSCF::System::Hook::V1::HookResult hookResult = (*i)->modifyForwardingConnectedLine(mSourceSession->getSession(),
+ destinationSession->getSession(),
+ currentConnectedLine, destSpecificConnectedLine);
+
+ if (hookResult.status == AsteriskSCF::System::Hook::V1::Succeeded)
+ {
+ currentConnectedLine = destSpecificConnectedLine;
+ }
+ }
+ catch (const std::exception e)
+ {
+ mLogger(Debug) << FUNLOG << " : " << e.what();
+ }
+ }
+
+ // Forward the info via the SessionController for this session.
+ destinationSession->getSessionController()->updateConnectedLine(currentConnectedLine);
+ }
+
+private:
+ BridgeImplPtr mBridge;
+ SessionWrapperPtr mSourceSession;
+ Logger mLogger;
+};
+
+/**
+ * Applies the ReceiveConnectedLine hooks to the new ConnectedLine
+ * information before caching it for the specified session.
+ */
+class UpdateConnectedLineTask : public QueuedTask
+{
+public:
+ UpdateConnectedLineTask(const BridgeImplPtr& bridge,
+ const SessionWrapperPtr& sourceSession,
+ const ConnectedLinePtr& connectedLine,
+ const Logger& logger) :
+ QueuedTask("UpdateConnectedLineTask"),
+ mBridge(bridge),
+ mSourceSession(sourceSession),
+ mConnectedLine(connectedLine),
+ mLogger(logger)
+ {
+ }
+
+protected:
+ bool executeImpl()
+ {
+ mLogger(Debug) << FUNLOG;
+
+ ConnectedLinePtr currentConnectedLine = mConnectedLine;
+ ConnectedLinePtr updatedConnectedLine = mConnectedLine;
+
+ PartyIdHooksPtr partyIdHooks = mBridge->getPartyIdHooks();
+
+ // Allow the ReceivedConnectedLinePartyId hooks to alter the ConnectedLine record.
+ for(vector<ReceivedConnectedLinePartyIdHookPrx>::const_iterator i = partyIdHooks->receivedConnectedLineHooks.begin();
+ i != partyIdHooks->receivedConnectedLineHooks.end(); ++i)
+ {
+ try
+ {
+ // Apply this hook.
+ AsteriskSCF::System::Hook::V1::HookResult hookResult = (*i)->modifyReceivedConnectedLine(mSourceSession->getSession(),
+ currentConnectedLine, updatedConnectedLine);
+
+ if (hookResult.status == AsteriskSCF::System::Hook::V1::Succeeded)
+ {
+ currentConnectedLine = updatedConnectedLine;
+ }
+ }
+ catch (const std::exception e)
+ {
+ mLogger(Debug) << FUNLOG << " : " << e.what();
+ }
+ }
+
+ // Cache this value.
+ mSourceSession->setConnectedLine(currentConnectedLine);
+
+ return true;
+ }
+
+private:
+ BridgeImplPtr mBridge;
+ SessionWrapperPtr mSourceSession;
+ ConnectedLinePtr mConnectedLine;
+ Logger mLogger;
+};
+
class RemoveSessionsNotify : public QueuedTask
{
public:
@@ -415,14 +691,14 @@ public:
cb->ice_response();
}
- void updateConnectedLine(const ConnectedLinePtr&, const Ice::Current&)
+ void updateConnectedLine(const ConnectedLinePtr& connectedLine, const Ice::Current&)
{
- // TBD
+ mBridge->updateConnectedLine(mSelf, connectedLine);
}
- void updateRedirecting(const RedirectingPtr&, const ::Ice::Current&)
+ void updateRedirections(const RedirectionsPtr& redirections, const ::Ice::Current&)
{
- // TBD
+ mBridge->updateRedirections(mSelf, redirections);
}
private:
@@ -732,6 +1008,54 @@ BridgeImpl::~BridgeImpl()
//
}
+/**
+ * Process an updated ConnectedLine record from a session.
+ */
+void BridgeImpl::updateConnectedLine(const SessionWrapperPtr& sourceSession, const ConnectedLinePtr& connectedLine)
+{
+ try
+ {
+ QueuedTasks tasks;
+
+ // Updates the cached ConnectedLine party id information for the given session.
+ // - Applies receive hooks on the received ConnectedLine info before caching.
+ tasks.push_back(new UpdateConnectedLineTask(this, sourceSession, connectedLine, mLogger));
+
+
+ // Forwards the ConnectedLine information to the other sessions in the bridge.
+ // - Applies forwarding hooks to the cached ConnectedLine info before forwarding.
+ tasks.push_back(new ForwardConnectedLineTask(this, sourceSession, mLogger));
+
+ ExecutorPtr runner(new Executor(tasks, mLogger));
+ runner->start();
+ }
+ catch (const std::exception e)
+ {
+ mLogger(Debug) << FUNLOG << " : " << e.what();
+ }
+}
+
+/**
+ * Process an updated Redirections record from a session.
+ */
+void BridgeImpl::updateRedirections(const SessionWrapperPtr& sourceSession, const RedirectionsPtr& redirections)
+{
+ try
+ {
+ QueuedTasks tasks;
+
+ // Forwards the Redirections information to the other sessions in the bridge.
+ // Applies forwarding hooks to the Redirecrting info before forwarding.
+ tasks.push_back(new ForwardRedirectionsUpdatedTask(this, sourceSession, redirections, mLogger));
+ ExecutorPtr runner(new Executor(tasks, mLogger));
+ runner->start();
+ }
+ catch (const std::exception e)
+ {
+ mLogger(Debug) << FUNLOG << " : " << e.what();
+ }
+}
+
void BridgeImpl::addSessions_async(const AMD_Bridge_addSessionsPtr& callback, const SessionSeq& sessions,
const Ice::Current&)
{
@@ -1319,12 +1643,14 @@ IceUtil::Handle<AsteriskSCF::BridgeService::BridgeServant>
AsteriskSCF::BridgeService::BridgeServant::create(const string& name, const Ice::ObjectAdapterPtr& objectAdapter,
const vector<BridgeListenerPrx>& listeners,
const AsteriskSCF::BridgeService::BridgeListenerMgrPtr& listenerMgr,
+ const AsteriskSCF::Replication::BridgeService::V1::PartyIdHooksPtr& partyIdHooks,
const ReplicatorSmartPrx& replicator,
const Logger& logger)
{
BridgeStateItemPtr state(new AsteriskSCF::Replication::BridgeService::V1::BridgeStateItem);
state->runningState = Running;
state->serial = SerialCounterStart;
+ state->partyIdHookSet = partyIdHooks;
//
// TODO: "replicate" is the only replication policy currently supported by the bridge service.
// In the future it may be possible for the bridge replica to reconstruct its media operations
diff --git a/src/BridgeImpl.h b/src/BridgeImpl.h
index 35b311f..d2a3fb3 100644
--- a/src/BridgeImpl.h
+++ b/src/BridgeImpl.h
@@ -16,8 +16,10 @@
#pragma once
#include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.h>
+#include <AsteriskSCF/Replication/BridgeService/BridgeReplicatorIf.h>
#include <boost/thread/shared_mutex.hpp>
#include <vector>
+#include "BridgePartyIdExtensionPoint.h"
#include "BridgeReplicatorIf.h"
#include "BridgeListenerMgr.h"
#include "BridgeServiceConfig.h"
@@ -142,6 +144,7 @@ public:
const Ice::ObjectAdapterPtr& objectAdapter,
const std::vector<AsteriskSCF::SessionCommunications::V1::BridgeListenerPrx>& listeners,
const AsteriskSCF::BridgeService::BridgeListenerMgrPtr& listenerMgr,
+ const AsteriskSCF::Replication::BridgeService::V1::PartyIdHooksPtr& partyIdHooks,
const ReplicatorSmartPrx& replicator,
const AsteriskSCF::System::Logging::Logger& logger);
diff --git a/src/BridgeManagerImpl.cpp b/src/BridgeManagerImpl.cpp
index d8a343d..48acd21 100644
--- a/src/BridgeManagerImpl.cpp
+++ b/src/BridgeManagerImpl.cpp
@@ -78,7 +78,9 @@ class BridgeManagerImpl : public BridgeManagerServant
{
public:
- BridgeManagerImpl(const Ice::ObjectAdapterPtr& adapter, const string& name,
+ BridgeManagerImpl(const Ice::ObjectAdapterPtr& adapter,
+ const string& name,
+ const BridgePartyIdExtensionPointPtr& partyIdExtensionPoint,
const BridgeReplicationContextPtr& replicationContext, const Logging::Logger& logger);
~BridgeManagerImpl();
@@ -127,6 +129,7 @@ private:
boost::shared_mutex mLock;
string mName;
+ BridgePartyIdExtensionPointPtr mPartyIdExtensionPoint;
vector<BridgeInfo> mBridges;
Ice::ObjectAdapterPtr mAdapter;
BridgeReplicationContextPtr mReplicationContext;
@@ -148,13 +151,17 @@ private:
typedef IceUtil::Handle<BridgeManagerImpl> BridgeManagerImplPtr;
-BridgeManagerImpl::BridgeManagerImpl(const Ice::ObjectAdapterPtr& adapter, const string& name, const BridgeReplicationContextPtr& replicationContext,
- const Logger& logger) :
- mName(name),
- mAdapter(adapter),
- mReplicationContext(replicationContext),
- mLogger(logger),
- mState(new BridgeManagerStateItem)
+BridgeManagerImpl::BridgeManagerImpl(const Ice::ObjectAdapterPtr& adapter,
+ const string& name,
+ const BridgePartyIdExtensionPointPtr& partyIdExtensionPoint,
+ const BridgeReplicationContextPtr& replicationContext,
+ const Logger& logger) :
+ mName(name),
+ mPartyIdExtensionPoint(partyIdExtensionPoint),
+ mAdapter(adapter),
+ mReplicationContext(replicationContext),
+ mLogger(logger),
+ mState(new BridgeManagerStateItem)
{
mLogger(Info) << "Created AsteriskSCF Session-Oriented Bridge Manager." ;
mListeners = new BridgeManagerListenerMgr(mAdapter->getCommunicator(), mName, mSourceProxy);
@@ -275,7 +282,8 @@ void BridgeManagerImpl::createBridge_async(const AMD_BridgeManager_createBridgeP
// initial sessions, etc that may have been defined or added as part of the createBridge
// call or the bridge creation hooks.
//
- BridgeServantPtr bridge = BridgeServant::create(stringId, mAdapter, listeners, mgr, mReplicationContext->getReplicator(), mLogger);
+ BridgeServantPtr bridge = BridgeServant::create(stringId, mAdapter, listeners, mgr,
+ mPartyIdExtensionPoint->getHooks(), mReplicationContext->getReplicator(), mLogger);
Ice::ObjectPrx obj = mAdapter->add(bridge, id);
@@ -464,6 +472,7 @@ BridgeManagerStateItemPtr BridgeManagerImpl::getState()
//
BridgeManagerStateItemPtr result(new BridgeManagerStateItem(*mState));
result->listeners = mListeners->getListeners();
+ result->partyIdExtensionPointHooks = mPartyIdExtensionPoint->getHooks();
return result;
}
@@ -477,6 +486,8 @@ void BridgeManagerImpl::updateState(const BridgeManagerStateItemPtr& state)
// safer to take the added cost of the copy.
//
*mState = *state;
+
+ mPartyIdExtensionPoint->replaceHooks(state->partyIdExtensionPointHooks);
}
vector<BridgeServantPtr> BridgeManagerImpl::getBridges()
@@ -534,7 +545,9 @@ void BridgeManagerImpl::createBridgeReplica(const BridgeStateItemPtr& state)
BridgePrx prx(BridgePrx::uncheckedCast(mAdapter->createProxy(id)));
BridgeListenerMgrPtr mgr(new BridgeListenerMgr(mAdapter->getCommunicator(), state->bridgeId, prx));
- BridgeServantPtr bridge = BridgeServant::create(mAdapter, mgr, mReplicationContext->getReplicator(), mLogger, state);
+
+ BridgeServantPtr bridge = BridgeServant::create(mAdapter, mgr,
+ mReplicationContext->getReplicator(), mLogger, state);
Ice::ObjectPrx obj = mAdapter->add(bridge, id);
mLogger(Info) << ": creating bridge replica " << obj->ice_toString() << "." ;
@@ -617,9 +630,11 @@ void BridgeManagerImpl::update()
} // End of anonymous namespace
BridgeManagerServantPtr
-AsteriskSCF::BridgeService::createBridgeManager(const Ice::ObjectAdapterPtr& adapter, const string& name,
- const BridgeReplicationContextPtr& replicationContext,
- const Logger& logger)
+AsteriskSCF::BridgeService::createBridgeManager(const Ice::ObjectAdapterPtr& adapter,
+ const string& name,
+ const BridgePartyIdExtensionPointPtr& partyIdExtensionPoint,
+ const BridgeReplicationContextPtr& replicationContext,
+ const Logger& logger)
{
- return new BridgeManagerImpl(adapter, name, replicationContext, logger);
+ return new BridgeManagerImpl(adapter, name, partyIdExtensionPoint, replicationContext, logger);
}
diff --git a/src/BridgeManagerImpl.h b/src/BridgeManagerImpl.h
index 163d5df..b1c4cc9 100644
--- a/src/BridgeManagerImpl.h
+++ b/src/BridgeManagerImpl.h
@@ -67,6 +67,10 @@ typedef IceUtil::Handle<BridgeManagerServant> BridgeManagerServantPtr;
*
* @param adapter The Ice object adapter for the BridgeManager all of the servants it will create.
*
+ *
+ * @param partyIdExtensionPoint Object that manages the hooks that have been added to this component for
+ * modifying Party Id information.
+ *
* @param name A name for this servant. This will be used to construct the new BridgeManager object's Ice::Identity.
* It is used to construct relative object ids for all objects that the bridge manager creates.
*
@@ -74,7 +78,9 @@ typedef IceUtil::Handle<BridgeManagerServant> BridgeManagerServantPtr;
*
**/
BridgeManagerServantPtr createBridgeManager(const Ice::ObjectAdapterPtr& adapter,
- const std::string& name, const BridgeReplicationContextPtr& replicationContext,
+ const std::string& name,
+ const BridgePartyIdExtensionPointPtr& partyIdExtensionPoint,
+ const BridgeReplicationContextPtr& replicationContext,
const AsteriskSCF::System::Logging::Logger& logger);
};
diff --git a/src/BridgePartyIdExtensionPoint.cpp b/src/BridgePartyIdExtensionPoint.cpp
new file mode 100644
index 0000000..60aa335
--- /dev/null
+++ b/src/BridgePartyIdExtensionPoint.cpp
@@ -0,0 +1,175 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#include <boost/thread/shared_mutex.hpp>
+
+#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Collections/ProxySet.h>
+#include <AsteriskSCF/SessionCommunications/SessionCommunicationsExtensionPointsIf.h>
+
+#include "BridgePartyIdExtensionPoint.h"
+
+using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::SessionCommunications::V1;
+using namespace AsteriskSCF::SessionCommunications::ExtensionPoints::V1;
+using namespace AsteriskSCF::BridgeService;
+using namespace AsteriskSCF::Replication::BridgeService::V1;
+using namespace AsteriskSCF::Collections;
+
+namespace
+{
+
+class BridgePartyIdExtensionPointImpl :
+ public AsteriskSCF::BridgeService::BridgePartyIdExtensionPoint
+{
+public:
+ BridgePartyIdExtensionPointImpl(const Ice::ObjectAdapterPtr& adapter,
+ const AsteriskSCF::System::Logging::Logger& logger);
+
+ // PartyIdentificationExtensionPoint API implementation
+ void addReceivedConnectedLinePartyIdHook(
+ const ::AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ReceivedConnectedLinePartyIdHookPrx& hook,
+ const Ice::Current& current);
+ void addForwardingConnectedLinePartyIdHook(
+ const ::AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ForwardingConnectedLinePartyIdHookPrx& hook,
+ const Ice::Current& current);
+ void addForwardingRedirectionsPartyIdHook(
+ const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ForwardingRedirectionsPartyIdHookPrx& hook,
+ const Ice::Current& current);
+
+ void removeReceivedConnectedLinePartyIdHook(
+ const ::AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ReceivedConnectedLinePartyIdHookPrx& hook,
+ const Ice::Current& current);
+ void removeForwardingConnectedLinePartyIdHook(
+ const ::AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ForwardingConnectedLinePartyIdHookPrx& hook,
+ const Ice::Current& current);
+ void removeForwardingRedirectionsPartyIdHook(
+ const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ForwardingRedirectionsPartyIdHookPrx& hook,
+ const Ice::Current& current);
+
+ void clearPartyIdentificationHooks(const Ice::Current& current);
+
+ virtual AsteriskSCF::Replication::BridgeService::V1::PartyIdHooksPtr getHooks();
+ virtual void replaceHooks(const AsteriskSCF::Replication::BridgeService::V1::PartyIdHooksPtr& hooks);
+
+private:
+ ProxySet<ReceivedConnectedLinePartyIdHookPrx>::SetPtr mReceiveConnectedLineHooks;
+ ProxySet<ForwardingConnectedLinePartyIdHookPrx>::SetPtr mForwardingConnectedLineHooks;
+ ProxySet<ForwardingRedirectionsPartyIdHookPrx>::SetPtr mForwardingRedirectionsHooks;
+
+ Logger mLogger;
+};
+
+} // end anon namespace
+
+BridgePartyIdExtensionPointImpl::BridgePartyIdExtensionPointImpl(
+ const Ice::ObjectAdapterPtr& adapter,
+ const AsteriskSCF::System::Logging::Logger& logger)
+ : mLogger(logger),
+ mReceiveConnectedLineHooks(new ProxySet<ReceivedConnectedLinePartyIdHookPrx>(adapter, logger, "ReceiveConnectedLineHooks")),
+ mForwardingConnectedLineHooks(new ProxySet<ForwardingConnectedLinePartyIdHookPrx>(adapter, logger, "ForwardingConnectedLineHooks")),
+ mForwardingRedirectionsHooks(new ProxySet<ForwardingRedirectionsPartyIdHookPrx>(adapter, logger, "ForwardingRedirectionHooks"))
+{
+}
+
+// PartyIdentificationExtensionPoint API implementation
+void BridgePartyIdExtensionPointImpl::addReceivedConnectedLinePartyIdHook(
+ const ::AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ReceivedConnectedLinePartyIdHookPrx& hook,
+ const Ice::Current& current)
+{
+ mReceiveConnectedLineHooks->add(hook);
+}
+
+void BridgePartyIdExtensionPointImpl::addForwardingConnectedLinePartyIdHook(
+ const ::AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ForwardingConnectedLinePartyIdHookPrx& hook,
+ const Ice::Current& current)
+{
+ mForwardingConnectedLineHooks->add(hook);
+}
+
+void BridgePartyIdExtensionPointImpl::addForwardingRedirectionsPartyIdHook(
+ const ::AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ForwardingRedirectionsPartyIdHookPrx& hook,
+ const Ice::Current& current)
+{
+ mForwardingRedirectionsHooks->add(hook);
+}
+
+void BridgePartyIdExtensionPointImpl::removeReceivedConnectedLinePartyIdHook(
+ const ::AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ReceivedConnectedLinePartyIdHookPrx& hook,
+ const Ice::Current& current)
+{
+ mReceiveConnectedLineHooks->remove(hook);
+}
+
+void BridgePartyIdExtensionPointImpl::removeForwardingConnectedLinePartyIdHook(
+ const ::AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ForwardingConnectedLinePartyIdHookPrx& hook,
+ const Ice::Current& current)
+{
+ mForwardingConnectedLineHooks->remove(hook);
+}
+
+void BridgePartyIdExtensionPointImpl::removeForwardingRedirectionsPartyIdHook(
+ const ::AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ForwardingRedirectionsPartyIdHookPrx& hook,
+ const Ice::Current& current)
+{
+ mForwardingRedirectionsHooks->remove(hook);
+}
+
+void BridgePartyIdExtensionPointImpl::clearPartyIdentificationHooks(const Ice::Current& current)
+{
+ mReceiveConnectedLineHooks->clear();
+ mForwardingConnectedLineHooks->clear();
+ mForwardingRedirectionsHooks->clear();
+}
+
+AsteriskSCF::Replication::BridgeService::V1::PartyIdHooksPtr BridgePartyIdExtensionPointImpl::getHooks()
+{
+ return new AsteriskSCF::Replication::BridgeService::V1::PartyIdHooks(
+ mReceiveConnectedLineHooks->getAll(),
+ mForwardingConnectedLineHooks->getAll(),
+ mForwardingRedirectionsHooks->getAll());
+}
+
+void BridgePartyIdExtensionPointImpl::replaceHooks(const PartyIdHooksPtr& hooks)
+{
+ mReceiveConnectedLineHooks->clear();
+ for(ReceivedConnectedLinePartyIdHookSeq::iterator i = hooks->receivedConnectedLineHooks.begin();
+ i != hooks->receivedConnectedLineHooks.end(); ++i)
+ {
+ mReceiveConnectedLineHooks->add(*i);
+ }
+
+ mForwardingConnectedLineHooks->clear();
+ for(ForwardingConnectedLinePartyIdHookSeq::iterator i = hooks->forwardingConnectedLineHooks.begin();
+ i != hooks->forwardingConnectedLineHooks.end(); ++i)
+ {
+ mForwardingConnectedLineHooks->add(*i);
+ }
+
+ mForwardingRedirectionsHooks->clear();
+ for(ForwardingRedirectionsPartyIdHookSeq::iterator i = hooks->forwardingRedirectionsHooks.begin();
+ i != hooks->forwardingRedirectionsHooks.end(); ++i)
+ {
+ mForwardingRedirectionsHooks->add(*i);
+ }
+}
+
+AsteriskSCF::BridgeService::BridgePartyIdExtensionPointPtr
+ AsteriskSCF::BridgeService::createPartyIdExtensionPoint(const Ice::ObjectAdapterPtr& adapter,
+ const AsteriskSCF::System::Logging::Logger& logger)
+{
+ return new BridgePartyIdExtensionPointImpl(adapter, logger);
+}
diff --git a/src/BridgePartyIdExtensionPoint.h b/src/BridgePartyIdExtensionPoint.h
new file mode 100644
index 0000000..e1c854a
--- /dev/null
+++ b/src/BridgePartyIdExtensionPoint.h
@@ -0,0 +1,82 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010-2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+#pragma once
+
+#include <AsteriskSCF/SessionCommunications/SessionCommunicationsExtensionPointsIf.h>
+#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Replication/BridgeService/BridgeReplicatorIf.h>
+
+namespace AsteriskSCF
+{
+namespace BridgeService
+{
+
+/**
+ * This is our servant for the PartyIdentificationExtensionPoint. It caches the
+ * hooks that are added.
+ */
+class BridgePartyIdExtensionPoint :
+ public AsteriskSCF::SessionCommunications::ExtensionPoints::V1::PartyIdentificationExtensionPoint
+{
+public:
+ virtual ~BridgePartyIdExtensionPoint() {}
+
+ // PartyIdentificationExtensionPoint API implementation
+
+ virtual void addReceivedConnectedLinePartyIdHook(
+ const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ReceivedConnectedLinePartyIdHookPrx& hook,
+ const Ice::Current& current) = 0;
+ virtual void addForwardingConnectedLinePartyIdHook(
+ const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ForwardingConnectedLinePartyIdHookPrx& hook,
+ const Ice::Current& current) = 0;
+ virtual void addForwardingRedirectionsPartyIdHook(
+ const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ForwardingRedirectionsPartyIdHookPrx& hook,
+ const Ice::Current& current) = 0;
+
+ virtual void removeReceivedConnectedLinePartyIdHook(
+ const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ReceivedConnectedLinePartyIdHookPrx& hook,
+ const Ice::Current& current) = 0;
+ virtual void removeForwardingConnectedLinePartyIdHook(
+ const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ForwardingConnectedLinePartyIdHookPrx& hook,
+ const Ice::Current& current) = 0;
+ virtual void removeForwardingRedirectionsPartyIdHook(
+ const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::ForwardingRedirectionsPartyIdHookPrx& hook,
+ const Ice::Current& current) = 0;
+
+ virtual void clearPartyIdentificationHooks(const Ice::Current& current) = 0;
+
+ // Implementation
+
+ /**
+ * Provides a PartyIdHooks object which contains a copy of the hooks as they exist
+ * at the time this operation is called.
+ */
+ virtual AsteriskSCF::Replication::BridgeService::V1::PartyIdHooksPtr getHooks() = 0;
+
+ /**
+ * Replaces the set of hooks with the specified set.
+ */
+ virtual void replaceHooks(const AsteriskSCF::Replication::BridgeService::V1::PartyIdHooksPtr& hooks) = 0;
+};
+
+typedef IceUtil::Handle<BridgePartyIdExtensionPoint> BridgePartyIdExtensionPointPtr;
+
+
+BridgePartyIdExtensionPointPtr createPartyIdExtensionPoint(const Ice::ObjectAdapterPtr& adapter,
+ const AsteriskSCF::System::Logging::Logger& logger);
+
+} // End of namespace Bridging.
+} // End of namespace AsteriskSCF.
diff --git a/src/BridgeReplicatorStateListenerI.cpp b/src/BridgeReplicatorStateListenerI.cpp
index 4e32e2b..ecdbf20 100644
--- a/src/BridgeReplicatorStateListenerI.cpp
+++ b/src/BridgeReplicatorStateListenerI.cpp
@@ -150,7 +150,7 @@ public:
if(managerItem->key == mManager->getID())
{
//
- // There is only on bridge per listener instance by design/implementation, so this
+ // There is only one bridge manager per listener instance by design/implementation, so this
// one is pretty easy.
//
mManager->updateState(managerItem);
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 839fd48..4e20b5c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -24,6 +24,8 @@ astscf_component_add_files(bridgeservice SessionOperations.cpp)
astscf_component_add_files(bridgeservice SessionOperations.h)
astscf_component_add_files(bridgeservice BridgeCreationExtensionPointImpl.cpp)
astscf_component_add_files(bridgeservice BridgeCreationExtensionPointImpl.h)
+astscf_component_add_files(bridgeservice BridgePartyIdExtensionPoint.cpp)
+astscf_component_add_files(bridgeservice BridgePartyIdExtensionPoint.h)
astscf_component_add_files(bridgeservice ServiceUtil.h)
astscf_component_add_files(bridgeservice DebugUtil.h)
astscf_component_add_files(bridgeservice MediaSplicer.h)
diff --git a/src/Component.cpp b/src/Component.cpp
index 595011a..331e6af 100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@ -29,9 +29,11 @@
#include "BridgeManagerImpl.h"
#include "BridgeReplicatorStateListenerI.h"
#include "BridgeReplicationContext.h"
+#include "BridgePartyIdExtensionPoint.h"
using namespace AsteriskSCF::System::Logging;
using namespace AsteriskSCF::SessionCommunications::V1;
+using namespace AsteriskSCF::SessionCommunications::ExtensionPoints::V1;
using namespace AsteriskSCF::Core::Discovery::V1;
using namespace AsteriskSCF::System::Component::V1;
using namespace AsteriskSCF::BridgeService;
@@ -75,10 +77,13 @@ private:
// Other base Component overrides
virtual ReplicationContextPtr createReplicationContext(ReplicationStateType state);
+ BridgePartyIdExtensionPointPtr mPartyIdExtensionPoint;
+ PartyIdentificationExtensionPointPrx mPartyIdExtensionPointPrx;
ReplicatorSmartPrx mReplicator;
BridgeManagerServantPtr mBridgeManager;
BridgeManagerPrx mBridgeManagerPrx;
LocatorRegistrationWrapperPtr mBridgeManagerRegistration;
+ LocatorRegistrationWrapperPtr mPartyIdExtensionRegistration;
RegisterThreadPtr mRegisterThread;
ReplicatorListenerPrx mReplicatorListenerPrx;
bool mListeningToReplicator;
@@ -130,8 +135,15 @@ void Component::createPrimaryServices()
// It's very important that uncheckedCast's be used here as there are no guarantees
// that the object adapter is activated yet. If it is not, then this can hang.
//
+
+ std::string extensionPointName =
+ getCommunicator()->getProperties()->getPropertyWithDefault(getName() + ".PartyIdentExtensionPoint", "BridgePartyIdExtensionPoint");
+ mPartyIdExtensionPoint = createPartyIdExtensionPoint(getServiceAdapter(), lg);
+ mPartyIdExtensionPointPrx = PartyIdentificationExtensionPointPrx::uncheckedCast(getServiceAdapter()->add(mPartyIdExtensionPoint,
+ getCommunicator()->stringToIdentity(extensionPointName)));
+
BridgeReplicationContextPtr replicationContext = boost::static_pointer_cast<BridgeReplicationContext>(getReplicationContext());
- mBridgeManager = createBridgeManager(getServiceAdapter(), managerName, replicationContext, lg);
+ mBridgeManager = createBridgeManager(getServiceAdapter(), managerName, mPartyIdExtensionPoint, replicationContext, lg);
mBridgeManagerPrx = BridgeManagerPrx::uncheckedCast(getServiceAdapter()->add(mBridgeManager,
getCommunicator()->stringToIdentity(managerName)));
assert(mBridgeManagerPrx != 0);
@@ -139,6 +151,7 @@ void Component::createPrimaryServices()
{
throw IceBox::FailureException(__FILE__, __LINE__, "Unable to instantiate bridge manager object");
}
+
}
/**
@@ -151,6 +164,11 @@ void Component::preparePrimaryServicesForDiscovery()
mBridgeManagerRegistration = this->wrapServiceForRegistration(mBridgeManagerPrx,
BridgeManagerDiscoveryCategory);
managePrimaryService(mBridgeManagerRegistration);
+
+ mPartyIdExtensionRegistration = this->wrapServiceForRegistration(mPartyIdExtensionPointPrx,
+ PartyIdentificationHookLocatorCategory);
+ managePrimaryService(mPartyIdExtensionRegistration);
+
}
catch (const Ice::Exception& e)
{
diff --git a/src/SessionWrapper.cpp b/src/SessionWrapper.cpp
index f70ee87..4adbd59 100644
--- a/src/SessionWrapper.cpp
+++ b/src/SessionWrapper.cpp
@@ -22,6 +22,7 @@
using namespace AsteriskSCF::System::Logging;
using namespace AsteriskSCF::SessionCommunications::V1;
+using namespace AsteriskSCF::SessionCommunications::PartyIdentification::V1;
using namespace AsteriskSCF::BridgeService;
using namespace AsteriskSCF::Replication::BridgeService::V1;
using namespace AsteriskSCF;
@@ -391,7 +392,8 @@ SessionWrapper::SessionWrapper(const BridgedSessionPtr& session,
mLogger(logger),
mId(mSession->key),
mSplicer(splicer),
- mActivities(new Executor(mLogger))
+ mActivities(new Executor(mLogger)),
+ mConnectedLineSet(false)
{
}
@@ -614,6 +616,32 @@ void SessionWrapper::shutdown(const SessionListenerPrx& listener, const Response
// shutdownRunner->start();
}
+/**
+ * Set the connected line information associcated with this session.
+ */
+void SessionWrapper::setConnectedLine(const ConnectedLinePtr& connectedLine)
+{
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ mConnectedLine = connectedLine;
+ mConnectedLineSet = true;
+}
+
+/**
+ * Get the connected line information that's been cached for this session.
+ */
+bool SessionWrapper::getConnectedLine(ConnectedLinePtr& connectedLine)
+{
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ if (!mConnectedLineSet)
+ {
+ return false;
+ }
+
+ connectedLine = mConnectedLine;
+ return true;
+}
+
+
AsteriskSCF::Replication::BridgeService::V1::BridgedSessionState SessionWrapper::setState(const AsteriskSCF::Replication::BridgeService::V1::BridgedSessionState newState)
{
mLogger(Trace) << FUNLOG << ": updating state " << mId;
diff --git a/src/SessionWrapper.h b/src/SessionWrapper.h
index 0bdef83..6fc3f43 100644
--- a/src/SessionWrapper.h
+++ b/src/SessionWrapper.h
@@ -145,6 +145,19 @@ public:
* Disconnection helper.
**/
void unplugMedia();
+
+ /**
+ * Set the connected line information associcated with this session.
+ * This is information received from the session.
+ */
+ void setConnectedLine(const AsteriskSCF::SessionCommunications::PartyIdentification::V1::ConnectedLinePtr& connectedLine);
+
+ /**
+ * Gets a reference to the cached Connected Line party identification information if it's available.
+ * @param connectedLine A reference to set the cached Connected Line record (if available).
+ * @return true if the connectedLine parameter was set.
+ */
+ bool getConnectedLine(AsteriskSCF::SessionCommunications::PartyIdentification::V1::ConnectedLinePtr& connectedLine);
private:
@@ -157,6 +170,9 @@ private:
MediaSplicerPtr mSplicer;
ExecutorPtr mActivities;
AsteriskSCF::SessionCommunications::V1::SessionControllerPrx mSessionController;
+ AsteriskSCF::SessionCommunications::PartyIdentification::V1::ConnectedLinePtr mConnectedLine;
+ bool mConnectedLineSet;
+
/**
* Sends changes to the replication service. This should never occur
-----------------------------------------------------------------------
--
asterisk-scf/release/bridging.git
More information about the asterisk-scf-commits
mailing list