[asterisk-scf-commits] asterisk-scf/integration/media_rtp_pjmedia.git branch "replication" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Dec 8 06:51:08 CST 2010


branch "replication" has been created
        at  dfff07e4c5f76afe413a808f40a7a75b05849a63 (commit)

- Log -----------------------------------------------------------------
commit dfff07e4c5f76afe413a808f40a7a75b05849a63
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Dec 8 08:40:50 2010 -0400

    Add skeleton listener implementation.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4b3b0a5..a4d07c9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -18,6 +18,8 @@ asterisk_scf_component_add_file(media_rtp_pjmedia RTPSink.cpp)
 asterisk_scf_component_add_file(media_rtp_pjmedia RTPSession.h)
 asterisk_scf_component_add_file(media_rtp_pjmedia RTPSource.h)
 asterisk_scf_component_add_file(media_rtp_pjmedia RTPSink.h)
+asterisk_scf_component_add_file(media_rtp_pjmedia RtpStateReplicatorListener.cpp)
+asterisk_scf_component_add_file(media_rtp_pjmedia RtpStateReplicator.h)
 asterisk_scf_component_add_boost_libraries(media_rtp_pjmedia core thread)
 
 if(NOT logger_dir)
diff --git a/src/RtpStateReplicatorListener.cpp b/src/RtpStateReplicatorListener.cpp
new file mode 100644
index 0000000..d467bd3
--- /dev/null
+++ b/src/RtpStateReplicatorListener.cpp
@@ -0,0 +1,82 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#include <IceUtil/UUID.h>
+
+#include <boost/thread.hpp>
+#include <boost/shared_ptr.hpp>
+
+#include "RtpStateReplicator.h"
+
+using namespace AsteriskSCF::Media::RTP::V1;
+
+class RtpStateReplicatorItem
+{
+public:
+    RtpStateReplicatorItem() { }
+    ~RtpStateReplicatorItem()
+    {
+    }
+
+private:
+};
+
+struct RtpStateReplicatorListenerImpl
+{
+public:
+    RtpStateReplicatorListenerImpl()
+        : mId(IceUtil::generateUUID()) {}
+    void removeStateNoticeImpl(const Ice::StringSeq& itemKeys)
+    {
+        for (Ice::StringSeq::const_iterator key = itemKeys.begin(); key != itemKeys.end(); ++key)
+        {
+            // Just erasing this from the map will cause the destructor to actually shut things down
+            mStateItems.erase((*key));
+        }
+    }
+    void setStateNoticeImpl(const RtpStateItemSeq& items)
+    {
+        for (RtpStateItemSeq::const_iterator item = items.begin(); item != items.end(); ++item)
+        {
+            std::map<std::string, boost::shared_ptr<RtpStateReplicatorItem> >::iterator i = mStateItems.find((*item)->mSessionId);
+        }
+    }
+    std::string mId;
+    std::map<std::string, boost::shared_ptr<RtpStateReplicatorItem> > mStateItems;
+};
+
+RtpStateReplicatorListenerI::RtpStateReplicatorListenerI()
+    : mImpl(new RtpStateReplicatorListenerImpl()) {}
+
+RtpStateReplicatorListenerI::~RtpStateReplicatorListenerI()
+{
+    delete mImpl;
+}
+
+void RtpStateReplicatorListenerI::stateRemoved(const Ice::StringSeq& itemKeys, const Ice::Current&)
+{
+    mImpl->removeStateNoticeImpl(itemKeys);
+}
+
+void RtpStateReplicatorListenerI::stateSet(const RtpStateItemSeq& items, const Ice::Current&)
+{
+    mImpl->setStateNoticeImpl(items);
+}
+
+bool RtpStateReplicatorListenerI::operator==(RtpStateReplicatorListenerI &rhs)
+{
+    return mImpl->mId == rhs.mImpl->mId;
+}

commit 06d305056bfc53aaecc01ea3d65227ad2f124733
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Dec 8 08:24:02 2010 -0400

    Add Rtp state replicator.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index eb0c5ca..4b3b0a5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -33,3 +33,25 @@ pjproject_link(media_rtp_pjmedia pjlib-util)
 pjproject_link(media_rtp_pjmedia pjmedia)
 pjproject_link(media_rtp_pjmedia pjnath)
 #asterisk_scf_component_install(media_rtp_pjmedia RUNTIME bin "pjmedia RTP Media." Media)
