[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
Tue Aug 16 12:26:36 CDT 2011


branch "master" has been updated
       via  575aada840ad67ff474824e90dc440db0a3abc69 (commit)
       via  444e25c4e543c5e45eea385690df5796fb159793 (commit)
       via  11b8191ee1964cdc4cc418f406400b8995b01a8f (commit)
       via  a38192bdb2b3722bfd9e827d589d7119fcbe7629 (commit)
       via  6fe4b416aabc8296bd500c5fb08d2a094bffe787 (commit)
      from  011901f570507bc0cc82c867c94e9c03c9573ba6 (commit)

Summary of changes:
 src/CMakeLists.txt                               |    2 +
 src/MediaOperationFactoryImpl.cpp                |   49 ++++++++++
 src/{ulaw_alaw.h => MediaOperationFactoryImpl.h} |   18 ++--
 src/MediaOperationsCore.cpp                      |  104 ++++++++++++++++++---
 src/ulaw_alaw.cpp                                |   19 +---
 src/ulaw_alaw.h                                  |   26 +-----
 6 files changed, 156 insertions(+), 62 deletions(-)
 create mode 100644 src/MediaOperationFactoryImpl.cpp
 copy src/{ulaw_alaw.h => MediaOperationFactoryImpl.h} (73%)


- Log -----------------------------------------------------------------
commit 575aada840ad67ff474824e90dc440db0a3abc69
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Aug 16 12:25:58 2011 -0500

    Use 'm' prefix for "factories" member.

diff --git a/src/MediaOperationsCore.cpp b/src/MediaOperationsCore.cpp
index ca9e864..2164ba1 100644
--- a/src/MediaOperationsCore.cpp
+++ b/src/MediaOperationsCore.cpp
@@ -104,7 +104,7 @@ private:
     ServiceLocatorManagementPrx mManagement;
     Ice::ObjectAdapterPtr mAdapter;
 
-    MediaOperationFactorySeq factories;
+    MediaOperationFactorySeq mFactories;
 
     MediaOperationsComparePtr mMediaOperationsCompare;
     ServiceLocatorParamsComparePrx mMediaOperationsComparePrx;
@@ -115,7 +115,7 @@ void MediaOperationsCoreApp::createAndRegisterFactory(const MediaOperationFactor
     MediaOperationFactoryPrx factoryProxy =
         MediaOperationFactoryPrx::uncheckedCast(mAdapter->addWithUUID(factory));
 
-    factories.push_back(std::make_pair(factory, factoryProxy));
+    mFactories.push_back(std::make_pair(factory, factoryProxy));
 
 }
 
@@ -127,15 +127,15 @@ void MediaOperationsCoreApp::createOperationFactories()
 
 void MediaOperationsCoreApp::registerWithServiceLocator()
 {
-    for (MediaOperationFactorySeq::iterator iter = factories.begin();
-            iter != factories.end(); ++iter)
+    for (MediaOperationFactorySeq::iterator iter = mFactories.begin();
+            iter != mFactories.end(); ++iter)
     {
         ServiceManagementPrx factoryServiceManagement =
             mManagement->addService(iter->second, iter->first->getName());
         factoryServiceManagement->addLocatorParams(iter->first->getLocatorParams(), iter->first->getName());
     }
 
-    mMediaOperationsCompare = new MediaOperationsCompare(factories);
+    mMediaOperationsCompare = new MediaOperationsCompare(mFactories);
     mMediaOperationsComparePrx = ServiceLocatorParamsComparePrx::uncheckedCast(mAdapter->addWithUUID(mMediaOperationsCompare));
 
     mManagement->addCompare(CompareGuid, mMediaOperationsComparePrx);
@@ -155,8 +155,8 @@ void MediaOperationsCoreApp::start(
 
 void MediaOperationsCoreApp::stop()
 {
-    for (MediaOperationFactorySeq::iterator iter = factories.begin();
-            iter != factories.end(); ++iter)
+    for (MediaOperationFactorySeq::iterator iter = mFactories.begin();
+            iter != mFactories.end(); ++iter)
     {
         try
         {

commit 444e25c4e543c5e45eea385690df5796fb159793
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Aug 16 12:24:50 2011 -0500

    Separate tasks out into more manageable chunks.

diff --git a/src/MediaOperationsCore.cpp b/src/MediaOperationsCore.cpp
index 6d5f0ea..ca9e864 100644
--- a/src/MediaOperationsCore.cpp
+++ b/src/MediaOperationsCore.cpp
@@ -41,12 +41,12 @@ namespace MediaOperationsCore
 using namespace AsteriskSCF::Core::Discovery::V1;
 using namespace AsteriskSCF::Media::V1;
 
-typedef std::vector<MediaOperationFactoryImplPtr> MediaOperationFactoryImplSeq;
+typedef std::vector<std::pair<MediaOperationFactoryImplPtr, MediaOperationFactoryPrx> > MediaOperationFactorySeq;
 
 class MediaOperationsCompare : public ServiceLocatorParamsCompare
 {
 public:
-    MediaOperationsCompare(const MediaOperationFactoryImplSeq& factories)
+    MediaOperationsCompare(const MediaOperationFactorySeq& factories)
         : mFactories(factories) { }
 
     bool isSupported(const ServiceLocatorParamsPtr& params, const Ice::Current&)
@@ -60,10 +60,10 @@ public:
             return false;
         }
 
-        for (MediaOperationFactoryImplSeq::iterator seqIter = mFactories.begin();
+        for (MediaOperationFactorySeq::iterator seqIter = mFactories.begin();
                 seqIter != mFactories.end(); ++seqIter)
         {
-            MediaOperationServiceLocatorParamsPtr ourParams = (*seqIter)->getLocatorParams();
+            MediaOperationServiceLocatorParamsPtr ourParams = seqIter->first->getLocatorParams();
             for (MediaOperationAttributesSeq::iterator ourParamsIter = ourParams->attributes.begin();
                     ourParamsIter != ourParams->attributes.end(); ++ourParamsIter)
             {
@@ -81,7 +81,7 @@ public:
         return false;
     }
 private:
-    MediaOperationFactoryImplSeq mFactories;
+    MediaOperationFactorySeq mFactories;
 };
 
 typedef IceUtil::Handle<MediaOperationsCompare> MediaOperationsComparePtr;
@@ -104,8 +104,7 @@ private:
     ServiceLocatorManagementPrx mManagement;
     Ice::ObjectAdapterPtr mAdapter;
 
-    MediaOperationFactoryImplSeq factories;
-    std::vector<MediaOperationFactoryPrx> factoryProxies;
+    MediaOperationFactorySeq factories;
 
     MediaOperationsComparePtr mMediaOperationsCompare;
     ServiceLocatorParamsComparePrx mMediaOperationsComparePrx;
@@ -113,15 +112,11 @@ private:
 
 void MediaOperationsCoreApp::createAndRegisterFactory(const MediaOperationFactoryImplPtr& factory)
 {
-    factories.push_back(factory);
-
     MediaOperationFactoryPrx factoryProxy =
         MediaOperationFactoryPrx::uncheckedCast(mAdapter->addWithUUID(factory));
-    factoryProxies.push_back(factoryProxy);
 
-    ServiceManagementPrx factoryServiceManagement =
-        mManagement->addService(factoryProxy, factory->getName());
-    factoryServiceManagement->addLocatorParams(factory->getLocatorParams(), factory->getName());
+    factories.push_back(std::make_pair(factory, factoryProxy));
+
 }
 
 void MediaOperationsCoreApp::createOperationFactories()
@@ -132,6 +127,14 @@ void MediaOperationsCoreApp::createOperationFactories()
 
 void MediaOperationsCoreApp::registerWithServiceLocator()
 {
+    for (MediaOperationFactorySeq::iterator iter = factories.begin();
+            iter != factories.end(); ++iter)
+    {
+        ServiceManagementPrx factoryServiceManagement =
+            mManagement->addService(iter->second, iter->first->getName());
+        factoryServiceManagement->addLocatorParams(iter->first->getLocatorParams(), iter->first->getName());
+    }
+
     mMediaOperationsCompare = new MediaOperationsCompare(factories);
     mMediaOperationsComparePrx = ServiceLocatorParamsComparePrx::uncheckedCast(mAdapter->addWithUUID(mMediaOperationsCompare));
 
@@ -152,12 +155,12 @@ void MediaOperationsCoreApp::start(
 
 void MediaOperationsCoreApp::stop()
 {
-    for (std::vector<MediaOperationFactoryPrx>::iterator iter = factoryProxies.begin();
-            iter != factoryProxies.end(); ++iter)
+    for (MediaOperationFactorySeq::iterator iter = factories.begin();
+            iter != factories.end(); ++iter)
     {
         try
         {
-            mAdapter->remove((*iter)->ice_getIdentity());
+            mAdapter->remove(iter->second->ice_getIdentity());
         }
         catch (const Ice::Exception& ex)
         {

commit 11b8191ee1964cdc4cc418f406400b8995b01a8f
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Aug 16 12:10:53 2011 -0500

    Add other files I forgot in previous change.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3daa16d..caa80e7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -3,6 +3,8 @@ include_directories(${logger_dir}/include)
 astscf_component_init(media_operations_core)
 astscf_component_add_files(media_operations_core ulaw_alaw.h)
 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_slice_collection_libraries(media_operations_core ASTSCF)
 astscf_component_build_icebox(media_operations_core)
diff --git a/src/MediaOperationsCore.cpp b/src/MediaOperationsCore.cpp
index d0ca618..6d5f0ea 100644
--- a/src/MediaOperationsCore.cpp
+++ b/src/MediaOperationsCore.cpp
@@ -21,6 +21,7 @@
 #include <AsteriskSCF/Media/MediaOperationIf.h>
 #include <AsteriskSCF/logger.h>
 
+#include "MediaOperationFactoryImpl.h"
 #include "ulaw_alaw.h"
 
 using namespace AsteriskSCF::System::Logging;
@@ -40,11 +41,13 @@ namespace MediaOperationsCore
 using namespace AsteriskSCF::Core::Discovery::V1;
 using namespace AsteriskSCF::Media::V1;
 
+typedef std::vector<MediaOperationFactoryImplPtr> MediaOperationFactoryImplSeq;
+
 class MediaOperationsCompare : public ServiceLocatorParamsCompare
 {
 public:
-    MediaOperationsCompare(const UlawAlawFactoryPtr& ulawAlawFactory)
-        : mUlawAlawFactory(ulawAlawFactory) { }
+    MediaOperationsCompare(const MediaOperationFactoryImplSeq& factories)
+        : mFactories(factories) { }
 
     bool isSupported(const ServiceLocatorParamsPtr& params, const Ice::Current&)
     {
@@ -57,24 +60,28 @@ public:
             return false;
         }
 
-        MediaOperationServiceLocatorParamsPtr ulawAlawParams = mUlawAlawFactory->getLocatorParams();
-        for (MediaOperationAttributesSeq::iterator ulawAlawIter = ulawAlawParams->attributes.begin();
-                ulawAlawIter != ulawAlawParams->attributes.end(); ++ulawAlawIter)
+        for (MediaOperationFactoryImplSeq::iterator seqIter = mFactories.begin();
+                seqIter != mFactories.end(); ++seqIter)
         {
-            for (MediaOperationAttributesSeq::iterator toCompareIter = toCompare->attributes.begin();
-                    toCompareIter != toCompare->attributes.end(); ++toCompareIter)
+            MediaOperationServiceLocatorParamsPtr ourParams = (*seqIter)->getLocatorParams();
+            for (MediaOperationAttributesSeq::iterator ourParamsIter = ourParams->attributes.begin();
+                    ourParamsIter != ourParams->attributes.end(); ++ourParamsIter)
             {
-                if (toCompareIter->inputFormat->name == ulawAlawIter->inputFormat->name &&
-                        toCompareIter->outputFormat->name == ulawAlawIter->outputFormat->name)
+                for (MediaOperationAttributesSeq::iterator theirParamsIter = toCompare->attributes.begin();
+                        theirParamsIter != toCompare->attributes.end(); ++theirParamsIter)
                 {
-                    return true;
+                    if (theirParamsIter->inputFormat->name == ourParamsIter->inputFormat->name &&
+                            theirParamsIter->outputFormat->name == ourParamsIter->outputFormat->name)
+                    {
+                        return true;
+                    }
                 }
             }
         }
         return false;
     }
 private:
-    UlawAlawFactoryPtr mUlawAlawFactory;
+    MediaOperationFactoryImplSeq mFactories;
 };
 
 typedef IceUtil::Handle<MediaOperationsCompare> MediaOperationsComparePtr;
@@ -90,35 +97,42 @@ public:
 
 private:
 
+    void createAndRegisterFactory(const MediaOperationFactoryImplPtr& factory);
     void createOperationFactories();
     void registerWithServiceLocator();
 
     ServiceLocatorManagementPrx mManagement;
     Ice::ObjectAdapterPtr mAdapter;
 
-    UlawAlawFactoryPtr mUlawAlawFactory;
-    MediaOperationFactoryPrx mUlawAlawFactoryProxy;
-    ServiceManagementPrx mUlawAlawServiceManagement;
+    MediaOperationFactoryImplSeq factories;
+    std::vector<MediaOperationFactoryPrx> factoryProxies;
 
     MediaOperationsComparePtr mMediaOperationsCompare;
     ServiceLocatorParamsComparePrx mMediaOperationsComparePrx;
 };
 
+void MediaOperationsCoreApp::createAndRegisterFactory(const MediaOperationFactoryImplPtr& factory)
+{
+    factories.push_back(factory);
+
+    MediaOperationFactoryPrx factoryProxy =
+        MediaOperationFactoryPrx::uncheckedCast(mAdapter->addWithUUID(factory));
+    factoryProxies.push_back(factoryProxy);
+
+    ServiceManagementPrx factoryServiceManagement =
+        mManagement->addService(factoryProxy, factory->getName());
+    factoryServiceManagement->addLocatorParams(factory->getLocatorParams(), factory->getName());
+}
+
 void MediaOperationsCoreApp::createOperationFactories()
 {
     lg(Debug) << "Creating UlawAlawFactory";
-    mUlawAlawFactory = new UlawAlawFactory(mAdapter, lg);
-    mUlawAlawFactoryProxy =
-        MediaOperationFactoryPrx::uncheckedCast(mAdapter->addWithUUID(mUlawAlawFactory));
+    createAndRegisterFactory(new UlawAlawFactory(mAdapter, lg));
 }
 
 void MediaOperationsCoreApp::registerWithServiceLocator()
 {
-    mUlawAlawServiceManagement =
-        mManagement->addService(mUlawAlawFactoryProxy, mUlawAlawFactory->getName());
-    mUlawAlawServiceManagement->addLocatorParams(mUlawAlawFactory->getLocatorParams(), mUlawAlawFactory->getName());
-
-    mMediaOperationsCompare = new MediaOperationsCompare(mUlawAlawFactory);
+    mMediaOperationsCompare = new MediaOperationsCompare(factories);
     mMediaOperationsComparePrx = ServiceLocatorParamsComparePrx::uncheckedCast(mAdapter->addWithUUID(mMediaOperationsCompare));
 
     mManagement->addCompare(CompareGuid, mMediaOperationsComparePrx);
@@ -138,13 +152,17 @@ void MediaOperationsCoreApp::start(
 
 void MediaOperationsCoreApp::stop()
 {
-    try
+    for (std::vector<MediaOperationFactoryPrx>::iterator iter = factoryProxies.begin();
+            iter != factoryProxies.end(); ++iter)
     {
-        mAdapter->remove(mUlawAlawFactoryProxy->ice_getIdentity());
-    }
-    catch (const Ice::Exception& ex)
-    {
-        lg(Error) << "Error attempting to remove a factory from the adapter" << ex.what();
+        try
+        {
+            mAdapter->remove((*iter)->ice_getIdentity());
+        }
+        catch (const Ice::Exception& ex)
+        {
+            lg(Error) << "Error attempting to remove a factory from the adapter" << ex.what();
+        }
     }
 }
 
diff --git a/src/ulaw_alaw.cpp b/src/ulaw_alaw.cpp
index 04e6608..15f78ac 100644
--- a/src/ulaw_alaw.cpp
+++ b/src/ulaw_alaw.cpp
@@ -294,10 +294,7 @@ typedef IceUtil::Handle<UlawAlawOperation> UlawAlawOperationPtr;
 
 UlawAlawFactory::UlawAlawFactory(const Ice::ObjectAdapterPtr& adapter,
         const Logger& logger)
-    : mAdapter(adapter),
-    mLogger(logger),
-    mName("UlawAlawFactory"),
-    mLocatorParams(new MediaOperationServiceLocatorParams)
+    : MediaOperationFactoryImpl(adapter, logger, "UlawAlawFactory")
 {
     MediaOperationAttributes ulawToAlaw;
     ulawToAlaw.inputFormat = new G711uLAW();
@@ -384,15 +381,5 @@ MediaOperationPrx UlawAlawFactory::createMediaOperation(
     return operation->mProxy;
 }
 
-const std::string& UlawAlawFactory::getName()
-{
-    return mName;
-}
-
-MediaOperationServiceLocatorParamsPtr UlawAlawFactory::getLocatorParams()
-{
-    return mLocatorParams;
-}
-
 } //end namespace MediaOperationsCore
 } //end namespace AsteriskSCF
diff --git a/src/ulaw_alaw.h b/src/ulaw_alaw.h
index 9bfa7b3..180b880 100644
--- a/src/ulaw_alaw.h
+++ b/src/ulaw_alaw.h
@@ -16,10 +16,7 @@
 
 #pragma once
 
-#include <Ice/Ice.h>
-#include <AsteriskSCF/Media/MediaOperationIf.h>
-#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
-#include <AsteriskSCF/logger.h>
+#include "MediaOperationFactoryImpl.h"
 
 namespace AsteriskSCF
 {
@@ -27,7 +24,7 @@ namespace AsteriskSCF
 namespace MediaOperationsCore
 {
 
-class UlawAlawFactory : public AsteriskSCF::Media::V1::MediaOperationFactory
+class UlawAlawFactory : public MediaOperationFactoryImpl
 {
 public:
     UlawAlawFactory(const Ice::ObjectAdapterPtr&,
@@ -37,25 +34,6 @@ public:
             const AsteriskSCF::Media::V1::StreamSourcePrx& source,
             const AsteriskSCF::Media::V1::StreamSinkPrx& sink,
             const Ice::Current&);
-
-    const std::string& getName();
-
-    AsteriskSCF::Media::V1::MediaOperationServiceLocatorParamsPtr getLocatorParams();
-
-private:
-    Ice::ObjectAdapterPtr mAdapter;
-    AsteriskSCF::System::Logging::Logger mLogger;
-    /**
-     * The name of the factory. Used as a GUID for the service locator params
-     * that we register.
-     */
-    const std::string mName;
-    /**
-     * Attributes of this factory.
-     * Let's the service locator know that we can translate from ulaw to alaw and
-     * from alaw to ulaw.
-     */
-    AsteriskSCF::Media::V1::MediaOperationServiceLocatorParamsPtr mLocatorParams;
 };
 
 typedef IceUtil::Handle<UlawAlawFactory> UlawAlawFactoryPtr;

commit a38192bdb2b3722bfd9e827d589d7119fcbe7629
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Aug 16 12:08:18 2011 -0500

    Make things a bit more generic, and make adding new factories easier when the time comes.

diff --git a/src/MediaOperationFactoryImpl.cpp b/src/MediaOperationFactoryImpl.cpp
new file mode 100644
index 0000000..fa4f0d1
--- /dev/null
+++ b/src/MediaOperationFactoryImpl.cpp
@@ -0,0 +1,49 @@
+/*
+ * 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 "MediaOperationFactoryImpl.h"
+
+namespace AsteriskSCF
+{
+
+namespace MediaOperationsCore
+{
+
+using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::Media::V1;
+
+MediaOperationFactoryImpl::MediaOperationFactoryImpl(const Ice::ObjectAdapterPtr& adapter,
+        const Logger& logger,
+        const std::string& name)
+    : mAdapter(adapter),
+    mLogger(logger),
+    mName(name),
+    mLocatorParams(new MediaOperationServiceLocatorParams)
+{
+}
+
+const std::string& MediaOperationFactoryImpl::getName()
+{
+    return mName;
+}
+
+MediaOperationServiceLocatorParamsPtr MediaOperationFactoryImpl::getLocatorParams()
+{
+    return mLocatorParams;
+}
+
+} //end namespace MediaOperationsCore
+} //end namespace AsteriskSCF
diff --git a/src/MediaOperationFactoryImpl.h b/src/MediaOperationFactoryImpl.h
new file mode 100644
index 0000000..48f9d9f
--- /dev/null
+++ b/src/MediaOperationFactoryImpl.h
@@ -0,0 +1,64 @@
+/*
+ * 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 <Ice/Ice.h>
+#include <AsteriskSCF/Media/MediaOperationIf.h>
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
+#include <AsteriskSCF/logger.h>
+
+namespace AsteriskSCF
+{
+
+namespace MediaOperationsCore
+{
+
+class MediaOperationFactoryImpl : public AsteriskSCF::Media::V1::MediaOperationFactory
+{
+public:
+    MediaOperationFactoryImpl(const Ice::ObjectAdapterPtr&,
+            const AsteriskSCF::System::Logging::Logger&,
+            const std::string&);
+
+    virtual AsteriskSCF::Media::V1::MediaOperationPrx createMediaOperation(
+            const AsteriskSCF::Media::V1::StreamSourcePrx& source,
+            const AsteriskSCF::Media::V1::StreamSinkPrx& sink,
+            const Ice::Current&) = 0;
+
+    const std::string& getName();
+
+    AsteriskSCF::Media::V1::MediaOperationServiceLocatorParamsPtr getLocatorParams();
+protected:
+    Ice::ObjectAdapterPtr mAdapter;
+    AsteriskSCF::System::Logging::Logger mLogger;
+    /**
+     * The name of the factory. Used as a GUID for the service locator params
+     * that we register.
+     */
+    const std::string mName;
+    /**
+     * Attributes of this factory.
+     * Let's the service locator know that we can translate from ulaw to alaw and
+     * from alaw to ulaw.
+     */
+    AsteriskSCF::Media::V1::MediaOperationServiceLocatorParamsPtr mLocatorParams;
+};
+
+typedef IceUtil::Handle<MediaOperationFactoryImpl> MediaOperationFactoryImplPtr;
+
+} //end namespace MediaOperationsCore
+} //end namespace AsteriskSCF

commit 6fe4b416aabc8296bd500c5fb08d2a094bffe787
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Aug 16 10:16:50 2011 -0500

    Add custom service locator compare to find appropriate translators.

diff --git a/src/MediaOperationsCore.cpp b/src/MediaOperationsCore.cpp
index 0567bf9..d0ca618 100644
--- a/src/MediaOperationsCore.cpp
+++ b/src/MediaOperationsCore.cpp
@@ -28,6 +28,7 @@ using namespace AsteriskSCF::System::Logging;
 namespace
 {
 Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaOperationsCore");
+const std::string CompareGuid("MediaOperationLocatorParamsCompare");
 };
 
 namespace AsteriskSCF
@@ -39,6 +40,45 @@ namespace MediaOperationsCore
 using namespace AsteriskSCF::Core::Discovery::V1;
 using namespace AsteriskSCF::Media::V1;
 
+class MediaOperationsCompare : public ServiceLocatorParamsCompare
+{
+public:
+    MediaOperationsCompare(const UlawAlawFactoryPtr& ulawAlawFactory)
+        : mUlawAlawFactory(ulawAlawFactory) { }
+
+    bool isSupported(const ServiceLocatorParamsPtr& params, const Ice::Current&)
+    {
+        MediaOperationServiceLocatorParamsPtr toCompare =
+            MediaOperationServiceLocatorParamsPtr::dynamicCast(params);
+        //First off, if we've been given params that are not for media operations,
+        //then this llama needs re-saddling.
+        if (!toCompare)
+        {
+            return false;
+        }
+
+        MediaOperationServiceLocatorParamsPtr ulawAlawParams = mUlawAlawFactory->getLocatorParams();
+        for (MediaOperationAttributesSeq::iterator ulawAlawIter = ulawAlawParams->attributes.begin();
+                ulawAlawIter != ulawAlawParams->attributes.end(); ++ulawAlawIter)
+        {
+            for (MediaOperationAttributesSeq::iterator toCompareIter = toCompare->attributes.begin();
+                    toCompareIter != toCompare->attributes.end(); ++toCompareIter)
+            {
+                if (toCompareIter->inputFormat->name == ulawAlawIter->inputFormat->name &&
+                        toCompareIter->outputFormat->name == ulawAlawIter->outputFormat->name)
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+private:
+    UlawAlawFactoryPtr mUlawAlawFactory;
+};
+
+typedef IceUtil::Handle<MediaOperationsCompare> MediaOperationsComparePtr;
+
 class MediaOperationsCoreApp : public IceBox::Service
 {
 public:
@@ -51,6 +91,7 @@ public:
 private:
 
     void createOperationFactories();
+    void registerWithServiceLocator();
 
     ServiceLocatorManagementPrx mManagement;
     Ice::ObjectAdapterPtr mAdapter;
@@ -58,6 +99,9 @@ private:
     UlawAlawFactoryPtr mUlawAlawFactory;
     MediaOperationFactoryPrx mUlawAlawFactoryProxy;
     ServiceManagementPrx mUlawAlawServiceManagement;
+
+    MediaOperationsComparePtr mMediaOperationsCompare;
+    ServiceLocatorParamsComparePrx mMediaOperationsComparePrx;
 };
 
 void MediaOperationsCoreApp::createOperationFactories()
@@ -66,10 +110,18 @@ void MediaOperationsCoreApp::createOperationFactories()
     mUlawAlawFactory = new UlawAlawFactory(mAdapter, lg);
     mUlawAlawFactoryProxy =
         MediaOperationFactoryPrx::uncheckedCast(mAdapter->addWithUUID(mUlawAlawFactory));
+}
 
+void MediaOperationsCoreApp::registerWithServiceLocator()
+{
     mUlawAlawServiceManagement =
         mManagement->addService(mUlawAlawFactoryProxy, mUlawAlawFactory->getName());
     mUlawAlawServiceManagement->addLocatorParams(mUlawAlawFactory->getLocatorParams(), mUlawAlawFactory->getName());
+
+    mMediaOperationsCompare = new MediaOperationsCompare(mUlawAlawFactory);
+    mMediaOperationsComparePrx = ServiceLocatorParamsComparePrx::uncheckedCast(mAdapter->addWithUUID(mMediaOperationsCompare));
+
+    mManagement->addCompare(CompareGuid, mMediaOperationsComparePrx);
 }
 
 void MediaOperationsCoreApp::start(
@@ -81,6 +133,7 @@ void MediaOperationsCoreApp::start(
     mAdapter = communicator->createObjectAdapter("MediaOperationsCoreAdapter");
 
     createOperationFactories();
+    registerWithServiceLocator();
 }
 
 void MediaOperationsCoreApp::stop()
diff --git a/src/ulaw_alaw.cpp b/src/ulaw_alaw.cpp
index 75e32d3..04e6608 100644
--- a/src/ulaw_alaw.cpp
+++ b/src/ulaw_alaw.cpp
@@ -301,12 +301,16 @@ UlawAlawFactory::UlawAlawFactory(const Ice::ObjectAdapterPtr& adapter,
 {
     MediaOperationAttributes ulawToAlaw;
     ulawToAlaw.inputFormat = new G711uLAW();
+    ulawToAlaw.inputFormat->name = "ulaw";
     ulawToAlaw.outputFormat = new G711aLAW();
+    ulawToAlaw.outputFormat->name = "alaw";
     ulawToAlaw.cost = 100; //XXX COST?
 
     MediaOperationAttributes alawToUlaw;
     alawToUlaw.inputFormat = new G711aLAW();
+    alawToUlaw.inputFormat->name = "alaw";
     alawToUlaw.outputFormat = new G711uLAW();
+    alawToUlaw.outputFormat->name = "ulaw";
     alawToUlaw.cost = 100; //XXX COST?
 
     mLocatorParams->attributes.push_back(ulawToAlaw);
@@ -385,7 +389,7 @@ const std::string& UlawAlawFactory::getName()
     return mName;
 }
 
-ServiceLocatorParamsPtr UlawAlawFactory::getLocatorParams()
+MediaOperationServiceLocatorParamsPtr UlawAlawFactory::getLocatorParams()
 {
     return mLocatorParams;
 }
diff --git a/src/ulaw_alaw.h b/src/ulaw_alaw.h
index b748ed1..9bfa7b3 100644
--- a/src/ulaw_alaw.h
+++ b/src/ulaw_alaw.h
@@ -40,7 +40,7 @@ public:
 
     const std::string& getName();
 
-    AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr getLocatorParams();
+    AsteriskSCF::Media::V1::MediaOperationServiceLocatorParamsPtr getLocatorParams();
 
 private:
     Ice::ObjectAdapterPtr mAdapter;

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


-- 
asterisk-scf/release/media_operations_core.git



More information about the asterisk-scf-commits mailing list