[asterisk-scf-commits] asterisk-scf/integration/mediaformatgeneric.git branch "rename" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Dec 29 11:00:08 CST 2011


branch "rename" has been created
        at  34850d5d4c6af304af9822bff730ac12d83d436a (commit)

- Log -----------------------------------------------------------------
commit 34850d5d4c6af304af9822bff730ac12d83d436a
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Dec 28 12:17:21 2011 -0600

    Adjust for name changes in ice-util-cpp

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f1c03ac..2a0a433 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -4,12 +4,12 @@ include_directories(${astscf-ice-util-cpp_dir}/include)
 astscf_component_init(mediaformatgeneric)
 astscf_component_add_files(mediaformatgeneric Component.cpp)
 astscf_component_add_files(mediaformatgeneric MediaFormatGeneric.h)
-astscf_component_add_files(mediaformatgeneric GenericConfiguration.cpp)
-astscf_component_add_files(mediaformatgeneric GenericConfiguration.h)
+astscf_component_add_files(mediaformatgeneric Configuration.cpp)
+astscf_component_add_files(mediaformatgeneric Configuration.h)
 astscf_component_add_slices(mediaformatgeneric PROJECT AsteriskSCF/Configuration/MediaFormatGeneric/MediaFormatGenericConfigurationIf.ice)
 astscf_component_add_boost_libraries(mediaformatgeneric core thread)
 astscf_component_add_slice_collection_libraries(mediaformatgeneric ASTSCF)
 astscf_component_build_icebox(mediaformatgeneric)
-target_link_libraries(mediaformatgeneric astscf-ice-util-cpp LoggingClient)
+target_link_libraries(mediaformatgeneric ASTSCFIceUtilCpp LoggingClient)
 astscf_component_install(mediaformatgeneric)
 

