[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:56:42 CST 2011


branch "replication" has been updated
       via  a36a1c558a7d563e4ac69db343103cf2ebb29cda (commit)
       via  c6c8e75f37eaecb2e1dceb97c21b6d58b6af4463 (commit)
       via  4db1e9d8314a3ad95c24446a99133cd005f2362f (commit)
       via  c42bb2fae80b489275b969b2a7f14151866b0edb (commit)
       via  a49aa9de79867fc8af7c3e979b390937fb33f2c4 (commit)
       via  8053dab526443105e44d902ab795a8252834d1fe (commit)
       via  c3f55bb7a358def51806d8bb5b06e9eefbd58500 (commit)
       via  2dfff43d9914d8a460f57a4b863dcf6fe6d844aa (commit)
      from  486c8f5bec883c8f01a3a933aa5cdce1aff12bdd (commit)

Summary of changes:
 local-slice/RtpStateReplicationIf.ice |  135 +++++++++++++++++----------------
 test/TestRTPpjmedia.cpp               |   43 +++++++----
 2 files changed, 96 insertions(+), 82 deletions(-)


- Log -----------------------------------------------------------------
commit a36a1c558a7d563e4ac69db343103cf2ebb29cda
Merge: c6c8e75 486c8f5
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Wed Jan 19 16:53:21 2011 -0600

    Merge branch 'replication' into replication-visitor
    
    Conflicts:
    	local-slice/CMakeLists.txt


commit c6c8e75f37eaecb2e1dceb97c21b6d58b6af4463
Merge: 4db1e9d 4fa74bf
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Tue Jan 4 15:56:42 2011 -0600

    Merge branch 'replication' into replication-visitor


commit 4db1e9d8314a3ad95c24446a99133cd005f2362f
Merge: c42bb2f 7de9901
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Tue Jan 4 15:51:16 2011 -0600

    Merge branch 'master' into replication-visitor

diff --cc src/MediaRTPpjmedia.cpp
index 1e7c30b,ddd847e..f770788
--- a/src/MediaRTPpjmedia.cpp
+++ b/src/MediaRTPpjmedia.cpp
@@@ -46,12 -40,9 +46,12 @@@ using namespace AsteriskSCF::SmartProxy
  
  namespace
  {
- Logger &lg = getLoggerFactory().getLogger("AsteriskSCF.MediaRTP");
+ Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaRTP");
  }
  
 +static const string ReplicaServiceId("MediaRtpReplica");
 +static const string MediaServiceId("RTPMediaService");
 +
  /**
   * Implementation of the RTPMediaService interface as defined in MediaRTPIf.ice
   */

commit c42bb2fae80b489275b969b2a7f14151866b0edb
Merge: a49aa9d dda37f6
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Tue Jan 4 15:50:17 2011 -0600

    Merge branch 'master' into replication-visitor


commit a49aa9de79867fc8af7c3e979b390937fb33f2c4
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Tue Jan 4 09:09:25 2011 -0600

    Avoid MCPP bug by using C-style comments.

diff --git a/local-slice/RtpStateReplicationIf.ice b/local-slice/RtpStateReplicationIf.ice
index 2dbbeed..d7a52c5 100644
--- a/local-slice/RtpStateReplicationIf.ice
+++ b/local-slice/RtpStateReplicationIf.ice
@@ -96,10 +96,10 @@ module V1
     {
 	AsteriskSCF::Media::V1::StreamSink *mSink;
     };
-}; // module V1
+}; /* module V1 */
 
-}; // module RTP
+}; /* module RTP */
 
-}; // module Media
+}; /* module Media */
 
-}; // module Asterisk SCF
+}; /* module Asterisk SCF */

commit 8053dab526443105e44d902ab795a8252834d1fe
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Thu Dec 30 16:47:34 2010 -0600

    Use new translator support for visitors

diff --git a/local-slice/CMakeLists.txt b/local-slice/CMakeLists.txt
index 4f25cf4..bc354ab 100644
--- a/local-slice/CMakeLists.txt
+++ b/local-slice/CMakeLists.txt
@@ -1,2 +1,2 @@
 asterisk_scf_slice_include_directories("${CMAKE_SOURCE_DIR}/slice")
