[Freeswitch-branches] [commit] r3457 - in freeswitch/branches/mishehu/src/mod: endpoints endpoints/mod_opal event_handlers/mod_cdr
Freeswitch SVN
mishehu at freeswitch.org
Sun Nov 26 03:09:59 EST 2006
Author: mishehu
Date: Sun Nov 26 03:09:57 2006
New Revision: 3457
Added:
freeswitch/branches/mishehu/src/mod/endpoints/
freeswitch/branches/mishehu/src/mod/endpoints/mod_opal/
freeswitch/branches/mishehu/src/mod/endpoints/mod_opal/Makefile
freeswitch/branches/mishehu/src/mod/endpoints/mod_opal/baseopal.cpp
freeswitch/branches/mishehu/src/mod/endpoints/mod_opal/baseopal.h
freeswitch/branches/mishehu/src/mod/endpoints/mod_opal/mod_opal.cpp
Modified:
freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/cdrcontainer.cpp
freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mod_cdr.cpp
Log:
Started working on the very base of mod_opal.
Added: freeswitch/branches/mishehu/src/mod/endpoints/mod_opal/Makefile
==============================================================================
--- (empty file)
+++ freeswitch/branches/mishehu/src/mod/endpoints/mod_opal/Makefile Sun Nov 26 03:09:57 2006
@@ -0,0 +1,23 @@
+CFLAGS += -I/usr/include/ptlib -I/usr/include/opal
+LDFLAGS += -lopal -lpt
+
+CPPCC = g++
+OBJS=
+
+all: depends $(OBJS) $(MODNAME).$(DYNAMIC_LIB_EXTEN)
+
+depends:
+
+$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(OBJS) $(MODNAME).cpp
+ $(CPPCC) $(CFLAGS) -fPIC -c $(MODNAME).cpp -o $(MODNAME).o
+ $(CPPCC) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(OBJS) $(LDFLAGS)
+
+
+%.o: %.cpp
+ $(CPPCC) -Wall -Werror -fPIC $(CFLAGS) -c -o $@ $<
+
+clean:
+ rm -fr *.$(DYNAMIC_LIB_EXTEN) *.o *~
+
+install:
+ cp -f $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(PREFIX)/mod
Added: freeswitch/branches/mishehu/src/mod/endpoints/mod_opal/baseopal.cpp
==============================================================================
--- (empty file)
+++ freeswitch/branches/mishehu/src/mod/endpoints/mod_opal/baseopal.cpp Sun Nov 26 03:09:57 2006
@@ -0,0 +1,30 @@
+#include "baseopal.h"
+
+char BaseOPAL::*configfile = "mod_opal.conf";
+
+BaseOPAL::BaseOPAL()
+{
+ memset(&globals, 0, sizeof(globals));
+ switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
+}
+
+void BaseOPAL::load_config()
+{
+ if (!(xml = switch_xml_open_cfg(configfile, &cfg, NULL))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
+ return SWITCH_STATUS_TERM;
+ }
+
+ if ((settings = switch_xml_child(cfg, "settings"))) {
+ for (param = switch_xml_child(settings, "param"); param; param = param->next) {
+ char *var = (char *) switch_xml_attr_soft(param, "name");
+ char *val = (char *) switch_xml_attr_soft(param, "value");
+
+ if (!strcmp(var, "foo")) {
+ foo = atoi(val);
+ }
+
+ switch_xml_free(xml);
+
+ return SWITCH_STATUS_SUCCESS;
+}
\ No newline at end of file
Added: freeswitch/branches/mishehu/src/mod/endpoints/mod_opal/baseopal.h
==============================================================================
--- (empty file)
+++ freeswitch/branches/mishehu/src/mod/endpoints/mod_opal/baseopal.h Sun Nov 26 03:09:57 2006
@@ -0,0 +1,18 @@
+#include <ptlib.h>
+
+#include <opal/buildopts.h>
+
+#include <h323/h323.h>
+#include <h323/gkclient.h>
+#include <lids/lidep.h>
+#include <lids/ixjlid.h>
+#include <ptclib/pstun.h>
+
+class BaseOPAL : public OpalManager {
+ public:
+ BaseOPAL();
+ void load_config();
+ private:
+ switch_xml_t cfg, xml, settings, param;
+ static char *configfile;
+};
\ No newline at end of file
Added: freeswitch/branches/mishehu/src/mod/endpoints/mod_opal/mod_opal.cpp
==============================================================================
--- (empty file)
+++ freeswitch/branches/mishehu/src/mod/endpoints/mod_opal/mod_opal.cpp Sun Nov 26 03:09:57 2006
@@ -0,0 +1,117 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005/2006, Anthony Minessale II <anthmct at yahoo.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * Anthony Minessale II <anthmct at yahoo.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Yossi Neiman <freeswitch AT cartissolutions.com>
+ * Brian West <brian.west at mac.com>
+ *
+ *
+ *
+ * mod_opal.cpp -- OPAL Endpoint Module
+ *
+ */
+
+#include <switch.h>
+
+static const char modname[] = "mod_opal";
+
+static switch_memory_pool_t *module_pool = NULL;
+static int running = 1;
+
+static switch_loadable_module_interface_t opal_module_interface = {
+ /*.module_name */ modname,
+ /*.endpoint_interface */ channel_endpoint_interface,
+ /*.timer_interface */ NULL,
+ /*.dialplan_interface */ NULL,
+ /*.codec_interface */ NULL,
+ /*.application_interface */ NULL,
+ /*.api_interface */ NULL,
+ /*.file_interface */ NULL,
+ /*.speech_interface */ NULL,
+ /*.directory_interface */ NULL
+};
+
+static const switch_state_handler_table_t channel_event_handlers = {
+ /*.on_init */ channel_on_init,
+ /*.on_ring */ channel_on_ring,
+ /*.on_execute */ channel_on_execute,
+ /*.on_hangup */ channel_on_hangup,
+ /*.on_loopback */ channel_on_loopback,
+ /*.on_transmit */ channel_on_transmit
+};
+
+static const switch_io_routines_t channel_io_routines = {
+ /*.outgoing_channel */ channel_outgoing_channel,
+ /*.answer_channel */ channel_answer_channel,
+ /*.read_frame */ channel_read_frame,
+ /*.write_frame */ channel_write_frame,
+ /*.kill_channel */ channel_kill_channel,
+ /*.waitfor_read */ channel_waitfor_read,
+ /*.waitfor_write */ channel_waitfor_write,
+ /*.send_dtmf */ channel_send_dtmf
+};
+
+static const switch_endpoint_interface_t channel_endpoint_interface = {
+ /*.interface_name */ "opal",
+ /*.io_routines */ &channel_io_routines,
+ /*.event_handlers */ &channel_event_handlers,
+ /*.private */ NULL,
+ /*.next */ NULL
+};
+
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+{
+
+ if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
+ return SWITCH_STATUS_TERM;
+ }
+
+ /* connect my internal structure to the blank pointer passed to me */
+ *module_interface = &opal_module_interface;
+
+ /* indicate that the module should continue to be loaded */
+ return SWITCH_STATUS_SUCCESS;
+}
+
+/*
+ Called when the system shuts down
+SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
+{
+ return SWITCH_STATUS_SUCCESS;
+}
+*/
+
+/*
+ If it exists, this is called in it's own thread when the module-load completes
+ If it returns anything but SWITCH_STATUS_TERM it will be called again automaticly
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
+{
+ while(looping)
+ {
+ switch_yield(1000);
+ }
+ return SWITCH_STATUS_TERM;
+}
+*/
Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/cdrcontainer.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/cdrcontainer.cpp (original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/cdrcontainer.cpp Sun Nov 26 03:09:57 2006
@@ -98,12 +98,19 @@
switch_mod_cdr_newchannel_t *newchannel; // = new switch_mod_cdr_newchannel_t;
newchannel = 0;
+ const char *err;
+ switch_xml_t xml_root;
+
+ if ((xml_root = switch_xml_open_root(1, &err))) {
+ switch_console_printf(SWITCH_CHANNEL_LOG,"Reloading the XML file...\n");
+ switch_xml_free(xml_root);
+ }
+
if (!(xml = switch_xml_open_cfg(configfile, &cfg, NULL)))
switch_console_printf(SWITCH_CHANNEL_LOG,"open of %s failed\n", configfile);
else
{
BaseRegistry& registry(BaseRegistry::get());
- registry.reset_active();
for(BaseRegistry::iterator it = registry.active_begin(); it != registry.active_end(); ++it)
{
basecdr_creator func = *it;
@@ -111,6 +118,8 @@
std::auto_ptr<BaseCDR> ptr(_ptr);
ptr->disconnect();
}
+
+ registry.reset_active();
for(BaseRegistry::iterator it = registry.begin(); it != registry.end(); ++it)
{
Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mod_cdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mod_cdr.cpp (original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mod_cdr.cpp Sun Nov 26 03:09:57 2006
@@ -119,6 +119,7 @@
switch_thread_rwlock_wrlock(cdr_rwlock);
newcdrcontainer->reload();
switch_thread_rwlock_unlock(cdr_rwlock);
+ stream->write_function(stream, "XML Reloaded and mod_cdr reloaded.\n");
return SWITCH_STATUS_SUCCESS;
}
More information about the Freeswitch-branches
mailing list