commit 151e606d447e25ef531c2b6aca271e60323c9746
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Dec 27 16:33:11 2011 -0600

    Adjust for change for T.38 header name change.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 92892f0..f1c03ac 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -10,6 +10,6 @@ astscf_component_add_slices(mediaformatgeneric PROJECT AsteriskSCF/Configuration
 astscf_component_add_boost_libraries(mediaformatgeneric core thread)
 astscf_component_add_slice_collection_libraries(mediaformatgeneric ASTSCF)
 astscf_component_build_icebox(mediaformatgeneric)
-target_link_libraries(mediaformatgeneric astscf-ice-util-cpp logging-client)
+target_link_libraries(mediaformatgeneric astscf-ice-util-cpp LoggingClient)
 astscf_component_install(mediaformatgeneric)
 
diff --git a/src/Component.cpp b/src/Component.cpp
index 15820e9..a685379 100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@ -23,8 +23,8 @@
 #include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
 #include <AsteriskSCF/Media/MediaIf.h>
 #include <AsteriskSCF/Media/SDP/MediaSDPIf.h>
-#include <AsteriskSCF/Media/Formats/AudioFormats.h>
-#include <AsteriskSCF/Media/Formats/T38UdptlFormat.h>
+#include <AsteriskSCF/Media/Formats/AudioFormatsIf.h>
+#include <AsteriskSCF/Media/Formats/T38UDPTLFormatIf.h>
 #include <AsteriskSCF/System/Component/ComponentServiceIf.h>
 #include <AsteriskSCF/Logger/IceLogger.h>
 #include <AsteriskSCF/Logger.h>

commit 2774dadcf3722dfe8af461b90e1d3444bff23ce8
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Dec 1 10:55:02 2011 -0600

    Some initial file renaming work.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7ff06ab..92892f0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -4,8 +4,8 @@ include_directories(${astscf-ice-util-cpp_dir}/include)
 astscf_component_init(mediaformatgeneric)
 astscf_component_add_files(mediaformatgeneric Component.cpp)
 astscf_component_add_files(mediaformatgeneric MediaFormatGeneric.h)
-astscf_component_add_files(mediaformatgeneric MediaFormatGenericConfiguration.cpp)
-astscf_component_add_files(mediaformatgeneric MediaFormatGenericConfiguration.h)
+astscf_component_add_files(mediaformatgeneric GenericConfiguration.cpp)
+astscf_component_add_files(mediaformatgeneric GenericConfiguration.h)
 astscf_component_add_slices(mediaformatgeneric PROJECT AsteriskSCF/Configuration/MediaFormatGeneric/MediaFormatGenericConfigurationIf.ice)
 astscf_component_add_boost_libraries(mediaformatgeneric core thread)
 astscf_component_add_slice_collection_libraries(mediaformatgeneric ASTSCF)
diff --git a/src/Component.cpp b/src/Component.cpp
index 09694c7..15820e9 100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@ -27,12 +27,12 @@
 #include <AsteriskSCF/Media/Formats/T38UdptlFormat.h>
 #include <AsteriskSCF/System/Component/ComponentServiceIf.h>
 #include <AsteriskSCF/Logger/IceLogger.h>
-#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Logger.h>
 #include <AsteriskSCF/Discovery/LocatorRegistrationWrapper.h>
 #include <AsteriskSCF/Component/Component.h>
 
 #include "MediaFormatGeneric.h"
-#include "MediaFormatGenericConfiguration.h"
+#include "Configuration.h"
 #include "MediaFormatGenericConfigurationIf.h"
 
 using namespace std;
diff --git a/src/MediaFormatGenericConfiguration.cpp b/src/Configuration.cpp
similarity index 99%
rename from src/MediaFormatGenericConfiguration.cpp
rename to src/Configuration.cpp
index a125576..2f29437 100644
--- a/src/MediaFormatGenericConfiguration.cpp
+++ b/src/Configuration.cpp
@@ -23,7 +23,7 @@
 #include <AsteriskSCF/System/Component/ConfigurationIf.h>
 
 #include "MediaFormatGenericConfigurationIf.h"
-#include "MediaFormatGenericConfiguration.h"
+#include "Configuration.h"
 #include "MediaFormatGeneric.h"
 
 using namespace AsteriskSCF::System::Configuration::V1;
diff --git a/src/MediaFormatGenericConfiguration.h b/src/Configuration.h
similarity index 100%
rename from src/MediaFormatGenericConfiguration.h
rename to src/Configuration.h

commit 509edd9fe10e802048ef108bd8f0874724468830
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Oct 3 19:44:57 2011 -0300

    Add support for the T.38 media format.

diff --git a/src/Component.cpp b/src/Component.cpp
index 209e69b..09694c7 100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@ -18,10 +18,13 @@
 #include <IceBox/IceBox.h>
 #include <IceUtil/UUID.h>
 
+#include <boost/lexical_cast.hpp>
+
 #include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
 #include <AsteriskSCF/Media/MediaIf.h>
 #include <AsteriskSCF/Media/SDP/MediaSDPIf.h>
 #include <AsteriskSCF/Media/Formats/AudioFormats.h>
+#include <AsteriskSCF/Media/Formats/T38UdptlFormat.h>
 #include <AsteriskSCF/System/Component/ComponentServiceIf.h>
 #include <AsteriskSCF/Logger/IceLogger.h>
 #include <AsteriskSCF/logger.h>
@@ -37,6 +40,7 @@ using namespace AsteriskSCF::Core::Discovery::V1;
 using namespace AsteriskSCF::Media::V1;
 using namespace AsteriskSCF::Media::SDP::V1;
 using namespace AsteriskSCF::Media::Formats::Audio::V1;
+using namespace AsteriskSCF::Media::Formats::T38Udptl::V1;
 using namespace AsteriskSCF::Configuration::FormatGeneric::V1;
 using namespace AsteriskSCF::System::Component::V1;
 using namespace AsteriskSCF::System::Logging;
@@ -91,7 +95,7 @@ void SDPDescriptorCompareServiceImpl::removeAllFormats()
     mSupportedFormats.clear();
 }
 
