[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Mon Nov 15 14:10:49 CST 2010
branch "master" has been updated
via 6d5df48797464117d25ab060aa40b554c252a271 (commit)
from 49c9bb7541a41f86b3b3706581a21e193d2be937 (commit)
Summary of changes:
src/BridgeImpl.cpp | 542 ++++++++++++++++----------------
src/BridgeImpl.h | 252 ++++++++--------
src/BridgeListenerMgr.cpp | 4 +-
src/BridgeListenerMgr.h | 26 +-
src/BridgeManagerImpl.cpp | 46 ++--
src/BridgeManagerImpl.h | 70 +++---
src/BridgeManagerListenerMgr.cpp | 2 +-
src/BridgeManagerListenerMgr.h | 26 +-
src/BridgeServiceImpl.h | 8 +-
src/InternalExceptions.h | 48 ++--
src/ListenerManager.h | 358 +++++++++++-----------
src/MediaSplicer.cpp | 628 +++++++++++++++++++-------------------
src/MediaSplicer.h | 40 ++--
src/Service.cpp | 18 +-
test/BridgeManagerListenerI.cpp | 2 +-
test/BridgeManagerListenerI.h | 4 +-
test/SessionListenerI.cpp | 6 +-
test/SessionListenerI.h | 6 +-
test/TestBridging.cpp | 28 +-
19 files changed, 1057 insertions(+), 1057 deletions(-)
- Log -----------------------------------------------------------------
commit 6d5df48797464117d25ab060aa40b554c252a271
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/BridgeImpl.cpp b/src/BridgeImpl.cpp
index 53e788e..8924abb 100755
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -24,16 +24,16 @@
using namespace AsteriskSCF::System::Logging;
-/**
+/**
*
* NOTE: Code must be reviewed/refactored for exception safety/consistency.
* Operations involving establishing media connections may or may not be
* catastrophic. An example of a non-catastrophic situation might be a media
* allocation operation that might immediately fail for transient reasons but
* can be initialized in the background in a relatively timely fashion (of
- * course this would depend on the context).
+ * course this would depend on the context).
*
- */
+ */
namespace
{
@@ -70,7 +70,7 @@ private:
void checkSessions(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions)
{
- Ice::LongSeq invalidIndexes;
+ Ice::LongSeq invalidIndexes;
Ice::Long index = 0;
for(AsteriskSCF::SessionCommunications::V1::SessionSeq::const_iterator i = sessions.begin(); i != sessions.end(); ++i, ++index)
{
@@ -96,162 +96,103 @@ static const std::string TopicPrefix("AsteriskSCF.Bridge.");
//
// TODO:
// Operations that are performed on all bridge sessions might be better done as AMI requests.
-//
+//
namespace AsteriskSCF
{
namespace BridgeService
{
- //
- // Functor to support using for_each on shutdown.
- //
- class ShutdownImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
+//
+// Functor to support using for_each on shutdown.
+//
+class ShutdownImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
+{
+public:
+ ShutdownImpl(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
+ const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response) :
+ mListener(listener),
+ mResponse(response)
{
- public:
- ShutdownImpl(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
- const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response) :
- mListener(listener),
- mResponse(response)
- {
- }
-
- void operator()(const BridgeImpl::BridgeSessionPtr& b)
- {
- try
- {
- b->getSession()->removeBridge(mListener);
- b->disconnect();
- b->getSession()->stop(mResponse);
- }
- catch(const Ice::ObjectNotExistException& ex)
- {
- lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
- mNonExistent.push_back(b);
- }
- catch(const Ice::Exception& ex)
- {
- lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
- }
- }
+ }
- const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
- {
- return mNonExistent;
- }
- private:
- AsteriskSCF::SessionCommunications::V1::SessionListenerPrx mListener;
- AsteriskSCF::SessionCommunications::V1::ResponseCodePtr mResponse;
- std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
- };
-
- class ProgressingImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
+ void operator()(const BridgeImpl::BridgeSessionPtr& b)
{
- public:
- ProgressingImpl(const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response) :
- mResponse(response)
+ try
{
+ b->getSession()->removeBridge(mListener);
+ b->disconnect();
+ b->getSession()->stop(mResponse);
}
-
- void operator()(const BridgeImpl::BridgeSessionPtr& b)
+ catch(const Ice::ObjectNotExistException& ex)
{
- try
- {
- b->getSession()->progress(mResponse);
- }
- catch(const Ice::ObjectNotExistException& ex)
- {
- mNonExistent.push_back(b);
- lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
- }
- catch(const Ice::Exception& ex)
- {
- lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
- }
+ lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
+ mNonExistent.push_back(b);
}
-
- const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+ catch(const Ice::Exception& ex)
{
- return mNonExistent;
+ lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
}
+ }
+
+ const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+ {
+ return mNonExistent;
+ }
+private:
+ AsteriskSCF::SessionCommunications::V1::SessionListenerPrx mListener;
+ AsteriskSCF::SessionCommunications::V1::ResponseCodePtr mResponse;
+ std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
+};
- private:
- AsteriskSCF::SessionCommunications::V1::ResponseCodePtr mResponse;
- std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
- };
+class ProgressingImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
+{
+public:
+ ProgressingImpl(const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response) :
+ mResponse(response)
+ {
+ }
- class RingImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
+ void operator()(const BridgeImpl::BridgeSessionPtr& b)
{
- public:
- RingImpl(const AsteriskSCF::SessionCommunications::V1::SessionPrx& exclude) :
- mExclude(exclude)
+ try
{
+ b->getSession()->progress(mResponse);
}
-
- void operator()(const BridgeImpl::BridgeSessionPtr& b)
+ catch(const Ice::ObjectNotExistException& ex)
{
- if(b->getSession() != mExclude)
- {
- try
- {
- b->ring();
- }
- catch(const Ice::ObjectNotExistException& ex)
- {
- mNonExistent.push_back(b);
- lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
- }
- catch(const Ice::Exception& ex)
- {
- lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
- }
- }
+ mNonExistent.push_back(b);
+ lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
}
-
- const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+ catch(const Ice::Exception& ex)
{
- return mNonExistent;
+ lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
}
+ }
+
+ const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+ {
+ return mNonExistent;
+ }
- private:
- AsteriskSCF::SessionCommunications::V1::SessionPrx mExclude;
- std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
- };
+private:
+ AsteriskSCF::SessionCommunications::V1::ResponseCodePtr mResponse;
+ std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
+};
- class FlashImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
+class RingImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
+{
+public:
+ RingImpl(const AsteriskSCF::SessionCommunications::V1::SessionPrx& exclude) :
+ mExclude(exclude)
{
- public:
- void operator()(const BridgeImpl::BridgeSessionPtr& b)
- {
- try
- {
- b->getSession()->flash();
- }
- catch(const Ice::ObjectNotExistException& ex)
- {
- mNonExistent.push_back(b);
- lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
- }
- catch(const Ice::Exception& ex)
- {
- lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
- }
- }
+ }
- const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
- {
- return mNonExistent;
- }
- private:
- std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
- };
-
- class HoldImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
+ void operator()(const BridgeImpl::BridgeSessionPtr& b)
{
- public:
- void operator()(const BridgeImpl::BridgeSessionPtr& b)
+ if(b->getSession() != mExclude)
{
try
{
- b->getSession()->hold();
+ b->ring();
}
catch(const Ice::ObjectNotExistException& ex)
{
@@ -263,173 +204,232 @@ namespace BridgeService
lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
}
}
+ }
+
+ const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+ {
+ return mNonExistent;
+ }
+
+private:
+ AsteriskSCF::SessionCommunications::V1::SessionPrx mExclude;
+ std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
+};
- const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+class FlashImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
+{
+public:
+ void operator()(const BridgeImpl::BridgeSessionPtr& b)
+ {
+ try
{
- return mNonExistent;
+ b->getSession()->flash();
}
- private:
- std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
- };
-
- class UnholdImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
- {
- public:
- void operator()(const BridgeImpl::BridgeSessionPtr& b)
+ catch(const Ice::ObjectNotExistException& ex)
{
- try
- {
- b->getSession()->unhold();
- }
- catch(const Ice::ObjectNotExistException& ex)
- {
- mNonExistent.push_back(b);
- lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
- }
- catch(const Ice::Exception& ex)
- {
- lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
- }
+ mNonExistent.push_back(b);
+ lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
}
-
- const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+ catch(const Ice::Exception& ex)
{
- return mNonExistent;
+ lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
}
- private:
- std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
- };
+ }
- class ConnectImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
+ const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
{
- public:
- ConnectImpl(const AsteriskSCF::SessionCommunications::V1::SessionPrx& exclude) :
- mExclude(exclude)
+ return mNonExistent;
+ }
+private:
+ std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
+};
+
+class HoldImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
+{
+public:
+ void operator()(const BridgeImpl::BridgeSessionPtr& b)
+ {
+ try
{
+ b->getSession()->hold();
}
-
- void operator()(BridgeImpl::BridgeSessionPtr& b)
+ catch(const Ice::ObjectNotExistException& ex)
{
- if(b->getSession() != mExclude)
- {
- try
- {
- b->connect();
- }
- catch(const Ice::ObjectNotExistException& ex)
- {
- mNonExistent.push_back(b);
- lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
- }
- catch(const Ice::Exception& ex)
- {
- lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
- }
- }
+ mNonExistent.push_back(b);
+ lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
}
-
- const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+ catch(const Ice::Exception& ex)
{
- return mNonExistent;
+ lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
}
+ }
- private:
- AsteriskSCF::SessionCommunications::V1::SessionPrx mExclude;
- std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
- };
+ const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+ {
+ return mNonExistent;
+ }
+private:
+ std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
+};
- class FindImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, bool>
+class UnholdImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
+{
+public:
+ void operator()(const BridgeImpl::BridgeSessionPtr& b)
{
- public:
- FindImpl(const AsteriskSCF::SessionCommunications::V1::SessionPrx& prx) :
- mPrx(prx)
+ try
+ {
+ b->getSession()->unhold();
+ }
+ catch(const Ice::ObjectNotExistException& ex)
{
+ mNonExistent.push_back(b);
+ lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
}
-
- bool operator()(const BridgeImpl::BridgeSessionPtr& b)
+ catch(const Ice::Exception& ex)
{
- return b->getSession() == mPrx;
+ lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
}
- private:
- AsteriskSCF::SessionCommunications::V1::SessionPrx mPrx;
- };
+ }
+ const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+ {
+ return mNonExistent;
+ }
+private:
+ std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
+};
- //
- // For events that require modification to the bridge, we use helper methods on the bridge itself.
- // For events result in distribution to the bridge sessions, we copy the current sessions and
- // run the calls from the listener itself.
- //
- class SessionListener : public AsteriskSCF::SessionCommunications::V1::SessionListener
+class ConnectImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
+{
+public:
+ ConnectImpl(const AsteriskSCF::SessionCommunications::V1::SessionPrx& exclude) :
+ mExclude(exclude)
{
- public:
- SessionListener(const BridgeImplPtr& b) :
- mBridge(b)
- {
- }
+ }
- void connected(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source, const Ice::Current&)
+ void operator()(BridgeImpl::BridgeSessionPtr& b)
+ {
+ if(b->getSession() != mExclude)
{
try
{
- mBridge->sessionConnected(source);
+ b->connect();
+ }
+ catch(const Ice::ObjectNotExistException& ex)
+ {
+ mNonExistent.push_back(b);
+ lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
}
catch(const Ice::Exception& ex)
{
lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
- throw;
}
- std::vector<BridgeImpl::BridgeSessionPtr> sessions(mBridge->currentSessions());
- std::for_each(sessions.begin(), sessions.end(), ConnectImpl(source));
}
+ }
- void flashed(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source, const Ice::Current&)
- {
- }
+ const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+ {
+ return mNonExistent;
+ }
- void held(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source, const Ice::Current&)
- {
- }
+private:
+ AsteriskSCF::SessionCommunications::V1::SessionPrx mExclude;
+ std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
+};
+
+class FindImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, bool>
+{
+public:
+ FindImpl(const AsteriskSCF::SessionCommunications::V1::SessionPrx& prx) :
+ mPrx(prx)
+ {
+ }
+
+ bool operator()(const BridgeImpl::BridgeSessionPtr& b)
+ {
+ return b->getSession() == mPrx;
+ }
+private:
+ AsteriskSCF::SessionCommunications::V1::SessionPrx mPrx;
+};
+
+
+//
+// For events that require modification to the bridge, we use helper methods on the bridge itself.
+// For events result in distribution to the bridge sessions, we copy the current sessions and
+// run the calls from the listener itself.
+//
+class SessionListener : public AsteriskSCF::SessionCommunications::V1::SessionListener
+{
+public:
+ SessionListener(const BridgeImplPtr& b) :
+ mBridge(b)
+ {
+ }
- void progressing(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source, const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response, const Ice::Current&)
+ void connected(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source, const Ice::Current&)
+ {
+ try
{
+ mBridge->sessionConnected(source);
}
-
- void ringing(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source, const Ice::Current&)
+ catch(const Ice::Exception& ex)
{
- std::vector<BridgeImpl::BridgeSessionPtr> sessions(mBridge->currentSessions());
- if(sessions.size() > 0)
- {
- std::for_each(sessions.begin(), sessions.end(), RingImpl(source));
- }
+ lg(Debug) << __FUNCTION__ << ":" << __LINE__ << ex.what();
+ throw;
}
+ std::vector<BridgeImpl::BridgeSessionPtr> sessions(mBridge->currentSessions());
+ std::for_each(sessions.begin(), sessions.end(), ConnectImpl(source));
+ }
+
+ void flashed(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source, const Ice::Current&)
+ {
+ }
- void stopped(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source, const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response, const Ice::Current& current)
+ void held(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source, const Ice::Current&)
+ {
+ }
+
+ void progressing(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source, const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response, const Ice::Current&)
+ {
+ }
+
+ void ringing(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source, const Ice::Current&)
+ {
+ std::vector<BridgeImpl::BridgeSessionPtr> sessions(mBridge->currentSessions());
+ if(sessions.size() > 0)
{
- size_t endpointCount = mBridge->sessionStopped(source, response);
- if(endpointCount < 2)
- {
- mBridge->spawnShutdown();
- }
+ std::for_each(sessions.begin(), sessions.end(), RingImpl(source));
}
+ }
- void unheld(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source, const Ice::Current&)
+ void stopped(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source, const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response, const Ice::Current& current)
+ {
+ size_t endpointCount = mBridge->sessionStopped(source, response);
+ if(endpointCount < 2)
{
+ mBridge->spawnShutdown();
}
+ }
+
+ void unheld(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source, const Ice::Current&)
+ {
+ }
+
+private:
+ BridgeImplPtr mBridge;
+};
- private:
- BridgeImplPtr mBridge;
- };
-
} // End of namespace BridgeService
} // End of namespace AsteriskSCF
AsteriskSCF::BridgeService::BridgeImpl::BridgeImpl(
- const Ice::ObjectAdapterPtr& adapter,
- const AsteriskSCF::SessionCommunications::V1::BridgeListenerPrx& ev,
- const AsteriskSCF::BridgeService::BridgeListenerMgrPtr& listenerMgr,
- const AsteriskSCF::SessionCommunications::V1::BridgePrx& prx
- ) :
+ const Ice::ObjectAdapterPtr& adapter,
+ const AsteriskSCF::SessionCommunications::V1::BridgeListenerPrx& ev,
+ const AsteriskSCF::BridgeService::BridgeListenerMgrPtr& listenerMgr,
+ const AsteriskSCF::SessionCommunications::V1::BridgePrx& prx
+ ) :
mState(Running),
mObjAdapter(adapter),
mListeners(listenerMgr),
@@ -442,10 +442,10 @@ AsteriskSCF::BridgeService::BridgeImpl::BridgeImpl(
}
std::string listenerId = mObjAdapter->getCommunicator()->identityToString(prx->ice_getIdentity());
listenerId += ".sessionListener";
- mSessionListenerPrx =
+ mSessionListenerPrx =
AsteriskSCF::SessionCommunications::V1::SessionListenerPrx::uncheckedCast(
- mObjAdapter->add(mSessionListener, mObjAdapter->getCommunicator()->stringToIdentity(listenerId))
- );
+ mObjAdapter->add(mSessionListener, mObjAdapter->getCommunicator()->stringToIdentity(listenerId))
+ );
}
AsteriskSCF::BridgeService::BridgeImpl::~BridgeImpl()
@@ -480,7 +480,7 @@ void AsteriskSCF::BridgeService::BridgeImpl::addSessions(const AsteriskSCF::Sess
std::vector<BridgeSessionPtr>::iterator j = find_if(mSessions.begin(), mSessions.end(), AsteriskSCF::BridgeService::FindImpl(*i));
if(j != mSessions.end())
{
- lg(Debug) << __FUNCTION__ << ": " << (*i)->ice_toString() << " is already registered with this bridge.";
+ lg(Debug) << __FUNCTION__ << ": " << (*i)->ice_toString() << " is already registered with this bridge.";
continue;
}
@@ -489,7 +489,7 @@ void AsteriskSCF::BridgeService::BridgeImpl::addSessions(const AsteriskSCF::Sess
{
RetryPolicy policy(5, 500);
//
- // canRetry should never return false since we throw ourselves out of this loop. But
+ // canRetry should never return false since we throw ourselves out of this loop. But
// we'll do it here in case we decide to do something else.
//
while(policy.canRetry())
@@ -497,7 +497,7 @@ void AsteriskSCF::BridgeService::BridgeImpl::addSessions(const AsteriskSCF::Sess
try
{
info = (*i)->setBridge(mPrx, mSessionListenerPrx);
- break;
+ break;
}
catch(const Ice::ConnectionLostException&)
{
@@ -517,15 +517,15 @@ void AsteriskSCF::BridgeService::BridgeImpl::addSessions(const AsteriskSCF::Sess
//
if(info->currentState == "ready")
{
- lg(Debug) << __FUNCTION__ << ": " << (*i)->ice_toString() << " current state is ready (not yet connected), not establishing media connections.";
+ lg(Debug) << __FUNCTION__ << ": " << (*i)->ice_toString() << " current state is ready (not yet connected), not establishing media connections.";
mSessions.push_back(new BridgeSession(*i, 0, false));
}
else
{
- lg(Debug) << __FUNCTION__ << ": " << (*i)->ice_toString() << " media is expected to be establishing, plugging media into bridge.";
+ lg(Debug) << __FUNCTION__ << ": " << (*i)->ice_toString() << " media is expected to be establishing, plugging media into bridge.";
mSessions.push_back(new BridgeSession(*i, mSplicer.connect(*i), false));;
}
-
+
addedSessions.push_back(*i);
}
}
@@ -557,7 +557,7 @@ void AsteriskSCF::BridgeService::BridgeImpl::removeSessions(const AsteriskSCF::S
}
catch(const Ice::Exception& ex)
{
- lg(Info) << __FUNCTION__ << ": removingthe bridge from " << (*j)->getSession() << " threw " << ex.what();
+ lg(Info) << __FUNCTION__ << ": removingthe bridge from " << (*j)->getSession() << " threw " << ex.what();
}
(*j)->disconnect();
mSessions.erase(j);
@@ -605,7 +605,7 @@ void AsteriskSCF::BridgeService::BridgeImpl::shutdown(const Ice::Current& curren
{
//
// When shutting down, the bridge makes a copy of its current state and unlocks, proceeding with
- // no other internal locks.
+ // no other internal locks.
//
lg(Debug) << __FUNCTION__ << ":" << current.adapter->getCommunicator()->identityToString(current.id) ;
boost::unique_lock<boost::shared_mutex> lock(mLock);
@@ -620,7 +620,7 @@ void AsteriskSCF::BridgeService::BridgeImpl::shutdown(const Ice::Current& curren
throw Ice::ObjectNotExistException(__FILE__, __LINE__);
}
mState = ShuttingDown;
-
+
mListeners->stopping();
//
@@ -629,7 +629,7 @@ void AsteriskSCF::BridgeService::BridgeImpl::shutdown(const Ice::Current& curren
if(mSessions.size() > 0)
{
std::for_each(mSessions.begin(), mSessions.end(),
- AsteriskSCF::BridgeService::ShutdownImpl(mSessionListenerPrx, new AsteriskSCF::SessionCommunications::V1::ResponseCode));
+ AsteriskSCF::BridgeService::ShutdownImpl(mSessionListenerPrx, new AsteriskSCF::SessionCommunications::V1::ResponseCode));
}
lg(Info) << current.adapter->getCommunicator()->identityToString(current.id) << ": is shutdown." ;
@@ -670,24 +670,24 @@ void AsteriskSCF::BridgeService::BridgeImpl::destroy(const Ice::Current& current
}
//
- // The bridge manager removes us from the object adapter on reaping.
+ // The bridge manager removes us from the object adapter on reaping.
//
}
void AsteriskSCF::BridgeService::BridgeImpl::addListener(const AsteriskSCF::SessionCommunications::V1::BridgeListenerPrx& listener,
- const Ice::Current&)
+ const Ice::Current&)
{
mListeners->addListener(listener);
}
void AsteriskSCF::BridgeService::BridgeImpl::removeListener(const AsteriskSCF::SessionCommunications::V1::BridgeListenerPrx& listener,
- const Ice::Current&)
+ const Ice::Current&)
{
mListeners->removeListener(listener);
}
-void AsteriskSCF::BridgeService::BridgeImpl::replaceSession(const AsteriskSCF::SessionCommunications::V1::SessionPrx& oldSession,
- const AsteriskSCF::SessionCommunications::V1::SessionSeq& newSessions, const Ice::Current& current)
+void AsteriskSCF::BridgeService::BridgeImpl::replaceSession(const AsteriskSCF::SessionCommunications::V1::SessionPrx& oldSession,
+ const AsteriskSCF::SessionCommunications::V1::SessionSeq& newSessions, const Ice::Current& current)
{
lg(Debug) << __FUNCTION__ << ":" << current.adapter->getCommunicator()->identityToString(current.id) ;
BridgeSessionPtr toRemove;
@@ -709,7 +709,7 @@ void AsteriskSCF::BridgeService::BridgeImpl::replaceSession(const AsteriskSCF::S
//
if(i != mSessions.end())
{
- lg(Debug) << __FUNCTION__ << ": found session to replace : " << oldSession->ice_toString();
+ lg(Debug) << __FUNCTION__ << ": found session to replace : " << oldSession->ice_toString();
toRemove = *i;
toRemove->disconnect();
mSessions.erase(i);
@@ -725,7 +725,7 @@ void AsteriskSCF::BridgeService::BridgeImpl::replaceSession(const AsteriskSCF::S
{
RetryPolicy policy(5, 500);
//
- // canRetry should never return false since we throw ourselves out of this loop. But
+ // canRetry should never return false since we throw ourselves out of this loop. But
// we'll do it here in case we decide to do something else.
//
while(policy.canRetry())
@@ -754,7 +754,7 @@ void AsteriskSCF::BridgeService::BridgeImpl::replaceSession(const AsteriskSCF::S
// really be required if things like replaceSessions() were to be
// atomic.
//
- lg(Info) << __FUNCTION__ << ": setting the bridge on " << *i << " threw " << ex.what();
+ lg(Info) << __FUNCTION__ << ": setting the bridge on " << *i << " threw " << ex.what();
}
}
assert(infoSeq.size() == newMembers.size());
@@ -778,7 +778,7 @@ void AsteriskSCF::BridgeService::BridgeImpl::replaceSession(const AsteriskSCF::S
{
RetryPolicy policy(5, 500);
//
- // canRetry should never return false since we throw ourselves out of this loop. But
+ // canRetry should never return false since we throw ourselves out of this loop. But
// we'll do it here in case we decide to do something else.
//
while(policy.canRetry())
@@ -786,11 +786,11 @@ void AsteriskSCF::BridgeService::BridgeImpl::replaceSession(const AsteriskSCF::S
try
{
toRemove->getSession()->removeBridge(mSessionListenerPrx);
- break;
+ break;
}
catch(const AsteriskSCF::SessionCommunications::V1::NotBridged&)
{
- lg(Info) << __FUNCTION__ << ": removeBridge on session being replaced threw a `NotBridged' exception";
+ lg(Info) << __FUNCTION__ << ": removeBridge on session being replaced threw a `NotBridged' exception";
break;
}
catch(const Ice::ConnectionLostException&)
@@ -858,8 +858,8 @@ void AsteriskSCF::BridgeService::BridgeImpl::sessionConnected(const AsteriskSCF:
}
}
-size_t AsteriskSCF::BridgeService::BridgeImpl::sessionStopped(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
- const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response)
+size_t AsteriskSCF::BridgeService::BridgeImpl::sessionStopped(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
+ const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response)
{
lg(Debug) << __FUNCTION__ << ": session terminated from " << session->ice_toString() ;
try
@@ -915,7 +915,7 @@ namespace
class ShutdownThread : public IceUtil::Thread
{
public:
- ShutdownThread(const AsteriskSCF::SessionCommunications::V1::BridgePrx& bridge) :
+ ShutdownThread(const AsteriskSCF::SessionCommunications::V1::BridgePrx& bridge) :
mBridge(bridge)
{
}
diff --git a/src/BridgeImpl.h b/src/BridgeImpl.h
index a807714..8044d24 100644
--- a/src/BridgeImpl.h
+++ b/src/BridgeImpl.h
@@ -25,162 +25,162 @@ namespace AsteriskSCF
{
namespace BridgeService
{
- //
- // BridgeImpl is an implmentation of AsteriskSCF::Bridging::V1::Bridge.
- //
- class BridgeImpl : public SessionCommunications::V1::Bridge
+//
+// BridgeImpl is an implmentation of AsteriskSCF::Bridging::V1::Bridge.
+//
+class BridgeImpl : public SessionCommunications::V1::Bridge
+{
+public:
+ class BridgeSession : public IceUtil::Shared
{
public:
- class BridgeSession : public IceUtil::Shared
- {
- public:
- BridgeSession(const SessionCommunications::V1::SessionPrx& s, const MediaConnectorPtr& con, bool isConnected) :
- mSession(s),
- mConnector(con),
- mConnected(isConnected)
- {
- }
-
- bool isConnected()
- {
- IceUtil::Mutex::Lock lock(mMutex);
- return mConnected;
- }
-
- void connect()
- {
- //
- // Only call connect on a session if its not already connected.
- //
- IceUtil::Mutex::Lock lock(mMutex);
- if(mConnected)
- return;
-
- mSession->connect();
- mConnected = true;
- }
+ BridgeSession(const SessionCommunications::V1::SessionPrx& s, const MediaConnectorPtr& con, bool isConnected) :
+ mSession(s),
+ mConnector(con),
+ mConnected(isConnected)
+ {
+ }
- void ring()
- {
- //
- // Don't relay ring notifications to connected sessions.
- //
- IceUtil::Mutex::Lock lock(mMutex);
- if(mConnected)
- return;
- mSession->ring();
- }
+ bool isConnected()
+ {
+ IceUtil::Mutex::Lock lock(mMutex);
+ return mConnected;
+ }
- void setConnected()
- {
- IceUtil::Mutex::Lock lock(mMutex);
- mConnected = true;
- }
+ void connect()
+ {
+ //
+ // Only call connect on a session if its not already connected.
+ //
+ IceUtil::Mutex::Lock lock(mMutex);
+ if(mConnected)
+ return;
+
+ mSession->connect();
+ mConnected = true;
+ }
+
+ void ring()
+ {
+ //
+ // Don't relay ring notifications to connected sessions.
+ //
+ IceUtil::Mutex::Lock lock(mMutex);
+ if(mConnected)
+ return;
+ mSession->ring();
+ }
+
+ void setConnected()
+ {
+ IceUtil::Mutex::Lock lock(mMutex);
+ mConnected = true;
+ }
- SessionCommunications::V1::SessionPrx getSession() const
- {
- return mSession;
- }
+ SessionCommunications::V1::SessionPrx getSession() const
+ {
+ return mSession;
+ }
- void setConnector(const MediaConnectorPtr& connector)
- {
- IceUtil::Mutex::Lock lock(mMutex);
- mConnector = connector;
- }
+ void setConnector(const MediaConnectorPtr& connector)
+ {
+ IceUtil::Mutex::Lock lock(mMutex);
+ mConnector = connector;
+ }
- void disconnect()
+ void disconnect()
+ {
+ IceUtil::Mutex::Lock lock(mMutex);
+ if(mConnector)
{
- IceUtil::Mutex::Lock lock(mMutex);
- if(mConnector)
+ try
{
- try
- {
- mConnector->unplug();
- }
- catch(const Ice::Exception&)
- {
- //
- // There are several valid reasons why this might occur, so we'll ignore it and move on.
- //
- }
- mConnector = 0;
+ mConnector->unplug();
}
+ catch(const Ice::Exception&)
+ {
+ //
+ // There are several valid reasons why this might occur, so we'll ignore it and move on.
+ //
+ }
+ mConnector = 0;
}
+ }
+
+ private:
+ SessionCommunications::V1::SessionPrx mSession;
+ MediaConnectorPtr mConnector;
+ bool mConnected;
+ IceUtil::Mutex mMutex;
+ };
+ typedef IceUtil::Handle<BridgeSession> BridgeSessionPtr;
- private:
- SessionCommunications::V1::SessionPrx mSession;
- MediaConnectorPtr mConnector;
- bool mConnected;
- IceUtil::Mutex mMutex;
- };
- typedef IceUtil::Handle<BridgeSession> BridgeSessionPtr;
+ BridgeImpl(const Ice::ObjectAdapterPtr& objAdapter,
+ const SessionCommunications::V1::BridgeListenerPrx& ev,
+ const AsteriskSCF::BridgeService::BridgeListenerMgrPtr& listenerMgr,
+ const AsteriskSCF::SessionCommunications::V1::BridgePrx& prx);
- BridgeImpl(const Ice::ObjectAdapterPtr& objAdapter,
- const SessionCommunications::V1::BridgeListenerPrx& ev,
- const AsteriskSCF::BridgeService::BridgeListenerMgrPtr& listenerMgr,
- const AsteriskSCF::SessionCommunications::V1::BridgePrx& prx);
+ ~BridgeImpl();
- ~BridgeImpl();
+ //
+ // AsteriskSCF::SessionCommunications::Bridging::Bridge Interface
+ //
+ void addSessions(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, const Ice::Current& current);
+ void removeSessions(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, const Ice::Current& current);
- //
- // AsteriskSCF::SessionCommunications::Bridging::Bridge Interface
- //
- void addSessions(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, const Ice::Current& current);
- void removeSessions(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, const Ice::Current& current);
+ AsteriskSCF::SessionCommunications::V1::SessionSeq listSessions(const Ice::Current&);
+ void shutdown(const Ice::Current& current);
+ void destroy(const Ice::Current& current);
- AsteriskSCF::SessionCommunications::V1::SessionSeq listSessions(const Ice::Current&);
- void shutdown(const Ice::Current& current);
- void destroy(const Ice::Current& current);
+ void addListener(const AsteriskSCF::SessionCommunications::V1::BridgeListenerPrx& listener, const Ice::Current& current);
+ void removeListener(const AsteriskSCF::SessionCommunications::V1::BridgeListenerPrx& listener, const Ice::Current& current);
- void addListener(const AsteriskSCF::SessionCommunications::V1::BridgeListenerPrx& listener, const Ice::Current& current);
- void removeListener(const AsteriskSCF::SessionCommunications::V1::BridgeListenerPrx& listener, const Ice::Current& current);
+ void replaceSession(const AsteriskSCF::SessionCommunications::V1::SessionPrx& ,
+ const AsteriskSCF::SessionCommunications::V1::SessionSeq& newSessions, const Ice::Current& current);
- void replaceSession(const AsteriskSCF::SessionCommunications::V1::SessionPrx& ,
- const AsteriskSCF::SessionCommunications::V1::SessionSeq& newSessions, const Ice::Current& current);
+ //
+ // Internal methods
+ //
+ bool destroyed();
+ void destroyImpl();
- //
- // Internal methods
- //
- bool destroyed();
- void destroyImpl();
+ void sessionConnected(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session);
+ size_t sessionStopped(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
+ const SessionCommunications::V1::ResponseCodePtr& response);
- void sessionConnected(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session);
- size_t sessionStopped(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
- const SessionCommunications::V1::ResponseCodePtr& response);
-
- std::vector<BridgeSessionPtr> currentSessions();
+ std::vector<BridgeSessionPtr> currentSessions();
- void spawnShutdown();
+ void spawnShutdown();
- private:
+private:
- boost::shared_mutex mLock;
- enum ServiceStates
- {
- Running,
- ShuttingDown,
- Destroyed
- };
- ServiceStates mState;
+ boost::shared_mutex mLock;
+ enum ServiceStates
+ {
+ Running,
+ ShuttingDown,
+ Destroyed
+ };
+ ServiceStates mState;
- std::vector<BridgeSessionPtr> mSessions;
+ std::vector<BridgeSessionPtr> mSessions;
- MediaSplicer mSplicer;
+ MediaSplicer mSplicer;
- const std::string mName;
- Ice::ObjectAdapterPtr mObjAdapter;
+ const std::string mName;
+ Ice::ObjectAdapterPtr mObjAdapter;
- BridgeListenerMgrPtr mListeners;
- SessionCommunications::V1::SessionListenerPtr mSessionListener;
- SessionCommunications::V1::SessionListenerPrx mSessionListenerPrx;
- AsteriskSCF::SessionCommunications::V1::BridgePrx mPrx;
+ BridgeListenerMgrPtr mListeners;
+ SessionCommunications::V1::SessionListenerPtr mSessionListener;
+ SessionCommunications::V1::SessionListenerPrx mSessionListenerPrx;
+ AsteriskSCF::SessionCommunications::V1::BridgePrx mPrx;
- IceUtil::Handle<IceUtil::Thread> mShutdownThread;
+ IceUtil::Handle<IceUtil::Thread> mShutdownThread;
- void statePreCheck();
- };
+ void statePreCheck();
+};
- typedef IceUtil::Handle<BridgeImpl> BridgeImplPtr;
+typedef IceUtil::Handle<BridgeImpl> BridgeImplPtr;
} // End of namespace Bridging.
} // End of namespace AsteriskSCF.
diff --git a/src/BridgeListenerMgr.cpp b/src/BridgeListenerMgr.cpp
index a7456e1..675b6e3 100644
--- a/src/BridgeListenerMgr.cpp
+++ b/src/BridgeListenerMgr.cpp
@@ -16,8 +16,8 @@
#include "BridgeListenerMgr.h"
AsteriskSCF::BridgeService::BridgeListenerMgr::BridgeListenerMgr(const Ice::CommunicatorPtr& comm,
- const std::string& name,
- const AsteriskSCF::SessionCommunications::V1::BridgePrx& bridgeProxy) :
+ const std::string& name,
+ const AsteriskSCF::SessionCommunications::V1::BridgePrx& bridgeProxy) :
ListenerManagerT<AsteriskSCF::SessionCommunications::V1::BridgeListenerPrx>(comm, name, false),
mPrx(bridgeProxy)
{
diff --git a/src/BridgeListenerMgr.h b/src/BridgeListenerMgr.h
index 69a7fcc..041fd0d 100644
--- a/src/BridgeListenerMgr.h
+++ b/src/BridgeListenerMgr.h
@@ -24,21 +24,21 @@ namespace AsteriskSCF
{
namespace BridgeService
{
- class BridgeListenerMgr : virtual public ListenerManagerT<AsteriskSCF::SessionCommunications::V1::BridgeListenerPrx>
- {
- public:
- BridgeListenerMgr(const Ice::CommunicatorPtr& communicator, const std::string& name,
- const AsteriskSCF::SessionCommunications::V1::BridgePrx& source);
+class BridgeListenerMgr : virtual public ListenerManagerT<AsteriskSCF::SessionCommunications::V1::BridgeListenerPrx>
+{
+public:
+ BridgeListenerMgr(const Ice::CommunicatorPtr& communicator, const std::string& name,
+ const AsteriskSCF::SessionCommunications::V1::BridgePrx& source);
- void sessionsAdded(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions);
- void sessionsRemoved(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions);
- void stopped();
- void stopping();
+ void sessionsAdded(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions);
+ void sessionsRemoved(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions);
+ void stopped();
+ void stopping();
- private:
- AsteriskSCF::SessionCommunications::V1::BridgePrx mPrx;
- };
+private:
+ AsteriskSCF::SessionCommunications::V1::BridgePrx mPrx;
+};
- typedef IceUtil::Handle<BridgeListenerMgr> BridgeListenerMgrPtr;
+typedef IceUtil::Handle<BridgeListenerMgr> BridgeListenerMgrPtr;
} // End of namespace BridgeService
} // End of namespace AsteriskSCF
diff --git a/src/BridgeManagerImpl.cpp b/src/BridgeManagerImpl.cpp
index 66ea54e..3540bc6 100644
--- a/src/BridgeManagerImpl.cpp
+++ b/src/BridgeManagerImpl.cpp
@@ -39,33 +39,33 @@ namespace AsteriskSCF
{
namespace BridgeService
{
- //
- // Functor used with for_each on shutdown.
- //
- class BridgeMgrShutdownImpl : public std::unary_function<BridgeManagerImpl::BridgeInfo, void>
+//
+// Functor used with for_each on shutdown.
+//
+class BridgeMgrShutdownImpl : public std::unary_function<BridgeManagerImpl::BridgeInfo, void>
+{
+public:
+ BridgeMgrShutdownImpl(const Ice::Current& c) :
+ mCurrent(c)
{
- public:
- BridgeMgrShutdownImpl(const Ice::Current& c) :
- mCurrent(c)
- {
- }
+ }
- void operator()(const BridgeManagerImpl::BridgeInfo& b)
- {
- b.servant->shutdown(mCurrent);
- }
+ void operator()(const BridgeManagerImpl::BridgeInfo& b)
+ {
+ b.servant->shutdown(mCurrent);
+ }
- private:
- const Ice::Current mCurrent;
- };
+private:
+ const Ice::Current mCurrent;
+};
} // End of namespace BridgeService
} // End of namespace AsteriskSCF
AsteriskSCF::BridgeService::BridgeManagerImpl::BridgeManagerImpl(
const Ice::ObjectAdapterPtr& adapter,
- const std::string& name,
- const AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx& prx) :
+ const std::string& name,
+ const AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx& prx) :
mName(name),
mShuttingDown(false),
mSuspended(false),
@@ -86,9 +86,9 @@ AsteriskSCF::BridgeService::BridgeManagerImpl::~BridgeManagerImpl()
}
AsteriskSCF::SessionCommunications::V1::BridgePrx AsteriskSCF::BridgeService::BridgeManagerImpl::createBridge(
- const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions,
- const AsteriskSCF::SessionCommunications::V1::BridgeListenerPrx& listener,
- const Ice::Current& current)
+ const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions,
+ const AsteriskSCF::SessionCommunications::V1::BridgeListenerPrx& listener,
+ const Ice::Current& current)
{
lg(Debug) << __FUNCTION__ << ":" << current.adapter->getCommunicator()->identityToString(current.id) ;
@@ -110,10 +110,10 @@ AsteriskSCF::SessionCommunications::V1::BridgePrx AsteriskSCF::BridgeService::Br
AsteriskSCF::SessionCommunications::V1::BridgePrx prx(
AsteriskSCF::SessionCommunications::V1::BridgePrx::uncheckedCast(mAdapter->createProxy(id)));
AsteriskSCF::BridgeService::BridgeListenerMgrPtr mgr(new BridgeListenerMgr(mAdapter->getCommunicator(), stringId, prx));
-
+
AsteriskSCF::BridgeService::BridgeImplPtr bridge = new AsteriskSCF::BridgeService::BridgeImpl(mAdapter, listener, mgr, prx);
Ice::ObjectPrx obj = mAdapter->add(bridge, id);
-
+
lg(Info) << current.adapter->getCommunicator()->identityToString(current.id) << ": creating new bridge " << obj->ice_toString() << "." ;
BridgeInfo info;
info.servant = bridge;
diff --git a/src/BridgeManagerImpl.h b/src/BridgeManagerImpl.h
index fa62ae3..c2a18a5 100644
--- a/src/BridgeManagerImpl.h
+++ b/src/BridgeManagerImpl.h
@@ -26,45 +26,45 @@ namespace AsteriskSCF
{
namespace BridgeService
{
- class BridgeManagerImpl : public SessionCommunications::V1::BridgeManager
- {
- public:
-
- BridgeManagerImpl(const Ice::ObjectAdapterPtr& adapter, const std::string& name, const AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx& prx);
- ~BridgeManagerImpl();
-
- //
- // AsteriskSCF::SessionCommunications::V1::BridgeManager Interface
- //
- SessionCommunications::V1::BridgePrx createBridge(
- const SessionCommunications::V1::SessionSeq& endpoints,
+class BridgeManagerImpl : public SessionCommunications::V1::BridgeManager
+{
+public:
+
+ BridgeManagerImpl(const Ice::ObjectAdapterPtr& adapter, const std::string& name, const AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx& prx);
+ ~BridgeManagerImpl();
+
+ //
+ // AsteriskSCF::SessionCommunications::V1::BridgeManager Interface
+ //
+ SessionCommunications::V1::BridgePrx createBridge(
+ const SessionCommunications::V1::SessionSeq& endpoints,
const SessionCommunications::V1::BridgeListenerPrx& listener,
const Ice::Current& current);
-
- void addListener(const SessionCommunications::V1::BridgeManagerListenerPrx& listener, const Ice::Current& current);
- void removeListener(const SessionCommunications::V1::BridgeManagerListenerPrx& listener, const Ice::Current& current);
- SessionCommunications::V1::BridgeSeq listBridges(const Ice::Current& current);
- void shutdown(const Ice::Current& current);
- struct BridgeInfo
- {
- BridgeImplPtr servant;
- SessionCommunications::V1::BridgePrx proxy;
- };
-
- private:
-
- boost::shared_mutex mLock;
- std::string mName;
- std::vector<BridgeInfo> mBridges;
- bool mShuttingDown;
- bool mSuspended;
- Ice::ObjectAdapterPtr mAdapter;
- AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx mSourceProxy;
- BridgeManagerListenerMgrPtr mListeners;
- void reap();
+ void addListener(const SessionCommunications::V1::BridgeManagerListenerPrx& listener, const Ice::Current& current);
+ void removeListener(const SessionCommunications::V1::BridgeManagerListenerPrx& listener, const Ice::Current& current);
+ SessionCommunications::V1::BridgeSeq listBridges(const Ice::Current& current);
+ void shutdown(const Ice::Current& current);
+
+ struct BridgeInfo
+ {
+ BridgeImplPtr servant;
+ SessionCommunications::V1::BridgePrx proxy;
};
- typedef IceUtil::Handle<BridgeManagerImpl> BridgeManagerImplPtr;
+private:
+
+ boost::shared_mutex mLock;
+ std::string mName;
+ std::vector<BridgeInfo> mBridges;
+ bool mShuttingDown;
+ bool mSuspended;
+ Ice::ObjectAdapterPtr mAdapter;
+ AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx mSourceProxy;
+ BridgeManagerListenerMgrPtr mListeners;
+ void reap();
+};
+
+typedef IceUtil::Handle<BridgeManagerImpl> BridgeManagerImplPtr;
};
};
diff --git a/src/BridgeManagerListenerMgr.cpp b/src/BridgeManagerListenerMgr.cpp
index f7c4b5b..dd7b6f9 100644
--- a/src/BridgeManagerListenerMgr.cpp
+++ b/src/BridgeManagerListenerMgr.cpp
@@ -16,7 +16,7 @@
#include "BridgeManagerListenerMgr.h"
AsteriskSCF::BridgeService::BridgeManagerListenerMgr::BridgeManagerListenerMgr(const Ice::CommunicatorPtr& communicator, const std::string& name,
- const AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx& source) :
+ const AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx& source) :
AsteriskSCF::BridgeService::ListenerManagerT<AsteriskSCF::SessionCommunications::V1::BridgeManagerListenerPrx>(communicator, name, true),
mPrx(source)
{
diff --git a/src/BridgeManagerListenerMgr.h b/src/BridgeManagerListenerMgr.h
index 5af19b6..1579772 100644
--- a/src/BridgeManagerListenerMgr.h
+++ b/src/BridgeManagerListenerMgr.h
@@ -24,21 +24,21 @@ namespace AsteriskSCF
{
namespace BridgeService
{
- class BridgeManagerListenerMgr : virtual public ListenerManagerT<AsteriskSCF::SessionCommunications::V1::BridgeManagerListenerPrx>
- {
- public:
- BridgeManagerListenerMgr(const Ice::CommunicatorPtr& communicator, const std::string& name,
- const AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx& source);
+class BridgeManagerListenerMgr : virtual public ListenerManagerT<AsteriskSCF::SessionCommunications::V1::BridgeManagerListenerPrx>
+{
+public:
+ BridgeManagerListenerMgr(const Ice::CommunicatorPtr& communicator, const std::string& name,
+ const AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx& source);
- void bridgeCreated(const AsteriskSCF::SessionCommunications::V1::BridgePrx& bridge);
- void stopped();
- void stopping();
+ void bridgeCreated(const AsteriskSCF::SessionCommunications::V1::BridgePrx& bridge);
+ void stopped();
+ void stopping();
- void setSource(const AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx& source);
- private:
- AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx mPrx;
- };
+ void setSource(const AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx& source);
+private:
+ AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx mPrx;
+};
- typedef IceUtil::Handle<BridgeManagerListenerMgr> BridgeManagerListenerMgrPtr;
+typedef IceUtil::Handle<BridgeManagerListenerMgr> BridgeManagerListenerMgrPtr;
} // End of namespace BridgeService
} // End of namespace AsteriskSCF
diff --git a/src/BridgeServiceImpl.h b/src/BridgeServiceImpl.h
index b29c58b..edf00e1 100644
--- a/src/BridgeServiceImpl.h
+++ b/src/BridgeServiceImpl.h
@@ -13,10 +13,10 @@
namespace AsteriskSCF
{
- namespace BridgeService
- {
- class BridgeImpl
- }
+namespace BridgeService
+{
+class BridgeImpl
+}
}
#endif
diff --git a/src/InternalExceptions.h b/src/InternalExceptions.h
index 2eca5cd..17d189e 100644
--- a/src/InternalExceptions.h
+++ b/src/InternalExceptions.h
@@ -17,36 +17,36 @@ namespace AsteriskSCF
{
namespace BridgeService
{
- class ConfigException : public std::exception
- {
- public:
+class ConfigException : public std::exception
+{
+public:
- ConfigException(const std::string& propertyName, const std::string& message)
+ ConfigException(const std::string& propertyName, const std::string& message)
+ {
+ std::stringstream what;
+ what << propertyName << " configuration error: ";
+ if(message.size() != 0)
{
- std::stringstream what;
- what << propertyName << " configuration error: ";
- if(message.size() != 0)
- {
- what << message;
- }
- else
- {
- what << "(no message)";
- }
- mWhat = what.str();
+ what << message;
}
-
- ~ConfigException() throw()
+ else
{
+ what << "(no message)";
}
+ mWhat = what.str();
+ }
- const char* what() const throw()
- {
- return mWhat.c_str();
- }
+ ~ConfigException() throw()
+ {
+ }
+
+ const char* what() const throw()
+ {
+ return mWhat.c_str();
+ }
- private:
- std::string mWhat;
- };
+private:
+ std::string mWhat;
+};
}
}
diff --git a/src/ListenerManager.h b/src/ListenerManager.h
index 170e9cb..e0e8700 100644
--- a/src/ListenerManager.h
+++ b/src/ListenerManager.h
@@ -21,245 +21,245 @@ namespace AsteriskSCF
{
namespace BridgeService
{
- //
- // Helper template for classes that need to implement listener style interfaces.
- //
- template <class T>
- class ListenerManagerT : public IceUtil::Shared
+//
+// Helper template for classes that need to implement listener style interfaces.
+//
+template <class T>
+class ListenerManagerT : public IceUtil::Shared
+{
+ typedef std::vector<T> ListenerSeq;
+ typename std::vector<T>::iterator ListenerIter;
+
+ class InitializationThread : public IceUtil::Thread
{
- typedef std::vector<T> ListenerSeq;
- typename std::vector<T>::iterator ListenerIter;
+ public:
+ InitializationThread(const typename IceUtil::Handle<ListenerManagerT>& mgr) :
+ mMgr(mgr),
+ mStopped(false)
+ {
+ }
- class InitializationThread : public IceUtil::Thread
+ void run()
{
- public:
- InitializationThread(const typename IceUtil::Handle<ListenerManagerT>& mgr) :
- mMgr(mgr),
- mStopped(false)
+ bool initialized = false;
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mMonitor);
+ while(!mStopped && !initialized)
{
+ //
+ // TODO: Make configurable.
+ //
+ mMonitor.timedWait(IceUtil::Time::seconds(15));
+ initialized = mMgr->init();
}
+ }
- void run()
- {
- bool initialized = false;
- IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mMonitor);
- while(!mStopped && !initialized)
- {
- //
- // TODO: Make configurable.
- //
- mMonitor.timedWait(IceUtil::Time::seconds(15));
- initialized = mMgr->init();
- }
- }
+ void stop()
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mMonitor);
+ mStopped = true;
+ mMonitor.notify();
+ }
- void stop()
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mMonitor);
- mStopped = true;
- mMonitor.notify();
- }
+ private:
+ IceUtil::Monitor<IceUtil::Mutex> mMonitor;
+ typename IceUtil::Handle<ListenerManagerT> mMgr;
+ bool mStopped;
+ };
- private:
- IceUtil::Monitor<IceUtil::Mutex> mMonitor;
- typename IceUtil::Handle<ListenerManagerT> mMgr;
- bool mStopped;
- };
+public:
+ ListenerManagerT(const Ice::CommunicatorPtr& communicator, const std::string& topicName, bool enableBackgroundInit) :
+ mCommunicator(communicator),
+ mTopicName(topicName),
+ mInitialized(false)
+ {
+ try
+ {
+ init();
+ }
+ catch(const Ice::Exception&)
+ {
+ }
+ if(!mInitialized && enableBackgroundInit)
+ {
+ mInitThread = new InitializationThread(this);
+ mInitThread->start();
+ }
+ }
- public:
- ListenerManagerT(const Ice::CommunicatorPtr& communicator, const std::string& topicName, bool enableBackgroundInit) :
- mCommunicator(communicator),
- mTopicName(topicName),
- mInitialized(false)
+ virtual ~ListenerManagerT()
+ {
+ if(mTopic)
{
try
{
- init();
- }
- catch(const Ice::Exception&)
- {
+ mTopic->destroy();
}
- if(!mInitialized && enableBackgroundInit)
+ catch(...)
{
- mInitThread = new InitializationThread(this);
- mInitThread->start();
+ //
+ // Destructors are no-throw!
+ //
}
}
+ }
- virtual ~ListenerManagerT()
+ //
+ // NOTE: The current implementation is a little fast and loose here. Inconsistent conditions
+ // and whatnot are not flagged.
+ //
+ void addListener(const T& listener)
+ {
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ if(std::find(mListeners.begin(), mListeners.end(), listener) == mListeners.end())
{
- if(mTopic)
- {
- try
- {
- mTopic->destroy();
- }
- catch(...)
- {
- //
- // Destructors are no-throw!
- //
- }
- }
+ mListeners.push_back(listener);
}
- //
- // NOTE: The current implementation is a little fast and loose here. Inconsistent conditions
- // and whatnot are not flagged.
- //
- void addListener(const T& listener)
+ if(mInitialized)
{
- boost::unique_lock<boost::shared_mutex> lock(mLock);
- if(std::find(mListeners.begin(), mListeners.end(), listener) == mListeners.end())
+ IceStorm::QoS qos;
+ qos["reliability"] = "ordered";
+
+ try
{
- mListeners.push_back(listener);
+ mTopic->subscribeAndGetPublisher(qos, listener);
}
-
- if(mInitialized)
+ catch(const IceStorm::AlreadySubscribed&)
{
- IceStorm::QoS qos;
- qos["reliability"] = "ordered";
-
- try
- {
- mTopic->subscribeAndGetPublisher(qos, listener);
- }
- catch(const IceStorm::AlreadySubscribed&)
- {
- //
- // This indicates some kind of inconsistent state.
- //
- }
+ //
+ // This indicates some kind of inconsistent state.
+ //
}
}
+ }
- void removeListener(const T& listener)
+ void removeListener(const T& listener)
+ {
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ typename std::vector<T>::iterator i = std::find(mListeners.begin(), mListeners.end(), listener);
+ if(i != mListeners.end())
{
- boost::unique_lock<boost::shared_mutex> lock(mLock);
- typename std::vector<T>::iterator i = std::find(mListeners.begin(), mListeners.end(), listener);
- if(i != mListeners.end())
+ mListeners.erase(i);
+ if(mInitialized)
{
- mListeners.erase(i);
- if(mInitialized)
- {
- mTopic->unsubscribe(listener);
- }
+ mTopic->unsubscribe(listener);
}
}
+ }
+
+ std::vector<T> getListeners()
+ {
+ boost::shared_lock<boost::shared_mutex> lock(mLock);
+ std::vector<T> result(mListeners);
+ return result;
+ }
+
+ bool isSuspended()
+ {
+ boost::shared_lock<boost::shared_mutex> lock(mLock);
+ return !mInitialized;
+ }
- std::vector<T> getListeners()
+ void stop()
+ {
+ if(mInitThread)
{
- boost::shared_lock<boost::shared_mutex> lock(mLock);
- std::vector<T> result(mListeners);
- return result;
+ mInitThread->stop();
}
+ }
- bool isSuspended()
+protected:
+ boost::shared_mutex mLock;
+ Ice::CommunicatorPtr mCommunicator;
+ std::string mTopicName;
+ IceStorm::TopicPrx mTopic;
+ IceStorm::TopicManagerPrx mTopicManager;
+ T mPublisher;
+ ListenerSeq mListeners;
+ IceUtil::Handle<InitializationThread> mInitThread;
+
+ bool mInitialized;
+
+ bool init()
+ {
+ boost::shared_lock<boost::shared_mutex> lock(mLock);
+ if(mInitialized)
{
- boost::shared_lock<boost::shared_mutex> lock(mLock);
- return !mInitialized;
+ return mInitialized;
}
- void stop()
+ //
+ // TODO: While this is being concocted for a single component, it would make more sense
+ // to have the topic manager passed in during construction for more general usage.
+ //
+ const std::string propertyName = "TopicManager.Proxy";
+ std::string topicManagerProperty = mCommunicator->getProperties()->getProperty(propertyName);
+ if(topicManagerProperty.size() == 0)
{
- if(mInitThread)
- {
- mInitThread->stop();
- }
+ throw ConfigException(propertyName, "Topic manager proxy property missing. "
+ "Unable to initialize listener support.");
}
- protected:
- boost::shared_mutex mLock;
- Ice::CommunicatorPtr mCommunicator;
- std::string mTopicName;
- IceStorm::TopicPrx mTopic;
- IceStorm::TopicManagerPrx mTopicManager;
- T mPublisher;
- ListenerSeq mListeners;
- IceUtil::Handle<InitializationThread> mInitThread;
-
- bool mInitialized;
-
- bool init()
+ try
{
- boost::shared_lock<boost::shared_mutex> lock(mLock);
- if(mInitialized)
- {
- return mInitialized;
- }
+ mTopicManager = IceStorm::TopicManagerPrx::checkedCast(mCommunicator->stringToProxy(topicManagerProperty));
+ }
+ catch(const Ice::Exception&)
+ {
+ return false;
+ }
- //
- // TODO: While this is being concocted for a single component, it would make more sense
- // to have the topic manager passed in during construction for more general usage.
- //
- const std::string propertyName = "TopicManager.Proxy";
- std::string topicManagerProperty = mCommunicator->getProperties()->getProperty(propertyName);
- if(topicManagerProperty.size() == 0)
- {
- throw ConfigException(propertyName, "Topic manager proxy property missing. "
- "Unable to initialize listener support.");
- }
+ try
+ {
+ mTopic = mTopicManager->retrieve(mTopicName);
+ }
+ catch(const IceStorm::NoSuchTopic&)
+ {
+ }
+ if(!mTopic)
+ {
try
{
- mTopicManager = IceStorm::TopicManagerPrx::checkedCast(mCommunicator->stringToProxy(topicManagerProperty));
- }
- catch(const Ice::Exception&)
- {
- return false;
+ mTopic = mTopicManager->create(mTopicName);
}
-
- try
+ catch(const IceStorm::TopicExists&)
{
+ //
+ // In case there is a race condition when creating the topic.
+ //
mTopic = mTopicManager->retrieve(mTopicName);
}
- catch(const IceStorm::NoSuchTopic&)
- {
- }
+ }
- if(!mTopic)
+ if(!mTopic)
+ {
+ return mInitialized;
+ }
+ mPublisher = T::uncheckedCast(mTopic->getPublisher());
+
+ if(mListeners.size() > 0)
+ {
+ for(typename std::vector<T>::iterator i = mListeners.begin(); i != mListeners.end(); ++i)
{
+ IceStorm::QoS qos;
+ qos["reliability"] = "ordered";
+
try
{
- mTopic = mTopicManager->create(mTopicName);
+ mTopic->subscribeAndGetPublisher(qos, *i);
}
- catch(const IceStorm::TopicExists&)
+ catch(const IceStorm::AlreadySubscribed&)
{
//
- // In case there is a race condition when creating the topic.
+ // This indicates some kind of inconsistent state.
//
- mTopic = mTopicManager->retrieve(mTopicName);
}
}
-
- if(!mTopic)
- {
- return mInitialized;
- }
- mPublisher = T::uncheckedCast(mTopic->getPublisher());
-
- if(mListeners.size() > 0)
- {
- for(typename std::vector<T>::iterator i = mListeners.begin(); i != mListeners.end(); ++i)
- {
- IceStorm::QoS qos;
- qos["reliability"] = "ordered";
-
- try
- {
- mTopic->subscribeAndGetPublisher(qos, *i);
- }
- catch(const IceStorm::AlreadySubscribed&)
- {
- //
- // This indicates some kind of inconsistent state.
- //
- }
- }
- }
- mInitialized = true;
- return mInitialized;
}
- };
+ mInitialized = true;
+ return mInitialized;
+ }
+};
}
}
diff --git a/src/MediaSplicer.cpp b/src/MediaSplicer.cpp
index a7048f6..81fc3e7 100755
--- a/src/MediaSplicer.cpp
+++ b/src/MediaSplicer.cpp
@@ -28,412 +28,412 @@ namespace AsteriskSCF
{
namespace BridgeService
{
- //
- // Forward declarations.
- //
- class MediaSplicerI;
- class MedixMixerPtr;
+//
+// Forward declarations.
+//
+class MediaSplicerI;
+class MedixMixerPtr;
- typedef std::pair<Media::V1::StreamSinkPrx, Media::V1::StreamSourcePrx> OutgoingPairing;
- typedef std::pair<Media::V1::StreamSourcePrx, Media::V1::StreamSinkPrx> IncomingPairing;
+typedef std::pair<Media::V1::StreamSinkPrx, Media::V1::StreamSourcePrx> OutgoingPairing;
+typedef std::pair<Media::V1::StreamSourcePrx, Media::V1::StreamSinkPrx> IncomingPairing;
- //
- // TODO: These proxies could use some retry properties added to them...
- // particularily for the media stream connect/disconnect operations.
- //
+//
+// TODO: These proxies could use some retry properties added to them...
+// particularily for the media stream connect/disconnect operations.
+//
- class MediaConnectorI : public MediaConnector
+class MediaConnectorI : public MediaConnector
+{
+public:
+
+ MediaConnectorI(const std::vector<OutgoingPairing>& outgoing, const std::vector<IncomingPairing>& incoming,
+ const MediaConnectorPtr& peer):
+ mOutgoing(outgoing),
+ mIncoming(incoming),
+ mPeer(peer),
+ mConnected(true)
{
- public:
+ lg(Debug) << __FUNCTION__ << ": setting up a media connector with " << outgoing.size() << " outgoing pairings and " << incoming.size() << " incoming pairings.";
+ for(std::vector<OutgoingPairing>::iterator i = mOutgoing.begin(); i != mOutgoing.end(); ++i)
+ {
+ i->second->setSink(i->first);
+ i->first->setSource(i->second);
+ }
+ for(std::vector<IncomingPairing>::iterator i = mIncoming.begin(); i != mIncoming.end(); ++i)
+ {
+ i->first->setSink(i->second);
+ i->second->setSource(i->first);
+ }
+ }
- MediaConnectorI(const std::vector<OutgoingPairing>& outgoing, const std::vector<IncomingPairing>& incoming,
- const MediaConnectorPtr& peer):
- mOutgoing(outgoing),
- mIncoming(incoming),
- mPeer(peer),
- mConnected(true)
+ void unplug()
+ {
+ lg(Debug) << __FUNCTION__ << ": called.";
+ bool hadMedia = disconnectMedia();
+ if(!hadMedia)
{
- lg(Debug) << __FUNCTION__ << ": setting up a media connector with " << outgoing.size() << " outgoing pairings and " << incoming.size() << " incoming pairings.";
- for(std::vector<OutgoingPairing>::iterator i = mOutgoing.begin(); i != mOutgoing.end(); ++i)
+ lg(Debug) << __FUNCTION__ << ": we did not have any media. Contacting the peer connector and telling it to disconnect!";
+ MediaConnectorPtr peer;
{
- i->second->setSink(i->first);
- i->first->setSource(i->second);
+ IceUtil::Mutex::Lock lock(mMutex);
+ peer = mPeer;
+ mPeer = 0;
}
... 957 lines suppressed ...
--
asterisk-scf/integration/bridging.git
More information about the asterisk-scf-commits
mailing list