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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Feb 6 11:12:54 CST 2012


branch "master" has been updated
       via  5dcc557d1502add0161d9aa8b4ffdc14b5bcfba5 (commit)
      from  08da42c8d62e313744e028ebf951d4ebc092430e (commit)

Summary of changes:
 src/CMakeLists.txt               |    2 +-
 src/ComponentStateReplicator.cpp |  114 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 115 insertions(+), 1 deletions(-)
 create mode 100644 src/ComponentStateReplicator.cpp


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

    State replicator uses base ComponentStateReplicator class.

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

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


-- 
asterisk-scf/release/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list