-FormatPtr SDPDescriptorServiceImpl::getNamedFormat(const std::string& name, int, int, const Ice::StringSeq&, const Ice::Current&)
+FormatPtr SDPDescriptorServiceImpl::getNamedFormat(const std::string& name, int, int, const Ice::StringSeq& params, const Ice::Current&)
 {
     boost::shared_lock<boost::shared_mutex> lock(mLock);
     std::map<std::string, FormatPtr>::const_iterator format = mNamedFormats.find(name);
@@ -101,7 +105,43 @@ FormatPtr SDPDescriptorServiceImpl::getNamedFormat(const std::string& name, int,
         return 0;
     }
 
-    return format->second;
+    if (name == "t38udptl")
+    {
+        T38UdptlFormatPtr t38Format = new T38UdptlFormat();
+
+        t38Format->name = "t38udptl";
+        
+        for (Ice::StringSeq::const_iterator param = params.begin();
+             param != params.end();
+             ++param)
+        {
+	    size_t separator = (*param).find_first_of("=");
+	    std::string param_name = (*param).substr(0, separator);
+	    std::string param_value = (*param).substr(separator + 1);
+
+	    if (param_name == "maxdatagram")
+	    {
+		t38Format->maxDatagram = boost::lexical_cast<int>(param_value);
+	    }
+	    else if (param_name == "errorcorrect")
+	    {
+		if (param_value == "fec")
+		{
+		    t38Format->errorCorrection = AsteriskSCF::Media::UDPTL::V1::FEC;
+		}
+		else if (param_value == "redundancy")
+		{
+		    t38Format->errorCorrection = AsteriskSCF::Media::UDPTL::V1::REDUNDANCY;
+		}
+	    }
+        }
+
+        return t38Format;
+    }
+    else
+    {
+        return format->second;
+    }
 }
 
 FormatPtr SDPDescriptorServiceImpl::getDescribedFormat(const SDPDescriptorPtr& descriptor, const Ice::Current&)
@@ -128,7 +168,103 @@ FormatPtr SDPDescriptorServiceImpl::getDescribedFormat(const SDPDescriptorPtr& d
             return 0;
         }
 
-        return format->second;
+        if (descriptor->type == "image" && descriptor->subtype == "UDPTL")
+        {
+            T38UdptlFormatPtr t38Format = new T38UdptlFormat();
+
+            t38Format->name = "t38udptl";
+
+            for (SDPFormatParameterSeq::const_iterator param = descriptor->parameters.begin();
+                 param != descriptor->parameters.end();
+                 ++param)
+            {
+                std::string param_name = (*param), param_value;
+                size_t separator = (*param).find_first_of(":");
+
+                if (separator != string::npos)
+                {
+                    param_name = (*param).substr(0, separator);
+                    param_value = (*param).substr(separator + 1);
+                }
+
+                if (param_name == "T38FaxVersion")
+                {
+                    t38Format->version = boost::lexical_cast<int>(param_value);
+		    std::cout << "Set version to " << t38Format->version << std::endl;
+                }
+                else if (param_name == "T38MaxBitRate")
+                {
+                    if (param_value == "2400")
+                    {
+                        t38Format->faxRate = RATE_2400;
+                    }
+                    else if (param_value == "4800")
+                    {
+                        t38Format->faxRate = RATE_4800;
+                    }
+                    else if (param_value == "7200")
+                    {
+                        t38Format->faxRate = RATE_7200;
+                    }
+                    else if (param_value == "9600")
+                    {
+                        t38Format->faxRate = RATE_9600;
+                    }
+                    else if (param_value == "12000")
+                    {
+                        t38Format->faxRate = RATE_12000;
+                    }
+                    else if (param_value == "14400")
+                    {
+                        t38Format->faxRate = RATE_14400;
+                    }
+                }
+                else if (param_name == "T38FaxFillBitRemoval")
+                {
+                    t38Format->fillBitRemoval = true;
+                }
+                else if (param_name == "T38FaxTranscodingMMR")
+                {
+                    t38Format->transcodingMmr = true;
+                }
+                else if (param_name == "T38FaxTranscodingJBIG")
+                {
+                    t38Format->transcodingJbig = true;
+                }
+                else if (param_name == "T38FaxRateManagement")
+                {
+                    if (param_value == "transferredTCF")
+                    {
+                        t38Format->faxRateManagement = TRANSFERRED_TCF;
+                    }
+                    else if (param_value == "localTCF")
+                    {
+                        t38Format->faxRateManagement = LOCAL_TCF;
+                    }
+                }
+                else if (param_name == "T38FaxMaxDatagram")
+                {
+                    t38Format->maxDatagram = boost::lexical_cast<int>(param_value);
+                }
+                else if (param_name == "T38FaxUdpEC")
+                {
+                    if (param_value == "t38UDPFEC")
+                    {
+                        t38Format->errorCorrection = AsteriskSCF::Media::UDPTL::V1::FEC;
+                    }
+                    else if (param_value == "t38UDPRedundancy")
+                    {
+                        t38Format->errorCorrection = AsteriskSCF::Media::UDPTL::V1::REDUNDANCY;
+                    }
+                }
+            }
+
+            return t38Format;
+        }
+        else
+        {
+            return format->second;
+        }
     }
 
     // This will never get reached but just in case the compiler is silly...
