[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
Thu Aug 19 13:29:44 CDT 2010


branch "master" has been updated
       via  4bf3ca690bee921a65dc38ac61431c696d4d3284 (commit)
      from  68d6330eecd7c56a4886b4788306111473b6e548 (commit)

Summary of changes:
 src/CMakeLists.txt      |    1 +
 src/MediaRTPpjmedia.cpp |   65 ++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 65 insertions(+), 1 deletions(-)


- Log -----------------------------------------------------------------
commit 4bf3ca690bee921a65dc38ac61431c696d4d3284
Author: Joshua Colp <jcolp at digium.com>
Date:   Thu Aug 19 15:41:51 2010 -0300

    Add an implementation of the ComponentService interface for the media_rtp_pjmedia component.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a346a70..af26f6f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -2,6 +2,7 @@ hydra_component_init(media_rtp_pjmedia CXX)
 hydra_component_add_slice(media_rtp_pjmedia ServiceLocatorIf)
 hydra_component_add_slice(media_rtp_pjmedia MediaIf)
 hydra_component_add_slice(media_rtp_pjmedia MediaRTPIf)
+hydra_component_add_slice(media_rtp_pjmedia ComponentServiceIf)
 hydra_component_add_file(media_rtp_pjmedia MediaRTPpjmedia.cpp)
 hydra_component_add_file(media_rtp_pjmedia RTPSession.cpp)
 hydra_component_add_file(media_rtp_pjmedia RTPSource.cpp)
diff --git a/src/MediaRTPpjmedia.cpp b/src/MediaRTPpjmedia.cpp
index d9006d5..e235de6 100644
--- a/src/MediaRTPpjmedia.cpp
+++ b/src/MediaRTPpjmedia.cpp
@@ -26,6 +26,7 @@
 #include "Core/Discovery/ServiceLocatorIf.h"
 #include "Media/MediaIf.h"
 #include "Media/RTP/MediaRTPIf.h"
+#include "System/Component/ComponentServiceIf.h"
 
 #include "RTPSession.h"
 
@@ -33,6 +34,7 @@ using namespace std;
 using namespace Hydra::Core::Discovery::V1;
 using namespace Hydra::Media::V1;
 using namespace Hydra::Media::RTP::V1;
+using namespace Hydra::System::Component::V1;
 
 /**
  * Implementation of the RTPMediaService interface as defined in MediaRTPIf.ice
@@ -72,6 +74,57 @@ private:
 };
 
 /**
+ * Implementation of the ComponentService interface as defined in ComponentServiceIf.ice
+ */
+class ComponentServiceImpl : public ComponentService
+{
+public:
+	/**
+	 * A constructor for this implementation which just sets a few variables, nothing extreme.
+	 */
+	ComponentServiceImpl(MediaRTPpjmediaApp& app, ServiceManagementPrx& management) : mApplication(app), mManagement(management) { };
+
+	/**
+	 * An implementation of the suspend method which actually suspends ourselves
+	 * from the service locator.
+	 */
+	virtual void suspend(const ::Ice::Current&)
+	{
+		mManagement->suspend();
+	}
+
+	/**
+	 * An implementation of the resume method which actually unsuspends ourselves
+	 * from the service locator.
+	 */
+	virtual void resume(const ::Ice::Current&)
+	{
+		mManagement->unsuspend();
+	}
+
+	/**
+	 * An implementation of the shutdown method which really does shut us down.
+	 * Goodbye cruel world.
+	 */
+	virtual void shutdown(const ::Ice::Current&)
+	{
+		mApplication.interruptCallback(EXIT_SUCCESS);
+	}
+
+private:
+        /**
+	 * Our application instance, used for shutting the component down.
+	 */
+	MediaRTPpjmediaApp& mApplication;
+
+	/**
+	 * Our service locator management proxy, we'll use it to suspend and
+	 * unsuspend ourselves.
+	 */
+	ServiceManagementPrx& mManagement;
+};
+
+/**
  * Wrapper class around pj_thread_desc.
  */
 class ThreadDescWrapper
@@ -187,8 +240,17 @@ int MediaRTPpjmediaApp::run(int argc, char* argv[])
 
 	ServiceManagementPrx service_management = ServiceManagementPrx::uncheckedCast(management->addService(RTPMediaServiceProxy, "media_rtp_pjmedia"));
 
-	/* Now we can add some parameters to help find us. */
+	/* One must provide a component service to manage us, if someone wants to */
+	ComponentServicePtr ComponentService = new ComponentServiceImpl(*this, service_management);
+	ComponentServicePrx ComponentServiceProxy = ComponentServicePrx::uncheckedCast(adapter->addWithUUID(ComponentService));
+
+	/* Let's add the component service to the service locator first */
+	ServiceManagementPrx component_service_management = ServiceManagementPrx::uncheckedCast(management->addService(ComponentServiceProxy, "media_rtp_pjmedia"));
 	ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
+	genericparams->category = "Component/media_rtp_pjmedia";
+	component_service_management->addLocatorParams(genericparams, "");
+
+	/* Now we can add some parameters to help find us. */
 	genericparams->category = "rtp";
 	service_management->addLocatorParams(genericparams, "");
 
@@ -196,6 +258,7 @@ int MediaRTPpjmediaApp::run(int argc, char* argv[])
 	communicator()->waitForShutdown();
 
 	/* When all is said and done we have to leave the party */
+	component_service_management->unregister();
 	service_management->unregister();
 
 	return EXIT_SUCCESS;

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


-- 
asterisk-scf/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list