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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Oct 5 10:20:25 CDT 2010


branch "master" has been updated
       via  2d4f25efbd402d1f97df4f9209830db24a63d4b2 (commit)
      from  3b87167160824ca5f5f68c0396bfc6aa95d638c1 (commit)

Summary of changes:
 cmake                              |    2 +-
 config/test_component.config.in    |   20 +++++++++
 config/test_media_rtp_pjmedia.conf |    1 +
 src/CMakeLists.txt                 |    4 +-
 src/MediaRTPpjmedia.cpp            |   82 ++++++++++++++++++++----------------
 test/CMakeLists.txt                |   10 ++++-
 test/TestRTPpjmedia.cpp            |   58 ++++++++++++++++++++-----
 7 files changed, 123 insertions(+), 54 deletions(-)
 create mode 100644 config/test_component.config.in


- Log -----------------------------------------------------------------
commit 2d4f25efbd402d1f97df4f9209830db24a63d4b2
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Oct 5 12:23:20 2010 -0300

    Convert everything to be an IceBox service.

diff --git a/cmake b/cmake
index 364040a..e9cf9f2 160000
--- a/cmake
+++ b/cmake
@@ -1 +1 @@
-Subproject commit 364040aa2e2252eb07d896dc98eee1d2362f56e9
+Subproject commit e9cf9f2e6dd03fe7bc39c363d72812aceed28367
diff --git a/config/test_component.config.in b/config/test_component.config.in
new file mode 100644
index 0000000..fd73afe
--- /dev/null
+++ b/config/test_component.config.in
@@ -0,0 +1,20 @@
+# This is a configuration file used in conjunction with the media_rtp_pjmedia test driver
+
+# media_rtp_pjmedia Configuration
+#
+IceBox.Service.MediaRTPpjmedia=media_rtp_pjmedia:create --Ice.Config=config/test_media_rtp_pjmedia.conf
+
+# Adapter parameters for this component
+MediaRTPpjmediaAdapter.Endpoints=default
+
+# A proxy to the service locator management service
+ServiceLocatorManagementProxy=LocatorServiceManagement:tcp -p 4422
+
+# A proxy to the service locator service
+ServiceLocatorProxy=LocatorService:tcp -p 4411
+
+#
+# media_rtp_pjmedia_test Configuration
+#
+IceBox.Service.MediaRTPpjmediaTest=media_rtp_pjmedia_test:create --Ice.Config=config/test_component.config --report_sink=${CMAKE_BINARY_DIR}/media_rtp_pjmedia_test-result.xml --report_format=XML --report_level=detailed
+
diff --git a/config/test_media_rtp_pjmedia.conf b/config/test_media_rtp_pjmedia.conf
index ae63258..abb2ca9 100644
--- a/config/test_media_rtp_pjmedia.conf
+++ b/config/test_media_rtp_pjmedia.conf
@@ -1,4 +1,5 @@
 # This is a configuration file used in conjunction with the pjmedia rtp component test driver
+IceBox.Service.MediaRTPpjmedia=media_rtp_pjmedia:create --Ice.Config=config/test_media_rtp_pjmedia.conf
 
 # Adapter parameters for this component
 MediaRTPpjmediaAdapter.Endpoints=default
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5f781ba..c4bb605 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -16,9 +16,9 @@ hydra_component_add_file(media_rtp_pjmedia RTPSession.cpp)
 hydra_component_add_file(media_rtp_pjmedia RTPSource.cpp)
 hydra_component_add_file(media_rtp_pjmedia RTPSink.cpp)
 hydra_component_add_boost_libraries(media_rtp_pjmedia core thread)
-hydra_component_build_standalone(media_rtp_pjmedia)
+hydra_component_build_icebox(media_rtp_pjmedia)
 pjproject_link(media_rtp_pjmedia pjlib)
 pjproject_link(media_rtp_pjmedia pjlib-util)
 pjproject_link(media_rtp_pjmedia pjmedia)
 pjproject_link(media_rtp_pjmedia pjnath)
-hydra_component_install(media_rtp_pjmedia RUNTIME bin "pjmedia RTP Media." Media)
+#hydra_component_install(media_rtp_pjmedia RUNTIME bin "pjmedia RTP Media." Media)
diff --git a/src/MediaRTPpjmedia.cpp b/src/MediaRTPpjmedia.cpp
index 34419a8..6dd8ef1 100644
--- a/src/MediaRTPpjmedia.cpp
+++ b/src/MediaRTPpjmedia.cpp
@@ -7,6 +7,7 @@
  */
 
 #include <Ice/Ice.h>
+#include <IceBox/IceBox.h>
 
 #include <pjlib.h>
 #include <pjmedia.h>
@@ -52,16 +53,26 @@ private:
 };
 
 /**
- * Implementation of the Ice::Application class
+ * Implementation of the IceBox::Service class
  */