+
+asterisk_scf_component_init(RtpStateReplicator CXX)
+
+asterisk_scf_component_add_slice(RtpStateReplicator ServiceLocatorIf)
+asterisk_scf_component_add_slice(RtpStateReplicator ComponentServiceIf)
+asterisk_scf_component_add_slice(RtpStateReplicator SipIf)
+asterisk_scf_component_add_slice(RtpStateReplicator RtpStateReplicationIf)
+asterisk_scf_component_add_slice(RtpStateReplicator RoutingIf)
+asterisk_scf_component_add_slice(RtpStateReplicator MediaRTPIf)
+
+include_directories(${utils_dir}/StateReplicator/src)
+include_directories(${utils_dir}/SmartProxy/src)
+
+asterisk_scf_component_add_file(RtpStateReplicator RtpStateReplicatorApp.cpp)
+asterisk_scf_component_add_file(RtpStateReplicator RtpStateReplicator.h)
+
+asterisk_scf_component_add_ice_libraries(RtpStateReplicator IceStorm)
+
+asterisk_scf_component_add_boost_libraries(RtpStateReplicator thread date_time)
+
+asterisk_scf_component_build_icebox(RtpStateReplicator)
+target_link_libraries(RtpStateReplicator logging-client)
diff --git a/src/RtpStateReplicator.h b/src/RtpStateReplicator.h
new file mode 100644
index 0000000..4741f2b
--- /dev/null
+++ b/src/RtpStateReplicator.h
@@ -0,0 +1,38 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#pragma once
+
+#include <Ice/Ice.h>
+#include "RtpStateReplicationIf.h"
+#include "StateReplicator.h"
+
+using namespace AsteriskSCF::Media::RTP::V1;
+
+typedef AsteriskSCF::StateReplication::StateReplicator<RtpStateReplicator, RtpStateItemPtr, std::string, RtpStateReplicatorListenerPrx> RtpStateReplicatorI;
+typedef IceUtil::Handle<RtpStateReplicatorI> RtpStateReplicatorIPtr;
+
+class RtpStateReplicatorListenerI : public RtpStateReplicatorListener
+{
+public:
+    RtpStateReplicatorListenerI();
+    ~RtpStateReplicatorListenerI();
+    void stateRemoved(const Ice::StringSeq&, const Ice::Current&);
+    void stateSet(const RtpStateItemSeq&, const Ice::Current&);
+    bool operator==(RtpStateReplicatorListenerI &rhs);
+private:
+    struct RtpStateReplicatorListenerImpl *mImpl;
+};
diff --git a/src/RtpStateReplicatorApp.cpp b/src/RtpStateReplicatorApp.cpp
new file mode 100644
index 0000000..7d78c07
--- /dev/null
+++ b/src/RtpStateReplicatorApp.cpp
@@ -0,0 +1,229 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#include <Ice/Ice.h>
+#include <IceUtil/UUID.h>
+#include <IceStorm/IceStorm.h>
+#include <IceBox/IceBox.h>
+
+#include "ServiceLocatorIf.h"
+#include "ComponentServiceIf.h"
+#include "RtpStateReplicator.h"
+#include "IceLogger.h"
+#include "logger.h"
+
+using namespace std;
+using namespace AsteriskSCF::Core;
+using namespace AsteriskSCF::Core::Discovery::V1;
+using namespace AsteriskSCF::System::Component::V1;
+using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::Media::RTP::V1;
+
+namespace
+{
+Logger &lg = getLoggerFactory().getLogger("AsteriskSCF.MediaRTP");
+}
+
+class RtpStateReplicatorService : public IceBox::Service
+{
+public:
+    RtpStateReplicatorService() { };
+    ~RtpStateReplicatorService()
+    {
+        mComponentService = 0;
+        mAdapter = 0;
+        mStateReplicator = 0;
+    };
+    virtual void start(const string &name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq& args);
+    virtual void stop();
+private:
+    void initialize(std::string appName, const Ice::CommunicatorPtr& ic);
+    void registerWithServiceLocator(const Ice::CommunicatorPtr& ic);
+    void deregisterFromServiceLocator();
+    std::string mAppName;
+    Ice::ObjectAdapterPtr mAdapter;
+    ServiceLocatorManagementPrx mServiceLocatorManagement;
+    Discovery::V1::ServiceManagementPrx mComponentServiceManagement;
+    Discovery::V1::ServiceManagementPrx mStateReplicationManagement;
+    ConfiguredIceLoggerPtr mIceLogger;
+    ComponentServicePtr mComponentService;
+    RtpStateReplicatorIPtr mStateReplicator;
+};
+
+static const string ComponentServiceId("RtpStateReplicatorComponent");
+static const string ServiceDiscoveryId("RtpStateReplicatorService");
+
+/**
+ * This class provides implementation for the ComponentService interface, which
+ * every Asterisk SCF component is expected to publish.
+ */
+class ComponentServiceImpl : public ComponentService
+{
+public:
+    ComponentServiceImpl(RtpStateReplicatorService &service) : mService(service) {}
+
+public: // Overrides of the ComponentService interface.
+    virtual void suspend(const ::Ice::Current& = ::Ice::Current())
+    {
+        // TBD
+    }
+
+    virtual void resume(const ::Ice::Current& = ::Ice::Current())
+    {
+        // TBD
+    }
+
+    virtual void shutdown(const ::Ice::Current& = ::Ice::Current())
+    {
+        // TBD
+    }
+
+private:
+    RtpStateReplicatorService& mService;
+};
+
+class RtpStateReplicatorCompare : public ServiceLocatorParamsCompare
+{
+public:
+    RtpStateReplicatorCompare(string name) : mName(name) {}
+    bool isSupported(const ServiceLocatorParamsPtr &params, const Ice::Current &)
+    {
+        RtpStateReplicatorParamsPtr sipParams = RtpStateReplicatorParamsPtr::dynamicCast(params);
+        if (sipParams->mName == mName)
+        {
+            return true;
+        }
+        return false;
+    }
+private:
+    string mName;
+};
+
+typedef IceUtil::Handle<RtpStateReplicatorCompare> RtpStateReplicatorComparePtr;
+
+/**
+ * Register this component's primary public interfaces with the Service Locator.
+ * This enables other Asterisk SCF components to locate our interfaces.
+ */
+void RtpStateReplicatorService::registerWithServiceLocator(const Ice::CommunicatorPtr& ic)
+{
+    try
+    {
+        // Get a proxy to the management interface for the Service Locator, so we can add ourselves into the system discovery mechanisms.
+        mServiceLocatorManagement = ServiceLocatorManagementPrx::checkedCast(ic->propertyToProxy("LocatorServiceManagement.Proxy"));
+
+        if (mServiceLocatorManagement == 0)
+        {
+            lg(Error) << "Unable to obtain proxy to ServiceLocatorManagement interface. Check config file. This component can't be found until this is corrected." << endl;
+            return;
+        }
+
+        // Get a proxy to our ComponentService interface and add it to the Service Locator.
+        Ice::ObjectPrx componentServiceObjectPrx = mAdapter->createDirectProxy(ic->stringToIdentity(ComponentServiceId));
+        ComponentServicePrx componentServicePrx = ComponentServicePrx::checkedCast(componentServiceObjectPrx);
+
+        // The GUID passed in to add service needs to be unique for reporting.
+        string componentServiceGuid(AsteriskSCF::Media::RTP::V1::StateReplicatorComponentCategory);
+        mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(componentServicePrx, componentServiceGuid));
+
+        // Add category as a parameter to enable other components look this component up.
+        ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
+        genericparams->category = AsteriskSCF::Media::RTP::V1::StateReplicatorComponentCategory;
+
+        mComponentServiceManagement->addLocatorParams(genericparams, "");
+
+        Ice::ObjectPrx stateReplicatorObjectPrx = mAdapter->createDirectProxy(ic->stringToIdentity(ServiceDiscoveryId));
+        RtpStateReplicatorPrx stateReplicatorPrx = RtpStateReplicatorPrx::checkedCast(stateReplicatorObjectPrx);
+
+        string stateReplicationGuid(AsteriskSCF::Media::RTP::V1::StateReplicatorDiscoveryCategory);
+        mStateReplicationManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(stateReplicatorPrx, stateReplicationGuid));
+
+        ServiceLocatorParamsPtr discoveryParams = new ServiceLocatorParams();
+        discoveryParams->category = AsteriskSCF::Media::RTP::V1::StateReplicatorDiscoveryCategory;
+
+        string replicatorName = ic->getProperties()->getPropertyWithDefault("RtpStateReplicator.Name", "default");
+        RtpStateReplicatorCompare* nameCompare = new RtpStateReplicatorCompare(replicatorName);
+        ServiceLocatorParamsComparePrx compareProxy = ServiceLocatorParamsComparePrx::uncheckedCast(mAdapter->addWithUUID(nameCompare));
+
+        string compareGuid = IceUtil::generateUUID();
+        mServiceLocatorManagement->addCompare(compareGuid, compareProxy);
+        mStateReplicationManagement->addLocatorParams(discoveryParams, compareGuid);
+
+        // TBD... We may have other interfaces to publish to the Service Locator.
+    }
+    catch(...)
+    {
+        lg(Error) << "Exception in " << mAppName << " registerWithServiceLocator()" << endl;
+    }
+}
+
+/**
+ * Deregister this component's primary public interfaces from the Service Locator.
+ * This is done at shutdown, and whenever we want to keep other services from locating
+ * our interfaces.
+ */
+void RtpStateReplicatorService::deregisterFromServiceLocator()
+{
+    try
+    {
+        mComponentServiceManagement->unregister();
+    }
+    catch(...)
+    {
+        lg(Error) << "Had trouble in deregisterFromServiceLocator()." << endl;
+    }
+}
+
+void RtpStateReplicatorService::initialize(const std::string appName, const Ice::CommunicatorPtr& ic)
+{
+    mAdapter = ic->createObjectAdapter("RtpStateReplicator");
+
+    // setup logging client
+    mIceLogger = createIceLogger(mAdapter);
+    getLoggerFactory().setLogOutput(mIceLogger->getLogger());
+
+    mAppName = appName;
+    // Create and publish our ComponentService interface support.
+    mComponentService = new ComponentServiceImpl(*this);
+    mAdapter->add(mComponentService, ic->stringToIdentity(ComponentServiceId));
+    mStateReplicator = new RtpStateReplicatorI();
+    mAdapter->add(mStateReplicator, ic->stringToIdentity(ServiceDiscoveryId));
+
+    mAdapter->activate();
+}
+
+void RtpStateReplicatorService::start(const string &name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq& args)
+{
+    initialize(name, ic);
+    // Plug into the Asterisk SCF discovery system so that the interfaces we provide
+    // can be located.
+    registerWithServiceLocator(ic);
+}
+
+void RtpStateReplicatorService::stop()
+{
+    // Remove our interfaces from the service locator.
+    deregisterFromServiceLocator();
+}
+
+extern "C"
+{
+ASTERISK_SCF_ICEBOX_EXPORT IceBox::Service* create(Ice::CommunicatorPtr communicator)
+{
+    return new RtpStateReplicatorService;
+}
+}
+