@@ -145,7 +281,88 @@ SDPDescriptorPtr SDPDescriptorServiceImpl::getDescriptor(const FormatPtr& format
         return 0;
     }
 
-    return descriptor->second;
+    if (format->name == "t38udptl")
+    {
+        T38UdptlFormatPtr t38Format = T38UdptlFormatPtr::dynamicCast(format);
+
+        if (!t38Format)
+        {
+            return 0;
+        }
+
+        SDPDescriptorPtr t38SDP = new SDPDescriptor();
+        t38SDP->payload = 96;
+        t38SDP->type = "image";
+        t38SDP->subtype = "UDPTL";
+
+        t38SDP->parameters.push_back("T38FaxVersion:" + boost::lexical_cast<std::string>(t38Format->version));
+
+        if (t38Format->faxRate == RATE_2400)
+        {
+            t38SDP->parameters.push_back("T38MaxBitRate:2400");
+        }
+        else if (t38Format->faxRate == RATE_4800)
+        {
+            t38SDP->parameters.push_back("T38MaxBitRate:4800");
+        }
+        else if (t38Format->faxRate == RATE_7200)
+        {
+            t38SDP->parameters.push_back("T38MaxBitRate:7200");
+        }
+        else if (t38Format->faxRate == RATE_9600)
+        {
+            t38SDP->parameters.push_back("T38MaxBitRate:9600");
+        }
+        else if (t38Format->faxRate == RATE_12000)
+        {
+            t38SDP->parameters.push_back("T38MaxBitRate:12000");
+        }
+        else if (t38Format->faxRate == RATE_14400)
+        {
+            t38SDP->parameters.push_back("T38MaxBitRate:14400");
+        }
+
+        if (t38Format->fillBitRemoval == true)
+        {
+            t38SDP->parameters.push_back("T38FaxFillBitRemoval");
+        }
+
+        if (t38Format->transcodingMmr == true)
+        {
+            t38SDP->parameters.push_back("T38TranscodingMMR");
+        }
+
+        if (t38Format->transcodingJbig == true)
+        {
+            t38SDP->parameters.push_back("T38TranscodingJBIG");
+        }
+
+        if (t38Format->faxRateManagement == TRANSFERRED_TCF)
+        {
+            t38SDP->parameters.push_back("T38FaxRateManagement:transferredTCF");
+        }
+        else if (t38Format->faxRateManagement == LOCAL_TCF)
+        {
+            t38SDP->parameters.push_back("T38FaxRateManagement:localTCF");
+        }
+
+        t38SDP->parameters.push_back("T38FaxMaxDatagram:" + boost::lexical_cast<std::string>(t38Format->maxDatagram));
+
+        if (t38Format->errorCorrection == AsteriskSCF::Media::UDPTL::V1::FEC)
+        {
+            t38SDP->parameters.push_back("T38FaxUdpEC:t38UDPFEC");
+        }
+        else if (t38Format->errorCorrection == AsteriskSCF::Media::UDPTL::V1::REDUNDANCY)
+        {
+            t38SDP->parameters.push_back("T38FaxUdpEC:t38UDPRedundancy");
+        }
+
+        return t38SDP;
+    }
+    else
+    {
+        return descriptor->second;
+    }
 }
 
 /**
@@ -283,6 +500,16 @@ void Component::createPrimaryServices()
         mSdpDescriptorService->addFormat(alaw->name, alaw, alawSDP);
         mSdpComparator->addFormat(alaw->name);
 
+        // Add the T.38 media format
+        T38UdptlFormatPtr t38 = new T38UdptlFormat();
+        t38->name = "t38udptl";
+        SDPDescriptorPtr t38SDP = new SDPDescriptor();
+        t38SDP->payload = 96;
+        t38SDP->type = "image";
+        t38SDP->subtype = "UDPTL";
+        mSdpDescriptorService->addFormat(t38->name, t38, t38SDP);
+        mSdpComparator->addFormat(t38->name);
+
         // Register our custom comparator with the service locator
         ServiceLocatorParamsComparePrx comparatorServicePrx = ServiceLocatorParamsComparePrx::uncheckedCast(
 	    getServiceAdapter()->addWithUUID(mSdpComparator));

commit 408e18897ab9e63f0c30d66032baa15d7a95f97c
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue Sep 20 12:03:15 2011 -0500

    This Component now uses the base Component class.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e216ea7..7ff06ab 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,7 +1,8 @@
 include_directories(${logger_dir}/include)
+include_directories(${astscf-ice-util-cpp_dir}/include)
 
 astscf_component_init(mediaformatgeneric)
-astscf_component_add_files(mediaformatgeneric MediaFormatGeneric.cpp)
+astscf_component_add_files(mediaformatgeneric Component.cpp)
 astscf_component_add_files(mediaformatgeneric MediaFormatGeneric.h)
 astscf_component_add_files(mediaformatgeneric MediaFormatGenericConfiguration.cpp)
 astscf_component_add_files(mediaformatgeneric MediaFormatGenericConfiguration.h)
@@ -9,6 +10,6 @@ astscf_component_add_slices(mediaformatgeneric PROJECT AsteriskSCF/Configuration
 astscf_component_add_boost_libraries(mediaformatgeneric core thread)
 astscf_component_add_slice_collection_libraries(mediaformatgeneric ASTSCF)
 astscf_component_build_icebox(mediaformatgeneric)
-target_link_libraries(mediaformatgeneric logging-client)
+target_link_libraries(mediaformatgeneric astscf-ice-util-cpp logging-client)
 astscf_component_install(mediaformatgeneric)
 
diff --git a/src/MediaFormatGeneric.cpp b/src/Component.cpp
similarity index 54%
rename from src/MediaFormatGeneric.cpp
rename to src/Component.cpp
index 33c84e6..209e69b 100644
--- a/src/MediaFormatGeneric.cpp
+++ b/src/Component.cpp
@@ -25,6 +25,8 @@
 #include <AsteriskSCF/System/Component/ComponentServiceIf.h>
 #include <AsteriskSCF/Logger/IceLogger.h>
 #include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Discovery/LocatorRegistrationWrapper.h>
+#include <AsteriskSCF/Component/Component.h>
 
 #include "MediaFormatGeneric.h"
 #include "MediaFormatGenericConfiguration.h"
@@ -38,53 +40,14 @@ using namespace AsteriskSCF::Media::Formats::Audio::V1;
 using namespace AsteriskSCF::Configuration::FormatGeneric::V1;
 using namespace AsteriskSCF::System::Component::V1;
 using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::System::Configuration::V1;
+using namespace AsteriskSCF::Discovery;
 
 namespace
 {
 Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaFormatGeneric");
 }
 
-/**
- * Implementation of the IceBox::Service class
- */
-class MediaFormatGenericApp : public IceBox::Service
-{
-public:
-    void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&);
-    void stop();
-
-private:
-    /**
-     * Ice Communicator used for this service.
-     */
-    Ice::CommunicatorPtr mCommunicator;
-
-    /**
-     * Object adapter that stuff is associated with.
-     */
-    Ice::ObjectAdapterPtr mAdapter;
-
-    /**
-     * A proxy to the service locator manager for our SDP descriptor service.
-     */
-    ServiceManagementPrx mServiceManagement;
-
-    /**
-     * A proxy to the service locator manager for our configuration service.
-     */
-    ServiceManagementPrx mConfigurationServiceManagement;
-
-    /**
-     * A proxy to the service locator management service.
-     */
-    ServiceLocatorManagementPrx mManagement;
-
-    /**
-     * Unique guid for SDP descriptor service name comparator.
-     */
-    std::string mCompareGuid;
-};
-
 bool SDPDescriptorCompareServiceImpl::isSupported(const ServiceLocatorParamsPtr& params, const Ice::Current&)
 {
     boost::shared_lock<boost::shared_mutex> lock(mLock);
@@ -250,100 +213,161 @@ void SDPDescriptorServiceImpl::removeAllFormats()
     mFormatDescriptors.clear();
 }
 
