[asterisk-scf-commits] asterisk-scf/integration/media_rtp_pjmedia.git branch "operation-context-propagation" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Feb 7 12:11:47 CST 2012


branch "operation-context-propagation" has been updated
       via  c9b4691cf5552a3a963a5efb3e85fe759d91f2e4 (commit)
       via  40c6241d8fcbfb3f668d7b4c5b701071f29b651d (commit)
       via  15388049c7596f65d76720b0e8d61a94568158b4 (commit)
       via  5dcc557d1502add0161d9aa8b4ffdc14b5bcfba5 (commit)
      from  ad27c6de20b28f7c8d7035ad55e43ffb1153874e (commit)

Summary of changes:
 src/CMakeLists.txt               |    2 +-
 src/ComponentStateReplicator.cpp |  114 ++++++++++++++
 src/RTPStateReplicatorApp.cpp    |  305 --------------------------------------
 test/TestRTPICE.cpp              |    9 +-
 test/TestRTPpjmedia.cpp          |   22 ++-
 5 files changed, 133 insertions(+), 319 deletions(-)
 create mode 100644 src/ComponentStateReplicator.cpp
 delete mode 100644 src/RTPStateReplicatorApp.cpp


- Log -----------------------------------------------------------------
commit c9b4691cf5552a3a963a5efb3e85fe759d91f2e4
Author: Brent Eagles <beagles at digium.com>
Date:   Tue Feb 7 14:41:28 2012 -0330

    Fix up missing signature changes.

diff --git a/test/TestRTPICE.cpp b/test/TestRTPICE.cpp
index bb64c41..85ce649 100644
--- a/test/TestRTPICE.cpp
+++ b/test/TestRTPICE.cpp
@@ -29,6 +29,7 @@
 #include <boost/thread/condition.hpp>
 #include <Ice/Ice.h>
 #include <Ice/BuiltinSequences.h>
+#include <AsteriskSCF/Helpers/OperationContext.h>
 
 #include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
 #include <AsteriskSCF/Media/MediaIf.h>
@@ -181,7 +182,7 @@ BOOST_AUTO_TEST_CASE(RTPSessionWithICEEnabled)
 
         ConfigurationGroupSeq s;
         s.push_back(iceGroup);