-asterisk_scf_compile_slice(RtpStateReplicationIf lib "RTP State Replicator" media_rtp_pjmedia SOURCES RtpStateReplicationIf.ice RtpStateItemHelpers.ice RtpStateItemHelpersImpl.h RtpStateItemHelpersImpl.cpp)
+asterisk_scf_compile_slice(RtpStateReplicationIf.ice lib "RTP State Replicator" media_rtp_pjmedia)
diff --git a/local-slice/RtpStateItemHelpers.ice b/local-slice/RtpStateItemHelpers.ice
deleted file mode 100644
index 455869c..0000000
--- a/local-slice/RtpStateItemHelpers.ice
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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 "RtpStateReplicationIf.ice"
-
-[["cpp:include:RtpStateItemHelpersImpl.h"]]
-
-module AsteriskSCF
-{
-
-module Media
-{
-
-module RTP
-{
-
-["suppress"]
-module V1
-{
-
-module StateItemHelpers
-{
-    // This module is intentionally left empty, as its contents
-    // cannot be defined in the Slice language. However, its
-    // contents should be provided to all users of the RTPStateItem
-    // mechanism, written in each language that is supported. Those
-    // implementations will be available in companion files in the
-    // same directory as this one. For C++, the helpers will be
-    // automatically brought into the program by the inclusion
-    // of the RtpStateItemHelpers.h file above.
-}; // module StateItemHelpers
-
-}; // module V1
-
-}; // module RTP
-
-}; // module Media
-
-}; // module Asterisk SCF
diff --git a/local-slice/RtpStateItemHelpersImpl.cpp b/local-slice/RtpStateItemHelpersImpl.cpp
deleted file mode 100644
index 5acc233..0000000
--- a/local-slice/RtpStateItemHelpersImpl.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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 "RtpStateReplicationIf.h"
-#include "RtpStateItemHelpers.h"
-
-using namespace AsteriskSCF::Media::RTP::V1;
-
-namespace AsteriskSCF
-{
-
-namespace Media
-{
-
-namespace RTP
-{
-
-namespace V1
-{
-
-namespace StateItemHelpers
-{
-
-template <typename T>
-class factory : public Ice::ObjectFactory
-{
-public:
-	virtual Ice::ObjectPtr create(const std::string &)
-	{
-		return new T();
-	}
-
-	virtual void destroy()
-	{
-	}
-};
-
-void registerObjectFactory(const Ice::CommunicatorPtr &communicator)
-{
-	communicator->addObjectFactory(new factory<RtpStateItemImpl>(), RtpStateItem::ice_staticId());
-	communicator->addObjectFactory(new factory<RtpGeneralStateItemImpl>(), RtpGeneralStateItem::ice_staticId());
-	communicator->addObjectFactory(new factory<RtpSessionStateItemImpl>(), RtpSessionStateItem::ice_staticId());
-	communicator->addObjectFactory(new factory<RtpStreamSourceStateItemImpl>(), RtpStreamSourceStateItem::ice_staticId());
-	communicator->addObjectFactory(new factory<RtpStreamSinkStateItemImpl>(), RtpStreamSinkStateItem::ice_staticId());
-}
-
-void RtpStateItemImpl::visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &)
-{
-}
-
-RtpStateItemPtr newRtpStateItem(void)
-{
-	return new RtpStateItemImpl();
-}
-
-void RtpGeneralStateItemImpl::visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &)
-{
-	visitor->visitGeneral(this);
-}
-
-RtpGeneralStateItemPtr newRtpGeneralStateItem(void)
-{
-	return new RtpGeneralStateItemImpl();
-}
-
-void RtpSessionStateItemImpl::visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &)
-{
-	visitor->visitSession(this);
-}
-
-RtpSessionStateItemPtr newRtpSessionStateItem(void)
-{
-	return new RtpSessionStateItemImpl();
-}
-
-void RtpStreamSourceStateItemImpl::visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &)
-{
-	visitor->visitStreamSource(this);
-}
-
-RtpStreamSourceStateItemPtr newRtpStreamSourceStateItem(void)
-{
-	return new RtpStreamSourceStateItemImpl();
-}
-
-void RtpStreamSinkStateItemImpl::visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &)
-{
-	visitor->visitStreamSink(this);
-}
-
-RtpStreamSinkStateItemPtr newRtpStreamSinkStateItem(void)
-{
-	return new RtpStreamSinkStateItemImpl();
-}
-
-} // namespace StateItemHelpers
-
-} // namespace V1
-
-} // namespace RTP
-
-} // namespace Media
-
-} // namespace AsteriskSCF
diff --git a/local-slice/RtpStateItemHelpersImpl.h b/local-slice/RtpStateItemHelpersImpl.h
deleted file mode 100644
index 5621760..0000000
--- a/local-slice/RtpStateItemHelpersImpl.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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
-
-namespace AsteriskSCF
-{
-
-namespace Media
-{
-
-namespace RTP
-{
-
-namespace V1
-{
-
-namespace StateItemHelpers
-{
-
-void registerObjectFactory(const Ice::CommunicatorPtr &communicator);
-
-class RtpStateItemImpl : public RtpStateItem
-{
-public:
-	void visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &);
-};
-
-RtpStateItemPtr newRtpStateItem(void);
-
-class RtpGeneralStateItemImpl : public RtpGeneralStateItem
-{
-public:
-	void visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &);
-};
-
-RtpGeneralStateItemPtr newRtpGeneralStateItem(void);
-
-class RtpSessionStateItemImpl : public RtpSessionStateItem
-{
-public:
-	void visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &);
-};
-
-RtpSessionStateItemPtr newRtpSessionStateItem(void);
-
-class RtpStreamSourceStateItemImpl : public RtpStreamSourceStateItem
-{
-public:
-	void visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &);
-};
-
-RtpStreamSourceStateItemPtr newRtpStreamSourceStateItem(void);
-
-class RtpStreamSinkStateItemImpl : public RtpStreamSinkStateItem
-{
-public:
-	void visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &);
-};
-
-RtpStreamSinkStateItemPtr newRtpStreamSinkStateItem(void);
-
-} // namespace StateItemHelpers
-
-} // namespace V1
-
-} // namespace RTP
-
-} // namespace Media
-
-} // namespace AsteriskSCF
diff --git a/local-slice/RtpStateReplicationIf.ice b/local-slice/RtpStateReplicationIf.ice
index 49d2dc5..2dbbeed 100644
--- a/local-slice/RtpStateReplicationIf.ice
+++ b/local-slice/RtpStateReplicationIf.ice
@@ -34,75 +34,68 @@ module RTP
 ["suppress"]
 module V1
 {
-   const string StateReplicatorComponentCategory = "RtpStateReplicatorComponent";
-   const string StateReplicatorDiscoveryCategory = "RtpStateReplicator";
-
-   class RtpStateReplicatorParams extends AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams
-   {
-      string mName;
-   };
-
-   interface RtpStateItemVisitor;
-
-   class RtpStateItem
-   {
-      string key;
-      string mSessionId;
-      void visit(RtpStateItemVisitor visitor);
-   };
-
-   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;
-   };
-
-   interface RtpStateItemVisitor
-   {
-       void visitGeneral(RtpGeneralStateItem item);
-       void visitSession(RtpSessionStateItem item);
-       void visitStreamSink(RtpStreamSinkStateItem item);
-       void visitStreamSource(RtpStreamSourceStateItem item);
-   };
+    const string StateReplicatorComponentCategory = "RtpStateReplicatorComponent";
+    const string StateReplicatorDiscoveryCategory = "RtpStateReplicator";
+    
+    class RtpStateReplicatorParams extends AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams
+    {
+	string mName;
+    };
+    
+    ["visitor"] local class RtpStateItemVisitor
+    {
+    };
+
+    ["visitor:::AsteriskSCF::Media::RTP::V1::RtpStateItemVisitor"] 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
diff --git a/src/MediaRTPpjmedia.cpp b/src/MediaRTPpjmedia.cpp
index 1af4b00..1e7c30b 100644
--- a/src/MediaRTPpjmedia.cpp
+++ b/src/MediaRTPpjmedia.cpp
@@ -30,7 +30,6 @@
 #include "IceLogger.h"
 #include "logger.h"
 #include "RtpStateReplicationIf.h"
