[asterisk-scf-commits] asterisk-scf/release/media_operations_core.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Aug 17 17:09:44 CDT 2011


branch "master" has been updated
       via  b0f0497104ff0726fddd0ab626c0dab957ae610c (commit)
       via  ef874f0d1ef381870ed4bf07fcc12268304a14b2 (commit)
       via  1dd49457aa15390c544d53a2f2c2803ce0e3ffcf (commit)
      from  1c0eba48c860531621a3c0d5318361867199f2bf (commit)

Summary of changes:
 CMakeLists.txt                                     |    1 +
 .../MediaOperationsCore/MediaOperationsCoreIf.ice  |   79 +++++++++++++----
 src/CMakeLists.txt                                 |   15 +++-
 src/MediaOperationStateReplicator.h                |   47 ++++++++++
 src/MediaOperationStateReplicatorApp.cpp           |   92 ++++++++++++++++++++
 src/MediaOperationStateReplicatorListener.cpp      |   82 +++++++++++++++++
 src/ulaw_alaw.cpp                                  |   39 +++++++--
 src/ulaw_alaw.h                                    |    5 +
 8 files changed, 335 insertions(+), 25 deletions(-)
 create mode 100644 src/MediaOperationStateReplicator.h
 create mode 100644 src/MediaOperationStateReplicatorApp.cpp
 create mode 100644 src/MediaOperationStateReplicatorListener.cpp


- Log -----------------------------------------------------------------
commit b0f0497104ff0726fddd0ab626c0dab957ae610c
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Aug 17 17:10:31 2011 -0500

    Add some more startup for the replicator app.

diff --git a/src/MediaOperationStateReplicatorApp.cpp b/src/MediaOperationStateReplicatorApp.cpp
index 463f73d..887bec1 100644
--- a/src/MediaOperationStateReplicatorApp.cpp
+++ b/src/MediaOperationStateReplicatorApp.cpp
@@ -26,6 +26,8 @@ using namespace AsteriskSCF::System::Logging;
 namespace
 {
 Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaOperationStateReplicator");
+
+const std::string ReplicatorId("MediaOperationStateReplicator");
 }
 
 class MediaOperationStateReplicatorService : public IceBox::Service
@@ -37,14 +39,43 @@ public:
             const Ice::StringSeq&);
 
     virtual void stop();
+
+    Ice::ObjectAdapterPtr mAdapter;
+    MediaOperationStateReplicatorImplPtr mReplicator;
 };
 
+void MediaOperationStateReplicatorService::createStateReplicator(const Ice::CommunicatorPtr& communicator)
+{
+    mReplicator = new MediaOperationStateReplicatorImpl;
+    mAdapter->add(mReplicator, communicator->stringToIdentity(ReplicatorId));
+}
+
+void MediaOperationStateReplicatorService::registerWithServiceLocator(const Ice::CommunicatorPtr& communicator)
+{
+    MediaOperationStateReplicatorPrx stateReplicatorProxy =
+        MediaOperationStateReplicatorPrx::uncheckedCast(mAdapter->createDirectProxy(communicator->stringToIdentity(ReplicatorId)));
+
+    ServiceManagementPrx serviceManagement = mManagement->addService(stateReplicatorProxy, ReplicatorId);
+
+    ServiceLocatorParamsPtr params = new ServiceLocatorParams();
+    params->category = StateReplicatorDiscoveryCategory;
+    params->service = communicator->getProperties()->getPropertyWithDefault("MediaOperationStateReplicator.Service", "default");
+    params->id = communicator->getProperties()->getPropertyWithDefault("MediaOperationStateReplicator.Name", "default");
+    serviceManagement->addLocatorParams(params, "");
+}
+
 void MediaOperationStateReplicatorService::start(
         const std::string&,
-        const Ice::CommunicatorPtr&,
+        const Ice::CommunicatorPtr& communicator,
         const Ice::StringSeq&)
 {
-    //stub
+    mManagement = ServiceLocatorManagementPrx::checkedCast(communicator->propertyToProxy("ServiceLocatorManagementProxy"));
+    mAdapter = communicator->createObjectAdapter("MediaOperationStateReplicatorAdapter");
+
+    createStateReplicator(communicator);
+    registerWithServiceLocator();
+
+    mAdapter->activate();
 }
 
 void MediaOperationStateReplicatorService::stop()