-        configPrx->setConfiguration(s);
+        configPrx->setConfiguration(AsteriskSCF::createContext(), s);
 
         RTPMediaServicePrx servicePrx;
         {
@@ -201,7 +202,7 @@ BOOST_AUTO_TEST_CASE(RTPSessionWithICEEnabled)
             RTPSessionPrx sessionPrx;
             RTPOptionsPtr options(new RTPOptions);
             RTPAllocationOutputsPtr outputs(new RTPAllocationOutputs);
-            BOOST_REQUIRE_NO_THROW(sessionPrx = servicePrx->allocate(query, options, outputs));
+            BOOST_REQUIRE_NO_THROW(sessionPrx = servicePrx->allocate(AsteriskSCF::createContext(), query, options, outputs));
             BOOST_REQUIRE(sessionPrx != 0);
             sessionPrx->ice_ping(); // To silence unused arg warning.
             sessionPrx->release();
@@ -248,7 +249,7 @@ BOOST_AUTO_TEST_CASE(RTPSessionAllocationFailure)
         iceGroup->configurationItems[RTPICETransportFlagsItemName] = iceFlags;
         ConfigurationGroupSeq s;
         s.push_back(iceGroup);
-        BOOST_REQUIRE_NO_THROW(configPrx->setConfiguration(s));
+        BOOST_REQUIRE_NO_THROW(configPrx->setConfiguration(AsteriskSCF::createContext(), s));
         try
         {
             RTPOverICEServiceLocatorParamsPtr query = new RTPOverICEServiceLocatorParams;
@@ -257,7 +258,7 @@ BOOST_AUTO_TEST_CASE(RTPSessionAllocationFailure)
             query->enableTURN = true;
             RTPOptionsPtr options(new RTPOptions);
             RTPAllocationOutputsPtr outputs(new RTPAllocationOutputs);
-            RTPSessionPrx sessionPrx = servicePrx->allocate(query, options, outputs);
+            RTPSessionPrx sessionPrx = servicePrx->allocate(AsteriskSCF::createContext(), query, options, outputs);
             sessionPrx->ice_ping();
         }
         catch (const SessionAllocationFailure& ex)
diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index e500af3..1f35b5c 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -36,6 +36,7 @@
 #include <AsteriskSCF/Media/MediaIf.h>
 #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
 #include <AsteriskSCF/Media/RTP/MediaRTCPIf.h>
+#include <AsteriskSCF/Helpers/OperationContext.h>
 
 #include "RTPStateReplicationIf.h"
 #include "TestRTPpjmediaIf.h"
@@ -87,17 +88,20 @@ class TestInformationListener : public RTCP::V1::InformationListener
 public:
     TestInformationListener() : mSsrcChanged(false) { }
 
-    void sourceStatisticsUpdated(const StreamSourceRTPPrx&, const RTCP::V1::StatisticsPtr& statistics, const Ice::Current&)
+    void sourceStatisticsUpdated(const AsteriskSCF::System::V1::OperationContextPtr&,
+        const StreamSourceRTPPrx&, const RTCP::V1::StatisticsPtr& statistics, const Ice::Current&)
     {
         mSourceStatistics = statistics;
     }
 
-    void sinkStatisticsUpdated(const StreamSinkRTPPrx&, const RTCP::V1::StatisticsPtr& statistics, const Ice::Current&)
+    void sinkStatisticsUpdated(const AsteriskSCF::System::V1::OperationContextPtr&,
+        const StreamSinkRTPPrx&, const RTCP::V1::StatisticsPtr& statistics, const Ice::Current&)
     {
         mSinkStatistics = statistics;
     }
 
-    void sourceSsrcChanged(const StreamSourceRTPPrx&, Ice::Int, const Ice::Current&)
+    void sourceSsrcChanged(const AsteriskSCF::System::V1::OperationContextPtr&,
+        const StreamSourceRTPPrx&, Ice::Int, const Ice::Current&)
     {
         mSsrcChanged = true;
     }
@@ -488,7 +492,7 @@ BOOST_AUTO_TEST_CASE(AllocateRTPSession)
         RTPOptionsPtr options(new RTPOptions);
         RTPAllocationOutputsPtr outputs(new RTPAllocationOutputs);
 
-        Testbed.session = service->allocate(params, options, outputs);
+        Testbed.session = service->allocate(AsteriskSCF::createContext(), params, options, outputs);
 
         // Give the RTP component time to replicate this session
         Testbed.mCondition.wait(lock);
@@ -664,7 +668,7 @@ BOOST_AUTO_TEST_CASE(VerifyReplicatedRTCPRemoteDetails)
         RTCP::V1::RTCPSessionPrx session = RTCP::V1::RTCPSessionPrx::checkedCast(Testbed.session,
         RTCP::V1::SessionFacet);
 
-        session->setRemoteDetails(address, 10001);
+        session->setRemoteDetails(AsteriskSCF::createContext(), address, 10001);
     }
     catch (const Ice::Exception &e)
     {
@@ -936,7 +940,7 @@ BOOST_AUTO_TEST_CASE(PushPayloadMappings)
         PayloadMap mapping;
         mapping.insert(make_pair(98, format));
 
-        Testbed.session->associatePayloads(mapping);
+        Testbed.session->associatePayloads(AsteriskSCF::createContext(), mapping);
 
         pushed = true;
     }
@@ -1027,7 +1031,7 @@ BOOST_AUTO_TEST_CASE(SetupRTCPLoopback)
 
         boost::mutex::scoped_lock lock(Testbed.mLock);
 
-        session->setRemoteDetails(address, port);
+        session->setRemoteDetails(AsteriskSCF::createContext(), address, port);
 
         looped = true;
 
@@ -1267,12 +1271,12 @@ BOOST_AUTO_TEST_CASE(ReceiveUnknownRTPPacket)
         RTPOptionsPtr options(new RTPOptions);
         RTPAllocationOutputsPtr outputs(new RTPAllocationOutputs);
 
-        RTPSessionPrx session = service->allocate(params, options, outputs);
+        RTPSessionPrx session = service->allocate(AsteriskSCF::createContext(), params, options, outputs);
 
         PayloadMap mapping;
         mapping.insert(make_pair(13, format));
 
-        session->associatePayloads(mapping);
+        session->associatePayloads(AsteriskSCF::createContext(), mapping);
 
         StreamSourceSeq sources = Testbed.session->getSources();
         StreamSourceRTPPrx source = StreamSourceRTPPrx::uncheckedCast(sources.front());

commit 40c6241d8fcbfb3f668d7b4c5b701071f29b651d
Merge: ad27c6d 1538804
Author: Brent Eagles <beagles at digium.com>
Date:   Tue Feb 7 11:57:14 2012 -0330

    Merge remote-tracking branch 'origin/master' into operation-context-propagation