+class Component : public AsteriskSCF::Component::Component
+{
+public:
+    Component() : 
+        AsteriskSCF::Component::Component(lg, 
+                                          "MediaFormatGeneric")   {}
+
+private:
+    // Optional base Component notification overrides. 
+    virtual void createBackplaneServices();
+    virtual void prepareBackplaneServicesForDiscovery();
+
+    // Required base Component overrides
+    virtual void createPrimaryServices();
+    virtual void preparePrimaryServicesForDiscovery();
+    virtual void createReplicationStateListeners() {} // No-op. This component doesn't replicate.
+    virtual void stopListeningToStateReplicators() {}
+    virtual void listenToStateReplicators() {}
+    virtual void findRemoteServices() {}
+
+    SDPDescriptorServiceImplPtr mSdpDescriptorService;
+    SDPDescriptorServicePrx mSdpDescriptorPrx;
+    LocatorRegistrationWrapperPtr mSdpDescriptorRegistration;
+
+    ConfigurationServiceImplPtr mConfigService;
+    ConfigurationServicePrx mConfigServicePrx;
+    LocatorRegistrationWrapperPtr mConfigurationRegistration;
+
+    // Unique guid for SDP descriptor service name comparator.
+    std::string mCompareGuid;
+    SDPDescriptorCompareServiceImplPtr mSdpComparator;
+};
+
 /**
- * Implementation of the IceBox::Service::start method.
+ * Create the objects that implement the main services this component provides 
+ * the system.
  */