-#include "RtpStateItemHelpers.h"
 #include "ReplicaIf.h"
 #include "SmartProxy.h"
 
@@ -161,7 +160,7 @@ private:
 class MediaRTPpjmediaApp : public IceBox::Service
 {
 public:
-    MediaRTPpjmediaApp() : mGeneralState(StateItemHelpers::newRtpGeneralStateItem()) { mGeneralState->key = IceUtil::generateUUID(); };
+    MediaRTPpjmediaApp() : mGeneralState(new RtpGeneralStateItem()) { mGeneralState->key = IceUtil::generateUUID(); };
     void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&);
     void stop();
 
diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index e91824d..15633ef 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -23,7 +23,6 @@
 #include "Media/MediaIf.h"
 #include "Media/RTP/MediaRTPIf.h"
 #include "RtpStateReplicationIf.h"
-#include "RtpStateItemHelpers.h"
 #include "ReplicaIf.h"
 #include "SmartProxy.h"
 
@@ -55,7 +54,7 @@ class RTPSessionImplPriv
 {
 public:
     RTPSessionImplPriv(Ice::ObjectAdapterPtr adapter, const FormatSeq& formats, ReplicaPtr replicaService, AsteriskSCF::SmartProxy::SmartProxy<RtpStateReplicatorPrx> stateReplicator) :
-	mAdapter(adapter), mFormats(formats), mSessionStateItem(StateItemHelpers::newRtpSessionStateItem()), mReplicaService(replicaService), mStateReplicator(stateReplicator) { };
+	mAdapter(adapter), mFormats(formats), mSessionStateItem(new RtpSessionStateItem()), mReplicaService(replicaService), mStateReplicator(stateReplicator) { };
     ~RTPSessionImplPriv();
 
     /**
diff --git a/src/RTPSink.cpp b/src/RTPSink.cpp
index a14b87d..ed63b32 100644
--- a/src/RTPSink.cpp
+++ b/src/RTPSink.cpp
@@ -23,7 +23,6 @@
 #include "Media/MediaIf.h"
 #include "Media/RTP/MediaRTPIf.h"
 #include "RtpStateReplicationIf.h"
-#include "RtpStateItemHelpers.h"
 #include "ReplicaIf.h"
 #include "SmartProxy.h"
 
@@ -65,7 +64,7 @@ public:
 /**
  * Constructor for the StreamSinkRTPImplPriv class.
  */
-StreamSinkRTPImplPriv::StreamSinkRTPImplPriv(RTPSessionImplPtr session, std::string sessionId) : mSession(session), mSinkStateItem(StateItemHelpers::newRtpStreamSinkStateItem())
+StreamSinkRTPImplPriv::StreamSinkRTPImplPriv(RTPSessionImplPtr session, std::string sessionId) : mSession(session), mSinkStateItem(new RtpStreamSinkStateItem())
 {
     pjmedia_rtp_session_init(&mOutgoingSession, 0, pj_rand());
     mSinkStateItem->mSessionId = sessionId;
diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index bbc3ab1..3747677 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -23,7 +23,6 @@
 #include "Media/MediaIf.h"
 #include "Media/RTP/MediaRTPIf.h"
 #include "RtpStateReplicationIf.h"
-#include "RtpStateItemHelpers.h"
 #include "ReplicaIf.h"
 #include "SmartProxy.h"
 
@@ -72,7 +71,7 @@ public:
 /**
  * Constructor for the StreamSourceRTPImplPriv class.
  */
-StreamSourceRTPImplPriv::StreamSourceRTPImplPriv(RTPSessionImplPtr session, std::string sessionId) : mSession(session), mSourceStateItem(StateItemHelpers::newRtpStreamSourceStateItem())
+StreamSourceRTPImplPriv::StreamSourceRTPImplPriv(RTPSessionImplPtr session, std::string sessionId) : mSession(session), mSourceStateItem(new RtpStreamSourceStateItem())
 {
     pjmedia_rtp_session_init(&mIncomingSession, 0, 0);
     mSourceStateItem->mSessionId = sessionId;
diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index 1c71863..1efa138 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -27,7 +27,6 @@
 #include "Media/MediaIf.h"
 #include "Media/RTP/MediaRTPIf.h"
 #include "RtpStateReplicationIf.h"
-#include "RtpStateItemHelpers.h"
 
 using namespace std;
 using namespace AsteriskSCF::Core::Discovery::V1;

commit c3f55bb7a358def51806d8bb5b06e9eefbd58500
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Wed Dec 29 18:34:52 2010 -0600

    Not quite finished, but functional.
    
    This version of the Visitor pattern for RTPStateItem objects contains a
    number of improvements over the previous one, primarily that it no longer
    requires any Slice translator modifications. In addition, it now includes
    the 'boilerplate' stuff, that all users would have to write, in the library
    produced by compiling the Slice definitions.
    
    There are still a few rough edges that need some polishing... but it's
    almost there.

diff --git a/local-slice/CMakeLists.txt b/local-slice/CMakeLists.txt
index b348049..4f25cf4 100644
--- a/local-slice/CMakeLists.txt
+++ b/local-slice/CMakeLists.txt
@@ -1,3 +1,2 @@
 asterisk_scf_slice_include_directories("${CMAKE_SOURCE_DIR}/slice")
-asterisk_scf_compile_slice(RtpStateReplicationIf.ice lib "RTP State Replicator" media_rtp_pjmedia)
-
+asterisk_scf_compile_slice(RtpStateReplicationIf lib "RTP State Replicator" media_rtp_pjmedia SOURCES RtpStateReplicationIf.ice RtpStateItemHelpers.ice RtpStateItemHelpersImpl.h RtpStateItemHelpersImpl.cpp)
diff --git a/local-slice/RtpStateItemHelpers.ice b/local-slice/RtpStateItemHelpers.ice
new file mode 100644
index 0000000..455869c
--- /dev/null
+++ b/local-slice/RtpStateItemHelpers.ice
@@ -0,0 +1,54 @@
+/*
+ * 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 "RtpStateReplicationIf.ice"
+
+[["cpp:include:RtpStateItemHelpersImpl.h"]]
+
+module AsteriskSCF
+{
+
+module Media
+{
+
+module RTP
+{
+
+["suppress"]
+module V1
+{
+
+module StateItemHelpers
+{
+    // This module is intentionally left empty, as its contents
+    // cannot be defined in the Slice language. However, its
+    // contents should be provided to all users of the RTPStateItem
+    // mechanism, written in each language that is supported. Those
+    // implementations will be available in companion files in the
+    // same directory as this one. For C++, the helpers will be
+    // automatically brought into the program by the inclusion
+    // of the RtpStateItemHelpers.h file above.
+}; // module StateItemHelpers
+
+}; // module V1
+
+}; // module RTP
+
+}; // module Media
+
+}; // module Asterisk SCF
diff --git a/local-slice/RtpStateItemHelpersImpl.cpp b/local-slice/RtpStateItemHelpersImpl.cpp
new file mode 100644
index 0000000..5acc233
--- /dev/null
+++ b/local-slice/RtpStateItemHelpersImpl.cpp
@@ -0,0 +1,119 @@
+/*
+ * 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 "RtpStateReplicationIf.h"
+#include "RtpStateItemHelpers.h"
+
+using namespace AsteriskSCF::Media::RTP::V1;
+
+namespace AsteriskSCF
+{
+
+namespace Media
+{
+
+namespace RTP
+{
+
+namespace V1
+{
+
+namespace StateItemHelpers
+{
+
+template <typename T>
+class factory : public Ice::ObjectFactory
+{
+public:
+	virtual Ice::ObjectPtr create(const std::string &)
+	{
+		return new T();
+	}
+
+	virtual void destroy()
+	{
+	}
+};
+
+void registerObjectFactory(const Ice::CommunicatorPtr &communicator)
+{
+	communicator->addObjectFactory(new factory<RtpStateItemImpl>(), RtpStateItem::ice_staticId());
+	communicator->addObjectFactory(new factory<RtpGeneralStateItemImpl>(), RtpGeneralStateItem::ice_staticId());
+	communicator->addObjectFactory(new factory<RtpSessionStateItemImpl>(), RtpSessionStateItem::ice_staticId());
+	communicator->addObjectFactory(new factory<RtpStreamSourceStateItemImpl>(), RtpStreamSourceStateItem::ice_staticId());
+	communicator->addObjectFactory(new factory<RtpStreamSinkStateItemImpl>(), RtpStreamSinkStateItem::ice_staticId());
+}
+
+void RtpStateItemImpl::visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &)
+{
+}
+
+RtpStateItemPtr newRtpStateItem(void)
+{
+	return new RtpStateItemImpl();
+}
+
+void RtpGeneralStateItemImpl::visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &)
+{
+	visitor->visitGeneral(this);
+}
+
+RtpGeneralStateItemPtr newRtpGeneralStateItem(void)
+{
+	return new RtpGeneralStateItemImpl();
+}
+
+void RtpSessionStateItemImpl::visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &)
+{
+	visitor->visitSession(this);
+}
+
+RtpSessionStateItemPtr newRtpSessionStateItem(void)
+{
+	return new RtpSessionStateItemImpl();
+}
+
+void RtpStreamSourceStateItemImpl::visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &)
+{
+	visitor->visitStreamSource(this);
+}
+
+RtpStreamSourceStateItemPtr newRtpStreamSourceStateItem(void)
+{
+	return new RtpStreamSourceStateItemImpl();
+}
+
+void RtpStreamSinkStateItemImpl::visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &)
+{
+	visitor->visitStreamSink(this);
+}
+
+RtpStreamSinkStateItemPtr newRtpStreamSinkStateItem(void)
+{
+	return new RtpStreamSinkStateItemImpl();
+}
+
+} // namespace StateItemHelpers
+
+} // namespace V1
+
+} // namespace RTP
+
+} // namespace Media
+
+} // namespace AsteriskSCF
diff --git a/local-slice/RtpStateItemHelpersImpl.h b/local-slice/RtpStateItemHelpersImpl.h
new file mode 100644
index 0000000..5621760
--- /dev/null
+++ b/local-slice/RtpStateItemHelpersImpl.h
@@ -0,0 +1,84 @@
+/*
+ * 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
+
+namespace AsteriskSCF
+{
+
+namespace Media
+{
+
+namespace RTP
+{
+
+namespace V1
+{
+
+namespace StateItemHelpers
+{
+
+void registerObjectFactory(const Ice::CommunicatorPtr &communicator);
+
+class RtpStateItemImpl : public RtpStateItem
+{
+public:
+	void visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &);
+};
+
+RtpStateItemPtr newRtpStateItem(void);
+
+class RtpGeneralStateItemImpl : public RtpGeneralStateItem
+{
+public:
+	void visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &);
+};
+
+RtpGeneralStateItemPtr newRtpGeneralStateItem(void);
+
+class RtpSessionStateItemImpl : public RtpSessionStateItem
+{
+public:
+	void visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &);
+};
+
+RtpSessionStateItemPtr newRtpSessionStateItem(void);
+
+class RtpStreamSourceStateItemImpl : public RtpStreamSourceStateItem
+{
+public:
+	void visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &);
+};
+
+RtpStreamSourceStateItemPtr newRtpStreamSourceStateItem(void);
+
+class RtpStreamSinkStateItemImpl : public RtpStreamSinkStateItem
+{
+public:
+	void visit(const RtpStateItemVisitorPtr &visitor, const Ice::Current &);
+};
+
+RtpStreamSinkStateItemPtr newRtpStreamSinkStateItem(void);
+
+} // namespace StateItemHelpers
+
+} // namespace V1
+
+} // namespace RTP
+
+} // namespace Media
+
+} // namespace AsteriskSCF
diff --git a/local-slice/RtpStateReplicationIf.ice b/local-slice/RtpStateReplicationIf.ice
index aed5cf4..49d2dc5 100644
--- a/local-slice/RtpStateReplicationIf.ice
+++ b/local-slice/RtpStateReplicationIf.ice
@@ -42,13 +42,13 @@ module V1
       string mName;
    };
 
-   local interface RtpStateItemVisitor;
+   interface RtpStateItemVisitor;
 
    class RtpStateItem
    {
       string key;
       string mSessionId;
-      /* local void visit(RtpStateItemVisitor *visitor) ;*/
+      void visit(RtpStateItemVisitor visitor);
    };
 
    sequence<RtpStateItem> RtpStateItemSeq;
@@ -96,24 +96,17 @@ module V1
        AsteriskSCF::Media::V1::StreamSink *mSink;
    };
 
-/*
-  Cannot use this method yet because the member function
-  signatures are written to accept proxy pointers to the
-  concrete class objects, not local object pointers
-
-   local interface RtpStateItemVisitor
+   interface RtpStateItemVisitor
    {
-       void visitGeneral(RtpGeneralStateItem *item);
-       void visitSession(RtpSessionStateItem *item);
-       void visitStreamSink(RtpStreamSinkStateItem *item);
-       void visitStreamSource(RtpStreamSourceStateItem *item);
+       void visitGeneral(RtpGeneralStateItem item);
+       void visitSession(RtpSessionStateItem item);
+       void visitStreamSink(RtpStreamSinkStateItem item);
+       void visitStreamSource(RtpStreamSourceStateItem item);
    };
-*/
-
-}; //module V1
+}; // module V1
 