commit dea398070f3c13f96d6cffac05552b01e0314fc2
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Dec 8 08:03:55 2010 -0400

    Add slice file for replication.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c61faa5..46343f0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,6 +38,7 @@ if(NOT integrated_build STREQUAL "true")
    set(integrated_build false)
 endif()
 
+add_subdirectory(local-slice)
 add_subdirectory(src)
 add_subdirectory(config)
 add_subdirectory(test)
diff --git a/local-slice/CMakeLists.txt b/local-slice/CMakeLists.txt
new file mode 100644
index 0000000..b348049
--- /dev/null
+++ b/local-slice/CMakeLists.txt
@@ -0,0 +1,3 @@
+asterisk_scf_slice_include_directories("${CMAKE_SOURCE_DIR}/slice")
+asterisk_scf_compile_slice(RtpStateReplicationIf.ice lib "RTP State Replicator" media_rtp_pjmedia)
+
diff --git a/local-slice/RtpStateReplicationIf.ice b/local-slice/RtpStateReplicationIf.ice
new file mode 100644
index 0000000..d88bbfe
--- /dev/null
+++ b/local-slice/RtpStateReplicationIf.ice
@@ -0,0 +1,97 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#pragma once
+
+#include <Ice/BuiltinSequences.ice>
+#include <Ice/Identity.ice>
+#include "Media/MediaIf.ice"
+#include "Media/RTP/MediaRTPIf.ice"
+#include "Core/Discovery/ServiceLocatorIf.ice"
+
+module AsteriskSCF
+{
+
+module Media
+{
+
+module RTP
+{
+
+["suppress"]
+module V1
+{
+   const string StateReplicatorComponentCategory = "RtpStateReplicatorComponent";
+   const string StateReplicatorDiscoveryCategory = "RtpStateReplicator";
+
+   class RtpStateReplicatorParams extends AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams
+   {
+      string mName;
+   };
+
+   class RtpStateItem
+   {
+      string key;
+      string mSessionId;
+   };
+
+   sequence<RtpStateItem> RtpStateItemSeq;
+
+   interface RtpStateReplicatorListener
+   {
+	   void stateRemoved(Ice::StringSeq itemKeys);
+	   void stateSet(RtpStateItemSeq items);
+   };
+
+   interface RtpStateReplicator
+   {
+	   void addListener(RtpStateReplicatorListener *listener);
+	   void removeListener(RtpStateReplicatorListener *listener);
+	   void setState (RtpStateItemSeq items);
+	   void removeState(Ice::StringSeq items);
+	   idempotent RtpStateItemSeq getState(Ice::StringSeq itemKeys);
+	   idempotent RtpStateItemSeq getAllState();
+   };
+
+   class RtpSessionStateItem extends RtpStateItem
+   {
+       Ice::Identity mSessionIdentity;
+       int port;
+       Ice::Identity mSinkIdentity;
+       Ice::Identity mSourceIdentity;
+       AsteriskSCF::Media::V1::FormatSeq mFormats;
+       PayloadMap mPayloadstoFormats;
+   };
+
+   class RtpStreamSinkStateItem extends RtpStateItem
+   {
+       AsteriskSCF::Media::V1::StreamSource *mSource;
+       string mRemoteAddress;
+       int mRemotePort;
+   };
+
+   class RtpStreamSourceStateItem extends RtpStateItem
+   {
+       AsteriskSCF::Media::V1::StreamSink *mSink;
+   };
+
+}; //module V1
+
+}; //module RTP
+
+}; //module Media
+
+}; //module Asterisk SCF