commit ef874f0d1ef381870ed4bf07fcc12268304a14b2
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Aug 17 16:43:01 2011 -0500

    Add the skeleton for the MediaOperationStateReplicatorApp.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fda887c..a23bc93 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -19,3 +19,12 @@ pjproject_link(media_operations_core pjlib-util)
 pjproject_link(media_operations_core pjmedia)
 pjproject_link(media_operations_core pjnath)
 astscf_component_install(media_operations_core)
+
+astscf_component_init(MediaOperationStateReplicator)
+astscf_component_add_files(MediaOperationStateReplicator MediaOperationStateReplicatorApp.cpp)
+astscf_component_add_files(MediaOperationStateReplicator MediaOperationStateReplicator.h)
+astscf_component_add_slices(MediaOperationStateReplicator PROJECT AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice)
+astscf_component_add_slice_collection_libraries(MediaOperationStateReplicator ASTSCF)
+astscf_component_build_icebox(MediaOperationStateReplicator)
+target_link_libraries(MediaOperationStateReplicator logging-client astscf-ice-util-cpp)
+astscf_component_install(MediaOperationStateReplicator)
diff --git a/src/MediaOperationStateReplicatorApp.cpp b/src/MediaOperationStateReplicatorApp.cpp
new file mode 100644
index 0000000..463f73d
--- /dev/null
+++ b/src/MediaOperationStateReplicatorApp.cpp
@@ -0,0 +1,61 @@
+/*
+ * 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 "MediaOperationStateReplicator.h"
+
+#include <Ice/Ice.h>
+#include <IceBox/IceBox.h>
+
+#include <AsteriskSCF/logger.h>
+
+using namespace AsteriskSCF::System::Logging;
+
+namespace
+{
+Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaOperationStateReplicator");
+}
+
+class MediaOperationStateReplicatorService : public IceBox::Service
+{
+public:
+    virtual void start(
+            const std::string& name,
+            const Ice::CommunicatorPtr&,
+            const Ice::StringSeq&);
+
+    virtual void stop();
+};
+
+void MediaOperationStateReplicatorService::start(
+        const std::string&,
+        const Ice::CommunicatorPtr&,
+        const Ice::StringSeq&)
+{
+    //stub
+}
+
+void MediaOperationStateReplicatorService::stop()
+{
+    //stub
+}
+
+extern "C"
+{
+ASTSCF_DLL_EXPORT IceBox::Service* create(Ice::CommunicatorPtr)
+{
+    return new MediaOperationStateReplicatorService;
+}
+}

commit 1dd49457aa15390c544d53a2f2c2803ce0e3ffcf
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Aug 17 15:56:40 2011 -0500

    Facilitate state replication listening.
    
    Next up is the sending side...

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 15bd049..ae8afab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,3 +4,4 @@ add_subdirectory(src)
 if(BUILD_TESTING)
   add_subdirectory(test)
 endif()
+astscf_slice_collection_install(PROJECT)
diff --git a/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice b/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice
index 344a9ec..d407b45 100644
--- a/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice
+++ b/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice
@@ -16,6 +16,11 @@
 
 #pragma once
 
+#include <Ice/Identity.ice>
+#include <Ice/BuiltinSequences.ice>
+
+#include <AsteriskSCF/Media/MediaIf.ice>
+
 module AsteriskSCF
 {
 
@@ -25,31 +30,73 @@ module Replication
 module MediaOperationsCore
 {
 
-["visitor"] local class MediaOperationsCoreStateItemVisitor;
+module V1
+{
 
-["visitor:MediaOperationsCoreStateItemVisitor"] class MediaOperationsCoreStateItem
+["visitor"] local class MediaOperationStateItemVisitor
 {
-}
+};
 
-class MediaOperationFactoryStateItem
+/**
+ * All media operations will need to replicate their factory's
+ * Id and their operation's Id. Specific operations may
+ * have other items to replicate. They may do so by subclassing
+ * this.
+ */
+["visitor:MediaOperationStateItemVisitor"] class MediaOperationStateItem
 {
-    Ice::Identity id;
-}
+    /**
+     * The identity of the factory from which this operation was made.
+     * We use this to look up the factory in the object adapter so that
+     * we can create a new media operation
+     */
+    Ice::Identity factoryId;
+    /**
+     * The identity of the operation. We use this so that the proxy
+     * we create in the replica will have the same identity as the primary.
+     * We use a string instead of an Ice::Identity because it will be easier
+     * manipulate for creating the corresponding source and sink ids for this
+     * operation
+     */
+    string operationId;
+};
+
+sequence<MediaOperationStateItem> MediaOperationStateItemSeq;
 
 /**
- * All media operations will need
- * to replicate their own ID, as well
- * as their source and sink IDs. Any
- * operation that has more state to
- * replicate can create a subclass of this
+ * State item for a ulaw<->alaw translator
  */