-}; //module RTP
+}; // module RTP
 
-}; //module Media
+}; // module Media
 
-}; //module Asterisk SCF
+}; // module Asterisk SCF
diff --git a/src/MediaRTPpjmedia.cpp b/src/MediaRTPpjmedia.cpp
index 1e7c30b..1af4b00 100644
--- a/src/MediaRTPpjmedia.cpp
+++ b/src/MediaRTPpjmedia.cpp
@@ -30,6 +30,7 @@
 #include "IceLogger.h"
 #include "logger.h"
 #include "RtpStateReplicationIf.h"
+#include "RtpStateItemHelpers.h"
 #include "ReplicaIf.h"
 #include "SmartProxy.h"
 
@@ -160,7 +161,7 @@ private:
 class MediaRTPpjmediaApp : public IceBox::Service
 {
 public:
-    MediaRTPpjmediaApp() : mGeneralState(new RtpGeneralStateItem()) { mGeneralState->key = IceUtil::generateUUID(); };
+    MediaRTPpjmediaApp() : mGeneralState(StateItemHelpers::newRtpGeneralStateItem()) { mGeneralState->key = IceUtil::generateUUID(); };
     void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&);
     void stop();
 
diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index 15633ef..e91824d 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -23,6 +23,7 @@
 #include "Media/MediaIf.h"
 #include "Media/RTP/MediaRTPIf.h"
 #include "RtpStateReplicationIf.h"
