[asterisk-scf-commits] asterisk-scf/integration/media_format_ulaw.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Thu Aug 19 12:45:11 CDT 2010
branch "master" has been updated
via 996f9d303e6c227fd00de98f21d0a9ce625b0f5f (commit)
from 1f842709c6067d8c62b824aa1fe5935227fbb9e1 (commit)
Summary of changes:
src/CMakeLists.txt | 1 +
src/MediaFormatULAW.cpp | 65 ++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 65 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit 996f9d303e6c227fd00de98f21d0a9ce625b0f5f
Author: Joshua Colp <jcolp at digium.com>
Date: Thu Aug 19 14:57:35 2010 -0300
Add a component service implementation for the media_format_ulaw component.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8257a93..0f4ec0a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,6 +1,7 @@
hydra_component_init(media_format_ulaw CXX)
hydra_component_add_slice(media_format_ulaw ServiceLocatorIf)
hydra_component_add_slice(media_format_ulaw MediaIf)
+hydra_component_add_slice(media_format_ulaw ComponentServiceIf)
hydra_component_add_file(media_format_ulaw MediaFormatULAW.cpp)
hydra_component_build_standalone(media_format_ulaw)
hydra_component_install(media_format_ulaw RUNTIME bin "Media Format ULAW." Media)
diff --git a/src/MediaFormatULAW.cpp b/src/MediaFormatULAW.cpp
index bb6296f..d627f74 100644
--- a/src/MediaFormatULAW.cpp
+++ b/src/MediaFormatULAW.cpp
@@ -20,10 +20,12 @@
#include "Core/Discovery/ServiceLocatorIf.h"
#include "Media/MediaIf.h"
+#include "System/Component/ComponentServiceIf.h"
using namespace std;
using namespace Hydra::Core::Discovery::V1;
using namespace Hydra::Media::V1;
+using namespace Hydra::System::Component::V1;
/**
* Implementation of the MediaFormatService interface as defined in media.ice
@@ -111,6 +113,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(MediaFormatULAWApp& 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.
+ */
+ MediaFormatULAWApp& mApplication;
+
+ /**
+ * Our service locator management proxy, we'll use it to suspend and
+ * unsuspend ourselves.
+ */
+ ServiceManagementPrx& mManagement;
+};
+
+/**
* Main entry point for our ulaw media format component.
*/
int main(int argc, char* argv[])
@@ -155,8 +208,17 @@ int MediaFormatULAWApp::run(int argc, char* argv[])
/* Boom! In we go as a service. */
ServiceManagementPrx service_management = ServiceManagementPrx::uncheckedCast(management->addService(MediaFormatServiceProxy, "media_format_ulaw"));
- /* 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_format_ulaw"));
ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
+ genericparams->category = "Component/media_format_ulaw";
+ component_service_management->addLocatorParams(genericparams, "");
+
+ /* Now we can add some parameters to help find the actual media format service. */
genericparams->category = "media_format";
service_management->addLocatorParams(genericparams, ServiceLocatorParamsCompareProxy->ice_getIdentity().name);
@@ -164,6 +226,7 @@ int MediaFormatULAWApp::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_format_ulaw.git
More information about the asterisk-scf-commits
mailing list