-class MediaOperationStateItem
+class UlawAlawMediaOperationStateItem extends MediaOperationStateItem
+{
+    /**
+     * The format to use for the source of the media operation
+     */
+    AsteriskSCF::Media::V1::Format sourceFormat;
+    /**
+     * The format to use for the sink of the media operation
+     */
+    AsteriskSCF::Media::V1::Format sinkFormat;
+};
+
+interface MediaOperationStateReplicatorListener
+{
+    void stateRemoved(Ice::StringSeq itemKeys);
+    void stateRemovedForItems(MediaOperationStateItemSeq items);
+    void stateSet(MediaOperationStateItemSeq items);
+};
+
+interface MediaOperationStateReplicator
 {
-    Ice::Identity operationId;
-    Ice::Identity sourceId;
-    Ice::Identity sinkId;
-}
+    void addListener(MediaOperationStateReplicatorListener *listener);
+    void removeListener(MediaOperationStateReplicatorListener *listener);
+    void setState (MediaOperationStateItemSeq items);
+    void removeState(Ice::StringSeq items);
+    void removeStateForItems(MediaOperationStateItemSeq items);
+    idempotent MediaOperationStateItemSeq getState(Ice::StringSeq iteKeys);
+    idempotent MediaOperationStateItemSeq getAllState();
+};
 
+}; /* end module V1 */
 }; /* end module MediaOperationsCore */
 }; /* end module Replication */
 }; /* end module AsteriskSCF */
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index caa80e7..fda887c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,4 +1,5 @@
 include_directories(${logger_dir}/include)
+include_directories(${astscf-ice-util-cpp_dir}/include)
 
 astscf_component_init(media_operations_core)
 astscf_component_add_files(media_operations_core ulaw_alaw.h)
@@ -6,9 +7,12 @@ astscf_component_add_files(media_operations_core ulaw_alaw.cpp)
 astscf_component_add_files(media_operations_core MediaOperationFactoryImpl.h)
 astscf_component_add_files(media_operations_core MediaOperationFactoryImpl.cpp)
 astscf_component_add_files(media_operations_core MediaOperationsCore.cpp)
+astscf_component_add_files(media_operations_core MediaOperationStateReplicatorListener.cpp)
+astscf_component_add_files(media_operations_core MediaOperationStateReplicator.h)
+astscf_component_add_slices(media_operations_core PROJECT AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice)
 astscf_component_add_slice_collection_libraries(media_operations_core ASTSCF)
 astscf_component_build_icebox(media_operations_core)
-target_link_libraries(media_operations_core logging-client)
+target_link_libraries(media_operations_core logging-client astscf-ice-util-cpp)
 
 pjproject_link(media_operations_core pjlib)
 pjproject_link(media_operations_core pjlib-util)
