]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
move mod_opal into trunk
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 12 Dec 2008 16:44:23 +0000 (16:44 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 12 Dec 2008 16:44:23 +0000 (16:44 +0000)
still needs some work
still needs some FUNDING

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10734 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_opal/Makefile [new file with mode: 0644]
src/mod/endpoints/mod_opal/mod_opal.cpp [new file with mode: 0644]
src/mod/endpoints/mod_opal/mod_opal.h [new file with mode: 0644]
src/mod/endpoints/mod_opal/mod_opal_2005.vcproj [new file with mode: 0644]
src/mod/endpoints/mod_opal/mod_opal_2008.vcproj [new file with mode: 0644]
src/mod/endpoints/mod_opal/opal.conf.xml [new file with mode: 0644]

diff --git a/src/mod/endpoints/mod_opal/Makefile b/src/mod/endpoints/mod_opal/Makefile
new file mode 100644 (file)
index 0000000..fc0fc48
--- /dev/null
@@ -0,0 +1,8 @@
+BASE=../../../..
+LOCAL_INSERT_CFLAGS= pkg-config opal --cflags 
+LOCAL_CFLAGS+=-g -ggdb -I.
+LOCAL_INSERT_LDFLAGS= pkg-config opal --libs
+
+include $(BASE)/build/modmake.rules
+
+
diff --git a/src/mod/endpoints/mod_opal/mod_opal.cpp b/src/mod/endpoints/mod_opal/mod_opal.cpp
new file mode 100644 (file)
index 0000000..ac44b46
--- /dev/null
@@ -0,0 +1,1250 @@
+/* Opal endpoint interface for Freeswitch Modular Media Switching Software Library /\r
+ * Soft-Switch Application\r
+ *\r
+ * Version: MPL 1.1\r
+ *\r
+ * Copyright (c) 2007 Tuyan Ozipek (tuyanozipek@gmail.com)\r
+ *\r
+ * The contents of this file are subject to the Mozilla Public License Version\r
+ * 1.1 (the "License"); you may not use this file except in compliance with\r
+ * the License. You may obtain a copy of the License at\r
+ * http://www.mozilla.org/MPL/\r
+ *\r
+ * Software distributed under the License is distributed on an "AS IS" basis,\r
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License\r
+ * for the specific language governing rights and limitations under the\r
+ * License.\r
+ *\r
+ * Contributor(s):\r
+ * Tuyan Ozipek   (tuyanozipek@gmail.com)\r
+ * Lukasz Zwierko (lzwierko@gmail.com)\r
+ * Robert Jongbloed (robertj@voxlucida.com.au)\r
+ *\r
+ */\r
+\r
+#include "mod_opal.h"\r
+#include <opal/patch.h>\r
+#include <h323/h323pdu.h>\r
+\r
+SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, mod_opal_globals.codec_string);\r
+SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_context, mod_opal_globals.context);\r
+SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, mod_opal_globals.dialplan);\r
+\r
+\r
+#define CF_NEED_FLUSH (1 << 1)\r
+\r
+struct mod_opal_globals mod_opal_globals = { 0 };\r
+\r
+\r
+static switch_call_cause_t create_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,\r
+                                                   switch_caller_profile_t *outbound_profile, switch_core_session_t **new_session,\r
+                                                   switch_memory_pool_t **pool, switch_originate_flag_t flags);\r
+\r
+\r
+static FSProcess *opal_process = NULL;\r
+\r
+\r
+static const char ModuleName[] = "opal";\r
+\r
+\r
+static switch_io_routines_t opalfs_io_routines = {\r
+    /*.outgoing_channel */ create_outgoing_channel,\r
+    /*.read_frame */ FSConnection::read_audio_frame,\r
+    /*.write_frame */ FSConnection::write_audio_frame,\r
+    /*.kill_channel */ FSConnection::kill_channel,\r
+    /*.send_dtmf */ FSConnection::send_dtmf,\r
+    /*.receive_message */ FSConnection::receive_message,\r
+    /*.receive_event */ FSConnection::receive_event,\r
+    /*.state_change */ FSConnection::state_change,\r
+    /*.read_video_frame */ FSConnection::read_video_frame,\r
+    /*.write_video_frame */ FSConnection::write_video_frame\r
+};\r
+\r
+static switch_state_handler_table_t opalfs_event_handlers = {\r
+    /*.on_init */ FSConnection::on_init,\r
+    /*.on_routing */ FSConnection::on_routing,\r
+    /*.on_execute */ FSConnection::on_execute,\r
+    /*.on_hangup */ FSConnection::on_hangup,\r
+    /*.on_loopback */ FSConnection::on_loopback,\r
+    /*.on_transmit */ FSConnection::on_transmit\r
+};\r
+\r
+\r
+SWITCH_BEGIN_EXTERN_C\r
+/*******************************************************************************/\r
+\r
+SWITCH_MODULE_LOAD_FUNCTION(mod_opal_load);\r
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_opal_shutdown);\r
+SWITCH_MODULE_DEFINITION(mod_opal, mod_opal_load, mod_opal_shutdown, NULL);\r
+\r
+SWITCH_MODULE_LOAD_FUNCTION(mod_opal_load) {\r
+    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Starting loading mod_opal\n");\r
+\r
+    /* Prevent the loading of OPAL codecs via "plug ins", this is a directory\r
+       full of DLLs that will be loaded automatically. */\r
+    putenv("PTLIBPLUGINDIR=/no/thanks");\r
+\r
+\r
+    *module_interface = switch_loadable_module_create_module_interface(pool, modname);\r
+    if (!*module_interface) {\r
+        return SWITCH_STATUS_MEMERR;\r
+    }\r
+\r
+    opal_process = new FSProcess();\r
+    if (opal_process == NULL) {\r
+        return SWITCH_STATUS_MEMERR;\r
+    }\r
+\r
+    if (opal_process->Initialise(*module_interface)) {\r
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Opal manager initialized and running\n");\r
+        //unloading causes a seg in linux\r
+        return SWITCH_STATUS_NOUNLOAD;\r
+        //return SWITCH_STATUS_SUCCESS;\r
+    }\r
+\r
+    delete opal_process;\r
+    opal_process = NULL;\r
+    return SWITCH_STATUS_FALSE;\r
+}\r
+\r
+\r
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_opal_shutdown) {\r
+    \r
+    switch_safe_free(mod_opal_globals.context);\r
+    switch_safe_free(mod_opal_globals.dialplan);\r
+    switch_safe_free(mod_opal_globals.codec_string);\r
+    delete opal_process;\r
+    opal_process = NULL;\r
+    return SWITCH_STATUS_SUCCESS;\r
+}\r
+\r
+SWITCH_END_EXTERN_C\r
+/*******************************************************************************/\r
+\r
+\r
+\r
+static switch_call_cause_t create_outgoing_channel(switch_core_session_t *session,\r
+                                                   switch_event_t *var_event,\r
+                                                   switch_caller_profile_t *outbound_profile,\r
+                                                   switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)\r
+{\r
+    if (opal_process == NULL) {\r
+        return SWITCH_CAUSE_CRASH;\r
+    }\r
+\r
+    PString token;\r
+\r
+    FSManager & manager = opal_process->GetManager();\r
+    if (!manager.SetUpCall("local:", outbound_profile->destination_number, token)) {\r
+        return SWITCH_CAUSE_INVALID_NUMBER_FORMAT;\r
+    }\r
+\r
+    PSafePtr < OpalCall > call = manager.FindCallWithLock(token);\r
+\r
+    if (call == NULL) {\r
+        return SWITCH_CAUSE_PROTOCOL_ERROR;\r
+    }\r
+\r
+    PSafePtr < FSConnection > connection = call->GetConnectionAs < FSConnection > (0);\r
+\r
+    if (connection == NULL) {\r
+        return SWITCH_CAUSE_PROTOCOL_ERROR;\r
+    }\r
+\r
+    *new_session = connection->GetSession();\r
+\r
+    connection->SetLocalPartyName(outbound_profile->caller_id_number);\r
+    connection->SetDisplayName(outbound_profile->caller_id_name);\r
+\r
+\r
+    switch_caller_profile_t *caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);\r
+    switch_channel_t *channel = switch_core_session_get_channel(*new_session);\r
+    char name[256] = "opal/";\r
+    switch_copy_string(name + 5, outbound_profile->destination_number, sizeof(name)-5);\r
+    switch_channel_set_name(channel, name);\r
+\r
+    switch_channel_set_caller_profile(channel, caller_profile);\r
+    switch_channel_set_state(channel, CS_INIT);\r
+\r
+    return SWITCH_CAUSE_SUCCESS;\r
+}\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////\r
+\r
+#if PTRACING\r
+\r
+class FSTrace : public ostream {\r
+ public:\r
+ FSTrace()\r
+     : ostream(&buffer)\r
+        {\r
+        }\r
+\r
+ private:\r
+ class Buffer : public streambuf {\r
+        char buffer[250];\r
+\r
+    public:\r
+        Buffer()\r
+            {\r
+                setg(buffer, buffer, &buffer[sizeof(buffer)-2]);\r
+                setp(buffer, &buffer[sizeof(buffer)-2]);\r
+            }\r
+\r
+        virtual int sync()\r
+        {\r
+            return overflow(EOF);\r
+        }\r
+\r
+        virtual int underflow()\r
+        {\r
+            return EOF;\r
+        }\r
+\r
+        virtual int overflow(int c)\r
+        {\r
+            const char *fmt = "%s";\r
+            char *func = NULL;\r
+\r
+            int bufSize = pptr() - pbase();\r
+\r
+            if (c != EOF) {\r
+                *pptr() = (char)c;\r
+                bufSize++;\r
+            }\r
+            \r
+            if (bufSize != 0) {\r
+                char *bufPtr = pbase();\r
+                char *bufEndPtr = NULL;\r
+                setp(bufPtr, epptr());\r
+                bufPtr[bufSize] = '\0';\r
+                int line = 0;\r
+                char *p;\r
+                \r
+                char *file = NULL;\r
+                switch_log_level_t level;\r
+\r
+                \r
+                switch (strtoul(bufPtr, &file, 10)) {\r
+                case 1 :\r
+                    level = SWITCH_LOG_INFO;\r
+                    break;\r
+                default :\r
+                    level = SWITCH_LOG_DEBUG;\r
+                    break;\r
+                }\r
+\r
+                if (file) {\r
+                    while (isspace(*file)) file++;\r
+                    \r
+                    if (file && (bufPtr = strchr(file, '(')) && (bufEndPtr = strchr(bufPtr, ')'))) {\r
+                        char *e;\r
+\r
+                        for(p = bufPtr; p && *p; p++) {\r
+                            if (*p == '\t') {\r
+                                *p = ' ';\r
+                            }\r
+                        }\r
+\r
+                        *bufPtr++ = '\0';\r
+                        line = atoi(bufPtr);\r
+                        while (bufEndPtr && isspace(*(++bufEndPtr)));\r
+                        bufPtr = bufEndPtr;\r
+                        if (bufPtr && (e = strchr(bufPtr, ' ')) || (e = strchr(bufPtr, '\t'))) {\r
+                            func = bufPtr;\r
+                            bufPtr = e;\r
+                            *bufPtr++ = '\0';\r
+                        }\r
+                    }\r
+                }\r
+                \r
+                switch_text_channel_t tchannel = SWITCH_CHANNEL_ID_LOG;\r
+\r
+                if (!bufPtr) {\r
+                    bufPtr = pbase();\r
+                    level = SWITCH_LOG_DEBUG;\r
+                }\r
+\r
+                if (bufPtr) {\r
+                    if (end_of(bufPtr) != '\n') {\r
+                        fmt = "%s\n";\r
+                    }\r
+                    if (!(file && func && line)) tchannel = SWITCH_CHANNEL_ID_LOG_CLEAN;\r
+\r
+                    switch_log_printf(tchannel, file, func, line, NULL, level, fmt, bufPtr);\r
+                }\r
+                \r
+            }\r
+\r
+            return 0;\r
+        }\r
+    } buffer;\r
+};\r
+\r
+#endif\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////\r
+\r
+FSProcess::FSProcess()\r
+  : PLibraryProcess("Vox Lucida Pty. Ltd.", "mod_opal", 1, 0, AlphaCode, 1)\r
+  , m_manager(NULL)\r
+{\r
+}\r
+\r
+\r
+FSProcess::~FSProcess()\r
+{\r
+  delete m_manager;\r
+}\r
+\r
+\r
+bool FSProcess::Initialise(switch_loadable_module_interface_t *iface)\r
+{\r
+  m_manager = new FSManager();\r
+  return m_manager != NULL && m_manager->Initialise(iface);\r
+}\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////\r
+\r
+FSManager::FSManager()\r
+{\r
+    // These are deleted by the OpalManager class, no need to have destructor\r
+    m_h323ep = new H323EndPoint(*this);\r
+    m_iaxep = new IAX2EndPoint(*this);\r
+    m_fsep = new FSEndPoint(*this);\r
+}\r
+\r
+\r
+bool FSManager::Initialise(switch_loadable_module_interface_t *iface)\r
+{\r
+    ReadConfig(false);\r
+\r
+#if PTRACING\r
+    PTrace::SetLevel(mod_opal_globals.trace_level);        //just for fun and eyecandy ;)\r
+    PTrace::SetOptions(PTrace::TraceLevel);\r
+    PTrace::SetStream(new FSTrace);\r
+#endif\r
+\r
+    m_FreeSwitch = (switch_endpoint_interface_t *) switch_loadable_module_create_interface(iface, SWITCH_ENDPOINT_INTERFACE);\r
+    m_FreeSwitch->interface_name = ModuleName;\r
+    m_FreeSwitch->io_routines = &opalfs_io_routines;\r
+    m_FreeSwitch->state_handler = &opalfs_event_handlers;\r
+\r
+    SetAudioJitterDelay(800, 3000); // should be config option\r
+\r
+    silenceDetectParams.m_mode = OpalSilenceDetector::NoSilenceDetection;\r
+\r
+    if (m_listeners.empty()) {\r
+        m_h323ep->StartListener("");\r
+    } else {\r
+        for (std::list < FSListener >::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) {\r
+            if (!m_h323ep->StartListener(it->listenAddress)) {\r
+                PTRACE(3, "mod_opal\tCannot start listener for " << it->name);\r
+            }\r
+        }\r
+    }\r
+\r
+    AddRouteEntry("h323:.* = local:<da>");  // config option for direct routing\r
+    AddRouteEntry("iax2:.* = local:<da>");  // config option for direct routing\r
+    AddRouteEntry("local:.* = h323:<da>");  // config option for direct routing\r
+\r
+    /* For compatibility with the algorithm in FSConnection::SetCodecs() we need\r
+       to set all audio media formats to be 1 frame per packet */\r
+    OpalMediaFormatList allCodecs = OpalMediaFormat::GetAllRegisteredMediaFormats();\r
+    for (OpalMediaFormatList::iterator it = allCodecs.begin(); it != allCodecs.end(); ++it) {\r
+      if (it->GetMediaType() == OpalMediaType::Audio()) {\r
+        it->SetOptionInteger(OpalAudioFormat::RxFramesPerPacketOption(), 1);\r
+        it->SetOptionInteger(OpalAudioFormat::TxFramesPerPacketOption(), 1);\r
+      }\r
+    }\r
+\r
+    return TRUE;\r
+}\r
+\r
+\r
+switch_status_t FSManager::ReadConfig(int reload)\r
+{\r
+    const char *cf = "opal.conf";\r
+    switch_status_t status = SWITCH_STATUS_SUCCESS;\r
+\r
+    switch_memory_pool_t *pool = NULL;\r
+    if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) {\r
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");\r
+        return status;\r
+    }\r
+\r
+    set_global_context("default");\r
+    set_global_dialplan("XML");\r
+\r
+    switch_event_t *params = NULL;\r
+    switch_event_create(&params, SWITCH_EVENT_REQUEST_PARAMS);\r
+    switch_assert(params);\r
+    switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "profile", switch_str_nil(""));\r
+    switch_xml_t cfg;\r
+    switch_xml_t xml = switch_xml_open_cfg(cf, &cfg, params);\r
+    if (xml == NULL) {\r
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);\r
+        return SWITCH_STATUS_FALSE;\r
+    } else {\r
+        switch_xml_t xmlSettings = switch_xml_child(cfg, "settings");\r
+        if (xmlSettings) {\r
+            for (switch_xml_t xmlParam = switch_xml_child(xmlSettings, "param"); xmlParam != NULL; xmlParam = xmlParam->next) {\r
+                const char *var = switch_xml_attr_soft(xmlParam, "name");\r
+                const char *val = switch_xml_attr_soft(xmlParam, "value");\r
+\r
+                if (!strcasecmp(var, "trace-level")) {\r
+                    int level = atoi(val);\r
+                    if (level > 0) {\r
+                        mod_opal_globals.trace_level = level;\r
+                    }\r
+                } else if (!strcasecmp(var, "context")) {\r
+                    set_global_context(val);\r
+                } else if (!strcasecmp(var, "dialplan")) {\r
+                    set_global_dialplan(val);\r
+                } else if (!strcasecmp(var, "codec-prefs")) {\r
+                    set_global_codec_string(val);\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+\r
+    switch_xml_t xmlListeners = switch_xml_child(cfg, "listeners");\r
+    if (xmlListeners != NULL) {\r
+        for (switch_xml_t xmlListener = switch_xml_child(xmlListeners, "listener"); xmlListener != NULL; xmlListener = xmlListener->next) {\r
+\r
+            m_listeners.push_back(FSListener());\r
+            FSListener & listener = m_listeners.back();\r
+\r
+            listener.name = switch_xml_attr_soft(xmlListener, "name");\r
+            if (listener.name.IsEmpty())\r
+                listener.name = "unnamed";\r
+\r
+            PIPSocket::Address ip;\r
+            WORD port = 1720;\r
+\r
+            for (switch_xml_t xmlParam = switch_xml_child(xmlListener, "param"); xmlParam != NULL; xmlParam = xmlParam->next) {\r
+                const char *var = switch_xml_attr_soft(xmlParam, "name");\r
+                const char *val = switch_xml_attr_soft(xmlParam, "value");\r
+                //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Var - '%s' and Val - '%s' \n", var, val);\r
+                if (!strcasecmp(var, "h323-ip"))\r
+                    ip = val;\r
+                else if (!strcasecmp(var, "h323-port"))\r
+                    port = (WORD) atoi(val);\r
+            }\r
+\r
+            listener.listenAddress = OpalTransportAddress(ip, port);\r
+            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created Listener '%s'\n", (const char *) listener.name);\r
+        }\r
+    }\r
+\r
+    if (xml)\r
+        switch_xml_free(xml);\r
+\r
+    return status;\r
+}\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////\r
+\r
+FSEndPoint::FSEndPoint(FSManager & manager)\r
+:   OpalLocalEndPoint(manager)\r
+{\r
+    PTRACE(3, "mod_opal\t FSEndPoint Created!");\r
+}\r
+\r
+\r
+bool FSEndPoint::OnIncomingCall(OpalLocalConnection & connection)\r
+{\r
+    return ((FSConnection &) connection).OnIncoming();\r
+}\r
+\r
+\r
+OpalLocalConnection *FSEndPoint::CreateConnection(OpalCall & call, void *userData)\r
+{\r
+    return new FSConnection(call, *this);\r
+}\r
+\r
+\r
+bool FSEndPoint::AddMediaFormat(const switch_codec_implementation_t *codec)\r
+{\r
+    OpalMediaType mediaType;\r
+\r
+    switch (codec->codec_type) {\r
+      case SWITCH_CODEC_TYPE_AUDIO:\r
+        mediaType = OpalMediaType::Audio();\r
+        break;\r
+\r
+      case SWITCH_CODEC_TYPE_VIDEO:\r
+        mediaType = OpalMediaType::Video();\r
+        break;\r
+\r
+      case SWITCH_CODEC_TYPE_T38:\r
+        mediaType = OpalMediaType::Fax();\r
+        break;\r
+\r
+      default:\r
+        return false;\r
+    }\r
+\r
+    OpalMediaFormat * newMediaFormat = new OpalMediaFormat(codec->iananame,\r
+                                                           mediaType,\r
+                                                           (RTP_DataFrame::PayloadTypes) codec->ianacode,\r
+                                                           codec->iananame,\r
+                                                           codec->codec_type == SWITCH_CODEC_TYPE_AUDIO,\r
+                                                           codec->bits_per_second,\r
+                                                           codec->encoded_bytes_per_packet,\r
+                                                           codec->samples_per_packet,\r
+                                                           codec->samples_per_second);\r
+    if (newMediaFormat == NULL || !newMediaFormat->IsValid()) {\r
+        return false;\r
+    }\r
+\r
+    // Save pointer so will auto delete allocated objects on destruction.\r
+    m_globalMediaFormats.Append(newMediaFormat);\r
+\r
+    PTRACE(2, "mod_opal\tNew OPAL media format created for FS codec: iananame=" << codec->iananame\r
+           << ", ianacode=" << codec->ianacode << ", rate=" << codec->samples_per_second);\r
+    return true;\r
+}\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////\r
+\r
+FSConnection::FSConnection(OpalCall & call, FSEndPoint & endpoint)\r
+  : OpalLocalConnection(call, endpoint, NULL)\r
+  , m_endpoint(endpoint)\r
+{\r
+    FSManager & mgr = (FSManager &) endpoint.GetManager();\r
+    m_fsSession = switch_core_session_request(mgr.GetSwitchInterface(), NULL);\r
+    m_fsChannel = switch_core_session_get_channel(m_fsSession);\r
+    switch_core_session_set_private(m_fsSession, this);\r
+}\r
+\r
+\r
+bool FSConnection::OnIncoming()\r
+{\r
+    if (m_fsSession == NULL) {\r
+        PTRACE(1, "mod_opal\tSession request failed.");\r
+        return false;\r
+    }\r
+\r
+    switch_core_session_add_stream(m_fsSession, NULL);\r
+\r
+    switch_channel_t *channel = switch_core_session_get_channel(m_fsSession);\r
+    if (channel == NULL) {\r
+        PTRACE(1, "mod_opal\tSession does not have a channel");\r
+        return false;\r
+    }\r
+\r
+    PURL url = GetRemotePartyURL();\r
+    switch_caller_profile_t *caller_profile = switch_caller_profile_new(switch_core_session_get_pool(m_fsSession),\r
+                                                                        url.GetUserName(),\r
+                                                                        /** username */\r
+                                                                        mod_opal_globals.dialplan,\r
+                                                                        /** dial plan */\r
+                                                                        GetRemotePartyName(),\r
+                                                                        /** caller_id_name */\r
+                                                                        GetRemotePartyNumber(),\r
+                                                                        /** caller_id_number */\r
+                                                                        url.GetHostName(),\r
+                                                                        /** network addr */\r
+                                                                        NULL,\r
+                                                                        /** ANI */\r
+                                                                        NULL,\r
+                                                                        /** ANI II */\r
+                                                                        NULL,\r
+                                                                        /** RDNIS */\r
+                                                                        ModuleName,\r
+                                                                        /** source */\r
+                                                                        mod_opal_globals.context,\r
+                                                                        /** set context  */\r
+                                                                        GetCalledPartyNumber()\r
+                                                                        /** destination_number */\r
+                                                                        );\r
+    if (caller_profile == NULL) {\r
+        PTRACE(1, "mod_opal\tCould not create caller profile");\r
+        return false;\r
+    }\r
+\r
+    PTRACE(4, "mod_opal\tCreated switch caller profile:\n"\r
+           "  username       = " << caller_profile->username << "\n"\r
+           "  dialplan       = " << caller_profile->dialplan << "\n"\r
+           "  caller_id_name     = " << caller_profile->caller_id_name << "\n"\r
+           "  caller_id_number   = " << caller_profile->caller_id_number << "\n"\r
+           "  network_addr   = " << caller_profile->network_addr << "\n"\r
+           "  source         = " << caller_profile->source << "\n"\r
+           "  context        = " << caller_profile->context << "\n" "  destination_number= " << caller_profile->destination_number);\r
+    switch_channel_set_caller_profile(channel, caller_profile);\r
+\r
+    char name[256] = "opal/in:";\r
+    switch_copy_string(name + 8, caller_profile->destination_number, sizeof(name)-8);\r
+    switch_channel_set_name(channel, name);\r
+    switch_channel_set_state(channel, CS_INIT);\r
+\r
+    if (switch_core_session_thread_launch(m_fsSession) != SWITCH_STATUS_SUCCESS) {\r
+        PTRACE(1, "mod_opal\tCould not launch session thread");\r
+        return false;\r
+    }\r
+\r
+    return true;\r
+}\r
+\r
+\r
+void FSConnection::OnReleased()\r
+{\r
+    m_rxAudioOpened.Signal();   // Just in case\r
+    m_txAudioOpened.Signal();\r
+    H225_ReleaseCompleteReason dummy;\r
+    switch_channel_hangup(switch_core_session_get_channel(m_fsSession),\r
+                          (switch_call_cause_t)H323TranslateFromCallEndReason(GetCallEndReason(), dummy));\r
+    OpalLocalConnection::OnReleased();\r
+}\r
+\r
+\r
+void FSConnection::OnAlerting()\r
+{\r
+    switch_channel_mark_ring_ready(m_fsChannel);\r
+    return OpalLocalConnection::OnAlerting();\r
+}\r
+\r
+PBoolean FSConnection::SetAlerting(const PString & calleeName, PBoolean withMedia)\r
+{\r
+    return OpalLocalConnection::SetAlerting(calleeName, withMedia);\r
+}\r
+\r
+\r
+void FSConnection::OnEstablished()\r
+{\r
+    OpalLocalConnection::OnEstablished();\r
+}\r
+\r
+\r
+OpalMediaFormatList FSConnection::GetMediaFormats() const\r
+{\r
+    if (m_switchMediaFormats.IsEmpty()) {\r
+        const_cast<FSConnection *>(this)->SetCodecs();\r
+    }\r
+    \r
+    return m_switchMediaFormats;\r
+}\r
+\r
+\r
+void FSConnection::SetCodecs()\r
+{\r
+    int numCodecs = 0;\r
+    const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];    \r
+       const char *codec_string = NULL, *abs, *ocodec;\r
+    char *tmp_codec_string = NULL;\r
+    char *codec_order[SWITCH_MAX_CODECS];\r
+    int codec_order_last;\r
+\r
+\r
+       if ((abs = switch_channel_get_variable(m_fsChannel, "absolute_codec_string"))) {\r
+               codec_string = abs;\r
+       } else {\r
+               if ((abs = switch_channel_get_variable(m_fsChannel, "codec_string"))) {\r
+            codec_string = abs;\r
+               }\r
+\r
+               if ((ocodec = switch_channel_get_variable(m_fsChannel, SWITCH_ORIGINATOR_CODEC_VARIABLE))) {\r
+            codec_string = switch_core_session_sprintf(m_fsSession, "%s,%s", ocodec, codec_string);\r
+               }\r
+       }\r
+    \r
+    if (!codec_string) {\r
+        codec_string = mod_opal_globals.codec_string;\r
+    }\r
+\r
+       if (codec_string) {\r
+               if ((tmp_codec_string = strdup(codec_string))) {\r
+                       codec_order_last = switch_separate_string(tmp_codec_string, ',', codec_order, SWITCH_MAX_CODECS);\r
+            numCodecs = switch_loadable_module_get_codecs_sorted(codecs, SWITCH_MAX_CODECS, codec_order, codec_order_last);\r
+            \r
+               }\r
+       } else {\r
+               numCodecs = switch_loadable_module_get_codecs(codecs, sizeof(codecs) / sizeof(codecs[0]));\r
+       }\r
+    \r
+    for (int i = 0; i < numCodecs; i++) {\r
+        const switch_codec_implementation_t *codec = codecs[i];\r
+\r
+        // See if we have a match by PayloadType/rate/name\r
+        OpalMediaFormat switchFormat((RTP_DataFrame::PayloadTypes)codec->ianacode,\r
+                                     codec->samples_per_second,\r
+                                     codec->iananame);\r
+        if (!switchFormat.IsValid()) {\r
+            // See if we have a match by name alone\r
+            switchFormat = codec->iananame;\r
+            if (!switchFormat.IsValid()) {\r
+                // Add the new name to OPAL's global lists\r
+                if (m_endpoint.AddMediaFormat(codec)) {\r
+                    // Now we finally have it\r
+                    switchFormat = codec->iananame;\r
+                }\r
+            }\r
+        }\r
+        \r
+\r
+        // Did we match or create a new media format?\r
+        if (switchFormat.IsValid() && codec->codec_type == SWITCH_CODEC_TYPE_AUDIO) {\r
+            PTRACE(2, "mod_opal\tMatched FS codec " << codec->iananame << " to OPAL media format " << switchFormat);\r
+\r
+            // Calculate frames per packet, do not use codec->codec_frames_per_packet as that field\r
+            // has slightly different semantics when used in streamed codecs such as G.711\r
+            int fpp = codec->samples_per_packet/switchFormat.GetFrameTime();\r
+\r
+            /* Set the frames/packet to maximum of what is in the FS table. The OPAL negotiations will\r
+               drop the value from there. This might fail if there are "holes" in the FS table, e.g.\r
+               if for some reason G.723.1 has 30ms and 90ms but not 60ms, then the OPAL negotiations\r
+               could end up with 60ms and the codec cannot be created. The "holes" are unlikely in\r
+               all but streamed codecs such as G.711, where it is theoretically possible for OPAL to\r
+               come up with 32ms and there is only 30ms and 40ms in the FS table. We deem these\r
+               scenarios succifiently rare that we can safely ignore them ... for now. */\r
+\r
+            if (fpp > switchFormat.GetOptionInteger(OpalAudioFormat::RxFramesPerPacketOption())) {\r
+                switchFormat.SetOptionInteger(OpalAudioFormat::RxFramesPerPacketOption(), fpp);\r
+            }\r
+\r
+            if (fpp > switchFormat.GetOptionInteger(OpalAudioFormat::TxFramesPerPacketOption())) {\r
+                switchFormat.SetOptionInteger(OpalAudioFormat::TxFramesPerPacketOption(), fpp);\r
+            }\r
+        }\r
+\r
+        m_switchMediaFormats += switchFormat;\r
+    }\r
+    \r
+    switch_safe_free(tmp_codec_string);\r
+}\r
+\r
+\r
+OpalMediaStream *FSConnection::CreateMediaStream(const OpalMediaFormat & mediaFormat, unsigned sessionID, PBoolean isSource)\r
+{\r
+    return new FSMediaStream(*this, mediaFormat, sessionID, isSource);\r
+}\r
+\r
+\r
+PBoolean FSConnection::OnOpenMediaStream(OpalMediaStream & stream)\r
+{\r
+    if (!OpalConnection::OnOpenMediaStream(stream)) {\r
+        return false;\r
+    }\r
+\r
+    if (stream.GetMediaFormat().GetMediaType() != OpalMediaType::Audio()) {\r
+        return true;\r
+    }\r
+\r
+    if (stream.IsSource()) {\r
+        m_rxAudioOpened.Signal();\r
+    } else {\r
+        m_txAudioOpened.Signal();\r
+    }\r
+\r
+    if (GetMediaStream(stream.GetSessionID(), stream.IsSink()) != NULL) {\r
+        // Have open media in both directions.\r
+        if (GetPhase() == AlertingPhase) {\r
+            switch_channel_mark_pre_answered(m_fsChannel);\r
+        } else if (GetPhase() < ReleasingPhase) {\r
+            switch_channel_mark_answered(m_fsChannel);\r
+        }\r
+    }\r
+\r
+    return true;\r
+}\r
+\r
+\r
+switch_status_t FSConnection::on_init()\r
+{\r
+    switch_channel_t *channel = switch_core_session_get_channel(m_fsSession);\r
+    if (channel == NULL) {\r
+        return SWITCH_STATUS_FALSE;\r
+    }\r
+\r
+    PTRACE(3, "mod_opal\tStarted routing for connection " << *this);\r
+    switch_channel_set_state(channel, CS_ROUTING);\r
+    return SWITCH_STATUS_SUCCESS;\r
+}\r
+\r
+\r
+switch_status_t FSConnection::on_routing()\r
+{\r
+    PTRACE(3, "mod_opal\tRouting connection " << *this);\r
+    return SWITCH_STATUS_SUCCESS;\r
+}\r
+\r
+\r
+switch_status_t FSConnection::on_execute()\r
+{\r
+    PTRACE(3, "mod_opal\tExecuting connection " << *this);\r
+    return SWITCH_STATUS_SUCCESS;\r
+}\r
+\r
+\r
+switch_status_t FSConnection::on_hangup()\r
+{\r
+    switch_channel_t *channel = switch_core_session_get_channel(m_fsSession);\r
+    if (channel == NULL) {\r
+        return SWITCH_STATUS_FALSE;\r
+    }\r
+\r
+    Q931::CauseValues cause = (Q931::CauseValues)switch_channel_get_cause_q850(channel);\r
+    SetQ931Cause(cause);\r
+    ClearCallSynchronous(NULL, H323TranslateToCallEndReason(cause, UINT_MAX));\r
+    return SWITCH_STATUS_SUCCESS;\r
+}\r
+\r
+\r
+switch_status_t FSConnection::on_loopback()\r
+{\r
+    PTRACE(3, "mod_opal\tLoopback on connection " << *this);\r
+    return SWITCH_STATUS_SUCCESS;\r
+}\r
+\r
+\r
+switch_status_t FSConnection::on_transmit()\r
+{\r
+    PTRACE(3, "mod_opal\tTransmit on connection " << *this);\r
+    return SWITCH_STATUS_SUCCESS;\r
+}\r
+\r
+\r
+switch_status_t FSConnection::kill_channel(int sig)\r
+{\r
+    PTRACE(3, "mod_opal\tKill " << sig << " on connection " << *this);\r
+\r
+    switch (sig) {\r
+    case SWITCH_SIG_BREAK:\r
+        break;\r
+    case SWITCH_SIG_KILL:\r
+        m_rxAudioOpened.Signal();\r
+        m_txAudioOpened.Signal();\r
+        break;\r
+    default:\r
+        break;\r
+    }\r
+\r
+    return SWITCH_STATUS_SUCCESS;\r
+}\r
+\r
+\r
+switch_status_t FSConnection::send_dtmf(const switch_dtmf_t *dtmf)\r
+{\r
+    OnUserInputTone(dtmf->digit, dtmf->duration);\r
+    return SWITCH_STATUS_SUCCESS;\r
+}\r
+\r
+\r
+switch_status_t FSConnection::receive_message(switch_core_session_message_t *msg)\r
+{\r
+    switch_core_session_t *session = GetSession();\r
+    switch_channel_t *channel = switch_core_session_get_channel(session);\r
+\r
+\r
+    /*\r
+      SWITCH_MESSAGE_INDICATE_PROGRESS:  establish early media now and return SWITCH_STATUS_FALSE if you can't\r
+      SWITCH_MESSAGE_INDICATE_ANSWER:  answer and set up media now if it's not already and return SWITCH_STATUS_FALSE if you can't\r
+\r
+      Neither message means anything on an outbound call....\r
+\r
+      It would only happen if someone called switch_channel_answer() instead of switch_channel_mark_answered() on an outbound call.\r
+      it should not do anything if someone does it by accident somewhere hense this in both cases:\r
+\r
+      if (switch_channel_test_flag(channel, CF_OUTBOUND)) {\r
+      return SWITCH_STATUS_FALSE;\r
+      }\r
+\r
+\r
+      When we get these messages the core will trust that you have triggered FSMediaStream::Open and are ready for media if we do not\r
+      have media we MUST return SWITCH_STATUS_FALSE or it will cause a CRASH.\r
+\r
+\r
+\r
+    */\r
+    switch (msg->message_id) {\r
+    case SWITCH_MESSAGE_INDICATE_BRIDGE:\r
+    case SWITCH_MESSAGE_INDICATE_UNBRIDGE:\r
+    case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC:\r
+        switch_channel_set_private_flag(channel, CF_NEED_FLUSH);\r
+        break;\r
+    default:\r
+        break;\r
+    }\r
+\r
+    switch (msg->message_id) {\r
+    case SWITCH_MESSAGE_INDICATE_RINGING:\r
+        SetPhase(OpalConnection::AlertingPhase);\r
+        OnAlerting();\r
+        break;\r
+\r
+    case SWITCH_MESSAGE_INDICATE_PROGRESS:\r
+    case SWITCH_MESSAGE_INDICATE_ANSWER:\r
+        {\r
+            int fixed = 0;\r
+            \r
+            if (switch_channel_test_flag(channel, CF_OUTBOUND)) {\r
+                return SWITCH_STATUS_FALSE;\r
+            }\r
+\r
+            if (msg->message_id == SWITCH_MESSAGE_INDICATE_PROGRESS) {\r
+                if (fixed) {\r
+                    /* this should send alerting + media and wait for it to be established and return SUCCESS or FAIL\r
+                       depending on if media was able to be established.  Need code to tell the other side we want early media here.\r
+                    */\r
+                    GetCall().OpenSourceMediaStreams(*this, OpalMediaType::Audio());\r
+                    SetPhase(OpalConnection::AlertingPhase);\r
+                    /* how do i say please establish early media ? */\r
+                    OnAlerting();\r
+                } else {\r
+                    /* hack to avoid getting stuck, pre_answer will imply answer */\r
+                    OnConnectedInternal();\r
+                }\r
+            } else {\r
+                OnConnectedInternal();\r
+            }\r
+\r
+            // Wait for media\r
+            PTRACE(2, "mod_opal\tAwaiting media start on connection " << *this);\r
+            m_rxAudioOpened.Wait();\r
+            m_txAudioOpened.Wait();\r
+            \r
+            if (GetPhase() >= ReleasingPhase) {\r
+                // Call got aborted\r
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Call abandoned!\n");\r
+                return SWITCH_STATUS_FALSE;\r
+            }\r
+\r
+            PTRACE(4, "mod_opal\tMedia started on connection " << *this);\r
+\r
+            if (msg->message_id == SWITCH_MESSAGE_INDICATE_PROGRESS) {\r
+                if (!switch_channel_test_flag(m_fsChannel, CF_EARLY_MEDIA)) {\r
+                    switch_channel_mark_pre_answered(m_fsChannel);\r
+                }\r
+            } else {\r
+                if (!switch_channel_test_flag(m_fsChannel, CF_EARLY_MEDIA)) {\r
+                    switch_channel_mark_answered(m_fsChannel);\r
+                }\r
+            }\r
+\r
+        }\r
+        break;\r
+\r
+    default:\r
+        PTRACE(3, "mod_opal\tReceived message " << msg->message_id << " on connection " << *this);\r
+    }\r
+\r
+    return SWITCH_STATUS_SUCCESS;\r
+}\r
+\r
+\r
+switch_status_t FSConnection::receive_event(switch_event_t *event)\r
+{\r
+    PTRACE(3, "mod_opal\tReceived event " << event->event_id << " on connection " << *this);\r
+    return SWITCH_STATUS_SUCCESS;\r
+}\r
+\r
+\r
+switch_status_t FSConnection::state_change()\r
+{\r
+    PTRACE(3, "mod_opal\tState changed on connection " << *this);\r
+    return SWITCH_STATUS_SUCCESS;\r
+}\r
+\r
+\r
+switch_status_t FSConnection::read_audio_frame(switch_frame_t **frame, switch_io_flag_t flags, int stream_id)\r
+{\r
+    return read_frame(OpalMediaType::Audio(), frame, flags);\r
+}\r
+\r
+\r
+switch_status_t FSConnection::write_audio_frame(switch_frame_t *frame, switch_io_flag_t flags, int stream_id)\r
+{\r
+    return write_frame(OpalMediaType::Audio(), frame, flags);\r
+}\r
+\r
+\r
+switch_status_t FSConnection::read_video_frame(switch_frame_t **frame, switch_io_flag_t flag, int stream_id)\r
+{\r
+    return read_frame(OpalMediaType::Video(), frame, flag);\r
+}\r
+\r
+\r
+switch_status_t FSConnection::write_video_frame(switch_frame_t *frame, switch_io_flag_t flag, int stream_id)\r
+{\r
+    return write_frame(OpalMediaType::Video(), frame, flag);\r
+}\r
+\r
+\r
+switch_status_t FSConnection::read_frame(const OpalMediaType & mediaType, switch_frame_t **frame, switch_io_flag_t flags)\r
+{\r
+    PSafePtr < FSMediaStream > stream = PSafePtrCast < OpalMediaStream, FSMediaStream > (GetMediaStream(mediaType, false));\r
+    return stream != NULL ? stream->read_frame(frame, flags) : SWITCH_STATUS_FALSE;\r
+}\r
+\r
+\r
+switch_status_t FSConnection::write_frame(const OpalMediaType & mediaType, const switch_frame_t *frame, switch_io_flag_t flags)\r
+{\r
+    PSafePtr < FSMediaStream > stream = PSafePtrCast < OpalMediaStream, FSMediaStream > (GetMediaStream(mediaType, true));\r
+    return stream != NULL ? stream->write_frame(frame, flags) : SWITCH_STATUS_FALSE;\r
+}\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////\r
+\r
+FSMediaStream::FSMediaStream(FSConnection & conn, const OpalMediaFormat & mediaFormat, unsigned sessionID, bool isSource)\r
+    : OpalMediaStream(conn, mediaFormat, sessionID, isSource)\r
+    , m_fsSession(conn.GetSession())\r
+    , m_callOnStart(true)\r
+{\r
+    memset(&m_readFrame, 0, sizeof(m_readFrame));\r
+    m_readFrame.codec = &m_switchCodec;\r
+    m_readFrame.flags = SFF_RAW_RTP;\r
+}\r
+\r
+\r
+PBoolean FSMediaStream::Open()\r
+{\r
+    if (IsOpen()) {\r
+        return true;\r
+    }\r
+\r
+    bool isAudio;\r
+    if (mediaFormat.GetMediaType() == OpalMediaType::Audio()) {\r
+        isAudio = true;\r
+    } else if (mediaFormat.GetMediaType() == OpalMediaType::Video()) {\r
+        isAudio = false;\r
+    } else {\r
+        return OpalMediaStream::Open();\r
+    }\r
+\r
+    m_fsChannel = switch_core_session_get_channel(m_fsSession);\r
+    \r
+    int ptime = mediaFormat.GetOptionInteger(OpalAudioFormat::TxFramesPerPacketOption()) * mediaFormat.GetFrameTime() / mediaFormat.GetTimeUnits();\r
+\r
+    // The following is performed on two different instances of this object.\r
+    if (switch_core_codec_init(&m_switchCodec, mediaFormat.GetEncodingName(), NULL, // FMTP\r
+                               mediaFormat.GetClockRate(), ptime, 1,  // Channels\r
+                               SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,   // Settings\r
+                               switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) {\r
+        // Could not select a codecs using negotiated frames/packet, so try using default.\r
+        if (switch_core_codec_init(&m_switchCodec, mediaFormat.GetEncodingName(), NULL, // FMTP\r
+                                   mediaFormat.GetClockRate(), 0, 1,  // Channels\r
+                                   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,   // Settings\r
+                                   switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) {\r
+            PTRACE(1, "mod_opal  " << switch_channel_get_name(m_fsChannel)<< " Cannot initialise " << (IsSink()? "read" : "write") << ' '\r
+                   << mediaFormat.GetMediaType() << " codec " << mediaFormat << " for connection " << *this);\r
+            switch_channel_hangup(m_fsChannel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);\r
+            return false;\r
+        }\r
+        PTRACE(2, "mod_opal " << switch_channel_get_name(m_fsChannel)<< " Unsupported ptime of " << ptime << " on " << (IsSink()? "read" : "write") << ' '\r
+               << mediaFormat.GetMediaType() << " codec " << mediaFormat << " for connection " << *this);\r
+    }\r
+\r
+    PTRACE(1, "mod_opal " << switch_channel_get_name(m_fsChannel)<< " initialise " << \r
+           switch_channel_get_name(m_fsChannel) << (IsSink()? "read" : "write") << ' '\r
+           << mediaFormat.GetMediaType() << " codec " << mediaFormat << " for connection " << *this);\r
+\r
+    if (IsSink()) {\r
+        m_readFrame.rate = mediaFormat.GetClockRate();\r
+\r
+        if (isAudio) {\r
+            switch_core_session_set_read_codec(m_fsSession, &m_switchCodec);\r
+            if (switch_core_timer_init(&m_switchTimer,\r
+                                       "soft",\r
+                                       m_switchCodec.implementation->microseconds_per_packet / 1000,\r
+                                       m_switchCodec.implementation->samples_per_packet,\r
+                                       switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) {\r
+                switch_core_codec_destroy(&m_switchCodec);\r
+                return false;\r
+            }\r
+        } else {\r
+            switch_core_session_set_video_read_codec(m_fsSession, &m_switchCodec);\r
+            switch_channel_set_flag(m_fsChannel, CF_VIDEO);\r
+        }\r
+    } else {\r
+        if (isAudio) {\r
+            switch_core_session_set_write_codec(m_fsSession, &m_switchCodec);\r
+        } else {\r
+            switch_core_session_set_video_write_codec(m_fsSession, &m_switchCodec);\r
+            switch_channel_set_flag(m_fsChannel, CF_VIDEO);\r
+        }\r
+    }\r
+\r
+    PTRACE(3, "mod_opal\tSet " << (IsSink()? "read" : "write") << ' '\r
+           << mediaFormat.GetMediaType() << " codec to << " << mediaFormat << " for connection " << *this);\r
+\r
+    return OpalMediaStream::Open();\r
+}\r
+\r
+\r
+PBoolean FSMediaStream::Close()\r
+{\r
+    if (!IsOpen())\r
+        return false;\r
+\r
+    bool isAudio;\r
+\r
+    if (mediaFormat.GetMediaType() == OpalMediaType::Audio()) {\r
+        isAudio = true;\r
+    } else if (mediaFormat.GetMediaType() == OpalMediaType::Video()) {\r
+        isAudio = false;\r
+    } else {\r
+        return OpalMediaStream::Close();\r
+    }\r
+\r
+    if (IsSink()) {\r
+        if (isAudio) {\r
+            switch_core_session_unset_read_codec(m_fsSession);\r
+            switch_core_timer_destroy(&m_switchTimer);\r
+        } else {\r
+            switch_core_session_set_video_read_codec(m_fsSession, NULL);\r
+        }\r
+\r
+        switch_core_codec_destroy(&m_switchCodec);\r
+    } else {\r
+        if (isAudio)\r
+            switch_core_session_unset_write_codec(m_fsSession);\r
+        else\r
+            switch_core_session_set_video_write_codec(m_fsSession, NULL);\r
+        switch_core_codec_destroy(&m_switchCodec);\r
+    }\r
+\r
+    PTRACE(3, "mod_opal\tReset & destroyed " << (IsSink()? "read" : "write")\r
+           << ' ' << mediaFormat.GetMediaType() << " codec for connection " << *this);\r
+\r
+    return OpalMediaStream::Close();\r
+}\r
+\r
+\r
+PBoolean FSMediaStream::IsSynchronous() const\r
+{\r
+    return true;\r
+}\r
+\r
+\r
+PBoolean FSMediaStream::RequiresPatchThread(OpalMediaStream *) const\r
+{\r
+    return false;\r
+}\r
+\r
+\r
+switch_status_t FSMediaStream::read_frame(switch_frame_t **frame, switch_io_flag_t flags)\r
+{\r
+    if (m_callOnStart) {\r
+        /*\r
+          There is a race here... sometimes we make it here and GetPatch() is NULL\r
+          if we wait it shows up in 1ms, maybe there is a better way to wait.\r
+          \r
+        */\r
+        while(!GetPatch()) {\r
+            switch_cond_next();\r
+        }\r
+        GetPatch()->OnPatchStart();\r
+        m_callOnStart = false;\r
+    }\r
+\r
+    m_readFrame.flags = 0;\r
+\r
+    /*\r
+    while (switch_channel_ready(m_fsChannel)) {\r
+        if (!GetPatch()->GetSource().ReadPacket(m_readRTP)) {\r
+            return SWITCH_STATUS_FALSE;\r
+        }\r
+        \r
+        if ((m_readFrame.datalen = m_readRTP.GetPayloadSize()) || switch_core_timer_check(&m_switchTimer, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {\r
+            if (m_readFrame.datalen) {\r
+            } else {\r
+                m_readFrame.flags = SFF_CNG;\r
+            }\r
+            break;\r
+        }\r
+\r
+        switch_yield(1000);\r
+    }\r
+    */\r
+\r
+    if (switch_channel_test_private_flag(m_fsChannel, CF_NEED_FLUSH)) {\r
+        switch_channel_clear_private_flag(m_fsChannel, CF_NEED_FLUSH);\r
+        for(;;) {\r
+            if (!GetPatch()->GetSource().ReadPacket(m_readRTP)) {\r
+                return SWITCH_STATUS_FALSE;\r
+            }\r
+            if (!m_readRTP.GetPayloadSize()) {\r
+                m_readFrame.flags = SFF_CNG;\r
+                break;\r
+            }\r
+        }\r
+    } else {\r
+\r
+        if (!GetPatch()->GetSource().ReadPacket(m_readRTP)) {\r
+            return SWITCH_STATUS_FALSE;\r
+        }\r
+    \r
+        switch_core_timer_next(&m_switchTimer);\r
+    \r
+        if (!(m_readFrame.datalen = m_readRTP.GetPayloadSize())) {\r
+            m_readFrame.flags = SFF_CNG;\r
+        }\r
+    }\r
+\r
+    if (!switch_channel_ready(m_fsChannel)) {\r
+        return SWITCH_STATUS_FALSE;\r
+    }\r
+\r
+    //switch_core_timer_step(&m_switchTimer);\r
+\r
+    m_readFrame.buflen = m_readRTP.GetSize();\r
+    m_readFrame.data = m_readRTP.GetPayloadPtr();\r
+    m_readFrame.packet = m_readRTP.GetPointer();\r
+    m_readFrame.packetlen = m_readRTP.GetHeaderSize() + m_readFrame.datalen;\r
+    m_readFrame.payload = (switch_payload_t) m_readRTP.GetPayloadType();\r
+    m_readFrame.timestamp = m_readRTP.GetTimestamp();\r
+    m_readFrame.m = (switch_bool_t) m_readRTP.GetMarker();\r
+    m_readFrame.seq = m_readRTP.GetSequenceNumber();\r
+    m_readFrame.ssrc = m_readRTP.GetSyncSource();\r
+    *frame = &m_readFrame;\r
+\r
+    return SWITCH_STATUS_SUCCESS;\r
+}\r
+\r
+\r
+switch_status_t FSMediaStream::write_frame(const switch_frame_t *frame, switch_io_flag_t flags)\r
+{\r
+    if (!switch_channel_ready(m_fsChannel)) {\r
+        return SWITCH_STATUS_FALSE;\r
+    }\r
+\r
+    if (m_callOnStart) {\r
+        GetPatch()->OnPatchStart();\r
+        m_callOnStart = false;\r
+    }\r
+\r
+    if ((frame->flags & SFF_RAW_RTP) != 0) {\r
+        RTP_DataFrame rtp((const BYTE *) frame->packet, frame->packetlen, false);\r
+        if (GetPatch()->PushFrame(rtp))\r
+            return SWITCH_STATUS_SUCCESS;\r
+    } else if (frame->flags == 0) {\r
+        RTP_DataFrame rtp;\r
+        rtp.SetPayloadType(mediaFormat.GetPayloadType());\r
+        rtp.SetPayloadSize(frame->datalen);\r
+        memcpy(rtp.GetPayloadPtr(), frame->data, frame->datalen);\r
+        if (GetPatch()->PushFrame(rtp))\r
+            return SWITCH_STATUS_SUCCESS;\r
+    }\r
+\r
+    return SWITCH_STATUS_FALSE;\r
+}\r
+\r
+\r
+/* For Emacs:\r
+ * Local Variables:\r
+ * mode:c\r
+ * indent-tabs-mode:nil\r
+ * tab-width:4\r
+ * c-basic-offset:4\r
+ * End:\r
+ * For VIM:\r
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4: expandtabs:\r
+ */\r
diff --git a/src/mod/endpoints/mod_opal/mod_opal.h b/src/mod/endpoints/mod_opal/mod_opal.h
new file mode 100644 (file)
index 0000000..5b16bb3
--- /dev/null
@@ -0,0 +1,233 @@
+/* Opal endpoint interface for Freeswitch Modular Media Switching Software Library /
+ * Soft-Switch Application
+ *
+ * Version: MPL 1.1
+ *
+ * Copyright (c) 2007 Tuyan Ozipek (tuyanozipek@gmail.com)
+ *
+ * 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.
+ *
+ * Contributor(s):
+ * Tuyan Ozipek   (tuyanozipek@gmail.com)
+ * Lukasz Zwierko (lzwierko@gmail.com)
+ * Robert Jongbloed (robertj@voxlucida.com.au)
+ *
+ */
+
+
+#ifndef __FREESWITCH_MOD_OPAL__
+#define __FREESWITCH_MOD_OPAL__
+
+#define HAVE_APR
+#include <switch.h>
+#include <switch_version.h>
+#define MODNAME "mod_opal"
+
+#undef strcasecmp
+#undef strncasecmp
+
+#include <ptlib.h>
+#include <opal/manager.h>
+#include <opal/localep.h>
+#include <h323/h323ep.h>
+#include <iax2/iax2ep.h>
+
+
+class FSEndPoint;
+class FSManager;
+
+
+struct mod_opal_globals {
+    int trace_level;
+    char *codec_string;
+    char *context;
+    char *dialplan;
+};
+
+extern struct mod_opal_globals mod_opal_globals;
+
+
+class FSProcess : public PLibraryProcess {
+    PCLASSINFO(FSProcess, PLibraryProcess);
+
+ public:
+    FSProcess();
+    ~FSProcess();
+
+    bool Initialise(switch_loadable_module_interface_t *iface);
+
+    FSManager & GetManager() const { return *m_manager; }
+
+  protected:
+    FSManager * m_manager;
+};
+
+
+struct FSListener {
+    FSListener() {
+    }
+
+    PString name;
+    OpalTransportAddress listenAddress;
+    PString localUserName;
+    PString gatekeeper;
+};
+
+
+class FSManager : public OpalManager {
+    PCLASSINFO(FSManager, OpalManager);
+
+ public:
+    FSManager();
+
+    bool Initialise(switch_loadable_module_interface_t *iface);
+
+    switch_status_t ReadConfig(int reload);
+
+    switch_endpoint_interface_t *GetSwitchInterface() const {
+        return m_FreeSwitch;
+    }
+
+  private:
+    switch_endpoint_interface_t *m_FreeSwitch;
+
+    H323EndPoint *m_h323ep;
+    IAX2EndPoint *m_iaxep;
+    FSEndPoint *m_fsep;
+
+    list < FSListener > m_listeners;
+};
+
+
+class FSEndPoint:public OpalLocalEndPoint {
+    PCLASSINFO(FSEndPoint, OpalLocalEndPoint);
+ public:
+    FSEndPoint(FSManager & manager);
+
+    virtual bool OnIncomingCall(OpalLocalConnection &);
+    virtual OpalLocalConnection *CreateConnection(OpalCall &, void *);
+
+    bool AddMediaFormat(const switch_codec_implementation_t *codec);
+
+  private:
+    PList<OpalMediaFormat> m_globalMediaFormats;
+};
+
+
+#define DECLARE_CALLBACK0(name)                                         \
+    static switch_status_t name(switch_core_session_t *session) {       \
+        FSConnection * conn = (FSConnection *)switch_core_session_get_private(session); \
+        return conn != NULL ? conn->name() : SWITCH_STATUS_FALSE; }     \
+switch_status_t name()
+
+#define DECLARE_CALLBACK1(name, type1, name1)                           \
+    static switch_status_t name(switch_core_session_t *session, type1 name1) { \
+        FSConnection * conn = (FSConnection *)switch_core_session_get_private(session); \
+        return conn != NULL ? conn->name(name1) : SWITCH_STATUS_FALSE; } \
+    switch_status_t name(type1 name1)
+
+#define DECLARE_CALLBACK3(name, type1, name1, type2, name2, type3, name3) \
+    static switch_status_t name(switch_core_session_t *session, type1 name1, type2 name2, type3 name3) { \
+        FSConnection * conn = (FSConnection *)switch_core_session_get_private(session); \
+        return conn != NULL ? conn->name(name1, name2, name3) : SWITCH_STATUS_FALSE; } \
+    switch_status_t name(type1 name1, type2 name2, type3 name3)
+
+
+class FSConnection:public OpalLocalConnection {
+    PCLASSINFO(FSConnection, OpalLocalConnection)
+
+  public:
+    FSConnection(OpalCall & call, FSEndPoint & endpoint);
+
+    virtual bool OnIncoming();
+    virtual void OnReleased();
+    virtual PBoolean SetAlerting(const PString & calleeName, PBoolean withMedia);
+    virtual void OnAlerting();
+    virtual void OnEstablished();
+    virtual OpalMediaStream *CreateMediaStream(const OpalMediaFormat &, unsigned, PBoolean);
+    virtual PBoolean OnOpenMediaStream(OpalMediaStream & stream);
+    virtual OpalMediaFormatList GetMediaFormats() const;
+
+    void SetCodecs();
+
+    DECLARE_CALLBACK0(on_init);
+    DECLARE_CALLBACK0(on_routing);
+    DECLARE_CALLBACK0(on_execute);
+    DECLARE_CALLBACK0(on_hangup);
+    DECLARE_CALLBACK0(on_loopback);
+    DECLARE_CALLBACK0(on_transmit);
+
+    DECLARE_CALLBACK1(kill_channel, int, sig);
+    DECLARE_CALLBACK1(send_dtmf, const switch_dtmf_t *, dtmf);
+    DECLARE_CALLBACK1(receive_message, switch_core_session_message_t *, msg);
+    DECLARE_CALLBACK1(receive_event, switch_event_t *, event);
+    DECLARE_CALLBACK0(state_change);
+    DECLARE_CALLBACK3(read_audio_frame, switch_frame_t **, frame, switch_io_flag_t, flags, int, stream_id);
+    DECLARE_CALLBACK3(write_audio_frame, switch_frame_t *, frame, switch_io_flag_t, flags, int, stream_id);
+    DECLARE_CALLBACK3(read_video_frame, switch_frame_t **, frame, switch_io_flag_t, flag, int, stream_id);
+    DECLARE_CALLBACK3(write_video_frame, switch_frame_t *, frame, switch_io_flag_t, flag, int, stream_id);
+
+    switch_status_t read_frame(const OpalMediaType & mediaType, switch_frame_t **frame, switch_io_flag_t flags);
+    switch_status_t write_frame(const OpalMediaType & mediaType, const switch_frame_t *frame, switch_io_flag_t flags);
+
+    switch_core_session_t *GetSession() const {
+        return m_fsSession;
+    }
+
+  private:
+    FSEndPoint & m_endpoint;
+    switch_core_session_t *m_fsSession;
+    switch_channel_t *m_fsChannel;
+    PSyncPoint m_rxAudioOpened;
+    PSyncPoint m_txAudioOpened;
+    OpalMediaFormatList m_switchMediaFormats;
+};
+
+
+class FSMediaStream:public OpalMediaStream {
+    PCLASSINFO(FSMediaStream, OpalMediaStream);
+ public:
+    FSMediaStream(FSConnection & conn, const OpalMediaFormat & mediaFormat, ///<  Media format for stream
+                  unsigned sessionID,   ///<  Session number for stream
+                  bool isSource ///<  Is a source stream
+                  );
+
+    virtual PBoolean Open();
+    virtual PBoolean Close();
+    virtual PBoolean IsSynchronous() const;
+    virtual PBoolean RequiresPatchThread(OpalMediaStream *) const;
+
+    switch_status_t read_frame(switch_frame_t **frame, switch_io_flag_t flags);
+    switch_status_t write_frame(const switch_frame_t *frame, switch_io_flag_t flags);
+
+ private:
+    switch_core_session_t *m_fsSession;
+    switch_channel_t *m_fsChannel;
+    switch_timer_t m_switchTimer;
+    switch_codec_t m_switchCodec;
+    switch_frame_t m_readFrame;
+    RTP_DataFrame m_readRTP;
+    bool m_callOnStart;
+};
+
+
+#endif /* __FREESWITCH_MOD_OPAL__ */
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:nil
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4: expandtabs:
+ */
diff --git a/src/mod/endpoints/mod_opal/mod_opal_2005.vcproj b/src/mod/endpoints/mod_opal/mod_opal_2005.vcproj
new file mode 100644 (file)
index 0000000..86e8be7
--- /dev/null
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="8.00"
+       Name="mod_opal"
+       ProjectGUID="{426B1369-FDB7-4B18-A7EF-9C6A9097A130}"
+       Keyword="Win32Proj"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="2"
+                       InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               PreprocessorDefinitions="_DEBUG;PTRACING"
+                               BasicRuntimeChecks="0"
+                               UsePrecompiledHeader="0"
+                               ProgramDataBaseFileName="$(TargetDir)$(TargetName).pdb"
+                               DebugInformationFormat="4"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="opalsd.lib ptlibsd.lib"
+                               LinkIncremental="2"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       ConfigurationType="2"
+                       InheritedPropertySheets="..\..\..\..\w32\module_release.vsprops"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               PreprocessorDefinitions="NDEBUG;PTRACING"
+                               UsePrecompiledHeader="0"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="opals.lib ptlibs.lib"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+               <ProjectReference
+                       ReferencedProjectIdentifier="{202D7A4E-760D-4D0E-AFA1-D7459CED30FF}"
+                       RelativePathToProject=".\w32\Library\FreeSwitchCore.vcproj"
+               />
+       </References>
+       <Files>
+               <File
+                       RelativePath=".\mod_opal.cpp"
+                       >
+               </File>
+               <File
+                       RelativePath=".\mod_opal.h"
+                       >
+               </File>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/src/mod/endpoints/mod_opal/mod_opal_2008.vcproj b/src/mod/endpoints/mod_opal/mod_opal_2008.vcproj
new file mode 100644 (file)
index 0000000..ad3669b
--- /dev/null
@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="9.00"
+       Name="mod_opal"
+       ProjectGUID="{05C9FB27-480E-4D53-B3B7-6338E2526666}"
+       Keyword="Win32Proj"
+       TargetFrameworkVersion="131072"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       ConfigurationType="2"
+                       InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories=""
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;ALLOW_SMP_DANGERS"
+                               UsePrecompiledHeader="0"
+                               DisableSpecificWarnings="4100;4101"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalOptions="/NODEFAULTLIB:LIMBCTD"
+                               AdditionalDependencies="opalsd.lib ptlibsd.lib"
+                               AdditionalLibraryDirectories=""
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       ConfigurationType="2"
+                       InheritedPropertySheets="..\..\..\..\w32\module_release.vsprops"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories=""
+                               PreprocessorDefinitions=""
+                               UsePrecompiledHeader="0"
+                               DisableSpecificWarnings="4100;4101"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies=""
+                               AdditionalLibraryDirectories=""
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <File
+                       RelativePath=".\mod_opal.cpp"
+                       >
+               </File>
+               <File
+                       RelativePath=".\mod_opal.h"
+                       >
+               </File>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/src/mod/endpoints/mod_opal/opal.conf.xml b/src/mod/endpoints/mod_opal/opal.conf.xml
new file mode 100644 (file)
index 0000000..c084421
--- /dev/null
@@ -0,0 +1,15 @@
+<configuration name="opal.conf" description="Opal Endpoints">
+  <settings>
+    <param name="trace-level" value="4"/>
+    <param name="context" value="default"/>
+    <param name="dialplan" value="XML"/>
+    <param name="codec-prefs" value="PCMU"/>
+  </settings>
+  <listeners>
+    <listener name="default">
+      <param name="h323-ip" value="$${local_ip_v4}"/>
+      <param name="h323-port" value="1720"/>
+    </listener>
+  </listeners>
+</configuration>
+