[asterisk-scf-commits] asterisk-scf/integration/media_rtp_pjmedia.git branch "replication" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Wed Jan 19 16:53:55 CST 2011
branch "replication" has been updated
via 486c8f5bec883c8f01a3a933aa5cdce1aff12bdd (commit)
via 68adbcebbfa998bf8dcefdb0b8c9be7a237f487a (commit)
via 2189bc87234ec3ab1635b8ae76a24369b4ac0a81 (commit)
via e605e6f1425c816fd588b9d5ee4c35215e1e9a40 (commit)
from 4fa74bfce6ca302972f471447269c56e6075d660 (commit)
Summary of changes:
CMakeLists.txt | 5 ++---
local-slice/CMakeLists.txt | 3 ---
local-slice/RtpStateReplicationIf.ice | 7 ++++---
src/CMakeLists.txt | 27 ++++++++++++++-------------
src/MediaRTPpjmedia.cpp | 17 +++++++++--------
src/RTPSession.cpp | 9 +++++----
src/RTPSink.cpp | 9 +++++----
src/RTPSource.cpp | 11 ++++++-----
src/RtpStateReplicator.h | 4 +++-
src/RtpStateReplicatorApp.cpp | 9 +++++----
src/RtpStateReplicatorListener.cpp | 4 ++--
test/CMakeLists.txt | 9 +++++----
test/TestRTPpjmedia.cpp | 7 ++++---
13 files changed, 64 insertions(+), 57 deletions(-)
delete mode 100644 local-slice/CMakeLists.txt
- Log -----------------------------------------------------------------
commit 486c8f5bec883c8f01a3a933aa5cdce1aff12bdd
Merge: 4fa74bf 68adbce
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Wed Jan 19 16:48:56 2011 -0600
Merge branch 'master' into replication
Conflicts:
src/CMakeLists.txt
src/MediaRTPpjmedia.cpp
src/RTPSession.cpp
src/RTPSink.cpp
src/RTPSource.cpp
test/CMakeLists.txt
test/TestRTPpjmedia.cpp
diff --cc local-slice/RtpStateReplicationIf.ice
index b449ee5,0000000..bd04de3
mode 100644,000000..100644
--- a/local-slice/RtpStateReplicationIf.ice
+++ b/local-slice/RtpStateReplicationIf.ice
@@@ -1,102 -1,0 +1,103 @@@
+/*
+ * 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"
++
++#include <AsteriskSCF/Media/MediaIf.ice>
++#include <AsteriskSCF/Media/RTP/MediaRTPIf.ice>
++#include <AsteriskSCF/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 RtpGeneralStateItem extends RtpStateItem
+ {
+ AsteriskSCF::Core::Discovery::V1::ServiceManagement *mServiceManagement;
+ };
+
+ class RtpSessionStateItem extends RtpStateItem
+ {
+ Ice::Identity mSessionIdentity;
+ int mPort;
+ 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
diff --cc src/CMakeLists.txt
index f30e2bc,0c7dd07..fa8662e
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@@ -6,17 -6,7 +6,13 @@@
# All rights reserved.
#
+
+include_directories(${utils_dir}/StateReplicator/src)
+include_directories(${utils_dir}/SmartProxy/src)
+
++asterisk_scf_slice_include_directories(${API_SLICE_DIR})
++
asterisk_scf_component_init(media_rtp_pjmedia CXX)
- asterisk_scf_component_add_slice(media_rtp_pjmedia ServiceLocatorIf)
- asterisk_scf_component_add_slice(media_rtp_pjmedia MediaIf)
- asterisk_scf_component_add_slice(media_rtp_pjmedia MediaRTPIf)
- asterisk_scf_component_add_slice(media_rtp_pjmedia ComponentServiceIf)
- asterisk_scf_component_add_slice(media_rtp_pjmedia ReplicaIf)
- asterisk_scf_component_add_slice(media_rtp_pjmedia RtpStateReplicationIf)
asterisk_scf_component_add_file(media_rtp_pjmedia MediaRTPpjmedia.cpp)
asterisk_scf_component_add_file(media_rtp_pjmedia RTPSession.cpp)
asterisk_scf_component_add_file(media_rtp_pjmedia RTPSource.cpp)
@@@ -24,8 -14,6 +20,9 @@@ asterisk_scf_component_add_file(media_r
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_slice(media_rtp_pjmedia ../local-slice/RtpStateReplicationIf.ice)
asterisk_scf_component_add_boost_libraries(media_rtp_pjmedia core thread)
if(NOT logger_dir)
@@@ -41,21 -30,3 +39,24 @@@ pjproject_link(media_rtp_pjmedia pjlib-
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 RtpStateReplicationIf)
- asterisk_scf_component_add_slice(RtpStateReplicator RoutingIf)
- asterisk_scf_component_add_slice(RtpStateReplicator MediaRTPIf)
++#This line allows us to use the templated state replicator
++#code. This statement is not the most permanent of changes
++#and assumes the directories are structured in the way that
++#gitall structures them.
++include_directories(${utils_dir}/StateReplicator/include)
++include_directories(${utils_dir}/SmartProxy/include)
++include_directories(${API_INCLUDE_DIR})
+
+asterisk_scf_component_add_file(RtpStateReplicator RtpStateReplicatorApp.cpp)
+asterisk_scf_component_add_file(RtpStateReplicator RtpStateReplicator.h)
++asterisk_scf_component_add_slice(RtpStateReplicator ../local-slice/RtpStateReplicationIf.ice)
+
+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 --cc src/MediaRTPpjmedia.cpp
index f770788,6fb92b3..4a1d0ee
--- a/src/MediaRTPpjmedia.cpp
+++ b/src/MediaRTPpjmedia.cpp
@@@ -23,18 -22,14 +23,19 @@@
#include <boost/shared_ptr.hpp>
- #include "Core/Discovery/ServiceLocatorIf.h"
- #include "Media/MediaIf.h"
- #include "Media/RTP/MediaRTPIf.h"
- #include "System/Component/ComponentServiceIf.h"
- #include "IceLogger.h"
- #include "logger.h"
+ #include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
+ #include <AsteriskSCF/Media/MediaIf.h>
+ #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
+ #include <AsteriskSCF/System/Component/ComponentServiceIf.h>
++#include <AsteriskSCF/System/Component/ReplicaIf.h>
+ #include <AsteriskSCF/Logger/IceLogger.h>
+ #include <AsteriskSCF/logger.h>
++#include <AsteriskSCF/SmartProxy.h>
++
+#include "RtpStateReplicationIf.h"
- #include "ReplicaIf.h"
- #include "SmartProxy.h"
#include "RTPSession.h"
+#include "RtpStateReplicator.h"
using namespace std;
using namespace AsteriskSCF::Core::Discovery::V1;
diff --cc src/RTPSession.cpp
index 15633ef,fa6fbf7..5e7f33e
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@@ -20,11 -19,8 +20,12 @@@
#include <pjlib.h>
#include <pjmedia.h>
- #include "Media/MediaIf.h"
- #include "Media/RTP/MediaRTPIf.h"
+ #include <AsteriskSCF/Media/MediaIf.h>
+ #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
++#include <AsteriskSCF/System/Component/ReplicaIf.h>
++#include <AsteriskSCF/SmartProxy.h>
++
+#include "RtpStateReplicationIf.h"
- #include "ReplicaIf.h"
- #include "SmartProxy.h"
#include "RTPSession.h"
#include "RTPSource.h"
diff --cc src/RTPSink.cpp
index ed63b32,23d7bdd..e20f86d
--- a/src/RTPSink.cpp
+++ b/src/RTPSink.cpp
@@@ -20,11 -19,8 +20,12 @@@
#include <pjlib.h>
#include <pjmedia.h>
- #include "Media/MediaIf.h"
- #include "Media/RTP/MediaRTPIf.h"
+ #include <AsteriskSCF/Media/MediaIf.h>
+ #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
++#include <AsteriskSCF/System/Component/ReplicaIf.h>
++#include <AsteriskSCF/SmartProxy.h>
++
+#include "RtpStateReplicationIf.h"
- #include "ReplicaIf.h"
- #include "SmartProxy.h"
#include "RTPSession.h"
#include "RTPSink.h"
diff --cc src/RTPSource.cpp
index 9590b6d,7125fb4..39c52e2
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@@ -20,11 -19,9 +20,13 @@@
#include <pjlib.h>
#include <pjmedia.h>
- #include "Media/MediaIf.h"
- #include "Media/RTP/MediaRTPIf.h"
+ #include <AsteriskSCF/Media/MediaIf.h>
+ #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
+ #include <AsteriskSCF/logger.h>
++#include <AsteriskSCF/System/Component/ReplicaIf.h>
++#include <AsteriskSCF/SmartProxy.h>
++
+#include "RtpStateReplicationIf.h"
- #include "ReplicaIf.h"
- #include "SmartProxy.h"
#include "RTPSession.h"
#include "RTPSource.h"
diff --cc src/RtpStateReplicator.h
index d3bc6c9,0000000..34dc017
mode 100644,000000..100644
--- a/src/RtpStateReplicator.h
+++ b/src/RtpStateReplicator.h
@@@ -1,38 -1,0 +1,40 @@@
+/*
+ * 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 <AsteriskSCF/StateReplicator.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(Ice::ObjectAdapterPtr, pj_pool_factory*, RtpGeneralStateItemPtr);
+ ~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 --cc src/RtpStateReplicatorApp.cpp
index 2b49c1b,0000000..6fa76d9
mode 100644,000000..100644
--- a/src/RtpStateReplicatorApp.cpp
+++ b/src/RtpStateReplicatorApp.cpp
@@@ -1,231 -1,0 +1,232 @@@
+/*
+ * 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 <pjlib.h>
+
- #include "ServiceLocatorIf.h"
- #include "ComponentServiceIf.h"
++#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
++#include <AsteriskSCF/System/Component/ComponentServiceIf.h>
++#include <AsteriskSCF/Logger/IceLogger.h>
++#include <AsteriskSCF/logger.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 ¶ms, 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;
+}
+}
+
diff --cc src/RtpStateReplicatorListener.cpp
index f11b9d7,0000000..58da256
mode 100644,000000..100644
--- a/src/RtpStateReplicatorListener.cpp
+++ b/src/RtpStateReplicatorListener.cpp
@@@ -1,151 -1,0 +1,151 @@@
+/*
+ * 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 <pjlib.h>
+#include <pjmedia.h>
+
- #include "ReplicaIf.h"
- #include "SmartProxy.h"
++#include <AsteriskSCF/System/Component/ReplicaIf.h>
++#include <AsteriskSCF/SmartProxy.h>
+
+#include "RtpStateReplicator.h"
+#include "RTPSession.h"
+#include "RTPSink.h"
+#include "RTPSource.h"
+
+using namespace AsteriskSCF::Media::RTP::V1;
+
+class RtpStateReplicatorItem
+{
+public:
+ RtpStateReplicatorItem() { }
+ ~RtpStateReplicatorItem()
+ {
+ mSession->release(Ice::Current());
+ }
+
+ // Helper function which sets the session on this replicator item
+ void setSession(RTPSessionImplPtr session) { mSession = session; };
+
+ // Helper function which gets the session
+ RTPSessionImplPtr getSession() { return mSession; };
+
+private:
+ // Pointer to the session that we are managing
+ RTPSessionImplPtr mSession;
+};
+
+struct RtpStateReplicatorListenerImpl
+{
+public:
+ RtpStateReplicatorListenerImpl(Ice::ObjectAdapterPtr adapter, pj_pool_factory *poolFactory, RtpGeneralStateItemPtr generalState)
+ : mId(IceUtil::generateUUID()), mAdapter(adapter), mPoolFactory(poolFactory), mGeneralState(generalState) {}
+ 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);
+ RtpGeneralStateItemPtr general;
+ RtpSessionStateItemPtr session;
+ RtpStreamSinkStateItemPtr sink;
+ RtpStreamSourceStateItemPtr source;
+ boost::shared_ptr<RtpStateReplicatorItem> localitem;
+
+ if ((general = RtpGeneralStateItemPtr::dynamicCast((*item))))
+ {
+ mGeneralState->mServiceManagement = general->mServiceManagement;
+ }
+ else if ((session = RtpSessionStateItemPtr::dynamicCast((*item))))
+ {
+ if (i == mStateItems.end())
+ {
+ boost::shared_ptr<RtpStateReplicatorItem> newitem(new RtpStateReplicatorItem());
+ localitem = newitem;
+ mStateItems.insert(std::make_pair<std::string, boost::shared_ptr<RtpStateReplicatorItem> >((*item)->mSessionId, newitem));
+
+ RTPSessionImplPtr localSession = new RTPSessionImpl(mAdapter, mPoolFactory, session->mSessionIdentity, session->mSinkIdentity,
+ session->mSourceIdentity, session->mPort, session->mFormats);
+ localitem->setSession(localSession);
+ }
+ else
+ {
+ localitem = i->second;
+ }
+
+ localitem->getSession()->associatePayloads(session->mPayloadstoFormats, Ice::Current());
+ }
+ else if ((sink = RtpStreamSinkStateItemPtr::dynamicCast((*item))))
+ {
+ if (i == mStateItems.end())
+ {
+ continue;
+ }
+
+ i->second->getSession()->getSink()->setSource(sink->mSource, Ice::Current());
+ i->second->getSession()->getSink()->setRemoteDetails(sink->mRemoteAddress, sink->mRemotePort, Ice::Current());
+ }
+ else if ((source = RtpStreamSourceStateItemPtr::dynamicCast((*item))))
+ {
+ if (i == mStateItems.end())
+ {
+ continue;
+ }
+
+ i->second->getSession()->getSource()->setSink(source->mSink, Ice::Current());
+ }
+ }
+ }
+ std::string mId;
+ std::map<std::string, boost::shared_ptr<RtpStateReplicatorItem> > mStateItems;
+ Ice::ObjectAdapterPtr mAdapter;
+ pj_pool_factory *mPoolFactory;
+ RtpGeneralStateItemPtr mGeneralState;
+};
+
+RtpStateReplicatorListenerI::RtpStateReplicatorListenerI(Ice::ObjectAdapterPtr adapter, pj_pool_factory *poolFactory, RtpGeneralStateItemPtr generalState)
+ : mImpl(new RtpStateReplicatorListenerImpl(adapter, poolFactory, generalState)) {}
+
+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;
+}
diff --cc test/CMakeLists.txt
index b36ae1b,6876f33..5ca2576
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@@ -6,14 -6,12 +6,15 @@@
# All rights reserved.
#
++asterisk_scf_slice_include_directories(${API_SLICE_DIR})
++
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_slice(media_rtp_pjmedia_test RtpStateReplicationIf)
++asterisk_scf_component_add_slice(media_rtp_pjmedia_test ../local-slice/RtpStateReplicationIf.ice)
asterisk_scf_component_add_boost_libraries(media_rtp_pjmedia_test unit_test_framework thread date_time)
+ include_directories(${API_INCLUDE_DIR})
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)
+ target_link_libraries(media_rtp_pjmedia_test asterisk-scf-api)
# integration test
if(integrated_build STREQUAL "true")
diff --cc test/TestRTPpjmedia.cpp
index 4b6c2ed,e71ffc6..a21b3c0
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@@ -23,11 -23,10 +23,12 @@@
#include <Ice/Ice.h>
#include <IceBox/IceBox.h>
- #include "Core/Discovery/ServiceLocatorIf.h"
- #include "Media/MediaIf.h"
- #include "Media/RTP/MediaRTPIf.h"
+ #include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
+ #include <AsteriskSCF/Media/MediaIf.h>
+ #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
+
+#include "RtpStateReplicationIf.h"
+
using namespace std;
using namespace AsteriskSCF::Core::Discovery::V1;
using namespace AsteriskSCF::Media::V1;
commit 68adbcebbfa998bf8dcefdb0b8c9be7a237f487a
Author: David M. Lee <dlee at digium.com>
Date: Wed Jan 19 12:18:10 2011 -0600
We require cmake 2.8 or better.
Now make it a specific "You're cmake is old" failure, as opposed to some
random failure later on.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c61faa5..a60eae4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,8 +10,8 @@
if(NOT integrated_build STREQUAL "true")
- # Minimum we require is 2.6, any lower and stuff would fail horribly
- cmake_minimum_required(VERSION 2.6)
+ # Minimum we require is 2.8, any lower and stuff would fail horribly
+ cmake_minimum_required(VERSION 2.8)
# Include pjproject build integration
include(cmake/modules/pjproject.cmake)
-----------------------------------------------------------------------
--
asterisk-scf/integration/media_rtp_pjmedia.git
More information about the asterisk-scf-commits
mailing list