-void MediaFormatGenericApp::start(const std::string&, const Ice::CommunicatorPtr& communicator,
-                                  const Ice::StringSeq&)
+void Component::createPrimaryServices()
+{
+    try
+    {
+        // Create an instance of our SDP descriptor service
+        mSdpDescriptorService = new SDPDescriptorServiceImpl();
+        mSdpDescriptorPrx = SDPDescriptorServicePrx::uncheckedCast(getServiceAdapter()->addWithUUID(mSdpDescriptorService));
+
+        // Create an instance of our custom comparator service
+        mSdpComparator = new SDPDescriptorCompareServiceImpl();
+
+        // Add the ulaw audio format
+        G711uLAWPtr ulaw = new G711uLAW();
+        ulaw->name = "ulaw";
+        SDPDescriptorPtr ulawSDP = new SDPDescriptor();
+        ulawSDP->payload = 0;
+        ulawSDP->type = "audio";
+        ulawSDP->subtype = "PCMU";
+        ulawSDP->samplerate = 8000;
+        mSdpDescriptorService->addFormat(ulaw->name, ulaw, ulawSDP);
+        mSdpComparator->addFormat(ulaw->name);
+
+        // Add the alaw audio format
+        G711aLAWPtr alaw = new G711aLAW();
+        alaw->name = "alaw";
+        SDPDescriptorPtr alawSDP = new SDPDescriptor();
+        alawSDP->payload = 8;
+        alawSDP->type = "audio";
+        alawSDP->subtype = "PCMA";
+        alawSDP->samplerate = 8000;
+        mSdpDescriptorService->addFormat(alaw->name, alaw, alawSDP);
+        mSdpComparator->addFormat(alaw->name);
+
+        // Register our custom comparator with the service locator
+        ServiceLocatorParamsComparePrx comparatorServicePrx = ServiceLocatorParamsComparePrx::uncheckedCast(
+	    getServiceAdapter()->addWithUUID(mSdpComparator));
+        mCompareGuid = getName() + ".Media/SDP_Descriptor";
+        getServiceLocatorManagement()->addCompare(mCompareGuid, comparatorServicePrx);
+
+    }
+    catch(const Ice::Exception& e)
+    {
+       lg(Critical) << getName() << " : " << BOOST_CURRENT_FUNCTION << " : " << e.what();
+    }
+}
+
+void Component::createBackplaneServices()
 {
-    // Use the configured value for the service locator management to create a proxy
-    mManagement = ServiceLocatorManagementPrx::checkedCast(communicator->propertyToProxy("ServiceLocatorManagementProxy"));
-    
-    mAdapter = communicator->createObjectAdapter("MediaFormatGenericAdapter");
-
-    // Create an instance of our SDP descriptor service
-    SDPDescriptorServiceImplPtr descriptorService = new SDPDescriptorServiceImpl();
-
-    // Create an instance of our custom comparator service
-    SDPDescriptorCompareServiceImplPtr comparatorService = new SDPDescriptorCompareServiceImpl();
-
-    // Create an instance of our configuration service
-    ConfigurationServiceImplPtr configurationService = new ConfigurationServiceImpl(descriptorService, comparatorService);
-
-    // Add the ulaw audio format
-    G711uLAWPtr ulaw = new G711uLAW();
-    ulaw->name = "ulaw";
-    SDPDescriptorPtr ulawSDP = new SDPDescriptor();
-    ulawSDP->payload = 0;
-    ulawSDP->type = "audio";
-    ulawSDP->subtype = "PCMU";
-    ulawSDP->samplerate = 8000;
-    descriptorService->addFormat(ulaw->name, ulaw, ulawSDP);
-    comparatorService->addFormat(ulaw->name);
-
-    // Add the alaw audio format
-    G711aLAWPtr alaw = new G711aLAW();
-    alaw->name = "alaw";
-    SDPDescriptorPtr alawSDP = new SDPDescriptor();
-    alawSDP->payload = 8;
-    alawSDP->type = "audio";
-    alawSDP->subtype = "PCMA";
-    alawSDP->samplerate = 8000;
-    descriptorService->addFormat(alaw->name, alaw, alawSDP);
-    comparatorService->addFormat(alaw->name);
-
-    // Register our custom comparator with the service locator
-    ServiceLocatorParamsComparePrx comparatorServicePrx = ServiceLocatorParamsComparePrx::uncheckedCast(
-	mAdapter->addWithUUID(comparatorService));
-    mCompareGuid = IceUtil::generateUUID();
-    mManagement->addCompare(mCompareGuid, comparatorServicePrx);
-
-    // Add our configuration service to the service locator
-    Ice::ObjectPrx configurationServicePrx = mAdapter->addWithUUID(configurationService);
-    mConfigurationServiceManagement = ServiceManagementPrx::uncheckedCast(
-        mManagement->addService(configurationServicePrx, "Configuration/MediaFormatGeneric"));
-
-    // Populate some locator params so we can be found
-    ConfigurationParamsPtr configurationParams = new ConfigurationParams();
-    configurationParams->category = ConfigurationDiscoveryCategory;
-
-    // Tada! Add these and boom we are found
-    mConfigurationServiceManagement->addLocatorParams(configurationParams, "");
-
-    // Add ourselves to the service locator
-    Ice::ObjectPrx descriptorServicePrx = mAdapter->addWithUUID(descriptorService);
-    mServiceManagement = ServiceManagementPrx::uncheckedCast(
-	mManagement->addService(descriptorServicePrx, "Media/SDP_Descriptor"));
-
-    // Populate some locator parameters so we can be found
-    SDPDescriptorServiceLocatorParamsPtr params = new SDPDescriptorServiceLocatorParams();
-    params->category = "Media/SDP_Descriptor";
-
-    // Now we can add these parameters and tada we shall be found
-    mServiceManagement->addLocatorParams(params, mCompareGuid);
-
-    mAdapter->activate();
+    // Include the base Component services. 
+    AsteriskSCF::Component::Component::createBackplaneServices();
+
+    try
+    {
+        // Create an instance of our configuration service
+        mConfigService = new ConfigurationServiceImpl(mSdpDescriptorService, mSdpComparator);
+
+        mConfigServicePrx = ConfigurationServicePrx::uncheckedCast(
+            getBackplaneAdapter()->addWithUUID(mConfigService));
+
+        lg(Debug) << "Created Generic Format Configuration servant";
+
+    }
+    catch(const Ice::Exception& e)
+    {
+       lg(Critical) << getName() << " : " << BOOST_CURRENT_FUNCTION << " : " << e.what();
+    }
 }
 
 /**
- * Implementation of the IceBox::Service::stop method.
+ * Register this component's primary public interfaces with the Service Locator.
+ * This enables other Asterisk SCF components to locate our interfaces.
  */