commit 837913ff0338a6925e6fda63380b2b43d1b2e0b0
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Fri Dec 3 13:31:50 2010 -0600

    Manage boost link options in CMake.
    CR-ASTSCF-14

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 774e512..f7150af 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -10,7 +10,7 @@ asterisk_scf_component_init(media_rtp_pjmedia_test CXX)
 asterisk_scf_component_add_file(media_rtp_pjmedia_test TestRTPpjmedia.cpp)
 asterisk_scf_component_add_slice(media_rtp_pjmedia_test MediaIf)
 asterisk_scf_component_add_slice(media_rtp_pjmedia_test MediaRTPIf)
-asterisk_scf_component_add_boost_libraries(media_rtp_pjmedia_test unit_test_framework thread)
+asterisk_scf_component_add_boost_libraries(media_rtp_pjmedia_test unit_test_framework thread date_time)
 asterisk_scf_component_build_icebox(media_rtp_pjmedia_test)
 #asterisk_scf_component_install(media_rtp_pjmedia_test RUNTIME bin "PJmedia RTP Media Test Driver." Core)
 
diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index bd882f2..4866ed8 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -13,8 +13,6 @@
  * the GNU General Public License Version 2. See the LICENSE.txt file
  * at the top of the source tree.
  */
-
-#define BOOST_TEST_DYN_LINK
 #define BOOST_TEST_MODULE RTPpjmediaTestSuite
 #define BOOST_TEST_NO_MAIN
 

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


-- 
asterisk-scf/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list