commit 15388049c7596f65d76720b0e8d61a94568158b4
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Mon Feb 6 11:38:08 2012 -0600

    Correction for file name case change.

diff --git a/src/ComponentStateReplicator.cpp b/src/ComponentStateReplicator.cpp
index 71fb874..3deb18f 100644
--- a/src/ComponentStateReplicator.cpp
+++ b/src/ComponentStateReplicator.cpp
@@ -21,7 +21,7 @@
 #include <AsteriskSCF/Component/ComponentStateReplicator.h>
 #include <AsteriskSCF/System/Component/ComponentServiceIf.h>
 #include <AsteriskSCF/Logger/IceLogger.h>
-#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Logger.h>
 #include <AsteriskSCF/CollocatedIceStorm/CollocatedIceStorm.h>
 #include <AsteriskSCF/System/Component/ConfigurationIf.h>
 
diff --git a/src/RTPStateReplicatorApp.cpp b/src/RTPStateReplicatorApp.cpp
deleted file mode 100644
index 971c80b..0000000
--- a/src/RTPStateReplicatorApp.cpp
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * 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 <Ice/Ice.h>
-#include <IceUtil/UUID.h>
-#include <IceStorm/IceStorm.h>
-#include <IceBox/IceBox.h>
-
-#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
-#include <AsteriskSCF/System/Component/ComponentServiceIf.h>
-#include <AsteriskSCF/Logger/IceLogger.h>
-#include <AsteriskSCF/Logger.h>
-#include <AsteriskSCF/CollocatedIceStorm/CollocatedIceStorm.h>
-#include <AsteriskSCF/System/Component/ConfigurationIf.h>
-
-#include "RTPConfigurationIf.h"
-#include "RTPStateReplicator.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;
-using namespace AsteriskSCF::Replication::MediaRTPPJMEDIA::V1;
-using namespace AsteriskSCF::Configuration::MediaRTPPJMEDIA::V1;
-using namespace AsteriskSCF::CollocatedIceStorm;
-using namespace AsteriskSCF::System::Configuration::V1;
-
-namespace
-{
-Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaRTP");
-}
-
-class RTPStateReplicatorService : public IceBox::Service
-{
-public:
-    RTPStateReplicatorService() { };
-    ~RTPStateReplicatorService()
-    {
-        mComponentService = 0;
-        mAdapter = 0;
-        mStateReplicator = 0;
-    mConfigurationReplicator = 0;
-    };
-    virtual void start(const string &name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq& args);
-    virtual void stop();
-
-private:
-    void initialize(const 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;
-    ConfigurationReplicatorPtr mConfigurationReplicator;
-    CollocatedIceStormPtr mIceStorm;
-    Ice::ObjectPrx mConfigurationPublisher;
-    Discovery::V1::ServiceManagementPrx mConfigurationManagement;
-};
-
-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 ConfigurationReplicatorI : public ConfigurationReplicator
-{
-public:
-    ConfigurationReplicatorI(const IceStorm::TopicPrx& topic) : mConfigurationReplicationTopic(topic) { };
-    void registerConfigurationService(const AsteriskSCF::System::Configuration::V1::ConfigurationServicePrx&, const Ice::Current&);
-private:
-    IceStorm::TopicPrx mConfigurationReplicationTopic;    
-};
-
-void ConfigurationReplicatorI::registerConfigurationService(const AsteriskSCF::System::Configuration::V1::ConfigurationServicePrx& service, const Ice::Current&)
-{
-    if (mConfigurationReplicationTopic)
-    {
-        IceStorm::QoS qos;
-        qos["reliability"] = "ordered";
-    
-        try
-        {
-            mConfigurationReplicationTopic->subscribeAndGetPublisher(qos, service);
-        }
-        catch (const IceStorm::AlreadySubscribed&)
-        {
-            // This is perfectly okay actually, it just means what they wanted us to do
-            // is already done.
-        }
-    }
-}
-
-/**
- * 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 LocatorServiceManagement interface. Check config file. "
-                "This component can't be found until this is corrected.";
-            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::Replication::MediaRTPPJMEDIA::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::Replication::MediaRTPPJMEDIA::V1::StateReplicatorComponentCategory;
-        genericparams->service =  ic->getProperties()->getPropertyWithDefault(mAppName + ".ServiceName", "default");
-        genericparams->id = mAppName;
-        mComponentServiceManagement->addLocatorParams(genericparams, "");
-
-        Ice::ObjectPrx stateReplicatorObjectPrx = mAdapter->createDirectProxy(ic->stringToIdentity(ServiceDiscoveryId));
-        RTPStateReplicatorPrx stateReplicatorPrx = RTPStateReplicatorPrx::checkedCast(stateReplicatorObjectPrx);
-
-        string stateReplicationGuid(AsteriskSCF::Replication::MediaRTPPJMEDIA::V1::StateReplicatorDiscoveryCategory);
-        mStateReplicationManagement = ServiceManagementPrx::uncheckedCast(
-            mServiceLocatorManagement->addService(stateReplicatorPrx, stateReplicationGuid));
-
-        ServiceLocatorParamsPtr discoveryParams = new ServiceLocatorParams;
-        discoveryParams->category = AsteriskSCF::Replication::MediaRTPPJMEDIA::V1::StateReplicatorDiscoveryCategory;
-        discoveryParams->service = ic->getProperties()->getPropertyWithDefault(mAppName + ".ServiceName", "default");
-        discoveryParams->id = mAppName;
-        mStateReplicationManagement->addLocatorParams(discoveryParams, "");
-
-        // Publish the configuration service IceStorm topic so everybody gets configuration
-        mConfigurationManagement = ServiceManagementPrx::uncheckedCast(
-        mServiceLocatorManagement->addService(mConfigurationPublisher, ""));
-
-        // Populate the configuration parameters with details so we can be found
-        ServiceLocatorParamsPtr configurationParams = new ServiceLocatorParams();
-        configurationParams->category = ConfigurationDiscoveryCategory;
-        configurationParams->service = ic->getProperties()->getPropertyWithDefault(mAppName + ".ServiceName", "default");
-        configurationParams->id = mAppName;
-        mConfigurationManagement->addLocatorParams(configurationParams, "");
-
-        // TBD... We may have other interfaces to publish to the Service Locator.
-    }
-    catch(...)
-    {
-        lg(Error) << "Exception in " << mAppName << " registerWithServiceLocator()";
-    }
-}
-
-/**
- * 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();
-        mConfigurationManagement->unregister();
-    }
-    catch(...)
-    {
-        lg(Error) << "Had trouble in deregisterFromServiceLocator().";
-    }
-}
-
-void RTPStateReplicatorService::initialize(const string& appName, const Ice::CommunicatorPtr& ic)
-{
-    mIceStorm = new CollocatedIceStorm(appName, ic->getProperties());
-
-    IceStorm::TopicManagerPrx topicManager = mIceStorm->createTopicManagerProxy(ic);
-
-    IceStorm::TopicPrx topic;
-
-    if (topicManager)
-    {
-        try
-        {
-        topic = topicManager->retrieve("ConfigurationReplication");
-        }
-        catch (const IceStorm::NoSuchTopic&)
-        {
-            try
-            {
-                topic = topicManager->create("ConfigurationReplication");
-            }
-            catch (const IceStorm::TopicExists&)
-            {
-                lg(Error) << "Oh snap! Race condition creating topic, aborting";
-                return;
-            }
-        }
-    // There is no cast here on purpose as this is just going to get passed to
-    // the service locator which just takes a plain ol' proxy anyway.
-    mConfigurationPublisher = topic->getPublisher();
-    }
-    else
-    {
-        lg(Info) << "IceStorm topic manager proxy not present, unable to perform configuration replication.";
-    }
-
-    mAdapter = ic->createObjectAdapter(appName + ".Adapter");
-
-    // 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));
-    mConfigurationReplicator = new ConfigurationReplicatorI(topic);
-    mAdapter->addFacet(mConfigurationReplicator, ic->stringToIdentity(ServiceDiscoveryId),
-    ReplicatorFacet);
-
-    mAdapter->activate();
-}
-
-void RTPStateReplicatorService::start(const string &name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq&)
-{
-    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();
-
-    // Stop our local IceStorm instance
-    mIceStorm->stop();
-}
-
-extern "C"
-{
-ASTSCF_DLL_EXPORT IceBox::Service* create(Ice::CommunicatorPtr)
-{
-    return new RTPStateReplicatorService;
-}
-}
-

commit 5dcc557d1502add0161d9aa8b4ffdc14b5bcfba5
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Mon Feb 6 10:54:54 2012 -0600

    State replicator uses base ComponentStateReplicator class.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8d1cf96..06d14a3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -58,7 +58,7 @@ pjproject_link(MediaRTPPJMEDIA pjnath)
 astscf_component_install(MediaRTPPJMEDIA)
 
 astscf_component_init(RTPStateReplicator)
-astscf_component_add_files(RTPStateReplicator RTPStateReplicatorApp.cpp)
+astscf_component_add_files(RTPStateReplicator ComponentStateReplicator.cpp)
 astscf_component_add_files(RTPStateReplicator RTPStateReplicator.h)
 astscf_component_add_slices(RTPStateReplicator PROJECT AsteriskSCF/Replication/MediaRTPPJMEDIA/RTPStateReplicationIf.ice)
 astscf_component_add_slices(RTPStateReplicator PROJECT AsteriskSCF/Configuration/MediaRTPPJMEDIA/RTPConfigurationIf.ice)
diff --git a/src/ComponentStateReplicator.cpp b/src/ComponentStateReplicator.cpp
new file mode 100644
index 0000000..71fb874
--- /dev/null
+++ b/src/ComponentStateReplicator.cpp
@@ -0,0 +1,114 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#include <pjlib.h>
+
+#include <Ice/Ice.h>
+
+#include <AsteriskSCF/Component/ComponentStateReplicator.h>
+#include <AsteriskSCF/System/Component/ComponentServiceIf.h>
+#include <AsteriskSCF/Logger/IceLogger.h>
+#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/CollocatedIceStorm/CollocatedIceStorm.h>
+#include <AsteriskSCF/System/Component/ConfigurationIf.h>
+
+#include "RTPConfigurationIf.h"
+#include "RTPStateReplicator.h"
+
+using namespace std;
+using namespace AsteriskSCF::Core;
+using namespace AsteriskSCF::Discovery;
+using namespace AsteriskSCF::Core::Discovery::V1;
+using namespace AsteriskSCF::System::Component::V1;
+using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::Media::RTP::V1;
+using namespace AsteriskSCF::Replication::MediaRTPPJMEDIA::V1;
+using namespace AsteriskSCF::Configuration::MediaRTPPJMEDIA::V1;
+
+namespace
+{
+Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaRTP");
+}
+
+class ComponentStateReplicator : public AsteriskSCF::Component::ComponentStateReplicator
+{
+public:
+    ComponentStateReplicator() :
+      AsteriskSCF::Component::ComponentStateReplicator(lg, 
+          AsteriskSCF::Replication::MediaRTPPJMEDIA::V1::StateReplicatorComponentCategory, 
+          true)  // if true, supports configuration
+    {
+    }
+
+    ~ComponentStateReplicator() {};
+
+    ///////////////////////////////////////////////////
+    // Required overrides
+
+    void createPrimaryServices();
+    void preparePrimaryServicesForDiscovery();
+
+private:
+    RTPStateReplicatorIPtr mStateReplicator;
+    RTPStateReplicatorPrx mStateReplicatorPrx;
+    LocatorRegistrationWrapperPtr mStateReplicatorRegistration;
+};
+
+static const string ServiceDiscoveryId("RTPStateReplicatorService");
+
+/**
+ * Register this component's primary public interfaces with the Service Locator.
+ * This enables other Asterisk SCF components to locate our interfaces.
+ */
+void ComponentStateReplicator::preparePrimaryServicesForDiscovery()
+{
+    try
+    {
+        // Wrap our replicator interface for the Service Locator.
+        mStateReplicatorRegistration = wrapServiceForRegistration(mStateReplicatorPrx,
+                                                                  StateReplicatorDiscoveryCategory);
+        managePrimaryService(mStateReplicatorRegistration);
+    }
+    catch(const std::exception& e)
+    {
+        lg(Error) << "Unable to publish component interfaces in " << getName() << BOOST_CURRENT_FUNCTION <<
+            ". Exception: " << e.what();
+        throw; // rethrow
+    }
+}
+
+void ComponentStateReplicator::createPrimaryServices()
+{
+    // Create our instance of the StateReplicator template. 
+    mStateReplicator = new RTPStateReplicatorI;
+    mStateReplicatorPrx = RTPStateReplicatorPrx::uncheckedCast(
+        getServiceAdapter()->add(mStateReplicator, getCommunicator()->stringToIdentity(ServiceDiscoveryId)));
+
+    assert(mStateReplicatorPrx != 0);
+    if(mStateReplicatorPrx == 0)
+    {
+        throw IceBox::FailureException(__FILE__, __LINE__, "Unable to instantiate RTP State Replicator object");
+    }
+}
+
+extern "C"
+{
+ASTSCF_DLL_EXPORT IceBox::Service* create(Ice::CommunicatorPtr)
+{
+    return new ComponentStateReplicator;
+}
+}
+

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list