diff --git a/src/MediaOperationStateReplicator.h b/src/MediaOperationStateReplicator.h
new file mode 100644
index 0000000..1930ace
--- /dev/null
+++ b/src/MediaOperationStateReplicator.h
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <AsteriskSCF/Replication/StateReplicator.h>
+#include <AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.h>
+
+namespace AsteriskSCF
+{
+
+namespace MediaOperationsCore
+{
+
+typedef AsteriskSCF::Replication::StateReplicator<
+    AsteriskSCF::Replication::MediaOperationsCore::V1::MediaOperationStateReplicator,
+    AsteriskSCF::Replication::MediaOperationsCore::V1::MediaOperationStateItemPtr,
+    std::string,
+    AsteriskSCF::Replication::MediaOperationsCore::V1::MediaOperationStateReplicatorListenerPrx> MediaOperationStateReplicatorImpl;
+typedef IceUtil::Handle<MediaOperationStateReplicatorImpl> MediaOperationStateReplicatorImplPtr;
+
+class MediaOperationStateReplicatorListenerImpl : public AsteriskSCF::Replication::MediaOperationsCore::V1::MediaOperationStateReplicatorListener
+{
+public:
+    MediaOperationStateReplicatorListenerImpl(const Ice::ObjectAdapterPtr& adapter);
+    void stateRemoved(const Ice::StringSeq&, const Ice::Current&);
+    void stateRemovedForItems(const AsteriskSCF::Replication::MediaOperationsCore::V1::MediaOperationStateItemSeq&, const Ice::Current&);
+    void stateSet(const AsteriskSCF::Replication::MediaOperationsCore::V1::MediaOperationStateItemSeq&, const Ice::Current&);
+private:
+    Ice::ObjectAdapterPtr mAdapter;
+};
+
+}
+}
diff --git a/src/MediaOperationStateReplicatorListener.cpp b/src/MediaOperationStateReplicatorListener.cpp
new file mode 100644
index 0000000..99e391f
--- /dev/null
+++ b/src/MediaOperationStateReplicatorListener.cpp
@@ -0,0 +1,82 @@
+/*
+ * 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 "MediaOperationStateReplicator.h"
+#include "ulaw_alaw.h"
+
+namespace AsteriskSCF
+{
+
+namespace MediaOperationsCore
+{
+
+using namespace AsteriskSCF::Replication::MediaOperationsCore::V1;
+
+MediaOperationStateReplicatorListenerImpl::MediaOperationStateReplicatorListenerImpl(const Ice::ObjectAdapterPtr& adapter)
+    : mAdapter(adapter)
+{
+}
+
+void MediaOperationStateReplicatorListenerImpl::stateRemoved(
+        const Ice::StringSeq&,
+        const Ice::Current&)
+{
+}
+
+void MediaOperationStateReplicatorListenerImpl::stateRemovedForItems(
+        const MediaOperationStateItemSeq&,
+        const Ice::Current&)
+{
+}
+
+void MediaOperationStateReplicatorListenerImpl::stateSet(
+        const MediaOperationStateItemSeq& items,
+        const Ice::Current&)
+{
+    class Visitor : public MediaOperationStateItemVisitor
+    {
+    public:
+        Visitor(const Ice::ObjectAdapterPtr& adapter)
+            : mAdapter(adapter) { }
+    private:
+        void visitUlawAlawMediaOperationStateItem(const UlawAlawMediaOperationStateItemPtr& ulawAlaw)
+        {
+            UlawAlawFactoryPtr factory = UlawAlawFactoryPtr::dynamicCast(mAdapter->find(ulawAlaw->factoryId));
+
+            if (!factory)
+            {
+                return;
+            }
+
+            factory->createMediaOperation(
+                    ulawAlaw->sourceFormat,
+                    ulawAlaw->sinkFormat,
+                    ulawAlaw->operationId);
+        }
+        Ice::ObjectAdapterPtr mAdapter;
+    };
+
+    MediaOperationStateItemVisitorPtr v = new Visitor(mAdapter);
+
+    for (MediaOperationStateItemSeq::const_iterator iter = items.begin();
+            iter != items.end(); ++iter)
+    {
+        (*iter)->visit(v);
+    }
+}
+
+}
+}
diff --git a/src/ulaw_alaw.cpp b/src/ulaw_alaw.cpp
index ae9a84a..475bce5 100644
--- a/src/ulaw_alaw.cpp
+++ b/src/ulaw_alaw.cpp
@@ -177,14 +177,14 @@ public:
     {
     }
 
-    MediaOperationPrx activate()
+    MediaOperationPrx activate(const std::string& id)
     {
         mProxy =
-            MediaOperationPrx::uncheckedCast(mAdapter->addWithUUID(this));
+            MediaOperationPrx::uncheckedCast(mAdapter->add(this, mAdapter->getCommunicator()->stringToIdentity(id)));
         mSinkProxy =
-            StreamSinkPrx::uncheckedCast(mAdapter->addWithUUID(mSink));
+            StreamSinkPrx::uncheckedCast(mAdapter->add(mSink, mAdapter->getCommunicator()->stringToIdentity(id + ".Sink")));
         mSourceProxy =
-            StreamSourcePrx::uncheckedCast(mAdapter->addWithUUID(mSource));
+            StreamSourcePrx::uncheckedCast(mAdapter->add(mSource, mAdapter->getCommunicator()->stringToIdentity(id +".Source")));
 
         return mProxy;
     }
@@ -354,21 +354,44 @@ MediaOperationPrx UlawAlawFactory::createMediaOperation(
         //This means we are translating from ulaw to alaw.
         //This means that we need a ulaw sink and an alaw source.
         //This accounts for what may seem to be a bit of backwardness
-        //regarding the parameters passed into the constructor.
+        //regarding the parameters passed in.
         mLogger(Debug) << "Creating ulaw to alaw translator";
-        operation = new UlawAlawOperation(mAdapter, mLogger, sinkAlaw, sourceUlaw);
+        return createMediaOperation(
+                sinkAlaw,
+                sourceUlaw,
+                IceUtil::generateUUID());
     }
     else if (sourceAlaw && sinkUlaw)
     {
         mLogger(Debug) << "Creating alaw to ulaw translator";
-        operation = new UlawAlawOperation(mAdapter, mLogger, sinkUlaw, sourceAlaw);
+        return createMediaOperation(
+                sinkUlaw,
+                sourceAlaw,
+                IceUtil::generateUUID());
     }
     else
     {
         mLogger(Error) << "Cannot create translator because source and sink do not have supported formats";
         throw UnsupportedMediaFormatException();
     }
-    return operation->activate();
+}
+
+MediaOperationPrx UlawAlawFactory::createMediaOperation(
+        const FormatPtr& sourceFormat,
+        const FormatPtr& sinkFormat,
+        const std::string& operationId)
+{
+    UlawAlawOperationPtr operation(
+            new UlawAlawOperation(
+                mAdapter,
+                mLogger,
+                sourceFormat,
+                sinkFormat));
+
+    MediaOperationPrx proxy = operation->activate(operationId);
+    //Here be where state replication should go
+
+    return proxy;
 }
 
 } //end namespace MediaOperationsCore
diff --git a/src/ulaw_alaw.h b/src/ulaw_alaw.h
index 180b880..cc2eb3d 100644
--- a/src/ulaw_alaw.h
+++ b/src/ulaw_alaw.h
@@ -34,6 +34,11 @@ public:
             const AsteriskSCF::Media::V1::StreamSourcePrx& source,
             const AsteriskSCF::Media::V1::StreamSinkPrx& sink,
             const Ice::Current&);
+
+    AsteriskSCF::Media::V1::MediaOperationPrx createMediaOperation(
+            const AsteriskSCF::Media::V1::FormatPtr& sourceFormat,
+            const AsteriskSCF::Media::V1::FormatPtr& sinkFormat,
+            const std::string& operationId);
 };
 
 typedef IceUtil::Handle<UlawAlawFactory> UlawAlawFactoryPtr;

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


-- 
asterisk-scf/release/media_operations_core.git



More information about the asterisk-scf-commits mailing list