+#include "RtpStateItemHelpers.h"
 #include "ReplicaIf.h"
 #include "SmartProxy.h"
 
@@ -54,7 +55,7 @@ class RTPSessionImplPriv
 {
 public:
     RTPSessionImplPriv(Ice::ObjectAdapterPtr adapter, const FormatSeq& formats, ReplicaPtr replicaService, AsteriskSCF::SmartProxy::SmartProxy<RtpStateReplicatorPrx> stateReplicator) :
-	mAdapter(adapter), mFormats(formats), mSessionStateItem(new RtpSessionStateItem()), mReplicaService(replicaService), mStateReplicator(stateReplicator) { };
+	mAdapter(adapter), mFormats(formats), mSessionStateItem(StateItemHelpers::newRtpSessionStateItem()), mReplicaService(replicaService), mStateReplicator(stateReplicator) { };
     ~RTPSessionImplPriv();
 
     /**
diff --git a/src/RTPSink.cpp b/src/RTPSink.cpp
index ed63b32..a14b87d 100644
--- a/src/RTPSink.cpp
+++ b/src/RTPSink.cpp
@@ -23,6 +23,7 @@
 #include "Media/MediaIf.h"
 #include "Media/RTP/MediaRTPIf.h"
 #include "RtpStateReplicationIf.h"
+#include "RtpStateItemHelpers.h"
 #include "ReplicaIf.h"
 #include "SmartProxy.h"
 
@@ -64,7 +65,7 @@ public:
 /**
  * Constructor for the StreamSinkRTPImplPriv class.
  */
-StreamSinkRTPImplPriv::StreamSinkRTPImplPriv(RTPSessionImplPtr session, std::string sessionId) : mSession(session), mSinkStateItem(new RtpStreamSinkStateItem())
+StreamSinkRTPImplPriv::StreamSinkRTPImplPriv(RTPSessionImplPtr session, std::string sessionId) : mSession(session), mSinkStateItem(StateItemHelpers::newRtpStreamSinkStateItem())
 {
     pjmedia_rtp_session_init(&mOutgoingSession, 0, pj_rand());
     mSinkStateItem->mSessionId = sessionId;
diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index 3747677..bbc3ab1 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -23,6 +23,7 @@
 #include "Media/MediaIf.h"
 #include "Media/RTP/MediaRTPIf.h"
 #include "RtpStateReplicationIf.h"
+#include "RtpStateItemHelpers.h"
 #include "ReplicaIf.h"
 #include "SmartProxy.h"
 
@@ -71,7 +72,7 @@ public:
 /**
  * Constructor for the StreamSourceRTPImplPriv class.
  */
-StreamSourceRTPImplPriv::StreamSourceRTPImplPriv(RTPSessionImplPtr session, std::string sessionId) : mSession(session), mSourceStateItem(new RtpStreamSourceStateItem())
+StreamSourceRTPImplPriv::StreamSourceRTPImplPriv(RTPSessionImplPtr session, std::string sessionId) : mSession(session), mSourceStateItem(StateItemHelpers::newRtpStreamSourceStateItem())
 {
     pjmedia_rtp_session_init(&mIncomingSession, 0, 0);
     mSourceStateItem->mSessionId = sessionId;
diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index f838127..1c71863 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -27,6 +27,7 @@
 #include "Media/MediaIf.h"
 #include "Media/RTP/MediaRTPIf.h"
 #include "RtpStateReplicationIf.h"
+#include "RtpStateItemHelpers.h"
 
 using namespace std;
 using namespace AsteriskSCF::Core::Discovery::V1;
@@ -72,44 +73,6 @@ void TestRtpReplicatorListener::stateRemoved(const Ice::StringSeq& items, const
 {
 }
 
-// this interface should be written by the Slice translator,
-// but can't be currently
-struct AsteriskSCF::Media::RTP::V1::RtpStateItemVisitor
-{
-public:
-    virtual void visitGeneral(RtpGeneralStateItemPtr item) = 0;
-    virtual void visitSession(RtpSessionStateItemPtr item) = 0;
-    virtual void visitStreamSink(RtpStreamSinkStateItemPtr item) = 0;
-    virtual void visitStreamSource(RtpStreamSourceStateItemPtr item) = 0;
-};
-
-// these visitor functions are also common to all users of the
-// interface above, but the translator can't write them
-void AsteriskSCF::Media::RTP::V1::RtpStateItem::visit(RtpStateItemVisitorPtr visitor)
-{
-// nothing to do for unsupported state items
-}
-
-void AsteriskSCF::Media::RTP::V1::RtpGeneralStateItem::visit(RtpStateItemVisitorPtr visitor)
-{
-    visitor->visitGeneral(this);
-}
-
-void AsteriskSCF::Media::RTP::V1::RtpSessionStateItem::visit(RtpStateItemVisitorPtr visitor)
-{
-    visitor->visitSession(this);
-}
-
-void AsteriskSCF::Media::RTP::V1::RtpStreamSinkStateItem::visit(RtpStateItemVisitorPtr visitor)
-{
-    visitor->visitStreamSink(this);
-}
-
-void AsteriskSCF::Media::RTP::V1::RtpStreamSourceStateItem::visit(RtpStateItemVisitorPtr visitor)
-{
-    visitor->visitStreamSource(this);
-}
-
 void TestRtpReplicatorListener::stateSet(const RtpStateItemSeq& items, const Ice::Current&)
 {
     class visitor : public AsteriskSCF::Media::RTP::V1::RtpStateItemVisitor
@@ -122,22 +85,22 @@ void TestRtpReplicatorListener::stateSet(const RtpStateItemSeq& items, const Ice
     private:
 	TestRtpReplicatorListener *listener;
 
-	void visitGeneral(RtpGeneralStateItemPtr item)
+	void visitGeneral(const RtpGeneralStateItemPtr &item, const Ice::Current &)
 	{
             listener->mGeneral = item;
 	}
 
-	void visitSession(RtpSessionStateItemPtr item)
+	void visitSession(const RtpSessionStateItemPtr &item, const Ice::Current &)
 	{
             listener->mSession = item;
 	}
 
-	void visitStreamSink(RtpStreamSinkStateItemPtr item)
+	void visitStreamSink(const RtpStreamSinkStateItemPtr &item, const Ice::Current &)
 	{
             listener->mSink = item;
 	}
 
-	void visitStreamSource(RtpStreamSourceStateItemPtr item)
+	void visitStreamSource(const RtpStreamSourceStateItemPtr &item, const Ice::Current &)
 	{
             listener->mSource = item;
 	}

commit 2dfff43d9914d8a460f57a4b863dcf6fe6d844aa
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Sun Dec 26 13:02:02 2010 -0600

    Example of using Visitor pattern to process RTPStateItem objects.

diff --git a/local-slice/RtpStateReplicationIf.ice b/local-slice/RtpStateReplicationIf.ice
index b449ee5..aed5cf4 100644
--- a/local-slice/RtpStateReplicationIf.ice
+++ b/local-slice/RtpStateReplicationIf.ice
@@ -42,10 +42,13 @@ module V1
       string mName;
    };
 
+   local interface RtpStateItemVisitor;
+
    class RtpStateItem
    {
       string key;
       string mSessionId;
+      /* local void visit(RtpStateItemVisitor *visitor) ;*/
    };
 
    sequence<RtpStateItem> RtpStateItemSeq;
@@ -93,6 +96,20 @@ module V1
        AsteriskSCF::Media::V1::StreamSink *mSink;
    };
 
+/*
+  Cannot use this method yet because the member function
+  signatures are written to accept proxy pointers to the
+  concrete class objects, not local object pointers
+
+   local interface RtpStateItemVisitor
+   {
+       void visitGeneral(RtpGeneralStateItem *item);
+       void visitSession(RtpSessionStateItem *item);
+       void visitStreamSink(RtpStreamSinkStateItem *item);
+       void visitStreamSource(RtpStreamSourceStateItem *item);
+   };
+*/
+
 }; //module V1
 
 }; //module RTP
diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index 3951eb5..f838127 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -72,31 +72,80 @@ void TestRtpReplicatorListener::stateRemoved(const Ice::StringSeq& items, const
 {
 }
 
+// this interface should be written by the Slice translator,
+// but can't be currently
+struct AsteriskSCF::Media::RTP::V1::RtpStateItemVisitor
+{
+public:
+    virtual void visitGeneral(RtpGeneralStateItemPtr item) = 0;
+    virtual void visitSession(RtpSessionStateItemPtr item) = 0;
+    virtual void visitStreamSink(RtpStreamSinkStateItemPtr item) = 0;
+    virtual void visitStreamSource(RtpStreamSourceStateItemPtr item) = 0;
+};
+
+// these visitor functions are also common to all users of the
+// interface above, but the translator can't write them
+void AsteriskSCF::Media::RTP::V1::RtpStateItem::visit(RtpStateItemVisitorPtr visitor)
+{
+// nothing to do for unsupported state items
+}
+
+void AsteriskSCF::Media::RTP::V1::RtpGeneralStateItem::visit(RtpStateItemVisitorPtr visitor)
+{
+    visitor->visitGeneral(this);
+}
+
+void AsteriskSCF::Media::RTP::V1::RtpSessionStateItem::visit(RtpStateItemVisitorPtr visitor)
+{
+    visitor->visitSession(this);
+}
+
+void AsteriskSCF::Media::RTP::V1::RtpStreamSinkStateItem::visit(RtpStateItemVisitorPtr visitor)
+{
+    visitor->visitStreamSink(this);
+}
+
+void AsteriskSCF::Media::RTP::V1::RtpStreamSourceStateItem::visit(RtpStateItemVisitorPtr visitor)
+{
+    visitor->visitStreamSource(this);
+}
+
 void TestRtpReplicatorListener::stateSet(const RtpStateItemSeq& items, const Ice::Current&)
 {
-    for (RtpStateItemSeq::const_iterator item = items.begin(); item != items.end(); ++item)
+    class visitor : public AsteriskSCF::Media::RTP::V1::RtpStateItemVisitor
     {
-	RtpGeneralStateItemPtr general;
-	RtpSessionStateItemPtr session;
-	RtpStreamSinkStateItemPtr sink;
-	RtpStreamSourceStateItemPtr source;
+    public:
+        visitor(TestRtpReplicatorListener *listener) : listener(listener)
+	{
+	}
 
-        if ((general = RtpGeneralStateItemPtr::dynamicCast((*item))))
-        {
-	    mGeneral = general;
-        }
-	else if ((session = RtpSessionStateItemPtr::dynamicCast((*item))))
+    private:
+	TestRtpReplicatorListener *listener;
+
+	void visitGeneral(RtpGeneralStateItemPtr item)
 	{
-	    mSession = session;
+            listener->mGeneral = item;
 	}
-	else if ((sink = RtpStreamSinkStateItemPtr::dynamicCast((*item))))
+
+	void visitSession(RtpSessionStateItemPtr item)
+	{
+            listener->mSession = item;
+	}
+
+	void visitStreamSink(RtpStreamSinkStateItemPtr item)
 	{
-	    mSink = sink;
+            listener->mSink = item;
 	}
-	else if ((source = RtpStreamSourceStateItemPtr::dynamicCast((*item))))
+
+	void visitStreamSource(RtpStreamSourceStateItemPtr item)
 	{
-	    mSource = source;
+            listener->mSource = item;
 	}
+    } v(this);
+
+    for (RtpStateItemSeq::const_iterator item = items.begin(); item != items.end(); ++item)
+    {
+        (*item)->visit(&v);
     }
 }
 

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


-- 
asterisk-scf/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list