[asterisk-scf-commits] asterisk-scf/integration/media_rtp_pjmedia.git branch "code-conventions" created.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Mon Mar 21 08:51:00 CDT 2011
branch "code-conventions" has been created
at 5a8aa0e39283ebc8eed7883d0b6cbb1867e3863b (commit)
- Log -----------------------------------------------------------------
commit 5a8aa0e39283ebc8eed7883d0b6cbb1867e3863b
Author: Brent Eagles <beagles at digium.com>
Date: Mon Mar 21 11:19:59 2011 -0230
* Update method signatures to pass smart pointers, references and proxies
by const ref.
* Split some long lines
diff --git a/src/MediaRTPpjmedia.cpp b/src/MediaRTPpjmedia.cpp
index 4a1d0ee..f041e4f 100644
--- a/src/MediaRTPpjmedia.cpp
+++ b/src/MediaRTPpjmedia.cpp
@@ -59,7 +59,8 @@ static const string MediaServiceId("RTPMediaService");
class RTPMediaServiceImpl : public RTPMediaService
{
public:
- RTPMediaServiceImpl(Ice::ObjectAdapterPtr, ReplicaPtr, AsteriskSCF::SmartProxy::SmartProxy<RtpStateReplicatorPrx>);
+ RTPMediaServiceImpl(const Ice::ObjectAdapterPtr&, const ReplicaPtr&,
+ const AsteriskSCF::SmartProxy::SmartProxy<RtpStateReplicatorPrx>&);
RTPSessionPrx allocate(const FormatSeq&, const Ice::Current&);
pj_pool_factory *getPoolFactory() { return &mCachingPool.factory; };
private:
@@ -100,7 +101,7 @@ typedef IceUtil::Handle<RTPMediaServiceImpl> RTPMediaServiceImplPtr;
class ReplicaImpl : public Replica
{
public:
- ReplicaImpl(Ice::ObjectAdapterPtr adapter) : mAdapter(adapter), mPaused(false), mActive(true) { }
+ ReplicaImpl(const Ice::ObjectAdapterPtr& adapter) : mAdapter(adapter), mPaused(false), mActive(true) { }
bool isActive(const Ice::Current&)
{
@@ -111,9 +112,11 @@ public:
{
mActive = true;
- for (vector<AsteriskSCF::System::Component::V1::ReplicaListenerPrx>::const_iterator listener = mListeners.begin(); listener != mListeners.end(); ++listener)
+ for (vector<AsteriskSCF::System::Component::V1::ReplicaListenerPrx>::const_iterator listener =
+ mListeners.begin(); listener != mListeners.end(); ++listener)
{
- (*listener)->activated(ReplicaPrx::uncheckedCast(mAdapter->createDirectProxy(mAdapter->getCommunicator()->stringToIdentity(ReplicaServiceId))));
+ (*listener)->activated(ReplicaPrx::uncheckedCast(
+ mAdapter->createDirectProxy(mAdapter->getCommunicator()->stringToIdentity(ReplicaServiceId))));
}
return true;
@@ -123,9 +126,11 @@ public:
{
mActive = false;
- for (vector<AsteriskSCF::System::Component::V1::ReplicaListenerPrx>::const_iterator listener = mListeners.begin(); listener != mListeners.end(); ++listener)
+ for (vector<AsteriskSCF::System::Component::V1::ReplicaListenerPrx>::const_iterator listener =
+ mListeners.begin(); listener != mListeners.end(); ++listener)
{
- (*listener)->onStandby(ReplicaPrx::uncheckedCast(mAdapter->createDirectProxy(mAdapter->getCommunicator()->stringToIdentity(ReplicaServiceId))));
+ (*listener)->onStandby(ReplicaPrx::uncheckedCast(
+ mAdapter->createDirectProxy(mAdapter->getCommunicator()->stringToIdentity(ReplicaServiceId))));
}
}
@@ -226,7 +231,8 @@ public:
/**
* A constructor for this implementation which just sets a few variables, nothing extreme.
*/
- ComponentServicepjmediaImpl(MediaRTPpjmediaApp& app, RtpGeneralStateItemPtr generalState) : mApplication(app), mGeneralState(generalState) { };
+ ComponentServicepjmediaImpl(MediaRTPpjmediaApp& app, const RtpGeneralStateItemPtr& generalState) :
+ mApplication(app), mGeneralState(generalState) { };
/**
* An implementation of the suspend method which actually suspends ourselves
@@ -321,7 +327,8 @@ private:
/**
* Constructor for the RTPMediaServiceImpl class.
*/
-RTPMediaServiceImpl::RTPMediaServiceImpl(Ice::ObjectAdapterPtr adapter, ReplicaPtr replicaService, AsteriskSCF::SmartProxy::SmartProxy<RtpStateReplicatorPrx> stateReplicator) :
+RTPMediaServiceImpl::RTPMediaServiceImpl(const Ice::ObjectAdapterPtr& adapter, const ReplicaPtr& replicaService,
+ const AsteriskSCF::SmartProxy::SmartProxy<RtpStateReplicatorPrx>& stateReplicator) :
mAdapter(adapter), mReplicaService(replicaService), mStateReplicator(stateReplicator)
{
/* Initialize the memory caching pool using default policy as specified by pjlib. */
@@ -336,19 +343,20 @@ RTPMediaServiceImpl::RTPMediaServiceImpl(Ice::ObjectAdapterPtr adapter, ReplicaP
*/
RTPSessionPrx RTPMediaServiceImpl::allocate(const FormatSeq& formats, const Ice::Current&)
{
- RTPSessionImplPtr session = new RTPSessionImpl(mAdapter, formats, &mCachingPool.factory, mReplicaService, mStateReplicator);
+ RTPSessionImplPtr session =
+ new RTPSessionImpl(mAdapter, formats, &mCachingPool.factory, mReplicaService, mStateReplicator);
return session->getProxy();
}
/**
* Implementation of the IceBox::Service::start method.
*/
-void MediaRTPpjmediaApp::start(const std::string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args)
+void MediaRTPpjmediaApp::start(const std::string& name, const Ice::CommunicatorPtr& communicator,
+ const Ice::StringSeq& args)
{
// we need a logger before we're ready to build the real communicator.
// use the one we're provided to create the IceLogger.
- mLoggerAdapter = communicator->createObjectAdapter(
- "MediaRTPpjmediaAdapterLogger");
+ mLoggerAdapter = communicator->createObjectAdapter("MediaRTPpjmediaAdapterLogger");
ConfiguredIceLoggerPtr iceLogger = createIceLogger(mLoggerAdapter);
getLoggerFactory().setLogOutput(iceLogger->getLogger());
mLoggerAdapter->activate();
@@ -388,7 +396,8 @@ void MediaRTPpjmediaApp::start(const std::string& name, const Ice::CommunicatorP
lg(Info) << "Activated pjmedia rtp component media service." << endl;
- ServiceLocatorManagementPrx management = ServiceLocatorManagementPrx::checkedCast(mCommunicator->propertyToProxy("ServiceLocatorManagementProxy"));
+ ServiceLocatorManagementPrx management =
+ ServiceLocatorManagementPrx::checkedCast(mCommunicator->propertyToProxy("ServiceLocatorManagementProxy"));
// The service locator is required for state replicator operation, so go ahead and find it
ServiceLocatorPrx locator = ServiceLocatorPrx::checkedCast(mCommunicator->propertyToProxy("LocatorService.Proxy"));
@@ -396,7 +405,8 @@ void MediaRTPpjmediaApp::start(const std::string& name, const Ice::CommunicatorP
// Look for the configured state replicator or default one
RtpStateReplicatorParamsPtr replicatorParams = new RtpStateReplicatorParams();
replicatorParams->category = StateReplicatorDiscoveryCategory;
- replicatorParams->mName = mCommunicator->getProperties()->getPropertyWithDefault("Sip.StateReplicatorName", "default");
+ replicatorParams->mName =
+ mCommunicator->getProperties()->getPropertyWithDefault("Sip.StateReplicatorName", "default");
try
{
@@ -408,12 +418,15 @@ void MediaRTPpjmediaApp::start(const std::string& name, const Ice::CommunicatorP
lg(Error) << "State replicator could not be found, operating without.";
}
- RTPMediaServiceImplPtr rtpmediaservice = new RTPMediaServiceImpl(mGlobalAdapter, mReplicaService, mStateReplicator);
+ RTPMediaServiceImplPtr rtpmediaservice =
+ new RTPMediaServiceImpl(mGlobalAdapter, mReplicaService, mStateReplicator);
if (mStateReplicator)
{
- mReplicatorListener = new RtpStateReplicatorListenerI(mGlobalAdapter, rtpmediaservice->getPoolFactory(), mGeneralState);
- mReplicatorListenerProxy = RtpStateReplicatorListenerPrx::uncheckedCast(mLocalAdapter->addWithUUID(mReplicatorListener));
+ mReplicatorListener =
+ new RtpStateReplicatorListenerI(mGlobalAdapter, rtpmediaservice->getPoolFactory(), mGeneralState);
+ mReplicatorListenerProxy =
+ RtpStateReplicatorListenerPrx::uncheckedCast(mLocalAdapter->addWithUUID(mReplicatorListener));
if (mCommunicator->getProperties()->getPropertyWithDefault("Rtp.StateReplicatorListener", "no") == "yes")
{
@@ -434,7 +447,8 @@ void MediaRTPpjmediaApp::start(const std::string& name, const Ice::CommunicatorP
if (mReplicaService->isActive() == true)
{
- mGeneralState->mServiceManagement = ServiceManagementPrx::uncheckedCast(management->addService(RTPMediaServiceProxy, "media_rtp_pjmedia"));
+ mGeneralState->mServiceManagement = ServiceManagementPrx::uncheckedCast(
+ management->addService(RTPMediaServiceProxy, "media_rtp_pjmedia"));
/* Now we can add some parameters to help find us. */
genericparams->category = "rtp";
mGeneralState->mServiceManagement->addLocatorParams(genericparams, "");
@@ -442,10 +456,12 @@ void MediaRTPpjmediaApp::start(const std::string& name, const Ice::CommunicatorP
/* One must provide a component service to manage us, if someone wants to */
ComponentServicePtr ComponentService = new ComponentServicepjmediaImpl(*this, mGeneralState);
- ComponentServicePrx ComponentServiceProxy = ComponentServicePrx::uncheckedCast(mLocalAdapter->addWithUUID(ComponentService));
+ ComponentServicePrx ComponentServiceProxy =
+ ComponentServicePrx::uncheckedCast(mLocalAdapter->addWithUUID(ComponentService));
/* Let's add the component service to the service locator first */
- mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(management->addService(ComponentServiceProxy, "media_rtp_pjmedia"));
+ mComponentServiceManagement =
+ ServiceManagementPrx::uncheckedCast(management->addService(ComponentServiceProxy, "media_rtp_pjmedia"));
genericparams->category = "Component/media_rtp_pjmedia";
mComponentServiceManagement->addLocatorParams(genericparams, "");
diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index 5e7f33e..d4e0381 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -54,8 +54,12 @@ using namespace AsteriskSCF::SmartProxy;
class RTPSessionImplPriv
{
public:
- RTPSessionImplPriv(Ice::ObjectAdapterPtr adapter, const FormatSeq& formats, ReplicaPtr replicaService, AsteriskSCF::SmartProxy::SmartProxy<RtpStateReplicatorPrx> stateReplicator) :
- mAdapter(adapter), mFormats(formats), mSessionStateItem(new RtpSessionStateItem()), mReplicaService(replicaService), mStateReplicator(stateReplicator) { };
+ RTPSessionImplPriv(const Ice::ObjectAdapterPtr& adapter, const FormatSeq& formats,
+ const ReplicaPtr& replicaService,
+ const AsteriskSCF::SmartProxy::SmartProxy<RtpStateReplicatorPrx>& stateReplicator) :
+ mAdapter(adapter), mFormats(formats),
+ mSessionStateItem(new RtpSessionStateItem()),
+ mReplicaService(replicaService), mStateReplicator(stateReplicator) { };
~RTPSessionImplPriv();
/**
@@ -127,7 +131,9 @@ public:
/**
* Constructor for the RTPSessionImpl class (used by Ice).
*/
-RTPSessionImpl::RTPSessionImpl(Ice::ObjectAdapterPtr adapter, const FormatSeq& formats, pj_pool_factory* factory, ReplicaPtr replicaService, AsteriskSCF::SmartProxy::SmartProxy<RtpStateReplicatorPrx> stateReplicator) :
+RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter, const FormatSeq& formats,
+ pj_pool_factory* factory, const ReplicaPtr& replicaService,
+ const AsteriskSCF::SmartProxy::SmartProxy<RtpStateReplicatorPrx>& stateReplicator) :
mImpl(new RTPSessionImplPriv(adapter, formats, replicaService, stateReplicator))
{
/* Add ourselves to the ICE ASM so we can be used. */
@@ -144,7 +150,8 @@ RTPSessionImpl::RTPSessionImpl(Ice::ObjectAdapterPtr adapter, const FormatSeq& f
/* Now create some transport we can use to actually send or receive the media. */
for (int port = DEFAULT_RTP_PORT_MINIMUM; port < DEFAULT_RTP_PORT_MAXIMUM; port += 2)
{
- if ((status = pjmedia_transport_udp_create2(mImpl->mEndpoint, "RTP", NULL, port, 0, &mImpl->mTransport)) == PJ_SUCCESS)
+ if ((status = pjmedia_transport_udp_create2(mImpl->mEndpoint, "RTP", NULL, port, 0, &mImpl->mTransport)) ==
+ PJ_SUCCESS)
{
mImpl->mSessionStateItem->mPort = port;
break;
@@ -173,8 +180,10 @@ RTPSessionImpl::RTPSessionImpl(Ice::ObjectAdapterPtr adapter, const FormatSeq& f
/**
* Constructor for the RTPSessionImpl class (used by state replicator).
*/
-RTPSessionImpl::RTPSessionImpl(Ice::ObjectAdapterPtr adapter, pj_pool_factory* factory, Ice::Identity sessionIdentity, Ice::Identity sinkIdentity,
- Ice::Identity sourceIdentity, Ice::Int port, const FormatSeq& formats) : mImpl(new RTPSessionImplPriv(adapter, formats, 0, *(new AsteriskSCF::SmartProxy::SmartProxy<RtpStateReplicatorPrx>)))
+RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter, pj_pool_factory* factory,
+ const Ice::Identity& sessionIdentity, const Ice::Identity& sinkIdentity, const Ice::Identity& sourceIdentity,
+ Ice::Int port, const FormatSeq& formats) :
+ mImpl(new RTPSessionImplPriv(adapter, formats, 0, *(new AsteriskSCF::SmartProxy::SmartProxy<RtpStateReplicatorPrx>)))
{
mImpl->mProxy = RTPSessionPrx::uncheckedCast(adapter->add(this, sessionIdentity));
@@ -185,13 +194,15 @@ RTPSessionImpl::RTPSessionImpl(Ice::ObjectAdapterPtr adapter, pj_pool_factory* f
/* TODO: This is bad... we can't go on! */
}
- if ((status = pjmedia_transport_udp_create2(mImpl->mEndpoint, "RTP", NULL, port, 0, &mImpl->mTransport)) != PJ_SUCCESS)
+ if ((status = pjmedia_transport_udp_create2(mImpl->mEndpoint, "RTP", NULL, port, 0, &mImpl->mTransport))
+ != PJ_SUCCESS)
{
// TODO: This is also bad, something is using the port */
}
mImpl->mStreamSource = new StreamSourceRTPImpl(this, "");
- mImpl->mStreamSourceProxy = StreamSourceRTPPrx::uncheckedCast(mImpl->mAdapter->add(mImpl->mStreamSource, sourceIdentity));
+ mImpl->mStreamSourceProxy =
+ StreamSourceRTPPrx::uncheckedCast(mImpl->mAdapter->add(mImpl->mStreamSource, sourceIdentity));
mImpl->mStreamSink = new StreamSinkRTPImpl(this, "");
mImpl->mStreamSinkProxy = StreamSinkRTPPrx::uncheckedCast(mImpl->mAdapter->add(mImpl->mStreamSink, sinkIdentity));
@@ -331,7 +342,7 @@ FormatSeq RTPSessionImpl::getFormats()
/**
* API call which calls into RTPSourceImpl in order to setup transport.
*/
-void RTPSessionImpl::setRemoteDetails(std::string address, int port)
+void RTPSessionImpl::setRemoteDetails(const string& address, int port)
{
mImpl->mStreamSource->setRemoteDetails(address, port);
}
@@ -389,7 +400,8 @@ StreamSinkRTPPtr RTPSessionImpl::getSink()
/**
* API call which replicates state items.
*/
-void RTPSessionImpl::replicateState(RtpSessionStateItemPtr session, RtpStreamSinkStateItemPtr sink, RtpStreamSourceStateItemPtr source)
+void RTPSessionImpl::replicateState(const RtpSessionStateItemPtr& session, const RtpStreamSinkStateItemPtr& sink,
+ const RtpStreamSourceStateItemPtr& source)
{
// If state replication has been disabled do nothing
if (!mImpl->mStateReplicator || mImpl->mReplicaService->isActive() == false)
@@ -432,7 +444,8 @@ void RTPSessionImpl::replicateState(RtpSessionStateItemPtr session, RtpStreamSin
/**
* API call which removes state items from the replicator.
*/
-void RTPSessionImpl::removeState(RtpSessionStateItemPtr session, RtpStreamSinkStateItemPtr sink, RtpStreamSourceStateItemPtr source)
+void RTPSessionImpl::removeState(const RtpSessionStateItemPtr& session, const RtpStreamSinkStateItemPtr& sink,
+ const RtpStreamSourceStateItemPtr& source)
{
// If state replication has been disabled do nothing
if (!mImpl->mStateReplicator || mImpl->mReplicaService->isActive() == false)
diff --git a/src/RTPSession.h b/src/RTPSession.h
index a76b610..4929906 100644
--- a/src/RTPSession.h
+++ b/src/RTPSession.h
@@ -41,9 +41,11 @@ typedef IceUtil::Handle<StreamSourceRTPImpl> StreamSourceRTPImplPtr;
class RTPSessionImpl : public AsteriskSCF::Media::RTP::V1::RTPSession
{
public:
- RTPSessionImpl(Ice::ObjectAdapterPtr, const AsteriskSCF::Media::V1::FormatSeq&, pj_pool_factory*, AsteriskSCF::System::Component::V1::ReplicaPtr,
- AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::Media::RTP::V1::RtpStateReplicatorPrx>);
- RTPSessionImpl(Ice::ObjectAdapterPtr, pj_pool_factory*, Ice::Identity, Ice::Identity, Ice::Identity, Ice::Int, const AsteriskSCF::Media::V1::FormatSeq&);
+ RTPSessionImpl(const Ice::ObjectAdapterPtr&, const AsteriskSCF::Media::V1::FormatSeq&,
+ pj_pool_factory*, const AsteriskSCF::System::Component::V1::ReplicaPtr&,
+ const AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::Media::RTP::V1::RtpStateReplicatorPrx>&);
+ RTPSessionImpl(const Ice::ObjectAdapterPtr&, pj_pool_factory*, const Ice::Identity&, const Ice::Identity&,
+ const Ice::Identity&, Ice::Int, const AsteriskSCF::Media::V1::FormatSeq&);
AsteriskSCF::Media::V1::StreamSourceSeq getSources(const Ice::Current&);
AsteriskSCF::Media::V1::StreamSinkSeq getSinks(const Ice::Current&);
std::string getId(const Ice::Current&);
@@ -54,13 +56,17 @@ public:
pjmedia_transport* getTransport();
AsteriskSCF::Media::V1::FormatSeq getFormats();
void associatePayloads(const AsteriskSCF::Media::RTP::V1::PayloadMap&, const Ice::Current&);
- void setRemoteDetails(std::string address, int port);
+ void setRemoteDetails(const std::string& address, int port);
AsteriskSCF::Media::V1::FormatPtr getFormat(int payload);
int getPayload(const AsteriskSCF::Media::V1::FormatPtr& mediaformat);
StreamSourceRTPImplPtr getSource();
AsteriskSCF::Media::RTP::V1::StreamSinkRTPPtr getSink();
- void replicateState(AsteriskSCF::Media::RTP::V1::RtpSessionStateItemPtr, AsteriskSCF::Media::RTP::V1::RtpStreamSinkStateItemPtr, AsteriskSCF::Media::RTP::V1::RtpStreamSourceStateItemPtr);
- void removeState(AsteriskSCF::Media::RTP::V1::RtpSessionStateItemPtr, AsteriskSCF::Media::RTP::V1::RtpStreamSinkStateItemPtr, AsteriskSCF::Media::RTP::V1::RtpStreamSourceStateItemPtr);
+ void replicateState(const AsteriskSCF::Media::RTP::V1::RtpSessionStateItemPtr&,
+ const AsteriskSCF::Media::RTP::V1::RtpStreamSinkStateItemPtr&,
+ const AsteriskSCF::Media::RTP::V1::RtpStreamSourceStateItemPtr&);
+ void removeState(const AsteriskSCF::Media::RTP::V1::RtpSessionStateItemPtr&,
+ const AsteriskSCF::Media::RTP::V1::RtpStreamSinkStateItemPtr&,
+ const AsteriskSCF::Media::RTP::V1::RtpStreamSourceStateItemPtr&);
private:
/**
* Private implementation data for RTPSessionImpl.
diff --git a/src/RTPSink.cpp b/src/RTPSink.cpp
index e20f86d..2324799 100644
--- a/src/RTPSink.cpp
+++ b/src/RTPSink.cpp
@@ -44,7 +44,7 @@ public:
/**
* Constructor for our StreamSinkRTPImplPriv class.
*/
- StreamSinkRTPImplPriv(RTPSessionImplPtr, std::string);
+ StreamSinkRTPImplPriv(const RTPSessionImplPtr&, const std::string&);
/**
* A structure containing outgoing pjmedia session data.
@@ -65,7 +65,8 @@ public:
/**
* Constructor for the StreamSinkRTPImplPriv class.
*/
-StreamSinkRTPImplPriv::StreamSinkRTPImplPriv(RTPSessionImplPtr session, std::string sessionId) : mSession(session), mSinkStateItem(new RtpStreamSinkStateItem())
+StreamSinkRTPImplPriv::StreamSinkRTPImplPriv(const RTPSessionImplPtr& session, const string& sessionId) :
+ mSession(session), mSinkStateItem(new RtpStreamSinkStateItem)
{
pjmedia_rtp_session_init(&mOutgoingSession, 0, pj_rand());
mSinkStateItem->mSessionId = sessionId;
@@ -76,7 +77,8 @@ StreamSinkRTPImplPriv::StreamSinkRTPImplPriv(RTPSessionImplPtr session, std::str
/**
* Constructor for the StreamSinkRTPImpl class.
*/
-StreamSinkRTPImpl::StreamSinkRTPImpl(RTPSessionImplPtr session, std::string sessionId) : mImpl(new StreamSinkRTPImplPriv(session, sessionId))
+StreamSinkRTPImpl::StreamSinkRTPImpl(const RTPSessionImplPtr& session, const string& sessionId) :
+ mImpl(new StreamSinkRTPImplPriv(session, sessionId))
{
}
@@ -112,7 +114,8 @@ void StreamSinkRTPImpl::write(const AsteriskSCF::Media::V1::FrameSeq& frames, co
}
/* Using the available information construct an RTP header that we can place at the front of our packet */
- pj_status_t status = pjmedia_rtp_encode_rtp(&mImpl->mOutgoingSession, mImpl->mSession->getPayload((*frame)->mediaformat), 0, (*frame)->payload.size(),
+ pj_status_t status = pjmedia_rtp_encode_rtp(&mImpl->mOutgoingSession,
+ mImpl->mSession->getPayload((*frame)->mediaformat), 0, (*frame)->payload.size(),
(*frame)->payload.size(), &header, &header_len);
if (status != PJ_SUCCESS)
@@ -131,7 +134,8 @@ void StreamSinkRTPImpl::write(const AsteriskSCF::Media::V1::FrameSeq& frames, co
pj_memcpy(packet + header_len, &(*frame)->payload[0], (*frame)->payload.size());
/* All done, transmission can now occur */
- status = pjmedia_transport_send_rtp(mImpl->mSession->getTransport(), packet, (*frame)->payload.size() + header_len);
+ status = pjmedia_transport_send_rtp(mImpl->mSession->getTransport(), packet,
+ (*frame)->payload.size() + header_len);
if (status != PJ_SUCCESS)
{
@@ -179,7 +183,7 @@ std::string StreamSinkRTPImpl::getId(const Ice::Current& current)
/**
* Implementation of the setRemoteDetails method as defined in MediaRTPIf.ice
*/
-void StreamSinkRTPImpl::setRemoteDetails(const std::string& address, Ice::Int port, const Ice::Current&)
+void StreamSinkRTPImpl::setRemoteDetails(const string& address, Ice::Int port, const Ice::Current&)
{
/* This method is essentially a passthru to the RTPSourceImpl. It takes care of
* actually attaching the transport.
diff --git a/src/RTPSink.h b/src/RTPSink.h
index a350d18..6254d5a 100644
--- a/src/RTPSink.h
+++ b/src/RTPSink.h
@@ -21,7 +21,7 @@ class StreamSinkRTPImplPriv;
class StreamSinkRTPImpl : public AsteriskSCF::Media::RTP::V1::StreamSinkRTP
{
public:
- StreamSinkRTPImpl(RTPSessionImplPtr, std::string);
+ StreamSinkRTPImpl(const RTPSessionImplPtr&, const std::string&);
void write(const AsteriskSCF::Media::V1::FrameSeq&, const Ice::Current&);
void setSource(const AsteriskSCF::Media::V1::StreamSourcePrx&, const Ice::Current&);
AsteriskSCF::Media::V1::StreamSourcePrx getSource(const Ice::Current&);
diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index 39c52e2..7e0450b 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -51,7 +51,7 @@ public:
/**
* Constructor for our StreamSourceRTPImplPriv class.
*/
- StreamSourceRTPImplPriv(RTPSessionImplPtr, std::string);
+ StreamSourceRTPImplPriv(const RTPSessionImplPtr&, const string&);
/**
* A structure containing incoming pjmedia session data.
@@ -72,7 +72,8 @@ public:
/**
* Constructor for the StreamSourceRTPImplPriv class.
*/
-StreamSourceRTPImplPriv::StreamSourceRTPImplPriv(RTPSessionImplPtr session, std::string sessionId) : mSession(session), mSourceStateItem(new RtpStreamSourceStateItem())
+StreamSourceRTPImplPriv::StreamSourceRTPImplPriv(const RTPSessionImplPtr& session, const string& sessionId) :
+ mSession(session), mSourceStateItem(new RtpStreamSourceStateItem)
{
pjmedia_rtp_session_init(&mIncomingSession, 0, 0);
mSourceStateItem->mSessionId = sessionId;
@@ -82,7 +83,8 @@ StreamSourceRTPImplPriv::StreamSourceRTPImplPriv(RTPSessionImplPtr session, std:
/**
* Constructor for the StreamSourceRTPImpl class.
*/
-StreamSourceRTPImpl::StreamSourceRTPImpl(RTPSessionImplPtr session, std::string sessionId) : mImpl(new StreamSourceRTPImplPriv(session, sessionId))
+StreamSourceRTPImpl::StreamSourceRTPImpl(const RTPSessionImplPtr& session, const string& sessionId) :
+ mImpl(new StreamSourceRTPImplPriv(session, sessionId))
{
}
@@ -174,7 +176,8 @@ static void receiveRTP(void *userdata, void *packet, pj_ssize_t size)
Ice::Byte* payload;
unsigned int payload_size;
- pj_status_t status = pjmedia_rtp_decode_rtp(&source->mImpl->mIncomingSession, packet, size, &header, (const void**)&payload, &payload_size);
+ pj_status_t status = pjmedia_rtp_decode_rtp(&source->mImpl->mIncomingSession, packet, size, &header,
+ (const void**)&payload, &payload_size);
if (status != PJ_SUCCESS)
{
@@ -219,7 +222,7 @@ static void receiveRTP(void *userdata, void *packet, pj_ssize_t size)
/**
* API call which sets up our pjmedia transport and allows media to be sent and received.
*/
-void StreamSourceRTPImpl::setRemoteDetails(std::string address, int port)
+void StreamSourceRTPImpl::setRemoteDetails(const string& address, int port)
{
pj_sockaddr_in sin;
diff --git a/src/RTPSource.h b/src/RTPSource.h
index c6d9d4a..d7373e7 100644
--- a/src/RTPSource.h
+++ b/src/RTPSource.h
@@ -21,7 +21,7 @@ class StreamSourceRTPImplPriv;
class StreamSourceRTPImpl : public AsteriskSCF::Media::RTP::V1::StreamSourceRTP
{
public:
- StreamSourceRTPImpl(RTPSessionImplPtr, std::string);
+ StreamSourceRTPImpl(const RTPSessionImplPtr&, const std::string&);
void setSink(const AsteriskSCF::Media::V1::StreamSinkPrx&, const Ice::Current&);
AsteriskSCF::Media::V1::StreamSinkPrx getSink(const Ice::Current&);
AsteriskSCF::Media::V1::FormatSeq getFormats(const Ice::Current&);
@@ -29,7 +29,7 @@ public:
void requestFormat(const AsteriskSCF::Media::V1::FormatPtr&, const Ice::Current&);
std::string getLocalAddress(const Ice::Current&);
Ice::Int getLocalPort(const Ice::Current&);
- void setRemoteDetails(std::string address, int port);
+ void setRemoteDetails(const std::string& address, int port);
AsteriskSCF::Media::RTP::V1::RtpStreamSourceStateItemPtr getStateItem();
/**
diff --git a/src/RtpStateReplicator.h b/src/RtpStateReplicator.h
index 34dc017..b2db101 100644
--- a/src/RtpStateReplicator.h
+++ b/src/RtpStateReplicator.h
@@ -24,17 +24,18 @@
using namespace AsteriskSCF::Media::RTP::V1;
-typedef AsteriskSCF::StateReplication::StateReplicator<RtpStateReplicator, RtpStateItemPtr, std::string, RtpStateReplicatorListenerPrx> RtpStateReplicatorI;
+typedef AsteriskSCF::StateReplication::StateReplicator<RtpStateReplicator, RtpStateItemPtr, std::string,
+ RtpStateReplicatorListenerPrx> RtpStateReplicatorI;
typedef IceUtil::Handle<RtpStateReplicatorI> RtpStateReplicatorIPtr;
class RtpStateReplicatorListenerI : public RtpStateReplicatorListener
{
public:
- RtpStateReplicatorListenerI(Ice::ObjectAdapterPtr, pj_pool_factory*, RtpGeneralStateItemPtr);
+ RtpStateReplicatorListenerI(const Ice::ObjectAdapterPtr&, pj_pool_factory*, const RtpGeneralStateItemPtr&);
~RtpStateReplicatorListenerI();
void stateRemoved(const Ice::StringSeq&, const Ice::Current&);
void stateSet(const RtpStateItemSeq&, const Ice::Current&);
- bool operator==(RtpStateReplicatorListenerI &rhs);
+ bool operator==(const RtpStateReplicatorListenerI &rhs);
private:
struct RtpStateReplicatorListenerImpl *mImpl;
};
diff --git a/src/RtpStateReplicatorApp.cpp b/src/RtpStateReplicatorApp.cpp
index 6fa76d9..91c0e37 100644
--- a/src/RtpStateReplicatorApp.cpp
+++ b/src/RtpStateReplicatorApp.cpp
@@ -53,7 +53,7 @@ public:
virtual void start(const string &name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq& args);
virtual void stop();
private:
- void initialize(std::string appName, const Ice::CommunicatorPtr& ic);
+ void initialize(const string& appName, const Ice::CommunicatorPtr& ic);
void registerWithServiceLocator(const Ice::CommunicatorPtr& ic);
void deregisterFromServiceLocator();
std::string mAppName;
@@ -101,7 +101,7 @@ private:
class RtpStateReplicatorCompare : public ServiceLocatorParamsCompare
{
public:
- RtpStateReplicatorCompare(string name) : mName(name) {}
+ RtpStateReplicatorCompare(const string& name) : mName(name) {}
bool isSupported(const ServiceLocatorParamsPtr ¶ms, const Ice::Current &)
{
RtpStateReplicatorParamsPtr sipParams = RtpStateReplicatorParamsPtr::dynamicCast(params);
@@ -126,11 +126,13 @@ void RtpStateReplicatorService::registerWithServiceLocator(const Ice::Communicat
try
{
// Get a proxy to the management interface for the Service Locator, so we can add ourselves into the system discovery mechanisms.
- mServiceLocatorManagement = ServiceLocatorManagementPrx::checkedCast(ic->propertyToProxy("LocatorServiceManagement.Proxy"));
+ mServiceLocatorManagement =
+ ServiceLocatorManagementPrx::checkedCast(ic->propertyToProxy("LocatorServiceManagement.Proxy"));
if (mServiceLocatorManagement == 0)
{
- lg(Error) << "Unable to obtain proxy to ServiceLocatorManagement interface. Check config file. This component can't be found until this is corrected." << endl;
+ lg(Error) << "Unable to obtain proxy to ServiceLocatorManagement interface. Check config file. "
+ "This component can't be found until this is corrected.";
return;
}
@@ -140,7 +142,8 @@ void RtpStateReplicatorService::registerWithServiceLocator(const Ice::Communicat
// The GUID passed in to add service needs to be unique for reporting.
string componentServiceGuid(AsteriskSCF::Media::RTP::V1::StateReplicatorComponentCategory);
- mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(componentServicePrx, componentServiceGuid));
+ mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(
+ mServiceLocatorManagement->addService(componentServicePrx, componentServiceGuid));
// Add category as a parameter to enable other components look this component up.
ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
@@ -152,14 +155,16 @@ void RtpStateReplicatorService::registerWithServiceLocator(const Ice::Communicat
RtpStateReplicatorPrx stateReplicatorPrx = RtpStateReplicatorPrx::checkedCast(stateReplicatorObjectPrx);
string stateReplicationGuid(AsteriskSCF::Media::RTP::V1::StateReplicatorDiscoveryCategory);
- mStateReplicationManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(stateReplicatorPrx, stateReplicationGuid));
+ mStateReplicationManagement = ServiceManagementPrx::uncheckedCast(
+ mServiceLocatorManagement->addService(stateReplicatorPrx, stateReplicationGuid));
- ServiceLocatorParamsPtr discoveryParams = new ServiceLocatorParams();
+ ServiceLocatorParamsPtr discoveryParams = new ServiceLocatorParams;
discoveryParams->category = AsteriskSCF::Media::RTP::V1::StateReplicatorDiscoveryCategory;
string replicatorName = ic->getProperties()->getPropertyWithDefault("RtpStateReplicator.Name", "default");
RtpStateReplicatorCompare* nameCompare = new RtpStateReplicatorCompare(replicatorName);
- ServiceLocatorParamsComparePrx compareProxy = ServiceLocatorParamsComparePrx::uncheckedCast(mAdapter->addWithUUID(nameCompare));
+ ServiceLocatorParamsComparePrx compareProxy = ServiceLocatorParamsComparePrx::uncheckedCast(
+ mAdapter->addWithUUID(nameCompare));
string compareGuid = IceUtil::generateUUID();
mServiceLocatorManagement->addCompare(compareGuid, compareProxy);
@@ -169,7 +174,7 @@ void RtpStateReplicatorService::registerWithServiceLocator(const Ice::Communicat
}
catch(...)
{
- lg(Error) << "Exception in " << mAppName << " registerWithServiceLocator()" << endl;
+ lg(Error) << "Exception in " << mAppName << " registerWithServiceLocator()";
}
}
@@ -186,11 +191,11 @@ void RtpStateReplicatorService::deregisterFromServiceLocator()
}
catch(...)
{
- lg(Error) << "Had trouble in deregisterFromServiceLocator()." << endl;
+ lg(Error) << "Had trouble in deregisterFromServiceLocator().";
}
}
-void RtpStateReplicatorService::initialize(const std::string appName, const Ice::CommunicatorPtr& ic)
+void RtpStateReplicatorService::initialize(const string& appName, const Ice::CommunicatorPtr& ic)
{
mAdapter = ic->createObjectAdapter("RtpStateReplicator");
diff --git a/src/RtpStateReplicatorListener.cpp b/src/RtpStateReplicatorListener.cpp
index cc00a2a..b47f408 100644
--- a/src/RtpStateReplicatorListener.cpp
+++ b/src/RtpStateReplicatorListener.cpp
@@ -56,8 +56,10 @@ private:
struct RtpStateReplicatorListenerImpl
{
public:
- RtpStateReplicatorListenerImpl(Ice::ObjectAdapterPtr adapter, pj_pool_factory *poolFactory, RtpGeneralStateItemPtr generalState)
+ RtpStateReplicatorListenerImpl(const Ice::ObjectAdapterPtr& adapter, pj_pool_factory *poolFactory,
+ const RtpGeneralStateItemPtr& generalState)
: mId(IceUtil::generateUUID()), mAdapter(adapter), mPoolFactory(poolFactory), mGeneralState(generalState) {}
+
void removeStateNoticeImpl(const Ice::StringSeq& itemKeys)
{
for (Ice::StringSeq::const_iterator key = itemKeys.begin(); key != itemKeys.end(); ++key)
@@ -71,7 +73,7 @@ public:
class visitor : public AsteriskSCF::Media::RTP::V1::RtpStateItemVisitor
{
public:
- visitor(RtpStateReplicatorListenerImpl *impl) : impl(impl)
+ visitor(RtpStateReplicatorListenerImpl *impl) : impl(impl)
{
}
@@ -94,8 +96,9 @@ public:
localitem = newitem;
impl->mStateItems.insert(make_pair(item->mSessionId, newitem));
- RTPSessionImplPtr localSession = new RTPSessionImpl(impl->mAdapter, impl->mPoolFactory, item->mSessionIdentity, item->mSinkIdentity,
- item->mSourceIdentity, item->mPort, item->mFormats);
+ RTPSessionImplPtr localSession =
+ new RTPSessionImpl(impl->mAdapter, impl->mPoolFactory, item->mSessionIdentity,
+ item->mSinkIdentity, item->mSourceIdentity, item->mPort, item->mFormats);
localitem->setSession(localSession);
}
else
@@ -108,17 +111,20 @@ public:
void visitStreamSink(const RtpStreamSinkStateItemPtr &item, const Ice::Current &)
{
- map<string, boost::shared_ptr<RtpStateReplicatorItem> >::iterator i = impl->mStateItems.find(item->mSessionId);
+ map<string, boost::shared_ptr<RtpStateReplicatorItem> >::iterator i =
+ impl->mStateItems.find(item->mSessionId);
if (i != impl->mStateItems.end())
{
i->second->getSession()->getSink()->setSource(item->mSource, Ice::Current());
- i->second->getSession()->getSink()->setRemoteDetails(item->mRemoteAddress, item->mRemotePort, Ice::Current());
+ i->second->getSession()->getSink()->setRemoteDetails(item->mRemoteAddress, item->mRemotePort,
+ Ice::Current());
}
}
void visitStreamSource(const RtpStreamSourceStateItemPtr &item, const Ice::Current &)
{
- map<string, boost::shared_ptr<RtpStateReplicatorItem> >::iterator i = impl->mStateItems.find(item->mSessionId);
+ map<string, boost::shared_ptr<RtpStateReplicatorItem> >::iterator i =
+ impl->mStateItems.find(item->mSessionId);
if (i != impl->mStateItems.end())
{
i->second->getSession()->getSource()->setSink(item->mSink, Ice::Current());
@@ -141,7 +147,8 @@ public:
RtpGeneralStateItemPtr mGeneralState;
};
-RtpStateReplicatorListenerI::RtpStateReplicatorListenerI(Ice::ObjectAdapterPtr adapter, pj_pool_factory *poolFactory, RtpGeneralStateItemPtr generalState)
+RtpStateReplicatorListenerI::RtpStateReplicatorListenerI(const Ice::ObjectAdapterPtr& adapter,
+ pj_pool_factory *poolFactory, const RtpGeneralStateItemPtr& generalState)
: mImpl(new RtpStateReplicatorListenerImpl(adapter, poolFactory, generalState)) {}
RtpStateReplicatorListenerI::~RtpStateReplicatorListenerI()
@@ -159,7 +166,7 @@ void RtpStateReplicatorListenerI::stateSet(const RtpStateItemSeq& items, const I
mImpl->setStateNoticeImpl(items);
}
-bool RtpStateReplicatorListenerI::operator==(RtpStateReplicatorListenerI &rhs)
+bool RtpStateReplicatorListenerI::operator==(const RtpStateReplicatorListenerI &rhs)
{
return mImpl->mId == rhs.mImpl->mId;
}
commit b87be842f83fc697fdc7e7c7d2775f2607af7ce6
Author: Joshua Colp <jcolp at digium.com>
Date: Wed Mar 2 15:56:46 2011 -0400
Visitors must be allocated on the heap and not the stack to ensure Ice object reference counting works properly.
diff --git a/src/RtpStateReplicatorListener.cpp b/src/RtpStateReplicatorListener.cpp
index fb0061e..cc00a2a 100644
--- a/src/RtpStateReplicatorListener.cpp
+++ b/src/RtpStateReplicatorListener.cpp
@@ -124,11 +124,13 @@ public:
i->second->getSession()->getSource()->setSink(item->mSink, Ice::Current());
}
}
- } v(this);
+ };
+
+ AsteriskSCF::Media::RTP::V1::RtpStateItemVisitorPtr v = new visitor(this);
for (RtpStateItemSeq::const_iterator item = items.begin(); item != items.end(); ++item)
{
- (*item)->visit(&v);
+ (*item)->visit(v);
}
}
diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index 3b7cb2a..f03cb72 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -178,11 +178,13 @@ void TestRtpReplicatorListener::stateSet(const RtpStateItemSeq& items, const Ice
boost::mutex::scoped_lock lock(Testbed.mLock);
Testbed.mCondition.notify_one();
}
- } v(this);
+ };
+
+ AsteriskSCF::Media::RTP::V1::RtpStateItemVisitorPtr v = new visitor(this);
for (RtpStateItemSeq::const_iterator item = items.begin(); item != items.end(); ++item)
{
- (*item)->visit(&v);
+ (*item)->visit(v);
}
}
commit 13bea3f9271b2ecbe159b74cc0d8295819a6fd0b
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Fri Feb 18 16:32:05 2011 -0600
Use a relative class name for the class that visits RtpStateItem objects.
diff --git a/local-slice/RtpStateReplicationIf.ice b/local-slice/RtpStateReplicationIf.ice
index 7bc5531..46a5014 100644
--- a/local-slice/RtpStateReplicationIf.ice
+++ b/local-slice/RtpStateReplicationIf.ice
@@ -47,7 +47,7 @@ module V1
{
};
- ["visitor:::AsteriskSCF::Media::RTP::V1::RtpStateItemVisitor"] class RtpStateItem
+ ["visitor:RtpStateItemVisitor"] class RtpStateItem
{
string key;
string mSessionId;
commit f604c99c60525eae4bf71f1a7f722bb8d2e51ac6
Author: Joshua Colp <jcolp at digium.com>
Date: Fri Feb 4 08:18:14 2011 -0400
Fix build regression on some platforms.
diff --git a/src/RtpStateReplicatorListener.cpp b/src/RtpStateReplicatorListener.cpp
index 35f490d..fb0061e 100644
--- a/src/RtpStateReplicatorListener.cpp
+++ b/src/RtpStateReplicatorListener.cpp
@@ -92,7 +92,7 @@ public:
{
boost::shared_ptr<RtpStateReplicatorItem> newitem(new RtpStateReplicatorItem());
localitem = newitem;
- impl->mStateItems.insert(make_pair<string, boost::shared_ptr<RtpStateReplicatorItem> >(item->mSessionId, newitem));
+ impl->mStateItems.insert(make_pair(item->mSessionId, newitem));
RTPSessionImplPtr localSession = new RTPSessionImpl(impl->mAdapter, impl->mPoolFactory, item->mSessionIdentity, item->mSinkIdentity,
item->mSourceIdentity, item->mPort, item->mFormats);
commit 5a66fe64bbaf6449dad3c5966275c4e3b58c2c1c
Author: Joshua Colp <jcolp at digium.com>
Date: Fri Feb 4 07:52:56 2011 -0400
Add missing visitor code in the listener.
diff --git a/src/RtpStateReplicatorListener.cpp b/src/RtpStateReplicatorListener.cpp
index d7b0f8d..35f490d 100644
--- a/src/RtpStateReplicatorListener.cpp
+++ b/src/RtpStateReplicatorListener.cpp
@@ -30,6 +30,7 @@
#include "RTPSink.h"
#include "RTPSource.h"
+using namespace std;
using namespace AsteriskSCF::Media::RTP::V1;
class RtpStateReplicatorItem
@@ -67,29 +68,34 @@ public:
}
void setStateNoticeImpl(const RtpStateItemSeq& items)
{
- for (RtpStateItemSeq::const_iterator item = items.begin(); item != items.end(); ++item)
- {
- std::map<std::string, boost::shared_ptr<RtpStateReplicatorItem> >::iterator i = mStateItems.find((*item)->mSessionId);
- RtpGeneralStateItemPtr general;
- RtpSessionStateItemPtr session;
- RtpStreamSinkStateItemPtr sink;
- RtpStreamSourceStateItemPtr source;
- boost::shared_ptr<RtpStateReplicatorItem> localitem;
-
- if ((general = RtpGeneralStateItemPtr::dynamicCast((*item))))
+ class visitor : public AsteriskSCF::Media::RTP::V1::RtpStateItemVisitor
+ {
+ public:
+ visitor(RtpStateReplicatorListenerImpl *impl) : impl(impl)
{
- mGeneralState->mServiceManagement = general->mServiceManagement;
}
- else if ((session = RtpSessionStateItemPtr::dynamicCast((*item))))
+
+ private:
+ RtpStateReplicatorListenerImpl *impl;
+
+ void visitGeneral(const RtpGeneralStateItemPtr &item, const Ice::Current &)
{
- if (i == mStateItems.end())
+ impl->mGeneralState->mServiceManagement = item->mServiceManagement;
+ }
+
+ void visitSession(const RtpSessionStateItemPtr &item, const Ice::Current &)
+ {
+ map<string, boost::shared_ptr<RtpStateReplicatorItem> >::iterator i = impl->mStateItems.find(item->mSessionId);
+ boost::shared_ptr<RtpStateReplicatorItem> localitem;
+
+ if (i == impl->mStateItems.end())
{
boost::shared_ptr<RtpStateReplicatorItem> newitem(new RtpStateReplicatorItem());
localitem = newitem;
- mStateItems.insert(std::make_pair((*item)->mSessionId, newitem));
+ impl->mStateItems.insert(make_pair<string, boost::shared_ptr<RtpStateReplicatorItem> >(item->mSessionId, newitem));
- RTPSessionImplPtr localSession = new RTPSessionImpl(mAdapter, mPoolFactory, session->mSessionIdentity, session->mSinkIdentity,
- session->mSourceIdentity, session->mPort, session->mFormats);
+ RTPSessionImplPtr localSession = new RTPSessionImpl(impl->mAdapter, impl->mPoolFactory, item->mSessionIdentity, item->mSinkIdentity,
+ item->mSourceIdentity, item->mPort, item->mFormats);
localitem->setSession(localSession);
}
else
@@ -97,31 +103,37 @@ public:
localitem = i->second;
}
- localitem->getSession()->associatePayloads(session->mPayloadstoFormats, Ice::Current());
+ localitem->getSession()->associatePayloads(item->mPayloadstoFormats, Ice::Current());
}
- else if ((sink = RtpStreamSinkStateItemPtr::dynamicCast((*item))))
+
+ void visitStreamSink(const RtpStreamSinkStateItemPtr &item, const Ice::Current &)
{
- if (i == mStateItems.end())
+ map<string, boost::shared_ptr<RtpStateReplicatorItem> >::iterator i = impl->mStateItems.find(item->mSessionId);
+ if (i != impl->mStateItems.end())
{
- continue;
+ i->second->getSession()->getSink()->setSource(item->mSource, Ice::Current());
+ i->second->getSession()->getSink()->setRemoteDetails(item->mRemoteAddress, item->mRemotePort, Ice::Current());
}
-
- i->second->getSession()->getSink()->setSource(sink->mSource, Ice::Current());
- i->second->getSession()->getSink()->setRemoteDetails(sink->mRemoteAddress, sink->mRemotePort, Ice::Current());
}
- else if ((source = RtpStreamSourceStateItemPtr::dynamicCast((*item))))
+
+ void visitStreamSource(const RtpStreamSourceStateItemPtr &item, const Ice::Current &)
{
- if (i == mStateItems.end())
+ map<string, boost::shared_ptr<RtpStateReplicatorItem> >::iterator i = impl->mStateItems.find(item->mSessionId);
+ if (i != impl->mStateItems.end())
{
- continue;
+ i->second->getSession()->getSource()->setSink(item->mSink, Ice::Current());
}
-
- i->second->getSession()->getSource()->setSink(source->mSink, Ice::Current());
}
+ } v(this);
+
+ for (RtpStateItemSeq::const_iterator item = items.begin(); item != items.end(); ++item)
+ {
+ (*item)->visit(&v);
}
}
- std::string mId;
- std::map<std::string, boost::shared_ptr<RtpStateReplicatorItem> > mStateItems;
+
+ string mId;
+ map<string, boost::shared_ptr<RtpStateReplicatorItem> > mStateItems;
Ice::ObjectAdapterPtr mAdapter;
pj_pool_factory *mPoolFactory;
RtpGeneralStateItemPtr mGeneralState;
commit 3ab1fdbe6e035a7fb16b4b53815b50d2a1f7238c
Merge: 6044159 5668dac
Author: Joshua Colp <jcolp at digium.com>
Date: Wed Jan 26 13:16:48 2011 -0400
Merge branch 'master' of git.asterisk.org:asterisk-scf/release/media_rtp_pjmedia
commit 60441594fa6e12cab55876bc4a654d70441867df
Author: Joshua Colp <jcolp at digium.com>
Date: Wed Jan 26 13:16:08 2011 -0400
Don't specify the template parameters.
diff --git a/src/RtpStateReplicatorListener.cpp b/src/RtpStateReplicatorListener.cpp
index 58da256..d7b0f8d 100644
--- a/src/RtpStateReplicatorListener.cpp
+++ b/src/RtpStateReplicatorListener.cpp
@@ -86,7 +86,7 @@ public:
{
boost::shared_ptr<RtpStateReplicatorItem> newitem(new RtpStateReplicatorItem());
localitem = newitem;
- mStateItems.insert(std::make_pair<std::string, boost::shared_ptr<RtpStateReplicatorItem> >((*item)->mSessionId, newitem));
+ mStateItems.insert(std::make_pair((*item)->mSessionId, newitem));
RTPSessionImplPtr localSession = new RTPSessionImpl(mAdapter, mPoolFactory, session->mSessionIdentity, session->mSinkIdentity,
session->mSourceIdentity, session->mPort, session->mFormats);
commit 5668dacfae47078f246f58cbf48534459e0cc222
Author: David M. Lee <dlee at digium.com>
Date: Tue Jan 25 22:31:34 2011 -0600
Adding missing dependencies for RtpStateReplicator.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ccabce8..1f2b232 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -60,5 +60,7 @@ asterisk_scf_component_add_ice_libraries(RtpStateReplicator IceStorm)
asterisk_scf_component_add_boost_libraries(RtpStateReplicator thread date_time)
asterisk_scf_component_build_icebox(RtpStateReplicator)
+target_link_libraries(RtpStateReplicator asterisk-scf-api)
+target_link_libraries(RtpStateReplicator logging-client)
-asterisk_scf_component_install(RtpStateReplicator)
\ No newline at end of file
+asterisk_scf_component_install(RtpStateReplicator)
commit 10846d9c15bc3a12ee211d00616d9c55e2a09a38
Merge: 7a004be dcf83d9
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Jan 24 20:18:34 2011 -0400
Add support for RTP component replication.
diff --cc src/CMakeLists.txt
index c0244c5,fa8662e..ccabce8
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@@ -29,5 -38,25 +38,27 @@@ pjproject_link(media_rtp_pjmedia pjlib
pjproject_link(media_rtp_pjmedia pjlib-util)
pjproject_link(media_rtp_pjmedia pjmedia)
pjproject_link(media_rtp_pjmedia pjnath)
-#asterisk_scf_component_install(media_rtp_pjmedia RUNTIME bin "pjmedia RTP Media." Media)
+
+asterisk_scf_component_install(media_rtp_pjmedia)
+
+ asterisk_scf_component_init(RtpStateReplicator CXX)
+
+ #This line allows us to use the templated state replicator
+ #code. This statement is not the most permanent of changes
+ #and assumes the directories are structured in the way that
+ #gitall structures them.
+ include_directories(${utils_dir}/StateReplicator/include)
+ include_directories(${utils_dir}/SmartProxy/include)
+ include_directories(${API_INCLUDE_DIR})
+
+ asterisk_scf_component_add_file(RtpStateReplicator RtpStateReplicatorApp.cpp)
+ asterisk_scf_component_add_file(RtpStateReplicator RtpStateReplicator.h)
+ asterisk_scf_component_add_slice(RtpStateReplicator ../local-slice/RtpStateReplicationIf.ice)
+
+ asterisk_scf_component_add_ice_libraries(RtpStateReplicator IceStorm)
+
+ asterisk_scf_component_add_boost_libraries(RtpStateReplicator thread date_time)
+
+ asterisk_scf_component_build_icebox(RtpStateReplicator)
-target_link_libraries(RtpStateReplicator logging-client)
++
++asterisk_scf_component_install(RtpStateReplicator)
commit dcf83d9551f609836ba0cce86bd5dbb07e371541
Author: Joshua Colp <jcolp at digium.com>
Date: Sun Jan 23 18:00:01 2011 -0400
Instead of using a sleep use a boost mutex lock and condition for signaling.
diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index 2d87f8c..3b7cb2a 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -19,6 +19,8 @@
#include <boost/test/unit_test.hpp>
#include <boost/test/debug.hpp>
#include <boost/thread/thread.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
#include <Ice/Ice.h>
#include <IceBox/IceBox.h>
@@ -69,49 +71,6 @@ public:
typedef IceUtil::Handle<TestRtpReplicatorListener> TestRtpReplicatorListenerPtr;
-void TestRtpReplicatorListener::stateRemoved(const Ice::StringSeq& items, const Ice::Current&)
-{
-}
-
-void TestRtpReplicatorListener::stateSet(const RtpStateItemSeq& items, const Ice::Current&)
-{
- class visitor : public AsteriskSCF::Media::RTP::V1::RtpStateItemVisitor
- {
- public:
- visitor(TestRtpReplicatorListener *listener) : listener(listener)
- {
- }
-
- private:
- TestRtpReplicatorListener *listener;
-
- void visitGeneral(const RtpGeneralStateItemPtr &item, const Ice::Current &)
- {
- listener->mGeneral = item;
- }
-
- void visitSession(const RtpSessionStateItemPtr &item, const Ice::Current &)
- {
- listener->mSession = item;
- }
-
- void visitStreamSink(const RtpStreamSinkStateItemPtr &item, const Ice::Current &)
- {
- listener->mSink = item;
- }
-
- void visitStreamSource(const RtpStreamSourceStateItemPtr &item, const Ice::Current &)
- {
- listener->mSource = item;
- }
- } v(this);
-
- for (RtpStateItemSeq::const_iterator item = items.begin(); item != items.end(); ++item)
- {
- (*item)->visit(&v);
- }
-}
-
/**
* It seems odd that boost doesn't provide an easy way to access the GLOBAL_FIXTURE members.
* But it doesn't seem to, so I'm sharing global setup stuff here.
@@ -163,9 +122,71 @@ public:
* A sequence containing frames received via RTP.
*/
FrameSeq frames;
+
+ /**
+ * Lock to be used with the below condition, for when we get state information.
+ */
+ boost::mutex mLock;
+
+ /**
+ * Condition used to signal test thread that state was set.
+ */
+ boost::condition mCondition;
};
static SharedTestData Testbed;
+void TestRtpReplicatorListener::stateRemoved(const Ice::StringSeq& items, const Ice::Current&)
+{
+}
+
+void TestRtpReplicatorListener::stateSet(const RtpStateItemSeq& items, const Ice::Current&)
+{
+ class visitor : public AsteriskSCF::Media::RTP::V1::RtpStateItemVisitor
+ {
+ public:
+ visitor(TestRtpReplicatorListener *listener) : listener(listener)
+ {
+ }
+
+ private:
+ TestRtpReplicatorListener *listener;
+
+ void visitGeneral(const RtpGeneralStateItemPtr &item, const Ice::Current &)
+ {
+ listener->mGeneral = item;
+ boost::mutex::scoped_lock lock(Testbed.mLock);
+ Testbed.mCondition.notify_one();
+ }
+
+ void visitSession(const RtpSessionStateItemPtr &item, const Ice::Current &)
+ {
+ listener->mSession = item;
+ boost::mutex::scoped_lock lock(Testbed.mLock);
+ Testbed.mCondition.notify_one();
+ }
+
+ void visitStreamSink(const RtpStreamSinkStateItemPtr &item, const Ice::Current &)
+ {
+ listener->mSink = item;
+ boost::mutex::scoped_lock lock(Testbed.mLock);
+ Testbed.mCondition.notify_one();
+ }
+
+ void visitStreamSource(const RtpStreamSourceStateItemPtr &item, const Ice::Current &)
+ {
+ listener->mSource = item;
+ boost::mutex::scoped_lock lock(Testbed.mLock);
+ Testbed.mCondition.notify_one();
+ }
+ } v(this);
+
+ for (RtpStateItemSeq::const_iterator item = items.begin(); item != items.end(); ++item)
+ {
+ (*item)->visit(&v);
+ }
+}
+
+
class TestStreamSink : public StreamSink
{
public:
@@ -175,6 +196,8 @@ public:
void write(const AsteriskSCF::Media::V1::FrameSeq& frames, const Ice::Current&)
{
Testbed.frames = frames;
+ boost::mutex::scoped_lock lock(Testbed.mLock);
+ Testbed.mCondition.notify_one();
}
/**
@@ -363,7 +386,8 @@ BOOST_AUTO_TEST_CASE(AddListenertoStateReplicator)
BOOST_AUTO_TEST_CASE(CheckReplicatedGeneralStateItem)
{
// Since the RTP component is using a oneway invocation we wait here to ensure that the packet has been sent and processed
- boost::this_thread::sleep(boost::posix_time::seconds(1));
+ boost::mutex::scoped_lock lock(Testbed.mLock);
+ Testbed.mCondition.wait(lock);
BOOST_CHECK(Testbed.mListener->mGeneral);
}
@@ -392,7 +416,8 @@ BOOST_AUTO_TEST_CASE(AllocateRTPSession)
Testbed.session = service->allocate(formats);
// Give the RTP component time to replicate this session
- boost::this_thread::sleep(boost::posix_time::seconds(1));
+ boost::mutex::scoped_lock lock(Testbed.mLock);
+ Testbed.mCondition.wait(lock);
allocated = true;
}
@@ -753,7 +778,8 @@ BOOST_AUTO_TEST_CASE(SetupLoopback)
looped = true;
- boost::this_thread::sleep(boost::posix_time::seconds(1));
+ boost::mutex::scoped_lock lock(Testbed.mLock);
+ Testbed.mCondition.wait(lock);
}
catch (const Ice::Exception &e)
{
@@ -823,10 +849,10 @@ BOOST_AUTO_TEST_CASE(TransmitandReceiveFrame)
StreamSinkRTPPrx sink = StreamSinkRTPPrx::uncheckedCast(sinks.front());
sink->write(frames);
- /* In order to have the packet get sent and received we need to introduce a delay here, thus
- * why it exists.
+ /* It takes time for the packet to get sent and received so we wait until we get it here.
*/
- boost::this_thread::sleep(boost::posix_time::seconds(1));
+ boost::mutex::scoped_lock lock(Testbed.mLock);
+ Testbed.mCondition.wait(lock);
/* We only sent a single frame, so we should only get a single frame. */
AudioFramePtr received_frame;
commit 7a004be53942d4c1880a49076eb03db0a0b24a90
Author: David M. Lee <dlee at digium.com>
Date: Thu Jan 20 12:33:27 2011 -0600
Refactored out several install functions for installation.
* asterisk_scf_component_install - Install a component
* asterisk_scf_slice_headers_install - Install generated .h files
* asterisk_scf_slice_install - Install .ice files
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f495d26..c0244c5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -30,6 +30,4 @@ pjproject_link(media_rtp_pjmedia pjlib-util)
pjproject_link(media_rtp_pjmedia pjmedia)
pjproject_link(media_rtp_pjmedia pjnath)
-install(TARGETS media_rtp_pjmedia
- LIBRARY DESTINATION ${ASTERISK_SCF_INSTALL_ICEBOX_DIR}
- RUNTIME DESTINATION ${ASTERISK_SCF_INSTALL_ICEBOX_DIR})
+asterisk_scf_component_install(media_rtp_pjmedia)
commit a36a1c558a7d563e4ac69db343103cf2ebb29cda
Merge: c6c8e75 486c8f5
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Wed Jan 19 16:53:21 2011 -0600
Merge branch 'replication' into replication-visitor
Conflicts:
local-slice/CMakeLists.txt
commit 486c8f5bec883c8f01a3a933aa5cdce1aff12bdd
Merge: 4fa74bf 68adbce
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Wed Jan 19 16:48:56 2011 -0600
Merge branch 'master' into replication
Conflicts:
src/CMakeLists.txt
src/MediaRTPpjmedia.cpp
src/RTPSession.cpp
src/RTPSink.cpp
src/RTPSource.cpp
test/CMakeLists.txt
test/TestRTPpjmedia.cpp
diff --cc local-slice/RtpStateReplicationIf.ice
index b449ee5,0000000..bd04de3
mode 100644,000000..100644
--- a/local-slice/RtpStateReplicationIf.ice
+++ b/local-slice/RtpStateReplicationIf.ice
@@@ -1,102 -1,0 +1,103 @@@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, 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 <Ice/BuiltinSequences.ice>
+#include <Ice/Identity.ice>
- #include "Media/MediaIf.ice"
- #include "Media/RTP/MediaRTPIf.ice"
- #include "Core/Discovery/ServiceLocatorIf.ice"
++
++#include <AsteriskSCF/Media/MediaIf.ice>
++#include <AsteriskSCF/Media/RTP/MediaRTPIf.ice>
++#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.ice>
+
+module AsteriskSCF
+{
+
+module Media
+{
+
+module RTP
+{
+
+["suppress"]
+module V1
+{
+ const string StateReplicatorComponentCategory = "RtpStateReplicatorComponent";
+ const string StateReplicatorDiscoveryCategory = "RtpStateReplicator";
+
+ class RtpStateReplicatorParams extends AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams
+ {
+ string mName;
+ };
+
+ class RtpStateItem
+ {
+ string key;
+ string mSessionId;
+ };
+
+ sequence<RtpStateItem> RtpStateItemSeq;
+
+ interface RtpStateReplicatorListener
+ {
+ void stateRemoved(Ice::StringSeq itemKeys);
+ void stateSet(RtpStateItemSeq items);
+ };
+
+ interface RtpStateReplicator
+ {
+ void addListener(RtpStateReplicatorListener *listener);
+ void removeListener(RtpStateReplicatorListener *listener);
+ void setState (RtpStateItemSeq items);
+ void removeState(Ice::StringSeq items);
+ idempotent RtpStateItemSeq getState(Ice::StringSeq itemKeys);
+ idempotent RtpStateItemSeq getAllState();
+ };
+
+ class RtpGeneralStateItem extends RtpStateItem
+ {
+ AsteriskSCF::Core::Discovery::V1::ServiceManagement *mServiceManagement;
+ };
+
+ class RtpSessionStateItem extends RtpStateItem
+ {
+ Ice::Identity mSessionIdentity;
+ int mPort;
+ Ice::Identity mSinkIdentity;
+ Ice::Identity mSourceIdentity;
+ AsteriskSCF::Media::V1::FormatSeq mFormats;
+ PayloadMap mPayloadstoFormats;
+ };
+
+ class RtpStreamSinkStateItem extends RtpStateItem
+ {
+ AsteriskSCF::Media::V1::StreamSource *mSource;
+ string mRemoteAddress;
+ int mRemotePort;
+ };
+
+ class RtpStreamSourceStateItem extends RtpStateItem
+ {
+ AsteriskSCF::Media::V1::StreamSink *mSink;
+ };
+
+}; //module V1
+
+}; //module RTP
+
+}; //module Media
+
+}; //module Asterisk SCF
diff --cc src/CMakeLists.txt
index f30e2bc,0c7dd07..fa8662e
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@@ -6,17 -6,7 +6,13 @@@
# All rights reserved.
#
+
+include_directories(${utils_dir}/StateReplicator/src)
+include_directories(${utils_dir}/SmartProxy/src)
+
++asterisk_scf_slice_include_directories(${API_SLICE_DIR})
++
asterisk_scf_component_init(media_rtp_pjmedia CXX)
- asterisk_scf_component_add_slice(media_rtp_pjmedia ServiceLocatorIf)
- asterisk_scf_component_add_slice(media_rtp_pjmedia MediaIf)
- asterisk_scf_component_add_slice(media_rtp_pjmedia MediaRTPIf)
- asterisk_scf_component_add_slice(media_rtp_pjmedia ComponentServiceIf)
- asterisk_scf_component_add_slice(media_rtp_pjmedia ReplicaIf)
- asterisk_scf_component_add_slice(media_rtp_pjmedia RtpStateReplicationIf)
asterisk_scf_component_add_file(media_rtp_pjmedia MediaRTPpjmedia.cpp)
asterisk_scf_component_add_file(media_rtp_pjmedia RTPSession.cpp)
asterisk_scf_component_add_file(media_rtp_pjmedia RTPSource.cpp)
@@@ -24,8 -14,6 +20,9 @@@ asterisk_scf_component_add_file(media_r
asterisk_scf_component_add_file(media_rtp_pjmedia RTPSession.h)
asterisk_scf_component_add_file(media_rtp_pjmedia RTPSource.h)
asterisk_scf_component_add_file(media_rtp_pjmedia RTPSink.h)
+asterisk_scf_component_add_file(media_rtp_pjmedia RtpStateReplicatorListener.cpp)
+asterisk_scf_component_add_file(media_rtp_pjmedia RtpStateReplicator.h)
++asterisk_scf_component_add_slice(media_rtp_pjmedia ../local-slice/RtpStateReplicationIf.ice)
asterisk_scf_component_add_boost_libraries(media_rtp_pjmedia core thread)
if(NOT logger_dir)
@@@ -41,21 -30,3 +39,24 @@@ pjproject_link(media_rtp_pjmedia pjlib-
pjproject_link(media_rtp_pjmedia pjmedia)
pjproject_link(media_rtp_pjmedia pjnath)
#asterisk_scf_component_install(media_rtp_pjmedia RUNTIME bin "pjmedia RTP Media." Media)
+
+asterisk_scf_component_init(RtpStateReplicator CXX)
+
- asterisk_scf_component_add_slice(RtpStateReplicator ServiceLocatorIf)
- asterisk_scf_component_add_slice(RtpStateReplicator ComponentServiceIf)
- asterisk_scf_component_add_slice(RtpStateReplicator RtpStateReplicationIf)
- asterisk_scf_component_add_slice(RtpStateReplicator RoutingIf)
- asterisk_scf_component_add_slice(RtpStateReplicator MediaRTPIf)
++#This line allows us to use the templated state replicator
++#code. This statement is not the most permanent of changes
++#and assumes the directories are structured in the way that
++#gitall structures them.
++include_directories(${utils_dir}/StateReplicator/include)
++include_directories(${utils_dir}/SmartProxy/include)
++include_directories(${API_INCLUDE_DIR})
+
+asterisk_scf_component_add_file(RtpStateReplicator RtpStateReplicatorApp.cpp)
+asterisk_scf_component_add_file(RtpStateReplicator RtpStateReplicator.h)
++asterisk_scf_component_add_slice(RtpStateReplicator ../local-slice/RtpStateReplicationIf.ice)
+
+asterisk_scf_component_add_ice_libraries(RtpStateReplicator IceStorm)
+
+asterisk_scf_component_add_boost_libraries(RtpStateReplicator thread date_time)
+
+asterisk_scf_component_build_icebox(RtpStateReplicator)
+target_link_libraries(RtpStateReplicator logging-client)
diff --cc src/MediaRTPpjmedia.cpp
index f770788,6fb92b3..4a1d0ee
--- a/src/MediaRTPpjmedia.cpp
+++ b/src/MediaRTPpjmedia.cpp
@@@ -23,18 -22,14 +23,19 @@@
#include <boost/shared_ptr.hpp>
- #include "Core/Discovery/ServiceLocatorIf.h"
- #include "Media/MediaIf.h"
- #include "Media/RTP/MediaRTPIf.h"
- #include "System/Component/ComponentServiceIf.h"
- #include "IceLogger.h"
- #include "logger.h"
+ #include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
+ #include <AsteriskSCF/Media/MediaIf.h>
+ #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
+ #include <AsteriskSCF/System/Component/ComponentServiceIf.h>
++#include <AsteriskSCF/System/Component/ReplicaIf.h>
+ #include <AsteriskSCF/Logger/IceLogger.h>
+ #include <AsteriskSCF/logger.h>
++#include <AsteriskSCF/SmartProxy.h>
++
+#include "RtpStateReplicationIf.h"
- #include "ReplicaIf.h"
- #include "SmartProxy.h"
#include "RTPSession.h"
+#include "RtpStateReplicator.h"
using namespace std;
using namespace AsteriskSCF::Core::Discovery::V1;
diff --cc src/RTPSession.cpp
index 15633ef,fa6fbf7..5e7f33e
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@@ -20,11 -19,8 +20,12 @@@
#include <pjlib.h>
#include <pjmedia.h>
- #include "Media/MediaIf.h"
- #include "Media/RTP/MediaRTPIf.h"
+ #include <AsteriskSCF/Media/MediaIf.h>
+ #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
++#include <AsteriskSCF/System/Component/ReplicaIf.h>
++#include <AsteriskSCF/SmartProxy.h>
++
+#include "RtpStateReplicationIf.h"
- #include "ReplicaIf.h"
- #include "SmartProxy.h"
#include "RTPSession.h"
#include "RTPSource.h"
diff --cc src/RTPSink.cpp
index ed63b32,23d7bdd..e20f86d
--- a/src/RTPSink.cpp
+++ b/src/RTPSink.cpp
@@@ -20,11 -19,8 +20,12 @@@
#include <pjlib.h>
#include <pjmedia.h>
- #include "Media/MediaIf.h"
- #include "Media/RTP/MediaRTPIf.h"
+ #include <AsteriskSCF/Media/MediaIf.h>
+ #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
++#include <AsteriskSCF/System/Component/ReplicaIf.h>
++#include <AsteriskSCF/SmartProxy.h>
++
+#include "RtpStateReplicationIf.h"
- #include "ReplicaIf.h"
- #include "SmartProxy.h"
#include "RTPSession.h"
#include "RTPSink.h"
diff --cc src/RTPSource.cpp
index 9590b6d,7125fb4..39c52e2
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@@ -20,11 -19,9 +20,13 @@@
#include <pjlib.h>
#include <pjmedia.h>
- #include "Media/MediaIf.h"
- #include "Media/RTP/MediaRTPIf.h"
+ #include <AsteriskSCF/Media/MediaIf.h>
+ #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
+ #include <AsteriskSCF/logger.h>
++#include <AsteriskSCF/System/Component/ReplicaIf.h>
++#include <AsteriskSCF/SmartProxy.h>
++
+#include "RtpStateReplicationIf.h"
- #include "ReplicaIf.h"
- #include "SmartProxy.h"
#include "RTPSession.h"
#include "RTPSource.h"
diff --cc src/RtpStateReplicator.h
index d3bc6c9,0000000..34dc017
mode 100644,000000..100644
--- a/src/RtpStateReplicator.h
+++ b/src/RtpStateReplicator.h
@@@ -1,38 -1,0 +1,40 @@@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, 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 <Ice/Ice.h>
++
++#include <AsteriskSCF/StateReplicator.h>
++
+#include "RtpStateReplicationIf.h"
- #include "StateReplicator.h"
+
+using namespace AsteriskSCF::Media::RTP::V1;
+
+typedef AsteriskSCF::StateReplication::StateReplicator<RtpStateReplicator, RtpStateItemPtr, std::string, RtpStateReplicatorListenerPrx> RtpStateReplicatorI;
+typedef IceUtil::Handle<RtpStateReplicatorI> RtpStateReplicatorIPtr;
+
+class RtpStateReplicatorListenerI : public RtpStateReplicatorListener
+{
+public:
+ RtpStateReplicatorListenerI(Ice::ObjectAdapterPtr, pj_pool_factory*, RtpGeneralStateItemPtr);
+ ~RtpStateReplicatorListenerI();
+ void stateRemoved(const Ice::StringSeq&, const Ice::Current&);
+ void stateSet(const RtpStateItemSeq&, const Ice::Current&);
+ bool operator==(RtpStateReplicatorListenerI &rhs);
+private:
+ struct RtpStateReplicatorListenerImpl *mImpl;
+};
diff --cc src/RtpStateReplicatorApp.cpp
index 2b49c1b,0000000..6fa76d9
mode 100644,000000..100644
--- a/src/RtpStateReplicatorApp.cpp
+++ b/src/RtpStateReplicatorApp.cpp
@@@ -1,231 -1,0 +1,232 @@@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, 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 <Ice/Ice.h>
+#include <IceUtil/UUID.h>
+#include <IceStorm/IceStorm.h>
+#include <IceBox/IceBox.h>
+
+#include <pjlib.h>
+
- #include "ServiceLocatorIf.h"
- #include "ComponentServiceIf.h"
++#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
++#include <AsteriskSCF/System/Component/ComponentServiceIf.h>
++#include <AsteriskSCF/Logger/IceLogger.h>
++#include <AsteriskSCF/logger.h>
++
+#include "RtpStateReplicator.h"
- #include "IceLogger.h"
- #include "logger.h"
+
+using namespace std;
+using namespace AsteriskSCF::Core;
+using namespace AsteriskSCF::Core::Discovery::V1;
+using namespace AsteriskSCF::System::Component::V1;
+using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::Media::RTP::V1;
+
+namespace
+{
+Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaRTP");
+}
+
+class RtpStateReplicatorService : public IceBox::Service
+{
+public:
+ RtpStateReplicatorService() { };
+ ~RtpStateReplicatorService()
+ {
+ mComponentService = 0;
+ mAdapter = 0;
+ mStateReplicator = 0;
+ };
+ virtual void start(const string &name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq& args);
+ virtual void stop();
+private:
+ void initialize(std::string appName, const Ice::CommunicatorPtr& ic);
+ void registerWithServiceLocator(const Ice::CommunicatorPtr& ic);
+ void deregisterFromServiceLocator();
+ std::string mAppName;
+ Ice::ObjectAdapterPtr mAdapter;
+ ServiceLocatorManagementPrx mServiceLocatorManagement;
+ Discovery::V1::ServiceManagementPrx mComponentServiceManagement;
+ Discovery::V1::ServiceManagementPrx mStateReplicationManagement;
+ ConfiguredIceLoggerPtr mIceLogger;
+ ComponentServicePtr mComponentService;
+ RtpStateReplicatorIPtr mStateReplicator;
+};
+
+static const string ComponentServiceId("RtpStateReplicatorComponent");
+static const string ServiceDiscoveryId("RtpStateReplicatorService");
+
+/**
+ * This class provides implementation for the ComponentService interface, which
+ * every Asterisk SCF component is expected to publish.
+ */
+class ComponentServiceImpl : public ComponentService
+{
+public:
+ ComponentServiceImpl(RtpStateReplicatorService &service) : mService(service) {}
+
+public: // Overrides of the ComponentService interface.
+ virtual void suspend(const ::Ice::Current& = ::Ice::Current())
+ {
+ // TBD
+ }
+
+ virtual void resume(const ::Ice::Current& = ::Ice::Current())
+ {
+ // TBD
+ }
+
+ virtual void shutdown(const ::Ice::Current& = ::Ice::Current())
+ {
+ // TBD
+ }
+
+private:
+ RtpStateReplicatorService& mService;
+};
+
+class RtpStateReplicatorCompare : public ServiceLocatorParamsCompare
+{
+public:
+ RtpStateReplicatorCompare(string name) : mName(name) {}
+ bool isSupported(const ServiceLocatorParamsPtr ¶ms, const Ice::Current &)
+ {
+ RtpStateReplicatorParamsPtr sipParams = RtpStateReplicatorParamsPtr::dynamicCast(params);
+ if (sipParams->mName == mName)
+ {
+ return true;
+ }
+ return false;
+ }
+private:
+ string mName;
+};
+
+typedef IceUtil::Handle<RtpStateReplicatorCompare> RtpStateReplicatorComparePtr;
+
+/**
+ * Register this component's primary public interfaces with the Service Locator.
+ * This enables other Asterisk SCF components to locate our interfaces.
+ */
+void RtpStateReplicatorService::registerWithServiceLocator(const Ice::CommunicatorPtr& ic)
+{
+ try
+ {
+ // Get a proxy to the management interface for the Service Locator, so we can add ourselves into the system discovery mechanisms.
+ mServiceLocatorManagement = ServiceLocatorManagementPrx::checkedCast(ic->propertyToProxy("LocatorServiceManagement.Proxy"));
+
+ if (mServiceLocatorManagement == 0)
+ {
+ lg(Error) << "Unable to obtain proxy to ServiceLocatorManagement interface. Check config file. This component can't be found until this is corrected." << endl;
+ return;
+ }
+
+ // Get a proxy to our ComponentService interface and add it to the Service Locator.
+ Ice::ObjectPrx componentServiceObjectPrx = mAdapter->createDirectProxy(ic->stringToIdentity(ComponentServiceId));
+ ComponentServicePrx componentServicePrx = ComponentServicePrx::checkedCast(componentServiceObjectPrx);
+
+ // The GUID passed in to add service needs to be unique for reporting.
+ string componentServiceGuid(AsteriskSCF::Media::RTP::V1::StateReplicatorComponentCategory);
+ mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(componentServicePrx, componentServiceGuid));
+
+ // Add category as a parameter to enable other components look this component up.
+ ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
+ genericparams->category = AsteriskSCF::Media::RTP::V1::StateReplicatorComponentCategory;
+
+ mComponentServiceManagement->addLocatorParams(genericparams, "");
+
+ Ice::ObjectPrx stateReplicatorObjectPrx = mAdapter->createDirectProxy(ic->stringToIdentity(ServiceDiscoveryId));
+ RtpStateReplicatorPrx stateReplicatorPrx = RtpStateReplicatorPrx::checkedCast(stateReplicatorObjectPrx);
+
+ string stateReplicationGuid(AsteriskSCF::Media::RTP::V1::StateReplicatorDiscoveryCategory);
+ mStateReplicationManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(stateReplicatorPrx, stateReplicationGuid));
+
+ ServiceLocatorParamsPtr discoveryParams = new ServiceLocatorParams();
+ discoveryParams->category = AsteriskSCF::Media::RTP::V1::StateReplicatorDiscoveryCategory;
+
+ string replicatorName = ic->getProperties()->getPropertyWithDefault("RtpStateReplicator.Name", "default");
+ RtpStateReplicatorCompare* nameCompare = new RtpStateReplicatorCompare(replicatorName);
+ ServiceLocatorParamsComparePrx compareProxy = ServiceLocatorParamsComparePrx::uncheckedCast(mAdapter->addWithUUID(nameCompare));
+
+ string compareGuid = IceUtil::generateUUID();
+ mServiceLocatorManagement->addCompare(compareGuid, compareProxy);
+ mStateReplicationManagement->addLocatorParams(discoveryParams, compareGuid);
+
+ // TBD... We may have other interfaces to publish to the Service Locator.
+ }
+ catch(...)
+ {
+ lg(Error) << "Exception in " << mAppName << " registerWithServiceLocator()" << endl;
+ }
+}
+
+/**
+ * Deregister this component's primary public interfaces from the Service Locator.
+ * This is done at shutdown, and whenever we want to keep other services from locating
+ * our interfaces.
+ */
+void RtpStateReplicatorService::deregisterFromServiceLocator()
+{
+ try
+ {
+ mComponentServiceManagement->unregister();
+ }
+ catch(...)
+ {
+ lg(Error) << "Had trouble in deregisterFromServiceLocator()." << endl;
+ }
+}
+
+void RtpStateReplicatorService::initialize(const std::string appName, const Ice::CommunicatorPtr& ic)
+{
+ mAdapter = ic->createObjectAdapter("RtpStateReplicator");
+
+ // setup logging client
+ mIceLogger = createIceLogger(mAdapter);
+ getLoggerFactory().setLogOutput(mIceLogger->getLogger());
+
+ mAppName = appName;
+ // Create and publish our ComponentService interface support.
+ mComponentService = new ComponentServiceImpl(*this);
+ mAdapter->add(mComponentService, ic->stringToIdentity(ComponentServiceId));
+ mStateReplicator = new RtpStateReplicatorI();
+ mAdapter->add(mStateReplicator, ic->stringToIdentity(ServiceDiscoveryId));
+
+ mAdapter->activate();
+}
+
+void RtpStateReplicatorService::start(const string &name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq& args)
+{
+ initialize(name, ic);
+ // Plug into the Asterisk SCF discovery system so that the interfaces we provide
+ // can be located.
+ registerWithServiceLocator(ic);
+}
+
+void RtpStateReplicatorService::stop()
+{
+ // Remove our interfaces from the service locator.
+ deregisterFromServiceLocator();
+}
+
+extern "C"
+{
+ASTERISK_SCF_ICEBOX_EXPORT IceBox::Service* create(Ice::CommunicatorPtr communicator)
+{
+ return new RtpStateReplicatorService;
+}
+}
+
diff --cc src/RtpStateReplicatorListener.cpp
index f11b9d7,0000000..58da256
mode 100644,000000..100644
--- a/src/RtpStateReplicatorListener.cpp
+++ b/src/RtpStateReplicatorListener.cpp
@@@ -1,151 -1,0 +1,151 @@@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, 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 <IceUtil/UUID.h>
+
+#include <boost/thread.hpp>
+#include <boost/shared_ptr.hpp>
+
+#include <pjlib.h>
+#include <pjmedia.h>
+
- #include "ReplicaIf.h"
- #include "SmartProxy.h"
++#include <AsteriskSCF/System/Component/ReplicaIf.h>
++#include <AsteriskSCF/SmartProxy.h>
+
+#include "RtpStateReplicator.h"
+#include "RTPSession.h"
+#include "RTPSink.h"
+#include "RTPSource.h"
+
+using namespace AsteriskSCF::Media::RTP::V1;
+
+class RtpStateReplicatorItem
+{
+public:
+ RtpStateReplicatorItem() { }
+ ~RtpStateReplicatorItem()
+ {
+ mSession->release(Ice::Current());
+ }
+
+ // Helper function which sets the session on this replicator item
+ void setSession(RTPSessionImplPtr session) { mSession = session; };
+
+ // Helper function which gets the session
+ RTPSessionImplPtr getSession() { return mSession; };
+
+private:
+ // Pointer to the session that we are managing
+ RTPSessionImplPtr mSession;
+};
+
+struct RtpStateReplicatorListenerImpl
+{
+public:
+ RtpStateReplicatorListenerImpl(Ice::ObjectAdapterPtr adapter, pj_pool_factory *poolFactory, RtpGeneralStateItemPtr generalState)
+ : mId(IceUtil::generateUUID()), mAdapter(adapter), mPoolFactory(poolFactory), mGeneralState(generalState) {}
+ void removeStateNoticeImpl(const Ice::StringSeq& itemKeys)
+ {
+ for (Ice::StringSeq::const_iterator key = itemKeys.begin(); key != itemKeys.end(); ++key)
+ {
+ // Just erasing this from the map will cause the destructor to actually shut things down
+ mStateItems.erase((*key));
+ }
+ }
+ void setStateNoticeImpl(const RtpStateItemSeq& items)
+ {
+ for (RtpStateItemSeq::const_iterator item = items.begin(); item != items.end(); ++item)
+ {
+ std::map<std::string, boost::shared_ptr<RtpStateReplicatorItem> >::iterator i = mStateItems.find((*item)->mSessionId);
+ RtpGeneralStateItemPtr general;
+ RtpSessionStateItemPtr session;
+ RtpStreamSinkStateItemPtr sink;
+ RtpStreamSourceStateItemPtr source;
+ boost::shared_ptr<RtpStateReplicatorItem> localitem;
+
+ if ((general = RtpGeneralStateItemPtr::dynamicCast((*item))))
+ {
+ mGeneralState->mServiceManagement = general->mServiceManagement;
+ }
+ else if ((session = RtpSessionStateItemPtr::dynamicCast((*item))))
+ {
+ if (i == mStateItems.end())
+ {
+ boost::shared_ptr<RtpStateReplicatorItem> newitem(new RtpStateReplicatorItem());
+ localitem = newitem;
+ mStateItems.insert(std::make_pair<std::string, boost::shared_ptr<RtpStateReplicatorItem> >((*item)->mSessionId, newitem));
+
+ RTPSessionImplPtr localSession = new RTPSessionImpl(mAdapter, mPoolFactory, session->mSessionIdentity, session->mSinkIdentity,
+ session->mSourceIdentity, session->mPort, session->mFormats);
+ localitem->setSession(localSession);
+ }
+ else
+ {
+ localitem = i->second;
+ }
+
+ localitem->getSession()->associatePayloads(session->mPayloadstoFormats, Ice::Current());
+ }
+ else if ((sink = RtpStreamSinkStateItemPtr::dynamicCast((*item))))
+ {
+ if (i == mStateItems.end())
+ {
+ continue;
+ }
+
+ i->second->getSession()->getSink()->setSource(sink->mSource, Ice::Current());
+ i->second->getSession()->getSink()->setRemoteDetails(sink->mRemoteAddress, sink->mRemotePort, Ice::Current());
+ }
+ else if ((source = RtpStreamSourceStateItemPtr::dynamicCast((*item))))
+ {
+ if (i == mStateItems.end())
+ {
+ continue;
+ }
+
+ i->second->getSession()->getSource()->setSink(source->mSink, Ice::Current());
+ }
+ }
+ }
+ std::string mId;
+ std::map<std::string, boost::shared_ptr<RtpStateReplicatorItem> > mStateItems;
+ Ice::ObjectAdapterPtr mAdapter;
+ pj_pool_factory *mPoolFactory;
+ RtpGeneralStateItemPtr mGeneralState;
+};
+
+RtpStateReplicatorListenerI::RtpStateReplicatorListenerI(Ice::ObjectAdapterPtr adapter, pj_pool_factory *poolFactory, RtpGeneralStateItemPtr generalState)
+ : mImpl(new RtpStateReplicatorListenerImpl(adapter, poolFactory, generalState)) {}
+
+RtpStateReplicatorListenerI::~RtpStateReplicatorListenerI()
+{
+ delete mImpl;
+}
+
+void RtpStateReplicatorListenerI::stateRemoved(const Ice::StringSeq& itemKeys, const Ice::Current&)
+{
+ mImpl->removeStateNoticeImpl(itemKeys);
+}
+
+void RtpStateReplicatorListenerI::stateSet(const RtpStateItemSeq& items, const Ice::Current&)
+{
+ mImpl->setStateNoticeImpl(items);
+}
+
+bool RtpStateReplicatorListenerI::operator==(RtpStateReplicatorListenerI &rhs)
+{
+ return mImpl->mId == rhs.mImpl->mId;
+}
diff --cc test/CMakeLists.txt
index b36ae1b,6876f33..5ca2576
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@@ -6,14 -6,12 +6,15 @@@
# All rights reserved.
#
++asterisk_scf_slice_include_directories(${API_SLICE_DIR})
++
asterisk_scf_component_init(media_rtp_pjmedia_test CXX)
asterisk_scf_component_add_file(media_rtp_pjmedia_test TestRTPpjmedia.cpp)
- asterisk_scf_component_add_slice(media_rtp_pjmedia_test MediaIf)
- asterisk_scf_component_add_slice(media_rtp_pjmedia_test MediaRTPIf)
- asterisk_scf_component_add_slice(media_rtp_pjmedia_test RtpStateReplicationIf)
++asterisk_scf_component_add_slice(media_rtp_pjmedia_test ../local-slice/RtpStateReplicationIf.ice)
asterisk_scf_component_add_boost_libraries(media_rtp_pjmedia_test unit_test_framework thread date_time)
+ include_directories(${API_INCLUDE_DIR})
asterisk_scf_component_build_icebox(media_rtp_pjmedia_test)
- #asterisk_scf_component_install(media_rtp_pjmedia_test RUNTIME bin "PJmedia RTP Media Test Driver." Core)
+ target_link_libraries(media_rtp_pjmedia_test asterisk-scf-api)
# integration test
if(integrated_build STREQUAL "true")
diff --cc test/TestRTPpjmedia.cpp
index 4b6c2ed,e71ffc6..a21b3c0
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@@ -23,11 -23,10 +23,12 @@@
#include <Ice/Ice.h>
#include <IceBox/IceBox.h>
- #include "Core/Discovery/ServiceLocatorIf.h"
- #include "Media/MediaIf.h"
- #include "Media/RTP/MediaRTPIf.h"
+ #include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
+ #include <AsteriskSCF/Media/MediaIf.h>
+ #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
+
+#include "RtpStateReplicationIf.h"
+
using namespace std;
using namespace AsteriskSCF::Core::Discovery::V1;
using namespace AsteriskSCF::Media::V1;
commit d75167ff53c0113f951d0296cefcb2238294f1e0
Author: David M. Lee <dlee at digium.com>
Date: Thu Jan 13 20:25:28 2011 -0600
Properly install the media component.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0c7dd07..f495d26 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -29,4 +29,7 @@ pjproject_link(media_rtp_pjmedia pjlib)
pjproject_link(media_rtp_pjmedia pjlib-util)
pjproject_link(media_rtp_pjmedia pjmedia)
pjproject_link(media_rtp_pjmedia pjnath)
-#asterisk_scf_component_install(media_rtp_pjmedia RUNTIME bin "pjmedia RTP Media." Media)
+
+install(TARGETS media_rtp_pjmedia
+ LIBRARY DESTINATION ${ASTERISK_SCF_INSTALL_ICEBOX_DIR}
+ RUNTIME DESTINATION ${ASTERISK_SCF_INSTALL_ICEBOX_DIR})
commit 68adbcebbfa998bf8dcefdb0b8c9be7a237f487a
Author: David M. Lee <dlee at digium.com>
Date: Wed Jan 19 12:18:10 2011 -0600
We require cmake 2.8 or better.
Now make it a specific "You're cmake is old" failure, as opposed to some
random failure later on.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c61faa5..a60eae4 100644
--- a/CMakeLists.txt
... 14623 lines suppressed ...
--
asterisk-scf/integration/media_rtp_pjmedia.git
More information about the asterisk-scf-commits
mailing list