-class MediaRTPpjmediaApp : public Ice::Application
+class MediaRTPpjmediaApp : public IceBox::Service
 {
 public:
-	int run(int, char*[]);
-	void interruptCallback(int);
+	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 everything is associated with.
+	 */
+	Ice::ObjectAdapterPtr mAdapter;
+
+	/**
 	 * A proxy to the service locator manager for the RTP media service.
 	 */
 	ServiceManagementPrx mServiceManagement;
@@ -107,7 +118,7 @@ public:
 	 */
 	virtual void shutdown(const ::Ice::Current&)
 	{
-		mApplication.interruptCallback(EXIT_SUCCESS);
+		// TODO - Actually support this
 	}
 
 private:
@@ -175,18 +186,6 @@ private:
 };
 
 /**
- * Main entry point for our pjmedia rtp component.
- */
-int main(int argc, char* argv[])
-{
-	MediaRTPpjmediaApp app;
-	app.callbackOnInterrupt();
-	Ice::InitializationData id;
-	id.threadHook = new pjlibHook();
-	return app.main(argc, argv, id);
-}
-
-/**
  * Constructor for the RTPMediaServiceImpl class.
  */
 RTPMediaServiceImpl::RTPMediaServiceImpl(Ice::ObjectAdapterPtr adapter) : mAdapter(adapter)
@@ -208,45 +207,49 @@ RTPSessionPrx RTPMediaServiceImpl::allocate(const FormatSeq& formats, const Ice:
 }
 
 /**
- * Overload of the Ice::Application::run method.
+ * Implementation of the IceBox::Service::start method.
  */
-int MediaRTPpjmediaApp::run(int argc, char* argv[])
+void MediaRTPpjmediaApp::start(const std::string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args)
 {
-	callbackOnInterrupt();
-
 	/* Initialize pjlib as pjmedia will be using it */
 	pj_status_t status = pj_init();
 	if (status != PJ_SUCCESS)
 	{
 		cerr << "PJ library initialization failed." << endl;
-		return EXIT_SUCCESS;
+		return;
 	}
 
 	if ((status = pjlib_util_init()) != PJ_SUCCESS)
 	{
 		cerr << "PJ Utility library initialization failed." << endl;
-		return EXIT_SUCCESS;
+		return;
 	}
 
 	cout << "Initializing pjmedia rtp component" << endl;
 
-	Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("MediaRTPpjmediaAdapter");
+	Ice::InitializationData id;
+	id.threadHook = new pjlibHook();
+	id.properties = communicator->getProperties();
 
-	RTPMediaServicePtr rtpmediaservice = new RTPMediaServiceImpl(adapter);
+	mCommunicator = Ice::initialize(id);
 
-	RTPMediaServicePrx RTPMediaServiceProxy = RTPMediaServicePrx::uncheckedCast(adapter->addWithUUID(rtpmediaservice));
+	mAdapter = mCommunicator->createObjectAdapter("MediaRTPpjmediaAdapter");
 
-	adapter->activate();
+	RTPMediaServicePtr rtpmediaservice = new RTPMediaServiceImpl(mAdapter);
+
+	RTPMediaServicePrx RTPMediaServiceProxy = RTPMediaServicePrx::uncheckedCast(mAdapter->addWithUUID(rtpmediaservice));
+
+	mAdapter->activate();
 
 	cout << "Activated pjmedia rtp component media service." << endl;
 
-	ServiceLocatorManagementPrx management = ServiceLocatorManagementPrx::checkedCast(communicator()->propertyToProxy("ServiceLocatorManagementProxy"));
+	ServiceLocatorManagementPrx management = ServiceLocatorManagementPrx::checkedCast(mCommunicator->propertyToProxy("ServiceLocatorManagementProxy"));
 
 	mServiceManagement = ServiceManagementPrx::uncheckedCast(management->addService(RTPMediaServiceProxy, "media_rtp_pjmedia"));
 
 	/* One must provide a component service to manage us, if someone wants to */
 	ComponentServicePtr ComponentService = new ComponentServiceImpl(*this, mServiceManagement);
-	ComponentServicePrx ComponentServiceProxy = ComponentServicePrx::uncheckedCast(adapter->addWithUUID(ComponentService));
+	ComponentServicePrx ComponentServiceProxy = ComponentServicePrx::uncheckedCast(mAdapter->addWithUUID(ComponentService));
 
 	/* Let's add the component service to the service locator first */
 	mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(management->addService(ComponentServiceProxy, "media_rtp_pjmedia"));
@@ -257,17 +260,22 @@ int MediaRTPpjmediaApp::run(int argc, char* argv[])
 	/* Now we can add some parameters to help find us. */
 	genericparams->category = "rtp";
 	mServiceManagement->addLocatorParams(genericparams, "");
-
-	/* Welp we are now in the service locator... they can find us! */
-	communicator()->waitForShutdown();
-
-	return EXIT_SUCCESS;
 }
 
