[asterisk-scf-commits] asterisk-scf/integration/media_rtp_pjmedia.git branch "pjlib-thread-hook" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Sep 28 13:51:48 CDT 2011


branch "pjlib-thread-hook" has been created
        at  9550b9856c82fad80ea55ec5163377c2fc57bf5b (commit)

- Log -----------------------------------------------------------------
commit 9550b9856c82fad80ea55ec5163377c2fc57bf5b
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Wed Sep 28 13:49:43 2011 -0500

    * Convert to use AsteriskSCF::PJLib::ThreadHook.
    * Remove trailing whitespace.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d130546..10fee6a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -49,7 +49,7 @@ astscf_component_add_slices(media_rtp_pjmedia PROJECT AsteriskSCF/Configuration/
 astscf_component_add_boost_libraries(media_rtp_pjmedia core thread)
 astscf_component_add_slice_collection_libraries(media_rtp_pjmedia ASTSCF)
 astscf_component_build_icebox(media_rtp_pjmedia)
-target_link_libraries(media_rtp_pjmedia logging-client astscf-ice-util-cpp)
+target_link_libraries(media_rtp_pjmedia logging-client astscf-ice-util-cpp astscf-ice-util-cpp-pjlib)
 
 pjproject_link(media_rtp_pjmedia pjlib)
 pjproject_link(media_rtp_pjmedia pjlib-util)
diff --git a/src/Component.cpp b/src/Component.cpp
index 2b4b3a2..abfea53 100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@ -31,6 +31,7 @@
 #include <AsteriskSCF/logger.h>
 #include <AsteriskSCF/Discovery/SmartProxy.h>
 #include <AsteriskSCF/Component/Component.h>
+#include <AsteriskSCF/PJLib/ThreadHook.h>
 
 #include "RtpReplicationContext.h"
 #include "RTPSession.h"
@@ -67,7 +68,7 @@ static const string MediaComparatorServiceId("RTPMediaServiceComparator");
 class RTPMediaServiceImpl : public RTPMediaService
 {
 public:
-    RTPMediaServiceImpl(const Ice::ObjectAdapterPtr&, 
+    RTPMediaServiceImpl(const Ice::ObjectAdapterPtr&,
       const RtpReplicationContextPtr& replicationContext,
       const ConfigurationServiceImplPtr&);
 
@@ -138,7 +139,7 @@ public:
         {
             return false;
         }
-        
+
         RTPOverICEServiceLocatorParamsPtr iceParams = RTPOverICEServiceLocatorParamsPtr::dynamicCast(locatorParams);
         if (iceParams)
         {
@@ -176,13 +177,13 @@ private:
 };
 
 /**
- * Implementation of the Component class. 
+ * Implementation of the Component class.
  */
 class Component : public AsteriskSCF::Component::Component
 {
 public:
-    Component() : 
-       AsteriskSCF::Component::Component(lg, AsteriskSCF::Media::RTP::V1::ComponentServiceDiscoveryCategory), 
+    Component() :
+       AsteriskSCF::Component::Component(lg, AsteriskSCF::Media::RTP::V1::ComponentServiceDiscoveryCategory),
       mListeningToReplicator(false), mGeneralState(new RtpGeneralStateItem()) { mGeneralState->key = IceUtil::generateUUID(); };
 
 private:
@@ -199,7 +200,7 @@ private:
     virtual void onSuspend();
     virtual void onResume();
     virtual void onPreInitialize();
-    virtual void onStop();    
+    virtual void onStop();
     virtual void onStart();
 
     // Other base Component overrides
@@ -223,93 +224,35 @@ private:
     LocatorRegistrationWrapperPtr mRtpMediaServiceRegistration;
 
     // Media comparator service
-    ServiceLocatorParamsComparePtr mRtpMediaComparatorService; 
+    ServiceLocatorParamsComparePtr mRtpMediaComparatorService;
     ServiceLocatorParamsComparePrx mRtpMediaComparatorServicePrx;
     RTPOverICEServiceLocatorParamsPtr mRtpOverIceLocatorParams;
 
-    // Configuration state 
+    // Configuration state
     ConfigurationServiceImplPtr mConfigurationService;
     ConfigurationServicePrx mConfigurationServicePrx;
     LocatorRegistrationWrapperPtr mConfigurationRegistration;
 };
 
-void Component::onSuspend() 
+void Component::onSuspend()
 {
     mGeneralState->serviceManagement->suspend();
 }
 
-void Component::onResume() 
+void Component::onResume()
 {
     mGeneralState->serviceManagement->unsuspend();
 }
 
 /**
- * Wrapper class around pj_thread_desc.
- */
-class ThreadDescWrapper
-{
-public:
-    /**
-     * pjthread thread description information, must persist for the life of the thread
-     */
-    pj_thread_desc mDesc;
-};
-
-/**
- * Type definition used to create a smart pointer for the above.
- */
-typedef boost::shared_ptr<ThreadDescWrapper> ThreadDescWrapperPtr;
-
-/**
- * Implementation of the Ice::ThreadNotification class.
- */
-class pjlibHook : public Ice::ThreadNotification
-{
-public:
-    /**
-     * Implementation of the start function which is called when a thread starts.
-     */
-    void start()
-    {
-        ThreadDescWrapperPtr wrapper = ThreadDescWrapperPtr(new ThreadDescWrapper());
-        pj_thread_t *thread;
-        pj_thread_register("ICE Thread", wrapper->mDesc, &thread);
-        boost::lock_guard<boost::mutex> lock(mLock);
-        pjThreads.insert(make_pair(thread, wrapper));
-    }
-
-    /**
-     * Implementation of the stop function which is called when a thread stops.
-     */
-    void stop()
-    {
-        if (pj_thread_is_registered())
-        {
-            boost::lock_guard<boost::mutex> lock(mLock);
-            pjThreads.erase(pj_thread_this());
-        }
-    }
-private:
-    /**
-     * A map containing thread lifetime persistent data.
-     */
-    map<pj_thread_t*, ThreadDescWrapperPtr> pjThreads;
-
-    /**
-     * Mutex to protect the map
-     */
-    boost::mutex mLock;
-};
-
-/**
  * Constructor for the RTPMediaServiceImpl class.
  */
 RTPMediaServiceImpl::RTPMediaServiceImpl(const Ice::ObjectAdapterPtr& adapter,
     const RtpReplicationContextPtr& replicationContext,
     const ConfigurationServiceImplPtr& configurationService) :
-    mAdapter(adapter), 
+    mAdapter(adapter),
     mEnvironment(PJMediaEnvironment::create(adapter->getCommunicator()->getProperties(), configurationService)),
-    mReplicationContext(replicationContext), 
+    mReplicationContext(replicationContext),
     mConfigurationService(configurationService)
 {
 }
@@ -334,35 +277,28 @@ RTPSessionPrx RTPMediaServiceImpl::allocate(
             outputs);
 }
 
-void Component::onPreInitialize() 
+void Component::onPreInitialize()
 {
-    /* Initialize pjlib as pjmedia will be using it */
-    pj_status_t status = pj_init();
-    if (status != PJ_SUCCESS)
+    try
     {
-        lg(Error) << "PJ library initialization failed.";
-        return;
-    }
+	lg(Info) << "Initializing pjmedia rtp component" << endl;
+
+	Ice::InitializationData id;
+	id.threadHook = new AsteriskSCF::PJLib::ThreadHook("Ice");
+	id.properties = getCommunicator()->getProperties();
 
-    if ((status = pjlib_util_init()) != PJ_SUCCESS)
+	// To use our thread-hook, we need to set an alternate
+	// communicator in our Component base.
+	setCommunicator(Ice::initialize(id));
+    }
+    catch(const std::exception& e)
     {
-        lg(Error) << "PJ Utility library initialization failed.";
-        return;
+        lg(Critical) << "Major problems in " << getName() << " initialization: " << e.what();
     }
-
-    lg(Info) << "Initializing pjmedia rtp component" << endl;
-
-    Ice::InitializationData id;
-    id.threadHook = new pjlibHook();
-    id.properties = getCommunicator()->getProperties();
-
-    // To use our thread-hook, we need to set an alternate 
-    // communicator in our Component base. 
-    setCommunicator(Ice::initialize(id));
 }
 
 /**
- * Override of factory method to create our custom replication context. 
+ * Override of factory method to create our custom replication context.
  */
 ReplicationContextPtr Component::createReplicationContext(ReplicationStateType state)
 {
@@ -371,14 +307,14 @@ ReplicationContextPtr Component::createReplicationContext(ReplicationStateType s
 }
 
 /**
- * Create the objects that implement the main services this component provides 
+ * Create the objects that implement the main services this component provides
  * the system.
  */
 void Component::createPrimaryServices()
 {
     try
     {
-        RtpReplicationContextPtr rtpReplicationContext = 
+        RtpReplicationContextPtr rtpReplicationContext =
             boost::static_pointer_cast<RtpReplicationContext>(getReplicationContext());
 
         mConfigurationService = ConfigurationServiceImpl::create();
@@ -391,7 +327,7 @@ void Component::createPrimaryServices()
 
         mRtpMediaComparatorService = new RTPMediaServiceCompareServiceImpl(mConfigurationService);
         mRtpMediaComparatorServicePrx = ServiceLocatorParamsComparePrx::uncheckedCast(
-              getServiceAdapter()->add(mRtpMediaComparatorService, 
+              getServiceAdapter()->add(mRtpMediaComparatorService,
                   getCommunicator()->stringToIdentity(MediaComparatorServiceId)));
 
 
@@ -423,7 +359,7 @@ void Component::createPrimaryServices()
             mGeneralState->comparatorId = IceUtil::generateUUID();
             getServiceLocatorManagement()->addCompare(mGeneralState->comparatorId, mRtpMediaComparatorServicePrx);
         }
-    
+
     }
     catch(const Ice::Exception& e)
     {
@@ -437,13 +373,13 @@ void Component::createPrimaryServices()
  */
 void Component::prepareBackplaneServicesForDiscovery()
 {
-    // Insure the default Component services are prepped. 
+    // Insure the default Component services are prepped.
     AsteriskSCF::Component::Component::prepareBackplaneServicesForDiscovery();
 
     try
     {
         // Register our configuration interface with the Service Locator.
-        mConfigurationRegistration = wrapServiceForRegistration(mConfigurationServicePrx, 
+        mConfigurationRegistration = wrapServiceForRegistration(mConfigurationServicePrx,
                                                                 ConfigurationDiscoveryCategory);
         manageBackplaneService(mConfigurationRegistration);
     }
@@ -453,7 +389,7 @@ void Component::prepareBackplaneServicesForDiscovery()
     }
 }
 
-void Component::findRemoteServices() 
+void Component::findRemoteServices()
 {
     if (getReplicationContext()->getState() == ACTIVE_STANDALONE)
     {
@@ -468,14 +404,14 @@ void Component::findRemoteServices()
 
     try
     {
-        RtpReplicationContextPtr rtpReplicationContext = 
+        RtpReplicationContextPtr rtpReplicationContext =
             boost::static_pointer_cast<RtpReplicationContext>(getReplicationContext());
 
         AsteriskSCF::Discovery::SmartProxy<RtpStateReplicatorPrx> pw(getServiceLocator(), replicatorParams, lg);
         rtpReplicationContext->setReplicator(pw);
 
         // Since we're not in standalone mode, we'll get our configuration updates routed via the
-        // replicator service. 
+        // replicator service.
         ConfigurationReplicatorPrx configurationReplicator = ConfigurationReplicatorPrx::checkedCast(
             rtpReplicationContext->getReplicator().initialize(), ReplicatorFacet);
         configurationReplicator->registerConfigurationService(mConfigurationServicePrx);
@@ -491,7 +427,7 @@ void Component::createReplicationStateListeners()
 {
     try
     {
-        RtpReplicationContextPtr rtpReplicationContext = 
+        RtpReplicationContextPtr rtpReplicationContext =
             boost::static_pointer_cast<RtpReplicationContext>(getReplicationContext());
 
        // Create and publish our state replicator listener interface.
@@ -500,7 +436,7 @@ void Component::createReplicationStateListeners()
         RtpStateReplicatorListenerPrx replicatorListener = RtpStateReplicatorListenerPrx::uncheckedCast(
              getBackplaneAdapter()->addWithUUID(mReplicatorListener));
         mReplicatorListenerProxy = RtpStateReplicatorListenerPrx::uncheckedCast(replicatorListener->ice_oneway());
-            
+
         lg(Debug) << "Got proxy to RTP state replicator";
     }
     catch(const Ice::Exception &e)
@@ -512,7 +448,7 @@ void Component::createReplicationStateListeners()
 
 void Component::listenToStateReplicators()
 {
-    RtpReplicationContextPtr rtpReplicationContext = 
+    RtpReplicationContextPtr rtpReplicationContext =
         boost::static_pointer_cast<RtpReplicationContext>(getReplicationContext());
 
     if (mListeningToReplicator == true)
@@ -542,14 +478,14 @@ void Component::listenToStateReplicators()
     }
 }
 
-/** 
- * Unregister as a listener to our state replicator. 
+/**
+ * Unregister as a listener to our state replicator.
  * A component in active mode doesn't neeed to listen to
- * state replication data. 
+ * state replication data.
  */
 void Component::stopListeningToStateReplicators()
 {
-    RtpReplicationContextPtr rtpReplicationContext = 
+    RtpReplicationContextPtr rtpReplicationContext =
         boost::static_pointer_cast<RtpReplicationContext>(getReplicationContext());
 
     if ((!rtpReplicationContext->getReplicator().isInitialized()) || (mListeningToReplicator == false))
@@ -579,11 +515,11 @@ void Component::preparePrimaryServicesForDiscovery()
     {
         mRtpMediaServiceRegistration = wrapServiceForRegistration(mRtpMediaServicePrx,
                                                                   "rtp");
-        managePrimaryService(mRtpMediaServiceRegistration); 
+        managePrimaryService(mRtpMediaServiceRegistration);
     }
         catch(const std::exception& e)
     {
-        lg(Error) << "Unable to publish component interfaces in " << getName() << BOOST_CURRENT_FUNCTION << 
+        lg(Error) << "Unable to publish component interfaces in " << getName() << BOOST_CURRENT_FUNCTION <<
             ". Exception: " << e.what();
         throw; // rethrow
     }
@@ -600,15 +536,15 @@ void Component::onRegisterPrimaryServices()
     mGeneralState->serviceManagement->addLocatorParams(mRtpOverIceLocatorParams, mGeneralState->comparatorId);
 }
 
-void Component::onStart() 
+void Component::onStart()
 {
-    // Note: I don't think this is necessary. If we make the 
+    // Note: I don't think this is necessary. If we make the
     // comparator computed from a "service" identifier (which could default
     // to "default"), there's nothing replicated here that the standby component
-    // couldn't already determine itself. 
+    // couldn't already determine itself.
     if (getReplicationContext()->isReplicating() == true)
     {
-        RtpReplicationContextPtr rtpReplicationContext = 
+        RtpReplicationContextPtr rtpReplicationContext =
             boost::static_pointer_cast<RtpReplicationContext>(getReplicationContext());
 
         RtpStateItemSeq items;
@@ -618,7 +554,7 @@ void Component::onStart()
     }
 }
 
-void Component::onStop() 
+void Component::onStop()
 {
     if (getReplicationContext()->isActive() == true)
     {

commit ca14499ac6e6bf66f3eb5a33bfc4d1a12f6452d2
Author: Brent Eagles <beagles at digium.com>
Date:   Tue Sep 27 12:50:15 2011 -0230

    Comments for the ICE and SRTP related configuration options.

diff --git a/config/Rtp.config b/config/Rtp.config
index e1a99dd..47b975d 100644
--- a/config/Rtp.config
+++ b/config/Rtp.config
@@ -16,3 +16,59 @@ workerthreadcount=4
 
 # IPv6 address we should bind sessions to
 #ipv6bind=
+
+#
+# Enable SRTP support for RTP. If not enabled, attempts to allocate
+# an SRTP media session will fail. Enabled by default.
+#
+# enablesrtp=false
+
+#
+# Configure ICE support for NAT. 
+#
+[rtpoverice]
+
+#
+# Enable the ICE transport. Disbled by default. 
+#
+# rtpovericeenable=false
+
+#
+# Enable including TURN as a NAT traversal option. Default false.
+#
+# rtpovericewithturn=false
+
+# 
+# Set the limits for the number of candidates that will be sussed out. It is
+# usually okay to leave this unset.
+#
+# rtpicemaxcandidates=10
+
+# 
+# Set the maximum number of ICE sessions supported. An ICE media flow 
+# is essentially a negotiated and managed flow between two endpoints, so
+# there is some resource consumption per connection.
+#
+# rtpicemaxcalls=50
+
+#
+# Configure the STUN server hostname. Note that some public STUN servers may
+# not reply in a timely manner so you may need to experiment here.
+#
+# stunserverhost=[insert STUN server host here]
+
+#
+# Configure the STUN server port number. You can usually leave this blank as
+# the default would suffice.
+#
+# stunserverport=3478
+
+#
+# Configure the TURN server hostname. 
+#
+# turnserverhost=[insert TURN server host here]
+
+#
+# Configure the TURN server port
+#
+# turnserverport=3478

commit 79856c7897e1d9552c43e7d368b7c7f0268e3f3d
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue Sep 20 16:01:47 2011 -0500

    Updated the unit test config files for the recent config changes.

diff --git a/config/test_component.conf b/config/test_component.conf
index b0c6d4f..8489207 100644
--- a/config/test_component.conf
+++ b/config/test_component.conf
@@ -15,17 +15,18 @@ Ice.Override.Timeout=5000
 
 IceBox.Service.ServiceDiscovery=service_locator:create
 
-AsteriskSCFIceStorm.InstanceName=AsteriskSCFIceStorm
-AsteriskSCFIceStorm.TopicManager.Endpoints=tcp -p 4421
-AsteriskSCFIceStorm.Publish.Endpoints=tcp -p 4423
-AsteriskSCFIceStorm.Trace.TopicManager=2
-AsteriskSCFIceStorm.Transient=1
-AsteriskSCFIceStorm.Flush.Timeout=2000
-TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:tcp -p 4421
-
-ServiceLocatorManagementAdapter.Endpoints=tcp -p 4422
-ServiceLocatorAdapter.Endpoints=tcp -p 4411
-ServiceLocatorLocalAdapter.Endpoints=tcp -p 4412
+ServiceDiscovery.IceStorm.InstanceName=ServiceDiscovery
+
+ServiceDiscovery.IceStorm.TopicManager.Endpoints=tcp -p 4421
+ServiceDiscovery.IceStorm.Publish.Endpoints=tcp -p 4423
+ServiceDiscovery.IceStorm.Trace.TopicManager=2
+ServiceDiscovery.IceStorm.Transient=1
+ServiceDiscovery.IceStorm.Flush.Timeout=2000
+
+TopicManager.Proxy=ServiceDiscovery/TopicManager:tcp -p 4421
+
+ServiceDiscovery.Management.ServiceAdapter.Endpoints=tcp -p 4412
+ServiceDiscovery.Locator.ServiceAdapter.Endpoints=tcp -p 4411
 
 #
 # RtpStateReplicator Configuration
@@ -36,13 +37,12 @@ IceBox.Service.RtpStateReplicator=RtpStateReplicator:create
 RtpStateReplicator.Adapter.Endpoints=tcp:udp
 
 # IceStorm parameters for the RTP state replicator
-RtpStateReplicatorIceStorm.InstanceName=RtpStateReplicatorIceStorm
-RtpStateReplicatorIceStorm.TopicManager.Endpoints=default -p 10005
-RtpStateReplicatorIceStorm.Publish.Endpoints=default -p 10006
-RtpStateReplicatorIceStorm.Trace.TopicManager=2
-RtpStateReplicatorIceStorm.Transient=1
-RtpStateReplicatorIceStorm.Flush.Timeout=2000
-RtpStateReplicatorTopicManager.Proxy=RtpStateReplicatorIceStorm/TopicManager:default -p 10005
+RtpStateReplicator.IceStorm.InstanceName=RtpStateReplicator
+RtpStateReplicator.IceStorm.TopicManager.Endpoints=default -p 10007
+RtpStateReplicator.IceStorm.Publish.Endpoints=default -p 10008
+RtpStateReplicator.IceStorm.Trace.TopicManager=2
+RtpStateReplicator.IceStorm.Transient=1
+RtpStateReplicator.IceStorm.Flush.Timeout=2000
 
 #
 # media_rtp_pjmedia Configuration
@@ -58,7 +58,7 @@ MediaServiceRTP.ServiceAdapter.Endpoints=tcp -p 4471
 MediaServiceRTP.BackplaneAdapter.Endpoints=tcp -p 4472
 
 # A proxy to the service locator management service
-LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4422
+LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4412
 
 # A proxy to the service locator service
 LocatorService.Proxy=LocatorService:tcp -p 4411
diff --git a/config/test_component_v6.conf b/config/test_component_v6.conf
index 31a76e5..c64742f 100644
--- a/config/test_component_v6.conf
+++ b/config/test_component_v6.conf
@@ -15,17 +15,18 @@ Ice.Override.Timeout=5000
 
 IceBox.Service.ServiceDiscovery=service_locator:create
 
-AsteriskSCFIceStorm.InstanceName=AsteriskSCFIceStorm
-AsteriskSCFIceStorm.TopicManager.Endpoints=tcp -p 4421
-AsteriskSCFIceStorm.Publish.Endpoints=tcp -p 4423
-AsteriskSCFIceStorm.Trace.TopicManager=2
-AsteriskSCFIceStorm.Transient=1
-AsteriskSCFIceStorm.Flush.Timeout=2000
-TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:tcp -p 4421
-
-ServiceLocatorManagementAdapter.Endpoints=tcp -p 4422
-ServiceLocatorAdapter.Endpoints=tcp -p 4411
-ServiceLocatorLocalAdapter.Endpoints=tcp -p 4412
+ServiceDiscovery.IceStorm.InstanceName=ServiceDiscovery
+
+ServiceDiscovery.IceStorm.TopicManager.Endpoints=tcp -p 4421
+ServiceDiscovery.IceStorm.Publish.Endpoints=tcp -p 4423
+ServiceDiscovery.IceStorm.Trace.TopicManager=2
+ServiceDiscovery.IceStorm.Transient=1
+ServiceDiscovery.IceStorm.Flush.Timeout=2000
+
+TopicManager.Proxy=ServiceDiscovery/TopicManager:tcp -p 4421
+
+ServiceDiscovery.Management.ServiceAdapter.Endpoints=tcp -p 4412
+ServiceDiscovery.Locator.ServiceAdapter.Endpoints=tcp -p 4411
 
 #
 # RtpStateReplicator Configuration
@@ -36,13 +37,12 @@ IceBox.Service.RtpStateReplicator=RtpStateReplicator:create
 RtpStateReplicator.Adapter.Endpoints=tcp:udp
 
 # IceStorm parameters for the RTP state replicator
-RtpStateReplicatorIceStorm.InstanceName=RtpStateReplicatorIceStorm
-RtpStateReplicatorIceStorm.TopicManager.Endpoints=default -p 10005
-RtpStateReplicatorIceStorm.Publish.Endpoints=default -p 10006
-RtpStateReplicatorIceStorm.Trace.TopicManager=2
-RtpStateReplicatorIceStorm.Transient=1
-RtpStateReplicatorIceStorm.Flush.Timeout=2000
-RtpStateReplicatorTopicManager.Proxy=RtpStateReplicatorIceStorm/TopicManager:default -p 10005
+RtpStateReplicator.IceStorm.InstanceName=RtpStateReplicator
+RtpStateReplicator.IceStorm.TopicManager.Endpoints=default -p 10007
+RtpStateReplicator.IceStorm.Publish.Endpoints=default -p 10008
+RtpStateReplicator.IceStorm.Trace.TopicManager=2
+RtpStateReplicator.IceStorm.Transient=1
+RtpStateReplicator.IceStorm.Flush.Timeout=2000
 
 #
 # media_rtp_pjmedia Configuration
@@ -58,7 +58,7 @@ MediaServiceRTP.ServiceAdapter.Endpoints=tcp -p 4471
 MediaServiceRTP.BackplaneAdapter.Endpoints=tcp -p 4472
 
 # A proxy to the service locator management service
-LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4422
+LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4412
 
 # A proxy to the service locator service
 LocatorService.Proxy=LocatorService:tcp -p 4411
diff --git a/config/test_rtp_ice.conf b/config/test_rtp_ice.conf
index f672a04..a2ce988 100644
--- a/config/test_rtp_ice.conf
+++ b/config/test_rtp_ice.conf
@@ -47,28 +47,21 @@ IceBox.Service.MediaRTPpjmediaTest=media_rtp_pjmedia_ice_test:create
 
 IceBox.Service.ServiceDiscovery=service_locator:create
 
-AsteriskSCFIceStorm.InstanceName=AsteriskSCFIceStorm
-AsteriskSCFIceStorm.TopicManager.Endpoints=default -p 10000
-AsteriskSCFIceStorm.Publish.Endpoints=tcp -p 10001:udp -p 10001
-AsteriskSCFIceStorm.Trace.TopicManager=2
-AsteriskSCFIceStorm.Transient=1
-AsteriskSCFIceStorm.Flush.Timeout=2000
-TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:default -p 10000
-
-#RtpStateReplicatorIceStorm.InstanceName=RtpStateReplicatorIceStorm
-#RtpStateReplicatorIceStorm.TopicManager.Endpoints=default -p 10005
-#RtpStateReplicatorIceStorm.Publish.Endpoints=default -p 10006
-#RtpStateReplicatorIceStorm.Trace.TopicManager=2
-#RtpStateReplicatorIceStorm.Transient=1
-#RtpStateReplicatorIceStorm.Flush.Timeout=2000
-#RtpStateReplicatorTopicManager.Proxy=RtpStateReplicatorIceStorm/TopicManager:default -p 10005
-
-ServiceLocatorManagementAdapter.Endpoints=tcp -p 4422
-ServiceLocatorAdapter.Endpoints=tcp -p 4411
-ServiceLocatorLocalAdapter.Endpoints=tcp -p 4412
+ServiceDiscovery.IceStorm.InstanceName=ServiceDiscovery
+
+ServiceDiscovery.IceStorm.TopicManager.Endpoints=tcp -p 4421
+ServiceDiscovery.IceStorm.Publish.Endpoints=tcp -p 4423
+ServiceDiscovery.IceStorm.Trace.TopicManager=2
+ServiceDiscovery.IceStorm.Transient=1
+ServiceDiscovery.IceStorm.Flush.Timeout=2000
+
+TopicManager.Proxy=ServiceDiscovery/TopicManager:default -p 4421
+
+ServiceDiscovery.Management.ServiceAdapter.Endpoints=tcp -p 4412
+ServiceDiscovery.Locator.ServiceAdapter.Endpoints=tcp -p 4411
+
+LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4412
 LocatorService.Proxy=LocatorService:tcp -p 4411
 
-LoggerAdapter.Endpoints=default
 Ice.ThreadPool.Client.Size=6
 Ice.ThreadPool.Server.Size=6
-Rtp.Standalone=true

commit e8bce571fe3f100190ecdb614af33aba32baa504
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Sep 19 16:44:51 2011 -0300

    Make the rtp media service component conform to the configuration file in the examples repo.

diff --git a/config/test_component.config b/config/test_component.conf
similarity index 65%
rename from config/test_component.config
rename to config/test_component.conf
index d507786..b0c6d4f 100644
--- a/config/test_component.config
+++ b/config/test_component.conf
@@ -5,70 +5,66 @@
 #
 
 IceBox.InheritProperties=1
-IceBox.LoadOrder=ServiceDiscovery,RtpStateReplicator,MediaRTPpjmedia,MediaRTPpjmediaTest
+IceBox.LoadOrder=ServiceDiscovery,RtpStateReplicator,MediaServiceRTP,MediaRTPpjmediaTest
 
 Ice.Override.Timeout=5000
 
+#
+# Service Locator Configuration
+#
+
+IceBox.Service.ServiceDiscovery=service_locator:create
+
+AsteriskSCFIceStorm.InstanceName=AsteriskSCFIceStorm
+AsteriskSCFIceStorm.TopicManager.Endpoints=tcp -p 4421
+AsteriskSCFIceStorm.Publish.Endpoints=tcp -p 4423
+AsteriskSCFIceStorm.Trace.TopicManager=2
+AsteriskSCFIceStorm.Transient=1
+AsteriskSCFIceStorm.Flush.Timeout=2000
+TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:tcp -p 4421
+
+ServiceLocatorManagementAdapter.Endpoints=tcp -p 4422
+ServiceLocatorAdapter.Endpoints=tcp -p 4411
+ServiceLocatorLocalAdapter.Endpoints=tcp -p 4412
+
+#
 # RtpStateReplicator Configuration
+#
 IceBox.Service.RtpStateReplicator=RtpStateReplicator:create
 
 # Adapter parameters for this component
-RtpStateReplicator.Endpoints=tcp:udp
+RtpStateReplicator.Adapter.Endpoints=tcp:udp
 
-# A proxy to the service locator management service
-LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4422
-
-# A proxy to the service locator service
-LocatorService.Proxy=LocatorService:tcp -p 4411
+# IceStorm parameters for the RTP state replicator
+RtpStateReplicatorIceStorm.InstanceName=RtpStateReplicatorIceStorm
+RtpStateReplicatorIceStorm.TopicManager.Endpoints=default -p 10005
+RtpStateReplicatorIceStorm.Publish.Endpoints=default -p 10006
+RtpStateReplicatorIceStorm.Trace.TopicManager=2
+RtpStateReplicatorIceStorm.Transient=1
+RtpStateReplicatorIceStorm.Flush.Timeout=2000
+RtpStateReplicatorTopicManager.Proxy=RtpStateReplicatorIceStorm/TopicManager:default -p 10005
 
 #
 # media_rtp_pjmedia Configuration
 #
 
-IceBox.Service.MediaRTPpjmedia=media_rtp_pjmedia:create
+IceBox.Service.MediaServiceRTP=media_rtp_pjmedia:create
+
+# Name of this service
+MediaServiceRTP.ServiceName=test
 
 # Adapter parameters for this component
-MediaRTPpjmediaAdapter.Endpoints=default
-MediaRTPpjmediaAdapterLocal.Endpoints=default
-MediaRTPpjmediaAdapterLogger.Endpoints=default
+MediaServiceRTP.ServiceAdapter.Endpoints=tcp -p 4471
+MediaServiceRTP.BackplaneAdapter.Endpoints=tcp -p 4472
 
 # A proxy to the service locator management service
-ServiceLocatorManagementProxy=LocatorServiceManagement:tcp -p 4422
+LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4422
 
 # A proxy to the service locator service
-ServiceLocatorProxy=LocatorService:tcp -p 4411
+LocatorService.Proxy=LocatorService:tcp -p 4411
 
 #
 # media_rtp_pjmedia_test Configuration
 #
 
 IceBox.Service.MediaRTPpjmediaTest=media_rtp_pjmedia_test:create
-
-#
-# Service Locator Configuration
-#
-
-IceBox.Service.ServiceDiscovery=service_locator:create
-
-AsteriskSCFIceStorm.InstanceName=AsteriskSCFIceStorm
-AsteriskSCFIceStorm.TopicManager.Endpoints=default -p 10000
-AsteriskSCFIceStorm.Publish.Endpoints=tcp -p 10001:udp -p 10001
-AsteriskSCFIceStorm.Trace.TopicManager=2
-AsteriskSCFIceStorm.Transient=1
-AsteriskSCFIceStorm.Flush.Timeout=2000
-TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:default -p 10000
-
-RtpStateReplicatorIceStorm.InstanceName=RtpStateReplicatorIceStorm
-RtpStateReplicatorIceStorm.TopicManager.Endpoints=default -p 10005
-RtpStateReplicatorIceStorm.Publish.Endpoints=default -p 10006
-RtpStateReplicatorIceStorm.Trace.TopicManager=2
-RtpStateReplicatorIceStorm.Transient=1
-RtpStateReplicatorIceStorm.Flush.Timeout=2000
-RtpStateReplicatorTopicManager.Proxy=RtpStateReplicatorIceStorm/TopicManager:default -p 10005
-
-ServiceLocatorManagementAdapter.Endpoints=tcp -p 4422
-ServiceLocatorAdapter.Endpoints=tcp -p 4411
-ServiceLocatorLocalAdapter.Endpoints=tcp -p 4412
-LocatorService.Proxy=LocatorService:tcp -p 4411
-
-LoggerAdapter.Endpoints=default
diff --git a/config/test_component_v6.config b/config/test_component_v6.conf
similarity index 65%
rename from config/test_component_v6.config
rename to config/test_component_v6.conf
index 7349902..31a76e5 100644
--- a/config/test_component_v6.config
+++ b/config/test_component_v6.conf
@@ -5,70 +5,66 @@
 #
 
 IceBox.InheritProperties=1
-IceBox.LoadOrder=ServiceDiscovery,RtpStateReplicator,MediaRTPpjmedia,MediaRTPpjmediaTest
+IceBox.LoadOrder=ServiceDiscovery,RtpStateReplicator,MediaServiceRTP,MediaRTPpjmediaTest
 
 Ice.Override.Timeout=5000
 
+#
+# Service Locator Configuration
+#
+
+IceBox.Service.ServiceDiscovery=service_locator:create
+
+AsteriskSCFIceStorm.InstanceName=AsteriskSCFIceStorm
+AsteriskSCFIceStorm.TopicManager.Endpoints=tcp -p 4421
+AsteriskSCFIceStorm.Publish.Endpoints=tcp -p 4423
+AsteriskSCFIceStorm.Trace.TopicManager=2
+AsteriskSCFIceStorm.Transient=1
+AsteriskSCFIceStorm.Flush.Timeout=2000
+TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:tcp -p 4421
+
+ServiceLocatorManagementAdapter.Endpoints=tcp -p 4422
+ServiceLocatorAdapter.Endpoints=tcp -p 4411
+ServiceLocatorLocalAdapter.Endpoints=tcp -p 4412
+
+#
 # RtpStateReplicator Configuration
+#
 IceBox.Service.RtpStateReplicator=RtpStateReplicator:create
 
 # Adapter parameters for this component
-RtpStateReplicator.Endpoints=tcp:udp
+RtpStateReplicator.Adapter.Endpoints=tcp:udp
 
-# A proxy to the service locator management service
-LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4422
-
-# A proxy to the service locator service
-LocatorService.Proxy=LocatorService:tcp -p 4411
+# IceStorm parameters for the RTP state replicator
+RtpStateReplicatorIceStorm.InstanceName=RtpStateReplicatorIceStorm
+RtpStateReplicatorIceStorm.TopicManager.Endpoints=default -p 10005
+RtpStateReplicatorIceStorm.Publish.Endpoints=default -p 10006
+RtpStateReplicatorIceStorm.Trace.TopicManager=2
+RtpStateReplicatorIceStorm.Transient=1
+RtpStateReplicatorIceStorm.Flush.Timeout=2000
+RtpStateReplicatorTopicManager.Proxy=RtpStateReplicatorIceStorm/TopicManager:default -p 10005
 
 #
 # media_rtp_pjmedia Configuration
 #
 
-IceBox.Service.MediaRTPpjmedia=media_rtp_pjmedia:create
+IceBox.Service.MediaServiceRTP=media_rtp_pjmedia:create
+
+# Name of this service
+MediaServiceRTP.ServiceName=test
 
 # Adapter parameters for this component
-MediaRTPpjmediaAdapter.Endpoints=default
-MediaRTPpjmediaAdapterLocal.Endpoints=default
-MediaRTPpjmediaAdapterLogger.Endpoints=default
+MediaServiceRTP.ServiceAdapter.Endpoints=tcp -p 4471
+MediaServiceRTP.BackplaneAdapter.Endpoints=tcp -p 4472
 
 # A proxy to the service locator management service
-ServiceLocatorManagementProxy=LocatorServiceManagement:tcp -p 4422
+LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4422
 
 # A proxy to the service locator service
-ServiceLocatorProxy=LocatorService:tcp -p 4411
+LocatorService.Proxy=LocatorService:tcp -p 4411
 
 #
 # media_rtp_pjmedia_test Configuration
 #
 
 IceBox.Service.MediaRTPpjmediaTest=media_rtp_pjmedia_test_v6:create
-
-#
-# Service Locator Configuration
-#
-
-IceBox.Service.ServiceDiscovery=service_locator:create
-
-AsteriskSCFIceStorm.InstanceName=AsteriskSCFIceStorm
-AsteriskSCFIceStorm.TopicManager.Endpoints=default -p 10000
-AsteriskSCFIceStorm.Publish.Endpoints=tcp -p 10001:udp -p 10001
-AsteriskSCFIceStorm.Trace.TopicManager=2
-AsteriskSCFIceStorm.Transient=1
-AsteriskSCFIceStorm.Flush.Timeout=2000
-TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:default -p 10000
-
-RtpStateReplicatorIceStorm.InstanceName=RtpStateReplicatorIceStorm
-RtpStateReplicatorIceStorm.TopicManager.Endpoints=default -p 10005
-RtpStateReplicatorIceStorm.Publish.Endpoints=default -p 10006
-RtpStateReplicatorIceStorm.Trace.TopicManager=2
-RtpStateReplicatorIceStorm.Transient=1
-RtpStateReplicatorIceStorm.Flush.Timeout=2000
-RtpStateReplicatorTopicManager.Proxy=RtpStateReplicatorIceStorm/TopicManager:default -p 10005
-
-ServiceLocatorManagementAdapter.Endpoints=tcp -p 4422
-ServiceLocatorAdapter.Endpoints=tcp -p 4411
-ServiceLocatorLocalAdapter.Endpoints=tcp -p 4412
-LocatorService.Proxy=LocatorService:tcp -p 4411
-
-LoggerAdapter.Endpoints=default
diff --git a/config/test_media_rtp_pjmedia.conf b/config/test_media_rtp_pjmedia.conf
deleted file mode 100644
index 480a7ae..0000000
--- a/config/test_media_rtp_pjmedia.conf
+++ /dev/null
@@ -1,17 +0,0 @@
-# This is a configuration file used in conjunction with the pjmedia rtp component test driver
-IceBox.InheritProperties=1
-IceBox.Service.MediaRTPpjmedia=media_rtp_pjmedia:create
-
-# Adapter parameters for this component
-MediaRTPpjmediaAdapter.Endpoints=tcp -p 4423
-MediaRTPpjmediaAdapterLogger.Endpoints=default -h 127.0.0.1
-MediaRTPpjmediaAdapterLocal.Endpoints=tcp -p 4424
-
-# A proxy to the service locator management service
-ServiceLocatorManagementProxy=LocatorServiceManagement:tcp -p 4422
-
-# A proxy to the service locator service
-ServiceLocatorProxy=LocatorService:tcp -p 4411
-LocatorService.Proxy=LocatorService:tcp -p 4411
-
-TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:default -p 10000
diff --git a/config/test_rtp_ice.config b/config/test_rtp_ice.conf
similarity index 100%
rename from config/test_rtp_ice.config
rename to config/test_rtp_ice.conf
diff --git a/src/Component.cpp b/src/Component.cpp
index 9530a1f..2b4b3a2 100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@ -397,6 +397,9 @@ void Component::createPrimaryServices()
 
         mRtpOverIceLocatorParams = new RTPOverICEServiceLocatorParams;
         mRtpOverIceLocatorParams->category = "rtp";
+        mRtpOverIceLocatorParams->service =
+            getCommunicator()->getProperties()->getPropertyWithDefault(getName() + ".ServiceName", "default");
+        mRtpOverIceLocatorParams->id = getName();
         PJMediaEnvironmentPtr mediaEnvironment = mRtpMediaServicePtr->getEnvironment();
 
         //
@@ -461,7 +464,7 @@ void Component::findRemoteServices()
     ServiceLocatorParamsPtr replicatorParams = new ServiceLocatorParams();
     replicatorParams->category = StateReplicatorDiscoveryCategory;
     replicatorParams->service =
-        getCommunicator()->getProperties()->getPropertyWithDefault("Rtp.StateReplicatorService", "default");
+        getCommunicator()->getProperties()->getPropertyWithDefault(getName() + ".StateReplicatorService", "default");
 
     try
     {
diff --git a/src/RtpStateReplicatorApp.cpp b/src/RtpStateReplicatorApp.cpp
index 4de161e..d7fb661 100644
--- a/src/RtpStateReplicatorApp.cpp
+++ b/src/RtpStateReplicatorApp.cpp
@@ -170,7 +170,7 @@ void RtpStateReplicatorService::registerWithServiceLocator(const Ice::Communicat
         // Add category as a parameter to enable other components look this component up.
         ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
         genericparams->category = AsteriskSCF::Replication::MediaRTPPJMedia::V1::StateReplicatorComponentCategory;
-        genericparams->service =  ic->getProperties()->getPropertyWithDefault("RtpStateReplicator.Service", "default");
+        genericparams->service =  ic->getProperties()->getPropertyWithDefault(mAppName + ".ServiceName", "default");
         genericparams->id = mAppName;
         mComponentServiceManagement->addLocatorParams(genericparams, "");
 
@@ -183,7 +183,7 @@ void RtpStateReplicatorService::registerWithServiceLocator(const Ice::Communicat
 
         ServiceLocatorParamsPtr discoveryParams = new ServiceLocatorParams;
         discoveryParams->category = AsteriskSCF::Replication::MediaRTPPJMedia::V1::StateReplicatorDiscoveryCategory;
-        discoveryParams->service = ic->getProperties()->getPropertyWithDefault("RtpStateReplicator.Service", "default");
+        discoveryParams->service = ic->getProperties()->getPropertyWithDefault(mAppName + ".ServiceName", "default");
         discoveryParams->id = mAppName;
         mStateReplicationManagement->addLocatorParams(discoveryParams, "");
 
@@ -194,7 +194,7 @@ void RtpStateReplicatorService::registerWithServiceLocator(const Ice::Communicat
         // Populate the configuration parameters with details so we can be found
         ServiceLocatorParamsPtr configurationParams = new ServiceLocatorParams();
         configurationParams->category = ConfigurationDiscoveryCategory;
-        configurationParams->service = ic->getProperties()->getPropertyWithDefault("RtpConfiguration.Service", "default");
+        configurationParams->service = ic->getProperties()->getPropertyWithDefault(mAppName + ".ServiceName", "default");
         configurationParams->id = mAppName;
         mConfigurationManagement->addLocatorParams(configurationParams, "");
 
@@ -226,10 +226,9 @@ void RtpStateReplicatorService::deregisterFromServiceLocator()
 
 void RtpStateReplicatorService::initialize(const string& appName, const Ice::CommunicatorPtr& ic)
 {
-    mIceStorm = new CollocatedIceStorm("RtpStateReplicatorIceStorm", ic->getProperties());
+    mIceStorm = new CollocatedIceStorm(appName, ic->getProperties());
 
-    IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(
-    ic->propertyToProxy("RtpStateReplicatorTopicManager.Proxy"));
+    IceStorm::TopicManagerPrx topicManager = mIceStorm->createTopicManagerProxy(ic);
 
     IceStorm::TopicPrx topic;
 
@@ -260,7 +259,7 @@ void RtpStateReplicatorService::initialize(const string& appName, const Ice::Com
         lg(Info) << "IceStorm topic manager proxy not present, unable to perform configuration replication.";
     }
 
-    mAdapter = ic->createObjectAdapter("RtpStateReplicator");
+    mAdapter = ic->createObjectAdapter(appName + ".Adapter");
 
     // setup logging client
     mIceLogger = createIceLogger(mAdapter);
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index f5195f5..024dbe6 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -28,6 +28,6 @@ astscf_component_add_slice_collection_libraries(media_rtp_pjmedia_ice_test ASTSC
 astscf_component_build_icebox(media_rtp_pjmedia_ice_test)
 pjproject_link(media_rtp_pjmedia_ice_test pjlib)
 
-astscf_test_icebox(media_rtp_pjmedia_test config/test_component.config)
-astscf_test_icebox(media_rtp_pjmedia_test_v6 config/test_component_v6.config)
-astscf_test_icebox(media_rtp_pjmedia_ice_test config/test_rtp_ice.config)
+astscf_test_icebox(media_rtp_pjmedia_test config/test_component.conf)
+astscf_test_icebox(media_rtp_pjmedia_test_v6 config/test_component_v6.conf)
+astscf_test_icebox(media_rtp_pjmedia_ice_test config/test_rtp_ice.conf)

commit 34d0513bcbe9db15aed100eb38635f7d7de7eb20
Author: Brent Eagles <beagles at digium.com>
Date:   Fri Sep 16 14:25:22 2011 -0230

    Fix Winsock/Winsock2 build errors on Windows.

diff --git a/src/RTPSink.cpp b/src/RTPSink.cpp
index da5d45a..4f4eec6 100644
--- a/src/RTPSink.cpp
+++ b/src/RTPSink.cpp
@@ -14,18 +14,25 @@
  * at the top of the source tree.
  */
 
+//
+// It is annoying that #include <windows.h> pulls in the old version of winsock. The fix is to include
+// winsock2 first.
+//
+#ifdef _WIN32
+#include <WinSock2.h>
+#endif
+
 #include "RTPSink.h"
 #include "RtpStateReplicationIf.h"
 #include "RTPTelephonyEventSink.h"
 
-#include <pjlib.h>
-#include <pjmedia.h>
-
 #include <Ice/Ice.h>
 #include <IceUtil/UUID.h>
-
 #include <boost/asio/detail/socket_ops.hpp>
 
+#include <pjlib.h>
+#include <pjmedia.h>
+
 #include <AsteriskSCF/Media/MediaIf.h>
 #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
 #include <AsteriskSCF/System/Component/ReplicaIf.h>
diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index b9bf4f1..ea81708 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -14,19 +14,27 @@
  * at the top of the source tree.
  */
 
+//
+// It is annoying that #include <windows.h> pulls in the old version of winsock. The fix is to include
+// winsock2 first.
+//
+#ifdef _WIN32
+#include <WinSock2.h>
+#endif
+
+#include "RTPTelephonyEventSource.h"
 #include "RTPSource.h"
 #include "RtpStateReplicationIf.h"
-#include "RTPTelephonyEventSource.h"
-
-#include <pjlib.h>
-#include <pjmedia.h>
 
 #include <Ice/Ice.h>
 #include <IceUtil/UUID.h>
 #include <IceUtil/Timer.h>
 
-#include <boost/thread.hpp>
 #include <boost/asio/detail/socket_ops.hpp>
+#include <boost/thread.hpp>
+
+#include <pjlib.h>
+#include <pjmedia.h>
 
 #include <AsteriskSCF/Media/MediaIf.h>
 #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
diff --git a/src/RTPTelephonyEventSink.cpp b/src/RTPTelephonyEventSink.cpp
index 82cf3a7..0e62dd2 100644
--- a/src/RTPTelephonyEventSink.cpp
+++ b/src/RTPTelephonyEventSink.cpp
@@ -18,6 +18,7 @@
 
 #include <AsteriskSCF/Media/Formats/OtherFormats.h>
 #include <IceUtil/UUID.h>
+#include <pjmedia.h>
 
 namespace
 {
@@ -184,7 +185,7 @@ void RTPTelephonyEventSink::getSource_async(
     cb->ice_response(mStateItem->source);
 }
 
-pj_uint8_t RTPTelephonyEventSink::translateDTMF(Ice::Byte signal)
+unsigned char RTPTelephonyEventSink::translateDTMF(Ice::Byte signal)
 {
     if (signal >= '0' && signal <= '9')
     {
diff --git a/src/RTPTelephonyEventSink.h b/src/RTPTelephonyEventSink.h
index 407c1b2..fe458a1 100644
--- a/src/RTPTelephonyEventSink.h
+++ b/src/RTPTelephonyEventSink.h
@@ -16,13 +16,17 @@
 
 #pragma once
 
-#include <pjmedia.h>
 #include <AsteriskSCF/Replication/MediaRTPPJMedia/RtpStateReplicationIf.h>
 #include <AsteriskSCF/SessionCommunications/TelephonyEventsIf.h>
 
 #include "PJMediaTransport.h"
 #include "SessionAdapter.h"
 
+//
+// Forward declarations for pjmedia.
+//
+struct pjmedia_rtp_session;
+
 class RTPTelephonyEventSink : public AsteriskSCF::SessionCommunications::V1::TelephonyEventSink
 {
 public:
@@ -64,7 +68,7 @@ private:
     /**
      * Translate DTMF from ASCII into its RFC 4733-designated payload value
      */
-    pj_uint8_t translateDTMF(Ice::Byte signal);
+    unsigned char translateDTMF(Ice::Byte signal);
 
     /**
      * Replicate state
diff --git a/src/RTPTelephonyEventSource.cpp b/src/RTPTelephonyEventSource.cpp
index 3a6631a..5024232 100644
--- a/src/RTPTelephonyEventSource.cpp
+++ b/src/RTPTelephonyEventSource.cpp
@@ -205,7 +205,7 @@ void RTPTelephonyEventSource::distributeToSinks(const TelephonyEventPtr& event)
 
 // This function does no bounds checking and assumes that whoever
 // calls it will not call into it with invalid input (i.e. event > 15)
-Ice::Byte RTPTelephonyEventSource::translateDTMF(pj_uint8_t event)
+Ice::Byte RTPTelephonyEventSource::translateDTMF(unsigned char event)
 {
     if (event < 10)
     {
diff --git a/src/RTPTelephonyEventSource.h b/src/RTPTelephonyEventSource.h
index cd7eb13..cb315a6 100644
--- a/src/RTPTelephonyEventSource.h
+++ b/src/RTPTelephonyEventSource.h
@@ -20,11 +20,14 @@
 
 #include <AsteriskSCF/SessionCommunications/TelephonyEventsIf.h>
 #include <AsteriskSCF/Replication/MediaRTPPJMedia/RtpStateReplicationIf.h>
-
-#include <pjmedia.h>
-
 #include "SessionAdapter.h"
 
+//
+// Forward declarations for pjmedia.
+//
+struct pjmedia_rtp_hdr;
+struct pjmedia_rtp_dtmf_event;
+
 class RTPTelephonyEventSource : public AsteriskSCF::SessionCommunications::V1::TelephonyEventSource
 {
 public:
@@ -93,7 +96,7 @@ private:
     /**
      * Translate DTMF from its RFC 4733 event payload to ASCII representation
      */
-    Ice::Byte translateDTMF(pj_uint8_t event);
+    Ice::Byte translateDTMF(unsigned char event);
 
     /**
      * Replicate state to replicas

commit 458c78b6a0b5ca95265fb2ff8ad1ebbf0c2228ac
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Sep 14 17:44:59 2011 -0500

    Fix compilation problem in RtpStateReplicatorListener

diff --git a/src/RtpStateReplicatorListener.cpp b/src/RtpStateReplicatorListener.cpp
index e3edc22..95fbef3 100644
--- a/src/RtpStateReplicatorListener.cpp
+++ b/src/RtpStateReplicatorListener.cpp
@@ -112,9 +112,11 @@ public:
                     localitem = newitem;
                     mImpl->mStateItems.insert(make_pair(item->sessionId, newitem));
 
+                    RTPAllocationOutputsPtr outputs (new RTPAllocationOutputs);
+
                     localitem->setSession(
                          AsteriskSCF::PJMediaRTP::RTPSession::create(mImpl->mAdapter, mImpl->mEnvironment, item,
-                                    mImpl->mReplicationContext, mImpl->mConfigurationService));
+                                    mImpl->mReplicationContext, mImpl->mConfigurationService, item->options, outputs));
                 }
                 else
                 {

commit a042827c7bd657208756eb8176fb9b59c7ba60a8
Merge: 415cb5b 7743183
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Sep 14 16:52:15 2011 -0500

    Merge branch 'telephony-events2'
    
    Conflicts:
    	src/CMakeLists.txt
    	src/MediaRTPpjmedia.cpp
    	src/RTPSession.cpp
    	src/RTPSession.h
    	src/RtpStateReplicatorListener.cpp
    	test/TestRTPpjmedia.cpp

diff --cc src/CMakeLists.txt
index 28e729d,b1ca3d0..d130546
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@@ -2,14 -2,17 +2,18 @@@ include_directories(${astscf-ice-util-c
  include_directories(${logger_dir}/include)
  
  astscf_component_init(media_rtp_pjmedia)
 -astscf_component_add_files(media_rtp_pjmedia MediaRTPpjmedia.cpp)
 +astscf_component_add_files(media_rtp_pjmedia Component.cpp)
  astscf_component_add_files(media_rtp_pjmedia RTPSession.cpp)
  astscf_component_add_files(media_rtp_pjmedia RTPSource.cpp)
+ astscf_component_add_files(media_rtp_pjmedia RTPTelephonyEventSource.cpp)
  astscf_component_add_files(media_rtp_pjmedia RTPSink.cpp)
+ astscf_component_add_files(media_rtp_pjmedia RTPTelephonyEventSink.cpp)
  astscf_component_add_files(media_rtp_pjmedia RTPSession.h)
  astscf_component_add_files(media_rtp_pjmedia RTPSource.h)
+ astscf_component_add_files(media_rtp_pjmedia RTPTelephonyEventSource.h)
  astscf_component_add_files(media_rtp_pjmedia RTPSink.h)
 +astscf_component_add_files(media_rtp_pjmedia RtpReplicationContext.h)
+ astscf_component_add_files(media_rtp_pjmedia RTPTelephonyEventSink.h)
  astscf_component_add_files(media_rtp_pjmedia RtpStateReplicatorListener.cpp)
  astscf_component_add_files(media_rtp_pjmedia RtpStateReplicator.h)
  astscf_component_add_files(media_rtp_pjmedia RTPConfiguration.cpp)
diff --cc src/Component.cpp
index c029909,0000000..9530a1f
mode 100644,000000..100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@@ -1,621 -1,0 +1,637 @@@
 +/*
 + * 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 <pjlib.h>
 +#include <pjmedia.h>
 +
 +#include <Ice/Ice.h>
 +#include <IceBox/IceBox.h>
 +#include <IceUtil/UUID.h>
 +
 +#include <boost/shared_ptr.hpp>
 +
 +#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
 +#include <AsteriskSCF/Media/MediaIf.h>
 +#include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
 +#include <AsteriskSCF/System/Component/ConfigurationIf.h>
 +#include <AsteriskSCF/Logger/IceLogger.h>
 +#include <AsteriskSCF/logger.h>
 +#include <AsteriskSCF/Discovery/SmartProxy.h>
 +#include <AsteriskSCF/Component/Component.h>
 +
 +#include "RtpReplicationContext.h"
 +#include "RTPSession.h"
 +#include "RtpStateReplicator.h"
 +#include "RTPConfiguration.h"
 +#include "RtpConfigurationIf.h"
 +#include "PJMediaEnvironment.h"
 +
 +using namespace std;
 +using namespace AsteriskSCF::Core::Discovery::V1;
 +using namespace AsteriskSCF::Media::V1;
 +using namespace AsteriskSCF::Media::RTP::V1;
 +using namespace AsteriskSCF::Replication::MediaRTPPJMedia::V1;
 +using namespace AsteriskSCF::Configuration::MediaRTPPJMedia::V1;
 +using namespace AsteriskSCF::System::Configuration::V1;
 +using namespace AsteriskSCF::System::Component::V1;
 +using namespace AsteriskSCF::System::Logging;
 +using namespace AsteriskSCF::Discovery;
 +using namespace AsteriskSCF::Replication;
 +using namespace AsteriskSCF::PJMediaRTP;
 +
 +namespace
 +{
 +Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaRTP");
 +}
 +
 +static const string ReplicaServiceId("MediaRtpReplica");
 +static const string MediaServiceId("RTPMediaService");
 +static const string MediaComparatorServiceId("RTPMediaServiceComparator");
 +
 +/**
 + * Implementation of the RTPMediaService interface as defined in MediaRTPIf.ice
 + */
 +class RTPMediaServiceImpl : public RTPMediaService
 +{
 +public:
 +    RTPMediaServiceImpl(const Ice::ObjectAdapterPtr&, 
 +      const RtpReplicationContextPtr& replicationContext,
 +      const ConfigurationServiceImplPtr&);
 +
-     RTPSessionPrx allocate(const RTPServiceLocatorParamsPtr&, const Ice::Current&);
++    RTPSessionPrx allocate(
++            const RTPServiceLocatorParamsPtr&,
++            const RTPOptionsPtr&,
++            RTPAllocationOutputsPtr&,
++            const Ice::Current&);
++
 +    pj_pool_factory *getPoolFactory() { return mEnvironment->poolFactory(); };
 +
 +    PJMediaEnvironmentPtr getEnvironment()
 +    {
 +        return mEnvironment;
 +    }
 +
 +private:
 +    Ice::ObjectAdapterPtr mAdapter;
 +    PJMediaEnvironmentPtr mEnvironment;
 +    RtpReplicationContextPtr mReplicationContext;
 +    ConfigurationServiceImplPtr mConfigurationService;
 +
 +#if CONTROL_POINTS_ENABLED
 +    AsteriskSCF::PJMediaRTPTesting mMediaServiceSwitchBoard;
 +#endif
 +};
 +
 +/**
 + * Typedef which gives us a smart pointer type for RTPMediaServiceImpl class.
 + */
 +typedef IceUtil::Handle<RTPMediaServiceImpl> RTPMediaServiceImplPtr;
 +
 +/**
 + * Implementation of the ServiceLocatorParamsCompare class
 + */
 +class RTPMediaServiceCompareServiceImpl : public ServiceLocatorParamsCompare
 +{
 +public:
 +    RTPMediaServiceCompareServiceImpl(const ConfigurationServiceImplPtr& config) :
 +        mConfig(config)
 +    {
 +    }
 +
 +    bool isSupported(const ServiceLocatorParamsPtr& locatorParams, const Ice::Current&)
 +    {
 +    RTPServiceLocatorParamsPtr params;
 +
 +    if (!(params = RTPServiceLocatorParamsPtr::dynamicCast(locatorParams)))
 +    {
 +        return false;
 +    }
 +
 +    bool result = true;
 +
 +    // This is done on purpose for additional checks in the future
 +    if (params->ipv6 == true)
 +    {
 +#if defined(PJ_HAS_IPV6) && PJ_HAS_IPV6!=0
 +        result = true;
 +#else
 +        result = false;
 +#endif
 +    }
 +        //
 +        // We can ignore the SRTP criteria since we support it one way or the other.
 +        //
 +        if (!result)
 +        {
 +            return false;
 +        }
 +        
 +        RTPOverICEServiceLocatorParamsPtr iceParams = RTPOverICEServiceLocatorParamsPtr::dynamicCast(locatorParams);
 +        if (iceParams)
 +        {
 +            if (iceParams->enableRTPOverICE)
 +            {
 +                NATConfigPtr natConfig = mConfig->natConfig();
 +
 +                if (natConfig && natConfig->isSTUNEnabled())
 +                {
 +                    if (iceParams->enableTURN)
 +                    {
 +                        if (!natConfig->isTURNEnabled())
 +                        {
 +                            result = false;
 +                        }
 +                    }
 +                }
 +                else
 +                {
 +                    result = false;
 +                }
 +            }
 +            //
 +            // We ignore the else case because we can definitely do non-ICE related stuff... its not clear
 +            // that negative matches in this case should be exclusionary. Actual ICE usage will be specified
 +            // when the RTP session is allocated.
 +            //
 +        }
 +
 +    return result;
 +    }
 +
 +private:
 +    ConfigurationServiceImplPtr mConfig;
 +};
 +
 +/**
 + * Implementation of the Component class. 
 + */
 +class Component : public AsteriskSCF::Component::Component
 +{
 +public:
 +    Component() : 
 +       AsteriskSCF::Component::Component(lg, AsteriskSCF::Media::RTP::V1::ComponentServiceDiscoveryCategory), 
 +      mListeningToReplicator(false), mGeneralState(new RtpGeneralStateItem()) { mGeneralState->key = IceUtil::generateUUID(); };
 +
 +private:
 +    // Required base Component overrides
 +    virtual void createPrimaryServices();
 +    virtual void preparePrimaryServicesForDiscovery();
 +    virtual void createReplicationStateListeners();
 +    virtual void stopListeningToStateReplicators();
 +    virtual void listenToStateReplicators();
 +    virtual void findRemoteServices();
 +    virtual void onRegisterPrimaryServices();
 +
 +    // Optional base Component notifcation overrides
 +    virtual void onSuspend();
 +    virtual void onResume();
 +    virtual void onPreInitialize();
 +    virtual void onStop();    
 +    virtual void onStart();
 +
 +    // Other base Component overrides
 +    virtual void prepareBackplaneServicesForDiscovery();
 +    ReplicationContextPtr createReplicationContext(ReplicationStateType state);
 +
 +    // A proxy to the service locator manager for the component service.
 +    ServiceManagementPrx mComponentServiceManagement;
 +
 +    // State replicator listener.
 +    RtpStateReplicatorListenerPtr mReplicatorListener;
 +    RtpStateReplicatorListenerPrx mReplicatorListenerProxy;
 +    bool mListeningToReplicator;
 +
 +    // An instance of the general state information class.
 +    RtpGeneralStateItemPtr mGeneralState;
 +
 +    // Media service
 +    RTPMediaServiceImplPtr mRtpMediaServicePtr;
 +    RTPMediaServicePrx mRtpMediaServicePrx;
 +    LocatorRegistrationWrapperPtr mRtpMediaServiceRegistration;
 +
 +    // Media comparator service
 +    ServiceLocatorParamsComparePtr mRtpMediaComparatorService; 
 +    ServiceLocatorParamsComparePrx mRtpMediaComparatorServicePrx;
 +    RTPOverICEServiceLocatorParamsPtr mRtpOverIceLocatorParams;
 +
 +    // Configuration state 
 +    ConfigurationServiceImplPtr mConfigurationService;
 +    ConfigurationServicePrx mConfigurationServicePrx;
 +    LocatorRegistrationWrapperPtr mConfigurationRegistration;
 +};
 +
 +void Component::onSuspend() 
 +{
 +    mGeneralState->serviceManagement->suspend();
 +}
 +
 +void Component::onResume() 
 +{
 +    mGeneralState->serviceManagement->unsuspend();
 +}
 +
 +/**
 + * Wrapper class around pj_thread_desc.
 + */
 +class ThreadDescWrapper
 +{
 +public:
 +    /**
 +     * pjthread thread description information, must persist for the life of the thread
 +     */
 +    pj_thread_desc mDesc;
 +};
 +
 +/**
 + * Type definition used to create a smart pointer for the above.
 + */
 +typedef boost::shared_ptr<ThreadDescWrapper> ThreadDescWrapperPtr;
 +
 +/**
 + * Implementation of the Ice::ThreadNotification class.
 + */
 +class pjlibHook : public Ice::ThreadNotification
 +{
 +public:
 +    /**
 +     * Implementation of the start function which is called when a thread starts.
 +     */
 +    void start()
 +    {
 +        ThreadDescWrapperPtr wrapper = ThreadDescWrapperPtr(new ThreadDescWrapper());
 +        pj_thread_t *thread;
 +        pj_thread_register("ICE Thread", wrapper->mDesc, &thread);
 +        boost::lock_guard<boost::mutex> lock(mLock);
 +        pjThreads.insert(make_pair(thread, wrapper));
 +    }
 +
 +    /**
 +     * Implementation of the stop function which is called when a thread stops.
 +     */
 +    void stop()
 +    {
 +        if (pj_thread_is_registered())
 +        {
 +            boost::lock_guard<boost::mutex> lock(mLock);
 +            pjThreads.erase(pj_thread_this());
 +        }
 +    }
 +private:
 +    /**
 +     * A map containing thread lifetime persistent data.
 +     */
 +    map<pj_thread_t*, ThreadDescWrapperPtr> pjThreads;
 +
 +    /**
 +     * Mutex to protect the map
 +     */
 +    boost::mutex mLock;
 +};
 +
 +/**
 + * Constructor for the RTPMediaServiceImpl class.
 + */
 +RTPMediaServiceImpl::RTPMediaServiceImpl(const Ice::ObjectAdapterPtr& adapter,
 +    const RtpReplicationContextPtr& replicationContext,
 +    const ConfigurationServiceImplPtr& configurationService) :
 +    mAdapter(adapter), 
 +    mEnvironment(PJMediaEnvironment::create(adapter->getCommunicator()->getProperties(), configurationService)),
 +    mReplicationContext(replicationContext), 
 +    mConfigurationService(configurationService)
 +{
 +}
 +
 +/**
 + * Implementation of the allocate method as defined in MediaRTPIf.ice
 + */
- RTPSessionPrx RTPMediaServiceImpl::allocate(const RTPServiceLocatorParamsPtr& params, const Ice::Current&)
++RTPSessionPrx RTPMediaServiceImpl::allocate(
++        const RTPServiceLocatorParamsPtr& params,
++        const RTPOptionsPtr& options,
++        RTPAllocationOutputsPtr& outputs,
++        const Ice::Current&)
 +{
-     return AsteriskSCF::PJMediaRTP::RTPSession::create(mAdapter, IceUtil::generateUUID(), params, mEnvironment,
-             mReplicationContext, mConfigurationService);
++    return AsteriskSCF::PJMediaRTP::RTPSession::create(
++            mAdapter,
++            IceUtil::generateUUID(),
++            params,
++            mEnvironment,
++            mReplicationContext,
++            mConfigurationService,
++            options,
++            outputs);
 +}
 +
 +void Component::onPreInitialize() 
 +{
 +    /* Initialize pjlib as pjmedia will be using it */
 +    pj_status_t status = pj_init();
 +    if (status != PJ_SUCCESS)
 +    {
 +        lg(Error) << "PJ library initialization failed.";
 +        return;
 +    }
 +
 +    if ((status = pjlib_util_init()) != PJ_SUCCESS)
 +    {
 +        lg(Error) << "PJ Utility library initialization failed.";
 +        return;
 +    }
 +
 +    lg(Info) << "Initializing pjmedia rtp component" << endl;
 +
 +    Ice::InitializationData id;
 +    id.threadHook = new pjlibHook();
 +    id.properties = getCommunicator()->getProperties();
 +
 +    // To use our thread-hook, we need to set an alternate 
 +    // communicator in our Component base. 
 +    setCommunicator(Ice::initialize(id));
 +}
 +
 +/**
 + * Override of factory method to create our custom replication context. 
 + */
 +ReplicationContextPtr Component::createReplicationContext(ReplicationStateType state)
 +{
 +    RtpReplicationContextPtr context(new RtpReplicationContext(state));
 +    return context;
 +}
 +
 +/**
 + * Create the objects that implement the main services this component provides 
 + * the system.
 + */
 +void Component::createPrimaryServices()
 +{
 +    try
 +    {
 +        RtpReplicationContextPtr rtpReplicationContext = 
 +            boost::static_pointer_cast<RtpReplicationContext>(getReplicationContext());
 +
 +        mConfigurationService = ConfigurationServiceImpl::create();
 +        mConfigurationServicePrx = mConfigurationService->activate(getBackplaneAdapter(), IceUtil::generateUUID());
 +
 +        mRtpMediaServicePtr =
 +           new RTPMediaServiceImpl(getServiceAdapter(), rtpReplicationContext, mConfigurationService);
 +        mRtpMediaServicePrx = RTPMediaServicePrx::uncheckedCast(getServiceAdapter()->add(mRtpMediaServicePtr,
 +           getCommunicator()->stringToIdentity(MediaServiceId)));
 +
 +        mRtpMediaComparatorService = new RTPMediaServiceCompareServiceImpl(mConfigurationService);
 +        mRtpMediaComparatorServicePrx = ServiceLocatorParamsComparePrx::uncheckedCast(
 +              getServiceAdapter()->add(mRtpMediaComparatorService, 
 +                  getCommunicator()->stringToIdentity(MediaComparatorServiceId)));
 +
 +
 +        mRtpOverIceLocatorParams = new RTPOverICEServiceLocatorParams;
 +        mRtpOverIceLocatorParams->category = "rtp";
 +        PJMediaEnvironmentPtr mediaEnvironment = mRtpMediaServicePtr->getEnvironment();
 +
 +        //
 +        // Service wide configuration is done through properties allowing certain features
 +        // to be completely disabled.
 +        //
 +        NATConfigPtr natConfig = mediaEnvironment->natConfig();
 +        if (natConfig && natConfig->isSTUNEnabled())
 +        {
 +            mRtpOverIceLocatorParams->enableRTPOverICE = true;
 +            mRtpOverIceLocatorParams->enableTURN = natConfig->isTURNEnabled();
 +        }
 +        else
 +        {
 +            mRtpOverIceLocatorParams->enableRTPOverICE = false;
 +            mRtpOverIceLocatorParams->enableTURN = false;
 +        }
 +
 +        if (rtpReplicationContext->isActive() == true)
 +        {
 +            mGeneralState->comparatorId = IceUtil::generateUUID();
 +            getServiceLocatorManagement()->addCompare(mGeneralState->comparatorId, mRtpMediaComparatorServicePrx);
 +        }
 +    
 +    }
 +    catch(const Ice::Exception& e)
 +    {
 +       lg(Critical) << getName() << " : " << BOOST_CURRENT_FUNCTION << " : " << e.what();
 +    }
 +}
 +
 +/**
 + * Prepare this component's backplane interfaces for the Service Locator.
 + * This enables other Asterisk SCF components to locate our interfaces.
 + */
 +void Component::prepareBackplaneServicesForDiscovery()
 +{
 +    // Insure the default Component services are prepped. 
 +    AsteriskSCF::Component::Component::prepareBackplaneServicesForDiscovery();
 +
 +    try
 +    {
 +        // Register our configuration interface with the Service Locator.
 +        mConfigurationRegistration = wrapServiceForRegistration(mConfigurationServicePrx, 
 +                                                                ConfigurationDiscoveryCategory);
 +        manageBackplaneService(mConfigurationRegistration);
 +    }
 +    catch(const std::exception& e)
 +    {
 +        lg(Error) << "Exception in " << getName() << ", " << BOOST_CURRENT_FUNCTION <<  " : " << e.what();
 +    }
 +}
 +
 +void Component::findRemoteServices() 
 +{
 +    if (getReplicationContext()->getState() == ACTIVE_STANDALONE)
 +    {
 +        return;
 +    }
 +
 +    // Look for the configured state replicator or default one
 +    ServiceLocatorParamsPtr replicatorParams = new ServiceLocatorParams();
 +    replicatorParams->category = StateReplicatorDiscoveryCategory;
 +    replicatorParams->service =
 +        getCommunicator()->getProperties()->getPropertyWithDefault("Rtp.StateReplicatorService", "default");
 +
 +    try
 +    {
 +        RtpReplicationContextPtr rtpReplicationContext = 
 +            boost::static_pointer_cast<RtpReplicationContext>(getReplicationContext());
 +
 +        AsteriskSCF::Discovery::SmartProxy<RtpStateReplicatorPrx> pw(getServiceLocator(), replicatorParams, lg);
 +        rtpReplicationContext->setReplicator(pw);
 +
 +        // Since we're not in standalone mode, we'll get our configuration updates routed via the
 +        // replicator service. 
 +        ConfigurationReplicatorPrx configurationReplicator = ConfigurationReplicatorPrx::checkedCast(
 +            rtpReplicationContext->getReplicator().initialize(), ReplicatorFacet);
 +        configurationReplicator->registerConfigurationService(mConfigurationServicePrx);
 +
 +    }
 +    catch (const std::exception& e)
 +    {
 +        lg(Error) << getName() << ": " << BOOST_CURRENT_FUNCTION << " State replicator could not be found, operating without. " << e.what();
 +    }
 +}
 +
 +void Component::createReplicationStateListeners()
 +{
 +    try
 +    {
 +        RtpReplicationContextPtr rtpReplicationContext = 
 +            boost::static_pointer_cast<RtpReplicationContext>(getReplicationContext());
 +
 +       // Create and publish our state replicator listener interface.
 +        mReplicatorListener = new RtpStateReplicatorListenerI(getServiceAdapter(), mRtpMediaServicePtr->getEnvironment(),
 +            mGeneralState, rtpReplicationContext, mConfigurationService);
 +        RtpStateReplicatorListenerPrx replicatorListener = RtpStateReplicatorListenerPrx::uncheckedCast(
 +             getBackplaneAdapter()->addWithUUID(mReplicatorListener));
 +        mReplicatorListenerProxy = RtpStateReplicatorListenerPrx::uncheckedCast(replicatorListener->ice_oneway());
 +            
 +        lg(Debug) << "Got proxy to RTP state replicator";
 +    }
 +    catch(const Ice::Exception &e)
 +    {
 +        lg(Error) << getName() << " in " << BOOST_CURRENT_FUNCTION << " : " << e.what();
 +        throw;
 +    }
 +}
 +
 +void Component::listenToStateReplicators()
 +{
 +    RtpReplicationContextPtr rtpReplicationContext = 
 +        boost::static_pointer_cast<RtpReplicationContext>(getReplicationContext());
 +
 +    if (mListeningToReplicator == true)
 +    {
 +        return;
 +    }
 +
 +    if (!rtpReplicationContext->getReplicator().isInitialized())
 +    {
 +        lg(Error) << getName() << " : State replicator could not be found. Unable to listen for state updates!";
 +        return;
 +    }
 +
 +    try
 +    {
 +        // Are we in standby mode?
 +        if (rtpReplicationContext->getState() == STANDBY_IN_REPLICA_GROUP)
 +        {
 +            rtpReplicationContext->getReplicator()->addListener(mReplicatorListenerProxy);
 +            mListeningToReplicator = true;
 +        }
 +    }
 +    catch (const Ice::Exception& e)
 +    {
 +        lg(Error) << e.what();
 +        throw;
 +    }
 +}
 +
 +/** 
 + * Unregister as a listener to our state replicator. 
 + * A component in active mode doesn't neeed to listen to
 + * state replication data. 
 + */
 +void Component::stopListeningToStateReplicators()
 +{
 +    RtpReplicationContextPtr rtpReplicationContext = 
 +        boost::static_pointer_cast<RtpReplicationContext>(getReplicationContext());
 +
 +    if ((!rtpReplicationContext->getReplicator().isInitialized()) || (mListeningToReplicator == false))
 +    {
 +        return;
 +    }
 +
 +    try
 +    {
 +        rtpReplicationContext->getReplicator()->removeListener(mReplicatorListenerProxy);
 +        mListeningToReplicator = false;
 +    }
 +    catch (const Ice::Exception& e)
 +    {
 +        lg(Error) << e.what();
 +        throw;
 +    }
 +}
 +
 +/**
 + * Prepares this component's primary public interfaces for discovery via the Service Locator.
 + * This enables other Asterisk SCF components to locate the interfaces we are publishing.
 + */
 +void Component::preparePrimaryServicesForDiscovery()
 +{
 +    try
 +    {
 +        mRtpMediaServiceRegistration = wrapServiceForRegistration(mRtpMediaServicePrx,
 +                                                                  "rtp");
 +        managePrimaryService(mRtpMediaServiceRegistration); 
 +    }
 +        catch(const std::exception& e)
 +    {
 +        lg(Error) << "Unable to publish component interfaces in " << getName() << BOOST_CURRENT_FUNCTION << 
 +            ". Exception: " << e.what();
 +        throw; // rethrow
 +    }
 +}
 +
 +void Component::onRegisterPrimaryServices()
 +{
 +    if (getReplicationContext()->isActive() == false)
 +    {
 +        return;
 +    }
 +
 +    mGeneralState->serviceManagement = mRtpMediaServiceRegistration->getServiceManagement();
 +    mGeneralState->serviceManagement->addLocatorParams(mRtpOverIceLocatorParams, mGeneralState->comparatorId);
 +}
 +
 +void Component::onStart() 
 +{
 +    // Note: I don't think this is necessary. If we make the 
 +    // comparator computed from a "service" identifier (which could default
 +    // to "default"), there's nothing replicated here that the standby component
 +    // couldn't already determine itself. 
 +    if (getReplicationContext()->isReplicating() == true)
 +    {
 +        RtpReplicationContextPtr rtpReplicationContext = 
 +            boost::static_pointer_cast<RtpReplicationContext>(getReplicationContext());
 +
 +        RtpStateItemSeq items;
 +        items.push_back(mGeneralState);
 +        RtpStateReplicatorPrx oneway = RtpStateReplicatorPrx::uncheckedCast(rtpReplicationContext->getReplicator()->ice_oneway());
 +        oneway->setState(items);
 +    }
 +}
 +
 +void Component::onStop() 
 +{
 +    if (getReplicationContext()->isActive() == true)
 +    {
 +       mGeneralState->serviceManagement->unregister();
 +    }
 +
 +    if (!mGeneralState->comparatorId.empty())
 +    {
 +        getServiceLocatorManagement()->removeCompare(mGeneralState->comparatorId);
 +    }
 +}
 +
 +extern "C"
 +{
 +ASTSCF_DLL_EXPORT IceBox::Service* create(Ice::CommunicatorPtr)
 +{
 +    return new Component;
 +}
 +}
diff --cc src/RTPSession.cpp
index 9839a19,df04bdc..50416e8
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@@ -144,8 -146,9 +146,8 @@@ public
              const string& id,
              const PJMediaEnvironmentPtr& env,
              const AsteriskSCF::Media::RTP::V1::RTPServiceLocatorParamsPtr& params,
- 	    const RtpReplicationContextPtr& replicationContext,
- 	    const ConfigurationServiceImplPtr&);
 -            const AsteriskSCF::System::Component::V1::ReplicaPrx& replicaControl, 
 -	        const AsteriskSCF::Discovery::SmartProxy<AsteriskSCF::Replication::MediaRTPPJMedia::V1::RtpStateReplicatorPrx>&,
++	        const RtpReplicationContextPtr& replicationContext,
+ 	        const ConfigurationServiceImplPtr&);
      
      RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter,
              const string& sessionIdentity,    
@@@ -154,7 -157,7 +156,7 @@@
              const AsteriskSCF::Media::V1::FormatSeq& formats,
              bool isIPv6,
              bool srtp,
- 	    const RtpReplicationContextPtr& replicationContext,
 -            const AsteriskSCF::Discovery::SmartProxy<AsteriskSCF::Replication::MediaRTPPJMedia::V1::RtpStateReplicatorPrx>&,
++	        const RtpReplicationContextPtr& replicationContext,
              const ConfigurationServiceImplPtr& configurationServant);
  
      ~RTPSessionImpl();
@@@ -434,8 -464,9 +465,8 @@@ RTPSessionImpl::RTPSessionImpl(const Ic
          const string& id,
          const PJMediaEnvironmentPtr& env,
          const RTPServiceLocatorParamsPtr& params,
- 	const RtpReplicationContextPtr& replicationContext,
 -        const ReplicaPrx& replicaService,
 -        const AsteriskSCF::Discovery::SmartProxy<RtpStateReplicatorPrx>& stateReplicator,
 -        const ConfigurationServiceImplPtr& configurationService) :
++	    const RtpReplicationContextPtr& replicationContext,
 +        const ConfigurationServiceImplPtr& configurationService) : 
      mEnvironment(env),
      mEndpoint(PJMediaEndpoint::create(env)),
      mId(id),
@@@ -563,85 -596,6 +594,85 @@@ std::string RTPSessionImpl::getId(cons
      return mId;
  }
  
 +/** 
 + * Local implementation. 
 + */
 +void RTPSessionImpl::setCookies(const AsteriskSCF::Media::V1::SessionCookieDict& cookieMap)
 +{
 +    boost::unique_lock<boost::shared_mutex> lock(mLock);
 +    mSessionStateItem->cookies = cookieMap;
 +}
 +
 +/** 
 + * Support for the corresponding API call. 
 + */
 +void RTPSessionImpl::setCookies(const AsteriskSCF::Media::V1::SessionCookies& cookies, 
 +                const Ice::Current&)
 +{
 +    { // scope the lock
 +        boost::unique_lock<boost::shared_mutex> lock(mLock);
 +        for (AsteriskSCF::Media::V1::SessionCookies::const_iterator i = cookies.begin();
 +             i != cookies.end();  ++i)
 +        {
 +            mSessionStateItem->cookies[(*i)->ice_id()] = (*i);
 +        }
 +    }
 +
 +    if (mReplicationContext->isReplicating() == true)
 +    {
-         replicateState(mSessionStateItem, 0, 0);
++        replicateState(mSessionStateItem, 0, 0, 0, 0);
 +    }
 +}
 +
 +/** 
 + * Implementation of the corresponding API call. 
 + */
 +void RTPSessionImpl::getCookies_async(
 +        const AsteriskSCF::Media::V1::AMD_Session_getCookiesPtr &cb,
 +        const AsteriskSCF::Media::V1::SessionCookies& cookiesToGet, 
 +        const Ice::Current&)
 +{
 +    AsteriskSCF::Media::V1::SessionCookies results;
 +
 +    boost::unique_lock<boost::shared_mutex> lock(mLock);
 +    for (AsteriskSCF::Media::V1::SessionCookies::const_iterator i = cookiesToGet.begin();
 +	    i != cookiesToGet.end();
 +	    ++i)
 +    {
 +	AsteriskSCF::Media::V1::SessionCookieDict::const_iterator cookie = mSessionStateItem->cookies.find((*i)->ice_id());
 +
 +	if (cookie == mSessionStateItem->cookies.end())
 +	{
 +	    continue;
 +	}
 +
 +	results.push_back(cookie->second);
 +    }
 +
 +    cb->ice_response(results);
 +}
 +
 +/** 
 + * Implementation of the corresponding API call. 
 + */
 +void RTPSessionImpl::removeCookies(const AsteriskSCF::Media::V1::SessionCookies& cookies, 
 +                const Ice::Current&)
 +{
 +    { // scope the lock
 +        boost::unique_lock<boost::shared_mutex> lock(mLock);
 +        for (AsteriskSCF::Media::V1::SessionCookies::const_iterator i = cookies.begin();
... 1402 lines suppressed ...


-- 
asterisk-scf/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list