[hydra-commits] hydra/media_format_ulaw.git branch "master" updated.
Commits to the Hydra project code repositories
hydra-commits at lists.digium.com
Mon Aug 2 11:57:26 CDT 2010
branch "master" has been updated
via 70b8b7d371335dba998a8f438269ed7977e661de (commit)
via b113718c3063f60288e3fa38ce52c26116ef1607 (commit)
via b235cc4172872bf5cf36c4946a6b49db571c4bf0 (commit)
via 406aa738c8fdc36492dae8a03d62d95855a35b85 (commit)
from 12b6f84a2f3237c8887b3fa58e37b35a968e993a (commit)
Summary of changes:
CMakeLists.txt | 3 +
slice/CMakeLists.txt | 6 ++
slice/media.ice | 3 +-
slice/service_locator.ice | 158 ++++++++++++++++++++++++++++++++++++++++++
src/CMakeLists.txt | 3 +-
src/MediaFormatULAW.cpp | 73 +++++++++++++++++++
test/CMakeLists.txt | 1 +
test/TestMediaFormatULAW.cpp | 67 ++++++++++++++++++
8 files changed, 312 insertions(+), 2 deletions(-)
create mode 100644 slice/CMakeLists.txt
create mode 100644 slice/service_locator.ice
- Log -----------------------------------------------------------------
commit 70b8b7d371335dba998a8f438269ed7977e661de
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Aug 2 13:57:10 2010 -0300
Add skeleton files to the closet.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6c65e50..e711b8a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,5 +1,6 @@
hydra_component_init(media_format_ulaw CXX)
-#hydra_component_add_slice(media_format_ulaw service_discovery)
+hydra_component_add_slice(media_format_ulaw service_locator)
+hydra_component_add_slice(media_format_ulaw media)
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 e69de29..3bf79d9 100644
--- a/src/MediaFormatULAW.cpp
+++ b/src/MediaFormatULAW.cpp
@@ -0,0 +1,73 @@
+/*
+ * ZOMGZHYDRA?!? -- An open source telephony framework.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * Joshua Colp <jcolp at digium.com>
+ *
+ * See http://www.IcanhazURL.org for more information about
+ * the ZOMGZHYDRA?!? 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 file
+ * at the top of the source tree.
+ */
+
+#include <Ice/Ice.h>
+
+#include "service_locator.h"
+#include "media.h"
+
+using namespace std;
+using namespace Hydra::Location::V1;
+using namespace Hydra::Media::V1;
+
+/**
+ * Implementation of the Ice::Application class
+ */
+class MediaFormatULAWApp : public Ice::Application
+{
+public:
+ int run(int, char*[]);
+ void interruptCallback(int);
+
+private:
+};
+
+/**
+ * Main entry point for our ulaw media format component.
+ */
+int main(int argc, char* argv[])
+{
+ MediaFormatULAWApp app;
+ app.callbackOnInterrupt();
+ return app.main(argc, argv);
+}
+
+/**
+ * Overload of the Ice::Application::run method.
+ */
+int MediaFormatULAWApp::run(int argc, char* argv[])
+{
+ cout << "Initializing ulaw media format component" << endl;
+
+ Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("MediaFormatULAWAdapter");
+
+ adapter->activate();
+
+ cout << "Activated ulaw media format component." << endl;
+
+ /* Since we can now actually respond to requests we can add ourselves into the service locator. */
+
+ communicator()->waitForShutdown();
+
+ return EXIT_SUCCESS;
+}
+
+void MediaFormatULAWApp::interruptCallback(int val)
+{
+ _exit(EXIT_SUCCESS);
+}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 031146b..5a73669 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,5 +1,6 @@
hydra_component_init(media_format_ulaw_test CXX)
hydra_component_add_file(media_format_ulaw_test TestMediaFormatULAW.cpp)
+hydra_component_add_slice(media_format_ulaw_test media)
hydra_component_add_boost_libraries(media_format_ulaw_test unit_test_framework)
hydra_component_build_standalone(media_format_ulaw_test)
hydra_component_install(media_format_ulaw_test RUNTIME bin "Media Format ULAW Test Driver." Core)
diff --git a/test/TestMediaFormatULAW.cpp b/test/TestMediaFormatULAW.cpp
index e69de29..d48d7f9 100644
--- a/test/TestMediaFormatULAW.cpp
+++ b/test/TestMediaFormatULAW.cpp
@@ -0,0 +1,67 @@
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_MODULE MediaFormatULAWTestSuite
+#define BOOST_TEST_NO_MAIN
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/debug.hpp>
+
+#include <Ice/Ice.h>
+
+#include "media.h"
+
+using namespace std;
+using namespace Hydra::Media::V1;
+
+/* Cache the command line arguments so that Ice can be initialized within the global fixture. */
+struct ArgCacheType
+{
+public:
+ int argc;
+ char **argv;
+};
+static ArgCacheType mCachedArgs;
+
+/**
+ * It seems odd that boost doesn't provide an easy way to access the GLOBAL_FIXTURE members.
+ * But it doesn't seem to, so I'm sharing global setup stuff here.
+ */
+struct SharedTestData
+{
+public:
+};
+//static SharedTestData Testbed;
+
+/**
+ * A global fixture for Ice initialization.
+ * Provides setup/teardown for the entire set of tests.
+ */
+struct GlobalIceFixture
+{
+ GlobalIceFixture()
+ {
+ BOOST_TEST_MESSAGE("Setting up MediaFormatULAW test fixture");
+
+ ::boost::debug::detect_memory_leaks(false);
+ ::boost::unit_test::unit_test_log.set_stream( std::cout );
+ } // end Fixture() constructor
+
+ ~GlobalIceFixture()
+ {
+ BOOST_TEST_MESSAGE("Tearing down MediaFormatULAW test fixture");
+ }
+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 );
+}
commit b113718c3063f60288e3fa38ce52c26116ef1607
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Aug 2 13:44:42 2010 -0300
Make the FormatDiscovery class extend ServiceLocatorParams so it can be passed into the service locator.
diff --git a/slice/media.ice b/slice/media.ice
index 197b5a4..de3eb92 100644
--- a/slice/media.ice
+++ b/slice/media.ice
@@ -1,4 +1,5 @@
#include <Ice/BuiltinSequences.ice>
+#include "service_locator.ice"
module Hydra
{
@@ -198,7 +199,7 @@ module V1
* A generic format discovery class that can be extended for adding parameters. The parameters are used to find
* a component capable of interpreting and providing a concrete class for a format.
*/
- class FormatDiscovery
+ class FormatDiscovery extends Hydra::Location::V1::ServiceLocatorParams
{
};
commit b235cc4172872bf5cf36c4946a6b49db571c4bf0
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Aug 2 13:44:26 2010 -0300
Actually compile the slice definitions.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9080617..ff44655 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,6 +9,9 @@ include(cmake/Hydra_v4.cmake)
# This project is C++ based and requires a minimum of 3.4
hydra_project(media_format_ulaw 3.4 CXX)
+# Knock out slice definitions
+add_subdirectory(slice)
+
# Take care of the source code for this project
add_subdirectory(src)
diff --git a/slice/CMakeLists.txt b/slice/CMakeLists.txt
new file mode 100644
index 0000000..baa9f28
--- /dev/null
+++ b/slice/CMakeLists.txt
@@ -0,0 +1,6 @@
+# Compile our service discovery slice definition so we can then use it
+hydra_compile_slice(service_locator.ice lib "Slice Defined API" Core)
+
+# Oh, and of course media!
+hydra_compile_slice(media.ice lib "Slice Defined API" Core)
+
commit 406aa738c8fdc36492dae8a03d62d95855a35b85
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Aug 2 13:43:44 2010 -0300
Until how slices will be managed is settled just copy this into here for now.
diff --git a/slice/service_locator.ice b/slice/service_locator.ice
new file mode 100644
index 0000000..132403f
--- /dev/null
+++ b/slice/service_locator.ice
@@ -0,0 +1,158 @@
+#include <Ice/BuiltinSequences.ice>
+
+module Hydra
+{
+
+module Location
+{
+
+module V1
+{
+
+ /**
+ * Exception used for service locator requests to indicate that no service could be found.
+ */
+ exception ServiceNotFound
+ {
+ };
+
+ /**
+ * Exception used for indicating that a comparator is already registered with a given guid.
+ */
+ exception DuplicateCompare
+ {
+ };
+
+ /**
+ * Exception used for indicating that a comparator was not found.
+ */
+ exception CompareNotFound
+ {
+ };
+
+ /**
+ * Generic service locator parameters class that more specific parameter classes can extend.
+ */
+ class ServiceLocatorParams
+ {
+ /**
+ * Basic category for the service, such as bridge or channel service.
+ */
+ string category;
+ };
+
+ /**
+ * Interface used to perform service locator requests.
+ */
+ interface ServiceLocator
+ {
+ /**
+ * Method which performs a locator request using provided parameters but only returns a single
+ * proxy.
+ *
+ * @param params A concrete class containing parameters describing the service that is trying to be found.
+ *
+ * @return A proxy to the service matching the given parameters.
+ */
+ idempotent Object *locate(ServiceLocatorParams params) throws ServiceNotFound;
+
+ /**
+ * Method which performs a location request using provided parameters but can return multiple
+ * proxies.
+ *
+ * @param params A concrete class containing parameters describing the service that is trying to be found.
+ *
+ * @return A sequence of proxies which match the given parameters.
+ */
+ idempotent Ice::ObjectProxySeq locateAll(ServiceLocatorParams params) throws ServiceNotFound;
+ };
+
+ /**
+ * Interface to the service locator component which allows manipulation of registered service.
+ */
+ interface ServiceManagement
+ {
+ /**
+ * Method which adds supported discovery parameters to a registered service.
+ *
+ * @param params A concrete class containing parameters describing what is supported.
+ *
+ * @param compareguid The unique identifier of a comparator which can perform a lower level
+ * comparison to determine whether supplied parameters in a locator request
+ * are truly supported or not. This is optional.
+ */
+ void addLocatorParams(ServiceLocatorParams params, string compareguid);
+
+ /**
+ * Method which suspends this service from being considered when a locator request
+ * is performed.
+ */
+ void suspend();
+
+ /**
+ * Method which unsuspends this service. Once this method is called the service will
+ * be able to found again when a locator request is performed.
+ */
+ void unsuspend();
+
+ /**
+ * Method which unregisters this service from the service locator.
+ */
+ void unregister();
+ };
+
+ /**
+ * Interface to an external component which performs a service locator parameters comparison.
+ */
+ interface ServiceLocatorParamsCompare
+ {
+ /**
+ * Method which determines whether provided parameters are supported by the
+ * comparator or not.
+ *
+ * @param params A concrete class containing parameters describing the service that is trying to be found.
+ *
+ * @return A boolean value with true meaning the parameters are supported and false if not.
+ *
+ */
+ bool isSupported(ServiceLocatorParams params);
+ };
+
+ /**
+ * Interface to do service locator management, such as adding services and comparators.
+ */
+ interface ServiceLocatorManagement
+ {
+ /**
+ * Method which adds a service to the service locator.
+ *
+ * @param service A proxy to the service that is being registered.
+ *
+ * @param guid A unique identifier for the service which is used in events.
+ *
+ * @return A proxy to the service management interface for this service.
+ */
+ ServiceManagement *addService(Object *service, string guid);
+
+ /**
+ * Method which adds a comparator to the service locator.
+ *
+ * @param compareguid A unique identifier for this comparator.
+ *
+ * @param compare A proxy to the comparator service.
+ */
+ void addCompare(string compareguid, ServiceLocatorParamsCompare *compare) throws DuplicateCompare;
+
+ /**
+ * Method which removes a comparator from the service locator.
+ *
+ * @param compareguid The unique identifier for the comparator to remove.
+ */
+ void removeCompare(string compareguid) throws CompareNotFound;
+ };
+
+}; // end module V1
+
+}; // end module Location
+
+}; // end module Hydra
-----------------------------------------------------------------------
--
hydra/media_format_ulaw.git
More information about the asterisk-scf-commits
mailing list