[asterisk-scf-commits] asterisk-scf/integration/media_rtp_pjmedia.git branch "replication-visitor" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Thu Dec 30 00:36:48 UTC 2010
branch "replication-visitor" has been updated
via c3f55bb7a358def51806d8bb5b06e9eefbd58500 (commit)
from 2dfff43d9914d8a460f57a4b863dcf6fe6d844aa (commit)
Summary of changes:
local-slice/CMakeLists.txt | 3 +-
local-slice/RtpStateItemHelpers.ice | 54 ++++++++++++++
local-slice/RtpStateItemHelpersImpl.cpp | 119 +++++++++++++++++++++++++++++++
local-slice/RtpStateItemHelpersImpl.h | 84 ++++++++++++++++++++++
local-slice/RtpStateReplicationIf.ice | 29 +++-----
src/MediaRTPpjmedia.cpp | 3 +-
src/RTPSession.cpp | 3 +-
src/RTPSink.cpp | 3 +-
src/RTPSource.cpp | 3 +-
test/TestRTPpjmedia.cpp | 47 ++-----------
10 files changed, 282 insertions(+), 66 deletions(-)
create mode 100644 local-slice/RtpStateItemHelpers.ice
create mode 100644 local-slice/RtpStateItemHelpersImpl.cpp
create mode 100644 local-slice/RtpStateItemHelpersImpl.h
- Log -----------------------------------------------------------------
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;
}
-----------------------------------------------------------------------
--
asterisk-scf/integration/media_rtp_pjmedia.git
More information about the asterisk-scf-commits
mailing list