-void MediaRTPpjmediaApp::interruptCallback(int val)
+/**
+ * Implementation of the IceBox::Service::stop method.
+ */
+void MediaRTPpjmediaApp::stop()
 {
    mComponentServiceManagement->unregister();
    mServiceManagement->unregister();
-   communicator()->shutdown();
-   _exit(EXIT_SUCCESS);
+   mCommunicator->destroy();
+}
+
+extern "C"
+{
+   IceBox::Service* create(Ice::CommunicatorPtr communicator)
+   {
+      return new MediaRTPpjmediaApp;
+   }
 }
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 01381ea..32389c4 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -11,5 +11,11 @@ hydra_component_add_file(media_rtp_pjmedia_test TestRTPpjmedia.cpp)
 hydra_component_add_slice(media_rtp_pjmedia_test MediaIf)
 hydra_component_add_slice(media_rtp_pjmedia_test MediaRTPIf)
 hydra_component_add_boost_libraries(media_rtp_pjmedia_test unit_test_framework thread)
-hydra_component_build_standalone(media_rtp_pjmedia_test)
-hydra_component_install(media_rtp_pjmedia_test RUNTIME bin "PJmedia RTP Media Test Driver." Core)
+hydra_component_build_icebox(media_rtp_pjmedia_test)
+#hydra_component_install(media_rtp_pjmedia_test RUNTIME bin "PJmedia RTP Media Test Driver." Core)
+
+icebox_add_test(media_rtp_pjmedia_test config/test_component.config)
+
+# Copy our test config file to make it available in the test directory.
+# CMake does a bit of search-and-replace, as well.
+configure_file(../config/test_component.config.in ${CMAKE_CURRENT_BINARY_DIR}/config/test_component.config)
diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index 19d4a79..459b327 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -15,6 +15,7 @@
 #include <boost/thread/thread.hpp> 
 
 #include <Ice/Ice.h>
+#include <IceBox/IceBox.h>
 
 #include "Core/Discovery/ServiceLocatorIf.h"
 #include "Media/MediaIf.h"
@@ -25,6 +26,18 @@ using namespace AsteriskSCF::Core::Discovery::V1;
 using namespace AsteriskSCF::Media::V1;
 using namespace AsteriskSCF::Media::RTP::V1;
 
+/**
+ * Test service, for loading into icebox
+ */
+class MediaRTPpjmediaTest : public IceBox::Service
+{
+public:
+   void start(const std::string&,
+	      const Ice::CommunicatorPtr&,
+	      const Ice::StringSeq&);
+   void stop();
+};
+
 /* Cache the command line arguments so that Ice can be initialized within the global fixture. */
 struct ArgCacheType
 {
@@ -184,18 +197,6 @@ private:
 BOOST_GLOBAL_FIXTURE(GlobalIceFixture);
 
 /**
- * Implement our own main to intercept the command line args.
- * (A default main() is provided if we hadn't set BOOST_TEST_NO_MAIN at the top of file.)
- * NOTE: Pass in --log_level=message to see the debug print statements.
- */
-int BOOST_TEST_CALL_DECL main( int argc, char* argv[] )
-{
-	mCachedArgs.argc = argc;
-	mCachedArgs.argv = argv;
-	return ::boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
-}
-
-/**
  * Confirm that we find the rtp media session service based on category
  */
 BOOST_AUTO_TEST_CASE(ServiceFoundUsingName)
@@ -667,3 +668,36 @@ BOOST_AUTO_TEST_CASE(ReleaseRTPSession)
 	BOOST_CHECK(released);
 }
 
+void MediaRTPpjmediaTest::start(std::string const &name,
+			       Ice::CommunicatorPtr const &communicator,
+			       Ice::StringSeq const &args)
+{
+   std::vector<char const *> argv;
+   argv.push_back(name.c_str());
+   for (Ice::StringSeq::const_iterator i = args.begin();
+	i != args.end();
+	++i)
+   {
+      argv.push_back(i->c_str());
+   }
+   // null terminated list
+   argv.push_back(0);
+
+   mCachedArgs.argc = argv.size() - 1;
+   mCachedArgs.argv = (char**)&argv[0];
+
+   int r = ::boost::unit_test::unit_test_main(&init_unit_test, mCachedArgs.argc, mCachedArgs.argv);
+   exit(r);
+}
+
+void MediaRTPpjmediaTest::stop()
+{
+}
+
+extern "C"
+{
+   IceBox::Service* create(Ice::CommunicatorPtr communicator)
+   {
+      return new MediaRTPpjmediaTest;
+   }
+}

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


-- 
asterisk-scf/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list