-void MediaFormatGenericApp::stop()
+void Component::preparePrimaryServicesForDiscovery()
 {
-    // Remove our comparator from the service locator
-    mManagement->removeCompare(mCompareGuid);
+    try
+    {
+        // Wrap our authentication extensions point for the Service Locator.
+        mSdpDescriptorRegistration = wrapServiceForRegistration(mSdpDescriptorPrx, 
+                                                                "Media/SDP_Descriptor",
+                                                                getServiceName(),
+                                                                getName());
+
+        managePrimaryService(mSdpDescriptorRegistration);
+    }
+    catch(const std::exception& e)
+    {
+        lg(Error) << "Unable to publish component interfaces in " << getName() << BOOST_CURRENT_FUNCTION << 
+            ". Exception: " << e.what();
+        throw; // rethrow
+    }
+}
 
-    // Remove our configuration service from the service locator
-    mConfigurationServiceManagement->unregister();
 
-    // Remove our SDP descriptor service from the service locator
-    mServiceManagement->unregister();
+/**
+ * Prepare this component's backplane interfaces for discovery via the Service Locator.
+ */
+void Component::prepareBackplaneServicesForDiscovery()
+{
+    // Insure the default Component services are prepped. 
+    AsteriskSCF::Component::Component::prepareBackplaneServicesForDiscovery();
+
+    try
+    {
+        // Wrap our configuration interface for the Service Locator.
+        mConfigurationRegistration = wrapServiceForRegistration(mConfigServicePrx, 
+                                                                ConfigurationDiscoveryCategory);
+        manageBackplaneService(mConfigurationRegistration);
+    }
+    catch(const std::exception& e)
+    {
+        lg(Error) << "Exception in " << getName() << ", " << BOOST_CURRENT_FUNCTION <<  " : " << e.what();
+    }
 }
 
 extern "C"
 {
 ASTSCF_DLL_EXPORT IceBox::Service* create(Ice::CommunicatorPtr)
 {
-    return new MediaFormatGenericApp;
+    return new Component;
 }
 }

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


-- 
asterisk-scf/integration/mediaformatgeneric.git



More information about the asterisk-scf-commits mailing list