<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][17516] </title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=17516">17516</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2010-05-10 13:07:34 -0500 (Mon, 10 May 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>add bind method to EventConsumer takes same args as constructor to bind more events to an existing consumer</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcincludeswitch_cpph">freeswitch/trunk/src/include/switch_cpp.h</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_javasrcorgfreeswitchswigAPIjava">freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/API.java</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_javasrcorgfreeswitchswigCoreSessionjava">freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_javasrcorgfreeswitchswigDTMFjava">freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/DTMF.java</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_javasrcorgfreeswitchswigEventjava">freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/Event.java</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_javasrcorgfreeswitchswigEventConsumerjava">freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/EventConsumer.java</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_javasrcorgfreeswitchswigfreeswitchJNIjava">freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_javaswitch_swig_wrapcpp">freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_luamod_lua_wrapcpp">freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_managedfreeswitch_wrapcxx">freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_managedmanagedswigcs">freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_perlfreeswitchpm">freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_perlmod_perl_wrapcpp">freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_pythonfreeswitchpy">freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_pythonmod_python_wrapcpp">freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp</a></li>
<li><a href="#freeswitchtrunksrcswitch_cppcpp">freeswitch/trunk/src/switch_cpp.cpp</a></li>
<li><a href="#freeswitchtrunksrcswitch_eventc">freeswitch/trunk/src/switch_event.c</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#freeswitchtrunkbuildstrippl">freeswitch/trunk/build/strip.pl</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_typeshorig">freeswitch/trunk/src/include/switch_types.h.orig</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_conferencemod_conferencecorig">freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c.orig</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_conferencemod_conferencecrej">freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c.rej</a></li>
<li><a href="#freeswitchtrunksrcmodformatsmod_sndfilemod_sndfilecorig">freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c.orig</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_pythonmod_python_wrapcpprej">freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp.rej</a></li>
<li><a href="#freeswitchtrunksrcswitch_corecorig">freeswitch/trunk/src/switch_core.c.orig</a></li>
<li><a href="#freeswitchtrunksrcswitch_timecorig">freeswitch/trunk/src/switch_time.c.orig</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunkbuildstrippl"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/build/strip.pl (0 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/build/strip.pl                                (rev 0)
+++ freeswitch/trunk/build/strip.pl        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+#!/usr/bin/perl
+while(&lt;&gt;) {
+  s/SWITCH_DECLARE_CONSTRUCTOR//g;
+  s/SWITCH_DECLARE[^\(]*\((.*?)\)/$1/g;
+  print;
+}
</ins><span class="cx">Property changes on: freeswitch/trunk/build/strip.pl
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:executable
</span><span class="cx">   + on
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_cpph"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_cpp.h (17515 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_cpp.h        2010-05-10 17:03:22 UTC (rev 17515)
+++ freeswitch/trunk/src/include/switch_cpp.h        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -170,12 +170,12 @@
</span><span class="cx">          public:
</span><span class="cx">                  switch_queue_t *events;
</span><span class="cx">                  switch_event_types_t e_event_id;
</span><del>-                 switch_event_node_t *node;
</del><span class="cx">                  char *e_callback;
</span><span class="cx">                  char *e_subclass_name;
</span><span class="cx">                  char *e_cb_arg;
</span><del>-                 SWITCH_DECLARE_CONSTRUCTOR EventConsumer(const char *event_name, const char *subclass_name = &quot;&quot;);
</del><ins>+                 SWITCH_DECLARE_CONSTRUCTOR EventConsumer(const char *event_name = NULL, const char *subclass_name = &quot;&quot;);
</ins><span class="cx">                  SWITCH_DECLARE_CONSTRUCTOR ~ EventConsumer();
</span><ins>+                 SWITCH_DECLARE(int) bind(const char *event_name, const char *subclass_name = &quot;&quot;);
</ins><span class="cx">                  SWITCH_DECLARE(Event *) pop(int block = 0);
</span><span class="cx">          };
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_typeshorig"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/src/include/switch_types.h.orig (0 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_types.h.orig                                (rev 0)
+++ freeswitch/trunk/src/include/switch_types.h.orig        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -0,0 +1,1714 @@
</span><ins>+/* 
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the &quot;License&quot;); 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 &quot;AS IS&quot; 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 &lt;anthm@freeswitch.org&gt;
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * 
+ * Anthony Minessale II &lt;anthm@freeswitch.org&gt;
+ * Bret McDanel &lt;trixter AT 0xdecafbad dot com&gt;
+ *
+ * switch_types.h -- Data Types
+ *
+ */
+/*! \file switch_types.h
+    \brief Data Types
+*/
+#ifndef SWITCH_TYPES_H
+#define SWITCH_TYPES_H
+
+#include &lt;switch.h&gt;
+SWITCH_BEGIN_EXTERN_C
+#define SWITCH_ENT_ORIGINATE_DELIM &quot;:_:&quot;
+#define SWITCH_BLANK_STRING &quot;&quot;
+#define SWITCH_TON_UNDEF 255
+#define SWITCH_NUMPLAN_UNDEF 255
+#ifdef WIN32
+#define SWITCH_SEQ_FWHITE FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY
+#define SWITCH_SEQ_FRED FOREGROUND_RED | FOREGROUND_INTENSITY
+#define SWITCH_SEQ_FMAGEN FOREGROUND_BLUE | FOREGROUND_RED
+#define SWITCH_SEQ_FCYAN FOREGROUND_GREEN | FOREGROUND_BLUE
+#define SWITCH_SEQ_FGREEN FOREGROUND_GREEN
+#define SWITCH_SEQ_FYELLOW FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY
+#define SWITCH_SEQ_DEFAULT_COLOR SWITCH_SEQ_FWHITE
+#else
+#define SWITCH_SEQ_ESC &quot;\033[&quot;
+/* Ansi Control character suffixes */
+#define SWITCH_SEQ_HOME_CHAR 'H'
+#define SWITCH_SEQ_HOME_CHAR_STR &quot;H&quot;
+#define SWITCH_SEQ_CLEARLINE_CHAR '1'
+#define SWITCH_SEQ_CLEARLINE_CHAR_STR &quot;1&quot;
+#define SWITCH_SEQ_CLEARLINEEND_CHAR &quot;K&quot;
+#define SWITCH_SEQ_CLEARSCR_CHAR0 '2'
+#define SWITCH_SEQ_CLEARSCR_CHAR1 'J'
+#define SWITCH_SEQ_CLEARSCR_CHAR &quot;2J&quot;
+#define SWITCH_SEQ_DEFAULT_COLOR SWITCH_SEQ_ESC SWITCH_SEQ_END_COLOR        /* Reset to Default fg/bg color */
+#define SWITCH_SEQ_AND_COLOR &quot;;&quot;        /* To add multiple color definitions */
+#define SWITCH_SEQ_END_COLOR &quot;m&quot;        /* To end color definitions */
+/* Foreground colors values */
+#define SWITCH_SEQ_F_BLACK &quot;30&quot;
+#define SWITCH_SEQ_F_RED &quot;31&quot;
+#define SWITCH_SEQ_F_GREEN &quot;32&quot;
+#define SWITCH_SEQ_F_YELLOW &quot;33&quot;
+#define SWITCH_SEQ_F_BLUE &quot;34&quot;
+#define SWITCH_SEQ_F_MAGEN &quot;35&quot;
+#define SWITCH_SEQ_F_CYAN &quot;36&quot;
+#define SWITCH_SEQ_F_WHITE &quot;37&quot;
+/* Background colors values */
+#define SWITCH_SEQ_B_BLACK &quot;40&quot;
+#define SWITCH_SEQ_B_RED &quot;41&quot;
+#define SWITCH_SEQ_B_GREEN &quot;42&quot;
+#define SWITCH_SEQ_B_YELLOW &quot;43&quot;
+#define SWITCH_SEQ_B_BLUE &quot;44&quot;
+#define SWITCH_SEQ_B_MAGEN &quot;45&quot;
+#define SWITCH_SEQ_B_CYAN &quot;46&quot;
+#define SWITCH_SEQ_B_WHITE &quot;47&quot;
+/* Preset escape sequences - Change foreground colors only */
+#define SWITCH_SEQ_FBLACK SWITCH_SEQ_ESC SWITCH_SEQ_F_BLACK SWITCH_SEQ_END_COLOR
+#define SWITCH_SEQ_FRED SWITCH_SEQ_ESC SWITCH_SEQ_F_RED SWITCH_SEQ_END_COLOR
+#define SWITCH_SEQ_FGREEN SWITCH_SEQ_ESC SWITCH_SEQ_F_GREEN SWITCH_SEQ_END_COLOR
+#define SWITCH_SEQ_FYELLOW SWITCH_SEQ_ESC SWITCH_SEQ_F_YELLOW SWITCH_SEQ_END_COLOR
+#define SWITCH_SEQ_FBLUE SWITCH_SEQ_ESC SWITCH_SEQ_F_BLUE SWITCH_SEQ_END_COLOR
+#define SWITCH_SEQ_FMAGEN SWITCH_SEQ_ESC SWITCH_SEQ_F_MAGEN SWITCH_SEQ_END_COLOR
+#define SWITCH_SEQ_FCYAN SWITCH_SEQ_ESC SWITCH_SEQ_F_CYAN SWITCH_SEQ_END_COLOR
+#define SWITCH_SEQ_FWHITE SWITCH_SEQ_ESC SWITCH_SEQ_F_WHITE SWITCH_SEQ_END_COLOR
+#define SWITCH_SEQ_BBLACK SWITCH_SEQ_ESC SWITCH_SEQ_B_BLACK SWITCH_SEQ_END_COLOR
+#define SWITCH_SEQ_BRED SWITCH_SEQ_ESC SWITCH_SEQ_B_RED SWITCH_SEQ_END_COLOR
+#define SWITCH_SEQ_BGREEN SWITCH_SEQ_ESC SWITCH_SEQ_B_GREEN SWITCH_SEQ_END_COLOR
+#define SWITCH_SEQ_BYELLOW SWITCH_SEQ_ESC SWITCH_SEQ_B_YELLOW SWITCH_SEQ_END_COLOR
+#define SWITCH_SEQ_BBLUE SWITCH_SEQ_ESC SWITCH_SEQ_B_BLUE SWITCH_SEQ_END_COLOR
+#define SWITCH_SEQ_BMAGEN SWITCH_SEQ_ESC SWITCH_SEQ_B_MAGEN SWITCH_SEQ_END_COLOR
+#define SWITCH_SEQ_BCYAN SWITCH_SEQ_ESC SWITCH_SEQ_B_CYAN SWITCH_SEQ_END_COLOR
+#define SWITCH_SEQ_BWHITE SWITCH_SEQ_ESC SWITCH_SEQ_B_WHITE SWITCH_SEQ_END_COLOR
+/* Preset escape sequences */
+#define SWITCH_SEQ_HOME SWITCH_SEQ_ESC SWITCH_SEQ_HOME_CHAR_STR
+#define SWITCH_SEQ_CLEARLINE SWITCH_SEQ_ESC SWITCH_SEQ_CLEARLINE_CHAR_STR
+#define SWITCH_SEQ_CLEARLINEEND SWITCH_SEQ_ESC SWITCH_SEQ_CLEARLINEEND_CHAR
+#define SWITCH_SEQ_CLEARSCR SWITCH_SEQ_ESC SWITCH_SEQ_CLEARSCR_CHAR SWITCH_SEQ_HOME
+#endif
+#define SWITCH_DEFAULT_CLID_NAME &quot;&quot;
+#define SWITCH_DEFAULT_DTMF_DURATION 2000
+#define SWITCH_MIN_DTMF_DURATION 400
+#define SWITCH_MAX_DTMF_DURATION 192000
+#define SWITCH_DEFAULT_DIR_PERMS SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE | SWITCH_FPROT_UEXECUTE | SWITCH_FPROT_GREAD | SWITCH_FPROT_GEXECUTE
+#ifdef WIN32
+#define SWITCH_PATH_SEPARATOR &quot;\\&quot;
+#else
+#define SWITCH_PATH_SEPARATOR &quot;/&quot;
+#endif
+#define SWITCH_URL_SEPARATOR &quot;://&quot;
+#define SWITCH_IGNORE_DISPLAY_UPDATES_VARIABLE &quot;ignore_display_updates&quot;
+#define SWITCH_AUDIO_SPOOL_PATH_VARIABLE &quot;audio_spool_path&quot;
+#define SWITCH_BRIDGE_HANGUP_CAUSE_VARIABLE &quot;bridge_hangup_cause&quot;
+#define SWITCH_READ_TERMINATOR_USED_VARIABLE &quot;read_terminator_used&quot;
+#define SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE &quot;send_silence_when_idle&quot;
+#define SWITCH_CURRENT_APPLICATION_VARIABLE &quot;current_application&quot;
+#define SWITCH_CURRENT_APPLICATION_DATA_VARIABLE &quot;current_application_data&quot;
+#define SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE &quot;current_application_response&quot;
+#define SWITCH_ENABLE_HEARTBEAT_EVENTS_VARIABLE &quot;enable_heartbeat_events&quot;
+#define SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE &quot;bypass_media_after_bridge&quot;
+#define SWITCH_READ_RESULT_VARIABLE &quot;read_result&quot;
+#define SWITCH_COPY_XML_CDR_VARIABLE &quot;copy_xml_cdr&quot;
+#define SWITCH_CURRENT_APPLICATION_VARIABLE &quot;current_application&quot;
+#define SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE &quot;proto_specific_hangup_cause&quot;
+#define SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE &quot;execute_on_answer&quot;
+#define SWITCH_CHANNEL_EXECUTE_ON_PRE_ANSWER_VARIABLE &quot;execute_on_pre_answer&quot;
+#define SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE &quot;execute_on_media&quot;
+#define SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE &quot;api_on_answer&quot;
+#define SWITCH_CHANNEL_EXECUTE_ON_RING_VARIABLE &quot;execute_on_ring&quot;
+#define SWITCH_CALL_TIMEOUT_VARIABLE &quot;call_timeout&quot;
+#define SWITCH_HOLDING_UUID_VARIABLE &quot;holding_uuid&quot;
+#define SWITCH_SOFT_HOLDING_UUID_VARIABLE &quot;soft_holding_uuid&quot;
+#define SWITCH_API_BRIDGE_END_VARIABLE &quot;api_after_bridge&quot;
+#define SWITCH_API_HANGUP_HOOK_VARIABLE &quot;api_hangup_hook&quot;
+#define SWITCH_SESSION_IN_HANGUP_HOOK_VARIABLE &quot;session_in_hangup_hook&quot;
+#define SWITCH_PROCESS_CDR_VARIABLE &quot;process_cdr&quot;
+#define SWITCH_BRIDGE_CHANNEL_VARIABLE &quot;bridge_channel&quot;
+#define SWITCH_CHANNEL_NAME_VARIABLE &quot;channel_name&quot;
+#define SWITCH_BRIDGE_UUID_VARIABLE &quot;bridge_uuid&quot;
+#define SWITCH_CONTINUE_ON_FAILURE_VARIABLE &quot;continue_on_fail&quot;
+#define SWITCH_PLAYBACK_TERMINATORS_VARIABLE &quot;playback_terminators&quot;
+#define SWITCH_PLAYBACK_TERMINATOR_USED &quot;playback_terminator_used&quot;
+#define SWITCH_CACHE_SPEECH_HANDLES_VARIABLE &quot;cache_speech_handles&quot;
+#define SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME &quot;__cache_speech_handles_obj__&quot;
+#define SWITCH_BYPASS_MEDIA_VARIABLE &quot;bypass_media&quot;
+#define SWITCH_PROXY_MEDIA_VARIABLE &quot;proxy_media&quot;
+#define SWITCH_ENDPOINT_DISPOSITION_VARIABLE &quot;endpoint_disposition&quot;
+#define SWITCH_HOLD_MUSIC_VARIABLE &quot;hold_music&quot;
+#define SWITCH_EXPORT_VARS_VARIABLE &quot;export_vars&quot;
+#define SWITCH_R_SDP_VARIABLE &quot;switch_r_sdp&quot;
+#define SWITCH_L_SDP_VARIABLE &quot;switch_l_sdp&quot;
+#define SWITCH_B_SDP_VARIABLE &quot;switch_m_sdp&quot;
+#define SWITCH_BRIDGE_VARIABLE &quot;bridge_to&quot;
+#define SWITCH_SIGNAL_BRIDGE_VARIABLE &quot;signal_bridge_to&quot;
+#define SWITCH_SIGNAL_BOND_VARIABLE &quot;signal_bond&quot;
+#define SWITCH_ORIGINATOR_VARIABLE &quot;originator&quot;
+#define SWITCH_ORIGINATOR_CODEC_VARIABLE &quot;originator_codec&quot;
+#define SWITCH_ORIGINATOR_VIDEO_CODEC_VARIABLE &quot;originator_video_codec&quot;
+#define SWITCH_LOCAL_MEDIA_IP_VARIABLE &quot;local_media_ip&quot;
+#define SWITCH_LOCAL_MEDIA_PORT_VARIABLE &quot;local_media_port&quot;
+#define SWITCH_REMOTE_MEDIA_IP_VARIABLE &quot;remote_media_ip&quot;
+#define SWITCH_REMOTE_MEDIA_PORT_VARIABLE &quot;remote_media_port&quot;
+#define SWITCH_REMOTE_VIDEO_IP_VARIABLE &quot;remote_video_ip&quot;
+#define SWITCH_REMOTE_VIDEO_PORT_VARIABLE &quot;remote_video_port&quot;
+#define SWITCH_LOCAL_VIDEO_IP_VARIABLE &quot;local_video_ip&quot;
+#define SWITCH_LOCAL_VIDEO_PORT_VARIABLE &quot;local_video_port&quot;
+#define SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE &quot;hangup_after_bridge&quot;
+#define SWITCH_PARK_AFTER_BRIDGE_VARIABLE &quot;park_after_bridge&quot;
+#define SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE &quot;transfer_after_bridge&quot;
+#define SWITCH_EXEC_AFTER_BRIDGE_APP_VARIABLE &quot;exec_after_bridge_app&quot;
+#define SWITCH_EXEC_AFTER_BRIDGE_ARG_VARIABLE &quot;exec_after_bridge_arg&quot;
+#define SWITCH_MAX_FORWARDS_VARIABLE &quot;max_forwards&quot;
+#define SWITCH_DISABLE_APP_LOG_VARIABLE &quot;disable_app_log&quot;
+#define SWITCH_SPEECH_KEY &quot;speech&quot;
+#define SWITCH_UUID_BRIDGE &quot;uuid_bridge&quot;
+#define SWITCH_BITS_PER_BYTE 8
+#define SWITCH_DEFAULT_FILE_BUFFER_LEN 65536
+#define SWITCH_DTMF_LOG_LEN 1000
+typedef uint8_t switch_byte_t;
+
+typedef struct {
+        char digit;
+        uint32_t duration;
+} switch_dtmf_t;
+
+typedef enum {
+        SWITCH_CALL_DIRECTION_INBOUND,
+        SWITCH_CALL_DIRECTION_OUTBOUND
+} switch_call_direction_t;
+
+typedef enum {
+        SBF_DIAL_ALEG = (1 &lt;&lt; 0),
+        SBF_EXEC_ALEG = (1 &lt;&lt; 1),
+        SBF_DIAL_BLEG = (1 &lt;&lt; 2),
+        SBF_EXEC_BLEG = (1 &lt;&lt; 3),
+        SBF_EXEC_OPPOSITE = (1 &lt;&lt; 4),
+        SBF_EXEC_SAME = (1 &lt;&lt; 5),
+        SBF_ONCE = (1 &lt;&lt; 6),
+        SBF_EXEC_INLINE = (1 &lt;&lt; 7)
+} switch_bind_flag_enum_t;
+typedef uint32_t switch_bind_flag_t;
+
+typedef enum {
+        SWITCH_DTMF_RECV = 0,
+        SWITCH_DTMF_SEND = 1
+} switch_dtmf_direction_t;
+
+typedef enum {
+        SOF_NONE = 0,
+        SOF_NOBLOCK = (1 &lt;&lt; 0),
+        SOF_FORKED_DIAL = (1 &lt;&lt; 1),
+        SOF_NO_EFFECTIVE_CID_NUM = (1 &lt;&lt; 2),
+        SOF_NO_EFFECTIVE_CID_NAME = (1 &lt;&lt; 3)
+} switch_originate_flag_enum_t;
+typedef uint32_t switch_originate_flag_t;
+
+typedef enum {
+        SPF_NONE = 0,
+        SPF_ODD = (1 &lt;&lt; 0),
+        SPF_EVEN = (1 &lt;&lt; 1)
+} switch_port_flag_enum_t;
+typedef uint32_t switch_port_flag_t;
+
+typedef enum {
+        ED_MUX_READ = (1 &lt;&lt; 0),
+        ED_MUX_WRITE = (1 &lt;&lt; 1),
+        ED_DTMF = (1 &lt;&lt; 2)
+} switch_eavesdrop_flag_enum_t;
+typedef uint32_t switch_eavesdrop_flag_t;
+
+typedef enum {
+        SCF_NONE = 0,
+        SCF_USE_SQL = (1 &lt;&lt; 0),
+        SCF_NO_NEW_SESSIONS = (1 &lt;&lt; 1),
+        SCF_SHUTTING_DOWN = (1 &lt;&lt; 2),
+        SCF_VG = (1 &lt;&lt; 3),
+        SCF_RESTART = (1 &lt;&lt; 4),
+        SCF_SHUTDOWN_REQUESTED = (1 &lt;&lt; 5),
+        SCF_USE_AUTO_NAT = (1 &lt;&lt; 6),
+        SCF_EARLY_HANGUP = (1 &lt;&lt; 7),
+        SCF_CALIBRATE_CLOCK = (1 &lt;&lt; 8),
+        SCF_USE_HEAVY_TIMING = (1 &lt;&lt; 9),
+        SCF_USE_CLOCK_RT = (1 &lt;&lt; 10)
+} switch_core_flag_enum_t;
+typedef uint32_t switch_core_flag_t;
+
+typedef enum {
+        SWITCH_ENDPOINT_INTERFACE,
+        SWITCH_TIMER_INTERFACE,
+        SWITCH_DIALPLAN_INTERFACE,
+        SWITCH_CODEC_INTERFACE,
+        SWITCH_APPLICATION_INTERFACE,
+        SWITCH_API_INTERFACE,
+        SWITCH_FILE_INTERFACE,
+        SWITCH_SPEECH_INTERFACE,
+        SWITCH_DIRECTORY_INTERFACE,
+        SWITCH_CHAT_INTERFACE,
+        SWITCH_SAY_INTERFACE,
+        SWITCH_ASR_INTERFACE,
+        SWITCH_MANAGEMENT_INTERFACE
+} switch_module_interface_name_t;
+
+typedef enum {
+        SUF_NONE = 0,
+        SUF_THREAD_RUNNING = (1 &lt;&lt; 0),
+        SUF_READY = (1 &lt;&lt; 1),
+        SUF_NATIVE = (1 &lt;&lt; 2)
+} switch_unicast_flag_enum_t;
+typedef uint32_t switch_unicast_flag_t;
+
+typedef enum {
+        SWITCH_FALSE = 0,
+        SWITCH_TRUE = 1
+} switch_bool_t;
+
+/* WARNING, Do not forget to update *SAY_METHOD_NAMES[] in src/switch_ivr_play_say.c */
+typedef enum {
+        SSM_NA,
+        SSM_PRONOUNCED,
+        SSM_ITERATED,
+        SSM_COUNTED
+} switch_say_method_t;
+
+/* WARNING, Do not forget to update *SAY_TYPE_NAMES[] in src/switch_ivr_say.c */
+typedef enum {
+        SST_NUMBER,
+        SST_ITEMS,
+        SST_PERSONS,
+        SST_MESSAGES,
+        SST_CURRENCY,
+        SST_TIME_MEASUREMENT,
+        SST_CURRENT_DATE,
+        SST_CURRENT_TIME,
+        SST_CURRENT_DATE_TIME,
+        SST_TELEPHONE_NUMBER,
+        SST_TELEPHONE_EXTENSION,
+        SST_URL,
+        SST_IP_ADDRESS,
+        SST_EMAIL_ADDRESS,
+        SST_POSTAL_ADDRESS,
+        SST_ACCOUNT_NUMBER,
+        SST_NAME_SPELLED,
+        SST_NAME_PHONETIC,
+        SST_SHORT_DATE_TIME
+} switch_say_type_t;
+
+typedef enum {
+        SSG_MASCULINE,
+        SSG_FEMININE,
+        SSG_NEUTER
+} switch_say_gender_t;
+
+typedef enum {
+        SMA_NONE,
+        SMA_GET,
+        SMA_SET
+} switch_management_action_t;
+
+typedef enum {
+        SSHF_NONE = 0,
+        SSHF_OWN_THREAD = (1 &lt;&lt; 0),
+        SSHF_FREE_ARG = (1 &lt;&lt; 1),
+        SSHF_NO_DEL = (1 &lt;&lt; 2)
+} switch_scheduler_flag_enum_t;
+typedef uint32_t switch_scheduler_flag_t;
+
+typedef enum {
+        SMF_NONE = 0,
+        SMF_REBRIDGE = (1 &lt;&lt; 0),
+        SMF_ECHO_ALEG = (1 &lt;&lt; 1),
+        SMF_ECHO_BLEG = (1 &lt;&lt; 2),
+        SMF_FORCE = (1 &lt;&lt; 3),
+        SMF_LOOP = (1 &lt;&lt; 4),
+        SMF_HOLD_BLEG = (1 &lt;&lt; 5),
+        SMF_IMMEDIATE = (1 &lt;&lt; 6),
+        SMF_EXEC_INLINE = (1 &lt;&lt; 7),
+        SMF_PRIORITY = (1 &lt;&lt; 8)
+} switch_media_flag_enum_t;
+typedef uint32_t switch_media_flag_t;
+
+typedef enum {
+        SWITCH_BITPACK_MODE_RFC3551,
+        SWITCH_BITPACK_MODE_AAL2
+} switch_bitpack_mode_t;
+
+typedef enum {
+        SWITCH_ABC_TYPE_INIT,
+        SWITCH_ABC_TYPE_READ,
+        SWITCH_ABC_TYPE_WRITE,
+        SWITCH_ABC_TYPE_WRITE_REPLACE,
+        SWITCH_ABC_TYPE_READ_REPLACE,
+        SWITCH_ABC_TYPE_READ_PING,
+        SWITCH_ABC_TYPE_CLOSE
+} switch_abc_type_t;
+
+typedef struct {
+        switch_byte_t *buf;
+        uint32_t buflen;
+        switch_byte_t *cur;
+        uint32_t bytes;
+        uint32_t bits_tot;
+        switch_byte_t bits_cur;
+        switch_byte_t bits_rem;
+        switch_byte_t frame_bits;
+        switch_byte_t shiftby;
+        switch_byte_t this_byte;
+        switch_byte_t under;
+        switch_byte_t over;
+        switch_bitpack_mode_t mode;
+} switch_bitpack_t;
+
+
+struct switch_directories {
+        char *base_dir;
+        char *mod_dir;
+        char *conf_dir;
+        char *log_dir;
+        char *run_dir;
+        char *db_dir;
+        char *script_dir;
+        char *temp_dir;
+        char *htdocs_dir;
+        char *grammar_dir;
+        char *storage_dir;
+        char *recordings_dir;
+        char *sounds_dir;
+};
+
+typedef struct switch_directories switch_directories;
+SWITCH_DECLARE_DATA extern switch_directories SWITCH_GLOBAL_dirs;
+
+#define SWITCH_MAX_STACKS 16
+#define SWITCH_THREAD_STACKSIZE 240 * 1024
+#define SWITCH_SYSTEM_THREAD_STACKSIZE 8192 * 1024
+#define SWITCH_MAX_INTERVAL 120        /* we only do up to 120ms */
+#define SWITCH_INTERVAL_PAD 10        /* A little extra buffer space to be safe */
+#define SWITCH_MAX_SAMPLE_LEN 48
+#define SWITCH_BYTES_PER_SAMPLE 2        /* slin is 2 bytes per sample */
+#define SWITCH_RECOMMENDED_BUFFER_SIZE 4096        /* worst case of 32khz @60ms we only do 48khz @10ms which is 960 */
+#define SWITCH_MAX_CODECS 50
+#define SWITCH_MAX_STATE_HANDLERS 30
+#define SWITCH_CORE_QUEUE_LEN 100000
+#define SWITCH_MAX_MANAGEMENT_BUFFER_LEN 1024 * 8
+
+#define SWITCH_ACCEPTABLE_INTERVAL(_i) (_i &amp;&amp; _i &lt;= SWITCH_MAX_INTERVAL &amp;&amp; (_i % 10) == 0)
+
+typedef enum {
+        SWITCH_CPF_NONE = 0,
+        SWITCH_CPF_SCREEN = (1 &lt;&lt; 0),
+        SWITCH_CPF_HIDE_NAME = (1 &lt;&lt; 1),
+        SWITCH_CPF_HIDE_NUMBER = (1 &lt;&lt; 2)
+} switch_caller_profile_flag_enum_t;
+typedef uint32_t switch_caller_profile_flag_t;
+
+typedef enum {
+        SWITCH_AUDIO_COL_STR_TITLE = 0x01,
+        SWITCH_AUDIO_COL_STR_COPYRIGHT = 0x02,
+        SWITCH_AUDIO_COL_STR_SOFTWARE = 0x03,
+        SWITCH_AUDIO_COL_STR_ARTIST = 0x04,
+        SWITCH_AUDIO_COL_STR_COMMENT = 0x05,
+        SWITCH_AUDIO_COL_STR_DATE = 0x06
+} switch_audio_col_t;
+
+typedef enum {
+        SWITCH_XML_SECTION_RESULT = 0,
+        SWITCH_XML_SECTION_CONFIG = (1 &lt;&lt; 0),
+        SWITCH_XML_SECTION_DIRECTORY = (1 &lt;&lt; 1),
+        SWITCH_XML_SECTION_DIALPLAN = (1 &lt;&lt; 2),
+        SWITCH_XML_SECTION_PHRASES = (1 &lt;&lt; 3),
+
+        /* Nothing after this line */
+        SWITCH_XML_SECTION_MAX = (1 &lt;&lt; 4)
+} switch_xml_section_enum_t;
+typedef uint32_t switch_xml_section_t;
+
+/*!
+  \enum switch_vad_flag_t
+  \brief RTP Related Flags
+&lt;pre&gt;
+    SWITCH_VAD_FLAG_TALKING         - Currently Talking
+    SWITCH_VAD_FLAG_EVENTS_TALK     - Fire events when talking is detected
+        SWITCH_VAD_FLAG_EVENTS_NOTALK   - Fire events when not talking is detected
+        SWITCH_VAD_FLAG_CNG                                - Send CNG
+&lt;/pre&gt;
+ */
+typedef enum {
+        SWITCH_VAD_FLAG_TALKING = (1 &lt;&lt; 0),
+        SWITCH_VAD_FLAG_EVENTS_TALK = (1 &lt;&lt; 1),
+        SWITCH_VAD_FLAG_EVENTS_NOTALK = (1 &lt;&lt; 2),
+        SWITCH_VAD_FLAG_CNG = (1 &lt;&lt; 3)
+} switch_vad_flag_enum_t;
+typedef uint32_t switch_vad_flag_t;
+
+typedef struct {
+        switch_size_t raw_bytes;
+        switch_size_t media_bytes;
+        switch_size_t packet_count;
+        switch_size_t media_packet_count;
+        switch_size_t skip_packet_count;
+        switch_size_t jb_packet_count;
+        switch_size_t dtmf_packet_count;
+        switch_size_t cng_packet_count;
+        switch_size_t flush_packet_count;
+} switch_rtp_numbers_t;
+
+typedef struct {
+        switch_rtp_numbers_t inbound;
+        switch_rtp_numbers_t outbound;
+} switch_rtp_stats_t;
+
+typedef enum {
+        SWITCH_RTP_FLUSH_ONCE,
+        SWITCH_RTP_FLUSH_STICK,
+        SWITCH_RTP_FLUSH_UNSTICK
+} switch_rtp_flush_t;
+
+#define SWITCH_RTP_CNG_PAYLOAD 13
+
+/*!
+  \enum switch_rtp_flag_t
+  \brief RTP Related Flags
+&lt;pre&gt;
+    SWITCH_RTP_FLAG_NOBLOCK       - Do not block
+    SWITCH_RTP_FLAG_IO            - IO is ready
+        SWITCH_RTP_FLAG_USE_TIMER     - Timeout Reads and replace with a CNG Frame
+        SWITCH_RTP_FLAG_TIMER_RECLOCK - Resync the timer to the current clock on slips
+        SWITCH_RTP_FLAG_SECURE        - Secure RTP
+        SWITCH_RTP_FLAG_AUTOADJ       - Auto-Adjust the dest based on the source
+        SWITCH_RTP_FLAG_RAW_WRITE     - Try to forward packets unscathed
+        SWITCH_RTP_FLAG_GOOGLEHACK    - Convert payload from 102 to 97
+        SWITCH_RTP_FLAG_VAD           - Enable VAD
+        SWITCH_RTP_FLAG_BREAK                  - Stop what you are doing and return SWITCH_STATUS_BREAK
+        SWITCH_RTP_FLAG_MINI                  - Use mini RTP when possible
+        SWITCH_RTP_FLAG_DATAWAIT          - Do not return from reads unless there is data even when non blocking
+        SWITCH_RTP_FLAG_BUGGY_2833    - Emulate the bug in cisco equipment to allow interop
+        SWITCH_RTP_FLAG_PASS_RFC2833  - Pass 2833 (ignore it)
+        SWITCH_RTP_FLAG_AUTO_CNG      - Generate outbound CNG frames when idle    
+&lt;/pre&gt;
+ */
+typedef enum {
+        SWITCH_RTP_FLAG_NOBLOCK = (1 &lt;&lt; 0),
+        SWITCH_RTP_FLAG_IO = (1 &lt;&lt; 1),
+        SWITCH_RTP_FLAG_USE_TIMER = (1 &lt;&lt; 2),
+        SWITCH_RTP_FLAG_TIMER_RECLOCK = (1 &lt;&lt; 3),
+        SWITCH_RTP_FLAG_SECURE_SEND = (1 &lt;&lt; 4),
+        SWITCH_RTP_FLAG_SECURE_RECV = (1 &lt;&lt; 5),
+        SWITCH_RTP_FLAG_AUTOADJ = (1 &lt;&lt; 6),
+        SWITCH_RTP_FLAG_RAW_WRITE = (1 &lt;&lt; 7),
+        SWITCH_RTP_FLAG_GOOGLEHACK = (1 &lt;&lt; 8),
+        SWITCH_RTP_FLAG_VAD = (1 &lt;&lt; 9),
+        SWITCH_RTP_FLAG_BREAK = (1 &lt;&lt; 10),
+        SWITCH_RTP_FLAG_MINI = (1 &lt;&lt; 11),
+        SWITCH_RTP_FLAG_DATAWAIT = (1 &lt;&lt; 12),
+        SWITCH_RTP_FLAG_BUGGY_2833 = (1 &lt;&lt; 13),
+        SWITCH_RTP_FLAG_PASS_RFC2833 = (1 &lt;&lt; 14),
+        SWITCH_RTP_FLAG_AUTO_CNG = (1 &lt;&lt; 15),
+        SWITCH_RTP_FLAG_SECURE_SEND_RESET = (1 &lt;&lt; 16),
+        SWITCH_RTP_FLAG_SECURE_RECV_RESET = (1 &lt;&lt; 17),
+        SWITCH_RTP_FLAG_PROXY_MEDIA = (1 &lt;&lt; 18),
+        SWITCH_RTP_FLAG_SHUTDOWN = (1 &lt;&lt; 19),
+        SWITCH_RTP_FLAG_FLUSH = (1 &lt;&lt; 20),
+        SWITCH_RTP_FLAG_AUTOFLUSH = (1 &lt;&lt; 21),
+        SWITCH_RTP_FLAG_STICKY_FLUSH = (1 &lt;&lt; 22),
+        SWITCH_ZRTP_FLAG_SECURE_SEND = (1 &lt;&lt; 23),
+        SWITCH_ZRTP_FLAG_SECURE_RECV = (1 &lt;&lt; 24),
+        SWITCH_ZRTP_FLAG_SECURE_MITM_SEND = (1 &lt;&lt; 25),
+        SWITCH_ZRTP_FLAG_SECURE_MITM_RECV = (1 &lt;&lt; 26),
+        SWITCH_RTP_FLAG_DEBUG_RTP_READ = (1 &lt;&lt; 27),
+        SWITCH_RTP_FLAG_DEBUG_RTP_WRITE = (1 &lt;&lt; 28),
+        SWITCH_RTP_FLAG_VIDEO = (1 &lt;&lt; 29),
+        SWITCH_RTP_FLAG_ENABLE_RTCP = (1 &lt;&lt; 30),
+        SWITCH_RTP_FLAG_RTCP_PASSTHRU = (1 &lt;&lt; 31)
+        /* don't add any more 31 is the limit! gotta chnge to an array to add more */
+} switch_rtp_flag_enum_t;
+typedef uint32_t switch_rtp_flag_t;
+
+typedef enum {
+        RTP_BUG_NONE = 0,                        /* won't be using this one much ;) */
+
+        RTP_BUG_CISCO_SKIP_MARK_BIT_2833 = (1 &lt;&lt; 0),
+        /* Some Cisco devices get mad when you send the mark bit on new 2833 because it makes
+           them flush their jitterbuffer and the dtmf along with it.
+
+           This flag will disable the sending of the mark bit on the first DTMF packet.
+         */
+
+
+        RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833 = (1 &lt;&lt; 1)
+                /*
+                   Sonus wrongly expects that, when sending a multi-packet 2833 DTMF event, The sender
+                   should increment the RTP timestamp in each packet when, in reality, the sender should
+                   send the same exact timestamp and increment the duration field in the 2833 payload.
+                   This allows a reconstruction of the duration if any of the packets are lost.
+
+                   final_duration - initial_timestamp = total_samples
+
+                   However, if the duration value exceeds the space allocated (16 bits), The sender should increment
+                   the timestamp one unit and reset the duration to 0. 
+
+                   Always sending a duration of 0 with a new timestamp should be tolerated but is rarely intentional
+                   and is mistakenly done by many devices.  
+                   The issue is that the Sonus expects everyone to do it this way instead of tolerating either way.
+                   Sonus will actually ignore every packet with the same timestamp before concluding if it's DTMF.
+
+                   This flag will cause each packet to have a new timestamp.
+                 */
+} switch_rtp_bug_flag_t;
+
+#ifdef _MSC_VER
+#pragma pack(push, r1, 1)
+#endif
+
+#if SWITCH_BYTE_ORDER == __BIG_ENDIAN
+typedef struct {
+        unsigned version:2;                        /* protocol version       */
+        unsigned p:1;                                /* padding flag           */
+        unsigned x:1;                                /* header extension flag  */
+        unsigned cc:4;                                /* CSRC count             */
+        unsigned m:1;                                /* marker bit             */
+        unsigned pt:7;                                /* payload type           */
+        unsigned seq:16;                        /* sequence number        */
+        unsigned ts:32;                                /* timestamp              */
+        unsigned ssrc:32;                        /* synchronization source */
+} switch_rtp_hdr_t;
+
+#else /*  BIG_ENDIAN */
+
+typedef struct {
+        unsigned cc:4;                                /* CSRC count             */
+        unsigned x:1;                                /* header extension flag  */
+        unsigned p:1;                                /* padding flag           */
+        unsigned version:2;                        /* protocol version       */
+        unsigned pt:7;                                /* payload type           */
+        unsigned m:1;                                /* marker bit             */
+        unsigned seq:16;                        /* sequence number        */
+        unsigned ts:32;                                /* timestamp              */
+        unsigned ssrc:32;                        /* synchronization source */
+} switch_rtp_hdr_t;
+
+#endif
+
+#ifdef _MSC_VER
+#pragma pack(pop, r1)
+#endif
+
+#ifdef _MSC_VER
+#pragma pack(push, r1, 1)
+#endif
+
+#if SWITCH_BYTE_ORDER == __BIG_ENDIAN
+typedef struct {
+        unsigned version:2;                        /* protocol version                  */
+        unsigned p:1;                                /* padding flag                      */
+        unsigned count:5;                        /* number of reception report blocks */
+        unsigned type:8;                        /* packet type                       */
+        unsigned length:16;                        /* length in 32-bit words - 1        */
+} switch_rtcp_hdr_t;
+
+#else /*  BIG_ENDIAN */
+
+typedef struct {
+        unsigned count:5;                        /* number of reception report blocks */
+        unsigned p:1;                                /* padding flag                      */
+        unsigned version:2;                        /* protocol version                  */
+        unsigned type:8;                        /* packet type                       */
+        unsigned length:16;                        /* length in 32-bit words - 1        */
+} switch_rtcp_hdr_t;
+
+#endif
+
+#ifdef _MSC_VER
+#pragma pack(pop, r1)
+#endif
+
+/*!
+  \enum switch_priority_t
+  \brief Priority Indication
+&lt;pre&gt;
+    SWITCH_PRIORITY_NORMAL  - Normal Priority
+    SWITCH_PRIORITY_LOW     - Low Priority
+    SWITCH_PRIORITY_HIGH    - High Priority
+&lt;/pre&gt;
+ */
+typedef enum {
+        SWITCH_PRIORITY_NORMAL,
+        SWITCH_PRIORITY_LOW,
+        SWITCH_PRIORITY_HIGH
+} switch_priority_t;
+
+/*!
+  \enum switch_ivr_option_t
+  \brief Possible options related to ivr functions
+&lt;pre&gt;
+    SWITCH_IVR_OPTION_NONE  - nothing whatsoever
+    SWITCH_IVR_OPTION_ASYNC - Asynchronous (do things in the background when applicable)
+        SWITCH_IVR_OPTION_FILE  - string argument implies a filename
+&lt;/pre&gt;
+ */
+typedef enum {
+        SWITCH_IVR_OPTION_NONE = 0,
+        SWITCH_IVR_OPTION_ASYNC = (1 &lt;&lt; 0),
+        SWITCH_IVR_OPTION_FILE = (1 &lt;&lt; 1)
+} switch_ivr_option_enum_t;
+typedef uint32_t switch_ivr_option_t;
+
+/*!
+  \enum switch_core_session_message_types_t
+  \brief Possible types of messages for inter-session communication
+&lt;pre&gt;
+        SWITCH_MESSAGE_REDIRECT_AUDIO     - Indication to redirect audio to another location if possible
+        SWITCH_MESSAGE_TRANSMIT_TEXT      - A text message
+        SWITCH_MESSAGE_INDICATE_ANSWER    - indicate answer
+        SWITCH_MESSAGE_INDICATE_PROGRESS  - indicate progress 
+        SWITCH_MESSAGE_INDICATE_BRIDGE    - indicate a bridge starting
+        SWITCH_MESSAGE_INDICATE_UNBRIDGE  - indicate a bridge ending
+        SWITCH_MESSAGE_INDICATE_TRANSFER  - indicate a transfer is taking place
+        SWITCH_MESSAGE_INDICATE_MEDIA          - indicate media is required
+        SWITCH_MESSAGE_INDICATE_NOMEDIA          - indicate no-media is required
+        SWITCH_MESSAGE_INDICATE_HOLD      - indicate hold
+        SWITCH_MESSAGE_INDICATE_UNHOLD    - indicate unhold
+        SWITCH_MESSAGE_INDICATE_REDIRECT  - indicate redirect
+        SWITCH_MESSAGE_INDICATE_RESPOND    - indicate reject
+        SWITCH_MESSAGE_INDICATE_BROADCAST - indicate media broadcast
+        SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT - indicate media broadcast
+        SWITCH_MESSAGE_INDICATE_DEFLECT - indicate deflect
+        SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ - indicate video refresh request
+&lt;/pre&gt;
+ */
+typedef enum {
+        SWITCH_MESSAGE_REDIRECT_AUDIO,
+        SWITCH_MESSAGE_TRANSMIT_TEXT,
+        SWITCH_MESSAGE_INDICATE_ANSWER,
+        SWITCH_MESSAGE_INDICATE_PROGRESS,
+        SWITCH_MESSAGE_INDICATE_BRIDGE,
+        SWITCH_MESSAGE_INDICATE_UNBRIDGE,
+        SWITCH_MESSAGE_INDICATE_TRANSFER,
+        SWITCH_MESSAGE_INDICATE_RINGING,
+        SWITCH_MESSAGE_INDICATE_MEDIA,
+        SWITCH_MESSAGE_INDICATE_NOMEDIA,
+        SWITCH_MESSAGE_INDICATE_HOLD,
+        SWITCH_MESSAGE_INDICATE_UNHOLD,
+        SWITCH_MESSAGE_INDICATE_REDIRECT,
+        SWITCH_MESSAGE_INDICATE_RESPOND,
+        SWITCH_MESSAGE_INDICATE_BROADCAST,
+        SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT,
+        SWITCH_MESSAGE_INDICATE_DEFLECT,
+        SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ,
+        SWITCH_MESSAGE_INDICATE_DISPLAY,
+        SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY,
+        SWITCH_MESSAGE_INDICATE_AUDIO_SYNC,
+        SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA,
+        SWITCH_MESSAGE_INDICATE_UUID_CHANGE,
+        SWITCH_MESSAGE_INDICATE_SIMPLIFY,
+        SWITCH_MESSAGE_INDICATE_DEBUG_AUDIO,
+        SWITCH_MESSAGE_INDICATE_PROXY_MEDIA,
+        SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC,
+        SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC_COMPLETE,
+        SWITCH_MESSAGE_INDICATE_PHONE_EVENT,
+        SWITCH_MESSAGE_INVALID
+} switch_core_session_message_types_t;
+
+typedef struct {
+        uint32_t T38MaxBitRate;
+        switch_bool_t T38FaxFillBitRemoval;
+        switch_bool_t T38FaxTranscodingMMR;
+        switch_bool_t T38FaxTranscodingJBIG;
+        const char *T38FaxRateManagement;
+        uint32_t T38FaxMaxBuffer;
+        uint32_t T38FaxMaxDatagram;
+        const char *T38FaxUdpEC;
+        const char *T38VendorInfo;
+        const char *ip;
+        uint32_t port;
+} switch_t38_options_t;
+
+/*!
+  \enum switch_stack_t
+  \brief Expression of how to stack a list
+&lt;pre&gt;
+SWITCH_STACK_BOTTOM - Stack on the bottom
+SWITCH_STACK_TOP        - Stack on the top
+&lt;/pre&gt;
+ */
+typedef enum {
+        SWITCH_STACK_BOTTOM,
+        SWITCH_STACK_TOP
+} switch_stack_t;
+
+/*!
+  \enum switch_status_t
+  \brief Common return values
+&lt;pre&gt;
+    SWITCH_STATUS_SUCCESS        - General Success (common return value for most functions)
+    SWITCH_STATUS_FALSE                - General Falsehood
+    SWITCH_STATUS_TIMEOUT        - A Timeout has occured
+    SWITCH_STATUS_RESTART        - An indication to restart the previous operation
+    SWITCH_STATUS_TERM                - An indication to terminate
+    SWITCH_STATUS_NOTIMPL        - An indication that requested resource is not impelemented
+    SWITCH_STATUS_MEMERR        - General memory error
+    SWITCH_STATUS_NOOP                - NOTHING
+    SWITCH_STATUS_RESAMPLE        - An indication that a resample has occured
+    SWITCH_STATUS_GENERR        - A general Error
+    SWITCH_STATUS_INUSE                - An indication that requested resource is in use
+        SWITCH_STATUS_BREAK     - A non-fatal break of an operation
+    SWITCH_STATUS_SOCKERR   - A socket error
+        SWITCH_STATUS_MORE_DATA - Need More Data
+        SWITCH_STATUS_NOTFOUND  - Not Found
+        SWITCH_STATUS_UNLOAD    - Unload
+        SWITCH_STATUS_NOUNLOAD  - Never Unload
+&lt;/pre&gt;
+ */
+typedef enum {
+        SWITCH_STATUS_SUCCESS,
+        SWITCH_STATUS_FALSE,
+        SWITCH_STATUS_TIMEOUT,
+        SWITCH_STATUS_RESTART,
+        SWITCH_STATUS_TERM,
+        SWITCH_STATUS_NOTIMPL,
+        SWITCH_STATUS_MEMERR,
+        SWITCH_STATUS_NOOP,
+        SWITCH_STATUS_RESAMPLE,
+        SWITCH_STATUS_GENERR,
+        SWITCH_STATUS_INUSE,
+        SWITCH_STATUS_BREAK,
+        SWITCH_STATUS_SOCKERR,
+        SWITCH_STATUS_MORE_DATA,
+        SWITCH_STATUS_NOTFOUND,
+        SWITCH_STATUS_UNLOAD,
+        SWITCH_STATUS_NOUNLOAD,
+        SWITCH_STATUS_IGNORE,
+        SWITCH_STATUS_TOO_SMALL,
+        SWITCH_STATUS_NOT_INITALIZED
+} switch_status_t;
+
+
+
+/*!
+\enum switch_log_level_t
+\brief Log Level Enumeration
+&lt;pre&gt;
+        SWITCH_LOG_DEBUG            - Debug
+        SWITCH_LOG_INFO             - Info
+        SWITCH_LOG_NOTICE           - Notice
+        SWITCH_LOG_WARNING          - Warning
+        SWITCH_LOG_ERROR            - Error
+        SWITCH_LOG_CRIT             - Critical
+        SWITCH_LOG_ALERT            - Alert
+        SWITCH_LOG_CONSOLE          - Console
+&lt;/pre&gt;
+ */
+typedef enum {
+        SWITCH_LOG_DEBUG10 = 110,
+        SWITCH_LOG_DEBUG9 = 109,
+        SWITCH_LOG_DEBUG8 = 108,
+        SWITCH_LOG_DEBUG7 = 107,
+        SWITCH_LOG_DEBUG6 = 106,
+        SWITCH_LOG_DEBUG5 = 105,
+        SWITCH_LOG_DEBUG4 = 104,
+        SWITCH_LOG_DEBUG3 = 103,
+        SWITCH_LOG_DEBUG2 = 102,
+        SWITCH_LOG_DEBUG1 = 101,
+        SWITCH_LOG_DEBUG = 7,
+        SWITCH_LOG_INFO = 6,
+        SWITCH_LOG_NOTICE = 5,
+        SWITCH_LOG_WARNING = 4,
+        SWITCH_LOG_ERROR = 3,
+        SWITCH_LOG_CRIT = 2,
+        SWITCH_LOG_ALERT = 1,
+        SWITCH_LOG_CONSOLE = 0,
+        SWITCH_LOG_INVALID = 64
+} switch_log_level_t;
+
+
+/*!
+\enum switch_text_channel_t
+\brief A target to write log/debug info to
+&lt;pre&gt;
+SWITCH_CHANNEL_ID_LOG                        - Write to the currently defined log
+SWITCH_CHANNEL_ID_LOG_CLEAN                - Write to the currently defined log with no extra file/line/date information
+SWITCH_CHANNEL_ID_EVENT                        - Write to the event engine as a LOG event
+&lt;/pre&gt;
+ */
+typedef enum {
+        SWITCH_CHANNEL_ID_LOG,
+        SWITCH_CHANNEL_ID_LOG_CLEAN,
+        SWITCH_CHANNEL_ID_EVENT,
+        SWITCH_CHANNEL_ID_SESSION
+} switch_text_channel_t;
+
+typedef enum {
+        SCSMF_DYNAMIC = (1 &lt;&lt; 0),
+        SCSMF_FREE_STRING_REPLY = (1 &lt;&lt; 1),
+        SCSMF_FREE_POINTER_REPLY = (1 &lt;&lt; 2)
+} switch_core_session_message_flag_enum_t;
+typedef uint32_t switch_core_session_message_flag_t;
+
+#define SWITCH_CHANNEL_LOG SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, NULL
+#define SWITCH_CHANNEL_LOG_CLEAN SWITCH_CHANNEL_ID_LOG_CLEAN, __FILE__, __SWITCH_FUNC__, __LINE__, NULL
+#define SWITCH_CHANNEL_SESSION_LOG_CLEAN(x) SWITCH_CHANNEL_ID_LOG_CLEAN, __FILE__, __SWITCH_FUNC__, __LINE__, switch_core_session_get_uuid((x))
+#define SWITCH_CHANNEL_EVENT SWITCH_CHANNEL_ID_EVENT, __FILE__, __SWITCH_FUNC__, __LINE__, NULL
+#define SWITCH_CHANNEL_SESSION_LOG(x) SWITCH_CHANNEL_ID_SESSION, __FILE__, __SWITCH_FUNC__, __LINE__, (const char*)(x)
+#define SWITCH_CHANNEL_CHANNEL_LOG(x) SWITCH_CHANNEL_ID_SESSION, __FILE__, __SWITCH_FUNC__, __LINE__, (const char*)switch_channel_get_session(x)
+#define SWITCH_CHANNEL_UUID_LOG(x) SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, (x)
+
+/*!
+  \enum switch_channel_state_t
+  \brief Channel States (these are the defaults, CS_SOFT_EXECUTE, CS_EXCHANGE_MEDIA, and CS_CONSUME_MEDIA are often overridden by specific apps)
+&lt;pre&gt;
+CS_NEW       - Channel is newly created.
+CS_INIT      - Channel has been initilized.
+CS_ROUTING   - Channel is looking for an extension to execute.
+CS_SOFT_EXECUTE  - Channel is ready to execute from 3rd party control.
+CS_EXECUTE   - Channel is executing it's dialplan.
+CS_EXCHANGE_MEDIA  - Channel is exchanging media with another channel.
+CS_PARK      - Channel is accepting media awaiting commands.
+CS_CONSUME_MEDIA                 - Channel is consuming all media and dropping it.
+CS_HIBERNATE - Channel is in a sleep state.
+CS_RESET          - Channel is in a reset state.
+CS_HANGUP    - Channel is flagged for hangup and ready to end.
+CS_REPORTING - Channel is ready to collect call detail.
+CS_DESTROY      - Channel is ready to be destroyed and out of the state machine
+&lt;/pre&gt;
+ */
+typedef enum {
+        CS_NEW,
+        CS_INIT,
+        CS_ROUTING,
+        CS_SOFT_EXECUTE,
+        CS_EXECUTE,
+        CS_EXCHANGE_MEDIA,
+        CS_PARK,
+        CS_CONSUME_MEDIA,
+        CS_HIBERNATE,
+        CS_RESET,
+        CS_HANGUP,
+        CS_REPORTING,
+        CS_DESTROY,
+        CS_NONE
+} switch_channel_state_t;
+
+
+/*!
+  \enum switch_channel_flag_t
+  \brief Channel Flags
+
+&lt;pre&gt;
+CF_ANSWERED                        - Channel is answered
+CF_OUTBOUND                        - Channel is an outbound channel
+CF_EARLY_MEDIA                - Channel is ready for audio before answer 
+CF_ORIGINATOR                - Channel is an originator
+CF_TRANSFER                        - Channel is being transfered
+CF_ACCEPT_CNG                - Channel will accept CNG frames
+CF_REDIRECT                 - Channel is being redirected
+CF_BRIDGED                        - Channel in a bridge
+CF_HOLD                                - Channel is on hold
+CF_SERVICE                        - Channel has a service thread
+CF_TAGGED                        - Channel is tagged
+CF_WINNER                        - Channel is the winner
+CF_CONTROLLED                - Channel is under control
+CF_PROXY_MODE                - Channel has no media
+CF_SUSPEND                        - Suspend i/o
+CF_EVENT_PARSE                - Suspend control events
+CF_GEN_RINGBACK                - Channel is generating it's own ringback
+CF_RING_READY                - Channel is ready to send ringback
+CF_BREAK                        - Channel should stop what it's doing
+CF_BROADCAST                - Channel is broadcasting
+CF_UNICAST                        - Channel has a unicast connection
+CF_VIDEO                        - Channel has video
+CF_EVENT_LOCK                - Don't parse events
+CF_RESET                        - Tell extension parser to reset
+CF_ORIGINATING                - Channel is originating
+CF_STOP_BROADCAST        - Signal to stop broadcast
+&lt;/pre&gt;
+ */
+
+typedef enum {
+        CC_MEDIA_ACK = 1,
+        CC_BYPASS_MEDIA,
+        CC_PROXY_MEDIA,
+        /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
+        CC_FLAG_MAX
+} switch_channel_cap_t;
+
+typedef enum {
+        CF_ANSWERED = 1,
+        CF_OUTBOUND,
+        CF_EARLY_MEDIA,
+        CF_BRIDGE_ORIGINATOR,
+        CF_TRANSFER,
+        CF_ACCEPT_CNG,
+        CF_REDIRECT,
+        CF_BRIDGED,
+        CF_HOLD,
+        CF_SERVICE,
+        CF_TAGGED,
+        CF_WINNER,
+        CF_CONTROLLED,
+        CF_PROXY_MODE,
+        CF_SUSPEND,
+        CF_EVENT_PARSE,
+        CF_GEN_RINGBACK,
+        CF_RING_READY,
+        CF_BREAK,
+        CF_BROADCAST,
+        CF_UNICAST,
+        CF_VIDEO,
+        CF_EVENT_LOCK,
+        CF_EVENT_LOCK_PRI,
+        CF_RESET,
+        CF_ORIGINATING,
+        CF_STOP_BROADCAST,
+        CF_PROXY_MEDIA,
+        CF_INNER_BRIDGE,
+        CF_REQ_MEDIA,
+        CF_VERBOSE_EVENTS,
+        CF_PAUSE_BUGS,
+        CF_DIVERT_EVENTS,
+        CF_BLOCK_STATE,
+        CF_FS_RTP,
+        CF_REPORTING,
+        CF_PARK,
+        CF_TIMESTAMP_SET,
+        CF_ORIGINATOR,
+        CF_XFER_ZOMBIE,
+        CF_MEDIA_ACK,
+        CF_THREAD_SLEEPING,
+        CF_DISABLE_RINGBACK,
+        CF_NOT_READY,
+        CF_SIGNAL_BRIDGE_TTL,
+        CF_MEDIA_BRIDGE_TTL,
+        CF_BYPASS_MEDIA_AFTER_BRIDGE,
+        CF_LEG_HOLDING,
+        CF_BROADCAST_DROP_MEDIA,
+        CF_EARLY_HANGUP,
+        CF_MEDIA_SET,
+        /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
+        CF_FLAG_MAX
+} switch_channel_flag_t;
+
+
+typedef enum {
+        CF_APP_TAGGED = (1 &lt;&lt; 0)
+} switch_channel_app_flag_t;
+
+
+/*!
+  \enum switch_frame_flag_t
+  \brief Frame Flags
+
+&lt;pre&gt;
+SFF_CNG        = (1 &lt;&lt;  0) - Frame represents comfort noise
+SFF_RAW_RTP    = (1 &lt;&lt;  1) - Frame has raw rtp accessible
+SFF_RTP_HEADER = (1 &lt;&lt; 2)  - Get the rtp header from the frame header
+SFF_PLC        = (1 &lt;&lt; 3)  - Frame has generated PLC data
+SFF_RFC2833    = (1 &lt;&lt; 4)  - Frame has rfc2833 dtmf data
+SFF_DYNAMIC    = (1 &lt;&lt; 5)  - Frame is dynamic and should be freed
+&lt;/pre&gt;
+ */
+typedef enum {
+        SFF_NONE = 0,
+        SFF_CNG = (1 &lt;&lt; 0),
+        SFF_RAW_RTP = (1 &lt;&lt; 1),
+        SFF_RTP_HEADER = (1 &lt;&lt; 2),
+        SFF_PLC = (1 &lt;&lt; 3),
+        SFF_RFC2833 = (1 &lt;&lt; 4),
+        SFF_PROXY_PACKET = (1 &lt;&lt; 5),
+        SFF_DYNAMIC = (1 &lt;&lt; 6),
+        SFF_ZRTP = (1 &lt;&lt; 7)
+} switch_frame_flag_enum_t;
+typedef uint32_t switch_frame_flag_t;
+
+
+typedef enum {
+        SAF_NONE = 0,
+        SAF_SUPPORT_NOMEDIA = (1 &lt;&lt; 0),
+        SAF_ROUTING_EXEC = (1 &lt;&lt; 1),
+        SAF_MEDIA_TAP = (1 &lt;&lt; 2)
+} switch_application_flag_enum_t;
+typedef uint32_t switch_application_flag_t;
+
+/*!
+  \enum switch_signal_t
+  \brief Signals to send to channels
+&lt;pre&gt;
+SWITCH_SIG_KILL - Kill the channel
+SWITCH_SIG_XFER - Stop the current io but leave it viable
+&lt;/pre&gt;
+ */
+
+typedef enum {
+        SWITCH_SIG_NONE,
+        SWITCH_SIG_KILL,
+        SWITCH_SIG_XFER,
+        SWITCH_SIG_BREAK
+} switch_signal_t;
+
+/*!
+  \enum switch_codec_flag_t
+  \brief Codec related flags
+&lt;pre&gt;
+SWITCH_CODEC_FLAG_ENCODE =                        (1 &lt;&lt;  0) - Codec can encode
+SWITCH_CODEC_FLAG_DECODE =                        (1 &lt;&lt;  1) - Codec can decode
+SWITCH_CODEC_FLAG_SILENCE_START =        (1 &lt;&lt;  2) - Start period of silence
+SWITCH_CODEC_FLAG_SILENCE_STOP =        (1 &lt;&lt;  3) - End period of silence
+SWITCH_CODEC_FLAG_SILENCE =                        (1 &lt;&lt;  4) - Silence
+SWITCH_CODEC_FLAG_FREE_POOL =                (1 &lt;&lt;  5) - Free codec's pool on destruction
+SWITCH_CODEC_FLAG_AAL2 =                        (1 &lt;&lt;  6) - USE AAL2 Bitpacking
+SWITCH_CODEC_FLAG_PASSTHROUGH =                (1 &lt;&lt;  7) - Passthrough only
+&lt;/pre&gt;
+*/
+typedef enum {
+        SWITCH_CODEC_FLAG_ENCODE = (1 &lt;&lt; 0),
+        SWITCH_CODEC_FLAG_DECODE = (1 &lt;&lt; 1),
+        SWITCH_CODEC_FLAG_SILENCE_START = (1 &lt;&lt; 2),
+        SWITCH_CODEC_FLAG_SILENCE_STOP = (1 &lt;&lt; 3),
+        SWITCH_CODEC_FLAG_SILENCE = (1 &lt;&lt; 4),
+        SWITCH_CODEC_FLAG_FREE_POOL = (1 &lt;&lt; 5),
+        SWITCH_CODEC_FLAG_AAL2 = (1 &lt;&lt; 6),
+        SWITCH_CODEC_FLAG_PASSTHROUGH = (1 &lt;&lt; 7),
+        SWITCH_CODEC_FLAG_READY = (1 &lt;&lt; 8)
+} switch_codec_flag_enum_t;
+typedef uint32_t switch_codec_flag_t;
+
+
+/*!
+  \enum switch_speech_flag_t
+  \brief Speech related flags
+&lt;pre&gt;
+SWITCH_SPEECH_FLAG_HASTEXT =                (1 &lt;&lt;  0) - Interface is has text to read.
+SWITCH_SPEECH_FLAG_PEEK =                        (1 &lt;&lt;  1) - Read data but do not erase it.
+SWITCH_SPEECH_FLAG_FREE_POOL =                (1 &lt;&lt;  2) - Free interface's pool on destruction.
+SWITCH_SPEECH_FLAG_BLOCKING =       (1 &lt;&lt;  3) - Indicate that a blocking call is desired 
+SWITCH_SPEECH_FLAG_PAUSE =                         (1 &lt;&lt;  4) - Pause toggle for playback
+&lt;/pre&gt;
+*/
+typedef enum {
+        SWITCH_SPEECH_FLAG_NONE = 0,
+        SWITCH_SPEECH_FLAG_HASTEXT = (1 &lt;&lt; 0),
+        SWITCH_SPEECH_FLAG_PEEK = (1 &lt;&lt; 1),
+        SWITCH_SPEECH_FLAG_FREE_POOL = (1 &lt;&lt; 2),
+        SWITCH_SPEECH_FLAG_BLOCKING = (1 &lt;&lt; 3),
+        SWITCH_SPEECH_FLAG_PAUSE = (1 &lt;&lt; 4),
+        SWITCH_SPEECH_FLAG_OPEN = (1 &lt;&lt; 5),
+        SWITCH_SPEECH_FLAG_DONE = (1 &lt;&lt; 6)
+} switch_speech_flag_enum_t;
+typedef uint32_t switch_speech_flag_t;
+
+/*!
+  \enum switch_asr_flag_t
+  \brief Asr related flags
+&lt;pre&gt;
+SWITCH_ASR_FLAG_DATA =                        (1 &lt;&lt;  0) - Interface has data
+SWITCH_ASR_FLAG_FREE_POOL =                (1 &lt;&lt;  1) - Pool needs to be freed
+SWITCH_ASR_FLAG_CLOSED =                 (1 &lt;&lt;  2) - Interface has been closed
+SWITCH_ASR_FLAG_FIRE_EVENTS =        (1 &lt;&lt;  3) - Fire all speech events
+SWITCH_ASR_FLAG_AUTO_RESUME =   (1 &lt;&lt;  4) - Auto Resume
+&lt;/pre&gt;
+*/
+typedef enum {
+        SWITCH_ASR_FLAG_NONE = 0,
+        SWITCH_ASR_FLAG_DATA = (1 &lt;&lt; 0),
+        SWITCH_ASR_FLAG_FREE_POOL = (1 &lt;&lt; 1),
+        SWITCH_ASR_FLAG_CLOSED = (1 &lt;&lt; 2),
+        SWITCH_ASR_FLAG_FIRE_EVENTS = (1 &lt;&lt; 3),
+        SWITCH_ASR_FLAG_AUTO_RESUME = (1 &lt;&lt; 4)
+
+} switch_asr_flag_enum_t;
+typedef uint32_t switch_asr_flag_t;
+
+/*!
+  \enum switch_directory_flag_t
+  \brief Directory Handle related flags
+&lt;pre&gt;
+SWITCH_DIRECTORY_FLAG_FREE_POOL =                (1 &lt;&lt;  0) - Free interface's pool on destruction.
+&lt;/pre&gt;
+*/
+typedef enum {
+        SWITCH_DIRECTORY_FLAG_FREE_POOL = (1 &lt;&lt; 0)
+
+} switch_directory_flag_enum_t;
+typedef uint32_t switch_directory_flag_t;
+
+/*!
+  \enum switch_codec_type_t
+  \brief Codec types
+&lt;pre&gt;
+SWITCH_CODEC_TYPE_AUDIO - Audio Codec
+SWITCH_CODEC_TYPE_VIDEO - Video Codec
+SWITCH_CODEC_TYPE_T38   - T38 Codec
+SWITCH_CODEC_TYPE_APP   - Application Codec
+&lt;/pre&gt;
+ */
+typedef enum {
+        SWITCH_CODEC_TYPE_AUDIO,
+        SWITCH_CODEC_TYPE_VIDEO,
+        SWITCH_CODEC_TYPE_T38,
+        SWITCH_CODEC_TYPE_APP
+} switch_codec_type_t;
+
+
+/*!
+  \enum switch_timer_flag_t
+  \brief Timer related flags
+&lt;pre&gt;
+SWITCH_TIMER_FLAG_FREE_POOL =                (1 &lt;&lt;  0) - Free timer's pool on destruction
+&lt;/pre&gt;
+*/
+typedef enum {
+        SWITCH_TIMER_FLAG_FREE_POOL = (1 &lt;&lt; 0)
+} switch_timer_flag_enum_t;
+typedef uint32_t switch_timer_flag_t;
+
+
+/*!
+  \enum switch_timer_flag_t
+  \brief Timer related flags
+&lt;pre&gt;
+SMBF_READ_STREAM - Include the Read Stream
+SMBF_WRITE_STREAM - Include the Write Stream
+SMBF_WRITE_REPLACE - Replace the Write Stream
+SMBF_READ_REPLACE - Replace the Read Stream
+SMBF_STEREO - Record in stereo
+SMBF_ANSWER_RECORD_REQ - Don't record until the channel is answered
+SMBF_THREAD_LOCK - Only let the same thread who created the bug remove it.
+&lt;/pre&gt;
+*/
+typedef enum {
+        SMBF_BOTH = 0,
+        SMBF_READ_STREAM = (1 &lt;&lt; 0),
+        SMBF_WRITE_STREAM = (1 &lt;&lt; 1),
+        SMBF_WRITE_REPLACE = (1 &lt;&lt; 2),
+        SMBF_READ_REPLACE = (1 &lt;&lt; 3),
+        SMBF_READ_PING = (1 &lt;&lt; 4),
+        SMBF_STEREO = (1 &lt;&lt; 5),
+        SMBF_ANSWER_REQ = (1 &lt;&lt; 6),
+        SMBF_THREAD_LOCK = (1 &lt;&lt; 7),
+        SMBF_PRUNE = (1 &lt;&lt; 8)
+} switch_media_bug_flag_enum_t;
+typedef uint32_t switch_media_bug_flag_t;
+
+/*!
+  \enum switch_file_flag_t
+  \brief File flags
+&lt;pre&gt;
+SWITCH_FILE_FLAG_READ =         (1 &lt;&lt;  0) - Open for read
+SWITCH_FILE_FLAG_WRITE =        (1 &lt;&lt;  1) - Open for write
+SWITCH_FILE_FLAG_FREE_POOL =    (1 &lt;&lt;  2) - Free file handle's pool on destruction
+SWITCH_FILE_DATA_SHORT =        (1 &lt;&lt;  3) - Read data in shorts
+SWITCH_FILE_DATA_INT =          (1 &lt;&lt;  4) - Read data in ints
+SWITCH_FILE_DATA_FLOAT =        (1 &lt;&lt;  5) - Read data in floats
+SWITCH_FILE_DATA_DOUBLE =       (1 &lt;&lt;  6) - Read data in doubles
+SWITCH_FILE_DATA_RAW =          (1 &lt;&lt;  7) - Read data as is
+SWITCH_FILE_PAUSE =             (1 &lt;&lt;  8) - Pause
+SWITCH_FILE_NATIVE =            (1 &lt;&lt;  9) - File is in native format (no transcoding)
+SWITCH_FILE_SEEK =                                 (1 &lt;&lt; 10) - File has done a seek
+SWITCH_FILE_OPEN =              (1 &lt;&lt; 11) - File is open
+&lt;/pre&gt;
+ */
+typedef enum {
+        SWITCH_FILE_FLAG_READ = (1 &lt;&lt; 0),
+        SWITCH_FILE_FLAG_WRITE = (1 &lt;&lt; 1),
+        SWITCH_FILE_FLAG_FREE_POOL = (1 &lt;&lt; 2),
+        SWITCH_FILE_DATA_SHORT = (1 &lt;&lt; 3),
+        SWITCH_FILE_DATA_INT = (1 &lt;&lt; 4),
+        SWITCH_FILE_DATA_FLOAT = (1 &lt;&lt; 5),
+        SWITCH_FILE_DATA_DOUBLE = (1 &lt;&lt; 6),
+        SWITCH_FILE_DATA_RAW = (1 &lt;&lt; 7),
+        SWITCH_FILE_PAUSE = (1 &lt;&lt; 8),
+        SWITCH_FILE_NATIVE = (1 &lt;&lt; 9),
+        SWITCH_FILE_SEEK = (1 &lt;&lt; 10),
+        SWITCH_FILE_OPEN = (1 &lt;&lt; 11),
+        SWITCH_FILE_CALLBACK = (1 &lt;&lt; 12),
+        SWITCH_FILE_DONE = (1 &lt;&lt; 13),
+        SWITCH_FILE_BUFFER_DONE = (1 &lt;&lt; 14),
+        SWITCH_FILE_WRITE_APPEND = (1 &lt;&lt; 15)
+} switch_file_flag_enum_t;
+typedef uint32_t switch_file_flag_t;
+
+typedef enum {
+        SWITCH_IO_FLAG_NONE = 0,
+        SWITCH_IO_FLAG_NOBLOCK = (1 &lt;&lt; 0)
+} switch_io_flag_enum_t;
+typedef uint32_t switch_io_flag_t;
+
+/* make sure this is synced with the EVENT_NAMES array in switch_event.c
+   also never put any new ones before EVENT_ALL
+*/
+/*!
+  \enum switch_event_types_t
+  \brief Built-in Events
+
+&lt;pre&gt;
+    SWITCH_EVENT_CUSTOM                                - A custom event
+    SWITCH_EVENT_CHANNEL_CREATE                - A channel has been created
+    SWITCH_EVENT_CHANNEL_DESTROY        - A channel has been destroyed
+    SWITCH_EVENT_CHANNEL_STATE                - A channel has changed state
+    SWITCH_EVENT_CHANNEL_ANSWER                - A channel has been answered
+    SWITCH_EVENT_CHANNEL_HANGUP                - A channel has been hungup
+    SWITCH_EVENT_CHANNEL_EXECUTE        - A channel has executed a module's application
+    SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE        - A channel has finshed executing a module's application
+        SWITCH_EVENT_CHANNEL_BRIDGE     - A channel has bridged to another channel
+        SWITCH_EVENT_CHANNEL_UNBRIDGE   - A channel has unbridged from another channel
+    SWITCH_EVENT_CHANNEL_PROGRESS        - A channel has started ringing
+    SWITCH_EVENT_CHANNEL_PROGRESS_MEDIA        - A channel has started early media
+    SWITCH_EVENT_CHANNEL_OUTGOING        - A channel has been unparked
+        SWITCH_EVENT_CHANNEL_PARK                 - A channel has been parked
+        SWITCH_EVENT_CHANNEL_UNPARK         - A channel has been unparked
+        SWITCH_EVENT_CHANNEL_APPLICATION- A channel has called and event from an application
+        SWITCH_EVENT_CHANNEL_ORIGINATE  - A channel has been originated
+        SWITCH_EVENT_CHANNEL_UUID       - A channel has changed uuid
+    SWITCH_EVENT_API                                - An API call has been executed
+    SWITCH_EVENT_LOG                                - A LOG event has been triggered
+    SWITCH_EVENT_INBOUND_CHAN                - A new inbound channel has been created
+    SWITCH_EVENT_OUTBOUND_CHAN                - A new outbound channel has been created
+    SWITCH_EVENT_STARTUP                        - The system has been started
+    SWITCH_EVENT_SHUTDOWN                        - The system has been shutdown
+        SWITCH_EVENT_PUBLISH                        - Publish
+        SWITCH_EVENT_UNPUBLISH                        - UnPublish
+        SWITCH_EVENT_TALK                                - Talking Detected
+        SWITCH_EVENT_NOTALK                                - Not Talking Detected
+        SWITCH_EVENT_SESSION_CRASH                - Session Crashed
+        SWITCH_EVENT_MODULE_LOAD                - Module was loaded
+        SWITCH_EVENT_MODULE_UNLOAD                - Module was unloaded
+        SWITCH_EVENT_DTMF                                - DTMF was sent
+        SWITCH_EVENT_MESSAGE                        - A Basic Message
+        SWITCH_EVENT_PRESENCE_IN                - Presence in
+        SWITCH_EVENT_NOTIFY_IN                        - Received incoming NOTIFY from gateway subscription
+        SWITCH_EVENT_PRESENCE_OUT                - Presence out
+        SWITCH_EVENT_PRESENCE_PROBE                - Presence probe
+        SWITCH_EVENT_MESSAGE_WAITING        - A message is waiting
+        SWITCH_EVENT_MESSAGE_QUERY                - A query for MESSAGE_WAITING events
+        SWITCH_EVENT_CODEC                                - Codec Change
+        SWITCH_EVENT_BACKGROUND_JOB                - Background Job
+        SWITCH_EVENT_DETECTED_SPEECH        - Detected Speech
+        SWITCH_EVENT_DETECTED_TONE      - Detected Tone
+        SWITCH_EVENT_PRIVATE_COMMAND        - A private command event 
+        SWITCH_EVENT_HEARTBEAT                        - Machine is alive
+        SWITCH_EVENT_TRAP                                - Error Trap
+        SWITCH_EVENT_ADD_SCHEDULE                - Something has been scheduled
+        SWITCH_EVENT_DEL_SCHEDULE                - Something has been unscheduled
+        SWITCH_EVENT_EXE_SCHEDULE                - Something scheduled has been executed
+        SWITCH_EVENT_RE_SCHEDULE                - Something scheduled has been rescheduled
+        SWITCH_EVENT_RELOADXML                        - XML registry has been reloaded
+        SWITCH_EVENT_NOTIFY                                - Notification
+        SWITCH_EVENT_SEND_MESSAGE                - Message
+        SWITCH_EVENT_RECV_MESSAGE                - Message
+        SWITCH_EVENT_NAT            - NAT Management (new/del/status)
+        SWITCH_EVENT_FAILURE            - A failure occurred which might impact the normal functioning of the switch
+    SWITCH_EVENT_ALL                                - All events at once
+&lt;/pre&gt;
+
+ */
+typedef enum {
+        SWITCH_EVENT_CUSTOM,
+        SWITCH_EVENT_CLONE,
+        SWITCH_EVENT_CHANNEL_CREATE,
+        SWITCH_EVENT_CHANNEL_DESTROY,
+        SWITCH_EVENT_CHANNEL_STATE,
+        SWITCH_EVENT_CHANNEL_ANSWER,
+        SWITCH_EVENT_CHANNEL_HANGUP,
+        SWITCH_EVENT_CHANNEL_HANGUP_COMPLETE,
+        SWITCH_EVENT_CHANNEL_EXECUTE,
+        SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE,
+        SWITCH_EVENT_CHANNEL_BRIDGE,
+        SWITCH_EVENT_CHANNEL_UNBRIDGE,
+        SWITCH_EVENT_CHANNEL_PROGRESS,
+        SWITCH_EVENT_CHANNEL_PROGRESS_MEDIA,
+        SWITCH_EVENT_CHANNEL_OUTGOING,
+        SWITCH_EVENT_CHANNEL_PARK,
+        SWITCH_EVENT_CHANNEL_UNPARK,
+        SWITCH_EVENT_CHANNEL_APPLICATION,
+        SWITCH_EVENT_CHANNEL_ORIGINATE,
+        SWITCH_EVENT_CHANNEL_UUID,
+        SWITCH_EVENT_API,
+        SWITCH_EVENT_LOG,
+        SWITCH_EVENT_INBOUND_CHAN,
+        SWITCH_EVENT_OUTBOUND_CHAN,
+        SWITCH_EVENT_STARTUP,
+        SWITCH_EVENT_SHUTDOWN,
+        SWITCH_EVENT_PUBLISH,
+        SWITCH_EVENT_UNPUBLISH,
+        SWITCH_EVENT_TALK,
+        SWITCH_EVENT_NOTALK,
+        SWITCH_EVENT_SESSION_CRASH,
+        SWITCH_EVENT_MODULE_LOAD,
+        SWITCH_EVENT_MODULE_UNLOAD,
+        SWITCH_EVENT_DTMF,
+        SWITCH_EVENT_MESSAGE,
+        SWITCH_EVENT_PRESENCE_IN,
+        SWITCH_EVENT_NOTIFY_IN,
+        SWITCH_EVENT_PRESENCE_OUT,
+        SWITCH_EVENT_PRESENCE_PROBE,
+        SWITCH_EVENT_MESSAGE_WAITING,
+        SWITCH_EVENT_MESSAGE_QUERY,
+        SWITCH_EVENT_ROSTER,
+        SWITCH_EVENT_CODEC,
+        SWITCH_EVENT_BACKGROUND_JOB,
+        SWITCH_EVENT_DETECTED_SPEECH,
+        SWITCH_EVENT_DETECTED_TONE,
+        SWITCH_EVENT_PRIVATE_COMMAND,
+        SWITCH_EVENT_HEARTBEAT,
+        SWITCH_EVENT_TRAP,
+        SWITCH_EVENT_ADD_SCHEDULE,
+        SWITCH_EVENT_DEL_SCHEDULE,
+        SWITCH_EVENT_EXE_SCHEDULE,
+        SWITCH_EVENT_RE_SCHEDULE,
+        SWITCH_EVENT_RELOADXML,
+        SWITCH_EVENT_NOTIFY,
+        SWITCH_EVENT_SEND_MESSAGE,
+        SWITCH_EVENT_RECV_MESSAGE,
+        SWITCH_EVENT_REQUEST_PARAMS,
+        SWITCH_EVENT_CHANNEL_DATA,
+        SWITCH_EVENT_GENERAL,
+        SWITCH_EVENT_COMMAND,
+        SWITCH_EVENT_SESSION_HEARTBEAT,
+        SWITCH_EVENT_CLIENT_DISCONNECTED,
+        SWITCH_EVENT_SERVER_DISCONNECTED,
+        SWITCH_EVENT_SEND_INFO,
+        SWITCH_EVENT_RECV_INFO,
+        SWITCH_EVENT_RECV_RTCP_MESSAGE,
+        SWITCH_EVENT_CALL_SECURE,
+        SWITCH_EVENT_NAT,
+        SWITCH_EVENT_RECORD_START,
+        SWITCH_EVENT_RECORD_STOP,
+        SWITCH_EVENT_CALL_UPDATE,
+        SWITCH_EVENT_FAILURE,
+        SWITCH_EVENT_SOCKET_DATA,
+        SWITCH_EVENT_MEDIA_BUG_START,
+        SWITCH_EVENT_MEDIA_BUG_STOP,
+        SWITCH_EVENT_ALL
+} switch_event_types_t;
+
+typedef enum {
+        SWITCH_INPUT_TYPE_DTMF,
+        SWITCH_INPUT_TYPE_EVENT
+} switch_input_type_t;
+
+typedef enum {
+        SWITCH_CAUSE_NONE = 0,
+        SWITCH_CAUSE_UNALLOCATED_NUMBER = 1,
+        SWITCH_CAUSE_NO_ROUTE_TRANSIT_NET = 2,
+        SWITCH_CAUSE_NO_ROUTE_DESTINATION = 3,
+        SWITCH_CAUSE_CHANNEL_UNACCEPTABLE = 6,
+        SWITCH_CAUSE_CALL_AWARDED_DELIVERED = 7,
+        SWITCH_CAUSE_NORMAL_CLEARING = 16,
+        SWITCH_CAUSE_USER_BUSY = 17,
+        SWITCH_CAUSE_NO_USER_RESPONSE = 18,
+        SWITCH_CAUSE_NO_ANSWER = 19,
+        SWITCH_CAUSE_SUBSCRIBER_ABSENT = 20,
+        SWITCH_CAUSE_CALL_REJECTED = 21,
+        SWITCH_CAUSE_NUMBER_CHANGED = 22,
+        SWITCH_CAUSE_REDIRECTION_TO_NEW_DESTINATION = 23,
+        SWITCH_CAUSE_EXCHANGE_ROUTING_ERROR = 25,
+        SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER = 27,
+        SWITCH_CAUSE_INVALID_NUMBER_FORMAT = 28,
+        SWITCH_CAUSE_FACILITY_REJECTED = 29,
+        SWITCH_CAUSE_RESPONSE_TO_STATUS_ENQUIRY = 30,
+        SWITCH_CAUSE_NORMAL_UNSPECIFIED = 31,
+        SWITCH_CAUSE_NORMAL_CIRCUIT_CONGESTION = 34,
+        SWITCH_CAUSE_NETWORK_OUT_OF_ORDER = 38,
+        SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE = 41,
+        SWITCH_CAUSE_SWITCH_CONGESTION = 42,
+        SWITCH_CAUSE_ACCESS_INFO_DISCARDED = 43,
+        SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL = 44,
+        SWITCH_CAUSE_PRE_EMPTED = 45,
+        SWITCH_CAUSE_FACILITY_NOT_SUBSCRIBED = 50,
+        SWITCH_CAUSE_OUTGOING_CALL_BARRED = 52,
+        SWITCH_CAUSE_INCOMING_CALL_BARRED = 54,
+        SWITCH_CAUSE_BEARERCAPABILITY_NOTAUTH = 57,
+        SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL = 58,
+        SWITCH_CAUSE_SERVICE_UNAVAILABLE = 63,
+        SWITCH_CAUSE_BEARERCAPABILITY_NOTIMPL = 65,
+        SWITCH_CAUSE_CHAN_NOT_IMPLEMENTED = 66,
+        SWITCH_CAUSE_FACILITY_NOT_IMPLEMENTED = 69,
+        SWITCH_CAUSE_SERVICE_NOT_IMPLEMENTED = 79,
+        SWITCH_CAUSE_INVALID_CALL_REFERENCE = 81,
+        SWITCH_CAUSE_INCOMPATIBLE_DESTINATION = 88,
+        SWITCH_CAUSE_INVALID_MSG_UNSPECIFIED = 95,
+        SWITCH_CAUSE_MANDATORY_IE_MISSING = 96,
+        SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST = 97,
+        SWITCH_CAUSE_WRONG_MESSAGE = 98,
+        SWITCH_CAUSE_IE_NONEXIST = 99,
+        SWITCH_CAUSE_INVALID_IE_CONTENTS = 100,
+        SWITCH_CAUSE_WRONG_CALL_STATE = 101,
+        SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE = 102,
+        SWITCH_CAUSE_MANDATORY_IE_LENGTH_ERROR = 103,
+        SWITCH_CAUSE_PROTOCOL_ERROR = 111,
+        SWITCH_CAUSE_INTERWORKING = 127,
+        SWITCH_CAUSE_SUCCESS = 142,
+        SWITCH_CAUSE_ORIGINATOR_CANCEL = 487,
+        SWITCH_CAUSE_CRASH = 500,
+        SWITCH_CAUSE_SYSTEM_SHUTDOWN = 501,
+        SWITCH_CAUSE_LOSE_RACE = 502,
+        SWITCH_CAUSE_MANAGER_REQUEST = 503,
+        SWITCH_CAUSE_BLIND_TRANSFER = 600,
+        SWITCH_CAUSE_ATTENDED_TRANSFER = 601,
+        SWITCH_CAUSE_ALLOTTED_TIMEOUT = 602,
+        SWITCH_CAUSE_USER_CHALLENGE = 603,
+        SWITCH_CAUSE_MEDIA_TIMEOUT = 604,
+        SWITCH_CAUSE_PICKED_OFF = 605,
+        SWITCH_CAUSE_USER_NOT_REGISTERED = 606,
+        SWITCH_CAUSE_PROGRESS_TIMEOUT = 607
+} switch_call_cause_t;
+
+typedef enum {
+        SCSC_PAUSE_INBOUND,
+        SCSC_HUPALL,
+        SCSC_SHUTDOWN,
+        SCSC_CHECK_RUNNING,
+        SCSC_LOGLEVEL,
+        SCSC_SPS,
+        SCSC_LAST_SPS,
+        SCSC_RECLAIM,
+        SCSC_MAX_SESSIONS,
+        SCSC_SYNC_CLOCK,
+        SCSC_MAX_DTMF_DURATION,
+        SCSC_MIN_DTMF_DURATION,
+        SCSC_DEFAULT_DTMF_DURATION,
+        SCSC_SHUTDOWN_ELEGANT,
+        SCSC_SHUTDOWN_ASAP,
+        SCSC_CANCEL_SHUTDOWN,
+        SCSC_SEND_SIGHUP,
+        SCSC_DEBUG_LEVEL,
+        SCSC_FLUSH_DB_HANDLES,
+        SCSC_SHUTDOWN_NOW,
+        SCSC_CALIBRATE_CLOCK,
+        SCSC_SAVE_HISTORY,
+        SCSC_CRASH,
+        SCSC_MIN_IDLE_CPU
+} switch_session_ctl_t;
+
+typedef enum {
+        SSH_FLAG_STICKY = (1 &lt;&lt; 0)
+} switch_state_handler_flag_t;
+
+typedef struct apr_pool_t switch_memory_pool_t;
+typedef uint16_t switch_port_t;
+typedef uint8_t switch_payload_t;
+typedef struct switch_app_log switch_app_log_t;
+typedef struct switch_rtp switch_rtp_t;
+typedef struct switch_rtcp switch_rtcp_t;
+typedef struct switch_core_session_message switch_core_session_message_t;
+typedef struct switch_event_header switch_event_header_t;
+typedef struct switch_event switch_event_t;
+typedef struct switch_event_subclass switch_event_subclass_t;
+typedef struct switch_event_node switch_event_node_t;
+typedef struct switch_loadable_module switch_loadable_module_t;
+typedef struct switch_frame switch_frame_t;
+typedef struct switch_rtcp_frame switch_rtcp_frame_t;
+typedef struct switch_channel switch_channel_t;
+typedef struct switch_file_handle switch_file_handle_t;
+typedef struct switch_core_session switch_core_session_t;
+typedef struct switch_caller_profile switch_caller_profile_t;
+typedef struct switch_caller_extension switch_caller_extension_t;
+typedef struct switch_caller_application switch_caller_application_t;
+typedef struct switch_state_handler_table switch_state_handler_table_t;
+typedef struct switch_timer switch_timer_t;
+typedef struct switch_codec switch_codec_t;
+typedef struct switch_core_thread_session switch_core_thread_session_t;
+typedef struct switch_codec_implementation switch_codec_implementation_t;
+typedef struct switch_buffer switch_buffer_t;
+typedef struct switch_codec_settings switch_codec_settings_t;
+typedef struct switch_odbc_handle switch_odbc_handle_t;
+
+typedef struct switch_io_routines switch_io_routines_t;
+typedef struct switch_speech_handle switch_speech_handle_t;
+typedef struct switch_asr_handle switch_asr_handle_t;
+typedef struct switch_directory_handle switch_directory_handle_t;
+typedef struct switch_loadable_module_interface switch_loadable_module_interface_t;
+typedef struct switch_endpoint_interface switch_endpoint_interface_t;
+typedef struct switch_timer_interface switch_timer_interface_t;
+typedef struct switch_dialplan_interface switch_dialplan_interface_t;
+typedef struct switch_codec_interface switch_codec_interface_t;
+typedef struct switch_application_interface switch_application_interface_t;
+typedef struct switch_api_interface switch_api_interface_t;
+typedef struct switch_file_interface switch_file_interface_t;
+typedef struct switch_speech_interface switch_speech_interface_t;
+typedef struct switch_asr_interface switch_asr_interface_t;
+typedef struct switch_directory_interface switch_directory_interface_t;
+typedef struct switch_chat_interface switch_chat_interface_t;
+typedef struct switch_management_interface switch_management_interface_t;
+typedef struct switch_core_port_allocator switch_core_port_allocator_t;
+typedef struct switch_media_bug switch_media_bug_t;
+
+struct switch_console_callback_match_node {
+        char *val;
+        struct switch_console_callback_match_node *next;
+};
+typedef struct switch_console_callback_match_node switch_console_callback_match_node_t;
+
+struct switch_console_callback_match {
+        struct switch_console_callback_match_node *head;
+        struct switch_console_callback_match_node *end;
+        int count;
+        int dynamic;
+};
+typedef struct switch_console_callback_match switch_console_callback_match_t;
+
+typedef switch_status_t (*switch_console_complete_callback_t) (const char *, const char *, switch_console_callback_match_t **matches);
+typedef switch_bool_t (*switch_media_bug_callback_t) (switch_media_bug_t *, void *, switch_abc_type_t);
+typedef switch_bool_t (*switch_tone_detect_callback_t) (switch_core_session_t *, const char *, const char *);
+typedef struct switch_xml_binding switch_xml_binding_t;
+
+typedef switch_status_t (*switch_core_codec_encode_func_t) (switch_codec_t *codec,
+                                                                                                                        switch_codec_t *other_codec,
+                                                                                                                        void *decoded_data,
+                                                                                                                        uint32_t decoded_data_len,
+                                                                                                                        uint32_t decoded_rate,
+                                                                                                                        void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag);
+
+
+typedef switch_status_t (*switch_core_codec_decode_func_t) (switch_codec_t *codec,
+                                                                                                                        switch_codec_t *other_codec,
+                                                                                                                        void *encoded_data,
+                                                                                                                        uint32_t encoded_data_len,
+                                                                                                                        uint32_t encoded_rate,
+                                                                                                                        void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag);
+
+typedef switch_status_t (*switch_core_codec_init_func_t) (switch_codec_t *, switch_codec_flag_t, const switch_codec_settings_t *codec_settings);
+typedef switch_status_t (*switch_core_codec_destroy_func_t) (switch_codec_t *);
+
+
+
+
+typedef void (*switch_application_function_t) (switch_core_session_t *, const char *);
+#define SWITCH_STANDARD_APP(name) static void name (switch_core_session_t *session, const char *data)
+
+typedef void (*switch_event_callback_t) (switch_event_t *);
+typedef switch_caller_extension_t *(*switch_dialplan_hunt_function_t) (switch_core_session_t *, void *, switch_caller_profile_t *);
+#define SWITCH_STANDARD_DIALPLAN(name) static switch_caller_extension_t *name (switch_core_session_t *session, void *arg, switch_caller_profile_t *caller_profile)
+
+typedef switch_bool_t (*switch_hash_delete_callback_t) (_In_ const void *key, _In_ const void *val, _In_opt_ void *pData);
+#define SWITCH_HASH_DELETE_FUNC(name) static switch_bool_t name (const void *key, const void *val, void *pData)
+
+typedef struct switch_scheduler_task switch_scheduler_task_t;
+
+typedef void (*switch_scheduler_func_t) (switch_scheduler_task_t *task);
+
+#define SWITCH_STANDARD_SCHED_FUNC(name) static void name (switch_scheduler_task_t *task)
+
+typedef switch_status_t (*switch_state_handler_t) (switch_core_session_t *);
+typedef struct switch_stream_handle switch_stream_handle_t;
+typedef switch_status_t (*switch_stream_handle_write_function_t) (switch_stream_handle_t *handle, const char *fmt, ...);
+typedef switch_status_t (*switch_stream_handle_raw_write_function_t) (switch_stream_handle_t *handle, uint8_t *data, switch_size_t datalen);
+
+typedef switch_status_t (*switch_api_function_t) (_In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session,
+                                                                                                  _In_ switch_stream_handle_t *stream);
+
+#define SWITCH_STANDARD_API(name) static switch_status_t name (_In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session, _In_ switch_stream_handle_t *stream)
+
+typedef switch_status_t (*switch_input_callback_function_t) (switch_core_session_t *session, void *input,
+                                                                                                                         switch_input_type_t input_type, void *buf, unsigned int buflen);
+typedef switch_status_t (*switch_read_frame_callback_function_t) (switch_core_session_t *session, switch_frame_t *frame, void *user_data);
+typedef struct switch_say_interface switch_say_interface_t;
+typedef struct {
+        switch_input_callback_function_t input_callback;
+        void *buf;
+        uint32_t buflen;
+        switch_read_frame_callback_function_t read_frame_callback;
+        void *user_data;
+} switch_input_args_t;
+
+typedef struct {
+        switch_say_type_t type;
+        switch_say_method_t method;
+        switch_say_gender_t gender;
+} switch_say_args_t;
+
+typedef switch_status_t (*switch_say_callback_t) (switch_core_session_t *session,
+                                                                                                  char *tosay,
+                                                                                                  switch_say_args_t *say_args,
+                                                                                                  switch_input_args_t *args);
+
+typedef struct switch_xml *switch_xml_t;
+typedef struct switch_core_time_duration switch_core_time_duration_t;
+typedef switch_xml_t(*switch_xml_search_function_t) (const char *section,
+                                                                                                         const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params,
+                                                                                                         void *user_data);
+
+typedef struct switch_hash switch_hash_t;
+struct HashElem;
+typedef struct HashElem switch_hash_index_t;
+
+struct switch_network_list;
+typedef struct switch_network_list switch_network_list_t;
+
+
+#define SWITCH_API_VERSION 4
+#define SWITCH_MODULE_LOAD_ARGS (switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool)
+#define SWITCH_MODULE_RUNTIME_ARGS (void)
+#define SWITCH_MODULE_SHUTDOWN_ARGS (void)
+typedef switch_status_t (*switch_module_load_t) SWITCH_MODULE_LOAD_ARGS;
+typedef switch_status_t (*switch_module_runtime_t) SWITCH_MODULE_RUNTIME_ARGS;
+typedef switch_status_t (*switch_module_shutdown_t) SWITCH_MODULE_SHUTDOWN_ARGS;
+#define SWITCH_MODULE_LOAD_FUNCTION(name) switch_status_t name SWITCH_MODULE_LOAD_ARGS
+#define SWITCH_MODULE_RUNTIME_FUNCTION(name) switch_status_t name SWITCH_MODULE_RUNTIME_ARGS
+#define SWITCH_MODULE_SHUTDOWN_FUNCTION(name) switch_status_t name SWITCH_MODULE_SHUTDOWN_ARGS
+
+typedef enum {
+        SMODF_NONE = 0,
+        SMODF_GLOBAL_SYMBOLS = (1 &lt;&lt; 0)
+} switch_module_flag_enum_t;
+typedef uint32_t switch_module_flag_t;
+
+typedef struct switch_loadable_module_function_table {
+        int switch_api_version;
+        switch_module_load_t load;
+        switch_module_shutdown_t shutdown;
+        switch_module_runtime_t runtime;
+        switch_module_flag_t flags;
+} switch_loadable_module_function_table_t;
+
+#define SWITCH_MODULE_DEFINITION_EX(name, load, shutdown, runtime, flags)                                        \
+static const char modname[] =  #name ;                                                                                                                \
+SWITCH_MOD_DECLARE_DATA switch_loadable_module_function_table_t name##_module_interface = {        \
+        SWITCH_API_VERSION,                                                                                                                                                \
+        load,                                                                                                                                                                        \
+        shutdown,                                                                                                                                                                \
+        runtime,                                                                                                                                                                \
+        flags                                                                                                                                                                        \
+}
+
+#define SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)                                                                \
+                SWITCH_MODULE_DEFINITION_EX(name, load, shutdown, runtime, SMODF_NONE)
+
+/* things we don't deserve to know about */
+/*! \brief A channel */
+struct switch_channel;
+/*! \brief A core session representing a call and all of it's resources */
+struct switch_core_session;
+/*! \brief An audio bug */
+struct switch_media_bug;
+/*! \brief A digit stream parser object */
+struct switch_ivr_digit_stream_parser;
+
+SWITCH_END_EXTERN_C
+#endif
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
+ */
</ins></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_conferencemod_conferencecorig"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c.orig (0 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c.orig                                (rev 0)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c.orig        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -0,0 +1,6343 @@
</span><ins>+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the &quot;License&quot;); 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 &quot;AS IS&quot; 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 &lt;anthm@freeswitch.org&gt;
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * 
+ * Anthony Minessale II &lt;anthm@freeswitch.org&gt;
+ * Neal Horman &lt;neal at wanlink dot com&gt;
+ * Bret McDanel &lt;trixter at 0xdecafbad dot com&gt;
+ * Dale Thatcher &lt;freeswitch at dalethatcher dot com&gt;
+ * Chris Danielson &lt;chris at maxpowersoft dot com&gt;
+ * Rupa Schomaker &lt;rupa@rupa.com&gt;
+ * David Weekly &lt;david@weekly.org&gt;
+ *
+ * mod_conference.c -- Software Conference Bridge
+ *
+ */
+#include &lt;switch.h&gt;
+//#define INTENSE_DEBUG
+SWITCH_MODULE_LOAD_FUNCTION(mod_conference_load);
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_conference_shutdown);
+SWITCH_MODULE_DEFINITION(mod_conference, mod_conference_load, mod_conference_shutdown, NULL);
+
+static const char global_app_name[] = &quot;conference&quot;;
+static char *global_cf_name = &quot;conference.conf&quot;;
+static char *cf_pin_url_param_name = &quot;X-ConfPin=&quot;;
+static char *api_syntax;
+static int EC = 0;
+
+/* Size to allocate for audio buffers */
+#define CONF_BUFFER_SIZE 1024 * 128
+#define CONF_EVENT_MAINT &quot;conference::maintenance&quot;
+#define CONF_DEFAULT_LEADIN 20
+
+#define CONF_DBLOCK_SIZE CONF_BUFFER_SIZE
+#define CONF_DBUFFER_SIZE CONF_BUFFER_SIZE
+#define CONF_DBUFFER_MAX 0
+#define CONF_CHAT_PROTO &quot;conf&quot;
+
+#ifndef MIN
+#define MIN(a, b) ((a)&lt;(b)?(a):(b))
+#endif
+
+/* the rate at which the infinite impulse response filter on speaker score will decay. */
+#define SCORE_DECAY 0.8
+/* the maximum value for the IIR score [keeps loud &amp; longwinded people from getting overweighted] */
+#define SCORE_MAX_IIR 25000
+/* the minimum score for which you can be considered to be loud enough to now have the floor */
+#define SCORE_IIR_SPEAKING_MAX 3000
+/* the threshold below which you cede the floor to someone loud (see above value). */
+#define SCORE_IIR_SPEAKING_MIN 100
+
+
+#define test_eflag(conference, flag) ((conference)-&gt;eflags &amp; flag)
+
+typedef enum {
+        FILE_STOP_CURRENT,
+        FILE_STOP_ALL,
+        FILE_STOP_ASYNC
+} file_stop_t;
+
+/* Global Values */
+static struct {
+        switch_memory_pool_t *conference_pool;
+        switch_mutex_t *conference_mutex;
+        switch_hash_t *conference_hash;
+        switch_mutex_t *id_mutex;
+        switch_mutex_t *hash_mutex;
+        switch_mutex_t *setup_mutex;
+        uint32_t id_pool;
+        int32_t running;
+        uint32_t threads;
+        switch_event_node_t *node;
+} globals;
+
+typedef enum {
+        CALLER_CONTROL_MUTE,
+        CALLER_CONTROL_MUTE_ON,
+        CALLER_CONTROL_MUTE_OFF,
+        CALLER_CONTROL_DEAF_MUTE,
+        CALLER_CONTROL_ENERGY_UP,
+        CALLER_CONTROL_ENERGY_EQU_CONF,
+        CALLER_CONTROL_ENERGEY_DN,
+        CALLER_CONTROL_VOL_TALK_UP,
+        CALLER_CONTROL_VOL_TALK_ZERO,
+        CALLER_CONTROL_VOL_TALK_DN,
+        CALLER_CONTROL_VOL_LISTEN_UP,
+        CALLER_CONTROL_VOL_LISTEN_ZERO,
+        CALLER_CONTROL_VOL_LISTEN_DN,
+        CALLER_CONTROL_HANGUP,
+        CALLER_CONTROL_MENU,
+        CALLER_CONTROL_DIAL,
+        CALLER_CONTROL_EVENT,
+        CALLER_CONTROL_LOCK,
+        CALLER_CONTROL_TRANSFER,
+        CALLER_CONTROL_EXEC_APP
+} caller_control_t;
+
+/* forward declaration for conference_obj and caller_control */
+struct conference_member;
+typedef struct conference_member conference_member_t;
+
+struct call_list {
+        char *string;
+        int itteration;
+        struct call_list *next;
+};
+typedef struct call_list call_list_t;
+
+struct caller_control_actions;
+
+typedef struct caller_control_fn_table {
+        char *key;
+        char *digits;
+        caller_control_t action;
+        void (*handler) (conference_member_t *, struct caller_control_actions *);
+} caller_control_fn_table_t;
+
+typedef struct caller_control_actions {
+        caller_control_fn_table_t *fndesc;
+        char *binded_dtmf;
+        void *data;
+} caller_control_action_t;
+
+typedef struct caller_control_menu_info {
+        switch_ivr_menu_t *stack;
+        char *name;
+} caller_control_menu_info_t;
+
+typedef enum {
+        MFLAG_RUNNING = (1 &lt;&lt; 0),
+        MFLAG_CAN_SPEAK = (1 &lt;&lt; 1),
+        MFLAG_CAN_HEAR = (1 &lt;&lt; 2),
+        MFLAG_KICKED = (1 &lt;&lt; 3),
+        MFLAG_ITHREAD = (1 &lt;&lt; 4),
+        MFLAG_NOCHANNEL = (1 &lt;&lt; 5),
+        MFLAG_INTREE = (1 &lt;&lt; 6),
+        MFLAG_WASTE_BANDWIDTH = (1 &lt;&lt; 7),
+        MFLAG_FLUSH_BUFFER = (1 &lt;&lt; 8),
+        MFLAG_ENDCONF = (1 &lt;&lt; 9),
+        MFLAG_HAS_AUDIO = (1 &lt;&lt; 10),
+        MFLAG_TALKING = (1 &lt;&lt; 11),
+        MFLAG_RESTART = (1 &lt;&lt; 12),
+        MFLAG_MINTWO = (1 &lt;&lt; 13),
+        MFLAG_MUTE_DETECT = (1 &lt;&lt; 14),
+        MFLAG_DIST_DTMF = (1 &lt;&lt; 15),
+        MFLAG_MOD = (1 &lt;&lt; 16)
+} member_flag_t;
+
+typedef enum {
+        CFLAG_RUNNING = (1 &lt;&lt; 0),
+        CFLAG_DYNAMIC = (1 &lt;&lt; 1),
+        CFLAG_ENFORCE_MIN = (1 &lt;&lt; 2),
+        CFLAG_DESTRUCT = (1 &lt;&lt; 3),
+        CFLAG_LOCKED = (1 &lt;&lt; 4),
+        CFLAG_ANSWERED = (1 &lt;&lt; 5),
+        CFLAG_BRIDGE_TO = (1 &lt;&lt; 6),
+        CFLAG_WAIT_MOD = (1 &lt;&lt; 7),
+        CFLAG_VID_FLOOR = (1 &lt;&lt; 8),
+        CFLAG_WASTE_BANDWIDTH = (1 &lt;&lt; 9)
+} conf_flag_t;
+
+typedef enum {
+        RFLAG_CAN_SPEAK = (1 &lt;&lt; 0),
+        RFLAG_CAN_HEAR = (1 &lt;&lt; 1)
+} relation_flag_t;
+
+typedef enum {
+        NODE_TYPE_FILE,
+        NODE_TYPE_SPEECH
+} node_type_t;
+
+typedef enum {
+        EFLAG_ADD_MEMBER = (1 &lt;&lt; 0),
+        EFLAG_DEL_MEMBER = (1 &lt;&lt; 1),
+        EFLAG_ENERGY_LEVEL = (1 &lt;&lt; 2),
+        EFLAG_VOLUME_LEVEL = (1 &lt;&lt; 3),
+        EFLAG_GAIN_LEVEL = (1 &lt;&lt; 4),
+        EFLAG_DTMF = (1 &lt;&lt; 5),
+        EFLAG_STOP_TALKING = (1 &lt;&lt; 6),
+        EFLAG_START_TALKING = (1 &lt;&lt; 7),
+        EFLAG_MUTE_MEMBER = (1 &lt;&lt; 8),
+        EFLAG_UNMUTE_MEMBER = (1 &lt;&lt; 9),
+        EFLAG_DEAF_MEMBER = (1 &lt;&lt; 10),
+        EFLAG_UNDEAF_MEMBER = (1 &lt;&lt; 11),
+        EFLAG_KICK_MEMBER = (1 &lt;&lt; 12),
+        EFLAG_DTMF_MEMBER = (1 &lt;&lt; 13),
+        EFLAG_ENERGY_LEVEL_MEMBER = (1 &lt;&lt; 14),
+        EFLAG_VOLUME_IN_MEMBER = (1 &lt;&lt; 15),
+        EFLAG_VOLUME_OUT_MEMBER = (1 &lt;&lt; 16),
+        EFLAG_PLAY_FILE = (1 &lt;&lt; 17),
+        EFLAG_PLAY_FILE_MEMBER = (1 &lt;&lt; 18),
+        EFLAG_SPEAK_TEXT = (1 &lt;&lt; 19),
+        EFLAG_SPEAK_TEXT_MEMBER = (1 &lt;&lt; 20),
+        EFLAG_LOCK = (1 &lt;&lt; 21),
+        EFLAG_UNLOCK = (1 &lt;&lt; 22),
+        EFLAG_TRANSFER = (1 &lt;&lt; 23),
+        EFLAG_BGDIAL_RESULT = (1 &lt;&lt; 24),
+        EFLAG_FLOOR_CHANGE = (1 &lt;&lt; 25),
+        EFLAG_MUTE_DETECT = (1 &lt;&lt; 26)
+} event_type_t;
+
+typedef struct conference_file_node {
+        switch_file_handle_t fh;
+        switch_speech_handle_t *sh;
+        node_type_t type;
+        uint8_t done;
+        uint8_t async;
+        switch_memory_pool_t *pool;
+        uint32_t leadin;
+        struct conference_file_node *next;
+        char *file;
+} conference_file_node_t;
+
+/* conference xml config sections */
+typedef struct conf_xml_cfg {
+        switch_xml_t profile;
+        switch_xml_t controls;
+} conf_xml_cfg_t;
+
+/* Conference Object */
+typedef struct conference_obj {
+        char *name;
+        char *timer_name;
+        char *tts_engine;
+        char *tts_voice;
+        char *enter_sound;
+        char *exit_sound;
+        char *alone_sound;
+        char *perpetual_sound;
+        char *moh_sound;
+        char *ack_sound;
+        char *nack_sound;
+        char *muted_sound;
+        char *mute_detect_sound;
+        char *unmuted_sound;
+        char *locked_sound;
+        char *is_locked_sound;
+        char *is_unlocked_sound;
+        char *kicked_sound;
+        char *caller_id_name;
+        char *caller_id_number;
+        char *sound_prefix;
+        char *special_announce;
+        char *auto_record;
+        uint32_t max_members;
+        char *maxmember_sound;
+        uint32_t announce_count;
+        switch_ivr_digit_stream_parser_t *dtmf_parser;
+        char *pin;
+        char *pin_sound;
+        char *bad_pin_sound;
+        char *profile_name;
+        char *domain;
+        uint32_t flags;
+        member_flag_t mflags;
+        switch_call_cause_t bridge_hangup_cause;
+        switch_mutex_t *flag_mutex;
+        uint32_t rate;
+        uint32_t interval;
+        switch_mutex_t *mutex;
+        conference_member_t *members;
+        conference_member_t *floor_holder;
+        switch_mutex_t *member_mutex;
+        conference_file_node_t *fnode;
+        conference_file_node_t *async_fnode;
+        switch_memory_pool_t *pool;
+        switch_thread_rwlock_t *rwlock;
+        uint32_t count;
+        int32_t energy_level;
+        uint8_t min;
+        switch_speech_handle_t lsh;
+        switch_speech_handle_t *sh;
+        switch_byte_t *not_talking_buf;
+        uint32_t not_talking_buf_len;
+        int comfort_noise_level;
+        int is_recording;
+        int video_running;
+        uint32_t eflags;
+        uint32_t verbose_events;
+        int end_count;
+        uint32_t relationship_total;
+} conference_obj_t;
+
+/* Relationship with another member */
+typedef struct conference_relationship {
+        uint32_t id;
+        uint32_t flags;
+        struct conference_relationship *next;
+} conference_relationship_t;
+
+/* Conference Member Object */
+struct conference_member {
+        uint32_t id;
+        switch_core_session_t *session;
+        conference_obj_t *conference;
+        switch_memory_pool_t *pool;
+        switch_buffer_t *audio_buffer;
+        switch_buffer_t *mux_buffer;
+        switch_buffer_t *resample_buffer;
+        uint32_t flags;
+        uint32_t score;
+        uint32_t score_iir;
+        switch_mutex_t *flag_mutex;
+        switch_mutex_t *write_mutex;
+        switch_mutex_t *audio_in_mutex;
+        switch_mutex_t *audio_out_mutex;
+        switch_mutex_t *read_mutex;
+        switch_codec_implementation_t orig_read_impl;
+        switch_codec_t read_codec;
+        switch_codec_t write_codec;
+        char *rec_path;
+        uint8_t *frame;
+        uint32_t frame_size;
+        uint8_t *mux_frame;
+        uint32_t read;
+        int32_t energy_level;
+        int32_t volume_in_level;
+        int32_t volume_out_level;
+        uint32_t native_rate;
+        switch_audio_resampler_t *read_resampler;
+        int16_t *resample_out;
+        uint32_t resample_out_len;
+        conference_file_node_t *fnode;
+        conference_relationship_t *relationships;
+        switch_ivr_digit_stream_parser_t *dtmf_parser;
+        switch_ivr_digit_stream_t *digit_stream;
+        switch_speech_handle_t lsh;
+        switch_speech_handle_t *sh;
+        uint32_t verbose_events;
+        struct conference_member *next;
+};
+
+/* Record Node */
+typedef struct conference_record {
+        conference_obj_t *conference;
+        char *path;
+        switch_memory_pool_t *pool;
+} conference_record_t;
+
+typedef enum {
+        CONF_API_SUB_ARGS_SPLIT,
+        CONF_API_SUB_MEMBER_TARGET,
+        CONF_API_SUB_ARGS_AS_ONE
+} conference_fntype_t;
+
+typedef void (*void_fn_t) (void);
+
+/* API command parser */
+typedef struct api_command {
+        char *pname;
+        void_fn_t pfnapicmd;
+        conference_fntype_t fntype;
+        char *psyntax;
+} api_command_t;
+
+/* Function Prototypes */
+static int setup_media(conference_member_t *member, conference_obj_t *conference);
+static uint32_t next_member_id(void);
+static conference_relationship_t *member_get_relationship(conference_member_t *member, conference_member_t *other_member);
+static conference_member_t *conference_member_get(conference_obj_t *conference, uint32_t id);
+static conference_relationship_t *member_add_relationship(conference_member_t *member, uint32_t id);
+static switch_status_t member_del_relationship(conference_member_t *member, uint32_t id);
+static switch_status_t conference_add_member(conference_obj_t *conference, conference_member_t *member);
+static switch_status_t conference_del_member(conference_obj_t *conference, conference_member_t *member);
+static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *obj);
+static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thread, void *obj);
+static void conference_loop_output(conference_member_t *member);
+static uint32_t conference_stop_file(conference_obj_t *conference, file_stop_t stop);
+static switch_status_t conference_play_file(conference_obj_t *conference, char *file, uint32_t leadin, switch_channel_t *channel, uint8_t async);
+static void conference_send_all_dtmf(conference_member_t *member, conference_obj_t *conference, const char *dtmf);
+static switch_status_t conference_say(conference_obj_t *conference, const char *text, uint32_t leadin);
+static void conference_list(conference_obj_t *conference, switch_stream_handle_t *stream, char *delim);
+static conference_obj_t *conference_find(char *name);
+
+SWITCH_STANDARD_API(conf_api_main);
+
+static switch_status_t conference_outcall(conference_obj_t *conference,
+                                                                                  char *conference_name,
+                                                                                  switch_core_session_t *session,
+                                                                                  char *bridgeto, uint32_t timeout, char *flags, char *cid_name, char *cid_num, switch_call_cause_t *cause);
+static switch_status_t conference_outcall_bg(conference_obj_t *conference,
+                                                                                         char *conference_name,
+                                                                                         switch_core_session_t *session, char *bridgeto, uint32_t timeout, const char *flags, const char *cid_name,
+                                                                                         const char *cid_num, const char *call_uuid);
+SWITCH_STANDARD_APP(conference_function);
+static void launch_conference_thread(conference_obj_t *conference);
+static void launch_conference_video_thread(conference_obj_t *conference);
+static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *obj);
+static switch_status_t conference_local_play_file(conference_obj_t *conference, switch_core_session_t *session, char *path, uint32_t leadin, void *buf,
+                                                                                                  uint32_t buflen);
+static switch_status_t conference_member_play_file(conference_member_t *member, char *file, uint32_t leadin);
+static switch_status_t conference_member_say(conference_member_t *member, char *text, uint32_t leadin);
+static uint32_t conference_member_stop_file(conference_member_t *member, file_stop_t stop);
+static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_memory_pool_t *pool);
+static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject,
+                                                                 const char *body, const char *type, const char *hint);
+
+static void launch_conference_record_thread(conference_obj_t *conference, char *path);
+
+typedef switch_status_t (*conf_api_args_cmd_t) (conference_obj_t *, switch_stream_handle_t *, int, char **);
+typedef switch_status_t (*conf_api_member_cmd_t) (conference_member_t *, switch_stream_handle_t *, void *);
+typedef switch_status_t (*conf_api_text_cmd_t) (conference_obj_t *, switch_stream_handle_t *, const char *);
+
+static void conference_member_itterator(conference_obj_t *conference, switch_stream_handle_t *stream, conf_api_member_cmd_t pfncallback, void *data);
+static switch_status_t conf_api_sub_mute(conference_member_t *member, switch_stream_handle_t *stream, void *data);
+static switch_status_t conf_api_sub_unmute(conference_member_t *member, switch_stream_handle_t *stream, void *data);
+static switch_status_t conf_api_sub_deaf(conference_member_t *member, switch_stream_handle_t *stream, void *data);
+static switch_status_t conf_api_sub_undeaf(conference_member_t *member, switch_stream_handle_t *stream, void *data);
+static switch_status_t conference_add_event_data(conference_obj_t *conference, switch_event_t *event);
+static switch_status_t conference_add_event_member_data(conference_member_t *member, switch_event_t *event);
+
+
+#define lock_member(_member) switch_mutex_lock(_member-&gt;write_mutex); switch_mutex_lock(_member-&gt;read_mutex)
+#define unlock_member(_member) switch_mutex_unlock(_member-&gt;read_mutex); switch_mutex_unlock(_member-&gt;write_mutex)
+
+//#define lock_member(_member) switch_mutex_lock(_member-&gt;write_mutex)
+//#define unlock_member(_member) switch_mutex_unlock(_member-&gt;write_mutex)
+
+static switch_status_t conference_add_event_data(conference_obj_t *conference, switch_event_t *event)
+{
+        switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Conference-Name&quot;, conference-&gt;name);
+        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Conference-Size&quot;, &quot;%u&quot;, conference-&gt;count);
+        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Conference-Profile-Name&quot;, conference-&gt;profile_name);
+
+        return status;
+}
+
+static switch_status_t conference_add_event_member_data(conference_member_t *member, switch_event_t *event)
+{
+        switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+        if (!member)
+                return status;
+
+        if (member-&gt;conference) {
+                status = conference_add_event_data(member-&gt;conference, event);
+        }
+
+        if (member-&gt;session) {
+                switch_channel_t *channel = switch_core_session_get_channel(member-&gt;session);
+
+                if (member-&gt;verbose_events) {
+                        switch_channel_event_set_data(channel, event);
+                } else {
+                        switch_channel_event_set_basic_data(channel, event);
+                }
+
+        }
+
+        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Member-ID&quot;, &quot;%u&quot;, member-&gt;id);
+        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Member-Type&quot;, &quot;%s&quot;, switch_test_flag(member, MFLAG_MOD) ? &quot;moderator&quot; : &quot;member&quot;);
+
+        return status;
+}
+
+/* Return a Distinct ID # */
+static uint32_t next_member_id(void)
+{
+        uint32_t id;
+
+        switch_mutex_lock(globals.id_mutex);
+        id = ++globals.id_pool;
+        switch_mutex_unlock(globals.id_mutex);
+
+        return id;
+}
+
+/* if other_member has a relationship with member, produce it */
+static conference_relationship_t *member_get_relationship(conference_member_t *member, conference_member_t *other_member)
+{
+        conference_relationship_t *rel = NULL, *global = NULL;
+
+        if (member == NULL || other_member == NULL || member-&gt;relationships == NULL)
+                return NULL;
+
+        lock_member(member);
+        lock_member(other_member);
+
+        for (rel = member-&gt;relationships; rel; rel = rel-&gt;next) {
+                if (rel-&gt;id == other_member-&gt;id) {
+                        break;
+                }
+
+                /* 0 matches everyone. (We will still test the others because a real match carries more clout) */
+                if (rel-&gt;id == 0) {
+                        global = rel;
+                }
+        }
+
+        unlock_member(other_member);
+        unlock_member(member);
+
+        return rel ? rel : global;
+}
+
+/* traverse the conference member list for the specified member id and return it's pointer */
+static conference_member_t *conference_member_get(conference_obj_t *conference, uint32_t id)
+{
+        conference_member_t *member = NULL;
+
+        switch_assert(conference != NULL);
+        if (!id) {
+                return NULL;
+        }
+
+        switch_mutex_lock(conference-&gt;member_mutex);
+        for (member = conference-&gt;members; member; member = member-&gt;next) {
+
+                if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
+                        continue;
+                }
+
+                if (member-&gt;id == id) {
+                        break;
+                }
+        }
+
+        if (member &amp;&amp; !switch_test_flag(member, MFLAG_INTREE)) {
+                member = NULL;
+        }
+
+        switch_mutex_unlock(conference-&gt;member_mutex);
+
+        return member;
+}
+
+/* stop the specified recording */
+static switch_status_t conference_record_stop(conference_obj_t *conference, char *path)
+{
+        conference_member_t *member = NULL;
+        int count = 0;
+
+        switch_assert(conference != NULL);
+        switch_mutex_lock(conference-&gt;member_mutex);
+        for (member = conference-&gt;members; member; member = member-&gt;next) {
+                if (switch_test_flag(member, MFLAG_NOCHANNEL) &amp;&amp; (!path || !strcmp(path, member-&gt;rec_path))) {
+                        switch_clear_flag_locked(member, MFLAG_RUNNING);
+                        count++;
+                }
+        }
+        switch_mutex_unlock(conference-&gt;member_mutex);
+        return count;
+}
+
+/* Add a custom relationship to a member */
+static conference_relationship_t *member_add_relationship(conference_member_t *member, uint32_t id)
+{
+        conference_relationship_t *rel = NULL;
+
+        if (member == NULL || id == 0 || !(rel = switch_core_alloc(member-&gt;pool, sizeof(*rel))))
+                return NULL;
+
+        rel-&gt;id = id;
+
+
+        lock_member(member);
+        switch_mutex_lock(member-&gt;conference-&gt;member_mutex);
+        member-&gt;conference-&gt;relationship_total++;
+        switch_mutex_unlock(member-&gt;conference-&gt;member_mutex);
+        rel-&gt;next = member-&gt;relationships;
+        member-&gt;relationships = rel;
+        unlock_member(member);
+
+        return rel;
+}
+
+/* Remove a custom relationship from a member */
+static switch_status_t member_del_relationship(conference_member_t *member, uint32_t id)
+{
+        switch_status_t status = SWITCH_STATUS_FALSE;
+        conference_relationship_t *rel, *last = NULL;
+
+        if (member == NULL || id == 0)
+                return status;
+
+        lock_member(member);
+        for (rel = member-&gt;relationships; rel; rel = rel-&gt;next) {
+                if (rel-&gt;id == id) {
+                        /* we just forget about rel here cos it was allocated by the member's pool 
+                           it will be freed when the member is */
+                        status = SWITCH_STATUS_SUCCESS;
+                        if (last) {
+                                last-&gt;next = rel-&gt;next;
+                        } else {
+                                member-&gt;relationships = rel-&gt;next;
+                        }
+
+                        switch_mutex_lock(member-&gt;conference-&gt;member_mutex);
+                        member-&gt;conference-&gt;relationship_total--;
+                        switch_mutex_unlock(member-&gt;conference-&gt;member_mutex);
+
+                }
+                last = rel;
+        }
+        unlock_member(member);
+
+        return status;
+}
+
+/* Gain exclusive access and add the member to the list */
+static switch_status_t conference_add_member(conference_obj_t *conference, conference_member_t *member)
+{
+        switch_status_t status = SWITCH_STATUS_FALSE;
+        switch_event_t *event;
+        char msg[512];                                /* conference count announcement */
+        call_list_t *call_list = NULL;
+        switch_channel_t *channel;
+
+        switch_assert(conference != NULL);
+        switch_assert(member != NULL);
+
+        switch_mutex_lock(conference-&gt;mutex);
+        switch_mutex_lock(member-&gt;audio_in_mutex);
+        switch_mutex_lock(member-&gt;audio_out_mutex);
+        lock_member(member);
+        switch_mutex_lock(conference-&gt;member_mutex);
+
+        switch_clear_flag(conference, CFLAG_DESTRUCT);
+        member-&gt;conference = conference;
+        member-&gt;next = conference-&gt;members;
+        member-&gt;energy_level = conference-&gt;energy_level;
+        member-&gt;score_iir = 0;
+        member-&gt;verbose_events = conference-&gt;verbose_events;
+        conference-&gt;members = member;
+        switch_set_flag_locked(member, MFLAG_INTREE);
+        switch_mutex_unlock(conference-&gt;member_mutex);
+
+        if (!switch_test_flag(member, MFLAG_NOCHANNEL)) {
+                conference-&gt;count++;
+
+                if (switch_test_flag(member, MFLAG_ENDCONF)) {
+                        if (conference-&gt;end_count++);
+                }
+
+                if (switch_event_create(&amp;event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;proto&quot;, CONF_CHAT_PROTO);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;login&quot;, conference-&gt;name);
+                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;from&quot;, &quot;%s@%s&quot;, conference-&gt;name, conference-&gt;domain);
+                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;status&quot;, &quot;Active (%d caller%s)&quot;, conference-&gt;count, conference-&gt;count == 1 ? &quot;&quot; : &quot;s&quot;);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;event_type&quot;, &quot;presence&quot;);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;alt_event_type&quot;, &quot;dialog&quot;);
+                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;event_count&quot;, &quot;%d&quot;, EC++);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;unique-id&quot;, conference-&gt;name);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;channel-state&quot;, &quot;CS_ROUTING&quot;);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;answer-state&quot;, conference-&gt;count == 1 ? &quot;early&quot; : &quot;confirmed&quot;);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;presence-call-direction&quot;, conference-&gt;count == 1 ? &quot;outbound&quot; : &quot;inbound&quot;);
+                        switch_event_fire(&amp;event);
+                }
+
+                if (switch_test_flag(conference, CFLAG_WAIT_MOD) &amp;&amp; switch_test_flag(member, MFLAG_MOD)) {
+                        switch_clear_flag(conference, CFLAG_WAIT_MOD);
+                }
+
+                if (conference-&gt;count &gt; 1) {
+                        if (conference-&gt;moh_sound &amp;&amp; !switch_test_flag(conference, CFLAG_WAIT_MOD)) {
+                                /* stop MoH if any */
+                                conference_stop_file(conference, FILE_STOP_ASYNC);
+                        }
+                        if (conference-&gt;enter_sound) {
+                                conference_play_file(conference, conference-&gt;enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member-&gt;session),
+                                                                         switch_test_flag(conference, CFLAG_WAIT_MOD) ? 0 : 1);
+                        }
+                }
+
+                channel = switch_core_session_get_channel(member-&gt;session);
+                call_list = (call_list_t *) switch_channel_get_private(channel, &quot;_conference_autocall_list_&quot;);
+
+                if (call_list) {
+                        char saymsg[1024];
+                        switch_snprintf(saymsg, sizeof(saymsg), &quot;Auto Calling %d parties&quot;, call_list-&gt;itteration);
+                        conference_member_say(member, saymsg, 0);
+                } else {
+                        if (zstr(conference-&gt;special_announce)) {
+                                /* announce the total number of members in the conference */
+                                if (conference-&gt;count &gt;= conference-&gt;announce_count &amp;&amp; conference-&gt;announce_count &gt; 1) {
+                                        switch_snprintf(msg, sizeof(msg), &quot;There are %d callers&quot;, conference-&gt;count);
+                                        conference_member_say(member, msg, CONF_DEFAULT_LEADIN);
+                                } else if (conference-&gt;count == 1 &amp;&amp; !conference-&gt;perpetual_sound &amp;&amp; !switch_test_flag(conference, CFLAG_WAIT_MOD)) {
+                                        /* as long as its not a bridge_to conference, announce if person is alone */
+                                        if (!switch_test_flag(conference, CFLAG_BRIDGE_TO)) {
+                                                if (conference-&gt;alone_sound) {
+                                                        conference_stop_file(conference, FILE_STOP_ASYNC);
+                                                        conference_play_file(conference, conference-&gt;alone_sound, CONF_DEFAULT_LEADIN,
+                                                                                                 switch_core_session_get_channel(member-&gt;session), 1);
+                                                } else {
+                                                        switch_snprintf(msg, sizeof(msg), &quot;You are currently the only person in this conference.&quot;);
+                                                        conference_member_say(member, msg, CONF_DEFAULT_LEADIN);
+                                                }
+                                        }
+
+                                }
+                        }
+                }
+
+                if (conference-&gt;count == 1) {
+                        conference-&gt;floor_holder = member;
+                }
+
+                if (conference-&gt;min &amp;&amp; conference-&gt;count &gt;= conference-&gt;min) {
+                        switch_set_flag(conference, CFLAG_ENFORCE_MIN);
+                }
+
+                if (test_eflag(conference, EFLAG_ADD_MEMBER) &amp;&amp;
+                        switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                        conference_add_event_member_data(member, event);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;add-member&quot;);
+                        switch_event_fire(&amp;event);
+                }
+
+        }
+        unlock_member(member);
+        switch_mutex_unlock(member-&gt;audio_out_mutex);
+        switch_mutex_unlock(member-&gt;audio_in_mutex);
+
+        switch_mutex_unlock(conference-&gt;mutex);
+        status = SWITCH_STATUS_SUCCESS;
+
+        return status;
+}
+
+/* Gain exclusive access and remove the member from the list */
+static switch_status_t conference_del_member(conference_obj_t *conference, conference_member_t *member)
+{
+        switch_status_t status = SWITCH_STATUS_FALSE;
+        conference_member_t *imember, *last = NULL;
+        switch_event_t *event;
+        conference_file_node_t *member_fnode;
+        switch_speech_handle_t *member_sh;
+
+        switch_assert(conference != NULL);
+        switch_assert(member != NULL);
+
+        lock_member(member);
+        member_fnode = member-&gt;fnode;
+        member_sh = member-&gt;sh;
+        member-&gt;fnode = NULL;
+        member-&gt;sh = NULL;
+        unlock_member(member);
+
+        switch_mutex_lock(conference-&gt;mutex);
+        switch_mutex_lock(conference-&gt;member_mutex);
+        switch_mutex_lock(member-&gt;audio_in_mutex);
+        switch_mutex_lock(member-&gt;audio_out_mutex);
+        lock_member(member);
+        switch_clear_flag(member, MFLAG_INTREE);
+
+        for (imember = conference-&gt;members; imember; imember = imember-&gt;next) {
+                if (imember == member) {
+                        if (last) {
+                                last-&gt;next = imember-&gt;next;
+                        } else {
+                                conference-&gt;members = imember-&gt;next;
+                        }
+                        break;
+                }
+                last = imember;
+        }
+
+        /* Close Unused Handles */
+        if (member_fnode) {
+                conference_file_node_t *fnode, *cur;
+                switch_memory_pool_t *pool;
+
+                fnode = member_fnode;
+                while (fnode) {
+                        cur = fnode;
+                        fnode = fnode-&gt;next;
+
+                        if (cur-&gt;type != NODE_TYPE_SPEECH) {
+                                switch_core_file_close(&amp;cur-&gt;fh);
+                        }
+
+                        pool = cur-&gt;pool;
+                        switch_core_destroy_memory_pool(&amp;pool);
+                }
+        }
+
+        if (member_sh) {
+                switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
+                switch_core_speech_close(&amp;member-&gt;lsh, &amp;flags);
+        }
+
+        if (member == member-&gt;conference-&gt;floor_holder) {
+                member-&gt;conference-&gt;floor_holder = NULL;
+        }
+
+        member-&gt;conference = NULL;
+
+        if (!switch_test_flag(member, MFLAG_NOCHANNEL)) {
+                conference-&gt;count--;
+
+                if (switch_test_flag(member, MFLAG_ENDCONF)) {
+                        if (!--conference-&gt;end_count) {
+                                switch_set_flag_locked(conference, CFLAG_DESTRUCT);
+                        }
+                }
+
+
+                if (switch_event_create(&amp;event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;proto&quot;, CONF_CHAT_PROTO);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;login&quot;, conference-&gt;name);
+                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;from&quot;, &quot;%s@%s&quot;, conference-&gt;name, conference-&gt;domain);
+                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;status&quot;, &quot;Active (%d caller%s)&quot;, conference-&gt;count, conference-&gt;count == 1 ? &quot;&quot; : &quot;s&quot;);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;event_type&quot;, &quot;presence&quot;);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;alt_event_type&quot;, &quot;dialog&quot;);
+                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;event_count&quot;, &quot;%d&quot;, EC++);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;unique-id&quot;, conference-&gt;name);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;channel-state&quot;, &quot;CS_ROUTING&quot;);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;answer-state&quot;, conference-&gt;count == 1 ? &quot;early&quot; : &quot;confirmed&quot;);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;call-direction&quot;, conference-&gt;count == 1 ? &quot;outbound&quot; : &quot;inbound&quot;);
+                        switch_event_fire(&amp;event);
+                }
+
+                if ((conference-&gt;min &amp;&amp; switch_test_flag(conference, CFLAG_ENFORCE_MIN) &amp;&amp; conference-&gt;count &lt; conference-&gt;min)
+                        || (switch_test_flag(conference, CFLAG_DYNAMIC) &amp;&amp; conference-&gt;count == 0)) {
+                        switch_set_flag(conference, CFLAG_DESTRUCT);
+                } else {
+                        if (conference-&gt;exit_sound) {
+                                conference_play_file(conference, conference-&gt;exit_sound, 0, switch_core_session_get_channel(member-&gt;session), 0);
+                        }
+                        if (conference-&gt;count == 1 &amp;&amp; conference-&gt;alone_sound &amp;&amp; !switch_test_flag(conference, CFLAG_WAIT_MOD)) {
+                                conference_stop_file(conference, FILE_STOP_ASYNC);
+                                conference_play_file(conference, conference-&gt;alone_sound, 0, switch_core_session_get_channel(member-&gt;session), 1);
+                        }
+                }
+
+                if (conference-&gt;announce_count == 1) {
+                        conference-&gt;floor_holder = conference-&gt;members;
+                }
+
+                if (test_eflag(conference, EFLAG_DEL_MEMBER) &amp;&amp;
+                        switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                        conference_add_event_member_data(member, event);
+                        conference_add_event_data(conference, event);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;del-member&quot;);
+                        switch_event_fire(&amp;event);
+                }
+        }
+        switch_mutex_unlock(conference-&gt;member_mutex);
+        unlock_member(member);
+        switch_mutex_unlock(member-&gt;audio_out_mutex);
+        switch_mutex_unlock(member-&gt;audio_in_mutex);
+        switch_mutex_unlock(conference-&gt;mutex);
+        status = SWITCH_STATUS_SUCCESS;
+
+        return status;
+}
+
+/* Main video monitor thread (1 per distinct conference room) */
+static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thread, void *obj)
+{
+        conference_obj_t *conference = (conference_obj_t *) obj;
+        conference_member_t *imember;
+        switch_frame_t *vid_frame;
+        switch_status_t status;
+        int has_vid = 1, req_iframe = 0;
+        int yield = 0;
+        uint32_t last_member = 0;
+        switch_core_session_t *session;
+
+        conference-&gt;video_running = 1;
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Video thread started for conference %s\n&quot;, conference-&gt;name);
+
+        while (has_vid &amp;&amp; conference-&gt;video_running == 1 &amp;&amp; globals.running &amp;&amp; !switch_test_flag(conference, CFLAG_DESTRUCT)) {
+                if (yield) {
+                        switch_yield(yield);
+                        yield = 0;
+                }
+
+                switch_mutex_lock(conference-&gt;member_mutex);
+
+                if (!conference-&gt;floor_holder) {
+                        yield = 100000;
+                        goto do_continue;
+                }
+
+                if (!switch_channel_test_flag(switch_core_session_get_channel(conference-&gt;floor_holder-&gt;session), CF_VIDEO)) {
+                        yield = 100000;
+                        goto do_continue;
+                }
+
+                session = conference-&gt;floor_holder-&gt;session;
+                switch_core_session_read_lock(session);
+                switch_mutex_unlock(conference-&gt;member_mutex);
+                status = switch_core_session_read_video_frame(session, &amp;vid_frame, SWITCH_IO_FLAG_NONE, 0);
+                switch_mutex_lock(conference-&gt;member_mutex);
+                switch_core_session_rwunlock(session);
+
+                if (!SWITCH_READ_ACCEPTABLE(status) || !conference-&gt;floor_holder || switch_test_flag(vid_frame, SFF_CNG)) {
+                        conference-&gt;floor_holder = NULL;
+                        req_iframe = 0;
+                        goto do_continue;
+                }
+
+                if (conference-&gt;floor_holder-&gt;id != last_member) {
+                        int iframe = 0;
+#if 0
+                        switch_core_session_message_t msg = { 0 };
+
+
+                        if (!req_iframe) {
+                                /* Tell the channel to request a fresh vid frame */
+                                msg.from = __FILE__;
+                                msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ;
+                                switch_core_session_receive_message(conference-&gt;floor_holder-&gt;session, &amp;msg);
+                                req_iframe = 1;
+                        }
+#endif
+
+                        if (vid_frame-&gt;codec-&gt;implementation-&gt;ianacode == 34) {        /* h.263 */
+                                //iframe = (*((int16_t *) vid_frame-&gt;data) &gt;&gt; 12 == 6);
+                                iframe = 1;
+                        } else if (vid_frame-&gt;codec-&gt;implementation-&gt;ianacode == 115) {        /* h.263-1998 */
+                                int y = *((int8_t *) vid_frame-&gt;data + 2) &amp; 0xfe;
+                                iframe = (y == 0x80 || y == 0x82);
+                        } else if (vid_frame-&gt;codec-&gt;implementation-&gt;ianacode == 99) {        /* h.264 */
+                                iframe = (*((int16_t *) vid_frame-&gt;data) &gt;&gt; 5 == 0x11);
+                        } else {                        /* we need more defs */
+                                iframe = 1;
+                        }
+
+                        if (!iframe) {
+                                goto do_continue;
+                        }
+
+                        req_iframe = 0;
+                }
+
+                last_member = conference-&gt;floor_holder-&gt;id;
+
+                switch_mutex_unlock(conference-&gt;member_mutex);
+                switch_mutex_lock(conference-&gt;member_mutex);
+                has_vid = 0;
+                for (imember = conference-&gt;members; imember; imember = imember-&gt;next) {
+                        if (imember-&gt;session &amp;&amp; switch_channel_test_flag(switch_core_session_get_channel(imember-&gt;session), CF_VIDEO)) {
+                                has_vid++;
+                                switch_core_session_write_video_frame(imember-&gt;session, vid_frame, SWITCH_IO_FLAG_NONE, 0);
+                        }
+                }
+
+          do_continue:
+
+                switch_mutex_unlock(conference-&gt;member_mutex);
+        }
+
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Video thread ending for conference %s\n&quot;, conference-&gt;name);
+        conference-&gt;video_running = 0;
+
+        return NULL;
+}
+
+/* Main monitor thread (1 per distinct conference room) */
+static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *obj)
+{
+        conference_obj_t *conference = (conference_obj_t *) obj;
+        conference_member_t *imember, *omember;
+        uint32_t samples = switch_samples_per_packet(conference-&gt;rate, conference-&gt;interval);
+        uint32_t bytes = samples * 2;
+        uint8_t ready = 0, total = 0;
+        switch_timer_t timer = { 0 };
+        switch_event_t *event;
+        uint8_t *file_frame;
+        uint8_t *async_file_frame;
+        int16_t *bptr;
+        int x;
+        int32_t z = 0;
+
+        file_frame = switch_core_alloc(conference-&gt;pool, SWITCH_RECOMMENDED_BUFFER_SIZE);
+        async_file_frame = switch_core_alloc(conference-&gt;pool, SWITCH_RECOMMENDED_BUFFER_SIZE);
+
+        if (switch_core_timer_init(&amp;timer, conference-&gt;timer_name, conference-&gt;interval, samples, conference-&gt;pool) == SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Setup timer success interval: %u  samples: %u\n&quot;, conference-&gt;interval, samples);
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Timer Setup Failed.  Conference Cannot Start\n&quot;);
+                return NULL;
+        }
+
+        switch_mutex_lock(globals.hash_mutex);
+        globals.threads++;
+        switch_mutex_unlock(globals.hash_mutex);
+
+        conference-&gt;is_recording = 0;
+
+        while (globals.running &amp;&amp; !switch_test_flag(conference, CFLAG_DESTRUCT)) {
+                switch_size_t file_sample_len = samples;
+                switch_size_t file_data_len = samples * 2;
+                int has_file_data = 0, members_with_video = 0;
+
+                /* Sync the conference to a single timing source */
+                if (switch_core_timer_next(&amp;timer) != SWITCH_STATUS_SUCCESS) {
+                        switch_set_flag(conference, CFLAG_DESTRUCT);
+                        break;
+                }
+
+                switch_mutex_lock(conference-&gt;mutex);
+                has_file_data = ready = total = 0;
+
+                if (conference-&gt;perpetual_sound &amp;&amp; !conference-&gt;async_fnode) {
+                        conference_play_file(conference, conference-&gt;perpetual_sound, CONF_DEFAULT_LEADIN, NULL, 1);
+                } else if (conference-&gt;moh_sound &amp;&amp; (conference-&gt;count == 1 || switch_test_flag(conference, CFLAG_WAIT_MOD)) &amp;&amp; !conference-&gt;async_fnode) {
+                        conference_play_file(conference, conference-&gt;moh_sound, CONF_DEFAULT_LEADIN, NULL, 1);
+                }
+
+                /* Read one frame of audio from each member channel and save it for redistribution */
+                for (imember = conference-&gt;members; imember; imember = imember-&gt;next) {
+                        uint32_t buf_read = 0;
+                        total++;
+                        imember-&gt;read = 0;
+
+                        if (imember-&gt;session &amp;&amp; switch_channel_test_flag(switch_core_session_get_channel(imember-&gt;session), CF_VIDEO)) {
+                                members_with_video++;
+                        }
+
+                        switch_clear_flag_locked(imember, MFLAG_HAS_AUDIO);
+                        switch_mutex_lock(imember-&gt;audio_in_mutex);
+
+                        if (switch_buffer_inuse(imember-&gt;audio_buffer) &gt;= bytes
+                                &amp;&amp; (buf_read = (uint32_t) switch_buffer_read(imember-&gt;audio_buffer, imember-&gt;frame, bytes))) {
+                                imember-&gt;read = buf_read;
+                                switch_set_flag_locked(imember, MFLAG_HAS_AUDIO);
+                                ready++;
+                        }
+                        switch_mutex_unlock(imember-&gt;audio_in_mutex);
+                }
+
+                /* Start recording if there's more than one participant. */
+                if (conference-&gt;auto_record &amp;&amp; !conference-&gt;is_recording &amp;&amp; conference-&gt;count &gt; 1) {
+                        conference-&gt;is_recording = 1;
+                        imember = conference-&gt;members;
+                        if (imember) {
+                                switch_channel_t *channel = switch_core_session_get_channel(imember-&gt;session);
+                                char *rfile = switch_channel_expand_variables(channel, conference-&gt;auto_record);
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Auto recording file: %s\n&quot;, rfile);
+                                launch_conference_record_thread(conference, rfile);
+                                if (rfile != conference-&gt;auto_record) {
+                                        switch_safe_free(rfile);
+                                }
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Auto Record Failed.  No members in conference.\n&quot;);
+                        }
+                }
+
+
+                if (members_with_video &amp;&amp; conference-&gt;video_running != 1) {
+                        launch_conference_video_thread(conference);
+                }
+
+                /* If a file or speech event is being played */
+                if (conference-&gt;fnode) {
+                        /* Lead in time */
+                        if (conference-&gt;fnode-&gt;leadin) {
+                                conference-&gt;fnode-&gt;leadin--;
+                        } else if (!conference-&gt;fnode-&gt;done) {
+                                file_sample_len = samples;
+                                if (conference-&gt;fnode-&gt;type == NODE_TYPE_SPEECH) {
+                                        switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING;
+
+                                        if (switch_core_speech_read_tts(conference-&gt;fnode-&gt;sh, file_frame, &amp;file_data_len, &amp;flags) == SWITCH_STATUS_SUCCESS) {
+                                                file_sample_len = file_data_len / 2;
+                                        } else {
+                                                file_sample_len = file_data_len = 0;
+                                        }
+                                } else if (conference-&gt;fnode-&gt;type == NODE_TYPE_FILE) {
+                                        switch_core_file_read(&amp;conference-&gt;fnode-&gt;fh, file_frame, &amp;file_sample_len);
+                                }
+
+                                if (file_sample_len &lt;= 0) {
+                                        if (test_eflag(conference, EFLAG_PLAY_FILE) &amp;&amp;
+                                                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                                                conference_add_event_data(conference, event);
+                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;play-file-done&quot;);
+                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;File&quot;, conference-&gt;fnode-&gt;file);
+                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Async&quot;, &quot;true&quot;);
+                                                switch_event_fire(&amp;event);
+                                        }
+
+                                        conference-&gt;fnode-&gt;done++;
+                                } else {
+                                        has_file_data = 1;
+                                }
+                        }
+                }
+
+                if (conference-&gt;async_fnode) {
+                        /* Lead in time */
+                        if (conference-&gt;async_fnode-&gt;leadin) {
+                                conference-&gt;async_fnode-&gt;leadin--;
+                        } else if (!conference-&gt;async_fnode-&gt;done) {
+                                file_sample_len = samples;
+                                switch_core_file_read(&amp;conference-&gt;async_fnode-&gt;fh, async_file_frame, &amp;file_sample_len);
+
+                                if (file_sample_len &lt;= 0) {
+                                        if (test_eflag(conference, EFLAG_PLAY_FILE) &amp;&amp;
+                                                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                                                conference_add_event_data(conference, event);
+                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;play-file-done&quot;);
+                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;File&quot;, conference-&gt;async_fnode-&gt;file);
+                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Async&quot;, &quot;true&quot;);
+                                                switch_event_fire(&amp;event);
+                                        }
+                                        conference-&gt;async_fnode-&gt;done++;
+                                } else {
+                                        if (has_file_data) {
+                                                switch_size_t x;
+
+                                                for (x = 0; x &lt; file_sample_len; x++) {
+                                                        int32_t z;
+                                                        int16_t *muxed;
+
+                                                        muxed = (int16_t *) file_frame;
+                                                        bptr = (int16_t *) async_file_frame;
+                                                        z = muxed[x] + bptr[x];
+                                                        switch_normalize_to_16bit(z);
+                                                        muxed[x] = (int16_t) z;
+                                                }
+                                        } else {
+                                                memcpy(file_frame, async_file_frame, file_sample_len * 2);
+                                                has_file_data = 1;
+                                        }
+                                }
+                        }
+                }
+
+                if (switch_test_flag(conference, CFLAG_WASTE_BANDWIDTH) &amp;&amp; !has_file_data) {
+                        file_sample_len = bytes / 2;
+
+                        if (conference-&gt;comfort_noise_level) {
+                                switch_generate_sln_silence((int16_t *) file_frame, file_sample_len, conference-&gt;comfort_noise_level);
+                        } else {
+                                memset(file_frame, 255, bytes);
+                        }
+                        has_file_data = 1;
+                }
+
+
+                if (ready || has_file_data) {
+                        /* Use more bits in the main_frame to preserve the exact sum of the audio samples. */
+                        int main_frame[SWITCH_RECOMMENDED_BUFFER_SIZE / 2] = { 0 };
+                        int16_t write_frame[SWITCH_RECOMMENDED_BUFFER_SIZE / 2] = { 0 };
+
+
+                        /* Init the main frame with file data if there is any. */
+                        bptr = (int16_t *) file_frame;
+                        if (has_file_data &amp;&amp; file_sample_len) {
+                                for (x = 0; x &lt; bytes / 2; x++) {
+                                        if (x &lt;= file_sample_len) {
+                                                main_frame[x] = (int32_t) bptr[x];
+                                        } else {
+                                                main_frame[x] = 255;
+                                        }
+                                }
+                        }
+
+                        /* Copy audio from every member known to be producing audio into the main frame. */
+                        for (omember = conference-&gt;members; omember; omember = omember-&gt;next) {
+                                if (!(switch_test_flag(omember, MFLAG_RUNNING) &amp;&amp; switch_test_flag(omember, MFLAG_HAS_AUDIO))) {
+                                        continue;
+                                }
+                                bptr = (int16_t *) omember-&gt;frame;
+                                for (x = 0; x &lt; omember-&gt;read / 2; x++) {
+                                        main_frame[x] += (int32_t) bptr[x];
+                                }
+                        }
+
+                        /* Create write frame once per member who is not deaf for each sample in the main frame
+                           check if our audio is involved and if so, subtract it from the sample so we don't hear ourselves.
+                           Since main frame was 32 bit int, we did not lose any detail, now that we have to convert to 16 bit we can
+                           cut it off at the min and max range if need be and write the frame to the output buffer.
+                         */
+                        for (omember = conference-&gt;members; omember; omember = omember-&gt;next) {
+                                switch_size_t ok = 1;
+
+                                if (!switch_test_flag(omember, MFLAG_RUNNING)) {
+                                        continue;
+                                }
+
+                                if (!switch_test_flag(omember, MFLAG_CAN_HEAR) &amp;&amp; !switch_test_flag(omember, MFLAG_WASTE_BANDWIDTH)
+                                        &amp;&amp; !switch_test_flag(conference, CFLAG_WASTE_BANDWIDTH)) {
+                                        continue;
+                                }
+
+                                bptr = (int16_t *) omember-&gt;frame;
+                                for (x = 0; x &lt; bytes / 2; x++) {
+                                        z = main_frame[x];
+                                        /* bptr[x] represents my own contribution to this audio sample */
+                                        if (switch_test_flag(omember, MFLAG_HAS_AUDIO) &amp;&amp; x &lt;= omember-&gt;read / 2) {
+                                                z -= (int32_t) bptr[x];
+                                        }
+
+                                        /* when there are relationships, we have to do more work by scouring all the members to see if there are any 
+                                           reasons why we should not be hearing a paticular member, and if not, delete their samples as well.
+                                         */
+                                        if (conference-&gt;relationship_total) {
+                                                for (imember = conference-&gt;members; imember; imember = imember-&gt;next) {
+                                                        conference_relationship_t *rel;
+                                                        for (rel = imember-&gt;relationships; rel; rel = rel-&gt;next) {
+                                                                if (imember != omember &amp;&amp; switch_test_flag(imember, MFLAG_HAS_AUDIO)) {
+                                                                        int16_t *rptr = (int16_t *) imember-&gt;frame;
+                                                                        if ((rel-&gt;id == omember-&gt;id || rel-&gt;id == 0) &amp;&amp; !switch_test_flag(rel, RFLAG_CAN_SPEAK)) {
+                                                                                z -= (int32_t) rptr[x];
+                                                                        }
+                                                                        if ((rel-&gt;id == imember-&gt;id || rel-&gt;id == 0) &amp;&amp; !switch_test_flag(rel, RFLAG_CAN_HEAR)) {
+                                                                                z -= (int32_t) rptr[x];
+                                                                        }
+                                                                }
+
+                                                        }
+                                                }
+                                        }
+
+                                        /* Now we can convert to 16 bit. */
+                                        switch_normalize_to_16bit(z);
+                                        write_frame[x] = (int16_t) z;
+                                }
+
+                                switch_mutex_lock(omember-&gt;audio_out_mutex);
+                                ok = switch_buffer_write(omember-&gt;mux_buffer, write_frame, bytes);
+                                switch_mutex_unlock(omember-&gt;audio_out_mutex);
+
+                                if (!ok) {
+                                        goto end;
+                                }
+                        }
+                }
+
+                if (conference-&gt;async_fnode &amp;&amp; conference-&gt;async_fnode-&gt;done) {
+                        switch_memory_pool_t *pool;
+                        switch_core_file_close(&amp;conference-&gt;async_fnode-&gt;fh);
+                        pool = conference-&gt;async_fnode-&gt;pool;
+                        conference-&gt;async_fnode = NULL;
+                        switch_core_destroy_memory_pool(&amp;pool);
+                }
+
+                if (conference-&gt;fnode &amp;&amp; conference-&gt;fnode-&gt;done) {
+                        conference_file_node_t *fnode;
+                        switch_memory_pool_t *pool;
+
+                        if (conference-&gt;fnode-&gt;type != NODE_TYPE_SPEECH) {
+                                switch_core_file_close(&amp;conference-&gt;fnode-&gt;fh);
+                        }
+
+                        fnode = conference-&gt;fnode;
+                        conference-&gt;fnode = conference-&gt;fnode-&gt;next;
+
+                        pool = fnode-&gt;pool;
+                        fnode = NULL;
+                        switch_core_destroy_memory_pool(&amp;pool);
+                }
+
+                switch_mutex_unlock(conference-&gt;mutex);
+        }
+        /* Rinse ... Repeat */
+  end:
+
+        if (switch_event_create(&amp;event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;proto&quot;, CONF_CHAT_PROTO);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;login&quot;, conference-&gt;name);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;from&quot;, &quot;%s@%s&quot;, conference-&gt;name, conference-&gt;domain);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;status&quot;, &quot;Inactive&quot;);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;rpid&quot;, &quot;idle&quot;);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;event_type&quot;, &quot;presence&quot;);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;alt_event_type&quot;, &quot;dialog&quot;);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;event_count&quot;, &quot;%d&quot;, EC++);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;unique-id&quot;, conference-&gt;name);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;channel-state&quot;, &quot;CS_HANGUP&quot;);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;answer-state&quot;, &quot;terminated&quot;);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;call-direction&quot;, &quot;inbound&quot;);
+                switch_event_fire(&amp;event);
+        }
+
+        switch_mutex_lock(conference-&gt;mutex);
+        conference_stop_file(conference, FILE_STOP_ASYNC);
+        conference_stop_file(conference, FILE_STOP_ALL);
+        /* Close Unused Handles */
+        if (conference-&gt;fnode) {
+                conference_file_node_t *fnode, *cur;
+                switch_memory_pool_t *pool;
+
+                fnode = conference-&gt;fnode;
+                while (fnode) {
+                        cur = fnode;
+                        fnode = fnode-&gt;next;
+
+                        if (cur-&gt;type != NODE_TYPE_SPEECH) {
+                                switch_core_file_close(&amp;cur-&gt;fh);
+                        }
+
+                        pool = cur-&gt;pool;
+                        switch_core_destroy_memory_pool(&amp;pool);
+                }
+                conference-&gt;fnode = NULL;
+        }
+
+        if (conference-&gt;async_fnode) {
+                switch_memory_pool_t *pool;
+                switch_core_file_close(&amp;conference-&gt;async_fnode-&gt;fh);
+                pool = conference-&gt;async_fnode-&gt;pool;
+                conference-&gt;async_fnode = NULL;
+                switch_core_destroy_memory_pool(&amp;pool);
+        }
+
+        switch_mutex_lock(conference-&gt;member_mutex);
+        for (imember = conference-&gt;members; imember; imember = imember-&gt;next) {
+                switch_channel_t *channel;
+
+                if (!switch_test_flag(imember, MFLAG_NOCHANNEL)) {
+                        channel = switch_core_session_get_channel(imember-&gt;session);
+
+                        /* add this little bit to preserve the bridge cause code in case of an early media call that */
+                        /* never answers */
+                        if (switch_test_flag(conference, CFLAG_ANSWERED)) {
+                                switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+                        } else {
+                                /* put actual cause code from outbound channel hangup here */
+                                switch_channel_hangup(channel, conference-&gt;bridge_hangup_cause);
+                        }
+                }
+
+                switch_clear_flag_locked(imember, MFLAG_RUNNING);
+        }
+        switch_mutex_unlock(conference-&gt;member_mutex);
+        switch_mutex_unlock(conference-&gt;mutex);
+
+        if (conference-&gt;video_running == 1) {
+                conference-&gt;video_running = -1;
+                while (conference-&gt;video_running) {
+                        switch_cond_next();
+                }
+        }
+
+        if (switch_test_flag(conference, CFLAG_DESTRUCT)) {
+                switch_core_timer_destroy(&amp;timer);
+                switch_mutex_lock(globals.hash_mutex);
+                switch_core_hash_delete(globals.conference_hash, conference-&gt;name);
+                switch_mutex_unlock(globals.hash_mutex);
+
+                /* Wait till everybody is out */
+                switch_clear_flag_locked(conference, CFLAG_RUNNING);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write Lock ON\n&quot;);
+                switch_thread_rwlock_wrlock(conference-&gt;rwlock);
+                switch_thread_rwlock_unlock(conference-&gt;rwlock);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write Lock OFF\n&quot;);
+
+                switch_ivr_digit_stream_parser_destroy(conference-&gt;dtmf_parser);
+
+                if (conference-&gt;sh) {
+                        switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
+                        switch_core_speech_close(&amp;conference-&gt;lsh, &amp;flags);
+                        conference-&gt;sh = NULL;
+                }
+
+                if (conference-&gt;pool) {
+                        switch_memory_pool_t *pool = conference-&gt;pool;
+                        switch_core_destroy_memory_pool(&amp;pool);
+                }
+        }
+
+        switch_mutex_lock(globals.hash_mutex);
+        globals.threads--;
+        switch_mutex_unlock(globals.hash_mutex);
+
+        return NULL;
+}
+
+static void conference_loop_fn_mute_toggle(conference_member_t *member, caller_control_action_t *action)
+{
+        if (member == NULL)
+                return;
+
+        if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
+                conf_api_sub_mute(member, NULL, NULL);
+        } else {
+                conf_api_sub_unmute(member, NULL, NULL);
+                if (!switch_test_flag(member, MFLAG_CAN_HEAR)) {
+                        conf_api_sub_undeaf(member, NULL, NULL);
+                }
+        }
+}
+
+static void conference_loop_fn_mute_on(conference_member_t *member, caller_control_action_t *action)
+{
+        if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
+                conf_api_sub_mute(member, NULL, NULL);
+        }
+}
+
+static void conference_loop_fn_mute_off(conference_member_t *member, caller_control_action_t *action)
+{
+        if (!switch_test_flag(member, MFLAG_CAN_SPEAK)) {
+                conf_api_sub_unmute(member, NULL, NULL);
+                if (!switch_test_flag(member, MFLAG_CAN_HEAR)) {
+                        conf_api_sub_undeaf(member, NULL, NULL);
+                }
+        }
+}
+
+static void conference_loop_fn_lock_toggle(conference_member_t *member, caller_control_action_t *action)
+{
+        switch_event_t *event;
+
+        if (member == NULL)
+                return;
+
+        if (!switch_test_flag(member-&gt;conference, CFLAG_LOCKED)) {
+                if (member-&gt;conference-&gt;is_locked_sound) {
+                        conference_play_file(member-&gt;conference, member-&gt;conference-&gt;is_locked_sound, CONF_DEFAULT_LEADIN, NULL, 0);
+                }
+
+                switch_set_flag_locked(member-&gt;conference, CFLAG_LOCKED);
+                if (test_eflag(member-&gt;conference, EFLAG_LOCK) &amp;&amp;
+                        switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                        conference_add_event_data(member-&gt;conference, event);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;lock&quot;);
+                        switch_event_fire(&amp;event);
+                }
+        } else {
+                if (member-&gt;conference-&gt;is_unlocked_sound) {
+                        conference_play_file(member-&gt;conference, member-&gt;conference-&gt;is_unlocked_sound, CONF_DEFAULT_LEADIN, NULL, 0);
+                }
+
+                switch_clear_flag_locked(member-&gt;conference, CFLAG_LOCKED);
+                if (test_eflag(member-&gt;conference, EFLAG_UNLOCK) &amp;&amp;
+                        switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                        conference_add_event_data(member-&gt;conference, event);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;unlock&quot;);
+                        switch_event_fire(&amp;event);
+                }
+        }
+
+}
+
+static void conference_loop_fn_deafmute_toggle(conference_member_t *member, caller_control_action_t *action)
+{
+        if (member == NULL)
+                return;
+
+        if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
+                conf_api_sub_mute(member, NULL, NULL);
+                if (switch_test_flag(member, MFLAG_CAN_HEAR)) {
+                        conf_api_sub_deaf(member, NULL, NULL);
+                }
+        } else {
+                conf_api_sub_unmute(member, NULL, NULL);
+                if (!switch_test_flag(member, MFLAG_CAN_HEAR)) {
+                        conf_api_sub_undeaf(member, NULL, NULL);
+                }
+        }
+}
+
+static void conference_loop_fn_energy_up(conference_member_t *member, caller_control_action_t *action)
+{
+        char msg[512];
+        switch_event_t *event;
+
+        if (member == NULL)
+                return;
+
+        lock_member(member);
+        member-&gt;energy_level += 200;
+        if (member-&gt;energy_level &gt; 3000) {
+                member-&gt;energy_level = 3000;
+        }
+
+        if (test_eflag(member-&gt;conference, EFLAG_ENERGY_LEVEL) &amp;&amp;
+                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;energy-level&quot;);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;New-Level&quot;, &quot;%d&quot;, member-&gt;energy_level);
+                switch_event_fire(&amp;event);
+        }
+        unlock_member(member);
+
+        switch_snprintf(msg, sizeof(msg), &quot;Energy level %d&quot;, member-&gt;energy_level);
+        conference_member_say(member, msg, 0);
+}
+
+static void conference_loop_fn_energy_equ_conf(conference_member_t *member, caller_control_action_t *action)
+{
+        char msg[512];
+        switch_event_t *event;
+
+        if (member == NULL)
+                return;
+
+        lock_member(member);
+        member-&gt;energy_level = member-&gt;conference-&gt;energy_level;
+
+        if (test_eflag(member-&gt;conference, EFLAG_ENERGY_LEVEL) &amp;&amp;
+                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;energy-level&quot;);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;New-Level&quot;, &quot;%d&quot;, member-&gt;energy_level);
+                switch_event_fire(&amp;event);
+        }
+        unlock_member(member);
+
+        switch_snprintf(msg, sizeof(msg), &quot;Energy level %d&quot;, member-&gt;energy_level);
+        conference_member_say(member, msg, 0);
+}
+
+static void conference_loop_fn_energy_dn(conference_member_t *member, caller_control_action_t *action)
+{
+        char msg[512];
+        switch_event_t *event;
+
+        if (member == NULL)
+                return;
+
+        lock_member(member);
+        member-&gt;energy_level -= 100;
+        if (member-&gt;energy_level &lt; 0) {
+                member-&gt;energy_level = 0;
+        }
+
+        if (test_eflag(member-&gt;conference, EFLAG_ENERGY_LEVEL) &amp;&amp;
+                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;energy-level&quot;);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;New-Level&quot;, &quot;%d&quot;, member-&gt;energy_level);
+                switch_event_fire(&amp;event);
+        }
+        unlock_member(member);
+
+        switch_snprintf(msg, sizeof(msg), &quot;Energy level %d&quot;, member-&gt;energy_level);
+        conference_member_say(member, msg, 0);
+}
+
+static void conference_loop_fn_volume_talk_up(conference_member_t *member, caller_control_action_t *action)
+{
+        char msg[512];
+        switch_event_t *event;
+
+        if (member == NULL)
+                return;
+
+        lock_member(member);
+        member-&gt;volume_out_level++;
+        switch_normalize_volume(member-&gt;volume_out_level);
+
+        if (test_eflag(member-&gt;conference, EFLAG_VOLUME_LEVEL) &amp;&amp;
+                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;volume-level&quot;);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;New-Level&quot;, &quot;%d&quot;, member-&gt;volume_out_level);
+                switch_event_fire(&amp;event);
+        }
+        unlock_member(member);
+
+        switch_snprintf(msg, sizeof(msg), &quot;Volume level %d&quot;, member-&gt;volume_out_level);
+        conference_member_say(member, msg, 0);
+}
+
+static void conference_loop_fn_volume_talk_zero(conference_member_t *member, caller_control_action_t *action)
+{
+        char msg[512];
+        switch_event_t *event;
+
+        if (member == NULL)
+                return;
+
+        lock_member(member);
+        member-&gt;volume_out_level = 0;
+
+        if (test_eflag(member-&gt;conference, EFLAG_VOLUME_LEVEL) &amp;&amp;
+                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;volume-level&quot;);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;New-Level&quot;, &quot;%d&quot;, member-&gt;volume_out_level);
+                switch_event_fire(&amp;event);
+        }
+        unlock_member(member);
+
+        switch_snprintf(msg, sizeof(msg), &quot;Volume level %d&quot;, member-&gt;volume_out_level);
+        conference_member_say(member, msg, 0);
+}
+
+static void conference_loop_fn_volume_talk_dn(conference_member_t *member, caller_control_action_t *action)
+{
+        char msg[512];
+        switch_event_t *event;
+
+        if (member == NULL)
+                return;
+
+        lock_member(member);
+        member-&gt;volume_out_level--;
+        switch_normalize_volume(member-&gt;volume_out_level);
+
+        if (test_eflag(member-&gt;conference, EFLAG_VOLUME_LEVEL) &amp;&amp;
+                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;volume-level&quot;);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;New-Level&quot;, &quot;%d&quot;, member-&gt;volume_out_level);
+                switch_event_fire(&amp;event);
+        }
+        unlock_member(member);
+
+        switch_snprintf(msg, sizeof(msg), &quot;Volume level %d&quot;, member-&gt;volume_out_level);
+        conference_member_say(member, msg, 0);
+}
+
+static void conference_loop_fn_volume_listen_up(conference_member_t *member, caller_control_action_t *action)
+{
+        char msg[512];
+        switch_event_t *event;
+
+        if (member == NULL)
+                return;
+
+        lock_member(member);
+        member-&gt;volume_in_level++;
+        switch_normalize_volume(member-&gt;volume_in_level);
+
+        if (test_eflag(member-&gt;conference, EFLAG_GAIN_LEVEL) &amp;&amp;
+                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;gain-level&quot;);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;New-Level&quot;, &quot;%d&quot;, member-&gt;volume_in_level);
+                switch_event_fire(&amp;event);
+        }
+        unlock_member(member);
+
+        switch_snprintf(msg, sizeof(msg), &quot;Gain level %d&quot;, member-&gt;volume_in_level);
+        conference_member_say(member, msg, 0);
+}
+
+static void conference_loop_fn_volume_listen_zero(conference_member_t *member, caller_control_action_t *action)
+{
+        char msg[512];
+        switch_event_t *event;
+
+        if (member == NULL)
+                return;
+
+        lock_member(member);
+        member-&gt;volume_in_level = 0;
+
+        if (test_eflag(member-&gt;conference, EFLAG_GAIN_LEVEL) &amp;&amp;
+                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;gain-level&quot;);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;New-Level&quot;, &quot;%d&quot;, member-&gt;volume_in_level);
+                switch_event_fire(&amp;event);
+        }
+        unlock_member(member);
+
+        switch_snprintf(msg, sizeof(msg), &quot;Gain level %d&quot;, member-&gt;volume_in_level);
+        conference_member_say(member, msg, 0);
+}
+
+static void conference_loop_fn_volume_listen_dn(conference_member_t *member, caller_control_action_t *action)
+{
+        char msg[512];
+        switch_event_t *event;
+
+        if (member == NULL)
+                return;
+
+        lock_member(member);
+        member-&gt;volume_in_level--;
+        switch_normalize_volume(member-&gt;volume_in_level);
+
+        if (test_eflag(member-&gt;conference, EFLAG_GAIN_LEVEL) &amp;&amp;
+                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;gain-level&quot;);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;New-Level&quot;, &quot;%d&quot;, member-&gt;volume_in_level);
+                switch_event_fire(&amp;event);
+        }
+        unlock_member(member);
+
+        switch_snprintf(msg, sizeof(msg), &quot;Gain level %d&quot;, member-&gt;volume_in_level);
+        conference_member_say(member, msg, 0);
+}
+
+static void conference_loop_fn_event(conference_member_t *member, caller_control_action_t *action)
+{
+        switch_event_t *event;
+        if (test_eflag(member-&gt;conference, EFLAG_DTMF) &amp;&amp; switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;dtmf&quot;);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;DTMF-Key&quot;, action-&gt;binded_dtmf);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Data&quot;, action-&gt;data);
+                switch_event_fire(&amp;event);
+        }
+}
+
+static void conference_loop_fn_transfer(conference_member_t *member, caller_control_action_t *action)
+{
+        char *exten = NULL;
+        char *dialplan = &quot;XML&quot;;
+        char *context = &quot;default&quot;;
+
+        char *argv[3] = { 0 };
+        int argc;
+        char *mydata = NULL;
+        switch_event_t *event;
+
+        if (test_eflag(member-&gt;conference, EFLAG_DTMF) &amp;&amp; switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;transfer&quot;);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Dialplan&quot;, action-&gt;data);
+                switch_event_fire(&amp;event);
+        }
+        switch_clear_flag_locked(member, MFLAG_RUNNING);
+
+        if ((mydata = switch_core_session_strdup(member-&gt;session, action-&gt;data))) {
+                if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+                        if (argc &gt; 0) {
+                                exten = argv[0];
+                        }
+                        if (argc &gt; 1) {
+                                dialplan = argv[1];
+                        }
+                        if (argc &gt; 2) {
+                                context = argv[2];
+                        }
+
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_ERROR, &quot;Empty transfer string [%s]\n&quot;, (char *) action-&gt;data);
+                        goto done;
+                }
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_ERROR, &quot;Unable to allocate memory to duplicate transfer data.\n&quot;);
+                goto done;
+        }
+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_DEBUG, &quot;Transfering to: %s, %s, %s\n&quot;, exten, dialplan, context);
+
+        switch_ivr_session_transfer(member-&gt;session, exten, dialplan, context);
+
+  done:
+        return;
+}
+
+static void conference_loop_fn_exec_app(conference_member_t *member, caller_control_action_t *action)
+{
+        char *app = NULL;
+        char *arg = &quot;&quot;;
+
+        char *argv[2] = { 0 };
+        int argc;
+        char *mydata = NULL;
+        switch_event_t *event = NULL;
+        switch_channel_t *channel = NULL;
+
+        if (test_eflag(member-&gt;conference, EFLAG_DTMF) &amp;&amp; switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;execute_app&quot;);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Application&quot;, action-&gt;data);
+                switch_event_fire(&amp;event);
+        }
+
+        if ((mydata = switch_core_session_strdup(member-&gt;session, action-&gt;data))) {
+                if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+                        if (argc &gt; 0) {
+                                app = argv[0];
+                        }
+                        if (argc &gt; 1) {
+                                arg = argv[1];
+                        }
+
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_ERROR, &quot;Empty execute app string [%s]\n&quot;, (char *) action-&gt;data);
+                        goto done;
+                }
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_ERROR, &quot;Unable to allocate memory to duplicate execute_app data.\n&quot;);
+                goto done;
+        }
+
+        if (!app) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_ERROR, &quot;Unable to find application.\n&quot;);
+                goto done;
+        }
+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_DEBUG, &quot;Execute app: %s, %s\n&quot;, app, arg);
+
+        channel = switch_core_session_get_channel(member-&gt;session);
+
+        switch_channel_set_app_flag(channel, CF_APP_TAGGED);
+        switch_core_session_set_read_codec(member-&gt;session, NULL);
+        switch_core_session_execute_application(member-&gt;session, app, arg);
+        switch_core_session_set_read_codec(member-&gt;session, &amp;member-&gt;read_codec);
+        switch_channel_clear_app_flag(channel, CF_APP_TAGGED);
+  done:
+        return;
+}
+
+static void conference_loop_fn_hangup(conference_member_t *member, caller_control_action_t *action)
+{
+        switch_clear_flag_locked(member, MFLAG_RUNNING);
+}
+
+/* marshall frames from the call leg to the conference thread for muxing to other call legs */
+static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *obj)
+{
+        conference_member_t *member = obj;
+        switch_channel_t *channel;
+        switch_status_t status;
+        switch_frame_t *read_frame = NULL;
+        uint32_t hangover = 40, hangunder = 15, hangover_hits = 0, hangunder_hits = 0, energy_level = 0, diff_level = 400;
+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_t *session = member-&gt;session;
+        switch_assert(member != NULL);
+
+        switch_clear_flag_locked(member, MFLAG_TALKING);
+
+        channel = switch_core_session_get_channel(session);
+
+        switch_core_session_get_read_impl(session, &amp;read_impl);
+
+        /* As long as we have a valid read, feed that data into an input buffer where the conference thread will take it 
+           and mux it with any audio from other channels. */
+
+        while (switch_test_flag(member, MFLAG_RUNNING) &amp;&amp; switch_channel_ready(channel)) {
+
+                if (switch_channel_ready(channel) &amp;&amp; switch_channel_test_app_flag(channel, CF_APP_TAGGED)) {
+                        switch_yield(100000);
+                        continue;
+                }
+
+                /* Read a frame. */
+                status = switch_core_session_read_frame(session, &amp;read_frame, SWITCH_IO_FLAG_NONE, 0);
+
+                switch_mutex_lock(member-&gt;read_mutex);
+
+                /* end the loop, if appropriate */
+                if (!SWITCH_READ_ACCEPTABLE(status) || !switch_test_flag(member, MFLAG_RUNNING)) {
+                        switch_mutex_unlock(member-&gt;read_mutex);
+                        break;
+                }
+
+                if (switch_test_flag(read_frame, SFF_CNG)) {
+                        if (hangunder_hits) {
+                                hangunder_hits--;
+                        }
+                        if (switch_test_flag(member, MFLAG_TALKING)) {
+                                switch_event_t *event;
+                                if (++hangover_hits &gt;= hangover) {
+                                        hangover_hits = hangunder_hits = 0;
+                                        switch_clear_flag_locked(member, MFLAG_TALKING);
+
+                                        if (test_eflag(member-&gt;conference, EFLAG_STOP_TALKING) &amp;&amp;
+                                                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                                                conference_add_event_member_data(member, event);
+                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;stop-talking&quot;);
+                                                switch_event_fire(&amp;event);
+                                        }
+                                }
+                        }
+
+                        goto do_continue;
+                }
+
+                energy_level = member-&gt;energy_level;
+
+                /* if the member can speak, compute the audio energy level and */
+                /* generate events when the level crosses the threshold        */
+                if ((switch_test_flag(member, MFLAG_CAN_SPEAK) || switch_test_flag(member, MFLAG_MUTE_DETECT)) &amp;&amp; energy_level) {
+                        uint32_t energy = 0, i = 0, samples = 0, j = 0;
+                        int16_t *data;
+                        int divisor = 0;
+
+                        data = read_frame-&gt;data;
+
+                        if (!(divisor = read_impl.actual_samples_per_second / 8000)) {
+                                divisor = 1;
+                        }
+
+                        member-&gt;score = 0;
+
+                        if ((samples = read_frame-&gt;datalen / sizeof(*data))) {
+                                for (i = 0; i &lt; samples; i++) {
+                                        energy += abs(data[j]);
+                                        j += read_impl.number_of_channels;
+                                }
+                                member-&gt;score = energy / (samples / divisor);
+                        }
+
+                        member-&gt;score_iir = (int) (((1.0 - SCORE_DECAY) * (float) member-&gt;score) + (SCORE_DECAY * (float) member-&gt;score_iir));
+
+                        if (member-&gt;score_iir &gt; SCORE_MAX_IIR) {
+                                member-&gt;score_iir = SCORE_MAX_IIR;
+                        }
+
+                        if (member-&gt;score &gt; energy_level) {
+                                uint32_t diff = member-&gt;score - energy_level;
+                                if (hangover_hits) {
+                                        hangover_hits--;
+                                }
+
+                                if (diff &gt;= diff_level || ++hangunder_hits &gt;= hangunder) {
+                                        hangover_hits = hangunder_hits = 0;
+
+                                        if (!switch_test_flag(member, MFLAG_TALKING)) {
+                                                switch_event_t *event;
+                                                switch_set_flag_locked(member, MFLAG_TALKING);
+                                                switch_mutex_lock(member-&gt;conference-&gt;member_mutex);
+                                                if ((!member-&gt;conference-&gt;floor_holder ||
+                                                         !switch_test_flag(member-&gt;conference-&gt;floor_holder, MFLAG_TALKING) ||
+                                                         ((member-&gt;score_iir &gt; SCORE_IIR_SPEAKING_MAX) &amp;&amp; (member-&gt;conference-&gt;floor_holder-&gt;score_iir &lt; SCORE_IIR_SPEAKING_MIN))) &amp;&amp;
+                                                        (!switch_test_flag(member-&gt;conference, CFLAG_VID_FLOOR) || switch_channel_test_flag(channel, CF_VIDEO))) {
+
+                                                        if (test_eflag(member-&gt;conference, EFLAG_FLOOR_CHANGE) &amp;&amp;
+                                                                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                                                                conference_add_event_member_data(member, event);
+                                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;floor-change&quot;);
+                                                                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Old-ID&quot;, &quot;%d&quot;,
+                                                                                                                member-&gt;conference-&gt;floor_holder ? member-&gt;conference-&gt;floor_holder-&gt;id : 0);
+                                                                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;New-ID&quot;, &quot;%d&quot;, member-&gt;conference-&gt;floor_holder ? member-&gt;id : 0);
+                                                                switch_event_fire(&amp;event);
+                                                        }
+                                                        member-&gt;conference-&gt;floor_holder = member;
+                                                }
+                                                switch_mutex_unlock(member-&gt;conference-&gt;member_mutex);
+
+                                                if (test_eflag(member-&gt;conference, EFLAG_START_TALKING) &amp;&amp; switch_test_flag(member, MFLAG_CAN_SPEAK) &amp;&amp;
+                                                        switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                                                        conference_add_event_member_data(member, event);
+                                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;start-talking&quot;);
+                                                        switch_event_fire(&amp;event);
+                                                }
+
+                                                if (switch_test_flag(member, MFLAG_MUTE_DETECT) &amp;&amp; !switch_test_flag(member, MFLAG_CAN_SPEAK)) {
+
+                                                        if (!zstr(member-&gt;conference-&gt;mute_detect_sound)) {
+                                                                conference_member_play_file(member, member-&gt;conference-&gt;mute_detect_sound, 0);
+                                                        }
+
+                                                        if (test_eflag(member-&gt;conference, EFLAG_MUTE_DETECT) &amp;&amp;
+                                                                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                                                                conference_add_event_member_data(member, event);
+                                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;mute-detect&quot;);
+                                                                switch_event_fire(&amp;event);
+                                                        }
+
+                                                }
+
+                                        }
+                                }
+                        } else {
+                                if (hangunder_hits) {
+                                        hangunder_hits--;
+                                }
+                                if (switch_test_flag(member, MFLAG_TALKING) &amp;&amp; switch_test_flag(member, MFLAG_CAN_SPEAK)) {
+                                        switch_event_t *event;
+                                        if (++hangover_hits &gt;= hangover) {
+                                                hangover_hits = hangunder_hits = 0;
+                                                switch_clear_flag_locked(member, MFLAG_TALKING);
+
+                                                if (test_eflag(member-&gt;conference, EFLAG_STOP_TALKING) &amp;&amp;
+                                                        switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                                                        conference_add_event_member_data(member, event);
+                                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;stop-talking&quot;);
+                                                        switch_event_fire(&amp;event);
+                                                }
+                                        }
+                                }
+                        }
+                }
+
+                /* skip frames that are not actual media or when we are muted or silent */
+                if ((switch_test_flag(member, MFLAG_TALKING) || energy_level == 0) &amp;&amp; switch_test_flag(member, MFLAG_CAN_SPEAK) &amp;&amp;
+                        !switch_test_flag(member-&gt;conference, CFLAG_WAIT_MOD)) {
+                        switch_audio_resampler_t *read_resampler = member-&gt;read_resampler;
+                        void *data;
+                        uint32_t datalen;
+
+                        if (read_resampler) {
+                                int16_t *bptr = (int16_t *) read_frame-&gt;data;
+                                int len = (int) read_frame-&gt;datalen;
+
+                                switch_resample_process(read_resampler, bptr, len / 2);
+                                memcpy(member-&gt;resample_out, read_resampler-&gt;to, read_resampler-&gt;to_len * 2);
+                                len = read_resampler-&gt;to_len * 2;
+                                datalen = len;
+                                data = member-&gt;resample_out;
+                        } else {
+                                data = read_frame-&gt;data;
+                                datalen = read_frame-&gt;datalen;
+                        }
+
+                        /* Check for input volume adjustments */
+                        if (member-&gt;volume_in_level) {
+                                switch_change_sln_volume(data, datalen / 2, member-&gt;volume_in_level);
+                        }
+
+                        if (datalen) {
+                                switch_size_t ok = 1;
+
+                                /* Write the audio into the input buffer */
+                                switch_mutex_lock(member-&gt;audio_in_mutex);
+                                ok = switch_buffer_write(member-&gt;audio_buffer, data, datalen);
+                                switch_mutex_unlock(member-&gt;audio_in_mutex);
+                                if (!ok) {
+                                        switch_mutex_unlock(member-&gt;read_mutex);
+                                        break;
+                                }
+                        }
+                }
+
+          do_continue:
+
+                switch_mutex_unlock(member-&gt;read_mutex);
+        }
+
+
+        switch_resample_destroy(&amp;member-&gt;read_resampler);
+        switch_clear_flag_locked(member, MFLAG_ITHREAD);
+
+        return NULL;
+}
+
+
+static void member_add_file_data(conference_member_t *member, int16_t *data, switch_size_t file_data_len)
+{
+        switch_size_t file_sample_len = file_data_len / 2;
+        int16_t file_frame[SWITCH_RECOMMENDED_BUFFER_SIZE / 2] = { 0 };
+
+        if (!member-&gt;fnode) {
+                return;
+        }
+
+        /* if we are done, clean it up */
+        if (member-&gt;fnode-&gt;done) {
+                conference_file_node_t *fnode;
+                switch_memory_pool_t *pool;
+
+                if (member-&gt;fnode-&gt;type != NODE_TYPE_SPEECH) {
+                        switch_core_file_close(&amp;member-&gt;fnode-&gt;fh);
+                }
+
+                fnode = member-&gt;fnode;
+                member-&gt;fnode = member-&gt;fnode-&gt;next;
+
+                pool = fnode-&gt;pool;
+                fnode = NULL;
+                switch_core_destroy_memory_pool(&amp;pool);
+        } else {
+                /* skip this frame until leadin time has expired */
+                if (member-&gt;fnode-&gt;leadin) {
+                        member-&gt;fnode-&gt;leadin--;
+                } else {
+                        if (member-&gt;fnode-&gt;type == NODE_TYPE_SPEECH) {
+                                switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING;
+
+                                if (switch_core_speech_read_tts(member-&gt;fnode-&gt;sh, file_frame, &amp;file_data_len, &amp;flags) == SWITCH_STATUS_SUCCESS) {
+                                        file_sample_len = file_data_len / 2;
+                                } else {
+                                        file_sample_len = file_data_len = 0;
+                                }
+                        } else if (member-&gt;fnode-&gt;type == NODE_TYPE_FILE) {
+                                switch_core_file_read(&amp;member-&gt;fnode-&gt;fh, file_frame, &amp;file_sample_len);
+                                file_data_len = file_sample_len * 2;
+                        }
+
+                        if (file_sample_len &lt;= 0) {
+                                switch_event_t *event;
+                                member-&gt;fnode-&gt;done++;
+
+                                if (test_eflag(member-&gt;conference, EFLAG_PLAY_FILE) &amp;&amp;
+                                        switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                                        conference_add_event_data(member-&gt;conference, event);
+                                        conference_add_event_member_data(member, event);
+                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;play-file-member-done&quot;);
+                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;File&quot;, member-&gt;fnode-&gt;file);
+                                        switch_event_fire(&amp;event);
+                                }
+                        } else {                        /* there is file node data to mix into the frame */
+                                int32_t i, sample;
+
+                                /* Check for output volume adjustments */
+                                if (member-&gt;volume_out_level) {
+                                        switch_change_sln_volume(file_frame, file_sample_len, member-&gt;volume_out_level);
+                                }
+
+                                for (i = 0; i &lt; file_sample_len; i++) {
+                                        sample = data[i] + file_frame[i];
+                                        switch_normalize_to_16bit(sample);
+                                        data[i] = sample;
+                                }
+
+                        }
+                }
+        }
+}
+
+
+
+/* launch an input thread for the call leg */
+static void launch_conference_loop_input(conference_member_t *member, switch_memory_pool_t *pool)
+{
+        switch_thread_t *thread;
+        switch_threadattr_t *thd_attr = NULL;
+
+        if (member == NULL)
+                return;
+
+        switch_threadattr_create(&amp;thd_attr, pool);
+        switch_threadattr_detach_set(thd_attr, 1);
+        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+        switch_set_flag_locked(member, MFLAG_ITHREAD);
+        switch_thread_create(&amp;thread, thd_attr, conference_loop_input, member, pool);
+}
+
+static caller_control_fn_table_t ccfntbl[] = {
+        {&quot;mute&quot;, &quot;0&quot;, CALLER_CONTROL_MUTE, conference_loop_fn_mute_toggle},
+        {&quot;mute on&quot;, NULL, CALLER_CONTROL_MUTE_ON, conference_loop_fn_mute_on},
+        {&quot;mute off&quot;, NULL, CALLER_CONTROL_MUTE_OFF, conference_loop_fn_mute_off},
+        {&quot;deaf mute&quot;, &quot;*&quot;, CALLER_CONTROL_DEAF_MUTE, conference_loop_fn_deafmute_toggle},
+        {&quot;energy up&quot;, &quot;9&quot;, CALLER_CONTROL_ENERGY_UP, conference_loop_fn_energy_up},
+        {&quot;energy equ&quot;, &quot;8&quot;, CALLER_CONTROL_ENERGY_EQU_CONF, conference_loop_fn_energy_equ_conf},
+        {&quot;energy dn&quot;, &quot;7&quot;, CALLER_CONTROL_ENERGEY_DN, conference_loop_fn_energy_dn},
+        {&quot;vol talk up&quot;, &quot;3&quot;, CALLER_CONTROL_VOL_TALK_UP, conference_loop_fn_volume_talk_up},
+        {&quot;vol talk zero&quot;, &quot;2&quot;, CALLER_CONTROL_VOL_TALK_ZERO, conference_loop_fn_volume_talk_zero},
+        {&quot;vol talk dn&quot;, &quot;1&quot;, CALLER_CONTROL_VOL_TALK_DN, conference_loop_fn_volume_talk_dn},
+        {&quot;vol listen up&quot;, &quot;6&quot;, CALLER_CONTROL_VOL_LISTEN_UP, conference_loop_fn_volume_listen_up},
+        {&quot;vol listen zero&quot;, &quot;5&quot;, CALLER_CONTROL_VOL_LISTEN_ZERO, conference_loop_fn_volume_listen_zero},
+        {&quot;vol listen dn&quot;, &quot;4&quot;, CALLER_CONTROL_VOL_LISTEN_DN, conference_loop_fn_volume_listen_dn},
+        {&quot;hangup&quot;, &quot;#&quot;, CALLER_CONTROL_HANGUP, conference_loop_fn_hangup},
+        {&quot;event&quot;, NULL, CALLER_CONTROL_EVENT, conference_loop_fn_event},
+        {&quot;lock&quot;, NULL, CALLER_CONTROL_LOCK, conference_loop_fn_lock_toggle},
+        {&quot;transfer&quot;, NULL, CALLER_CONTROL_TRANSFER, conference_loop_fn_transfer},
+        {&quot;execute_application&quot;, NULL, CALLER_CONTROL_EXEC_APP, conference_loop_fn_exec_app}
+};
+
+#define CCFNTBL_QTY (sizeof(ccfntbl)/sizeof(ccfntbl[0]))
+
+/* marshall frames from the conference (or file or tts output) to the call leg */
+/* NB. this starts the input thread after some initial setup for the call leg */
+static void conference_loop_output(conference_member_t *member)
+{
+        switch_channel_t *channel;
+        switch_frame_t write_frame = { 0 };
+        uint8_t *data = NULL;
+        switch_timer_t timer = { 0 };
+        uint32_t interval;
+        uint32_t samples;
+        uint32_t csamples;
+        uint32_t tsamples;
+        uint32_t flush_len;
+        uint32_t low_count, bytes;
+        call_list_t *call_list, *cp;
+        int restarting = -1;
+        switch_codec_implementation_t read_impl = { 0 };
+
+  top:
+
+        switch_core_session_get_read_impl(member-&gt;session, &amp;read_impl);
+
+        restarting++;
+
+        if (switch_test_flag(member, MFLAG_RESTART)) {
+                switch_clear_flag(member, MFLAG_RESTART);
+                switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER);
+                switch_core_timer_destroy(&amp;timer);
+        }
+
+        channel = switch_core_session_get_channel(member-&gt;session);
+        interval = read_impl.microseconds_per_packet / 1000;
+        samples = switch_samples_per_packet(member-&gt;conference-&gt;rate, interval);
+        csamples = samples;
+        tsamples = member-&gt;orig_read_impl.samples_per_packet;
+        flush_len = 0;
+        low_count = 0;
+        bytes = samples * 2;
+        call_list = NULL;
+        cp = NULL;
+
+
+
+        switch_assert(member-&gt;conference != NULL);
+
+        flush_len = switch_samples_per_packet(member-&gt;conference-&gt;rate, member-&gt;conference-&gt;interval) * 10;
+
+        if (switch_core_timer_init(&amp;timer, member-&gt;conference-&gt;timer_name, interval, tsamples, NULL) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_ERROR, &quot;Timer Setup Failed.  Conference Cannot Start\n&quot;);
+                return;
+        }
+
+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_DEBUG, &quot;Setup timer %s success interval: %u  samples: %u\n&quot;,
+                                          member-&gt;conference-&gt;timer_name, interval, tsamples);
+
+        if (!restarting) {
+                write_frame.data = data = switch_core_session_alloc(member-&gt;session, SWITCH_RECOMMENDED_BUFFER_SIZE);
+                write_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
+        }
+
+        write_frame.codec = &amp;member-&gt;write_codec;
+
+        if (!switch_test_flag(member-&gt;conference, CFLAG_ANSWERED)) {
+                switch_channel_answer(channel);
+        }
+
+        if (!restarting) {
+                /* Start the input thread */
+                launch_conference_loop_input(member, switch_core_session_get_pool(member-&gt;session));
+
+                /* build a digit stream object */
+                if (member-&gt;conference-&gt;dtmf_parser != NULL
+                        &amp;&amp; switch_ivr_digit_stream_new(member-&gt;conference-&gt;dtmf_parser, &amp;member-&gt;digit_stream) != SWITCH_STATUS_SUCCESS) {
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_ERROR,
+                                                          &quot;Danger Will Robinson, there is no digit parser stream object\n&quot;);
+                }
+
+                if ((call_list = switch_channel_get_private(channel, &quot;_conference_autocall_list_&quot;))) {
+                        const char *cid_name = switch_channel_get_variable(channel, &quot;conference_auto_outcall_caller_id_name&quot;);
+                        const char *cid_num = switch_channel_get_variable(channel, &quot;conference_auto_outcall_caller_id_number&quot;);
+                        const char *toval = switch_channel_get_variable(channel, &quot;conference_auto_outcall_timeout&quot;);
+                        const char *flags = switch_channel_get_variable(channel, &quot;conference_auto_outcall_flags&quot;);
+                        const char *ann = switch_channel_get_variable(channel, &quot;conference_auto_outcall_announce&quot;);
+                        const char *prefix = switch_channel_get_variable(channel, &quot;conference_auto_outcall_prefix&quot;);
+                        int to = 60;
+
+                        if (ann) {
+                                member-&gt;conference-&gt;special_announce = switch_core_strdup(member-&gt;conference-&gt;pool, ann);
+                        }
+
+                        switch_channel_set_private(channel, &quot;_conference_autocall_list_&quot;, NULL);
+
+                        if (toval) {
+                                to = atoi(toval);
+                                if (to &lt; 10 || to &gt; 500) {
+                                        to = 60;
+                                }
+                        }
+
+                        for (cp = call_list; cp; cp = cp-&gt;next) {
+                                int argc;
+                                char *argv[512] = { 0 };
+                                char *cpstr = strdup(cp-&gt;string);
+                                int x = 0;
+
+                                switch_assert(cpstr);
+                                argc = switch_separate_string(cpstr, ',', argv, (sizeof(argv) / sizeof(argv[0])));
+                                for (x = 0; x &lt; argc; x++) {
+                                        char *dial_str = switch_mprintf(&quot;%s%s&quot;, switch_str_nil(prefix), argv[x]);
+                                        switch_assert(dial_str);
+                                        conference_outcall_bg(member-&gt;conference, NULL, NULL, dial_str, to, switch_str_nil(flags), cid_name, cid_num, NULL);
+                                        switch_safe_free(dial_str);
+                                }
+                                switch_safe_free(cpstr);
+                        }
+                }
+        }
+
+        if (restarting) {
+                switch_channel_clear_app_flag(channel, CF_APP_TAGGED);
+        }
+
+        /* Fair WARNING, If you expect the caller to hear anything or for digit handling to be processed,      */
+        /* you better not block this thread loop for more than the duration of member-&gt;conference-&gt;timer_name!  */
+        while (switch_test_flag(member, MFLAG_RUNNING) &amp;&amp; switch_test_flag(member, MFLAG_ITHREAD)
+                   &amp;&amp; switch_channel_ready(channel)) {
+                char dtmf[128] = &quot;&quot;;
+                char *digit;
+                switch_event_t *event;
+                caller_control_action_t *caller_action = NULL;
+                int use_timer = 0;
+                switch_buffer_t *use_buffer = NULL;
+                uint32_t mux_used = 0;
+
+                switch_mutex_lock(member-&gt;write_mutex);
+
+                if (switch_test_flag(member, MFLAG_RESTART)) {
+                        switch_mutex_unlock(member-&gt;write_mutex);
+                        goto top;
+                }
+
+                if (switch_core_session_dequeue_event(member-&gt;session, &amp;event, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
+                        if (event-&gt;event_id == SWITCH_EVENT_MESSAGE) {
+                                char *from = switch_event_get_header(event, &quot;from&quot;);
+                                char *to = switch_event_get_header(event, &quot;to&quot;);
+                                char *proto = switch_event_get_header(event, &quot;proto&quot;);
+                                char *subject = switch_event_get_header(event, &quot;subject&quot;);
+                                char *hint = switch_event_get_header(event, &quot;hint&quot;);
+                                char *body = switch_event_get_body(event);
+                                char *p, *freeme = NULL;
+
+                                if (to &amp;&amp; from &amp;&amp; body) {
+                                        if ((p = strchr(to, '+')) &amp;&amp; strncmp(to, CONF_CHAT_PROTO, strlen(CONF_CHAT_PROTO))) {
+                                                freeme = switch_mprintf(&quot;%s+%s@%s&quot;, CONF_CHAT_PROTO, member-&gt;conference-&gt;name, member-&gt;conference-&gt;domain);
+                                                to = freeme;
+                                        }
+                                        chat_send(proto, from, to, subject, body, NULL, hint);
+                                        switch_safe_free(freeme);
+                                }
+                        }
+                        switch_event_destroy(&amp;event);
+                }
+
+                if (switch_channel_test_flag(channel, CF_OUTBOUND)) {
+                        /* test to see if outbound channel has answered */
+                        if (switch_channel_test_flag(channel, CF_ANSWERED) &amp;&amp; !switch_test_flag(member-&gt;conference, CFLAG_ANSWERED)) {
+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_DEBUG,
+                                                                  &quot;Outbound conference channel answered, setting CFLAG_ANSWERED\n&quot;);
+                                switch_set_flag(member-&gt;conference, CFLAG_ANSWERED);
+                        }
+                } else {
+                        if (switch_test_flag(member-&gt;conference, CFLAG_ANSWERED) &amp;&amp; !switch_channel_test_flag(channel, CF_ANSWERED)) {
+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_DEBUG, &quot;CLFAG_ANSWERED set, answering inbound channel\n&quot;);
+                                switch_channel_answer(channel);
+                        }
+                }
+
+                /* if we have caller digits, feed them to the parser to find an action */
+                if (switch_channel_has_dtmf(channel)) {
+                        switch_channel_dequeue_dtmf_string(channel, dtmf, sizeof(dtmf));
+
+                        if (switch_test_flag(member, MFLAG_DIST_DTMF)) {
+                                conference_send_all_dtmf(member, member-&gt;conference, dtmf);
+                        } else {
+                                if (member-&gt;conference-&gt;dtmf_parser != NULL) {
+                                        for (digit = dtmf; *digit &amp;&amp; caller_action == NULL; digit++) {
+                                                caller_action = (caller_control_action_t *)
+                                                        switch_ivr_digit_stream_parser_feed(member-&gt;conference-&gt;dtmf_parser, member-&gt;digit_stream, *digit);
+                                        }
+                                }
+                        }
+                        /* otherwise, clock the parser so that it can handle digit timeout detection */
+                } else if (member-&gt;conference-&gt;dtmf_parser != NULL) {
+                        caller_action = (caller_control_action_t *) switch_ivr_digit_stream_parser_feed(member-&gt;conference-&gt;dtmf_parser, member-&gt;digit_stream, '\0');
+                }
+
+                /* if a caller action has been detected, handle it */
+                if (caller_action != NULL &amp;&amp; caller_action-&gt;fndesc != NULL &amp;&amp; caller_action-&gt;fndesc-&gt;handler != NULL) {
+                        char *param = NULL;
+
+                        if (caller_action-&gt;fndesc-&gt;action != CALLER_CONTROL_MENU) {
+                                param = caller_action-&gt;data;
+                        }
+#ifdef INTENSE_DEBUG
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session),
+                                                          SWITCH_LOG_INFO,
+                                                          &quot;executing caller control '%s' param '%s' on call '%u, %s\n&quot;,
+                                                          caller_action-&gt;fndesc-&gt;key, param ? param : &quot;none&quot;, member-&gt;id, switch_channel_get_name(channel));
+#endif
+
+                        caller_action-&gt;fndesc-&gt;handler(member, caller_action);
+
+                        /* set up for next pass */
+                        caller_action = NULL;
+                }
+
+
+                use_buffer = NULL;
+                mux_used = (uint32_t) switch_buffer_inuse(member-&gt;mux_buffer);
+
+                if (mux_used) {
+                        if (mux_used &lt; bytes) {
+                                if (++low_count &gt;= 5) {
+                                        /* partial frame sitting around this long is useless and builds delay */
+                                        switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER);
+                                }
+                        } else if (mux_used &gt; flush_len) {
+                                /* getting behind, clear the buffer */
+                                switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER);
+                        }
+                }
+
+
+                use_timer = 1;
+
+                if (mux_used) {
+                        /* Flush the output buffer and write all the data (presumably muxed) back to the channel */
+                        switch_mutex_lock(member-&gt;audio_out_mutex);
+                        write_frame.data = data;
+                        use_buffer = member-&gt;mux_buffer;
+                        low_count = 0;
+                        if ((write_frame.datalen = (uint32_t) switch_buffer_read(use_buffer, write_frame.data, bytes))) {
+                                if (write_frame.datalen) {
+               write_frame.samples = write_frame.datalen / 2;
+                                   
+                                   if( !switch_test_flag(member, MFLAG_CAN_HEAR)) {
+                                      memset(write_frame.data, 255, write_frame.datalen);
+                                   }
+                                   else {
+                                           /* Check for output volume adjustments */
+                                           if (member-&gt;volume_out_level) {
+                                                   switch_change_sln_volume(write_frame.data, write_frame.samples, member-&gt;volume_out_level);
+                                           }
+                                   }
+                                        write_frame.timestamp = timer.samplecount;
+                                        if (member-&gt;fnode) {
+                                                member_add_file_data(member, write_frame.data, write_frame.datalen);
+                                        }
+                                        switch_core_session_write_frame(member-&gt;session, &amp;write_frame, SWITCH_IO_FLAG_NONE, 0);
+                                }
+                        }
+
+                        switch_mutex_unlock(member-&gt;audio_out_mutex);
+                } else if (member-&gt;fnode) {
+                        write_frame.datalen = bytes;
+                        write_frame.samples = samples;
+                        memset(write_frame.data, 255, write_frame.datalen);
+                        member_add_file_data(member, write_frame.data, write_frame.datalen);
+                        switch_core_session_write_frame(member-&gt;session, &amp;write_frame, SWITCH_IO_FLAG_NONE, 0);
+                } else if (!switch_test_flag(member-&gt;conference, CFLAG_WASTE_BANDWIDTH)) {
+                        if (switch_test_flag(member, MFLAG_WASTE_BANDWIDTH)) {
+                                if (member-&gt;conference-&gt;comfort_noise_level) {
+                                        switch_generate_sln_silence(write_frame.data, samples, member-&gt;conference-&gt;comfort_noise_level);
+                                } else {
+                                        memset(write_frame.data, 255, bytes);
+                                }
+
+                                write_frame.datalen = bytes;
+                                write_frame.samples = samples;
+                                write_frame.timestamp = timer.samplecount;
+
+                                switch_core_session_write_frame(member-&gt;session, &amp;write_frame, SWITCH_IO_FLAG_NONE, 0);
+                        }
+                }
+
+                if (switch_test_flag(member, MFLAG_FLUSH_BUFFER)) {
+                        if (switch_buffer_inuse(member-&gt;mux_buffer)) {
+                                switch_mutex_lock(member-&gt;audio_out_mutex);
+                                switch_buffer_zero(member-&gt;mux_buffer);
+                                switch_mutex_unlock(member-&gt;audio_out_mutex);
+                        }
+                        switch_clear_flag_locked(member, MFLAG_FLUSH_BUFFER);
+                }
+
+                switch_mutex_unlock(member-&gt;write_mutex);
+
+
+                if (switch_core_session_private_event_count(member-&gt;session)) {
+                        switch_channel_set_app_flag(channel, CF_APP_TAGGED);
+                        switch_ivr_parse_all_events(member-&gt;session);
+                        switch_channel_clear_app_flag(channel, CF_APP_TAGGED);
+                        switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER);
+                        switch_core_session_set_read_codec(member-&gt;session, &amp;member-&gt;read_codec);
+                } else {
+                        switch_ivr_parse_all_messages(member-&gt;session);
+                }
+
+                if (use_timer) {
+                        switch_core_timer_next(&amp;timer);
+                } else {
+                        switch_cond_next();
+                }
+
+        }                                                        /* Rinse ... Repeat */
+
+
+        if (member-&gt;digit_stream != NULL) {
+                switch_ivr_digit_stream_destroy(&amp;member-&gt;digit_stream);
+        }
+
+        switch_clear_flag_locked(member, MFLAG_RUNNING);
+        switch_core_timer_destroy(&amp;timer);
+
+        switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, &quot;Channel leaving conference, cause: %s\n&quot;,
+                                          switch_channel_cause2str(switch_channel_get_cause(channel)));
+
+        /* if it's an outbound channel, store the release cause in the conference struct, we might need it */
+        if (switch_channel_test_flag(channel, CF_OUTBOUND)) {
+                member-&gt;conference-&gt;bridge_hangup_cause = switch_channel_get_cause(channel);
+        }
+
+        /* Wait for the input thread to end */
+        while (switch_test_flag(member, MFLAG_ITHREAD)) {
+                switch_cond_next();
+        }
+}
+
+/* Sub-Routine called by a record entity inside a conference */
+static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *thread, void *obj)
+{
+        int16_t *data_buf;
+        switch_file_handle_t fh = { 0 };
+        conference_member_t smember = { 0 }, *member;
+        conference_record_t *rec = (conference_record_t *) obj;
+        conference_obj_t *conference = rec-&gt;conference;
+        uint32_t samples = switch_samples_per_packet(conference-&gt;rate, conference-&gt;interval);
+        uint32_t low_count = 0, mux_used;
+        char *vval;
+        switch_timer_t timer = { 0 };
+        uint32_t rlen;
+        switch_size_t data_buf_len;
+
+        data_buf_len = samples * sizeof(int16_t);
+
+        switch_zmalloc(data_buf, data_buf_len);
+
+        if (switch_thread_rwlock_tryrdlock(conference-&gt;rwlock) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Read Lock Fail\n&quot;);
+                return NULL;
+        }
+
+        switch_mutex_lock(globals.hash_mutex);
+        globals.threads++;
+        switch_mutex_unlock(globals.hash_mutex);
+
+        member = &amp;smember;
+
+        member-&gt;flags = MFLAG_CAN_HEAR | MFLAG_NOCHANNEL | MFLAG_RUNNING;
+
+        member-&gt;conference = conference;
+        member-&gt;native_rate = conference-&gt;rate;
+        member-&gt;rec_path = rec-&gt;path;
+        fh.channels = 1;
+        fh.samplerate = conference-&gt;rate;
+        member-&gt;id = next_member_id();
+        member-&gt;pool = rec-&gt;pool;
+
+        member-&gt;frame_size = SWITCH_RECOMMENDED_BUFFER_SIZE;
+        member-&gt;frame = switch_core_alloc(member-&gt;pool, member-&gt;frame_size);
+        member-&gt;mux_frame = switch_core_alloc(member-&gt;pool, member-&gt;frame_size);
+
+
+        switch_mutex_init(&amp;member-&gt;write_mutex, SWITCH_MUTEX_NESTED, rec-&gt;pool);
+        switch_mutex_init(&amp;member-&gt;flag_mutex, SWITCH_MUTEX_NESTED, rec-&gt;pool);
+        switch_mutex_init(&amp;member-&gt;audio_in_mutex, SWITCH_MUTEX_NESTED, rec-&gt;pool);
+        switch_mutex_init(&amp;member-&gt;audio_out_mutex, SWITCH_MUTEX_NESTED, rec-&gt;pool);
+        switch_mutex_init(&amp;member-&gt;read_mutex, SWITCH_MUTEX_NESTED, rec-&gt;pool);
+
+        /* Setup an audio buffer for the incoming audio */
+        if (switch_buffer_create_dynamic(&amp;member-&gt;audio_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, 0) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Memory Error Creating Audio Buffer!\n&quot;);
+                goto end;
+        }
+
+        /* Setup an audio buffer for the outgoing audio */
+        if (switch_buffer_create_dynamic(&amp;member-&gt;mux_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, 0) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Memory Error Creating Audio Buffer!\n&quot;);
+                goto end;
+        }
+
+        if (conference_add_member(conference, member) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Joining Conference\n&quot;);
+                goto end;
+        }
+
+        fh.pre_buffer_datalen = SWITCH_DEFAULT_FILE_BUFFER_LEN;
+
+        if (switch_core_file_open(&amp;fh,
+                                                          rec-&gt;path, (uint8_t) 1, conference-&gt;rate, SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT,
+                                                          rec-&gt;pool) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Opening File [%s]\n&quot;, rec-&gt;path);
+                goto end;
+        }
+
+
+        if (switch_core_timer_init(&amp;timer, conference-&gt;timer_name, conference-&gt;interval, samples, rec-&gt;pool) == SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Setup timer success interval: %u  samples: %u\n&quot;, conference-&gt;interval, samples);
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Timer Setup Failed.  Conference Cannot Start\n&quot;);
+                goto end;
+        }
+
+        if ((vval = switch_mprintf(&quot;Conference %s&quot;, conference-&gt;name))) {
+                switch_core_file_set_string(&amp;fh, SWITCH_AUDIO_COL_STR_TITLE, vval);
+                switch_safe_free(vval);
+        }
+
+        switch_core_file_set_string(&amp;fh, SWITCH_AUDIO_COL_STR_ARTIST, &quot;FreeSWITCH mod_conference Software Conference Module&quot;);
+
+        while (switch_test_flag(member, MFLAG_RUNNING) &amp;&amp; switch_test_flag(conference, CFLAG_RUNNING) &amp;&amp; conference-&gt;count) {
+                switch_size_t len = 0;
+                mux_used = (uint32_t) switch_buffer_inuse(member-&gt;mux_buffer);
+
+                if (switch_test_flag(member, MFLAG_FLUSH_BUFFER)) {
+                        if (mux_used) {
+                                switch_mutex_lock(member-&gt;audio_out_mutex);
+                                switch_buffer_zero(member-&gt;mux_buffer);
+                                switch_mutex_unlock(member-&gt;audio_out_mutex);
+                                mux_used = 0;
+                        }
+                        switch_clear_flag_locked(member, MFLAG_FLUSH_BUFFER);
+                }
+
+                if (switch_test_flag((&amp;fh), SWITCH_FILE_PAUSE)) {
+                        switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER);
+                } else {
+                        if (mux_used) {
+                                /* Flush the output buffer and write all the data (presumably muxed) to the file */
+                                switch_mutex_lock(member-&gt;audio_out_mutex);
+                                low_count = 0;
+
+                                if ((rlen = (uint32_t) switch_buffer_read(member-&gt;mux_buffer, data_buf, data_buf_len))) {
+                                        len = (switch_size_t) rlen / sizeof(int16_t);
+                                }
+                                switch_mutex_unlock(member-&gt;audio_out_mutex);
+                        }
+
+                        if (len &lt; (switch_size_t) samples) {
+                                memset(data_buf + (len * sizeof(int16_t)), 255, ((switch_size_t) samples - len) * sizeof(int16_t));
+                                len = (switch_size_t) samples;
+                        }
+
+                        if (!len || switch_core_file_write(&amp;fh, data_buf, &amp;len) != SWITCH_STATUS_SUCCESS) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write Failed\n&quot;);
+                                switch_clear_flag_locked(member, MFLAG_RUNNING);
+                        }
+                }
+
+                switch_core_timer_next(&amp;timer);
+        }                                                        /* Rinse ... Repeat */
+
+  end:
+
+        switch_safe_free(data_buf);
+        switch_core_timer_destroy(&amp;timer);
+        conference_del_member(conference, member);
+        switch_buffer_destroy(&amp;member-&gt;audio_buffer);
+        switch_buffer_destroy(&amp;member-&gt;mux_buffer);
+        switch_clear_flag_locked(member, MFLAG_RUNNING);
+        if (switch_test_flag((&amp;fh), SWITCH_FILE_OPEN)) {
+                switch_core_file_close(&amp;fh);
+        }
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Recording of %s Stopped\n&quot;, rec-&gt;path);
+
+        if (rec-&gt;pool) {
+                switch_memory_pool_t *pool = rec-&gt;pool;
+                rec = NULL;
+                switch_core_destroy_memory_pool(&amp;pool);
+        }
+
+        switch_mutex_lock(globals.hash_mutex);
+        globals.threads--;
+        switch_mutex_unlock(globals.hash_mutex);
+
+        switch_thread_rwlock_unlock(conference-&gt;rwlock);
+        return NULL;
+}
+
+/* Make files stop playing in a conference either the current one or all of them */
+static uint32_t conference_stop_file(conference_obj_t *conference, file_stop_t stop)
+{
+        uint32_t count = 0;
+        conference_file_node_t *nptr;
+
+        switch_assert(conference != NULL);
+
+        switch_mutex_lock(conference-&gt;mutex);
+
+        if (stop == FILE_STOP_ALL) {
+                for (nptr = conference-&gt;fnode; nptr; nptr = nptr-&gt;next) {
+                        nptr-&gt;done++;
+                        count++;
+                }
+                if (conference-&gt;async_fnode) {
+                        conference-&gt;async_fnode-&gt;done++;
+                        count++;
+                }
+        } else if (stop == FILE_STOP_ASYNC) {
+                if (conference-&gt;async_fnode) {
+                        conference-&gt;async_fnode-&gt;done++;
+                        count++;
+                }
+        } else {
+                if (conference-&gt;fnode) {
+                        conference-&gt;fnode-&gt;done++;
+                        count++;
+                }
+        }
+
+        switch_mutex_unlock(conference-&gt;mutex);
+
+        return count;
+}
+
+/* stop playing a file for the member of the conference */
+static uint32_t conference_member_stop_file(conference_member_t *member, file_stop_t stop)
+{
+        conference_file_node_t *nptr;
+        uint32_t count = 0;
+
+        if (member == NULL)
+                return count;
+
+        lock_member(member);
+
+        if (stop == FILE_STOP_ALL) {
+                for (nptr = member-&gt;fnode; nptr; nptr = nptr-&gt;next) {
+                        nptr-&gt;done++;
+                        count++;
+                }
+        } else {
+                if (member-&gt;fnode) {
+                        member-&gt;fnode-&gt;done++;
+                        count++;
+                }
+        }
+
+        unlock_member(member);
+
+        return count;
+}
+
+static void conference_send_all_dtmf(conference_member_t *member, conference_obj_t *conference, const char *dtmf)
+{
+        conference_member_t *imember;
+
+        switch_mutex_lock(conference-&gt;mutex);
+        switch_mutex_lock(conference-&gt;member_mutex);
+
+        for (imember = conference-&gt;members; imember; imember = imember-&gt;next) {
+                /* don't send to self */
+                if (imember-&gt;id == member-&gt;id) {
+                        continue;
+                }
+                if (imember-&gt;session) {
+                        const char *p;
+                        for (p = dtmf; p &amp;&amp; *p; p++) {
+                                switch_dtmf_t digit = { *p, SWITCH_DEFAULT_DTMF_DURATION };
+                                lock_member(imember);
+                                switch_core_session_kill_channel(imember-&gt;session, SWITCH_SIG_BREAK);
+                                switch_core_session_send_dtmf(imember-&gt;session, &amp;digit);
+                                unlock_member(imember);
+                        }
+                }
+        }
+
+        switch_mutex_unlock(conference-&gt;member_mutex);
+        switch_mutex_unlock(conference-&gt;mutex);
+}
+
+/* Play a file in the conference room */
+static switch_status_t conference_play_file(conference_obj_t *conference, char *file, uint32_t leadin, switch_channel_t *channel, uint8_t async)
+{
+        switch_status_t status = SWITCH_STATUS_SUCCESS;
+        conference_file_node_t *fnode, *nptr = NULL;
+        switch_memory_pool_t *pool;
+        uint32_t count;
+        char *dfile = NULL, *expanded = NULL;
+        int say = 0;
+
+        switch_assert(conference != NULL);
+
+        switch_mutex_lock(conference-&gt;mutex);
+        switch_mutex_lock(conference-&gt;member_mutex);
+        count = conference-&gt;count;
+        switch_mutex_unlock(conference-&gt;member_mutex);
+        switch_mutex_unlock(conference-&gt;mutex);
+
+        if (!count)
+                return SWITCH_STATUS_FALSE;
+
+        if (channel) {
+                if ((expanded = switch_channel_expand_variables(channel, file)) != file) {
+                        file = expanded;
+                } else {
+                        expanded = NULL;
+                }
+        }
+
+        if (!strncasecmp(file, &quot;say:&quot;, 4)) {
+                say = 1;
+        }
+
+        if (!async &amp;&amp; say) {
+                status = conference_say(conference, file + 4, leadin);
+                goto done;
+        }
+
+        if (!switch_is_file_path(file)) {
+                if (!say &amp;&amp; conference-&gt;sound_prefix) {
+                        if (!(dfile = switch_mprintf(&quot;%s%s%s&quot;, conference-&gt;sound_prefix, SWITCH_PATH_SEPARATOR, file))) {
+                                goto done;
+                        }
+                        file = dfile;
+                } else if (!async) {
+                        status = conference_say(conference, file, leadin);
+                        goto done;
+                } else {
+                        goto done;
+                }
+        }
+
+        /* Setup a memory pool to use. */
+        if (switch_core_new_memory_pool(&amp;pool) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Pool Failure\n&quot;);
+                status = SWITCH_STATUS_MEMERR;
+                goto done;
+        }
+
+        /* Create a node object */
+        if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Alloc Failure\n&quot;);
+                switch_core_destroy_memory_pool(&amp;pool);
+                status = SWITCH_STATUS_MEMERR;
+                goto done;
+        }
+
+        fnode-&gt;type = NODE_TYPE_FILE;
+        fnode-&gt;leadin = leadin;
+
+        /* Open the file */
+        fnode-&gt;fh.pre_buffer_datalen = SWITCH_DEFAULT_FILE_BUFFER_LEN;
+        if (switch_core_file_open(&amp;fnode-&gt;fh, file, (uint8_t) 1, conference-&gt;rate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, pool) !=
+                SWITCH_STATUS_SUCCESS) {
+                switch_core_destroy_memory_pool(&amp;pool);
+                status = SWITCH_STATUS_NOTFOUND;
+                goto done;
+        }
+
+        fnode-&gt;pool = pool;
+        fnode-&gt;async = async;
+        fnode-&gt;file = switch_core_strdup(fnode-&gt;pool, file);
+
+        /* Queue the node */
+        switch_mutex_lock(conference-&gt;mutex);
+
+        if (async) {
+                if (conference-&gt;async_fnode) {
+                        nptr = conference-&gt;async_fnode;
+                }
+                conference-&gt;async_fnode = fnode;
+
+                if (nptr) {
+                        switch_memory_pool_t *tmppool;
+                        switch_core_file_close(&amp;nptr-&gt;fh);
+                        tmppool = nptr-&gt;pool;
+                        switch_core_destroy_memory_pool(&amp;tmppool);
+                }
+
+        } else {
+                for (nptr = conference-&gt;fnode; nptr &amp;&amp; nptr-&gt;next; nptr = nptr-&gt;next);
+
+                if (nptr) {
+                        nptr-&gt;next = fnode;
+                } else {
+                        conference-&gt;fnode = fnode;
+                }
+        }
+
+        switch_mutex_unlock(conference-&gt;mutex);
+
+  done:
+
+        switch_safe_free(expanded);
+        switch_safe_free(dfile);
+
+        return status;
+}
+
+/* Play a file in the conference room to a member */
+static switch_status_t conference_member_play_file(conference_member_t *member, char *file, uint32_t leadin)
+{
+        switch_status_t status = SWITCH_STATUS_FALSE;
+        char *dfile = NULL, *expanded = NULL;
+        conference_file_node_t *fnode, *nptr = NULL;
+        switch_memory_pool_t *pool;
+
+        if (member == NULL || file == NULL)
+                return status;
+
+        if ((expanded = switch_channel_expand_variables(switch_core_session_get_channel(member-&gt;session), file)) != file) {
+                file = expanded;
+        } else {
+                expanded = NULL;
+        }
+        if (!strncasecmp(file, &quot;say:&quot;, 4)) {
+                if (!zstr(file + 4)) {
+                        status = conference_member_say(member, file + 4, leadin);
+                }
+                goto done;
+        }
+        if (!switch_is_file_path(file)) {
+                if (member-&gt;conference-&gt;sound_prefix) {
+                        if (!(dfile = switch_mprintf(&quot;%s%s%s&quot;, member-&gt;conference-&gt;sound_prefix, SWITCH_PATH_SEPARATOR, file))) {
+                                goto done;
+                        }
+                        file = dfile;
+                } else if (!zstr(file)) {
+                        status = conference_member_say(member, file, leadin);
+                        goto done;
+                }
+        }
+        /* Setup a memory pool to use. */
+        if (switch_core_new_memory_pool(&amp;pool) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_CRIT, &quot;Pool Failure\n&quot;);
+                status = SWITCH_STATUS_MEMERR;
+                goto done;
+        }
+        /* Create a node object */
+        if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_CRIT, &quot;Alloc Failure\n&quot;);
+                switch_core_destroy_memory_pool(&amp;pool);
+                status = SWITCH_STATUS_MEMERR;
+                goto done;
+        }
+        fnode-&gt;type = NODE_TYPE_FILE;
+        fnode-&gt;leadin = leadin;
+        /* Open the file */
+        fnode-&gt;fh.pre_buffer_datalen = SWITCH_DEFAULT_FILE_BUFFER_LEN;
+        if (switch_core_file_open(&amp;fnode-&gt;fh,
+                                                          file, (uint8_t) 1, member-&gt;conference-&gt;rate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
+                                                          pool) != SWITCH_STATUS_SUCCESS) {
+                switch_core_destroy_memory_pool(&amp;pool);
+                status = SWITCH_STATUS_NOTFOUND;
+                goto done;
+        }
+        fnode-&gt;pool = pool;
+        fnode-&gt;file = switch_core_strdup(fnode-&gt;pool, file);
+        /* Queue the node */
+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_DEBUG, &quot;Queueing file '%s' for play\n&quot;, file);
+        lock_member(member);
+        for (nptr = member-&gt;fnode; nptr &amp;&amp; nptr-&gt;next; nptr = nptr-&gt;next);
+        if (nptr) {
+                nptr-&gt;next = fnode;
+        } else {
+                member-&gt;fnode = fnode;
+        }
+        unlock_member(member);
+        status = SWITCH_STATUS_SUCCESS;
+
+  done:
+
+        switch_safe_free(expanded);
+        switch_safe_free(dfile);
+
+        return status;
+}
+
+/* Say some thing with TTS in the conference room */
+static switch_status_t conference_member_say(conference_member_t *member, char *text, uint32_t leadin)
+{
+        conference_obj_t *conference = (member != NULL ? member-&gt;conference : NULL);
+        conference_file_node_t *fnode, *nptr;
+        switch_memory_pool_t *pool;
+        switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
+        switch_status_t status = SWITCH_STATUS_FALSE;
+
+        if (member == NULL || zstr(text))
+                return SWITCH_STATUS_FALSE;
+
+        switch_assert(conference != NULL);
+
+        if (!(conference-&gt;tts_engine &amp;&amp; conference-&gt;tts_voice)) {
+                return SWITCH_STATUS_SUCCESS;
+        }
+
+        /* Setup a memory pool to use. */
+        if (switch_core_new_memory_pool(&amp;pool) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_CRIT, &quot;Pool Failure\n&quot;);
+                return SWITCH_STATUS_MEMERR;
+        }
+
+        /* Create a node object */
+        if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_CRIT, &quot;Alloc Failure\n&quot;);
+                switch_core_destroy_memory_pool(&amp;pool);
+                return SWITCH_STATUS_MEMERR;
+        }
+
+        fnode-&gt;type = NODE_TYPE_SPEECH;
+        fnode-&gt;leadin = leadin;
+        fnode-&gt;pool = pool;
+
+        if (!member-&gt;sh) {
+                memset(&amp;member-&gt;lsh, 0, sizeof(member-&gt;lsh));
+                if (switch_core_speech_open(&amp;member-&gt;lsh, conference-&gt;tts_engine, conference-&gt;tts_voice,
+                                                                        conference-&gt;rate, conference-&gt;interval, &amp;flags, switch_core_session_get_pool(member-&gt;session)) !=
+                        SWITCH_STATUS_SUCCESS) {
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_ERROR, &quot;Invalid TTS module [%s]!\n&quot;, conference-&gt;tts_engine);
+                        return SWITCH_STATUS_FALSE;
+                }
+                member-&gt;sh = &amp;member-&gt;lsh;
+        }
+
+        /* Queue the node */
+        lock_member(member);
+        for (nptr = member-&gt;fnode; nptr &amp;&amp; nptr-&gt;next; nptr = nptr-&gt;next);
+
+        if (nptr) {
+                nptr-&gt;next = fnode;
+        } else {
+                member-&gt;fnode = fnode;
+        }
+
+        fnode-&gt;sh = member-&gt;sh;
+        /* Begin Generation */
+        switch_sleep(200000);
+
+        if (*text == '#') {
+                char *tmp = (char *) text + 1;
+                char *vp = tmp, voice[128] = &quot;&quot;;
+                if ((tmp = strchr(tmp, '#'))) {
+                        text = tmp + 1;
+                        switch_copy_string(voice, vp, (tmp - vp) + 1);
+                        switch_core_speech_text_param_tts(fnode-&gt;sh, &quot;voice&quot;, voice);
+                }
+        } else {
+                switch_core_speech_text_param_tts(fnode-&gt;sh, &quot;voice&quot;, conference-&gt;tts_voice);
+        }
+
+        switch_core_speech_feed_tts(fnode-&gt;sh, text, &amp;flags);
+        unlock_member(member);
+
+        status = SWITCH_STATUS_SUCCESS;
+
+        return status;
+}
+
+/* Say some thing with TTS in the conference room */
+static switch_status_t conference_say(conference_obj_t *conference, const char *text, uint32_t leadin)
+{
+        switch_status_t status = SWITCH_STATUS_FALSE;
+        conference_file_node_t *fnode, *nptr;
+        switch_memory_pool_t *pool;
+        switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
+        uint32_t count;
+
+        switch_assert(conference != NULL);
+
+        if (zstr(text)) {
+                return SWITCH_STATUS_GENERR;
+        }
+
+        switch_mutex_lock(conference-&gt;mutex);
+        switch_mutex_lock(conference-&gt;member_mutex);
+        count = conference-&gt;count;
+        if (!(conference-&gt;tts_engine &amp;&amp; conference-&gt;tts_voice)) {
+                count = 0;
+        }
+        switch_mutex_unlock(conference-&gt;member_mutex);
+        switch_mutex_unlock(conference-&gt;mutex);
+
+        if (!count) {
+                return SWITCH_STATUS_FALSE;
+        }
+
+        /* Setup a memory pool to use. */
+        if (switch_core_new_memory_pool(&amp;pool) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Pool Failure\n&quot;);
+                return SWITCH_STATUS_MEMERR;
+        }
+
+        /* Create a node object */
+        if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Alloc Failure\n&quot;);
+                switch_core_destroy_memory_pool(&amp;pool);
+                return SWITCH_STATUS_MEMERR;
+        }
+
+        fnode-&gt;type = NODE_TYPE_SPEECH;
+        fnode-&gt;leadin = leadin;
+
+        if (!conference-&gt;sh) {
+                memset(&amp;conference-&gt;lsh, 0, sizeof(conference-&gt;lsh));
+                if (switch_core_speech_open(&amp;conference-&gt;lsh, conference-&gt;tts_engine, conference-&gt;tts_voice,
+                                                                        conference-&gt;rate, conference-&gt;interval, &amp;flags, NULL) != SWITCH_STATUS_SUCCESS) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid TTS module [%s]!\n&quot;, conference-&gt;tts_engine);
+                        return SWITCH_STATUS_FALSE;
+                }
+                conference-&gt;sh = &amp;conference-&gt;lsh;
+        }
+
+        fnode-&gt;pool = pool;
+
+        /* Queue the node */
+        switch_mutex_lock(conference-&gt;mutex);
+        for (nptr = conference-&gt;fnode; nptr &amp;&amp; nptr-&gt;next; nptr = nptr-&gt;next);
+
+        if (nptr) {
+                nptr-&gt;next = fnode;
+        } else {
+                conference-&gt;fnode = fnode;
+        }
+
+        fnode-&gt;sh = conference-&gt;sh;
+        if (*text == '#') {
+                char *tmp = (char *) text + 1;
+                char *vp = tmp, voice[128] = &quot;&quot;;
+                if ((tmp = strchr(tmp, '#'))) {
+                        text = tmp + 1;
+                        switch_copy_string(voice, vp, (tmp - vp) + 1);
+                        switch_core_speech_text_param_tts(fnode-&gt;sh, &quot;voice&quot;, voice);
+                }
+        } else {
+                switch_core_speech_text_param_tts(fnode-&gt;sh, &quot;voice&quot;, conference-&gt;tts_voice);
+        }
+
+        /* Begin Generation */
+        switch_sleep(200000);
+        switch_core_speech_feed_tts(fnode-&gt;sh, (char *) text, &amp;flags);
+        switch_mutex_unlock(conference-&gt;mutex);
+        status = SWITCH_STATUS_SUCCESS;
+
+        return status;
+}
+
+/* execute a callback for every member of the conference */
+static void conference_member_itterator(conference_obj_t *conference, switch_stream_handle_t *stream, conf_api_member_cmd_t pfncallback, void *data)
+{
+        conference_member_t *member = NULL;
+
+        switch_assert(conference != NULL);
+        switch_assert(stream != NULL);
+        switch_assert(pfncallback != NULL);
+
+        switch_mutex_lock(conference-&gt;member_mutex);
+        for (member = conference-&gt;members; member; member = member-&gt;next) {
+                if (member-&gt;session &amp;&amp; !switch_test_flag(member, MFLAG_NOCHANNEL)) {
+                        pfncallback(member, stream, data);
+                }
+        }
+        switch_mutex_unlock(conference-&gt;member_mutex);
+}
+
+static void conference_list_pretty(conference_obj_t *conference, switch_stream_handle_t *stream)
+{
+        conference_member_t *member = NULL;
+
+        switch_assert(conference != NULL);
+        switch_assert(stream != NULL);
+
+        switch_mutex_lock(conference-&gt;member_mutex);
+
+        for (member = conference-&gt;members; member; member = member-&gt;next) {
+                switch_channel_t *channel;
+                switch_caller_profile_t *profile;
+
+                if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
+                        continue;
+                }
+                channel = switch_core_session_get_channel(member-&gt;session);
+                profile = switch_channel_get_caller_profile(channel);
+
+                stream-&gt;write_function(stream, &quot;%u) %s (%s)\n&quot;, member-&gt;id, profile-&gt;caller_id_name, profile-&gt;caller_id_number);
+        }
+
+        switch_mutex_unlock(conference-&gt;member_mutex);
+}
+
+static void conference_list(conference_obj_t *conference, switch_stream_handle_t *stream, char *delim)
+{
+        conference_member_t *member = NULL;
+
+        switch_assert(conference != NULL);
+        switch_assert(stream != NULL);
+        switch_assert(delim != NULL);
+
+        switch_mutex_lock(conference-&gt;member_mutex);
+
+        for (member = conference-&gt;members; member; member = member-&gt;next) {
+                switch_channel_t *channel;
+                switch_caller_profile_t *profile;
+                char *uuid;
+                char *name;
+                uint32_t count = 0;
+
+                if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
+                        continue;
+                }
+
+                uuid = switch_core_session_get_uuid(member-&gt;session);
+                channel = switch_core_session_get_channel(member-&gt;session);
+                profile = switch_channel_get_caller_profile(channel);
+                name = switch_channel_get_name(channel);
+
+                stream-&gt;write_function(stream, &quot;%u%s%s%s%s%s%s%s%s%s&quot;,
+                                                           member-&gt;id, delim, name, delim, uuid, delim, profile-&gt;caller_id_name, delim, profile-&gt;caller_id_number, delim);
+
+                if (switch_test_flag(member, MFLAG_CAN_HEAR)) {
+                        stream-&gt;write_function(stream, &quot;hear&quot;);
+                        count++;
+                }
+
+                if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
+                        stream-&gt;write_function(stream, &quot;%s%s&quot;, count ? &quot;|&quot; : &quot;&quot;, &quot;speak&quot;);
+                        count++;
+                }
+
+                if (switch_test_flag(member, MFLAG_TALKING)) {
+                        stream-&gt;write_function(stream, &quot;%s%s&quot;, count ? &quot;|&quot; : &quot;&quot;, &quot;talking&quot;);
+                        count++;
+                }
+
+                if (switch_channel_test_flag(switch_core_session_get_channel(member-&gt;session), CF_VIDEO)) {
+                        stream-&gt;write_function(stream, &quot;%s%s&quot;, count ? &quot;|&quot; : &quot;&quot;, &quot;video&quot;);
+                        count++;
+                }
+
+                if (member == member-&gt;conference-&gt;floor_holder) {
+                        stream-&gt;write_function(stream, &quot;%s%s&quot;, count ? &quot;|&quot; : &quot;&quot;, &quot;floor&quot;);
+                        count++;
+                }
+
+                stream-&gt;write_function(stream, &quot;%s%d%s%d%s%d\n&quot;, delim, member-&gt;volume_in_level, delim, member-&gt;volume_out_level, delim, member-&gt;energy_level);
+        }
+
+        switch_mutex_unlock(conference-&gt;member_mutex);
+}
+
+static switch_status_t conf_api_sub_mute(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+{
+        switch_event_t *event;
+
+        if (member == NULL)
+                return SWITCH_STATUS_GENERR;
+
+        switch_clear_flag_locked(member, MFLAG_CAN_SPEAK);
+        if (!zstr(member-&gt;conference-&gt;muted_sound)) {
+                conference_member_play_file(member, member-&gt;conference-&gt;muted_sound, 0);
+        } else {
+                char msg[512];
+
+                switch_snprintf(msg, sizeof(msg), &quot;Muted&quot;);
+                conference_member_say(member, msg, 0);
+        }
+        if (stream != NULL) {
+                stream-&gt;write_function(stream, &quot;OK mute %u\n&quot;, member-&gt;id);
+        }
+        if (test_eflag(member-&gt;conference, EFLAG_MUTE_MEMBER) &amp;&amp;
+                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;mute-member&quot;);
+                switch_event_fire(&amp;event);
+        }
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_api_sub_unmute(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+{
+        switch_event_t *event;
+
+        if (member == NULL)
+                return SWITCH_STATUS_GENERR;
+
+        switch_set_flag_locked(member, MFLAG_CAN_SPEAK);
+        if (stream != NULL) {
+                stream-&gt;write_function(stream, &quot;OK unmute %u\n&quot;, member-&gt;id);
+        }
+        if (!zstr(member-&gt;conference-&gt;unmuted_sound)) {
+                conference_member_play_file(member, member-&gt;conference-&gt;unmuted_sound, 0);
+        } else {
+                char msg[512];
+
+                switch_snprintf(msg, sizeof(msg), &quot;Un-Muted&quot;);
+                conference_member_say(member, msg, 0);
+        }
+        if (test_eflag(member-&gt;conference, EFLAG_UNMUTE_MEMBER) &amp;&amp;
+                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;unmute-member&quot;);
+                switch_event_fire(&amp;event);
+        }
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_api_sub_deaf(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+{
+        switch_event_t *event;
+
+        if (member == NULL)
+                return SWITCH_STATUS_GENERR;
+
+        switch_clear_flag_locked(member, MFLAG_CAN_HEAR);
+        if (stream != NULL) {
+                stream-&gt;write_function(stream, &quot;OK deaf %u\n&quot;, member-&gt;id);
+        }
+        if (switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;deaf-member&quot;);
+                switch_event_fire(&amp;event);
+        }
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_api_sub_undeaf(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+{
+        switch_event_t *event;
+
+        if (member == NULL)
+                return SWITCH_STATUS_GENERR;
+
+        switch_set_flag_locked(member, MFLAG_CAN_HEAR);
+        if (stream != NULL) {
+                stream-&gt;write_function(stream, &quot;OK undeaf %u\n&quot;, member-&gt;id);
+        }
+        if (switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;undeaf-member&quot;);
+                switch_event_fire(&amp;event);
+        }
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_api_sub_kick(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+{
+        switch_event_t *event;
+
+        if (member == NULL)
+                return SWITCH_STATUS_GENERR;
+
+        lock_member(member);
+        switch_clear_flag(member, MFLAG_RUNNING);
+        switch_set_flag_locked(member, MFLAG_KICKED);
+
+        switch_core_session_kill_channel(member-&gt;session, SWITCH_SIG_BREAK);
+        unlock_member(member);
+        if (stream != NULL) {
+                stream-&gt;write_function(stream, &quot;OK kicked %u\n&quot;, member-&gt;id);
+        }
+        if (member-&gt;conference &amp;&amp; test_eflag(member-&gt;conference, EFLAG_KICK_MEMBER)) {
+                if (switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                        conference_add_event_member_data(member, event);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;kick-member&quot;);
+                        switch_event_fire(&amp;event);
+                }
+        }
+        return SWITCH_STATUS_SUCCESS;
+}
+
+
+static switch_status_t conf_api_sub_dtmf(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+{
+        switch_event_t *event;
+        char *dtmf = (char *) data;
+
+        if (member == NULL) {
+                stream-&gt;write_function(stream, &quot;Invalid member!\n&quot;);
+                return SWITCH_STATUS_GENERR;
+        }
+
+        if (zstr(dtmf)) {
+                stream-&gt;write_function(stream, &quot;Invalid input!\n&quot;);
+                return SWITCH_STATUS_GENERR;
+        }
+
+        lock_member(member);
+        switch_core_session_kill_channel(member-&gt;session, SWITCH_SIG_BREAK);
+        switch_core_session_send_dtmf_string(member-&gt;session, (char *) data);
+        unlock_member(member);
+
+        if (stream != NULL) {
+                stream-&gt;write_function(stream, &quot;OK sent %s to %u\n&quot;, (char *) data, member-&gt;id);
+        }
+
+        if (test_eflag(member-&gt;conference, EFLAG_DTMF_MEMBER) &amp;&amp;
+                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;dtmf-member&quot;);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Digits&quot;, dtmf);
+                switch_event_fire(&amp;event);
+        }
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_api_sub_energy(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+{
+        switch_event_t *event;
+
+        if (member == NULL)
+                return SWITCH_STATUS_GENERR;
+
+        if (data) {
+                lock_member(member);
+                member-&gt;energy_level = atoi((char *) data);
+                unlock_member(member);
+        }
+        if (stream != NULL) {
+                stream-&gt;write_function(stream, &quot;Energy %u = %d\n&quot;, member-&gt;id, member-&gt;energy_level);
+        }
+        if (test_eflag(member-&gt;conference, EFLAG_ENERGY_LEVEL_MEMBER) &amp;&amp;
+                data &amp;&amp; switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;energy-level-member&quot;);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Energy-Level&quot;, &quot;%d&quot;, member-&gt;energy_level);
+                switch_event_fire(&amp;event);
+        }
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_api_sub_volume_in(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+{
+        switch_event_t *event;
+
+        if (member == NULL)
+                return SWITCH_STATUS_GENERR;
+
+        if (data) {
+                lock_member(member);
+                member-&gt;volume_in_level = atoi((char *) data);
+                switch_normalize_volume(member-&gt;volume_in_level);
+                unlock_member(member);
+        }
+        if (stream != NULL) {
+                stream-&gt;write_function(stream, &quot;Volume IN %u = %d\n&quot;, member-&gt;id, member-&gt;volume_in_level);
+        }
+        if (test_eflag(member-&gt;conference, EFLAG_VOLUME_IN_MEMBER) &amp;&amp;
+                data &amp;&amp; switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;volume-in-member&quot;);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Volume-Level&quot;, &quot;%u&quot;, member-&gt;volume_in_level);
+                switch_event_fire(&amp;event);
+        }
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_api_sub_volume_out(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+{
+        switch_event_t *event;
+
+        if (member == NULL)
+                return SWITCH_STATUS_GENERR;
+
+        if (data) {
+                lock_member(member);
+                member-&gt;volume_out_level = atoi((char *) data);
+                switch_normalize_volume(member-&gt;volume_out_level);
+                unlock_member(member);
+        }
+        if (stream != NULL) {
+                stream-&gt;write_function(stream, &quot;Volume OUT %u = %d\n&quot;, member-&gt;id, member-&gt;volume_out_level);
+        }
+        if (test_eflag(member-&gt;conference, EFLAG_VOLUME_OUT_MEMBER) &amp;&amp; data &amp;&amp;
+                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;volume-out-member&quot;);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Volume-Level&quot;, &quot;%u&quot;, member-&gt;volume_out_level);
+                switch_event_fire(&amp;event);
+        }
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_api_sub_list(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
+{
+        int ret_status = SWITCH_STATUS_GENERR;
+        int count = 0;
+        switch_hash_index_t *hi;
+        void *val;
+        char *d = &quot;;&quot;;
+        int pretty = 0;
+        int summary = 0;
+        int argofs = (argc &gt;= 2 &amp;&amp; strcasecmp(argv[1], &quot;list&quot;) == 0);        /* detect being called from chat vs. api */
+
+        if (argv[1 + argofs]) {
+                if (argv[2 + argofs] &amp;&amp; !strcasecmp(argv[1 + argofs], &quot;delim&quot;)) {
+                        d = argv[2 + argofs];
+
+                        if (*d == '&quot;') {
+                                if (++d) {
+                                        char *p;
+                                        if ((p = strchr(d, '&quot;'))) {
+                                                *p = '\0';
+                                        }
+                                } else {
+                                        d = &quot;;&quot;;
+                                }
+                        }
+                } else if (strcasecmp(argv[1 + argofs], &quot;pretty&quot;) == 0) {
+                        pretty = 1;
+                } else if (strcasecmp(argv[1 + argofs], &quot;summary&quot;) == 0) {
+                        summary = 1;
+                }
+        }
+
+        if (conference == NULL) {
+                switch_mutex_lock(globals.hash_mutex);
+                for (hi = switch_hash_first(NULL, globals.conference_hash); hi; hi = switch_hash_next(hi)) {
+                        switch_hash_this(hi, NULL, NULL, &amp;val);
+                        conference = (conference_obj_t *) val;
+
+                        stream-&gt;write_function(stream, &quot;Conference %s (%u member%s rate: %u%s)\n&quot;,
+                                                                   conference-&gt;name,
+                                                                   conference-&gt;count,
+                                                                   conference-&gt;count == 1 ? &quot;&quot; : &quot;s&quot;, conference-&gt;rate, switch_test_flag(conference, CFLAG_LOCKED) ? &quot; locked&quot; : &quot;&quot;);
+                        count++;
+                        if (!summary) {
+                                if (pretty) {
+                                        conference_list_pretty(conference, stream);
+                                } else {
+                                        conference_list(conference, stream, d);
+                                }
+                        }
+                }
+                switch_mutex_unlock(globals.hash_mutex);
+        } else {
+                count++;
+                if (pretty) {
+                        conference_list_pretty(conference, stream);
+                } else {
+                        conference_list(conference, stream, d);
+                }
+        }
+
+        if (!count) {
+                stream-&gt;write_function(stream, &quot;No active conferences.\n&quot;);
+        }
+
+        ret_status = SWITCH_STATUS_SUCCESS;
+
+        return ret_status;
+}
+
+
+static void add_x_tag(switch_xml_t x_member, const char *name, const char *value, int off)
+{
+        switch_size_t dlen = strlen(value) * 3;
+        char *data;
+        switch_xml_t x_tag;
+
+        x_tag = switch_xml_add_child_d(x_member, name, off);
+        switch_assert(x_tag);
+
+        switch_zmalloc(data, dlen);
+
+        switch_url_encode(value, data, dlen);
+        switch_xml_set_txt_d(x_tag, data);
+        free(data);
+}
+
+static void conference_xlist(conference_obj_t *conference, switch_xml_t x_conference, int off)
+{
+        conference_member_t *member = NULL;
+        switch_xml_t x_member = NULL, x_members = NULL, x_flags;
+        int moff = 0;
+        char i[30] = &quot;&quot;;
+        char *ival = i;
+        switch_assert(conference != NULL);
+        switch_assert(x_conference != NULL);
+
+        switch_xml_set_attr_d(x_conference, &quot;name&quot;, conference-&gt;name);
+        switch_snprintf(i, sizeof(i), &quot;%d&quot;, conference-&gt;count);
+        switch_xml_set_attr_d(x_conference, &quot;member-count&quot;, ival);
+        switch_snprintf(i, sizeof(i), &quot;%u&quot;, conference-&gt;rate);
+        switch_xml_set_attr_d(x_conference, &quot;rate&quot;, ival);
+
+        if (switch_test_flag(conference, CFLAG_LOCKED)) {
+                switch_xml_set_attr_d(x_conference, &quot;locked&quot;, &quot;true&quot;);
+        }
+
+        if (switch_test_flag(conference, CFLAG_DESTRUCT)) {
+                switch_xml_set_attr_d(x_conference, &quot;destruct&quot;, &quot;true&quot;);
+        }
+
+        if (switch_test_flag(conference, CFLAG_WAIT_MOD)) {
+                switch_xml_set_attr_d(x_conference, &quot;wait_mod&quot;, &quot;true&quot;);
+        }
+
+        if (switch_test_flag(conference, CFLAG_RUNNING)) {
+                switch_xml_set_attr_d(x_conference, &quot;running&quot;, &quot;true&quot;);
+        }
+
+        if (switch_test_flag(conference, CFLAG_ANSWERED)) {
+                switch_xml_set_attr_d(x_conference, &quot;answered&quot;, &quot;true&quot;);
+        }
+
+        if (switch_test_flag(conference, CFLAG_ENFORCE_MIN)) {
+                switch_xml_set_attr_d(x_conference, &quot;enforce_min&quot;, &quot;true&quot;);
+        }
+
+        if (switch_test_flag(conference, CFLAG_BRIDGE_TO)) {
+                switch_xml_set_attr_d(x_conference, &quot;bridge_to&quot;, &quot;true&quot;);
+        }
+
+        if (switch_test_flag(conference, CFLAG_DYNAMIC)) {
+                switch_xml_set_attr_d(x_conference, &quot;dynamic&quot;, &quot;true&quot;);
+        }
+
+        x_members = switch_xml_add_child_d(x_conference, &quot;members&quot;, 0);
+        switch_assert(x_members);
+
+        switch_mutex_lock(conference-&gt;member_mutex);
+
+        for (member = conference-&gt;members; member; member = member-&gt;next) {
+                switch_channel_t *channel;
+                switch_caller_profile_t *profile;
+                char *uuid;
+                char *name;
+                uint32_t count = 0;
+                switch_xml_t x_tag;
+                int toff = 0;
+
+                if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
+                        continue;
+                }
+
+                uuid = switch_core_session_get_uuid(member-&gt;session);
+                channel = switch_core_session_get_channel(member-&gt;session);
+                profile = switch_channel_get_caller_profile(channel);
+                name = switch_channel_get_name(channel);
+
+
+                x_member = switch_xml_add_child_d(x_members, &quot;member&quot;, moff++);
+                switch_assert(x_member);
+
+                switch_snprintf(i, sizeof(i), &quot;%d&quot;, member-&gt;id);
+
+                add_x_tag(x_member, &quot;id&quot;, i, toff++);
+                add_x_tag(x_member, &quot;uuid&quot;, uuid, toff++);
+                add_x_tag(x_member, &quot;caller_id_name&quot;, profile-&gt;caller_id_name, toff++);
+                add_x_tag(x_member, &quot;caller_id_number&quot;, profile-&gt;caller_id_number, toff++);
+
+
+                x_flags = switch_xml_add_child_d(x_member, &quot;flags&quot;, count++);
+                switch_assert(x_flags);
+
+                x_tag = switch_xml_add_child_d(x_flags, &quot;can_hear&quot;, count++);
+                switch_xml_set_txt_d(x_tag, switch_test_flag(member, MFLAG_CAN_HEAR) ? &quot;true&quot; : &quot;false&quot;);
+
+                x_tag = switch_xml_add_child_d(x_flags, &quot;can_speak&quot;, count++);
+                switch_xml_set_txt_d(x_tag, switch_test_flag(member, MFLAG_CAN_SPEAK) ? &quot;true&quot; : &quot;false&quot;);
+
+                x_tag = switch_xml_add_child_d(x_flags, &quot;talking&quot;, count++);
+                switch_xml_set_txt_d(x_tag, switch_test_flag(member, MFLAG_TALKING) ? &quot;true&quot; : &quot;false&quot;);
+
+                x_tag = switch_xml_add_child_d(x_flags, &quot;has_video&quot;, count++);
+                switch_xml_set_txt_d(x_tag, switch_channel_test_flag(switch_core_session_get_channel(member-&gt;session), CF_VIDEO) ? &quot;true&quot; : &quot;false&quot;);
+
+                x_tag = switch_xml_add_child_d(x_flags, &quot;has_floor&quot;, count++);
+                switch_xml_set_txt_d(x_tag, (member == member-&gt;conference-&gt;floor_holder) ? &quot;true&quot; : &quot;false&quot;);
+
+                x_tag = switch_xml_add_child_d(x_flags, &quot;is_moderator&quot;, count++);
+                switch_xml_set_txt_d(x_tag, switch_test_flag(member, MFLAG_MOD) ? &quot;true&quot; : &quot;false&quot;);
+
+                x_tag = switch_xml_add_child_d(x_flags, &quot;end_conference&quot;, count++);
+                switch_xml_set_txt_d(x_tag, switch_test_flag(member, MFLAG_ENDCONF) ? &quot;true&quot; : &quot;false&quot;);
+
+        }
+
+        switch_mutex_unlock(conference-&gt;member_mutex);
+}
+static switch_status_t conf_api_sub_xml_list(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
+{
+        int count = 0;
+        switch_hash_index_t *hi;
+        void *val;
+        switch_xml_t x_conference, x_conferences;
+        int off = 0;
+        char *ebuf;
+
+        x_conferences = switch_xml_new(&quot;conferences&quot;);
+        switch_assert(x_conferences);
+
+        if (conference == NULL) {
+                switch_mutex_lock(globals.hash_mutex);
+                for (hi = switch_hash_first(NULL, globals.conference_hash); hi; hi = switch_hash_next(hi)) {
+                        switch_hash_this(hi, NULL, NULL, &amp;val);
+                        conference = (conference_obj_t *) val;
+
+                        x_conference = switch_xml_add_child_d(x_conferences, &quot;conference&quot;, off++);
+                        switch_assert(conference);
+
+                        count++;
+                        conference_xlist(conference, x_conference, off);
+
+                }
+                switch_mutex_unlock(globals.hash_mutex);
+        } else {
+                x_conference = switch_xml_add_child_d(x_conferences, &quot;conference&quot;, off++);
+                switch_assert(conference);
+                count++;
+                conference_xlist(conference, x_conference, off);
+        }
+
+
+        ebuf = switch_xml_toxml(x_conferences, SWITCH_TRUE);
+
+        stream-&gt;write_function(stream, &quot;%s&quot;, ebuf);
+
+        switch_xml_free(x_conferences);
+        free(ebuf);
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_api_sub_play(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
+{
+        int ret_status = SWITCH_STATUS_GENERR;
+        switch_event_t *event;
+        uint8_t async = 0;
+
+        switch_assert(conference != NULL);
+        switch_assert(stream != NULL);
+
+        if ((argc == 4 &amp;&amp; !strcasecmp(argv[3], &quot;async&quot;)) || (argc == 5 &amp;&amp; !strcasecmp(argv[4], &quot;async&quot;))) {
+                argc--;
+                async++;
+        }
+
+        if (argc == 3) {
+                if (conference_play_file(conference, argv[2], 0, NULL, async) == SWITCH_STATUS_SUCCESS) {
+                        stream-&gt;write_function(stream, &quot;(play) Playing file %s\n&quot;, argv[2]);
+                        if (test_eflag(conference, EFLAG_PLAY_FILE) &amp;&amp;
+                                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                                conference_add_event_data(conference, event);
+                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;play-file&quot;);
+                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;File&quot;, argv[2]);
+                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Async&quot;, async ? &quot;true&quot; : &quot;false&quot;);
+                                switch_event_fire(&amp;event);
+                        }
+                } else {
+                        stream-&gt;write_function(stream, &quot;(play) File: %s not found.\n&quot;, argv[2] ? argv[2] : &quot;(unspecified)&quot;);
+                }
+                ret_status = SWITCH_STATUS_SUCCESS;
+        } else if (argc == 4) {
+                uint32_t id = atoi(argv[3]);
+                conference_member_t *member;
+
+                if ((member = conference_member_get(conference, id))) {
+                        if (conference_member_play_file(member, argv[2], 0) == SWITCH_STATUS_SUCCESS) {
+                                stream-&gt;write_function(stream, &quot;(play) Playing file %s to member %u\n&quot;, argv[2], id);
+                                if (test_eflag(conference, EFLAG_PLAY_FILE_MEMBER) &amp;&amp;
+                                        switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                                        conference_add_event_member_data(member, event);
+                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;play-file-member&quot;);
+                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;File&quot;, argv[2]);
+                                        switch_event_fire(&amp;event);
+                                }
+                        } else {
+                                stream-&gt;write_function(stream, &quot;(play) File: %s not found.\n&quot;, argv[2] ? argv[2] : &quot;(unspecified)&quot;);
+                        }
+                        ret_status = SWITCH_STATUS_SUCCESS;
+                } else {
+                        stream-&gt;write_function(stream, &quot;Member: %u not found.\n&quot;, id);
+                }
+        }
+
+        return ret_status;
+}
+
+static switch_status_t conf_api_sub_say(conference_obj_t *conference, switch_stream_handle_t *stream, const char *text)
+{
+        switch_event_t *event;
+
+        if (zstr(text)) {
+                stream-&gt;write_function(stream, &quot;(say) Error! No text.\n&quot;);
+                return SWITCH_STATUS_GENERR;
+        }
+
+        if (conference_say(conference, text, 0) != SWITCH_STATUS_SUCCESS) {
+                stream-&gt;write_function(stream, &quot;(say) Error!\n&quot;);
+                return SWITCH_STATUS_GENERR;
+        }
+
+        stream-&gt;write_function(stream, &quot;(say) OK\n&quot;);
+        if (test_eflag(conference, EFLAG_SPEAK_TEXT) &amp;&amp; switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_data(conference, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;speak-text&quot;);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Text&quot;, text);
+                switch_event_fire(&amp;event);
+        }
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_api_sub_saymember(conference_obj_t *conference, switch_stream_handle_t *stream, const char *text)
+{
+        int ret_status = SWITCH_STATUS_GENERR;
+        char *expanded = NULL;
+        char *start_text = NULL;
+        char *workspace = NULL;
+        uint32_t id = 0;
+        conference_member_t *member;
+        switch_event_t *event;
+
+        if (zstr(text)) {
+                stream-&gt;write_function(stream, &quot;(saymember) No Text!\n&quot;);
+                goto done;
+        }
+
+        if (!(workspace = strdup(text))) {
+                stream-&gt;write_function(stream, &quot;(saymember) Memory Error!\n&quot;);
+                goto done;
+        }
+
+        if ((start_text = strchr(workspace, ' '))) {
+                *start_text++ = '\0';
+                text = start_text;
+        }
+
+        id = atoi(workspace);
+
+        if (!id || zstr(text)) {
+                stream-&gt;write_function(stream, &quot;(saymember) No Text!\n&quot;);
+                goto done;
+        }
+
+        if (!(member = conference_member_get(conference, id))) {
+                stream-&gt;write_function(stream, &quot;(saymember) Unknown Member %u!\n&quot;, id);
+                goto done;
+        }
+
+        if ((expanded = switch_channel_expand_variables(switch_core_session_get_channel(member-&gt;session), (char *) text)) != text) {
+                text = expanded;
+        } else {
+                expanded = NULL;
+        }
+
+        if (!text || conference_member_say(member, (char *) text, 0) != SWITCH_STATUS_SUCCESS) {
+                stream-&gt;write_function(stream, &quot;(saymember) Error!\n&quot;);
+                goto done;
+        }
+
+        stream-&gt;write_function(stream, &quot;(saymember) OK\n&quot;);
+        if (test_eflag(member-&gt;conference, EFLAG_SPEAK_TEXT_MEMBER) &amp;&amp;
+                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_member_data(member, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;speak-text-member&quot;);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Text&quot;, text);
+                switch_event_fire(&amp;event);
+        }
+        ret_status = SWITCH_STATUS_SUCCESS;
+
+  done:
+        switch_safe_free(workspace);
+        switch_safe_free(expanded);
+        return ret_status;
+}
+
+static switch_status_t conf_api_sub_stop(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
+{
+        uint8_t current = 0, all = 0, async = 0;
+
+        switch_assert(conference != NULL);
+        switch_assert(stream != NULL);
+
+        if (argc &gt; 2) {
+                current = strcasecmp(argv[2], &quot;current&quot;) ? 0 : 1;
+                all = strcasecmp(argv[2], &quot;all&quot;) ? 0 : 1;
+                async = strcasecmp(argv[2], &quot;async&quot;) ? 0 : 1;
+        } else {
+                all = 1;
+        }
+
+        if (!(current || all || async))
+                return SWITCH_STATUS_GENERR;
+
+        if (argc == 4) {
+                uint32_t id = atoi(argv[3]);
+                conference_member_t *member;
+
+                if ((member = conference_member_get(conference, id))) {
+                        uint32_t stopped = conference_member_stop_file(member, async ? FILE_STOP_ASYNC : current ? FILE_STOP_CURRENT : FILE_STOP_ALL);
+                        stream-&gt;write_function(stream, &quot;Stopped %u files.\n&quot;, stopped);
+                } else {
+                        stream-&gt;write_function(stream, &quot;Member: %u not found.\n&quot;, id);
+                }
+        } else {
+                uint32_t stopped = conference_stop_file(conference, async ? FILE_STOP_ASYNC : current ? FILE_STOP_CURRENT : FILE_STOP_ALL);
+                stream-&gt;write_function(stream, &quot;Stopped %u files.\n&quot;, stopped);
+        }
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_api_sub_relate(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
+{
+        uint8_t nospeak = 0, nohear = 0, clear = 0;
+
+        switch_assert(conference != NULL);
+        switch_assert(stream != NULL);
+
+        if (argc &lt;= 4)
+                return SWITCH_STATUS_GENERR;
+
+        nospeak = strstr(argv[4], &quot;nospeak&quot;) ? 1 : 0;
+        nohear = strstr(argv[4], &quot;nohear&quot;) ? 1 : 0;
+
+        if (!strcasecmp(argv[4], &quot;clear&quot;)) {
+                clear = 1;
+        }
+
+        if (!(clear || nospeak || nohear)) {
+                return SWITCH_STATUS_GENERR;
+        }
+
+        if (clear) {
+                conference_member_t *member = NULL;
+                uint32_t id = atoi(argv[2]);
+                uint32_t oid = atoi(argv[3]);
+
+                if ((member = conference_member_get(conference, id))) {
+                        member_del_relationship(member, oid);
+                        stream-&gt;write_function(stream, &quot;relationship %u-&gt;%u cleared.\n&quot;, id, oid);
+                } else {
+                        stream-&gt;write_function(stream, &quot;relationship %u-&gt;%u not found.\n&quot;, id, oid);
+                }
+                return SWITCH_STATUS_SUCCESS;
+        }
+
+        if (nospeak || nohear) {
+                conference_member_t *member = NULL, *other_member = NULL;
+                uint32_t id = atoi(argv[2]);
+                uint32_t oid = atoi(argv[3]);
+
+                if ((member = conference_member_get(conference, id))
+                        &amp;&amp; (other_member = conference_member_get(conference, oid))) {
+                        conference_relationship_t *rel = NULL;
+                        if ((rel = member_get_relationship(member, other_member))) {
+                                rel-&gt;flags = 0;
+                        } else {
+                                rel = member_add_relationship(member, oid);
+                        }
+
+                        if (rel) {
+                                switch_set_flag(rel, RFLAG_CAN_SPEAK | RFLAG_CAN_HEAR);
+                                if (nospeak) {
+                                        switch_clear_flag(rel, RFLAG_CAN_SPEAK);
+                                }
+                                if (nohear) {
+                                        switch_clear_flag(rel, RFLAG_CAN_HEAR);
+                                }
+                                stream-&gt;write_function(stream, &quot;ok %u-&gt;%u set\n&quot;, id, oid);
+                        } else {
+                                stream-&gt;write_function(stream, &quot;error!\n&quot;);
+                        }
+                } else {
+                        stream-&gt;write_function(stream, &quot;relationship %u-&gt;%u not found.\n&quot;, id, oid);
+                }
+        }
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_api_sub_lock(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
+{
+        switch_event_t *event;
+
+        switch_assert(conference != NULL);
+        switch_assert(stream != NULL);
+
+        if (conference-&gt;is_locked_sound) {
+                conference_play_file(conference, conference-&gt;is_locked_sound, CONF_DEFAULT_LEADIN, NULL, 0);
+        }
+
+        switch_set_flag_locked(conference, CFLAG_LOCKED);
+        stream-&gt;write_function(stream, &quot;OK %s locked\n&quot;, argv[0]);
+        if (test_eflag(conference, EFLAG_LOCK) &amp;&amp; switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_data(conference, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;lock&quot;);
+                switch_event_fire(&amp;event);
+        }
+
+        return 0;
+}
+
+static switch_status_t conf_api_sub_unlock(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
+{
+        switch_event_t *event;
+
+        switch_assert(conference != NULL);
+        switch_assert(stream != NULL);
+
+        if (conference-&gt;is_unlocked_sound) {
+                conference_play_file(conference, conference-&gt;is_unlocked_sound, CONF_DEFAULT_LEADIN, NULL, 0);
+        }
+
+        switch_clear_flag_locked(conference, CFLAG_LOCKED);
+        stream-&gt;write_function(stream, &quot;OK %s unlocked\n&quot;, argv[0]);
+        if (test_eflag(conference, EFLAG_UNLOCK) &amp;&amp; switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                conference_add_event_data(conference, event);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;unlock&quot;);
+                switch_event_fire(&amp;event);
+        }
+
+        return 0;
+}
+
+static switch_status_t conf_api_sub_dial(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
+{
+        switch_call_cause_t cause;
+
+        switch_assert(stream != NULL);
+
+        if (argc &lt;= 2) {
+                stream-&gt;write_function(stream, &quot;Bad Args\n&quot;);
+                return SWITCH_STATUS_GENERR;
+        }
+
+        if (conference) {
+                conference_outcall(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], &amp;cause);
+        } else {
+                conference_outcall(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], &amp;cause);
+        }
+        stream-&gt;write_function(stream, &quot;Call Requested: result: [%s]\n&quot;, switch_channel_cause2str(cause));
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_api_sub_bgdial(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
+{
+        switch_uuid_t uuid;
+        char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
+
+        switch_assert(stream != NULL);
+
+        if (argc &lt;= 2) {
+                stream-&gt;write_function(stream, &quot;Bad Args\n&quot;);
+                return SWITCH_STATUS_GENERR;
+        }
+
+        switch_uuid_get(&amp;uuid);
+        switch_uuid_format(uuid_str, &amp;uuid);
+
+        if (conference) {
+                conference_outcall_bg(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], uuid_str);
+        } else {
+                conference_outcall_bg(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], uuid_str);
+        }
+
+        stream-&gt;write_function(stream, &quot;OK Job-UUID: %s\n&quot;, uuid_str);
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
+{
+        switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+        char *conf_name = NULL, *profile_name;
+        switch_event_t *params = NULL;
+        conference_obj_t *new_conference = NULL;
+        int locked = 0;
+
+        switch_assert(conference != NULL);
+        switch_assert(stream != NULL);
+
+        if (argc &gt; 3 &amp;&amp; !zstr(argv[2])) {
+                int x;
+
+                conf_name = strdup(argv[2]);
+
+                if ((profile_name = strchr(conf_name, '@'))) {
+                        *profile_name++ = '\0';
+                } else {
+                        profile_name = &quot;default&quot;;
+                }
+
+                for (x = 3; x &lt; argc; x++) {
+                        conference_member_t *member = NULL;
+                        uint32_t id = atoi(argv[x]);
+                        switch_channel_t *channel;
+                        switch_event_t *event;
+                        switch_xml_t cxml = NULL, cfg = NULL, profiles = NULL;
+
+                        if (!id || !(member = conference_member_get(conference, id))) {
+                                stream-&gt;write_function(stream, &quot;No Member %u in conference %s.\n&quot;, id, conference-&gt;name);
+                                continue;
+                        }
+
+                        channel = switch_core_session_get_channel(member-&gt;session);
+
+                        if (!new_conference) {
+                                if (!locked) {
+                                        switch_mutex_lock(globals.setup_mutex);
+                                        locked = 1;
+                                }
+
+                                if ((new_conference = conference_find(conf_name))) {
+                                        if (locked) {
+                                                switch_mutex_unlock(globals.setup_mutex);
+                                                locked = 0;
+                                        }
+                                }
+
+                                if (!(new_conference = conference_find(conf_name))) {
+                                        /* build a new conference if it doesn't exist */
+                                        switch_memory_pool_t *pool = NULL;
+                                        conf_xml_cfg_t xml_cfg = { 0 };
+
+                                        /* Setup a memory pool to use. */
+                                        if (switch_core_new_memory_pool(&amp;pool) != SWITCH_STATUS_SUCCESS) {
+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Pool Failure\n&quot;);
+                                                goto done;
+                                        }
+
+                                        switch_event_create(&amp;params, SWITCH_EVENT_REQUEST_PARAMS);
+                                        switch_assert(params);
+                                        switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, &quot;conf_name&quot;, conf_name);
+                                        switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, &quot;profile_name&quot;, profile_name);
+                                        switch_channel_event_set_data(channel, params);
+
+                                        /* Open the config from the xml registry  */
+                                        if (!(cxml = switch_xml_open_cfg(global_cf_name, &amp;cfg, params))) {
+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Open of %s failed\n&quot;, global_cf_name);
+                                                goto done;
+                                        }
+
+                                        if ((profiles = switch_xml_child(cfg, &quot;profiles&quot;))) {
+                                                xml_cfg.profile = switch_xml_find_child(profiles, &quot;profile&quot;, &quot;name&quot;, profile_name);
+                                        }
+
+                                        xml_cfg.controls = switch_xml_child(cfg, &quot;caller-controls&quot;);
+
+                                        /* Release the config registry handle */
+                                        if (cxml) {
+                                                switch_xml_free(cxml);
+                                                cxml = NULL;
+                                        }
+
+                                        /* Create the conference object. */
+                                        new_conference = conference_new(conf_name, xml_cfg, pool);
+
+                                        if (!new_conference) {
+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Memory Error!\n&quot;);
+                                                if (pool != NULL) {
+                                                        switch_core_destroy_memory_pool(&amp;pool);
+                                                }
+                                                goto done;
+                                        }
+
+                                        if (locked) {
+                                                switch_mutex_unlock(globals.setup_mutex);
+                                                locked = 0;
+                                        }
+
+                                        /* Set the minimum number of members (once you go above it you cannot go below it) */
+                                        new_conference-&gt;min = 1;
+
+                                        /* Indicate the conference is dynamic */
+                                        switch_set_flag_locked(new_conference, CFLAG_DYNAMIC);
+
+                                        switch_mutex_lock(new_conference-&gt;mutex);
+
+                                        /* Start the conference thread for this conference */
+                                        launch_conference_thread(new_conference);
+                                } else {
+                                        switch_mutex_lock(new_conference-&gt;mutex);
+                                }
+                        }
+
+                        /* move the member from the old conference to the new one */
+                        lock_member(member);
+
+                        if (conference != new_conference) {
+                                conference_del_member(conference, member);
+                                conference_add_member(new_conference, member);
+
+                                if (conference-&gt;rate != new_conference-&gt;rate) {
+                                        if (setup_media(member, new_conference)) {
+                                                switch_clear_flag_locked(member, MFLAG_RUNNING);
+                                        } else {
+                                                switch_channel_set_app_flag(channel, CF_APP_TAGGED);
+                                                switch_set_flag_locked(member, MFLAG_RESTART);
+                                        }
+                                }
+                        }
+
+                        unlock_member(member);
+
+                        stream-&gt;write_function(stream, &quot;OK Member '%d' sent to conference %s.\n&quot;, member-&gt;id, argv[2]);
+
+                        /* tell them what happened */
+                        if (test_eflag(conference, EFLAG_TRANSFER) &amp;&amp;
+                                switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                                conference_add_event_member_data(member, event);
+                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Old-Conference-Name&quot;, conference-&gt;name);
+                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;New-Conference-Name&quot;, argv[3]);
+                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;transfer&quot;);
+                                switch_event_fire(&amp;event);
+                        }
+                }
+
+                if (new_conference) {
+                        switch_mutex_unlock(new_conference-&gt;mutex);
+                }
+
+        } else {
+                ret_status = SWITCH_STATUS_GENERR;
+        }
+
+  done:
+
+        if (locked) {
+                switch_mutex_unlock(globals.setup_mutex);
+                locked = 0;
+        }
+
+        if (params) {
+                switch_event_destroy(&amp;params);
+        }
+        switch_safe_free(conf_name);
+        return ret_status;
+}
+
+static switch_status_t conf_api_sub_record(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
+{
+        switch_assert(conference != NULL);
+        switch_assert(stream != NULL);
+
+        if (argc &lt;= 2)
+                return SWITCH_STATUS_GENERR;
+
+        stream-&gt;write_function(stream, &quot;Record file %s\n&quot;, argv[2]);
+        launch_conference_record_thread(conference, argv[2]);
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_api_sub_norecord(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
+{
+        int all;
+
+        switch_assert(conference != NULL);
+        switch_assert(stream != NULL);
+
+        if (argc &lt;= 2)
+                return SWITCH_STATUS_GENERR;
+
+        all = (strcasecmp(argv[2], &quot;all&quot;) == 0);
+        stream-&gt;write_function(stream, &quot;Stop recording file %s\n&quot;, argv[2]);
+        if (!conference_record_stop(conference, all ? NULL : argv[2]) &amp;&amp; !all) {
+                stream-&gt;write_function(stream, &quot;non-existant recording '%s'\n&quot;, argv[2]);
+        }
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_api_sub_pin(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
+{
+        switch_assert(conference != NULL);
+        switch_assert(stream != NULL);
+
+        if ((argc == 3) &amp;&amp; (!strcmp(argv[1], &quot;pin&quot;))) {
+                conference-&gt;pin = switch_core_strdup(conference-&gt;pool, argv[2]);
+                stream-&gt;write_function(stream, &quot;Pin for conference %s set: %s\n&quot;, argv[0], conference-&gt;pin);
+                return SWITCH_STATUS_SUCCESS;
+        } else if (argc == 2 &amp;&amp; (!strcmp(argv[1], &quot;nopin&quot;))) {
+                conference-&gt;pin = NULL;
+                stream-&gt;write_function(stream, &quot;Pin for conference %s deleted\n&quot;, argv[0]);
+                return SWITCH_STATUS_SUCCESS;
+        } else {
+                stream-&gt;write_function(stream, &quot;Invalid parameters:\n&quot;);
+                return SWITCH_STATUS_GENERR;
+        }
+}
+
+typedef enum {
+        CONF_API_COMMAND_LIST = 0,
+        CONF_API_COMMAND_ENERGY,
+        CONF_API_COMMAND_VOLUME_IN,
+        CONF_API_COMMAND_VOLUME_OUT,
+        CONF_API_COMMAND_PLAY,
+        CONF_API_COMMAND_SAY,
+        CONF_API_COMMAND_SAYMEMBER,
+        CONF_API_COMMAND_STOP,
+        CONF_API_COMMAND_DTMF,
+        CONF_API_COMMAND_KICK,
+        CONF_API_COMMAND_MUTE,
+        CONF_API_COMMAND_UNMUTE,
+        CONF_API_COMMAND_DEAF,
+        CONF_API_COMMAND_UNDEAF,
+        CONF_API_COMMAND_RELATE,
+        CONF_API_COMMAND_LOCK,
+        CONF_API_COMMAND_UNLOCK,
+        CONF_API_COMMAND_DIAL,
+        CONF_API_COMMAND_BGDIAL,
+        CONF_API_COMMAND_TRANSFER,
+        CONF_API_COMMAND_RECORD,
+        CONF_API_COMMAND_NORECORD
+} api_command_type_t;
+
+/* API Interface Function sub-commands */
+/* Entries in this list should be kept in sync with the enum above */
+static api_command_t conf_api_sub_commands[] = {
+        {&quot;list&quot;, (void_fn_t) &amp; conf_api_sub_list, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; list [delim &lt;string&gt;]&quot;},
+        {&quot;xml_list&quot;, (void_fn_t) &amp; conf_api_sub_xml_list, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; xml_list&quot;},
+        {&quot;energy&quot;, (void_fn_t) &amp; conf_api_sub_energy, CONF_API_SUB_MEMBER_TARGET,
+         &quot;&lt;confname&gt; energy &lt;member_id|all|last&gt; [&lt;newval&gt;]&quot;},
+        {&quot;volume_in&quot;, (void_fn_t) &amp; conf_api_sub_volume_in, CONF_API_SUB_MEMBER_TARGET,
+         &quot;&lt;confname&gt; volume_in &lt;member_id|all|last&gt; [&lt;newval&gt;]&quot;},
+        {&quot;volume_out&quot;, (void_fn_t) &amp; conf_api_sub_volume_out, CONF_API_SUB_MEMBER_TARGET,
+         &quot;&lt;confname&gt; volume_out &lt;member_id|all|last&gt; [&lt;newval&gt;]&quot;},
+        {&quot;play&quot;, (void_fn_t) &amp; conf_api_sub_play, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; play &lt;file_path&gt; [async|&lt;member_id&gt;]&quot;},
+        {&quot;say&quot;, (void_fn_t) &amp; conf_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, &quot;&lt;confname&gt; say &lt;text&gt;&quot;},
+        {&quot;saymember&quot;, (void_fn_t) &amp; conf_api_sub_saymember, CONF_API_SUB_ARGS_AS_ONE,
+         &quot;&lt;confname&gt; saymember &lt;member_id&gt; &lt;text&gt;&quot;},
+        {&quot;stop&quot;, (void_fn_t) &amp; conf_api_sub_stop, CONF_API_SUB_ARGS_SPLIT,
+         &quot;&lt;confname&gt; stop &lt;[current|all|async|last]&gt; [&lt;member_id&gt;]&quot;},
+        {&quot;dtmf&quot;, (void_fn_t) &amp; conf_api_sub_dtmf, CONF_API_SUB_MEMBER_TARGET,
+         &quot;&lt;confname&gt; dtmf &lt;[member_id|all|last]&gt; &lt;digits&gt;&quot;},
+        {&quot;kick&quot;, (void_fn_t) &amp; conf_api_sub_kick, CONF_API_SUB_MEMBER_TARGET, &quot;&lt;confname&gt; kick &lt;[member_id|all|last]&gt;&quot;},
+        {&quot;mute&quot;, (void_fn_t) &amp; conf_api_sub_mute, CONF_API_SUB_MEMBER_TARGET, &quot;&lt;confname&gt; mute &lt;[member_id|all]|last&gt;&quot;},
+        {&quot;unmute&quot;, (void_fn_t) &amp; conf_api_sub_unmute, CONF_API_SUB_MEMBER_TARGET,
+         &quot;&lt;confname&gt; unmute &lt;[member_id|all]|last&gt;&quot;},
+        {&quot;deaf&quot;, (void_fn_t) &amp; conf_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, &quot;&lt;confname&gt; deaf &lt;[member_id|all]|last&gt;&quot;},
+        {&quot;undeaf&quot;, (void_fn_t) &amp; conf_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET,
+         &quot;&lt;confname&gt; undeaf &lt;[member_id|all]|last&gt;&quot;},
+        {&quot;relate&quot;, (void_fn_t) &amp; conf_api_sub_relate, CONF_API_SUB_ARGS_SPLIT,
+         &quot;&lt;confname&gt; relate &lt;member_id&gt; &lt;other_member_id&gt; [nospeak|nohear|clear]&quot;},
+        {&quot;lock&quot;, (void_fn_t) &amp; conf_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; lock&quot;},
+        {&quot;unlock&quot;, (void_fn_t) &amp; conf_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; unlock&quot;},
+        {&quot;dial&quot;, (void_fn_t) &amp; conf_api_sub_dial, CONF_API_SUB_ARGS_SPLIT,
+         &quot;&lt;confname&gt; dial &lt;endpoint_module_name&gt;/&lt;destination&gt; &lt;callerid number&gt; &lt;callerid name&gt;&quot;},
+        {&quot;bgdial&quot;, (void_fn_t) &amp; conf_api_sub_bgdial, CONF_API_SUB_ARGS_SPLIT,
+         &quot;&lt;confname&gt; bgdial &lt;endpoint_module_name&gt;/&lt;destination&gt; &lt;callerid number&gt; &lt;callerid name&gt;&quot;},
+        {&quot;transfer&quot;, (void_fn_t) &amp; conf_api_sub_transfer, CONF_API_SUB_ARGS_SPLIT,
+         &quot;&lt;confname&gt; transfer &lt;conference_name&gt; &lt;member id&gt; [...&lt;member id&gt;]&quot;},
+        {&quot;record&quot;, (void_fn_t) &amp; conf_api_sub_record, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; record &lt;filename&gt;&quot;},
+        {&quot;norecord&quot;, (void_fn_t) &amp; conf_api_sub_norecord, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; norecord &lt;[filename|all]&gt;&quot;},
+        {&quot;pin&quot;, (void_fn_t) &amp; conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; pin &lt;pin#&gt;&quot;},
+        {&quot;nopin&quot;, (void_fn_t) &amp; conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; nopin&quot;},
+};
+
+#define CONFFUNCAPISIZE (sizeof(conf_api_sub_commands)/sizeof(conf_api_sub_commands[0]))
+
+switch_status_t conf_api_dispatch(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv, const char *cmdline, int argn)
+{
+        switch_status_t status = SWITCH_STATUS_FALSE;
+        uint32_t i, found = 0;
+        switch_assert(conference != NULL);
+        switch_assert(stream != NULL);
+
+        /* loop through the command table to find a match */
+        for (i = 0; i &lt; CONFFUNCAPISIZE &amp;&amp; !found; i++) {
+                if (strcasecmp(argv[argn], conf_api_sub_commands[i].pname) == 0) {
+                        found = 1;
+                        switch (conf_api_sub_commands[i].fntype) {
+
+                                /* commands that we've broken the command line into arguments for */
+                        case CONF_API_SUB_ARGS_SPLIT:
+                                {
+                                        conf_api_args_cmd_t pfn = (conf_api_args_cmd_t) conf_api_sub_commands[i].pfnapicmd;
+
+                                        if (pfn(conference, stream, argc, argv) != SWITCH_STATUS_SUCCESS) {
+                                                /* command returned error, so show syntax usage */
+                                                stream-&gt;write_function(stream, conf_api_sub_commands[i].psyntax);
+                                        }
+                                }
+                                break;
+
+                                /* member specific command that can be itteratted */
+                        case CONF_API_SUB_MEMBER_TARGET:
+                                {
+                                        uint32_t id = 0;
+                                        uint8_t all = 0;
+                                        uint8_t last = 0;
+
+                                        if (argv[argn + 1]) {
+                                                if (!(id = atoi(argv[argn + 1]))) {
+                                                        all = strcasecmp(argv[argn + 1], &quot;all&quot;) ? 0 : 1;
+                                                        last = strcasecmp(argv[argn + 1], &quot;last&quot;) ? 0 : 1;
+                                                }
+                                        }
+
+                                        if (all) {
+                                                conference_member_itterator(conference, stream, (conf_api_member_cmd_t) conf_api_sub_commands[i].pfnapicmd, argv[argn + 2]);
+                                        } else if (last) {
+                                                conference_member_t *member = NULL;
+                                                conference_member_t *last_member = NULL;
+
+                                                switch_mutex_lock(conference-&gt;member_mutex);
+
+                                                /* find last (oldest) member */
+                                                member = conference-&gt;members;
+                                                while (member != NULL) {
+                                                        if (last_member == NULL || member-&gt;id &gt; last_member-&gt;id) {
+                                                                last_member = member;
+                                                        }
+                                                        member = member-&gt;next;
+                                                }
+
+                                                /* exec functio on last (oldest) member */
+                                                if (last_member != NULL &amp;&amp; last_member-&gt;session &amp;&amp; !switch_test_flag(last_member, MFLAG_NOCHANNEL)) {
+                                                        conf_api_member_cmd_t pfn = (conf_api_member_cmd_t) conf_api_sub_commands[i].pfnapicmd;
+                                                        pfn(last_member, stream, argv[argn + 2]);
+                                                }
+
+                                                switch_mutex_unlock(conference-&gt;member_mutex);
+                                        } else if (id) {
+                                                conf_api_member_cmd_t pfn = (conf_api_member_cmd_t) conf_api_sub_commands[i].pfnapicmd;
+                                                conference_member_t *member = conference_member_get(conference, id);
+
+                                                if (member != NULL) {
+                                                        pfn(member, stream, argv[argn + 2]);
+                                                } else {
+                                                        stream-&gt;write_function(stream, &quot;Non-Existant ID %u\n&quot;, id);
+                                                }
+                                        } else {
+                                                stream-&gt;write_function(stream, conf_api_sub_commands[i].psyntax);
+                                        }
+                                }
+                                break;
+
+                                /* commands that deals with all text after command */
+                        case CONF_API_SUB_ARGS_AS_ONE:
+                                {
+                                        conf_api_text_cmd_t pfn = (conf_api_text_cmd_t) conf_api_sub_commands[i].pfnapicmd;
+                                        char *start_text;
+                                        const char *modified_cmdline = cmdline;
+                                        const char *cmd = conf_api_sub_commands[i].pname;
+
+                                        if (!zstr(modified_cmdline) &amp;&amp; (start_text = strstr(modified_cmdline, cmd))) {
+                                                modified_cmdline = start_text + strlen(cmd);
+                                                while (modified_cmdline &amp;&amp; (*modified_cmdline == ' ' || *modified_cmdline == '\t')) {
+                                                        modified_cmdline++;
+                                                }
+                                        }
+
+                                        /* call the command handler */
+                                        if (pfn(conference, stream, modified_cmdline) != SWITCH_STATUS_SUCCESS) {
+                                                /* command returned error, so show syntax usage */
+                                                stream-&gt;write_function(stream, conf_api_sub_commands[i].psyntax);
+                                        }
+                                }
+                                break;
+                        }
+                }
+        }
+
+        if (!found) {
+                stream-&gt;write_function(stream, &quot;Confernece command '%s' not found.\n&quot;, argv[argn]);
+        } else {
+                status = SWITCH_STATUS_SUCCESS;
+        }
+
+        return status;
+}
+
+/* API Interface Function */
+SWITCH_STANDARD_API(conf_api_main)
+{
+        char *lbuf = NULL;
+        switch_status_t status = SWITCH_STATUS_SUCCESS;
+        char *http = NULL, *type = NULL;
+        int argc;
+        char *argv[25] = { 0 };
+
+        if (!cmd) {
+                cmd = &quot;help&quot;;
+        }
+
+        if (stream-&gt;param_event) {
+                http = switch_event_get_header(stream-&gt;param_event, &quot;http-host&quot;);
+                type = switch_event_get_header(stream-&gt;param_event, &quot;content-type&quot;);
+        }
+
+        if (http) {
+                /* Output must be to a web browser */
+                if (type &amp;&amp; !strcasecmp(type, &quot;text/html&quot;)) {
+                        stream-&gt;write_function(stream, &quot;&lt;pre&gt;\n&quot;);
+                }
+        }
+
+        if (!(lbuf = strdup(cmd))) {
+                return status;
+        }
+
+        argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+
+        /* try to find a command to execute */
+        if (argc &amp;&amp; argv[0]) {
+                conference_obj_t *conference = NULL;
+
+                if ((conference = conference_find(argv[0]))) {
+                        if (switch_thread_rwlock_tryrdlock(conference-&gt;rwlock) != SWITCH_STATUS_SUCCESS) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Read Lock Fail\n&quot;);
+                                goto done;
+                        }
+                        if (argc &gt;= 2) {
+                                conf_api_dispatch(conference, stream, argc, argv, cmd, 1);
+                        } else {
+                                stream-&gt;write_function(stream, &quot;Conference command, not specified.\nTry 'help'\n&quot;);
+                        }
+                        switch_thread_rwlock_unlock(conference-&gt;rwlock);
+
+                } else if (argv[0]) {
+                        /* special case the list command, because it doesn't require a conference argument */
+                        if (strcasecmp(argv[0], &quot;list&quot;) == 0) {
+                                conf_api_sub_list(NULL, stream, argc, argv);
+                        } else if (strcasecmp(argv[0], &quot;xml_list&quot;) == 0) {
+                                conf_api_sub_xml_list(NULL, stream, argc, argv);
+                        } else if (strcasecmp(argv[0], &quot;help&quot;) == 0 || strcasecmp(argv[0], &quot;commands&quot;) == 0) {
+                                stream-&gt;write_function(stream, &quot;%s\n&quot;, api_syntax);
+                        } else if (argv[1] &amp;&amp; strcasecmp(argv[1], &quot;dial&quot;) == 0) {
+                                if (conf_api_sub_dial(NULL, stream, argc, argv) != SWITCH_STATUS_SUCCESS) {
+                                        /* command returned error, so show syntax usage */
+                                        stream-&gt;write_function(stream, conf_api_sub_commands[CONF_API_COMMAND_DIAL].psyntax);
+                                }
+                        } else if (argv[1] &amp;&amp; strcasecmp(argv[1], &quot;bgdial&quot;) == 0) {
+                                if (conf_api_sub_bgdial(NULL, stream, argc, argv) != SWITCH_STATUS_SUCCESS) {
+                                        /* command returned error, so show syntax usage */
+                                        stream-&gt;write_function(stream, conf_api_sub_commands[CONF_API_COMMAND_BGDIAL].psyntax);
+                                }
+                        } else {
+                                stream-&gt;write_function(stream, &quot;Conference %s not found\n&quot;, argv[0]);
+                        }
+                }
+
+        } else {
+                stream-&gt;write_function(stream, &quot;No parameters specified.\nTry 'help conference'\n&quot;);
+        }
+
+  done:
+        switch_safe_free(lbuf);
+
+        return status;
+}
+
+/* generate an outbound call from the conference */
+static switch_status_t conference_outcall(conference_obj_t *conference,
+                                                                                  char *conference_name,
+                                                                                  switch_core_session_t *session,
+                                                                                  char *bridgeto, uint32_t timeout, char *flags, char *cid_name, char *cid_num, switch_call_cause_t *cause)
+{
+        switch_core_session_t *peer_session = NULL;
+        switch_channel_t *peer_channel;
+        switch_status_t status = SWITCH_STATUS_SUCCESS;
+        switch_channel_t *caller_channel = NULL;
+        char appdata[512];
+        int rdlock = 0;
+
+        *cause = SWITCH_CAUSE_NORMAL_CLEARING;
+
+        if (conference == NULL) {
+                char *dialstr = switch_mprintf(&quot;{ignore_early_media=true}%s&quot;, bridgeto);
+                status = switch_ivr_originate(NULL, &amp;peer_session, cause, dialstr, 60, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE, NULL);
+                switch_safe_free(dialstr);
+
+                if (status != SWITCH_STATUS_SUCCESS) {
+                        return status;
+                }
+
+                peer_channel = switch_core_session_get_channel(peer_session);
+                rdlock = 1;
+                goto callup;
+        }
+
+        conference_name = conference-&gt;name;
+
+        if (switch_thread_rwlock_tryrdlock(conference-&gt;rwlock) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, &quot;Read Lock Fail\n&quot;);
+                return SWITCH_STATUS_FALSE;
+        }
+
+        if (session != NULL) {
+                caller_channel = switch_core_session_get_channel(session);
+        }
+
+        if (zstr(cid_name)) {
+                cid_name = conference-&gt;caller_id_name;
+        }
+
+        if (zstr(cid_num)) {
+                cid_num = conference-&gt;caller_id_number;
+        }
+
+        /* establish an outbound call leg */
+
+        if (switch_ivr_originate(session, &amp;peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE, NULL) !=
+                SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Cannot create outgoing channel, cause: %s\n&quot;,
+                                                  switch_channel_cause2str(*cause));
+                if (caller_channel) {
+                        switch_channel_hangup(caller_channel, *cause);
+                }
+                goto done;
+        }
+
+        rdlock = 1;
+        peer_channel = switch_core_session_get_channel(peer_session);
+        switch_channel_set_state(peer_channel, CS_SOFT_EXECUTE);
+
+        /* make sure the conference still exists */
+        if (!switch_test_flag(conference, CFLAG_RUNNING)) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Conference is gone now, nevermind..\n&quot;);
+                if (caller_channel) {
+                        switch_channel_hangup(caller_channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
+                }
+                switch_channel_hangup(peer_channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
+                goto done;
+        }
+
+        if (caller_channel &amp;&amp; switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
+                switch_channel_answer(caller_channel);
+        }
+
+  callup:
+
+        /* if the outbound call leg is ready */
+        if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) {
+                switch_caller_extension_t *extension = NULL;
+
+                /* build an extension name object */
+                if ((extension = switch_caller_extension_new(peer_session, conference_name, conference_name)) == 0) {
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, &quot;Memory Error!\n&quot;);
+                        status = SWITCH_STATUS_MEMERR;
+                        goto done;
+                }
+                /* add them to the conference */
+                if (flags &amp;&amp; strcasecmp(flags, &quot;none&quot;)) {
+                        switch_snprintf(appdata, sizeof(appdata), &quot;%s+flags{%s}&quot;, conference_name, flags);
+                        switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, appdata);
+                } else {
+                        switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, conference_name);
+                }
+
+                switch_channel_set_caller_extension(peer_channel, extension);
+                switch_channel_set_state(peer_channel, CS_EXECUTE);
+
+        } else {
+                switch_channel_hangup(peer_channel, SWITCH_CAUSE_NO_ANSWER);
+                status = SWITCH_STATUS_FALSE;
+                goto done;
+        }
+
+  done:
+        if (conference) {
+                switch_thread_rwlock_unlock(conference-&gt;rwlock);
+        }
+        if (rdlock &amp;&amp; peer_session) {
+                switch_core_session_rwunlock(peer_session);
+        }
+
+        return status;
+}
+
+struct bg_call {
+        conference_obj_t *conference;
+        switch_core_session_t *session;
+        char *bridgeto;
+        uint32_t timeout;
+        char *flags;
+        char *cid_name;
+        char *cid_num;
+        char *conference_name;
+        char *uuid;
+        switch_memory_pool_t *pool;
+};
+
+static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t *thread, void *obj)
+{
+        struct bg_call *call = (struct bg_call *) obj;
+
+        if (call) {
+                switch_call_cause_t cause;
+                switch_event_t *event;
+
+                conference_outcall(call-&gt;conference, call-&gt;conference_name,
+                                                   call-&gt;session, call-&gt;bridgeto, call-&gt;timeout, call-&gt;flags, call-&gt;cid_name, call-&gt;cid_num, &amp;cause);
+
+                if (call-&gt;conference &amp;&amp; test_eflag(call-&gt;conference, EFLAG_BGDIAL_RESULT) &amp;&amp;
+                        switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                        conference_add_event_data(call-&gt;conference, event);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;bgdial-result&quot;);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Result&quot;, switch_channel_cause2str(cause));
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Job-UUID&quot;, call-&gt;uuid);
+                        switch_event_fire(&amp;event);
+                }
+                switch_safe_free(call-&gt;bridgeto);
+                switch_safe_free(call-&gt;flags);
+                switch_safe_free(call-&gt;cid_name);
+                switch_safe_free(call-&gt;cid_num);
+                switch_safe_free(call-&gt;conference_name);
+                switch_safe_free(call-&gt;uuid);
+                if (call-&gt;pool) {
+                        switch_core_destroy_memory_pool(&amp;call-&gt;pool);
+                }
+                switch_safe_free(call);
+        }
+
+        return NULL;
+}
+
+static switch_status_t conference_outcall_bg(conference_obj_t *conference,
+                                                                                         char *conference_name,
+                                                                                         switch_core_session_t *session, char *bridgeto, uint32_t timeout, const char *flags, const char *cid_name,
+                                                                                         const char *cid_num, const char *call_uuid)
+{
+        struct bg_call *call = NULL;
+        switch_thread_t *thread;
+        switch_threadattr_t *thd_attr = NULL;
+        switch_memory_pool_t *pool = NULL;
+
+        if (!(call = malloc(sizeof(*call))))
+                return SWITCH_STATUS_MEMERR;
+
+        memset(call, 0, sizeof(*call));
+        call-&gt;conference = conference;
+        call-&gt;session = session;
+        call-&gt;timeout = timeout;
+
+        if (conference) {
+                pool = conference-&gt;pool;
+        } else {
+                switch_core_new_memory_pool(&amp;pool);
+                call-&gt;pool = pool;
+        }
+
+        if (bridgeto) {
+                call-&gt;bridgeto = strdup(bridgeto);
+        }
+        if (flags) {
+                call-&gt;flags = strdup(flags);
+        }
+        if (cid_name) {
+                call-&gt;cid_name = strdup(cid_name);
+        }
+        if (cid_num) {
+                call-&gt;cid_num = strdup(cid_num);
+        }
+
+        if (conference_name) {
+                call-&gt;conference_name = strdup(conference_name);
+        }
+
+        if (call_uuid) {
+                call-&gt;uuid = strdup(call_uuid);
+        }
+
+        switch_threadattr_create(&amp;thd_attr, pool);
+        switch_threadattr_detach_set(thd_attr, 1);
+        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+        switch_thread_create(&amp;thread, thd_attr, conference_outcall_run, call, pool);
+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Launching BG Thread for outcall\n&quot;);
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+/* Play a file */
+static switch_status_t conference_local_play_file(conference_obj_t *conference, switch_core_session_t *session, char *path, uint32_t leadin, void *buf,
+                                                                                                  uint32_t buflen)
+{
+        uint32_t x = 0;
+        switch_status_t status = SWITCH_STATUS_SUCCESS;
+        switch_channel_t *channel;
+        char *expanded = NULL;
+        switch_input_args_t args = { 0 }, *ap = NULL;
+
+        if (buf) {
+                args.buf = buf;
+                args.buflen = buflen;
+                ap = &amp;args;
+        }
+
+        /* generate some space infront of the file to be played */
+        for (x = 0; x &lt; leadin; x++) {
+                switch_frame_t *read_frame;
+                status = switch_core_session_read_frame(session, &amp;read_frame, SWITCH_IO_FLAG_NONE, 0);
+
+                if (!SWITCH_READ_ACCEPTABLE(status)) {
+                        break;
+                }
+        }
+
+        /* if all is well, really play the file */
+        if (status == SWITCH_STATUS_SUCCESS) {
+                char *dpath = NULL;
+
+                channel = switch_core_session_get_channel(session);
+                if ((expanded = switch_channel_expand_variables(channel, path)) != path) {
+                        path = expanded;
+                } else {
+                        expanded = NULL;
+                }
+
+                if (!strncasecmp(path, &quot;say:&quot;, 4)) {
+                        if (!(conference-&gt;tts_engine &amp;&amp; conference-&gt;tts_voice)) {
+                                status = SWITCH_STATUS_FALSE;
+                        } else {
+                                status = switch_ivr_speak_text(session, conference-&gt;tts_engine, conference-&gt;tts_voice, path + 4, ap);
+                        }
+                        goto done;
+                }
+
+                if (conference-&gt;sound_prefix) {
+                        if (!(dpath = switch_mprintf(&quot;%s%s%s&quot;, conference-&gt;sound_prefix, SWITCH_PATH_SEPARATOR, path))) {
+                                status = SWITCH_STATUS_MEMERR;
+                                goto done;
+                        }
+                        path = dpath;
+                }
+
+                status = switch_ivr_play_file(session, NULL, path, ap);
+                switch_safe_free(dpath);
+        }
+
+  done:
+        switch_safe_free(expanded);
+
+        return status;
+}
+
+static void set_mflags(const char *flags, member_flag_t *f)
+{
+        if (flags) {
+                char *dup = strdup(flags);
+                char *p;
+                char *argv[10] = { 0 };
+                int i, argc = 0;
+
+                for (p = dup; p &amp;&amp; *p; p++) {
+                        if (*p == ',') {
+                                *p = '|';
+                        }
+                }
+
+                argc = switch_separate_string(dup, '|', argv, (sizeof(argv) / sizeof(argv[0])));
+
+                for (i = 0; i &lt; argc &amp;&amp; argv[i]; i++) {
+                        if (!strcasecmp(argv[i], &quot;mute&quot;)) {
+                                *f &amp;= ~MFLAG_CAN_SPEAK;
+                        } else if (!strcasecmp(argv[i], &quot;deaf&quot;)) {
+                                *f &amp;= ~MFLAG_CAN_HEAR;
+                        } else if (!strcasecmp(argv[i], &quot;waste&quot;)) {
+                                *f |= MFLAG_WASTE_BANDWIDTH;
+                        } else if (!strcasecmp(argv[i], &quot;mute-detect&quot;)) {
+                                *f |= MFLAG_MUTE_DETECT;
+                        } else if (!strcasecmp(argv[i], &quot;dist-dtmf&quot;)) {
+                                *f |= MFLAG_DIST_DTMF;
+                        } else if (!strcasecmp(argv[i], &quot;moderator&quot;)) {
+                                *f |= MFLAG_MOD;
+                        } else if (!strcasecmp(argv[i], &quot;endconf&quot;)) {
+                                *f |= MFLAG_ENDCONF;
+                        } else if (!strcasecmp(argv[i], &quot;mintwo&quot;)) {
+                                *f |= MFLAG_MINTWO;
+                        }
+                }
+
+                free(dup);
+        }
+}
+
+
+
+static void set_cflags(const char *flags, uint32_t *f)
+{
+        if (flags) {
+                char *dup = strdup(flags);
+                char *p;
+                char *argv[10] = { 0 };
+                int i, argc = 0;
+
+                for (p = dup; p &amp;&amp; *p; p++) {
+                        if (*p == ',') {
+                                *p = '|';
+                        }
+                }
+
+                argc = switch_separate_string(dup, '|', argv, (sizeof(argv) / sizeof(argv[0])));
+
+                for (i = 0; i &lt; argc &amp;&amp; argv[i]; i++) {
+                        if (!strcasecmp(argv[i], &quot;wait-mod&quot;)) {
+                                *f |= CFLAG_WAIT_MOD;
+                        } else if (!strcasecmp(argv[i], &quot;video-floor-only&quot;)) {
+                                *f |= CFLAG_VID_FLOOR;
+                        } else if (!strcasecmp(argv[i], &quot;waste-bandwidth&quot;)) {
+                                *f |= CFLAG_WASTE_BANDWIDTH;
+                        }
+                }
+
+                free(dup);
+        }
+}
+
+
+static void clear_eflags(char *events, uint32_t *f)
+{
+        char buf[512] = &quot;&quot;;
+        char *next = NULL;
+        char *event = buf;
+
+        if (events) {
+                switch_copy_string(buf, events, sizeof(buf));
+
+                while (event) {
+                        next = strchr(event, ',');
+                        if (next) {
+                                *next++ = '\0';
+                        }
+
+                        if (!strcmp(event, &quot;add-member&quot;)) {
+                                *f &amp;= ~EFLAG_ADD_MEMBER;
+                        } else if (!strcmp(event, &quot;del-member&quot;)) {
+                                *f &amp;= ~EFLAG_DEL_MEMBER;
+                        } else if (!strcmp(event, &quot;energy-level&quot;)) {
+                                *f &amp;= ~EFLAG_ENERGY_LEVEL;
+                        } else if (!strcmp(event, &quot;volume-level&quot;)) {
+                                *f &amp;= ~EFLAG_VOLUME_LEVEL;
+                        } else if (!strcmp(event, &quot;gain-level&quot;)) {
+                                *f &amp;= ~EFLAG_GAIN_LEVEL;
+                        } else if (!strcmp(event, &quot;dtmf&quot;)) {
+                                *f &amp;= ~EFLAG_DTMF;
+                        } else if (!strcmp(event, &quot;stop-talking&quot;)) {
+                                *f &amp;= ~EFLAG_STOP_TALKING;
+                        } else if (!strcmp(event, &quot;start-talking&quot;)) {
+                                *f &amp;= ~EFLAG_START_TALKING;
+                        } else if (!strcmp(event, &quot;mute-detect&quot;)) {
+                                *f &amp;= ~EFLAG_MUTE_DETECT;
+                        } else if (!strcmp(event, &quot;mute-member&quot;)) {
+                                *f &amp;= ~EFLAG_MUTE_MEMBER;
+                        } else if (!strcmp(event, &quot;unmute-member&quot;)) {
+                                *f &amp;= ~EFLAG_UNMUTE_MEMBER;
+                        } else if (!strcmp(event, &quot;kick-member&quot;)) {
+                                *f &amp;= ~EFLAG_KICK_MEMBER;
+                        } else if (!strcmp(event, &quot;dtmf-member&quot;)) {
+                                *f &amp;= ~EFLAG_DTMF_MEMBER;
+                        } else if (!strcmp(event, &quot;energy-level-member&quot;)) {
+                                *f &amp;= ~EFLAG_ENERGY_LEVEL_MEMBER;
+                        } else if (!strcmp(event, &quot;volume-in-member&quot;)) {
+                                *f &amp;= ~EFLAG_VOLUME_IN_MEMBER;
+                        } else if (!strcmp(event, &quot;volume-out-member&quot;)) {
+                                *f &amp;= ~EFLAG_VOLUME_OUT_MEMBER;
+                        } else if (!strcmp(event, &quot;play-file&quot;)) {
+                                *f &amp;= ~EFLAG_PLAY_FILE;
+                        } else if (!strcmp(event, &quot;play-file-member&quot;)) {
+                                *f &amp;= ~EFLAG_PLAY_FILE_MEMBER;
+                        } else if (!strcmp(event, &quot;speak-text&quot;)) {
+                                *f &amp;= ~EFLAG_SPEAK_TEXT;
+                        } else if (!strcmp(event, &quot;speak-text-member&quot;)) {
+                                *f &amp;= ~EFLAG_SPEAK_TEXT_MEMBER;
+                        } else if (!strcmp(event, &quot;lock&quot;)) {
+                                *f &amp;= ~EFLAG_LOCK;
+                        } else if (!strcmp(event, &quot;unlock&quot;)) {
+                                *f &amp;= ~EFLAG_UNLOCK;
+                        } else if (!strcmp(event, &quot;transfer&quot;)) {
+                                *f &amp;= ~EFLAG_TRANSFER;
+                        } else if (!strcmp(event, &quot;bgdial-result&quot;)) {
+                                *f &amp;= ~EFLAG_BGDIAL_RESULT;
+                        } else if (!strcmp(event, &quot;floor-change&quot;)) {
+                                *f &amp;= ~EFLAG_FLOOR_CHANGE;
+                        }
+
+                        event = next;
+                }
+        }
+}
+
+SWITCH_STANDARD_APP(conference_auto_function)
+{
+        switch_channel_t *channel = switch_core_session_get_channel(session);
+        call_list_t *call_list, *np;
+
+        call_list = switch_channel_get_private(channel, &quot;_conference_autocall_list_&quot;);
+
+        if (zstr(data)) {
+                call_list = NULL;
+        } else {
+                np = switch_core_session_alloc(session, sizeof(*np));
+                switch_assert(np != NULL);
+
+                np-&gt;string = switch_core_session_strdup(session, data);
+                if (call_list) {
+                        np-&gt;next = call_list;
+                        np-&gt;itteration = call_list-&gt;itteration + 1;
+                } else {
+                        np-&gt;itteration = 1;
+                }
+                call_list = np;
+        }
+        switch_channel_set_private(channel, &quot;_conference_autocall_list_&quot;, call_list);
+}
+
+
+static int setup_media(conference_member_t *member, conference_obj_t *conference)
+{
+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(member-&gt;session, &amp;read_impl);
+
+        switch_core_session_reset(member-&gt;session, SWITCH_TRUE, SWITCH_FALSE);
+
+        if (switch_core_codec_ready(&amp;member-&gt;read_codec)) {
+                switch_core_codec_destroy(&amp;member-&gt;read_codec);
+        }
+
+        if (member-&gt;read_resampler) {
+                switch_resample_destroy(&amp;member-&gt;read_resampler);
+        }
+
+
+        switch_core_session_get_read_impl(member-&gt;session, &amp;member-&gt;orig_read_impl);
+        member-&gt;native_rate = read_impl.samples_per_second;
+
+        /* Setup a Signed Linear codec for reading audio. */
+        if (switch_core_codec_init(&amp;member-&gt;read_codec,
+                                                           &quot;L16&quot;,
+                                                           NULL, read_impl.actual_samples_per_second, read_impl.microseconds_per_packet / 1000,
+                                                           1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member-&gt;pool) == SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_DEBUG,
+                                                  &quot;Raw Codec Activation Success L16@%uhz 1 channel %dms\n&quot;,
+                                                  read_impl.actual_samples_per_second, read_impl.microseconds_per_packet / 1000);
+
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_DEBUG, &quot;Raw Codec Activation Failed L16@%uhz 1 channel %dms\n&quot;,
+                                                  read_impl.actual_samples_per_second, read_impl.microseconds_per_packet / 1000);
+
+                goto done;
+        }
+
+        if (!member-&gt;frame_size) {
+                member-&gt;frame_size = SWITCH_RECOMMENDED_BUFFER_SIZE;
+                member-&gt;frame = switch_core_alloc(member-&gt;pool, member-&gt;frame_size);
+                member-&gt;mux_frame = switch_core_alloc(member-&gt;pool, member-&gt;frame_size);
+        }
+
+        if (read_impl.actual_samples_per_second != conference-&gt;rate) {
+                if (switch_resample_create(&amp;member-&gt;read_resampler,
+                                                                   read_impl.actual_samples_per_second,
+                                                                   conference-&gt;rate, member-&gt;frame_size, SWITCH_RESAMPLE_QUALITY, 1) != SWITCH_STATUS_SUCCESS) {
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_CRIT, &quot;Unable to create resampler!\n&quot;);
+                        goto done;
+                }
+
+
+                member-&gt;resample_out = switch_core_alloc(member-&gt;pool, member-&gt;frame_size);
+                member-&gt;resample_out_len = member-&gt;frame_size;
+
+                /* Setup an audio buffer for the resampled audio */
+                if (switch_buffer_create_dynamic(&amp;member-&gt;resample_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX)
+                        != SWITCH_STATUS_SUCCESS) {
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_CRIT, &quot;Memory Error Creating Audio Buffer!\n&quot;);
+                        goto done;
+                }
+        }
+
+
+        /* Setup a Signed Linear codec for writing audio. */
+        if (switch_core_codec_init(&amp;member-&gt;write_codec,
+                                                           &quot;L16&quot;,
+                                                           NULL,
+                                                           conference-&gt;rate,
+                                                           read_impl.microseconds_per_packet / 1000,
+                                                           1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member-&gt;pool) == SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_DEBUG,
+                                                  &quot;Raw Codec Activation Success L16@%uhz 1 channel %dms\n&quot;, conference-&gt;rate, read_impl.microseconds_per_packet / 1000);
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_DEBUG, &quot;Raw Codec Activation Failed L16@%uhz 1 channel %dms\n&quot;,
+                                                  conference-&gt;rate, read_impl.microseconds_per_packet / 1000);
+                goto codec_done2;
+        }
+
+        /* Setup an audio buffer for the incoming audio */
+        if (switch_buffer_create_dynamic(&amp;member-&gt;audio_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_CRIT, &quot;Memory Error Creating Audio Buffer!\n&quot;);
+                goto codec_done1;
+        }
+
+        /* Setup an audio buffer for the outgoing audio */
+        if (switch_buffer_create_dynamic(&amp;member-&gt;mux_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_CRIT, &quot;Memory Error Creating Audio Buffer!\n&quot;);
+                goto codec_done1;
+        }
+
+        return 0;
+
+  codec_done1:
+        switch_core_codec_destroy(&amp;member-&gt;read_codec);
+  codec_done2:
+        switch_core_codec_destroy(&amp;member-&gt;write_codec);
+  done:
+
+        return -1;
+
+
+}
+
+
+/* Application interface function that is called from the dialplan to join the channel to a conference */
+SWITCH_STANDARD_APP(conference_function)
+{
+        switch_codec_t *read_codec = NULL;
+        uint32_t flags = 0;
+        conference_member_t member = { 0 };
+        conference_obj_t *conference = NULL;
+        switch_channel_t *channel = switch_core_session_get_channel(session);
+        char *mydata = NULL;
+        char *conf_name = NULL;
+        char *bridge_prefix = &quot;bridge:&quot;;
+        char *flags_prefix = &quot;+flags{&quot;;
+        char *bridgeto = NULL;
+        char *profile_name = NULL;
+        switch_xml_t cxml = NULL, cfg = NULL, profiles = NULL;
+        const char *flags_str;
+        member_flag_t mflags = 0;
+        switch_core_session_message_t msg = { 0 };
+        uint8_t rl = 0, isbr = 0;
+        char *dpin = NULL;
+        conf_xml_cfg_t xml_cfg = { 0 };
+        switch_event_t *params = NULL;
+        int locked = 0;
+
+        /* Save the original read codec. */
+        if (!(read_codec = switch_core_session_get_read_codec(session))) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Channel has no media!\n&quot;);
+                return;
+        }
+
+
+        if (zstr(data)) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, &quot;Invalid arguments\n&quot;);
+                return;
+        }
+
+        mydata = switch_core_session_strdup(session, data);
+
+        if (!mydata) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, &quot;Pool Failure\n&quot;);
+                return;
+        }
+
+        if ((flags_str = strstr(mydata, flags_prefix))) {
+                char *p;
+                *((char *) flags_str) = '\0';
+                flags_str += strlen(flags_prefix);
+                if ((p = strchr(flags_str, '}'))) {
+                        *p = '\0';
+                }
+        } else {
+                flags_str = switch_channel_get_variable(channel, &quot;conference_member_flags&quot;);
+        }
+
+        /* is this a bridging conference ? */
+        if (!strncasecmp(mydata, bridge_prefix, strlen(bridge_prefix))) {
+                isbr = 1;
+                mydata += strlen(bridge_prefix);
+                if ((bridgeto = strchr(mydata, ':'))) {
+                        *bridgeto++ = '\0';
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, &quot;Config Error!\n&quot;);
+                        goto done;
+                }
+        }
+
+        conf_name = mydata;
+
+        /* eat all leading spaces on conference name, which can cause problems */
+        while (*conf_name == ' ') {
+                conf_name++;
+        }
+
+        /* is there a conference pin ? */
+        if ((dpin = strchr(conf_name, '+'))) {
+                *dpin++ = '\0';
+        }
+
+        /* is there profile specification ? */
+        if ((profile_name = strchr(conf_name, '@'))) {
+                *profile_name++ = '\0';
+        } else {
+                profile_name = &quot;default&quot;;
+        }
+
+#if 0
+        if (0) {
+                member.dtmf_parser = conference-&gt;dtmf_parser;
+        } else {
+
+        }
+#endif
+
+        switch_event_create(&amp;params, SWITCH_EVENT_COMMAND);
+        switch_assert(params);
+        switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, &quot;conf_name&quot;, conf_name);
+        switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, &quot;profile_name&quot;, profile_name);
+
+        /* Open the config from the xml registry */
+        if (!(cxml = switch_xml_open_cfg(global_cf_name, &amp;cfg, params))) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Open of %s failed\n&quot;, global_cf_name);
+                goto done;
+        }
+
+        if ((profiles = switch_xml_child(cfg, &quot;profiles&quot;))) {
+                xml_cfg.profile = switch_xml_find_child(profiles, &quot;profile&quot;, &quot;name&quot;, profile_name);
+        }
+
+        xml_cfg.controls = switch_xml_child(cfg, &quot;caller-controls&quot;);
+
+        /* if this is a bridging call, and it's not a duplicate, build a */
+        /* conference object, and skip pin handling, and locked checking */
+
+        if (!locked) {
+                switch_mutex_lock(globals.setup_mutex);
+                locked = 1;
+        }
+
+        if (isbr) {
+                char *uuid = switch_core_session_get_uuid(session);
+
+                if (!strcmp(conf_name, &quot;_uuid_&quot;)) {
+                        conf_name = uuid;
+                }
+
+                if ((conference = conference_find(conf_name))) {
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Conference %s already exists!\n&quot;, conf_name);
+                        goto done;
+                }
+
+                /* Create the conference object. */
+                conference = conference_new(conf_name, xml_cfg, NULL);
+
+                if (!conference) {
+                        goto done;
+                }
+
+                if (locked) {
+                        switch_mutex_unlock(globals.setup_mutex);
+                        locked = 0;
+                }
+
+                switch_channel_set_variable(channel, &quot;conference_name&quot;, conference-&gt;name);
+
+                /* Set the minimum number of members (once you go above it you cannot go below it) */
+                conference-&gt;min = 2;
+
+                /* Indicate the conference is dynamic */
+                switch_set_flag_locked(conference, CFLAG_DYNAMIC);
+
+                /* Indicate the conference has a bridgeto party */
+                switch_set_flag_locked(conference, CFLAG_BRIDGE_TO);
+
+                /* Start the conference thread for this conference */
+                launch_conference_thread(conference);
+
+        } else {
+                int enforce_security = !switch_channel_test_flag(channel, CF_OUTBOUND);
+                const char *pvar = switch_channel_get_variable(channel, &quot;conference_enforce_security&quot;);
+
+                if (pvar) {
+                        enforce_security = switch_true(pvar);
+                }
+
+                if ((conference = conference_find(conf_name))) {
+                        if (locked) {
+                                switch_mutex_unlock(globals.setup_mutex);
+                                locked = 0;
+                        }
+                }
+
+                /* if the conference exists, get the pointer to it */
+                if (!conference) {
+                        const char *max_members_str;
+
+                        /* couldn't find the conference, create one */
+                        conference = conference_new(conf_name, xml_cfg, NULL);
+
+                        if (!conference) {
+                                goto done;
+                        }
+
+                        if (locked) {
+                                switch_mutex_unlock(globals.setup_mutex);
+                                locked = 0;
+                        }
+
+                        switch_channel_set_variable(channel, &quot;conference_name&quot;, conference-&gt;name);
+
+                        /* Set MOH from variable if not set */
+                        if (zstr(conference-&gt;moh_sound)) {
+                                conference-&gt;moh_sound = switch_core_strdup(conference-&gt;pool, switch_channel_get_variable(channel, &quot;conference_moh_sound&quot;));
+                        }
+                        /* Set perpetual-sound from variable if not set */
+                        if (zstr(conference-&gt;perpetual_sound)) {
+                                conference-&gt;perpetual_sound = switch_core_strdup(conference-&gt;pool, switch_channel_get_variable(channel, &quot;conference_perpetual_sound&quot;));
+                        }
+
+                        /* Set the minimum number of members (once you go above it you cannot go below it) */
+                        conference-&gt;min = 1;
+
+                        /* check for variable used to specify override for max_members */
+                        if (!zstr(max_members_str = switch_channel_get_variable(channel, &quot;conference_max_members&quot;))) {
+                                uint32_t max_members_val;
+                                errno = 0;                /* sanity first */
+                                max_members_val = strtol(max_members_str, NULL, 0);        /* base 0 lets 0x... for hex 0... for octal and base 10 otherwise through */
+                                if (errno == ERANGE || errno == EINVAL || max_members_val &lt; 0 || max_members_val == 1) {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+                                                                          &quot;conference_max_members variable %s is invalid, not setting a limit\n&quot;, max_members_str);
+                                } else {
+                                        conference-&gt;max_members = max_members_val;
+                                }
+                        }
+
+                        /* Indicate the conference is dynamic */
+                        switch_set_flag_locked(conference, CFLAG_DYNAMIC);
+
+                        /* Start the conference thread for this conference */
+                        launch_conference_thread(conference);
+                } else {                                /* setup user variable */
+                        switch_channel_set_variable(channel, &quot;conference_name&quot;, conference-&gt;name);
+                }
+
+                /* acquire a read lock on the thread so it can't leave without us */
+                if (switch_thread_rwlock_tryrdlock(conference-&gt;rwlock) != SWITCH_STATUS_SUCCESS) {
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, &quot;Read Lock Fail\n&quot;);
+                        goto done;
+                }
+                rl++;
+
+                if (!dpin &amp;&amp; conference-&gt;pin) {
+                        dpin = conference-&gt;pin;
+                }
+
+
+
+                /* if this is not an outbound call, deal with conference pins */
+                if (enforce_security &amp;&amp; !zstr(dpin)) {
+                        char pin_buf[80] = &quot;&quot;;
+                        int pin_retries = 3;        /* XXX - this should be configurable - i'm too lazy to do it right now... */
+                        int pin_valid = 0;
+                        switch_status_t status = SWITCH_STATUS_SUCCESS;
+                        char *supplied_pin_value;
+
+                        /* Answer the channel */
+                        switch_channel_answer(channel);
+
+                        /* look for PIN in channel variable first.  If not present or invalid revert to prompting user */
+                        supplied_pin_value = switch_core_strdup(conference-&gt;pool, switch_channel_get_variable(channel, &quot;supplied_pin&quot;));
+                        if (!zstr(supplied_pin_value)) {
+                                char *supplied_pin_value_start;
+                                int i = 0;
+                                if ((supplied_pin_value_start = (char *) switch_stristr(cf_pin_url_param_name, supplied_pin_value))) {
+                                        /* pin supplied as a URL parameter, move pointer to start of actual pin value */
+                                        supplied_pin_value = supplied_pin_value_start + strlen(cf_pin_url_param_name);
+                                }
+                                while (*supplied_pin_value != 0 &amp;&amp; *supplied_pin_value != ';') {
+                                        pin_buf[i++] = *supplied_pin_value++;
+                                }
+                                pin_valid = (strcmp(pin_buf, dpin) == 0);
+                                memset(pin_buf, 0, sizeof(pin_buf));
+                        }
+
+                        if (!conference-&gt;pin_sound) {
+                                conference-&gt;pin_sound = switch_core_strdup(conference-&gt;pool, &quot;conference/conf-pin.wav&quot;);
+                        }
+
+                        if (!conference-&gt;bad_pin_sound) {
+                                conference-&gt;bad_pin_sound = switch_core_strdup(conference-&gt;pool, &quot;conference/conf-bad-pin.wav&quot;);
+                        }
+
+                        while (!pin_valid &amp;&amp; pin_retries &amp;&amp; status == SWITCH_STATUS_SUCCESS) {
+                                switch_status_t pstatus = SWITCH_STATUS_FALSE;
+
+                                /* be friendly */
+                                if (conference-&gt;pin_sound) {
+                                        pstatus = conference_local_play_file(conference, session, conference-&gt;pin_sound, 20, pin_buf, sizeof(pin_buf));
+                                } else if (conference-&gt;tts_engine &amp;&amp; conference-&gt;tts_voice) {
+                                        pstatus =
+                                                switch_ivr_speak_text(session, conference-&gt;tts_engine, conference-&gt;tts_voice, &quot;please enter the conference pin number&quot;, NULL);
+                                } else {
+                                        pstatus = switch_ivr_speak_text(session, &quot;flite&quot;, &quot;slt&quot;, &quot;please enter the conference pin number&quot;, NULL);
+                                }
+
+                                if (pstatus != SWITCH_STATUS_SUCCESS &amp;&amp; pstatus != SWITCH_STATUS_BREAK) {
+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Cannot ask the user for a pin, ending call&quot;);
+                                        switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+                                }
+
+                                /* wait for them if neccessary */
+                                if (strlen(pin_buf) &lt; strlen(dpin)) {
+                                        char *buf = pin_buf + strlen(pin_buf);
+                                        char term = '\0';
+
+                                        status = switch_ivr_collect_digits_count(session,
+                                                                                                                         buf,
+                                                                                                                         sizeof(pin_buf) - strlen(pin_buf), strlen(dpin) - strlen(pin_buf), &quot;#&quot;, &amp;term, 10000, 0, 0);
+                                        if (status == SWITCH_STATUS_TIMEOUT) {
+                                                status = SWITCH_STATUS_SUCCESS;
+                                        }
+                                }
+
+                                pin_valid = (status == SWITCH_STATUS_SUCCESS &amp;&amp; strcmp(pin_buf, dpin) == 0);
+                                if (!pin_valid) {
+                                        /* zero the collected pin */
+                                        memset(pin_buf, 0, sizeof(pin_buf));
+
+                                        /* more friendliness */
+                                        if (conference-&gt;bad_pin_sound) {
+                                                conference_local_play_file(conference, session, conference-&gt;bad_pin_sound, 20, pin_buf, sizeof(pin_buf));
+                                        }
+                                }
+                                pin_retries--;
+                        }
+
+                        if (!pin_valid) {
+                                goto done;
+                        }
+                }
+
+                if (conference-&gt;special_announce) {
+                        conference_local_play_file(conference, session, conference-&gt;special_announce, CONF_DEFAULT_LEADIN, NULL, 0);
+                }
+
+                /* don't allow more callers if the conference is locked, unless we invited them */
+                if (switch_test_flag(conference, CFLAG_LOCKED) &amp;&amp; enforce_security) {
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Conference %s is locked.\n&quot;, conf_name);
+                        if (conference-&gt;locked_sound) {
+                                /* Answer the channel */
+                                switch_channel_answer(channel);
+                                conference_local_play_file(conference, session, conference-&gt;locked_sound, 20, NULL, 0);
+                        }
+                        goto done;
+                }
+
+                /* dont allow more callers than the max_members allows for -- I explicitly didnt allow outbound calls
+                 * someone else can add that (see above) if they feel that outbound calls should be able to violate the
+                 * max_members limit
+                 */
+                if ((conference-&gt;max_members &gt; 0) &amp;&amp; (conference-&gt;count &gt;= conference-&gt;max_members)) {
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Conference %s is full.\n&quot;, conf_name);
+                        if (conference-&gt;maxmember_sound) {
+                                /* Answer the channel */
+                                switch_channel_answer(channel);
+                                conference_local_play_file(conference, session, conference-&gt;maxmember_sound, 20, NULL, 0);
+                        }
+                        goto done;
+                }
+
+        }
+
+        /* Release the config registry handle */
+        if (cxml) {
+                switch_xml_free(cxml);
+                cxml = NULL;
+        }
+
+        /* if we're using &quot;bridge:&quot; make an outbound call and bridge it in */
+        if (!zstr(bridgeto) &amp;&amp; strcasecmp(bridgeto, &quot;none&quot;)) {
+                switch_call_cause_t cause;
+                if (conference_outcall(conference, NULL, session, bridgeto, 60, NULL, NULL, NULL, &amp;cause) != SWITCH_STATUS_SUCCESS) {
+                        goto done;
+                }
+        } else {
+                /* if we're not using &quot;bridge:&quot; set the conference answered flag */
+                /* and this isn't an outbound channel, answer the call */
+                if (!switch_channel_test_flag(channel, CF_OUTBOUND))
+                        switch_set_flag(conference, CFLAG_ANSWERED);
+        }
+
+        member.session = session;
+        member.pool = switch_core_session_get_pool(session);
+
+        if (setup_media(&amp;member, conference)) {
+                flags = 0;
+                goto done;
+        }
+
+        /* Prepare MUTEXS */
+        member.id = next_member_id();
+        switch_mutex_init(&amp;member.flag_mutex, SWITCH_MUTEX_NESTED, member.pool);
+        switch_mutex_init(&amp;member.write_mutex, SWITCH_MUTEX_NESTED, member.pool);
+        switch_mutex_init(&amp;member.read_mutex, SWITCH_MUTEX_NESTED, member.pool);
+        switch_mutex_init(&amp;member.audio_in_mutex, SWITCH_MUTEX_NESTED, member.pool);
+        switch_mutex_init(&amp;member.audio_out_mutex, SWITCH_MUTEX_NESTED, member.pool);
+
+        /* Install our Signed Linear codec so we get the audio in that format */
+        switch_core_session_set_read_codec(member.session, &amp;member.read_codec);
+
+
+        mflags = conference-&gt;mflags;
+        set_mflags(flags_str, &amp;mflags);
+        switch_set_flag_locked((&amp;member), MFLAG_RUNNING | mflags);
+
+        if (mflags &amp; MFLAG_MINTWO) {
+                conference-&gt;min = 2;
+        }
+
+        /* Add the caller to the conference */
+        if (conference_add_member(conference, &amp;member) != SWITCH_STATUS_SUCCESS) {
+                switch_core_codec_destroy(&amp;member.read_codec);
+                goto done;
+        }
+
+        msg.from = __FILE__;
+
+        /* Tell the channel we are going to be in a bridge */
+        msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
+        switch_core_session_receive_message(session, &amp;msg);
+
+        /* Run the confernece loop */
+        conference_loop_output(&amp;member);
+        switch_channel_set_private(channel, &quot;_conference_autocall_list_&quot;, NULL);
+
+        /* Tell the channel we are no longer going to be in a bridge */
+        msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
+        switch_core_session_receive_message(session, &amp;msg);
+
+        /* Remove the caller from the conference */
+        conference_del_member(member.conference, &amp;member);
+
+        /* Put the original codec back */
+        switch_core_session_set_read_codec(member.session, NULL);
+
+        /* Clean Up. */
+
+  done:
+
+        if (locked) {
+                switch_mutex_unlock(globals.setup_mutex);
+                locked = 0;
+        }
+
+        if (member.read_resampler) {
+                switch_resample_destroy(&amp;member.read_resampler);
+        }
+
+        switch_event_destroy(&amp;params);
+        switch_buffer_destroy(&amp;member.resample_buffer);
+        switch_buffer_destroy(&amp;member.audio_buffer);
+        switch_buffer_destroy(&amp;member.mux_buffer);
+        if (conference &amp;&amp; member.dtmf_parser != conference-&gt;dtmf_parser) {
+                switch_ivr_digit_stream_parser_destroy(member.dtmf_parser);
+        }
+
+        if (conference) {
+                switch_mutex_lock(conference-&gt;mutex);
+                if (switch_test_flag(conference, CFLAG_DYNAMIC) &amp;&amp; conference-&gt;count == 0) {
+                        switch_set_flag_locked(conference, CFLAG_DESTRUCT);
+                }
+                switch_mutex_unlock(conference-&gt;mutex);
+        }
+
+        /* Release the config registry handle */
+        if (cxml) {
+                switch_xml_free(cxml);
+        }
+
+        if (conference &amp;&amp; switch_test_flag(&amp;member, MFLAG_KICKED) &amp;&amp; conference-&gt;kicked_sound) {
+                char *toplay = NULL;
+                char *dfile = NULL;
+
+                if (!strncasecmp(conference-&gt;kicked_sound, &quot;say:&quot;, 4)) {
+                        if (conference-&gt;tts_engine &amp;&amp; conference-&gt;tts_voice) {
+                                switch_ivr_speak_text(session, conference-&gt;tts_engine, conference-&gt;tts_voice, conference-&gt;kicked_sound + 4, NULL);
+                        }
+                } else {
+                        if (conference-&gt;sound_prefix) {
+                                dfile = switch_mprintf(&quot;%s%s%s&quot;, conference-&gt;sound_prefix, SWITCH_PATH_SEPARATOR, conference-&gt;kicked_sound);
+                                switch_assert(dfile);
+                                toplay = dfile;
+                        } else {
+                                toplay = conference-&gt;kicked_sound;
+                        }
+
+                        switch_ivr_play_file(session, NULL, toplay, NULL);
+                        switch_safe_free(dfile);
+                }
+        }
+
+        switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
+
+        /* release the readlock */
+        if (rl) {
+                switch_thread_rwlock_unlock(conference-&gt;rwlock);
+        }
+}
+
+/* Create a thread for the conference and launch it */
+static void launch_conference_thread(conference_obj_t *conference)
+{
+        switch_thread_t *thread;
+        switch_threadattr_t *thd_attr = NULL;
+
+        switch_set_flag_locked(conference, CFLAG_RUNNING);
+        switch_threadattr_create(&amp;thd_attr, conference-&gt;pool);
+        switch_threadattr_detach_set(thd_attr, 1);
+        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+        switch_mutex_lock(globals.hash_mutex);
+        switch_mutex_unlock(globals.hash_mutex);
+        switch_thread_create(&amp;thread, thd_attr, conference_thread_run, conference, conference-&gt;pool);
+}
+
+
+/* Create a video thread for the conference and launch it */
+static void launch_conference_video_thread(conference_obj_t *conference)
+{
+        switch_thread_t *thread;
+        switch_threadattr_t *thd_attr = NULL;
+
+        switch_threadattr_create(&amp;thd_attr, conference-&gt;pool);
+        switch_threadattr_detach_set(thd_attr, 1);
+        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+        switch_thread_create(&amp;thread, thd_attr, conference_video_thread_run, conference, conference-&gt;pool);
+        conference-&gt;video_running = 1;
+}
+
+static void launch_conference_record_thread(conference_obj_t *conference, char *path)
+{
+        switch_thread_t *thread;
+        switch_threadattr_t *thd_attr = NULL;
+        switch_memory_pool_t *pool;
+        conference_record_t *rec;
+
+        /* Setup a memory pool to use. */
+        if (switch_core_new_memory_pool(&amp;pool) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Pool Failure\n&quot;);
+        }
+
+        /* Create a node object */
+        if (!(rec = switch_core_alloc(pool, sizeof(*rec)))) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Alloc Failure\n&quot;);
+                switch_core_destroy_memory_pool(&amp;pool);
+                return;
+        }
+
+        rec-&gt;conference = conference;
+        rec-&gt;path = switch_core_strdup(pool, path);
+        rec-&gt;pool = pool;
+
+        switch_threadattr_create(&amp;thd_attr, rec-&gt;pool);
+        switch_threadattr_detach_set(thd_attr, 1);
+        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+        switch_thread_create(&amp;thread, thd_attr, conference_record_thread_run, rec, rec-&gt;pool);
+}
+
+static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject,
+                                                                 const char *body, const char *type, const char *hint)
+{
+        char name[512] = &quot;&quot;, *p, *lbuf = NULL;
+        conference_obj_t *conference = NULL;
+        switch_stream_handle_t stream = { 0 };
+
+        if ((p = strchr(to, '+'))) {
+                to = ++p;
+        }
+
+        if (!body) {
+                return SWITCH_STATUS_SUCCESS;
+        }
+
+        if ((p = strchr(to, '@'))) {
+                switch_copy_string(name, to, ++p - to);
+        } else {
+                switch_copy_string(name, to, sizeof(name));
+        }
+
+        if (!(conference = conference_find(name))) {
+                switch_core_chat_send(proto, CONF_CHAT_PROTO, to, hint &amp;&amp; strchr(hint, '/') ? hint : from, &quot;&quot;, &quot;Conference not active.&quot;, NULL, NULL);
+                return SWITCH_STATUS_FALSE;
+        }
+
+        SWITCH_STANDARD_STREAM(stream);
+
+        if (body != NULL &amp;&amp; (lbuf = strdup(body))) {
+                /* special case list */
+                if (switch_stristr(&quot;list&quot;, lbuf)) {
+                        conference_list_pretty(conference, &amp;stream);
+                        /* provide help */
+                } else {
+                        return SWITCH_STATUS_SUCCESS;
+                }
+        }
+
+        switch_safe_free(lbuf);
+
+        switch_core_chat_send(proto, CONF_CHAT_PROTO, to, hint &amp;&amp; strchr(hint, '/') ? hint : from, &quot;&quot;, stream.data, NULL, NULL);
+        switch_safe_free(stream.data);
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_default_controls(conference_obj_t *conference)
+{
+        switch_status_t status = SWITCH_STATUS_FALSE;
+        uint32_t i;
+        caller_control_action_t *action;
+
+        switch_assert(conference != NULL);
+
+        for (i = 0, status = SWITCH_STATUS_SUCCESS; status == SWITCH_STATUS_SUCCESS &amp;&amp; i &lt; CCFNTBL_QTY; i++) {
+                if (!zstr(ccfntbl[i].digits)) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+                                                          &quot;Installing default caller control action '%s' bound to '%s'.\n&quot;, ccfntbl[i].key, ccfntbl[i].digits);
+                        action = (caller_control_action_t *) switch_core_alloc(conference-&gt;pool, sizeof(caller_control_action_t));
+                        if (action != NULL) {
+                                action-&gt;fndesc = &amp;ccfntbl[i];
+                                action-&gt;data = NULL;
+                                status = switch_ivr_digit_stream_parser_set_event(conference-&gt;dtmf_parser, ccfntbl[i].digits, action);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+                                                                  &quot;unable to alloc memory for caller control binding '%s' to '%s'\n&quot;, ccfntbl[i].key, ccfntbl[i].digits);
+                                status = SWITCH_STATUS_MEMERR;
+                        }
+                }
+        }
+
+        return status;
+}
+
+static switch_status_t conference_new_install_caller_controls_custom(conference_obj_t *conference, switch_xml_t xml_controls, switch_xml_t xml_menus)
+{
+        switch_status_t status = SWITCH_STATUS_FALSE;
+        switch_xml_t xml_kvp;
+
+        switch_assert(conference != NULL);
+
+        if (!xml_controls) {
+                return status;
+        }
+
+        /* parse the controls tree for caller control digit strings */
+        for (xml_kvp = switch_xml_child(xml_controls, &quot;control&quot;); xml_kvp; xml_kvp = xml_kvp-&gt;next) {
+                char *key = (char *) switch_xml_attr(xml_kvp, &quot;action&quot;);
+                char *val = (char *) switch_xml_attr(xml_kvp, &quot;digits&quot;);
+                char *data = (char *) switch_xml_attr_soft(xml_kvp, &quot;data&quot;);
+
+                if (!zstr(key) &amp;&amp; !zstr(val)) {
+                        uint32_t i;
+
+                        /* scan through all of the valid actions, and if found, */
+                        /* set the new caller control action digit string, then */
+                        /* stop scanning the table, and go to the next xml kvp. */
+                        for (i = 0, status = SWITCH_STATUS_NOOP; i &lt; CCFNTBL_QTY &amp;&amp; status == SWITCH_STATUS_NOOP; i++) {
+
+                                if (strcasecmp(ccfntbl[i].key, key) == 0) {
+
+                                        caller_control_action_t *action;
+
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Installing caller control action '%s' bound to '%s'.\n&quot;, key, val);
+                                        action = (caller_control_action_t *) switch_core_alloc(conference-&gt;pool, sizeof(caller_control_action_t));
+                                        if (action != NULL) {
+                                                action-&gt;fndesc = &amp;ccfntbl[i];
+                                                action-&gt;data = (void *) switch_core_strdup(conference-&gt;pool, data);
+                                                action-&gt;binded_dtmf = switch_core_strdup(conference-&gt;pool, val);
+                                                status = switch_ivr_digit_stream_parser_set_event(conference-&gt;dtmf_parser, val, action);
+                                        } else {
+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+                                                                                  &quot;unable to alloc memory for caller control binding '%s' to '%s'\n&quot;, ccfntbl[i].key, ccfntbl[i].digits);
+                                                status = SWITCH_STATUS_MEMERR;
+                                        }
+                                }
+                        }
+                        if (status == SWITCH_STATUS_NOOP) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Invalid caller control action name '%s'.\n&quot;, key);
+                        }
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Invalid caller control config entry pair action = '%s' digits = '%s'\n&quot;, key, val);
+                }
+        }
+
+        return status;
+}
+
+static conference_obj_t *conference_find(char *name)
+{
+        conference_obj_t *conference;
+
+        switch_mutex_lock(globals.hash_mutex);
+        conference = switch_core_hash_find(globals.conference_hash, name);
+        switch_mutex_unlock(globals.hash_mutex);
+
+        return conference;
+}
+
+/* create a new conferene with a specific profile */
+static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_memory_pool_t *pool)
+{
+        conference_obj_t *conference;
+        switch_xml_t xml_kvp;
+        char *timer_name = NULL;
+        char *domain = NULL;
+        char *tts_engine = NULL;
+        char *tts_voice = NULL;
+        char *enter_sound = NULL;
+        char *sound_prefix = NULL;
+        char *exit_sound = NULL;
+        char *alone_sound = NULL;
+        char *ack_sound = NULL;
+        char *nack_sound = NULL;
+        char *muted_sound = NULL;
+        char *mute_detect_sound = NULL;
+        char *unmuted_sound = NULL;
+        char *locked_sound = NULL;
+        char *is_locked_sound = NULL;
+        char *is_unlocked_sound = NULL;
+        char *kicked_sound = NULL;
+        char *pin = NULL;
+        char *pin_sound = NULL;
+        char *bad_pin_sound = NULL;
+        char *energy_level = NULL;
+        char *caller_id_name = NULL;
+        char *caller_id_number = NULL;
+        char *caller_controls = NULL;
+        char *member_flags = NULL;
+        char *conference_flags = NULL;
+        char *perpetual_sound = NULL;
+        char *moh_sound = NULL;
+        uint32_t max_members = 0;
+        uint32_t announce_count = 0;
+        char *maxmember_sound = NULL;
+        uint32_t rate = 8000, interval = 20;
+        switch_status_t status;
+        int comfort_noise_level = 0;
+        char *suppress_events = NULL;
+        char *verbose_events = NULL;
+        char *auto_record = NULL;
+
+        /* Validate the conference name */
+        if (zstr(name)) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid Record! no name.\n&quot;);
+                return NULL;
+        }
+
+        switch_mutex_lock(globals.hash_mutex);
+
+        /* parse the profile tree for param values */
+        if (cfg.profile)
+                for (xml_kvp = switch_xml_child(cfg.profile, &quot;param&quot;); xml_kvp; xml_kvp = xml_kvp-&gt;next) {
+                        char *var = (char *) switch_xml_attr_soft(xml_kvp, &quot;name&quot;);
+                        char *val = (char *) switch_xml_attr_soft(xml_kvp, &quot;value&quot;);
+                        char buf[128] = &quot;&quot;;
+                        char *p;
+
+                        if ((p = strchr(var, '_'))) {
+                                switch_copy_string(buf, var, sizeof(buf));
+                                for (p = buf; *p; p++) {
+                                        if (*p == '_') {
+                                                *p = '-';
+                                        }
+                                }
+                                var = buf;
+                        }
+
+                        if (!strcasecmp(var, &quot;rate&quot;) &amp;&amp; !zstr(val)) {
+                                uint32_t tmp = atoi(val);
+                                if (tmp == 8000 || tmp == 12000 || tmp == 16000 || tmp == 24000 || tmp == 32000 || tmp == 48000) {
+                                        rate = tmp;
+                                }
+                        } else if (!strcasecmp(var, &quot;domain&quot;) &amp;&amp; !zstr(val)) {
+                                domain = val;
+                        } else if (!strcasecmp(var, &quot;interval&quot;) &amp;&amp; !zstr(val)) {
+                                uint32_t tmp = atoi(val);
+                                if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) {
+                                        interval = tmp;
+                                } else {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                          &quot;Interval must be multipe of 10 and less than %d, Using default of 20\n&quot;, SWITCH_MAX_INTERVAL);
+                                }
+                        } else if (!strcasecmp(var, &quot;timer-name&quot;) &amp;&amp; !zstr(val)) {
+                                timer_name = val;
+                        } else if (!strcasecmp(var, &quot;tts-engine&quot;) &amp;&amp; !zstr(val)) {
+                                tts_engine = val;
+                        } else if (!strcasecmp(var, &quot;tts-voice&quot;) &amp;&amp; !zstr(val)) {
+                                tts_voice = val;
+                        } else if (!strcasecmp(var, &quot;enter-sound&quot;) &amp;&amp; !zstr(val)) {
+                                enter_sound = val;
+                        } else if (!strcasecmp(var, &quot;exit-sound&quot;) &amp;&amp; !zstr(val)) {
+                                exit_sound = val;
+                        } else if (!strcasecmp(var, &quot;alone-sound&quot;) &amp;&amp; !zstr(val)) {
+                                alone_sound = val;
+                        } else if (!strcasecmp(var, &quot;perpetual-sound&quot;) &amp;&amp; !zstr(val)) {
+                                perpetual_sound = val;
+                        } else if (!strcasecmp(var, &quot;moh-sound&quot;) &amp;&amp; !zstr(val)) {
+                                moh_sound = val;
+                        } else if (!strcasecmp(var, &quot;ack-sound&quot;) &amp;&amp; !zstr(val)) {
+                                ack_sound = val;
+                        } else if (!strcasecmp(var, &quot;nack-sound&quot;) &amp;&amp; !zstr(val)) {
+                                nack_sound = val;
+                        } else if (!strcasecmp(var, &quot;muted-sound&quot;) &amp;&amp; !zstr(val)) {
+                                muted_sound = val;
+                        } else if (!strcasecmp(var, &quot;mute-detect-sound&quot;) &amp;&amp; !zstr(val)) {
+                                mute_detect_sound = val;
+                        } else if (!strcasecmp(var, &quot;unmuted-sound&quot;) &amp;&amp; !zstr(val)) {
+                                unmuted_sound = val;
+                        } else if (!strcasecmp(var, &quot;locked-sound&quot;) &amp;&amp; !zstr(val)) {
+                                locked_sound = val;
+                        } else if (!strcasecmp(var, &quot;is-locked-sound&quot;) &amp;&amp; !zstr(val)) {
+                                is_locked_sound = val;
+                        } else if (!strcasecmp(var, &quot;is-unlocked-sound&quot;) &amp;&amp; !zstr(val)) {
+                                is_unlocked_sound = val;
+                        } else if (!strcasecmp(var, &quot;member-flags&quot;) &amp;&amp; !zstr(val)) {
+                                member_flags = val;
+                        } else if (!strcasecmp(var, &quot;conference-flags&quot;) &amp;&amp; !zstr(val)) {
+                                conference_flags = val;
+                        } else if (!strcasecmp(var, &quot;kicked-sound&quot;) &amp;&amp; !zstr(val)) {
+                                kicked_sound = val;
+                        } else if (!strcasecmp(var, &quot;pin&quot;) &amp;&amp; !zstr(val)) {
+                                pin = val;
+                        } else if (!strcasecmp(var, &quot;pin-sound&quot;) &amp;&amp; !zstr(val)) {
+                                pin_sound = val;
+                        } else if (!strcasecmp(var, &quot;bad-pin-sound&quot;) &amp;&amp; !zstr(val)) {
+                                bad_pin_sound = val;
+                        } else if (!strcasecmp(var, &quot;energy-level&quot;) &amp;&amp; !zstr(val)) {
+                                energy_level = val;
+                        } else if (!strcasecmp(var, &quot;caller-id-name&quot;) &amp;&amp; !zstr(val)) {
+                                caller_id_name = val;
+                        } else if (!strcasecmp(var, &quot;caller-id-number&quot;) &amp;&amp; !zstr(val)) {
+                                caller_id_number = val;
+                        } else if (!strcasecmp(var, &quot;caller-controls&quot;) &amp;&amp; !zstr(val)) {
+                                caller_controls = val;
+                        } else if (!strcasecmp(var, &quot;comfort-noise&quot;) &amp;&amp; !zstr(val)) {
+                                int tmp;
+                                tmp = atoi(val);
+                                if (tmp &gt; 1 &amp;&amp; tmp &lt; 10000) {
+                                        comfort_noise_level = tmp;
+                                } else if (switch_true(val)) {
+                                        comfort_noise_level = 1400;
+                                }
+                        } else if (!strcasecmp(var, &quot;sound-prefix&quot;) &amp;&amp; !zstr(val)) {
+                                sound_prefix = val;
+                        } else if (!strcasecmp(var, &quot;max-members&quot;) &amp;&amp; !zstr(val)) {
+                                errno = 0;                /* sanity first */
+                                max_members = strtol(val, NULL, 0);        /* base 0 lets 0x... for hex 0... for octal and base 10 otherwise through */
+                                if (errno == ERANGE || errno == EINVAL || max_members &lt; 0 || max_members == 1) {
+                                        /* a negative wont work well, and its foolish to have a conference limited to 1 person unless the outbound 
+                                         * stuff is added, see comments above
+                                         */
+                                        max_members = 0;        /* set to 0 to disable max counts */
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;max-members %s is invalid, not setting a limit\n&quot;, val);
+                                }
+                        } else if (!strcasecmp(var, &quot;max-members-sound&quot;) &amp;&amp; !zstr(val)) {
+                                maxmember_sound = val;
+                        } else if (!strcasecmp(var, &quot;announce-count&quot;) &amp;&amp; !zstr(val)) {
+                                errno = 0;                /* safety first */
+                                announce_count = strtol(val, NULL, 0);
+                                if (errno == ERANGE || errno == EINVAL) {
+                                        announce_count = 0;
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;announce-count is invalid, not anouncing member counts\n&quot;);
+                                }
+                        } else if (!strcasecmp(var, &quot;suppress-events&quot;) &amp;&amp; !zstr(val)) {
+                                suppress_events = val;
+                        } else if (!strcasecmp(var, &quot;verbose-events&quot;) &amp;&amp; !zstr(val)) {
+                                verbose_events = val;
+                        } else if (!strcasecmp(var, &quot;auto-record&quot;) &amp;&amp; !zstr(val)) {
+                                auto_record = val;
+                        }
+                }
+
+        /* Set defaults and various paramaters */
+
+        /* Timer module to use */
+        if (zstr(timer_name)) {
+                timer_name = &quot;soft&quot;;
+        }
+
+        /* Caller ID Name */
+        if (zstr(caller_id_name)) {
+                caller_id_name = (char *) global_app_name;
+        }
+
+        /* Caller ID Number */
+        if (zstr(caller_id_number)) {
+                caller_id_number = &quot;0000000000&quot;;
+        }
+
+        if (!pool) {
+                /* Setup a memory pool to use. */
+                if (switch_core_new_memory_pool(&amp;pool) != SWITCH_STATUS_SUCCESS) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Pool Failure\n&quot;);
+                        status = SWITCH_STATUS_TERM;
+                        conference = NULL;
+                        goto end;
+                }
+        }
+
+        /* Create the conference object. */
+        if (!(conference = switch_core_alloc(pool, sizeof(*conference)))) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Memory Error!\n&quot;);
+                status = SWITCH_STATUS_TERM;
+                conference = NULL;
+                goto end;
+        }
+
+        /* initialize the conference object with settings from the specified profile */
+        conference-&gt;pool = pool;
+        conference-&gt;profile_name = switch_core_strdup(conference-&gt;pool, cfg.profile ? switch_xml_attr_soft(cfg.profile, &quot;name&quot;) : &quot;none&quot;);
+        if (timer_name) {
+                conference-&gt;timer_name = switch_core_strdup(conference-&gt;pool, timer_name);
+        }
+        if (tts_engine) {
+                conference-&gt;tts_engine = switch_core_strdup(conference-&gt;pool, tts_engine);
+        }
+        if (tts_voice) {
+                conference-&gt;tts_voice = switch_core_strdup(conference-&gt;pool, tts_voice);
+        }
+
+        conference-&gt;comfort_noise_level = comfort_noise_level;
+        conference-&gt;caller_id_name = switch_core_strdup(conference-&gt;pool, caller_id_name);
+        conference-&gt;caller_id_number = switch_core_strdup(conference-&gt;pool, caller_id_number);
+
+
+        if (!zstr(perpetual_sound)) {
+                conference-&gt;perpetual_sound = switch_core_strdup(conference-&gt;pool, perpetual_sound);
+        }
+
+        conference-&gt;mflags = MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR;
+
+        if (!zstr(moh_sound) &amp;&amp; switch_is_moh(moh_sound)) {
+                conference-&gt;moh_sound = switch_core_strdup(conference-&gt;pool, moh_sound);
+        }
+
+        if (member_flags) {
+                set_mflags(member_flags, &amp;conference-&gt;mflags);
+        }
+
+        if (conference_flags) {
+                set_cflags(conference_flags, &amp;conference-&gt;flags);
+        }
+
+        if (sound_prefix) {
+                conference-&gt;sound_prefix = switch_core_strdup(conference-&gt;pool, sound_prefix);
+        }
+
+        if (!zstr(enter_sound)) {
+                conference-&gt;enter_sound = switch_core_strdup(conference-&gt;pool, enter_sound);
+        }
+
+        if (!zstr(exit_sound)) {
+                conference-&gt;exit_sound = switch_core_strdup(conference-&gt;pool, exit_sound);
+        }
+
+        if (!zstr(ack_sound)) {
+                conference-&gt;ack_sound = switch_core_strdup(conference-&gt;pool, ack_sound);
+        }
+
+        if (!zstr(nack_sound)) {
+                conference-&gt;nack_sound = switch_core_strdup(conference-&gt;pool, nack_sound);
+        }
+
+        if (!zstr(muted_sound)) {
+                conference-&gt;muted_sound = switch_core_strdup(conference-&gt;pool, muted_sound);
+        }
+
+        if (zstr(mute_detect_sound)) {
+                if (!zstr(muted_sound)) {
+                        conference-&gt;mute_detect_sound = switch_core_strdup(conference-&gt;pool, muted_sound);
+                }
+        } else {
+                conference-&gt;mute_detect_sound = switch_core_strdup(conference-&gt;pool, mute_detect_sound);
+        }
+
+        if (!zstr(unmuted_sound)) {
+                conference-&gt;unmuted_sound = switch_core_strdup(conference-&gt;pool, unmuted_sound);
+        }
+
+        if (!zstr(kicked_sound)) {
+                conference-&gt;kicked_sound = switch_core_strdup(conference-&gt;pool, kicked_sound);
+        }
+
+        if (!zstr(pin_sound)) {
+                conference-&gt;pin_sound = switch_core_strdup(conference-&gt;pool, pin_sound);
+        }
+
+        if (!zstr(bad_pin_sound)) {
+                conference-&gt;bad_pin_sound = switch_core_strdup(conference-&gt;pool, bad_pin_sound);
+        }
+
+        if (!zstr(pin)) {
+                conference-&gt;pin = switch_core_strdup(conference-&gt;pool, pin);
+        }
+
+        if (!zstr(alone_sound)) {
+                conference-&gt;alone_sound = switch_core_strdup(conference-&gt;pool, alone_sound);
+        }
+
+        if (!zstr(locked_sound)) {
+                conference-&gt;locked_sound = switch_core_strdup(conference-&gt;pool, locked_sound);
+        }
+
+        if (!zstr(is_locked_sound)) {
+                conference-&gt;is_locked_sound = switch_core_strdup(conference-&gt;pool, is_locked_sound);
+        }
+
+        if (!zstr(is_unlocked_sound)) {
+                conference-&gt;is_unlocked_sound = switch_core_strdup(conference-&gt;pool, is_unlocked_sound);
+        }
+
+        if (!zstr(energy_level)) {
+                conference-&gt;energy_level = atoi(energy_level);
+        }
+
+        if (!zstr(maxmember_sound)) {
+                conference-&gt;maxmember_sound = switch_core_strdup(conference-&gt;pool, maxmember_sound);
+        }
+        /* its going to be 0 by default, set to a value otherwise so this should be safe */
+        conference-&gt;max_members = max_members;
+        conference-&gt;announce_count = announce_count;
+
+        conference-&gt;name = switch_core_strdup(conference-&gt;pool, name);
+        if (domain) {
+                conference-&gt;domain = switch_core_strdup(conference-&gt;pool, domain);
+        } else {
+                conference-&gt;domain = &quot;cluecon.com&quot;;
+        }
+        conference-&gt;rate = rate;
+        conference-&gt;interval = interval;
+        conference-&gt;dtmf_parser = NULL;
+
+        conference-&gt;eflags = 0xFFFFFFFF;
+        if (!zstr(suppress_events)) {
+                clear_eflags(suppress_events, &amp;conference-&gt;eflags);
+        }
+
+        if (!zstr(auto_record)) {
+                conference-&gt;auto_record = switch_core_strdup(conference-&gt;pool, auto_record);
+        }
+
+        if (!zstr(verbose_events) &amp;&amp; switch_true(verbose_events)) {
+                conference-&gt;verbose_events = 1;
+        }
+
+        /* caller control configuration chores */
+        if (switch_ivr_digit_stream_parser_new(conference-&gt;pool, &amp;conference-&gt;dtmf_parser) == SWITCH_STATUS_SUCCESS) {
+
+                /* if no controls, or default controls specified, install default */
+                if (caller_controls == NULL || *caller_controls == '\0' || strcasecmp(caller_controls, &quot;default&quot;) == 0) {
+                        status = conf_default_controls(conference);
+                } else if (strcasecmp(caller_controls, &quot;none&quot;) != 0) {
+                        /* try to build caller control if the group has been specified and != &quot;none&quot; */
+                        switch_xml_t xml_controls = switch_xml_find_child(cfg.controls, &quot;group&quot;, &quot;name&quot;, caller_controls);
+                        status = conference_new_install_caller_controls_custom(conference, xml_controls, NULL);
+
+                        if (status != SWITCH_STATUS_SUCCESS) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Unable to install caller controls group '%s'\n&quot;, caller_controls);
+                        }
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;No caller controls installed.\n&quot;);
+                }
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Unable to allocate caller control digit parser.\n&quot;);
+        }
+
+        /* Activate the conference mutex for exclusivity */
+        switch_mutex_init(&amp;conference-&gt;mutex, SWITCH_MUTEX_NESTED, conference-&gt;pool);
+        switch_mutex_init(&amp;conference-&gt;flag_mutex, SWITCH_MUTEX_NESTED, conference-&gt;pool);
+        switch_thread_rwlock_create(&amp;conference-&gt;rwlock, conference-&gt;pool);
+        switch_mutex_init(&amp;conference-&gt;member_mutex, SWITCH_MUTEX_NESTED, conference-&gt;pool);
+        switch_mutex_lock(globals.hash_mutex);
+        switch_core_hash_insert(globals.conference_hash, conference-&gt;name, conference);
+        switch_mutex_unlock(globals.hash_mutex);
+
+  end:
+
+        switch_mutex_unlock(globals.hash_mutex);
+
+        return conference;
+}
+
+static void pres_event_handler(switch_event_t *event)
+{
+        char *to = switch_event_get_header(event, &quot;to&quot;);
+        char *dup_to = NULL, *conf_name, *e;
+        conference_obj_t *conference;
+
+        if (!to || strncasecmp(to, &quot;conf+&quot;, 5)) {
+                return;
+        }
+
+        if (!(dup_to = strdup(to))) {
+                return;
+        }
+
+        conf_name = dup_to + 5;
+
+        if ((e = strchr(conf_name, '@'))) {
+                *e = '\0';
+        }
+
+        if ((conference = conference_find(conf_name))) {
+                if (switch_event_create(&amp;event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;proto&quot;, CONF_CHAT_PROTO);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;login&quot;, conference-&gt;name);
+                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;from&quot;, &quot;%s@%s&quot;, conference-&gt;name, conference-&gt;domain);
+                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;status&quot;, &quot;Active (%d caller%s)&quot;, conference-&gt;count, conference-&gt;count == 1 ? &quot;&quot; : &quot;s&quot;);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;event_type&quot;, &quot;presence&quot;);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;alt_event_type&quot;, &quot;dialog&quot;);
+                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;event_count&quot;, &quot;%d&quot;, EC++);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;unique-id&quot;, conf_name);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;channel-state&quot;, &quot;CS_ROUTING&quot;);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;answer-state&quot;, conference-&gt;count == 1 ? &quot;early&quot; : &quot;confirmed&quot;);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;call-direction&quot;, conference-&gt;count == 1 ? &quot;outbound&quot; : &quot;inbound&quot;);
+                        switch_event_fire(&amp;event);
+                }
+        } else if (switch_event_create(&amp;event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;proto&quot;, CONF_CHAT_PROTO);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;login&quot;, conf_name);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;from&quot;, to);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;status&quot;, &quot;Idle&quot;);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;rpid&quot;, &quot;idle&quot;);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;event_type&quot;, &quot;presence&quot;);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;alt_event_type&quot;, &quot;dialog&quot;);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;event_count&quot;, &quot;%d&quot;, EC++);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;unique-id&quot;, conf_name);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;channel-state&quot;, &quot;CS_HANGUP&quot;);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;answer-state&quot;, &quot;terminated&quot;);
+                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;call-direction&quot;, &quot;inbound&quot;);
+                switch_event_fire(&amp;event);
+        }
+
+        switch_safe_free(dup_to);
+}
+
+static void send_presence(switch_event_types_t id)
+{
+        switch_xml_t cxml, cfg, advertise, room;
+        switch_event_t *params = NULL;
+
+        switch_event_create(&amp;params, SWITCH_EVENT_COMMAND);
+        switch_assert(params);
+        switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, &quot;presence&quot;, &quot;true&quot;);
+
+
+        /* Open the config from the xml registry */
+        if (!(cxml = switch_xml_open_cfg(global_cf_name, &amp;cfg, params))) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Open of %s failed\n&quot;, global_cf_name);
+                goto done;
+        }
+
+        if ((advertise = switch_xml_child(cfg, &quot;advertise&quot;))) {
+                for (room = switch_xml_child(advertise, &quot;room&quot;); room; room = room-&gt;next) {
+                        char *name = (char *) switch_xml_attr_soft(room, &quot;name&quot;);
+                        char *status = (char *) switch_xml_attr_soft(room, &quot;status&quot;);
+                        switch_event_t *event;
+
+                        if (name &amp;&amp; switch_event_create(&amp;event, id) == SWITCH_STATUS_SUCCESS) {
+                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;proto&quot;, CONF_CHAT_PROTO);
+                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;login&quot;, name);
+                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;from&quot;, name);
+                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;status&quot;, status ? status : &quot;Available&quot;);
+                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;rpid&quot;, &quot;idle&quot;);
+                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;event_type&quot;, &quot;presence&quot;);
+                                switch_event_fire(&amp;event);
+                        }
+                }
+        }
+
+  done:
+        switch_event_destroy(&amp;params);
+
+        /* Release the config registry handle */
+        if (cxml) {
+                switch_xml_free(cxml);
+                cxml = NULL;
+        }
+}
+
+/* Called by FreeSWITCH when the module loads */
+SWITCH_MODULE_LOAD_FUNCTION(mod_conference_load)
+{
+        uint32_t i;
+        size_t nl, ol = 0;
+        char *p = NULL, *tmp = NULL;
+        switch_chat_interface_t *chat_interface;
+        switch_api_interface_t *api_interface;
+        switch_application_interface_t *app_interface;
+        switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+        memset(&amp;globals, 0, sizeof(globals));
+
+        /* Connect my internal structure to the blank pointer passed to me */
+        *module_interface = switch_loadable_module_create_module_interface(pool, modname);
+
+        /* build api interface help &quot;.syntax&quot; field string */
+        p = strdup(&quot;&quot;);
+        for (i = 0; i &lt; CONFFUNCAPISIZE; i++) {
+                nl = strlen(conf_api_sub_commands[i].psyntax) + 4;
+                if (p != NULL) {
+                        ol = strlen(p);
+                }
+                tmp = realloc(p, ol + nl);
+                if (tmp != NULL) {
+                        p = tmp;
+                        strcat(p, &quot;\t\t&quot;);
+                        strcat(p, conf_api_sub_commands[i].psyntax);
+                        if (i &lt; CONFFUNCAPISIZE - 1) {
+                                strcat(p, &quot;\n&quot;);
+                        }
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn't realloc\n&quot;);
+                        return SWITCH_STATUS_TERM;
+                }
+
+        }
+        api_syntax = p;
+
+        /* create/register custom event message type */
+        if (switch_event_reserve_subclass(CONF_EVENT_MAINT) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn't register subclass %s!\n&quot;, CONF_EVENT_MAINT);
+                return SWITCH_STATUS_TERM;
+        }
+
+        /* Setup the pool */
+        globals.conference_pool = pool;
+
+        /* Setup a hash to store conferences by name */
+        switch_core_hash_init(&amp;globals.conference_hash, globals.conference_pool);
+        switch_mutex_init(&amp;globals.conference_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
+        switch_mutex_init(&amp;globals.id_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
+        switch_mutex_init(&amp;globals.hash_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
+        switch_mutex_init(&amp;globals.setup_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
+
+        /* Subscribe to presence request events */
+        if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL, &amp;globals.node) !=
+                SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn't subscribe to presence request events!\n&quot;);
+                return SWITCH_STATUS_GENERR;
+        }
+
+        SWITCH_ADD_API(api_interface, &quot;conference&quot;, &quot;Conference module commands&quot;, conf_api_main, p);
+        SWITCH_ADD_APP(app_interface, global_app_name, global_app_name, NULL, conference_function, NULL, SAF_NONE);
+        SWITCH_ADD_APP(app_interface, &quot;conference_set_auto_outcall&quot;, &quot;conference_set_auto_outcall&quot;, NULL, conference_auto_function, NULL, SAF_NONE);
+        SWITCH_ADD_CHAT(chat_interface, CONF_CHAT_PROTO, chat_send);
+
+        send_presence(SWITCH_EVENT_PRESENCE_IN);
+
+        globals.running = 1;
+        /* indicate that the module should continue to be loaded */
+        return status;
+}
+
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_conference_shutdown)
+{
+        if (globals.running) {
+
+                /* signal all threads to shutdown */
+                globals.running = 0;
+
+                /* wait for all threads */
+                while (globals.threads) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Waiting for %d threads\n&quot;, globals.threads);
+                        switch_yield(100000);
+                }
+
+                switch_event_unbind(&amp;globals.node);
+                switch_event_free_subclass(CONF_EVENT_MAINT);
+
+                /* free api interface help &quot;.syntax&quot; field string */
+                switch_safe_free(api_syntax);
+        }
+        switch_core_hash_destroy(&amp;globals.conference_hash);
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
+ */
</ins></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_conferencemod_conferencecrej"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c.rej (0 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c.rej                                (rev 0)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c.rej        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -0,0 +1,50 @@
</span><ins>+***************
+*** 3410,3420 ****
+          }
+          if (test_eflag(member-&gt;conference, EFLAG_VOLUME_IN_MEMBER) &amp;&amp;
+                  data &amp;&amp; switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                  conference_add_event_member_data(member, event);
+                  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;volume-in-member&quot;);
+-                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Volume-Level&quot;, &quot;%u&quot;, member-&gt;volume_in_level);
+                  switch_event_fire(&amp;event);
+          }
+  
+          return SWITCH_STATUS_SUCCESS;
+  }
+--- 3410,3420 ----
+          }
+          if (test_eflag(member-&gt;conference, EFLAG_VOLUME_IN_MEMBER) &amp;&amp;
+                  data &amp;&amp; switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                  conference_add_event_member_data(member, event);
+                  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;volume-in-member&quot;);
++                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Volume-Level&quot;, &quot;%d&quot;, member-&gt;volume_in_level);
+                  switch_event_fire(&amp;event);
+          }
+  
+          return SWITCH_STATUS_SUCCESS;
+  }
+***************
+*** 3437,3447 ****
+          }
+          if (test_eflag(member-&gt;conference, EFLAG_VOLUME_OUT_MEMBER) &amp;&amp; data &amp;&amp;
+                  switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                  conference_add_event_member_data(member, event);
+                  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;volume-out-member&quot;);
+-                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Volume-Level&quot;, &quot;%u&quot;, member-&gt;volume_out_level);
+                  switch_event_fire(&amp;event);
+          }
+  
+          return SWITCH_STATUS_SUCCESS;
+  }
+--- 3437,3447 ----
+          }
+          if (test_eflag(member-&gt;conference, EFLAG_VOLUME_OUT_MEMBER) &amp;&amp; data &amp;&amp;
+                  switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+                  conference_add_event_member_data(member, event);
+                  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;volume-out-member&quot;);
++                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Volume-Level&quot;, &quot;%d&quot;, member-&gt;volume_out_level);
+                  switch_event_fire(&amp;event);
+          }
+  
+          return SWITCH_STATUS_SUCCESS;
+  }
</ins></span></pre></div>
<a id="freeswitchtrunksrcmodformatsmod_sndfilemod_sndfilecorig"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c.orig (0 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c.orig                                (rev 0)
+++ freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c.orig        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -0,0 +1,462 @@
</span><ins>+/* 
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the &quot;License&quot;); 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 &quot;AS IS&quot; 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 &lt;anthm@freeswitch.org&gt;
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * 
+ * Anthony Minessale II &lt;anthm@freeswitch.org&gt;
+ *
+ *
+ * mod_sndfile.c -- Framework Demo Module
+ *
+ */
+#include &lt;switch.h&gt;
+#include &lt;sndfile.h&gt;
+
+SWITCH_MODULE_LOAD_FUNCTION(mod_sndfile_load);
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sndfile_shutdown);
+SWITCH_MODULE_DEFINITION(mod_sndfile, mod_sndfile_load, mod_sndfile_shutdown, NULL);
+
+static switch_memory_pool_t *module_pool = NULL;
+
+static struct {
+        switch_hash_t *format_hash;
+} globals;
+
+struct format_map {
+        char *ext;
+        char *uext;
+        uint32_t format;
+};
+
+struct sndfile_context {
+        SF_INFO sfinfo;
+        SNDFILE *handle;
+};
+
+typedef struct sndfile_context sndfile_context;
+
+static switch_status_t sndfile_file_open(switch_file_handle_t *handle, const char *path)
+{
+        sndfile_context *context;
+        int mode = 0;
+        char *ext;
+        struct format_map *map = NULL;
+        switch_status_t status = SWITCH_STATUS_SUCCESS;
+        char *alt_path = NULL, *last, *ldup = NULL;
+        size_t alt_len = 0;
+        int rates[4] = { 8000, 16000, 32000, 48000 };
+        int i;
+#ifdef WIN32
+        char ps = '\\';
+#else
+        char ps = '/';
+#endif
+
+        if ((ext = strrchr(path, '.')) == 0) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid Format\n&quot;);
+                return SWITCH_STATUS_GENERR;
+        }
+        ext++;
+
+        if (switch_test_flag(handle, SWITCH_FILE_FLAG_READ)) {
+                mode += SFM_READ;
+        }
+
+        if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) {
+                if (switch_test_flag(handle, SWITCH_FILE_WRITE_APPEND)) {
+                        mode += SFM_RDWR;
+                } else {
+                        mode += SFM_WRITE;
+                }
+        }
+
+        if (!mode) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid Mode!\n&quot;);
+                return SWITCH_STATUS_GENERR;
+        }
+
+        if ((context = switch_core_alloc(handle-&gt;memory_pool, sizeof(*context))) == 0) {
+                return SWITCH_STATUS_MEMERR;
+        }
+
+        map = switch_core_hash_find(globals.format_hash, ext);
+
+        if (mode &amp; SFM_WRITE) {
+                context-&gt;sfinfo.channels = handle-&gt;channels;
+                context-&gt;sfinfo.samplerate = handle-&gt;samplerate;
+                if (handle-&gt;samplerate == 8000 || handle-&gt;samplerate == 16000 ||
+                        handle-&gt;samplerate == 24000 || handle-&gt;samplerate == 32000 || handle-&gt;samplerate == 48000 ||
+                        handle-&gt;samplerate == 11025 || handle-&gt;samplerate == 22050 || handle-&gt;samplerate == 44100) {
+                        context-&gt;sfinfo.format |= SF_FORMAT_PCM_16;
+                }
+        }
+
+        if (map) {
+                context-&gt;sfinfo.format |= map-&gt;format;
+        }
+
+        if (!strcmp(ext, &quot;r8&quot;) || !strcmp(ext, &quot;raw&quot;)) {
+                context-&gt;sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16;
+                context-&gt;sfinfo.channels = 1;
+                context-&gt;sfinfo.samplerate = 8000;
+        } else if (!strcmp(ext, &quot;r16&quot;)) {
+                context-&gt;sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16;
+                context-&gt;sfinfo.channels = 1;
+                context-&gt;sfinfo.samplerate = 16000;
+        } else if (!strcmp(ext, &quot;r24&quot;)) {
+                context-&gt;sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_24;
+                context-&gt;sfinfo.channels = 1;
+                context-&gt;sfinfo.samplerate = 24000;
+        } else if (!strcmp(ext, &quot;r32&quot;)) {
+                context-&gt;sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_32;
+                context-&gt;sfinfo.channels = 1;
+                context-&gt;sfinfo.samplerate = 32000;
+        } else if (!strcmp(ext, &quot;gsm&quot;)) {
+                context-&gt;sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_GSM610;
+                context-&gt;sfinfo.channels = 1;
+                context-&gt;sfinfo.samplerate = 8000;
+        } else if (!strcmp(ext, &quot;ul&quot;)) {
+                context-&gt;sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_ULAW;
+                context-&gt;sfinfo.channels = 1;
+                context-&gt;sfinfo.samplerate = 8000;
+        } else if (!strcmp(ext, &quot;al&quot;)) {
+                context-&gt;sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_ALAW;
+                context-&gt;sfinfo.channels = 1;
+                context-&gt;sfinfo.samplerate = 8000;
+        } else if (!strcmp(ext, &quot;adpcm&quot;)) {
+                context-&gt;sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM;
+                context-&gt;sfinfo.channels = 1;
+                context-&gt;sfinfo.samplerate = 8000;
+        }
+
+        if ((mode &amp; SFM_WRITE) &amp;&amp; sf_format_check(&amp;context-&gt;sfinfo) == 0) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error : file format is invalid (0x%08X).\n&quot;, context-&gt;sfinfo.format);
+                return SWITCH_STATUS_GENERR;
+        }
+
+        alt_len = strlen(path) + 10;
+        switch_zmalloc(alt_path, alt_len);
+
+        switch_copy_string(alt_path, path, alt_len);
+
+        /* This block attempts to add the sample rate to the path
+           if the sample rate is already present in the path it does nothing
+           and reverts to the original file name.
+         */
+        if ((last = strrchr(alt_path, ps))) {
+                last++;
+#ifdef WIN32
+                if (strrchr(last, '/')) {
+                        last = strrchr(alt_path, '/');        /* do not swallow a forward slash if they are intermixed under windows */
+                        last++;
+                }
+#endif
+                ldup = strdup(last);
+                switch_assert(ldup);
+                switch_snprintf(last, alt_len - (last - alt_path), &quot;%d%s%s&quot;, handle-&gt;samplerate, SWITCH_PATH_SEPARATOR, ldup);
+                if ((context-&gt;handle = sf_open(alt_path, mode, &amp;context-&gt;sfinfo))) {
+                        path = alt_path;
+                } else {
+                        /* Try to find the file at the highest rate possible if we can't find one that matches the exact rate.
+                           If we don't find any, we will default back to the original file name.
+                         */
+                        for (i = 3; i &gt;= 0; i--) {
+                                switch_snprintf(last, alt_len - (last - alt_path), &quot;%d%s%s&quot;, rates[i], SWITCH_PATH_SEPARATOR, ldup);
+                                if ((context-&gt;handle = sf_open(alt_path, mode, &amp;context-&gt;sfinfo))) {
+                                        path = alt_path;
+                                        break;
+                                }
+                        }
+                }
+        }
+
+        if (!context-&gt;handle) {
+                if ((context-&gt;handle = sf_open(path, mode, &amp;context-&gt;sfinfo)) == 0) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Opening File [%s] [%s]\n&quot;, path, sf_strerror(context-&gt;handle));
+                        status = SWITCH_STATUS_GENERR;
+                        goto end;
+                }
+        }
+        //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Opening File [%s] rate %dhz\n&quot;, path, context-&gt;sfinfo.samplerate);
+        handle-&gt;samples = (unsigned int) context-&gt;sfinfo.frames;
+        handle-&gt;samplerate = context-&gt;sfinfo.samplerate;
+        handle-&gt;channels = (uint8_t) context-&gt;sfinfo.channels;
+        handle-&gt;format = context-&gt;sfinfo.format;
+        handle-&gt;sections = context-&gt;sfinfo.sections;
+        handle-&gt;seekable = context-&gt;sfinfo.seekable;
+        handle-&gt;speed = 0;
+        handle-&gt;private_info = context;
+
+        if (switch_test_flag(handle, SWITCH_FILE_WRITE_APPEND)) {
+                handle-&gt;pos = sf_seek(context-&gt;handle, 0, SEEK_END);
+        } else {
+                sf_count_t frames = 0;
+                sf_command(context-&gt;handle, SFC_FILE_TRUNCATE, &amp;frames, sizeof(frames));
+        }
+
+
+  end:
+
+        switch_safe_free(alt_path);
+        switch_safe_free(ldup);
+
+        return status;
+}
+
+static switch_status_t sndfile_file_truncate(switch_file_handle_t *handle, int64_t offset)
+{
+        sndfile_context *context = handle-&gt;private_info;
+        sf_command(context-&gt;handle, SFC_FILE_TRUNCATE, &amp;offset, sizeof(offset));
+        handle-&gt;pos = 0;
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t sndfile_file_close(switch_file_handle_t *handle)
+{
+        sndfile_context *context = handle-&gt;private_info;
+
+        sf_close(context-&gt;handle);
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t sndfile_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence)
+{
+        sndfile_context *context = handle-&gt;private_info;
+
+        if (!handle-&gt;seekable) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;File is not seekable\n&quot;);
+                return SWITCH_STATUS_NOTIMPL;
+        }
+
+        *cur_sample = (unsigned int) sf_seek(context-&gt;handle, samples, whence);
+        handle-&gt;pos = *cur_sample;
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t sndfile_file_read(switch_file_handle_t *handle, void *data, size_t *len)
+{
+        size_t inlen = *len;
+        sndfile_context *context = handle-&gt;private_info;
+
+        if (switch_test_flag(handle, SWITCH_FILE_DATA_RAW)) {
+                *len = (size_t) sf_read_raw(context-&gt;handle, data, inlen);
+        } else if (switch_test_flag(handle, SWITCH_FILE_DATA_INT)) {
+                *len = (size_t) sf_readf_int(context-&gt;handle, (int *) data, inlen);
+        } else if (switch_test_flag(handle, SWITCH_FILE_DATA_SHORT)) {
+                *len = (size_t) sf_readf_short(context-&gt;handle, (short *) data, inlen);
+        } else if (switch_test_flag(handle, SWITCH_FILE_DATA_FLOAT)) {
+                *len = (size_t) sf_readf_float(context-&gt;handle, (float *) data, inlen);
+        } else if (switch_test_flag(handle, SWITCH_FILE_DATA_DOUBLE)) {
+                *len = (size_t) sf_readf_double(context-&gt;handle, (double *) data, inlen);
+        } else {
+                *len = (size_t) sf_readf_int(context-&gt;handle, (int *) data, inlen);
+        }
+
+        handle-&gt;pos += *len;
+        handle-&gt;sample_count += *len;
+
+        return *len ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
+}
+
+static switch_status_t sndfile_file_write(switch_file_handle_t *handle, void *data, size_t *len)
+{
+        size_t inlen = *len;
+        sndfile_context *context = handle-&gt;private_info;
+
+        if (switch_test_flag(handle, SWITCH_FILE_DATA_RAW)) {
+                *len = (size_t) sf_write_raw(context-&gt;handle, data, inlen);
+        } else if (switch_test_flag(handle, SWITCH_FILE_DATA_INT)) {
+                *len = (size_t) sf_writef_int(context-&gt;handle, (int *) data, inlen);
+        } else if (switch_test_flag(handle, SWITCH_FILE_DATA_SHORT)) {
+                *len = (size_t) sf_writef_short(context-&gt;handle, (short *) data, inlen);
+        } else if (switch_test_flag(handle, SWITCH_FILE_DATA_FLOAT)) {
+                *len = (size_t) sf_writef_float(context-&gt;handle, (float *) data, inlen);
+        } else if (switch_test_flag(handle, SWITCH_FILE_DATA_DOUBLE)) {
+                *len = (size_t) sf_writef_double(context-&gt;handle, (double *) data, inlen);
+        } else {
+                *len = (size_t) sf_writef_int(context-&gt;handle, (int *) data, inlen);
+        }
+
+        handle-&gt;sample_count += *len;
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t sndfile_file_set_string(switch_file_handle_t *handle, switch_audio_col_t col, const char *string)
+{
+        sndfile_context *context = handle-&gt;private_info;
+
+        return sf_set_string(context-&gt;handle, (int) col, string) ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t sndfile_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col, const char **string)
+{
+        sndfile_context *context = handle-&gt;private_info;
+        const char *s;
+
+        if ((s = sf_get_string(context-&gt;handle, (int) col))) {
+                *string = s;
+                return SWITCH_STATUS_SUCCESS;
+        }
+
+        return SWITCH_STATUS_FALSE;
+}
+
+/* Registration */
+
+static char **supported_formats;
+
+static switch_status_t setup_formats(void)
+{
+        SF_FORMAT_INFO info;
+        SF_INFO sfinfo;
+        char buffer[128];
+        int format, major_count, subtype_count, m, s;
+        int len, x, skip;
+        char *extras[] = { &quot;r8&quot;, &quot;r16&quot;, &quot;r24&quot;, &quot;r32&quot;, &quot;gsm&quot;, &quot;ul&quot;, &quot;al&quot;, &quot;adpcm&quot;, NULL };
+        int exlen = (sizeof(extras) / sizeof(extras[0]));
+        buffer[0] = 0;
+
+        sf_command(NULL, SFC_GET_LIB_VERSION, buffer, sizeof(buffer));
+        if (strlen(buffer) &lt; 1) {
+                switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, &quot;Line %d: could not retrieve lib version.\n&quot;, __LINE__);
+                return SWITCH_STATUS_FALSE;
+        }
+
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;\nLibSndFile Version : %s Supported Formats\n&quot;, buffer);
+        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, &quot;================================================================================\n&quot;);
+        sf_command(NULL, SFC_GET_FORMAT_MAJOR_COUNT, &amp;major_count, sizeof(int));
+        sf_command(NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &amp;subtype_count, sizeof(int));
+
+        sfinfo.channels = 1;
+        len = ((major_count + (exlen + 2)) * sizeof(char *));
+        supported_formats = switch_core_permanent_alloc(len);
+
+        len = 0;
+        for (m = 0; m &lt; major_count; m++) {
+                skip = 0;
+                info.format = m;
+                sf_command(NULL, SFC_GET_FORMAT_MAJOR, &amp;info, sizeof(info));
+                switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, &quot;%s  (extension \&quot;%s\&quot;)\n&quot;, info.name, info.extension);
+                for (x = 0; x &lt; len; x++) {
+                        if (supported_formats[x] == info.extension) {
+                                skip++;
+                                break;
+                        }
+                }
+                if (!skip) {
+                        char *p;
+                        struct format_map *map = switch_core_permanent_alloc(sizeof(*map));
+                        switch_assert(map);
+
+                        map-&gt;ext = switch_core_permanent_strdup(info.extension);
+                        map-&gt;uext = switch_core_permanent_strdup(info.extension);
+                        map-&gt;format = info.format;
+                        if (map-&gt;ext) {
+                                for (p = map-&gt;ext; *p; p++) {
+                                        *p = (char) switch_tolower(*p);
+                                }
+                                switch_core_hash_insert(globals.format_hash, map-&gt;ext, map);
+                        }
+                        if (map-&gt;uext) {
+                                for (p = map-&gt;uext; *p; p++) {
+                                        *p = (char) switch_toupper(*p);
+                                }
+                                switch_core_hash_insert(globals.format_hash, map-&gt;uext, map);
+                        }
+                        supported_formats[len++] = (char *) info.extension;
+                }
+                format = info.format;
+
+                for (s = 0; s &lt; subtype_count; s++) {
+                        info.format = s;
+                        sf_command(NULL, SFC_GET_FORMAT_SUBTYPE, &amp;info, sizeof(info));
+                        format = (format &amp; SF_FORMAT_TYPEMASK) | info.format;
+                        sfinfo.format = format;
+                        /*
+                           if (sf_format_check(&amp;sfinfo)) {
+                           switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, &quot;   %s\n&quot;, info.name);
+                           }
+                         */
+                }
+        }
+        for (m = 0; m &lt; exlen; m++) {
+                supported_formats[len++] = extras[m];
+        }
+
+        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_NOTICE, &quot;================================================================================\n&quot;);
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_MODULE_LOAD_FUNCTION(mod_sndfile_load)
+{
+        switch_file_interface_t *file_interface;
+
+        if (switch_core_new_memory_pool(&amp;module_pool) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;OH OH no pool\n&quot;);
+                return SWITCH_STATUS_TERM;
+        }
+
+        switch_core_hash_init(&amp;globals.format_hash, module_pool);
+
+        if (setup_formats() != SWITCH_STATUS_SUCCESS) {
+                return SWITCH_STATUS_FALSE;
+        }
+
+        /* connect my internal structure to the blank pointer passed to me */
+        *module_interface = switch_loadable_module_create_module_interface(pool, modname);
+        file_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_FILE_INTERFACE);
+        file_interface-&gt;interface_name = modname;
+        file_interface-&gt;extens = supported_formats;
+        file_interface-&gt;file_open = sndfile_file_open;
+        file_interface-&gt;file_close = sndfile_file_close;
+        file_interface-&gt;file_truncate = sndfile_file_truncate;
+        file_interface-&gt;file_read = sndfile_file_read;
+        file_interface-&gt;file_write = sndfile_file_write;
+        file_interface-&gt;file_seek = sndfile_file_seek;
+        file_interface-&gt;file_set_string = sndfile_file_set_string;
+        file_interface-&gt;file_get_string = sndfile_file_get_string;
+
+        /* indicate that the module should continue to be loaded */
+        return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sndfile_shutdown)
+{
+        switch_core_hash_destroy(&amp;globals.format_hash);
+        return SWITCH_STATUS_SUCCESS;
+}
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
+ */
</ins></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_javasrcorgfreeswitchswigAPIjava"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/API.java (17515 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/API.java        2010-05-10 17:03:22 UTC (rev 17515)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/API.java        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -38,13 +38,9 @@
</span><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">   public String execute(String command, String data) {
</span><del>-    return freeswitchJNI.API_execute__SWIG_0(swigCPtr, this, command, data);
</del><ins>+    return freeswitchJNI.API_execute(swigCPtr, this, command, data);
</ins><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public String execute(String command) {
-    return freeswitchJNI.API_execute__SWIG_1(swigCPtr, this, command);
-  }
-
</del><span class="cx">   public String executeString(String command) {
</span><span class="cx">     return freeswitchJNI.API_executeString(swigCPtr, this, command);
</span><span class="cx">   }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_javasrcorgfreeswitchswigCoreSessionjava"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java (17515 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java        2010-05-10 17:03:22 UTC (rev 17515)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -125,13 +125,9 @@
</span><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">   public void hangup(String cause) {
</span><del>-    freeswitchJNI.CoreSession_hangup__SWIG_0(swigCPtr, this, cause);
</del><ins>+    freeswitchJNI.CoreSession_hangup(swigCPtr, this, cause);
</ins><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public void hangup() {
-    freeswitchJNI.CoreSession_hangup__SWIG_1(swigCPtr, this);
-  }
-
</del><span class="cx">   public void hangupState() {
</span><span class="cx">     freeswitchJNI.CoreSession_hangupState(swigCPtr, this);
</span><span class="cx">   }
</span><span class="lines">@@ -158,25 +154,13 @@
</span><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">   public void say(String tosay, String module_name, String say_type, String say_method, String say_gender) {
</span><del>-    freeswitchJNI.CoreSession_say__SWIG_0(swigCPtr, this, tosay, module_name, say_type, say_method, say_gender);
</del><ins>+    freeswitchJNI.CoreSession_say(swigCPtr, this, tosay, module_name, say_type, say_method, say_gender);
</ins><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public void say(String tosay, String module_name, String say_type, String say_method) {
-    freeswitchJNI.CoreSession_say__SWIG_1(swigCPtr, this, tosay, module_name, say_type, say_method);
-  }
-
</del><span class="cx">   public void sayPhrase(String phrase_name, String phrase_data, String phrase_lang) {
</span><del>-    freeswitchJNI.CoreSession_sayPhrase__SWIG_0(swigCPtr, this, phrase_name, phrase_data, phrase_lang);
</del><ins>+    freeswitchJNI.CoreSession_sayPhrase(swigCPtr, this, phrase_name, phrase_data, phrase_lang);
</ins><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public void sayPhrase(String phrase_name, String phrase_data) {
-    freeswitchJNI.CoreSession_sayPhrase__SWIG_1(swigCPtr, this, phrase_name, phrase_data);
-  }
-
-  public void sayPhrase(String phrase_name) {
-    freeswitchJNI.CoreSession_sayPhrase__SWIG_2(swigCPtr, this, phrase_name);
-  }
-
</del><span class="cx">   public String hangupCause() {
</span><span class="cx">     return freeswitchJNI.CoreSession_hangupCause(swigCPtr, this);
</span><span class="cx">   }
</span><span class="lines">@@ -186,33 +170,13 @@
</span><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">   public int recordFile(String file_name, int time_limit, int silence_threshold, int silence_hits) {
</span><del>-    return freeswitchJNI.CoreSession_recordFile__SWIG_0(swigCPtr, this, file_name, time_limit, silence_threshold, silence_hits);
</del><ins>+    return freeswitchJNI.CoreSession_recordFile(swigCPtr, this, file_name, time_limit, silence_threshold, silence_hits);
</ins><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public int recordFile(String file_name, int time_limit, int silence_threshold) {
-    return freeswitchJNI.CoreSession_recordFile__SWIG_1(swigCPtr, this, file_name, time_limit, silence_threshold);
-  }
-
-  public int recordFile(String file_name, int time_limit) {
-    return freeswitchJNI.CoreSession_recordFile__SWIG_2(swigCPtr, this, file_name, time_limit);
-  }
-
-  public int recordFile(String file_name) {
-    return freeswitchJNI.CoreSession_recordFile__SWIG_3(swigCPtr, this, file_name);
-  }
-
</del><span class="cx">   public int originate(CoreSession a_leg_session, String dest, int timeout, SWIGTYPE_p_switch_state_handler_table_t handlers) {
</span><del>-    return freeswitchJNI.CoreSession_originate__SWIG_0(swigCPtr, this, CoreSession.getCPtr(a_leg_session), a_leg_session, dest, timeout, SWIGTYPE_p_switch_state_handler_table_t.getCPtr(handlers));
</del><ins>+    return freeswitchJNI.CoreSession_originate(swigCPtr, this, CoreSession.getCPtr(a_leg_session), a_leg_session, dest, timeout, SWIGTYPE_p_switch_state_handler_table_t.getCPtr(handlers));
</ins><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public int originate(CoreSession a_leg_session, String dest, int timeout) {
-    return freeswitchJNI.CoreSession_originate__SWIG_1(swigCPtr, this, CoreSession.getCPtr(a_leg_session), a_leg_session, dest, timeout);
-  }
-
-  public int originate(CoreSession a_leg_session, String dest) {
-    return freeswitchJNI.CoreSession_originate__SWIG_2(swigCPtr, this, CoreSession.getCPtr(a_leg_session), a_leg_session, dest);
-  }
-
</del><span class="cx">   public void destroy() {
</span><span class="cx">     freeswitchJNI.CoreSession_destroy(swigCPtr, this);
</span><span class="cx">   }
</span><span class="lines">@@ -246,45 +210,25 @@
</span><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">   public int transfer(String extension, String dialplan, String context) {
</span><del>-    return freeswitchJNI.CoreSession_transfer__SWIG_0(swigCPtr, this, extension, dialplan, context);
</del><ins>+    return freeswitchJNI.CoreSession_transfer(swigCPtr, this, extension, dialplan, context);
</ins><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public int transfer(String extension, String dialplan) {
-    return freeswitchJNI.CoreSession_transfer__SWIG_1(swigCPtr, this, extension, dialplan);
-  }
-
-  public int transfer(String extension) {
-    return freeswitchJNI.CoreSession_transfer__SWIG_2(swigCPtr, this, extension);
-  }
-
</del><span class="cx">   public String read(int min_digits, int max_digits, String prompt_audio_file, int timeout, String valid_terminators) {
</span><span class="cx">     return freeswitchJNI.CoreSession_read(swigCPtr, this, min_digits, max_digits, prompt_audio_file, timeout, valid_terminators);
</span><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">   public String playAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, String terminators, String audio_files, String bad_input_audio_files, String digits_regex, String var_name) {
</span><del>-    return freeswitchJNI.CoreSession_playAndGetDigits__SWIG_0(swigCPtr, this, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, digits_regex, var_name);
</del><ins>+    return freeswitchJNI.CoreSession_playAndGetDigits(swigCPtr, this, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, digits_regex, var_name);
</ins><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public String playAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, String terminators, String audio_files, String bad_input_audio_files, String digits_regex) {
-    return freeswitchJNI.CoreSession_playAndGetDigits__SWIG_1(swigCPtr, this, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, digits_regex);
-  }
-
</del><span class="cx">   public int streamFile(String file, int starting_sample_count) {
</span><del>-    return freeswitchJNI.CoreSession_streamFile__SWIG_0(swigCPtr, this, file, starting_sample_count);
</del><ins>+    return freeswitchJNI.CoreSession_streamFile(swigCPtr, this, file, starting_sample_count);
</ins><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public int streamFile(String file) {
-    return freeswitchJNI.CoreSession_streamFile__SWIG_1(swigCPtr, this, file);
-  }
-
</del><span class="cx">   public int sleep(int ms, int sync) {
</span><del>-    return freeswitchJNI.CoreSession_sleep__SWIG_0(swigCPtr, this, ms, sync);
</del><ins>+    return freeswitchJNI.CoreSession_sleep(swigCPtr, this, ms, sync);
</ins><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public int sleep(int ms) {
-    return freeswitchJNI.CoreSession_sleep__SWIG_1(swigCPtr, this, ms);
-  }
-
</del><span class="cx">   public int flushEvents() {
</span><span class="cx">     return freeswitchJNI.CoreSession_flushEvents(swigCPtr, this);
</span><span class="cx">   }
</span><span class="lines">@@ -322,13 +266,9 @@
</span><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">   public void execute(String app, String data) {
</span><del>-    freeswitchJNI.CoreSession_execute__SWIG_0(swigCPtr, this, app, data);
</del><ins>+    freeswitchJNI.CoreSession_execute(swigCPtr, this, app, data);
</ins><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public void execute(String app) {
-    freeswitchJNI.CoreSession_execute__SWIG_1(swigCPtr, this, app);
-  }
-
</del><span class="cx">   public void sendEvent(Event sendME) {
</span><span class="cx">     freeswitchJNI.CoreSession_sendEvent(swigCPtr, this, Event.getCPtr(sendME), sendME);
</span><span class="cx">   }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_javasrcorgfreeswitchswigDTMFjava"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/DTMF.java (17515 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/DTMF.java        2010-05-10 17:03:22 UTC (rev 17515)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/DTMF.java        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -50,11 +50,7 @@
</span><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">   public DTMF(char idigit, SWIGTYPE_p_uint32_t iduration) {
</span><del>-    this(freeswitchJNI.new_DTMF__SWIG_0(idigit, SWIGTYPE_p_uint32_t.getCPtr(iduration)), true);
</del><ins>+    this(freeswitchJNI.new_DTMF(idigit, SWIGTYPE_p_uint32_t.getCPtr(iduration)), true);
</ins><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public DTMF(char idigit) {
-    this(freeswitchJNI.new_DTMF__SWIG_1(idigit), true);
-  }
-
</del><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_javasrcorgfreeswitchswigEventjava"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/Event.java (17515 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/Event.java        2010-05-10 17:03:22 UTC (rev 17515)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/Event.java        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -62,34 +62,18 @@
</span><span class="cx">     this(freeswitchJNI.new_Event__SWIG_0(type, subclass_name), true);
</span><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public Event(String type) {
-    this(freeswitchJNI.new_Event__SWIG_1(type), true);
-  }
-
</del><span class="cx">   public Event(SWIGTYPE_p_switch_event_t wrap_me, int free_me) {
</span><del>-    this(freeswitchJNI.new_Event__SWIG_2(SWIGTYPE_p_switch_event_t.getCPtr(wrap_me), free_me), true);
</del><ins>+    this(freeswitchJNI.new_Event__SWIG_1(SWIGTYPE_p_switch_event_t.getCPtr(wrap_me), free_me), true);
</ins><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public Event(SWIGTYPE_p_switch_event_t wrap_me) {
-    this(freeswitchJNI.new_Event__SWIG_3(SWIGTYPE_p_switch_event_t.getCPtr(wrap_me)), true);
-  }
-
</del><span class="cx">   public String serialize(String format) {
</span><del>-    return freeswitchJNI.Event_serialize__SWIG_0(swigCPtr, this, format);
</del><ins>+    return freeswitchJNI.Event_serialize(swigCPtr, this, format);
</ins><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public String serialize() {
-    return freeswitchJNI.Event_serialize__SWIG_1(swigCPtr, this);
-  }
-
</del><span class="cx">   public boolean setPriority(SWIGTYPE_p_switch_priority_t priority) {
</span><del>-    return freeswitchJNI.Event_setPriority__SWIG_0(swigCPtr, this, SWIGTYPE_p_switch_priority_t.getCPtr(priority));
</del><ins>+    return freeswitchJNI.Event_setPriority(swigCPtr, this, SWIGTYPE_p_switch_priority_t.getCPtr(priority));
</ins><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public boolean setPriority() {
-    return freeswitchJNI.Event_setPriority__SWIG_1(swigCPtr, this);
-  }
-
</del><span class="cx">   public String getHeader(String header_name) {
</span><span class="cx">     return freeswitchJNI.Event_getHeader(swigCPtr, this, header_name);
</span><span class="cx">   }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_javasrcorgfreeswitchswigEventConsumerjava"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/EventConsumer.java (17515 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/EventConsumer.java        2010-05-10 17:03:22 UTC (rev 17515)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/EventConsumer.java        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -50,15 +50,6 @@
</span><span class="cx">     return new SWIGTYPE_p_switch_event_types_t(freeswitchJNI.EventConsumer_e_event_id_get(swigCPtr, this), true);
</span><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public void setNode(SWIGTYPE_p_switch_event_node_t value) {
-    freeswitchJNI.EventConsumer_node_set(swigCPtr, this, SWIGTYPE_p_switch_event_node_t.getCPtr(value));
-  }
-
-  public SWIGTYPE_p_switch_event_node_t getNode() {
-    long cPtr = freeswitchJNI.EventConsumer_node_get(swigCPtr, this);
-    return (cPtr == 0) ? null : new SWIGTYPE_p_switch_event_node_t(cPtr, false);
-  }
-
</del><span class="cx">   public void setE_callback(String value) {
</span><span class="cx">     freeswitchJNI.EventConsumer_e_callback_set(swigCPtr, this, value);
</span><span class="cx">   }
</span><span class="lines">@@ -84,21 +75,16 @@
</span><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">   public EventConsumer(String event_name, String subclass_name) {
</span><del>-    this(freeswitchJNI.new_EventConsumer__SWIG_0(event_name, subclass_name), true);
</del><ins>+    this(freeswitchJNI.new_EventConsumer(event_name, subclass_name), true);
</ins><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public EventConsumer(String event_name) {
-    this(freeswitchJNI.new_EventConsumer__SWIG_1(event_name), true);
</del><ins>+  public int bind(String event_name, String subclass_name) {
+    return freeswitchJNI.EventConsumer_bind(swigCPtr, this, event_name, subclass_name);
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">   public Event pop(int block) {
</span><del>-    long cPtr = freeswitchJNI.EventConsumer_pop__SWIG_0(swigCPtr, this, block);
</del><ins>+    long cPtr = freeswitchJNI.EventConsumer_pop(swigCPtr, this, block);
</ins><span class="cx">     return (cPtr == 0) ? null : new Event(cPtr, true);
</span><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public Event pop() {
-    long cPtr = freeswitchJNI.EventConsumer_pop__SWIG_1(swigCPtr, this);
-    return (cPtr == 0) ? null : new Event(cPtr, true);
-  }
-
</del><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_javasrcorgfreeswitchswigfreeswitchJNIjava"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java (17515 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java        2010-05-10 17:03:22 UTC (rev 17515)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -17,8 +17,7 @@
</span><span class="cx">   public final static native void IVRMenu_execute(long jarg1, IVRMenu jarg1_, long jarg2, CoreSession jarg2_, String jarg3);
</span><span class="cx">   public final static native long new_API();
</span><span class="cx">   public final static native void delete_API(long jarg1);
</span><del>-  public final static native String API_execute__SWIG_0(long jarg1, API jarg1_, String jarg2, String jarg3);
-  public final static native String API_execute__SWIG_1(long jarg1, API jarg1_, String jarg2);
</del><ins>+  public final static native String API_execute(long jarg1, API jarg1_, String jarg2, String jarg3);
</ins><span class="cx">   public final static native String API_executeString(long jarg1, API jarg1_, String jarg2);
</span><span class="cx">   public final static native String API_getTime(long jarg1, API jarg1_);
</span><span class="cx">   public final static native void input_callback_state_t_function_set(long jarg1, input_callback_state_t jarg1_, long jarg2);
</span><span class="lines">@@ -38,8 +37,7 @@
</span><span class="cx">   public final static native char DTMF_digit_get(long jarg1, DTMF jarg1_);
</span><span class="cx">   public final static native void DTMF_duration_set(long jarg1, DTMF jarg1_, long jarg2);
</span><span class="cx">   public final static native long DTMF_duration_get(long jarg1, DTMF jarg1_);
</span><del>-  public final static native long new_DTMF__SWIG_0(char jarg1, long jarg2);
-  public final static native long new_DTMF__SWIG_1(char jarg1);
</del><ins>+  public final static native long new_DTMF(char jarg1, long jarg2);
</ins><span class="cx">   public final static native void delete_DTMF(long jarg1);
</span><span class="cx">   public final static native long new_Stream__SWIG_0();
</span><span class="cx">   public final static native long new_Stream__SWIG_1(long jarg1);
</span><span class="lines">@@ -53,14 +51,10 @@
</span><span class="cx">   public final static native void Event_mine_set(long jarg1, Event jarg1_, int jarg2);
</span><span class="cx">   public final static native int Event_mine_get(long jarg1, Event jarg1_);
</span><span class="cx">   public final static native long new_Event__SWIG_0(String jarg1, String jarg2);
</span><del>-  public final static native long new_Event__SWIG_1(String jarg1);
-  public final static native long new_Event__SWIG_2(long jarg1, int jarg2);
-  public final static native long new_Event__SWIG_3(long jarg1);
</del><ins>+  public final static native long new_Event__SWIG_1(long jarg1, int jarg2);
</ins><span class="cx">   public final static native void delete_Event(long jarg1);
</span><del>-  public final static native String Event_serialize__SWIG_0(long jarg1, Event jarg1_, String jarg2);
-  public final static native String Event_serialize__SWIG_1(long jarg1, Event jarg1_);
-  public final static native boolean Event_setPriority__SWIG_0(long jarg1, Event jarg1_, long jarg2);
-  public final static native boolean Event_setPriority__SWIG_1(long jarg1, Event jarg1_);
</del><ins>+  public final static native String Event_serialize(long jarg1, Event jarg1_, String jarg2);
+  public final static native boolean Event_setPriority(long jarg1, Event jarg1_, long jarg2);
</ins><span class="cx">   public final static native String Event_getHeader(long jarg1, Event jarg1_, String jarg2);
</span><span class="cx">   public final static native String Event_getBody(long jarg1, Event jarg1_);
</span><span class="cx">   public final static native String Event_getType(long jarg1, Event jarg1_);
</span><span class="lines">@@ -72,19 +66,16 @@
</span><span class="cx">   public final static native long EventConsumer_events_get(long jarg1, EventConsumer jarg1_);
</span><span class="cx">   public final static native void EventConsumer_e_event_id_set(long jarg1, EventConsumer jarg1_, long jarg2);
</span><span class="cx">   public final static native long EventConsumer_e_event_id_get(long jarg1, EventConsumer jarg1_);
</span><del>-  public final static native void EventConsumer_node_set(long jarg1, EventConsumer jarg1_, long jarg2);
-  public final static native long EventConsumer_node_get(long jarg1, EventConsumer jarg1_);
</del><span class="cx">   public final static native void EventConsumer_e_callback_set(long jarg1, EventConsumer jarg1_, String jarg2);
</span><span class="cx">   public final static native String EventConsumer_e_callback_get(long jarg1, EventConsumer jarg1_);
</span><span class="cx">   public final static native void EventConsumer_e_subclass_name_set(long jarg1, EventConsumer jarg1_, String jarg2);
</span><span class="cx">   public final static native String EventConsumer_e_subclass_name_get(long jarg1, EventConsumer jarg1_);
</span><span class="cx">   public final static native void EventConsumer_e_cb_arg_set(long jarg1, EventConsumer jarg1_, String jarg2);
</span><span class="cx">   public final static native String EventConsumer_e_cb_arg_get(long jarg1, EventConsumer jarg1_);
</span><del>-  public final static native long new_EventConsumer__SWIG_0(String jarg1, String jarg2);
-  public final static native long new_EventConsumer__SWIG_1(String jarg1);
</del><ins>+  public final static native long new_EventConsumer(String jarg1, String jarg2);
</ins><span class="cx">   public final static native void delete_EventConsumer(long jarg1);
</span><del>-  public final static native long EventConsumer_pop__SWIG_0(long jarg1, EventConsumer jarg1_, int jarg2);
-  public final static native long EventConsumer_pop__SWIG_1(long jarg1, EventConsumer jarg1_);
</del><ins>+  public final static native int EventConsumer_bind(long jarg1, EventConsumer jarg1_, String jarg2, String jarg3);
+  public final static native long EventConsumer_pop(long jarg1, EventConsumer jarg1_, int jarg2);
</ins><span class="cx">   public final static native void delete_CoreSession(long jarg1);
</span><span class="cx">   public final static native void CoreSession_session_set(long jarg1, CoreSession jarg1_, long jarg2);
</span><span class="cx">   public final static native long CoreSession_session_get(long jarg1, CoreSession jarg1_);
</span><span class="lines">@@ -108,28 +99,19 @@
</span><span class="cx">   public final static native String CoreSession_voice_name_get(long jarg1, CoreSession jarg1_);
</span><span class="cx">   public final static native int CoreSession_answer(long jarg1, CoreSession jarg1_);
</span><span class="cx">   public final static native int CoreSession_preAnswer(long jarg1, CoreSession jarg1_);
</span><del>-  public final static native void CoreSession_hangup__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2);
-  public final static native void CoreSession_hangup__SWIG_1(long jarg1, CoreSession jarg1_);
</del><ins>+  public final static native void CoreSession_hangup(long jarg1, CoreSession jarg1_, String jarg2);
</ins><span class="cx">   public final static native void CoreSession_hangupState(long jarg1, CoreSession jarg1_);
</span><span class="cx">   public final static native void CoreSession_setVariable(long jarg1, CoreSession jarg1_, String jarg2, String jarg3);
</span><span class="cx">   public final static native void CoreSession_setPrivate(long jarg1, CoreSession jarg1_, String jarg2, long jarg3);
</span><span class="cx">   public final static native long CoreSession_getPrivate(long jarg1, CoreSession jarg1_, String jarg2);
</span><span class="cx">   public final static native String CoreSession_getVariable(long jarg1, CoreSession jarg1_, String jarg2);
</span><span class="cx">   public final static native long CoreSession_process_callback_result(long jarg1, CoreSession jarg1_, String jarg2);
</span><del>-  public final static native void CoreSession_say__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2, String jarg3, String jarg4, String jarg5, String jarg6);
-  public final static native void CoreSession_say__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2, String jarg3, String jarg4, String jarg5);
-  public final static native void CoreSession_sayPhrase__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2, String jarg3, String jarg4);
-  public final static native void CoreSession_sayPhrase__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2, String jarg3);
-  public final static native void CoreSession_sayPhrase__SWIG_2(long jarg1, CoreSession jarg1_, String jarg2);
</del><ins>+  public final static native void CoreSession_say(long jarg1, CoreSession jarg1_, String jarg2, String jarg3, String jarg4, String jarg5, String jarg6);
+  public final static native void CoreSession_sayPhrase(long jarg1, CoreSession jarg1_, String jarg2, String jarg3, String jarg4);
</ins><span class="cx">   public final static native String CoreSession_hangupCause(long jarg1, CoreSession jarg1_);
</span><span class="cx">   public final static native String CoreSession_getState(long jarg1, CoreSession jarg1_);
</span><del>-  public final static native int CoreSession_recordFile__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2, int jarg3, int jarg4, int jarg5);
-  public final static native int CoreSession_recordFile__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2, int jarg3, int jarg4);
-  public final static native int CoreSession_recordFile__SWIG_2(long jarg1, CoreSession jarg1_, String jarg2, int jarg3);
-  public final static native int CoreSession_recordFile__SWIG_3(long jarg1, CoreSession jarg1_, String jarg2);
-  public final static native int CoreSession_originate__SWIG_0(long jarg1, CoreSession jarg1_, long jarg2, CoreSession jarg2_, String jarg3, int jarg4, long jarg5);
-  public final static native int CoreSession_originate__SWIG_1(long jarg1, CoreSession jarg1_, long jarg2, CoreSession jarg2_, String jarg3, int jarg4);
-  public final static native int CoreSession_originate__SWIG_2(long jarg1, CoreSession jarg1_, long jarg2, CoreSession jarg2_, String jarg3);
</del><ins>+  public final static native int CoreSession_recordFile(long jarg1, CoreSession jarg1_, String jarg2, int jarg3, int jarg4, int jarg5);
+  public final static native int CoreSession_originate(long jarg1, CoreSession jarg1_, long jarg2, CoreSession jarg2_, String jarg3, int jarg4, long jarg5);
</ins><span class="cx">   public final static native void CoreSession_destroy(long jarg1, CoreSession jarg1_);
</span><span class="cx">   public final static native void CoreSession_setDTMFCallback(long jarg1, CoreSession jarg1_, long jarg2, String jarg3);
</span><span class="cx">   public final static native int CoreSession_speak(long jarg1, CoreSession jarg1_, String jarg2);
</span><span class="lines">@@ -138,16 +120,11 @@
</span><span class="cx">   public final static native int CoreSession_collectDigits__SWIG_1(long jarg1, CoreSession jarg1_, int jarg2, int jarg3);
</span><span class="cx">   public final static native String CoreSession_getDigits__SWIG_0(long jarg1, CoreSession jarg1_, int jarg2, String jarg3, int jarg4);
</span><span class="cx">   public final static native String CoreSession_getDigits__SWIG_1(long jarg1, CoreSession jarg1_, int jarg2, String jarg3, int jarg4, int jarg5);
</span><del>-  public final static native int CoreSession_transfer__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2, String jarg3, String jarg4);
-  public final static native int CoreSession_transfer__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2, String jarg3);
-  public final static native int CoreSession_transfer__SWIG_2(long jarg1, CoreSession jarg1_, String jarg2);
</del><ins>+  public final static native int CoreSession_transfer(long jarg1, CoreSession jarg1_, String jarg2, String jarg3, String jarg4);
</ins><span class="cx">   public final static native String CoreSession_read(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, String jarg4, int jarg5, String jarg6);
</span><del>-  public final static native String CoreSession_playAndGetDigits__SWIG_0(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, String jarg9, String jarg10);
-  public final static native String CoreSession_playAndGetDigits__SWIG_1(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, String jarg9);
-  public final static native int CoreSession_streamFile__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2, int jarg3);
-  public final static native int CoreSession_streamFile__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2);
-  public final static native int CoreSession_sleep__SWIG_0(long jarg1, CoreSession jarg1_, int jarg2, int jarg3);
-  public final static native int CoreSession_sleep__SWIG_1(long jarg1, CoreSession jarg1_, int jarg2);
</del><ins>+  public final static native String CoreSession_playAndGetDigits(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, String jarg9, String jarg10);
+  public final static native int CoreSession_streamFile(long jarg1, CoreSession jarg1_, String jarg2, int jarg3);
+  public final static native int CoreSession_sleep(long jarg1, CoreSession jarg1_, int jarg2, int jarg3);
</ins><span class="cx">   public final static native int CoreSession_flushEvents(long jarg1, CoreSession jarg1_);
</span><span class="cx">   public final static native int CoreSession_flushDigits(long jarg1, CoreSession jarg1_);
</span><span class="cx">   public final static native int CoreSession_setAutoHangup(long jarg1, CoreSession jarg1_, boolean jarg2);
</span><span class="lines">@@ -157,8 +134,7 @@
</span><span class="cx">   public final static native boolean CoreSession_answered(long jarg1, CoreSession jarg1_);
</span><span class="cx">   public final static native boolean CoreSession_mediaReady(long jarg1, CoreSession jarg1_);
</span><span class="cx">   public final static native void CoreSession_waitForAnswer(long jarg1, CoreSession jarg1_, long jarg2, CoreSession jarg2_);
</span><del>-  public final static native void CoreSession_execute__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2, String jarg3);
-  public final static native void CoreSession_execute__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2);
</del><ins>+  public final static native void CoreSession_execute(long jarg1, CoreSession jarg1_, String jarg2, String jarg3);
</ins><span class="cx">   public final static native void CoreSession_sendEvent(long jarg1, CoreSession jarg1_, long jarg2, Event jarg2_);
</span><span class="cx">   public final static native void CoreSession_setEventData(long jarg1, CoreSession jarg1_, long jarg2, Event jarg2_);
</span><span class="cx">   public final static native String CoreSession_getXMLCDR(long jarg1, CoreSession jarg1_);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_javaswitch_swig_wrapcpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp (17515 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp        2010-05-10 17:03:22 UTC (rev 17515)
+++ freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -421,11 +421,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_API_1execute_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3) {
</del><ins>+SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_API_1execute(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3) {
</ins><span class="cx">   jstring jresult = 0 ;
</span><span class="cx">   API *arg1 = (API *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  char *arg3 = (char *) 0 ;
</del><ins>+  char *arg3 = (char *) NULL ;
</ins><span class="cx">   char *result = 0 ;
</span><span class="cx">   
</span><span class="cx">   (void)jenv;
</span><span class="lines">@@ -450,28 +450,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_API_1execute_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
-  jstring jresult = 0 ;
-  API *arg1 = (API *) 0 ;
-  char *arg2 = (char *) 0 ;
-  char *result = 0 ;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(API **)&amp;jarg1; 
-  arg2 = 0;
-  if (jarg2) {
-    arg2 = (char *)jenv-&gt;GetStringUTFChars(jarg2, 0);
-    if (!arg2) return 0;
-  }
-  result = (char *)(arg1)-&gt;execute((char const *)arg2);
-  if(result) jresult = jenv-&gt;NewStringUTF((const char *)result);
-  if (arg2) jenv-&gt;ReleaseStringUTFChars(jarg2, (const char *)arg2);
-  return jresult;
-}
-
-
</del><span class="cx"> SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_API_1executeString(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
</span><span class="cx">   jstring jresult = 0 ;
</span><span class="cx">   API *arg1 = (API *) 0 ;
</span><span class="lines">@@ -760,10 +738,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1DTMF_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jchar jarg1, jlong jarg2) {
</del><ins>+SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1DTMF(JNIEnv *jenv, jclass jcls, jchar jarg1, jlong jarg2) {
</ins><span class="cx">   jlong jresult = 0 ;
</span><span class="cx">   char arg1 ;
</span><del>-  uint32_t arg2 ;
</del><ins>+  uint32_t arg2 = (uint32_t) SWITCH_DEFAULT_DTMF_DURATION ;
</ins><span class="cx">   DTMF *result = 0 ;
</span><span class="cx">   uint32_t *argp2 ;
</span><span class="cx">   
</span><span class="lines">@@ -782,20 +760,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1DTMF_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jchar jarg1) {
-  jlong jresult = 0 ;
-  char arg1 ;
-  DTMF *result = 0 ;
-  
-  (void)jenv;
-  (void)jcls;
-  arg1 = (char)jarg1; 
-  result = (DTMF *)new DTMF(arg1);
-  *(DTMF **)&amp;jresult = result; 
-  return jresult;
-}
-
-
</del><span class="cx"> SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_delete_1DTMF(JNIEnv *jenv, jclass jcls, jlong jarg1) {
</span><span class="cx">   DTMF *arg1 = (DTMF *) 0 ;
</span><span class="cx">   
</span><span class="lines">@@ -979,7 +943,7 @@
</span><span class="cx"> SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1Event_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2) {
</span><span class="cx">   jlong jresult = 0 ;
</span><span class="cx">   char *arg1 = (char *) 0 ;
</span><del>-  char *arg2 = (char *) 0 ;
</del><ins>+  char *arg2 = (char *) NULL ;
</ins><span class="cx">   Event *result = 0 ;
</span><span class="cx">   
</span><span class="cx">   (void)jenv;
</span><span class="lines">@@ -1002,29 +966,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1Event_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jstring jarg1) {
</del><ins>+SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1Event_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) {
</ins><span class="cx">   jlong jresult = 0 ;
</span><del>-  char *arg1 = (char *) 0 ;
-  Event *result = 0 ;
-  
-  (void)jenv;
-  (void)jcls;
-  arg1 = 0;
-  if (jarg1) {
-    arg1 = (char *)jenv-&gt;GetStringUTFChars(jarg1, 0);
-    if (!arg1) return 0;
-  }
-  result = (Event *)new Event((char const *)arg1);
-  *(Event **)&amp;jresult = result; 
-  if (arg1) jenv-&gt;ReleaseStringUTFChars(jarg1, (const char *)arg1);
-  return jresult;
-}
-
-
-SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1Event_1_1SWIG_12(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) {
-  jlong jresult = 0 ;
</del><span class="cx">   switch_event_t *arg1 = (switch_event_t *) 0 ;
</span><del>-  int arg2 ;
</del><ins>+  int arg2 = (int) 0 ;
</ins><span class="cx">   Event *result = 0 ;
</span><span class="cx">   
</span><span class="cx">   (void)jenv;
</span><span class="lines">@@ -1037,20 +982,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1Event_1_1SWIG_13(JNIEnv *jenv, jclass jcls, jlong jarg1) {
-  jlong jresult = 0 ;
-  switch_event_t *arg1 = (switch_event_t *) 0 ;
-  Event *result = 0 ;
-  
-  (void)jenv;
-  (void)jcls;
-  arg1 = *(switch_event_t **)&amp;jarg1; 
-  result = (Event *)new Event(arg1);
-  *(Event **)&amp;jresult = result; 
-  return jresult;
-}
-
-
</del><span class="cx"> SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_delete_1Event(JNIEnv *jenv, jclass jcls, jlong jarg1) {
</span><span class="cx">   Event *arg1 = (Event *) 0 ;
</span><span class="cx">   
</span><span class="lines">@@ -1062,10 +993,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_Event_1serialize_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
</del><ins>+SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_Event_1serialize(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
</ins><span class="cx">   jstring jresult = 0 ;
</span><span class="cx">   Event *arg1 = (Event *) 0 ;
</span><del>-  char *arg2 = (char *) 0 ;
</del><ins>+  char *arg2 = (char *) NULL ;
</ins><span class="cx">   char *result = 0 ;
</span><span class="cx">   
</span><span class="cx">   (void)jenv;
</span><span class="lines">@@ -1084,25 +1015,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_Event_1serialize_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
-  jstring jresult = 0 ;
-  Event *arg1 = (Event *) 0 ;
-  char *result = 0 ;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(Event **)&amp;jarg1; 
-  result = (char *)(arg1)-&gt;serialize();
-  if(result) jresult = jenv-&gt;NewStringUTF((const char *)result);
-  return jresult;
-}
-
-
-SWIGEXPORT jboolean JNICALL Java_org_freeswitch_swig_freeswitchJNI_Event_1setPriority_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) {
</del><ins>+SWIGEXPORT jboolean JNICALL Java_org_freeswitch_swig_freeswitchJNI_Event_1setPriority(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) {
</ins><span class="cx">   jboolean jresult = 0 ;
</span><span class="cx">   Event *arg1 = (Event *) 0 ;
</span><del>-  switch_priority_t arg2 ;
</del><ins>+  switch_priority_t arg2 = (switch_priority_t) SWITCH_PRIORITY_NORMAL ;
</ins><span class="cx">   bool result;
</span><span class="cx">   switch_priority_t *argp2 ;
</span><span class="cx">   
</span><span class="lines">@@ -1122,21 +1038,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jboolean JNICALL Java_org_freeswitch_swig_freeswitchJNI_Event_1setPriority_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
-  jboolean jresult = 0 ;
-  Event *arg1 = (Event *) 0 ;
-  bool result;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(Event **)&amp;jarg1; 
-  result = (bool)(arg1)-&gt;setPriority();
-  jresult = (jboolean)result; 
-  return jresult;
-}
-
-
</del><span class="cx"> SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_Event_1getHeader(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
</span><span class="cx">   jstring jresult = 0 ;
</span><span class="cx">   Event *arg1 = (Event *) 0 ;
</span><span class="lines">@@ -1341,35 +1242,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_EventConsumer_1node_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) {
-  EventConsumer *arg1 = (EventConsumer *) 0 ;
-  switch_event_node_t *arg2 = (switch_event_node_t *) 0 ;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(EventConsumer **)&amp;jarg1; 
-  arg2 = *(switch_event_node_t **)&amp;jarg2; 
-  if (arg1) (arg1)-&gt;node = arg2;
-  
-}
-
-
-SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_EventConsumer_1node_1get(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
-  jlong jresult = 0 ;
-  EventConsumer *arg1 = (EventConsumer *) 0 ;
-  switch_event_node_t *result = 0 ;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(EventConsumer **)&amp;jarg1; 
-  result = (switch_event_node_t *) ((arg1)-&gt;node);
-  *(switch_event_node_t **)&amp;jresult = result; 
-  return jresult;
-}
-
-
</del><span class="cx"> SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_EventConsumer_1e_1callback_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
</span><span class="cx">   EventConsumer *arg1 = (EventConsumer *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><span class="lines">@@ -1493,10 +1365,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1EventConsumer_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2) {
</del><ins>+SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1EventConsumer(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2) {
</ins><span class="cx">   jlong jresult = 0 ;
</span><del>-  char *arg1 = (char *) 0 ;
-  char *arg2 = (char *) 0 ;
</del><ins>+  char *arg1 = (char *) NULL ;
+  char *arg2 = (char *) &quot;&quot; ;
</ins><span class="cx">   EventConsumer *result = 0 ;
</span><span class="cx">   
</span><span class="cx">   (void)jenv;
</span><span class="lines">@@ -1519,25 +1391,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1EventConsumer_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jstring jarg1) {
-  jlong jresult = 0 ;
-  char *arg1 = (char *) 0 ;
-  EventConsumer *result = 0 ;
-  
-  (void)jenv;
-  (void)jcls;
-  arg1 = 0;
-  if (jarg1) {
-    arg1 = (char *)jenv-&gt;GetStringUTFChars(jarg1, 0);
-    if (!arg1) return 0;
-  }
-  result = (EventConsumer *)new EventConsumer((char const *)arg1);
-  *(EventConsumer **)&amp;jresult = result; 
-  if (arg1) jenv-&gt;ReleaseStringUTFChars(jarg1, (const char *)arg1);
-  return jresult;
-}
-
-
</del><span class="cx"> SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_delete_1EventConsumer(JNIEnv *jenv, jclass jcls, jlong jarg1) {
</span><span class="cx">   EventConsumer *arg1 = (EventConsumer *) 0 ;
</span><span class="cx">   
</span><span class="lines">@@ -1549,33 +1402,47 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_EventConsumer_1pop_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) {
-  jlong jresult = 0 ;
</del><ins>+SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_EventConsumer_1bind(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3) {
+  jint jresult = 0 ;
</ins><span class="cx">   EventConsumer *arg1 = (EventConsumer *) 0 ;
</span><del>-  int arg2 ;
-  Event *result = 0 ;
</del><ins>+  char *arg2 = (char *) 0 ;
+  char *arg3 = (char *) &quot;&quot; ;
+  int result;
</ins><span class="cx">   
</span><span class="cx">   (void)jenv;
</span><span class="cx">   (void)jcls;
</span><span class="cx">   (void)jarg1_;
</span><span class="cx">   arg1 = *(EventConsumer **)&amp;jarg1; 
</span><del>-  arg2 = (int)jarg2; 
-  result = (Event *)(arg1)-&gt;pop(arg2);
-  *(Event **)&amp;jresult = result; 
</del><ins>+  arg2 = 0;
+  if (jarg2) {
+    arg2 = (char *)jenv-&gt;GetStringUTFChars(jarg2, 0);
+    if (!arg2) return 0;
+  }
+  arg3 = 0;
+  if (jarg3) {
+    arg3 = (char *)jenv-&gt;GetStringUTFChars(jarg3, 0);
+    if (!arg3) return 0;
+  }
+  result = (int)(arg1)-&gt;bind((char const *)arg2,(char const *)arg3);
+  jresult = (jint)result; 
+  if (arg2) jenv-&gt;ReleaseStringUTFChars(jarg2, (const char *)arg2);
+  if (arg3) jenv-&gt;ReleaseStringUTFChars(jarg3, (const char *)arg3);
</ins><span class="cx">   return jresult;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_EventConsumer_1pop_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
</del><ins>+SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_EventConsumer_1pop(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) {
</ins><span class="cx">   jlong jresult = 0 ;
</span><span class="cx">   EventConsumer *arg1 = (EventConsumer *) 0 ;
</span><ins>+  int arg2 = (int) 0 ;
</ins><span class="cx">   Event *result = 0 ;
</span><span class="cx">   
</span><span class="cx">   (void)jenv;
</span><span class="cx">   (void)jcls;
</span><span class="cx">   (void)jarg1_;
</span><span class="cx">   arg1 = *(EventConsumer **)&amp;jarg1; 
</span><del>-  result = (Event *)(arg1)-&gt;pop();
</del><ins>+  arg2 = (int)jarg2; 
+  result = (Event *)(arg1)-&gt;pop(arg2);
</ins><span class="cx">   *(Event **)&amp;jresult = result; 
</span><span class="cx">   return jresult;
</span><span class="cx"> }
</span><span class="lines">@@ -1961,9 +1828,9 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1hangup_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
</del><ins>+SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1hangup(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
</ins><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><del>-  char *arg2 = (char *) 0 ;
</del><ins>+  char *arg2 = (char *) &quot;normal_clearing&quot; ;
</ins><span class="cx">   
</span><span class="cx">   (void)jenv;
</span><span class="cx">   (void)jcls;
</span><span class="lines">@@ -1979,17 +1846,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1hangup_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(CoreSession **)&amp;jarg1; 
-  (arg1)-&gt;hangup();
-}
-
-
</del><span class="cx"> SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1hangupState(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   
</span><span class="lines">@@ -2112,13 +1968,13 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1say_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3, jstring jarg4, jstring jarg5, jstring jarg6) {
</del><ins>+SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1say(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3, jstring jarg4, jstring jarg5, jstring jarg6) {
</ins><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><span class="cx">   char *arg3 = (char *) 0 ;
</span><span class="cx">   char *arg4 = (char *) 0 ;
</span><span class="cx">   char *arg5 = (char *) 0 ;
</span><del>-  char *arg6 = (char *) 0 ;
</del><ins>+  char *arg6 = (char *) NULL ;
</ins><span class="cx">   
</span><span class="cx">   (void)jenv;
</span><span class="cx">   (void)jcls;
</span><span class="lines">@@ -2158,12 +2014,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1say_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3, jstring jarg4, jstring jarg5) {
</del><ins>+SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1sayPhrase(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3, jstring jarg4) {
</ins><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  char *arg3 = (char *) 0 ;
-  char *arg4 = (char *) 0 ;
-  char *arg5 = (char *) 0 ;
</del><ins>+  char *arg3 = (char *) &quot;&quot; ;
+  char *arg4 = (char *) NULL ;
</ins><span class="cx">   
</span><span class="cx">   (void)jenv;
</span><span class="cx">   (void)jcls;
</span><span class="lines">@@ -2184,44 +2039,6 @@
</span><span class="cx">     arg4 = (char *)jenv-&gt;GetStringUTFChars(jarg4, 0);
</span><span class="cx">     if (!arg4) return ;
</span><span class="cx">   }
</span><del>-  arg5 = 0;
-  if (jarg5) {
-    arg5 = (char *)jenv-&gt;GetStringUTFChars(jarg5, 0);
-    if (!arg5) return ;
-  }
-  (arg1)-&gt;say((char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5);
-  if (arg2) jenv-&gt;ReleaseStringUTFChars(jarg2, (const char *)arg2);
-  if (arg3) jenv-&gt;ReleaseStringUTFChars(jarg3, (const char *)arg3);
-  if (arg4) jenv-&gt;ReleaseStringUTFChars(jarg4, (const char *)arg4);
-  if (arg5) jenv-&gt;ReleaseStringUTFChars(jarg5, (const char *)arg5);
-}
-
-
-SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1sayPhrase_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3, jstring jarg4) {
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  char *arg3 = (char *) 0 ;
-  char *arg4 = (char *) 0 ;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(CoreSession **)&amp;jarg1; 
-  arg2 = 0;
-  if (jarg2) {
-    arg2 = (char *)jenv-&gt;GetStringUTFChars(jarg2, 0);
-    if (!arg2) return ;
-  }
-  arg3 = 0;
-  if (jarg3) {
-    arg3 = (char *)jenv-&gt;GetStringUTFChars(jarg3, 0);
-    if (!arg3) return ;
-  }
-  arg4 = 0;
-  if (jarg4) {
-    arg4 = (char *)jenv-&gt;GetStringUTFChars(jarg4, 0);
-    if (!arg4) return ;
-  }
</del><span class="cx">   (arg1)-&gt;sayPhrase((char const *)arg2,(char const *)arg3,(char const *)arg4);
</span><span class="cx">   if (arg2) jenv-&gt;ReleaseStringUTFChars(jarg2, (const char *)arg2);
</span><span class="cx">   if (arg3) jenv-&gt;ReleaseStringUTFChars(jarg3, (const char *)arg3);
</span><span class="lines">@@ -2229,49 +2046,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1sayPhrase_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3) {
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  char *arg3 = (char *) 0 ;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(CoreSession **)&amp;jarg1; 
-  arg2 = 0;
-  if (jarg2) {
-    arg2 = (char *)jenv-&gt;GetStringUTFChars(jarg2, 0);
-    if (!arg2) return ;
-  }
-  arg3 = 0;
-  if (jarg3) {
-    arg3 = (char *)jenv-&gt;GetStringUTFChars(jarg3, 0);
-    if (!arg3) return ;
-  }
-  (arg1)-&gt;sayPhrase((char const *)arg2,(char const *)arg3);
-  if (arg2) jenv-&gt;ReleaseStringUTFChars(jarg2, (const char *)arg2);
-  if (arg3) jenv-&gt;ReleaseStringUTFChars(jarg3, (const char *)arg3);
-}
-
-
-SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1sayPhrase_1_1SWIG_12(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(CoreSession **)&amp;jarg1; 
-  arg2 = 0;
-  if (jarg2) {
-    arg2 = (char *)jenv-&gt;GetStringUTFChars(jarg2, 0);
-    if (!arg2) return ;
-  }
-  (arg1)-&gt;sayPhrase((char const *)arg2);
-  if (arg2) jenv-&gt;ReleaseStringUTFChars(jarg2, (const char *)arg2);
-}
-
-
</del><span class="cx"> SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1hangupCause(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
</span><span class="cx">   jstring jresult = 0 ;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -2302,13 +2076,13 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1recordFile_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jint jarg3, jint jarg4, jint jarg5) {
</del><ins>+SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1recordFile(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jint jarg3, jint jarg4, jint jarg5) {
</ins><span class="cx">   jint jresult = 0 ;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  int arg3 ;
-  int arg4 ;
-  int arg5 ;
</del><ins>+  int arg3 = (int) 0 ;
+  int arg4 = (int) 0 ;
+  int arg5 = (int) 0 ;
</ins><span class="cx">   int result;
</span><span class="cx">   
</span><span class="cx">   (void)jenv;
</span><span class="lines">@@ -2330,85 +2104,13 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1recordFile_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jint jarg3, jint jarg4) {
</del><ins>+SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1originate(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jstring jarg3, jint jarg4, jlong jarg5) {
</ins><span class="cx">   jint jresult = 0 ;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><del>-  char *arg2 = (char *) 0 ;
-  int arg3 ;
-  int arg4 ;
-  int result;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(CoreSession **)&amp;jarg1; 
-  arg2 = 0;
-  if (jarg2) {
-    arg2 = (char *)jenv-&gt;GetStringUTFChars(jarg2, 0);
-    if (!arg2) return 0;
-  }
-  arg3 = (int)jarg3; 
-  arg4 = (int)jarg4; 
-  result = (int)(arg1)-&gt;recordFile(arg2,arg3,arg4);
-  jresult = (jint)result; 
-  if (arg2) jenv-&gt;ReleaseStringUTFChars(jarg2, (const char *)arg2);
-  return jresult;
-}
-
-
-SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1recordFile_1_1SWIG_12(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jint jarg3) {
-  jint jresult = 0 ;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  int arg3 ;
-  int result;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(CoreSession **)&amp;jarg1; 
-  arg2 = 0;
-  if (jarg2) {
-    arg2 = (char *)jenv-&gt;GetStringUTFChars(jarg2, 0);
-    if (!arg2) return 0;
-  }
-  arg3 = (int)jarg3; 
-  result = (int)(arg1)-&gt;recordFile(arg2,arg3);
-  jresult = (jint)result; 
-  if (arg2) jenv-&gt;ReleaseStringUTFChars(jarg2, (const char *)arg2);
-  return jresult;
-}
-
-
-SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1recordFile_1_1SWIG_13(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
-  jint jresult = 0 ;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  int result;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(CoreSession **)&amp;jarg1; 
-  arg2 = 0;
-  if (jarg2) {
-    arg2 = (char *)jenv-&gt;GetStringUTFChars(jarg2, 0);
-    if (!arg2) return 0;
-  }
-  result = (int)(arg1)-&gt;recordFile(arg2);
-  jresult = (jint)result; 
-  if (arg2) jenv-&gt;ReleaseStringUTFChars(jarg2, (const char *)arg2);
-  return jresult;
-}
-
-
-SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1originate_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jstring jarg3, jint jarg4, jlong jarg5) {
-  jint jresult = 0 ;
-  CoreSession *arg1 = (CoreSession *) 0 ;
</del><span class="cx">   CoreSession *arg2 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg3 = (char *) 0 ;
</span><del>-  int arg4 ;
-  switch_state_handler_table_t *arg5 = (switch_state_handler_table_t *) 0 ;
</del><ins>+  int arg4 = (int) 60 ;
+  switch_state_handler_table_t *arg5 = (switch_state_handler_table_t *) NULL ;
</ins><span class="cx">   int result;
</span><span class="cx">   
</span><span class="cx">   (void)jenv;
</span><span class="lines">@@ -2431,58 +2133,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1originate_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jstring jarg3, jint jarg4) {
-  jint jresult = 0 ;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  CoreSession *arg2 = (CoreSession *) 0 ;
-  char *arg3 = (char *) 0 ;
-  int arg4 ;
-  int result;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  (void)jarg2_;
-  arg1 = *(CoreSession **)&amp;jarg1; 
-  arg2 = *(CoreSession **)&amp;jarg2; 
-  arg3 = 0;
-  if (jarg3) {
-    arg3 = (char *)jenv-&gt;GetStringUTFChars(jarg3, 0);
-    if (!arg3) return 0;
-  }
-  arg4 = (int)jarg4; 
-  result = (int)(arg1)-&gt;originate(arg2,arg3,arg4);
-  jresult = (jint)result; 
-  if (arg3) jenv-&gt;ReleaseStringUTFChars(jarg3, (const char *)arg3);
-  return jresult;
-}
-
-
-SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1originate_1_1SWIG_12(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jstring jarg3) {
-  jint jresult = 0 ;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  CoreSession *arg2 = (CoreSession *) 0 ;
-  char *arg3 = (char *) 0 ;
-  int result;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  (void)jarg2_;
-  arg1 = *(CoreSession **)&amp;jarg1; 
-  arg2 = *(CoreSession **)&amp;jarg2; 
-  arg3 = 0;
-  if (jarg3) {
-    arg3 = (char *)jenv-&gt;GetStringUTFChars(jarg3, 0);
-    if (!arg3) return 0;
-  }
-  result = (int)(arg1)-&gt;originate(arg2,arg3);
-  jresult = (jint)result; 
-  if (arg3) jenv-&gt;ReleaseStringUTFChars(jarg3, (const char *)arg3);
-  return jresult;
-}
-
-
</del><span class="cx"> SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1destroy(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   
</span><span class="lines">@@ -2651,12 +2301,12 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1transfer_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3, jstring jarg4) {
</del><ins>+SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1transfer(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3, jstring jarg4) {
</ins><span class="cx">   jint jresult = 0 ;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  char *arg3 = (char *) 0 ;
-  char *arg4 = (char *) 0 ;
</del><ins>+  char *arg3 = (char *) NULL ;
+  char *arg4 = (char *) NULL ;
</ins><span class="cx">   int result;
</span><span class="cx">   
</span><span class="cx">   (void)jenv;
</span><span class="lines">@@ -2687,57 +2337,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1transfer_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3) {
-  jint jresult = 0 ;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  char *arg3 = (char *) 0 ;
-  int result;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(CoreSession **)&amp;jarg1; 
-  arg2 = 0;
-  if (jarg2) {
-    arg2 = (char *)jenv-&gt;GetStringUTFChars(jarg2, 0);
-    if (!arg2) return 0;
-  }
-  arg3 = 0;
-  if (jarg3) {
-    arg3 = (char *)jenv-&gt;GetStringUTFChars(jarg3, 0);
-    if (!arg3) return 0;
-  }
-  result = (int)(arg1)-&gt;transfer(arg2,arg3);
-  jresult = (jint)result; 
-  if (arg2) jenv-&gt;ReleaseStringUTFChars(jarg2, (const char *)arg2);
-  if (arg3) jenv-&gt;ReleaseStringUTFChars(jarg3, (const char *)arg3);
-  return jresult;
-}
-
-
-SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1transfer_1_1SWIG_12(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
-  jint jresult = 0 ;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  int result;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(CoreSession **)&amp;jarg1; 
-  arg2 = 0;
-  if (jarg2) {
-    arg2 = (char *)jenv-&gt;GetStringUTFChars(jarg2, 0);
-    if (!arg2) return 0;
-  }
-  result = (int)(arg1)-&gt;transfer(arg2);
-  jresult = (jint)result; 
-  if (arg2) jenv-&gt;ReleaseStringUTFChars(jarg2, (const char *)arg2);
-  return jresult;
-}
-
-
</del><span class="cx"> SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1read(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3, jstring jarg4, jint jarg5, jstring jarg6) {
</span><span class="cx">   jstring jresult = 0 ;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -2773,7 +2372,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1playAndGetDigits_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jstring jarg6, jstring jarg7, jstring jarg8, jstring jarg9, jstring jarg10) {
</del><ins>+SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1playAndGetDigits(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jstring jarg6, jstring jarg7, jstring jarg8, jstring jarg9, jstring jarg10) {
</ins><span class="cx">   jstring jresult = 0 ;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   int arg2 ;
</span><span class="lines">@@ -2784,7 +2383,7 @@
</span><span class="cx">   char *arg7 = (char *) 0 ;
</span><span class="cx">   char *arg8 = (char *) 0 ;
</span><span class="cx">   char *arg9 = (char *) 0 ;
</span><del>-  char *arg10 = (char *) 0 ;
</del><ins>+  char *arg10 = (char *) NULL ;
</ins><span class="cx">   char *result = 0 ;
</span><span class="cx">   
</span><span class="cx">   (void)jenv;
</span><span class="lines">@@ -2831,62 +2430,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1playAndGetDigits_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jstring jarg6, jstring jarg7, jstring jarg8, jstring jarg9) {
-  jstring jresult = 0 ;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  int arg2 ;
-  int arg3 ;
-  int arg4 ;
-  int arg5 ;
-  char *arg6 = (char *) 0 ;
-  char *arg7 = (char *) 0 ;
-  char *arg8 = (char *) 0 ;
-  char *arg9 = (char *) 0 ;
-  char *result = 0 ;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(CoreSession **)&amp;jarg1; 
-  arg2 = (int)jarg2; 
-  arg3 = (int)jarg3; 
-  arg4 = (int)jarg4; 
-  arg5 = (int)jarg5; 
-  arg6 = 0;
-  if (jarg6) {
-    arg6 = (char *)jenv-&gt;GetStringUTFChars(jarg6, 0);
-    if (!arg6) return 0;
-  }
-  arg7 = 0;
-  if (jarg7) {
-    arg7 = (char *)jenv-&gt;GetStringUTFChars(jarg7, 0);
-    if (!arg7) return 0;
-  }
-  arg8 = 0;
-  if (jarg8) {
-    arg8 = (char *)jenv-&gt;GetStringUTFChars(jarg8, 0);
-    if (!arg8) return 0;
-  }
-  arg9 = 0;
-  if (jarg9) {
-    arg9 = (char *)jenv-&gt;GetStringUTFChars(jarg9, 0);
-    if (!arg9) return 0;
-  }
-  result = (char *)(arg1)-&gt;playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
-  if(result) jresult = jenv-&gt;NewStringUTF((const char *)result);
-  if (arg6) jenv-&gt;ReleaseStringUTFChars(jarg6, (const char *)arg6);
-  if (arg7) jenv-&gt;ReleaseStringUTFChars(jarg7, (const char *)arg7);
-  if (arg8) jenv-&gt;ReleaseStringUTFChars(jarg8, (const char *)arg8);
-  if (arg9) jenv-&gt;ReleaseStringUTFChars(jarg9, (const char *)arg9);
-  return jresult;
-}
-
-
-SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1streamFile_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jint jarg3) {
</del><ins>+SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1streamFile(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jint jarg3) {
</ins><span class="cx">   jint jresult = 0 ;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  int arg3 ;
</del><ins>+  int arg3 = (int) 0 ;
</ins><span class="cx">   int result;
</span><span class="cx">   
</span><span class="cx">   (void)jenv;
</span><span class="lines">@@ -2906,33 +2454,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1streamFile_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
</del><ins>+SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1sleep(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3) {
</ins><span class="cx">   jint jresult = 0 ;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><del>-  char *arg2 = (char *) 0 ;
-  int result;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(CoreSession **)&amp;jarg1; 
-  arg2 = 0;
-  if (jarg2) {
-    arg2 = (char *)jenv-&gt;GetStringUTFChars(jarg2, 0);
-    if (!arg2) return 0;
-  }
-  result = (int)(arg1)-&gt;streamFile(arg2);
-  jresult = (jint)result; 
-  if (arg2) jenv-&gt;ReleaseStringUTFChars(jarg2, (const char *)arg2);
-  return jresult;
-}
-
-
-SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1sleep_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3) {
-  jint jresult = 0 ;
-  CoreSession *arg1 = (CoreSession *) 0 ;
</del><span class="cx">   int arg2 ;
</span><del>-  int arg3 ;
</del><ins>+  int arg3 = (int) 0 ;
</ins><span class="cx">   int result;
</span><span class="cx">   
</span><span class="cx">   (void)jenv;
</span><span class="lines">@@ -2947,23 +2473,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1sleep_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) {
-  jint jresult = 0 ;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  int arg2 ;
-  int result;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(CoreSession **)&amp;jarg1; 
-  arg2 = (int)jarg2; 
-  result = (int)(arg1)-&gt;sleep(arg2);
-  jresult = (jint)result; 
-  return jresult;
-}
-
-
</del><span class="cx"> SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1flushEvents(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
</span><span class="cx">   jint jresult = 0 ;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -3098,10 +2607,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1execute_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3) {
</del><ins>+SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1execute(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3) {
</ins><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  char *arg3 = (char *) 0 ;
</del><ins>+  char *arg3 = (char *) NULL ;
</ins><span class="cx">   
</span><span class="cx">   (void)jenv;
</span><span class="cx">   (void)jcls;
</span><span class="lines">@@ -3123,24 +2632,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1execute_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  
-  (void)jenv;
-  (void)jcls;
-  (void)jarg1_;
-  arg1 = *(CoreSession **)&amp;jarg1; 
-  arg2 = 0;
-  if (jarg2) {
-    arg2 = (char *)jenv-&gt;GetStringUTFChars(jarg2, 0);
-    if (!arg2) return ;
-  }
-  (arg1)-&gt;execute((char const *)arg2);
-  if (arg2) jenv-&gt;ReleaseStringUTFChars(jarg2, (const char *)arg2);
-}
-
-
</del><span class="cx"> SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1sendEvent(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_) {
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   Event *arg2 = (Event *) 0 ;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_luamod_lua_wrapcpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp (17515 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp        2010-05-10 17:03:22 UTC (rev 17515)
+++ freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -1499,20 +1499,19 @@
</span><span class="cx"> #define SWIGTYPE_p_switch_channel_state_t swig_types[12]
</span><span class="cx"> #define SWIGTYPE_p_switch_channel_t swig_types[13]
</span><span class="cx"> #define SWIGTYPE_p_switch_core_session_t swig_types[14]
</span><del>-#define SWIGTYPE_p_switch_event_node_t swig_types[15]
-#define SWIGTYPE_p_switch_event_t swig_types[16]
-#define SWIGTYPE_p_switch_event_types_t swig_types[17]
-#define SWIGTYPE_p_switch_input_args_t swig_types[18]
-#define SWIGTYPE_p_switch_input_type_t swig_types[19]
-#define SWIGTYPE_p_switch_priority_t swig_types[20]
-#define SWIGTYPE_p_switch_queue_t swig_types[21]
-#define SWIGTYPE_p_switch_state_handler_table_t swig_types[22]
-#define SWIGTYPE_p_switch_status_t swig_types[23]
-#define SWIGTYPE_p_switch_stream_handle_t swig_types[24]
-#define SWIGTYPE_p_uint32_t swig_types[25]
-#define SWIGTYPE_p_void swig_types[26]
-static swig_type_info *swig_types[28];
-static swig_module_info swig_module = {swig_types, 27, 0, 0, 0, 0};
</del><ins>+#define SWIGTYPE_p_switch_event_t swig_types[15]
+#define SWIGTYPE_p_switch_event_types_t swig_types[16]
+#define SWIGTYPE_p_switch_input_args_t swig_types[17]
+#define SWIGTYPE_p_switch_input_type_t swig_types[18]
+#define SWIGTYPE_p_switch_priority_t swig_types[19]
+#define SWIGTYPE_p_switch_queue_t swig_types[20]
+#define SWIGTYPE_p_switch_state_handler_table_t swig_types[21]
+#define SWIGTYPE_p_switch_status_t swig_types[22]
+#define SWIGTYPE_p_switch_stream_handle_t swig_types[23]
+#define SWIGTYPE_p_uint32_t swig_types[24]
+#define SWIGTYPE_p_void swig_types[25]
+static swig_type_info *swig_types[27];
+static swig_module_info swig_module = {swig_types, 26, 0, 0, 0, 0};
</ins><span class="cx"> #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&amp;swig_module, &amp;swig_module, name)
</span><span class="cx"> #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&amp;swig_module, &amp;swig_module, name)
</span><span class="cx"> 
</span><span class="lines">@@ -1801,24 +1800,26 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_API_execute__SWIG_0(lua_State* L) {
</del><ins>+static int _wrap_API_execute(lua_State* L) {
</ins><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   API *arg1 = (API *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  char *arg3 = (char *) 0 ;
</del><ins>+  char *arg3 = (char *) NULL ;
</ins><span class="cx">   char *result = 0 ;
</span><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;execute&quot;,3,3)
</del><ins>+  SWIG_check_num_args(&quot;execute&quot;,2,3)
</ins><span class="cx">   if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;execute&quot;,1,&quot;API *&quot;);
</span><span class="cx">   if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;execute&quot;,2,&quot;char const *&quot;);
</span><del>-  if(!lua_isstring(L,3)) SWIG_fail_arg(&quot;execute&quot;,3,&quot;char const *&quot;);
</del><ins>+  if(lua_gettop(L)&gt;=3 &amp;&amp; !lua_isstring(L,3)) SWIG_fail_arg(&quot;execute&quot;,3,&quot;char const *&quot;);
</ins><span class="cx">   
</span><span class="cx">   if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_API,0))){
</span><span class="cx">     SWIG_fail_ptr(&quot;API_execute&quot;,1,SWIGTYPE_p_API);
</span><span class="cx">   }
</span><span class="cx">   
</span><span class="cx">   arg2 = (char *)lua_tostring(L, 2);
</span><del>-  arg3 = (char *)lua_tostring(L, 3);
</del><ins>+  if(lua_gettop(L)&gt;=3){
+    arg3 = (char *)lua_tostring(L, 3);
+  }
</ins><span class="cx">   result = (char *)(arg1)-&gt;execute((char const *)arg2,(char const *)arg3);
</span><span class="cx">   SWIG_arg=0;
</span><span class="cx">   lua_pushstring(L,(const char*)result); SWIG_arg++;
</span><span class="lines">@@ -1832,90 +1833,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_API_execute__SWIG_1(lua_State* L) {
-  int SWIG_arg = -1;
-  API *arg1 = (API *) 0 ;
-  char *arg2 = (char *) 0 ;
-  char *result = 0 ;
-  
-  SWIG_check_num_args(&quot;execute&quot;,2,2)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;execute&quot;,1,&quot;API *&quot;);
-  if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;execute&quot;,2,&quot;char const *&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_API,0))){
-    SWIG_fail_ptr(&quot;API_execute&quot;,1,SWIGTYPE_p_API);
-  }
-  
-  arg2 = (char *)lua_tostring(L, 2);
-  result = (char *)(arg1)-&gt;execute((char const *)arg2);
-  SWIG_arg=0;
-  lua_pushstring(L,(const char*)result); SWIG_arg++;
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_API_execute(lua_State* L) {
-  int argc;
-  int argv[4]={
-    1,2,3,4
-  };
-  
-  argc = lua_gettop(L);
-  if (argc == 2) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_API, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        return _wrap_API_execute__SWIG_1(L);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_API, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        {
-          _v = lua_isstring(L,argv[2]);
-        }
-        if (_v) {
-          return _wrap_API_execute__SWIG_0(L);
-        }
-      }
-    }
-  }
-  
-  lua_pushstring(L,&quot;No matching function for overloaded 'API_execute'&quot;);
-  lua_error(L);return 0;
-}
-
-
</del><span class="cx"> static int _wrap_API_executeString(lua_State* L) {
</span><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   API *arg1 = (API *) 0 ;
</span><span class="lines">@@ -2381,23 +2298,23 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_new_DTMF__SWIG_0(lua_State* L) {
</del><ins>+static int _wrap_new_DTMF(lua_State* L) {
</ins><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   char arg1 ;
</span><del>-  uint32_t arg2 ;
</del><ins>+  uint32_t arg2 = (uint32_t) SWITCH_DEFAULT_DTMF_DURATION ;
</ins><span class="cx">   DTMF *result = 0 ;
</span><span class="cx">   uint32_t *argp2 ;
</span><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;DTMF&quot;,2,2)
</del><ins>+  SWIG_check_num_args(&quot;DTMF&quot;,1,2)
</ins><span class="cx">   if(!lua_isstring(L,1)) SWIG_fail_arg(&quot;DTMF&quot;,1,&quot;char&quot;);
</span><del>-  if(!lua_isuserdata(L,2)) SWIG_fail_arg(&quot;DTMF&quot;,2,&quot;uint32_t&quot;);
</del><ins>+  if(lua_gettop(L)&gt;=2 &amp;&amp; !lua_isuserdata(L,2)) SWIG_fail_arg(&quot;DTMF&quot;,2,&quot;uint32_t&quot;);
</ins><span class="cx">   arg1 = (lua_tostring(L, 1))[0];
</span><del>-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&amp;argp2,SWIGTYPE_p_uint32_t,0))){
-    SWIG_fail_ptr(&quot;new_DTMF&quot;,2,SWIGTYPE_p_uint32_t);
</del><ins>+  if(lua_gettop(L)&gt;=2){
+    if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&amp;argp2,SWIGTYPE_p_uint32_t,0))){
+      SWIG_fail_ptr(&quot;new_DTMF&quot;,2,SWIGTYPE_p_uint32_t);
+    }
+    arg2 = *argp2;
</ins><span class="cx">   }
</span><del>-  arg2 = *argp2;
-  
</del><span class="cx">   result = (DTMF *)new DTMF(arg1,arg2);
</span><span class="cx">   SWIG_arg=0;
</span><span class="cx">   SWIG_NewPointerObj(L,result,SWIGTYPE_p_DTMF,1); SWIG_arg++; 
</span><span class="lines">@@ -2411,68 +2328,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_new_DTMF__SWIG_1(lua_State* L) {
-  int SWIG_arg = -1;
-  char arg1 ;
-  DTMF *result = 0 ;
-  
-  SWIG_check_num_args(&quot;DTMF&quot;,1,1)
-  if(!lua_isstring(L,1)) SWIG_fail_arg(&quot;DTMF&quot;,1,&quot;char&quot;);
-  arg1 = (lua_tostring(L, 1))[0];
-  result = (DTMF *)new DTMF(arg1);
-  SWIG_arg=0;
-  SWIG_NewPointerObj(L,result,SWIGTYPE_p_DTMF,1); SWIG_arg++; 
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_new_DTMF(lua_State* L) {
-  int argc;
-  int argv[3]={
-    1,2,3
-  };
-  
-  argc = lua_gettop(L);
-  if (argc == 1) {
-    int _v;
-    {
-      _v = lua_isstring(L,argv[0]) &amp;&amp; (lua_strlen(L,argv[0])==1);
-    }
-    if (_v) {
-      return _wrap_new_DTMF__SWIG_1(L);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    {
-      _v = lua_isstring(L,argv[0]) &amp;&amp; (lua_strlen(L,argv[0])==1);
-    }
-    if (_v) {
-      {
-        void *ptr;
-        if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &amp;ptr, SWIGTYPE_p_uint32_t, 0)) {
-          _v = 0;
-        } else {
-          _v = 1;
-        }
-      }
-      if (_v) {
-        return _wrap_new_DTMF__SWIG_0(L);
-      }
-    }
-  }
-  
-  lua_pushstring(L,&quot;No matching function for overloaded 'new_DTMF'&quot;);
-  lua_error(L);return 0;
-}
-
-
</del><span class="cx"> static int _wrap_delete_DTMF(lua_State* L) {
</span><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   DTMF *arg1 = (DTMF *) 0 ;
</span><span class="lines">@@ -2853,14 +2708,16 @@
</span><span class="cx"> static int _wrap_new_Event__SWIG_0(lua_State* L) {
</span><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   char *arg1 = (char *) 0 ;
</span><del>-  char *arg2 = (char *) 0 ;
</del><ins>+  char *arg2 = (char *) NULL ;
</ins><span class="cx">   Event *result = 0 ;
</span><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;Event&quot;,2,2)
</del><ins>+  SWIG_check_num_args(&quot;Event&quot;,1,2)
</ins><span class="cx">   if(!lua_isstring(L,1)) SWIG_fail_arg(&quot;Event&quot;,1,&quot;char const *&quot;);
</span><del>-  if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;Event&quot;,2,&quot;char const *&quot;);
</del><ins>+  if(lua_gettop(L)&gt;=2 &amp;&amp; !lua_isstring(L,2)) SWIG_fail_arg(&quot;Event&quot;,2,&quot;char const *&quot;);
</ins><span class="cx">   arg1 = (char *)lua_tostring(L, 1);
</span><del>-  arg2 = (char *)lua_tostring(L, 2);
</del><ins>+  if(lua_gettop(L)&gt;=2){
+    arg2 = (char *)lua_tostring(L, 2);
+  }
</ins><span class="cx">   result = (Event *)new Event((char const *)arg1,(char const *)arg2);
</span><span class="cx">   SWIG_arg=0;
</span><span class="cx">   SWIG_NewPointerObj(L,result,SWIGTYPE_p_Event,1); SWIG_arg++; 
</span><span class="lines">@@ -2876,40 +2733,21 @@
</span><span class="cx"> 
</span><span class="cx"> static int _wrap_new_Event__SWIG_1(lua_State* L) {
</span><span class="cx">   int SWIG_arg = -1;
</span><del>-  char *arg1 = (char *) 0 ;
-  Event *result = 0 ;
-  
-  SWIG_check_num_args(&quot;Event&quot;,1,1)
-  if(!lua_isstring(L,1)) SWIG_fail_arg(&quot;Event&quot;,1,&quot;char const *&quot;);
-  arg1 = (char *)lua_tostring(L, 1);
-  result = (Event *)new Event((char const *)arg1);
-  SWIG_arg=0;
-  SWIG_NewPointerObj(L,result,SWIGTYPE_p_Event,1); SWIG_arg++; 
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_new_Event__SWIG_2(lua_State* L) {
-  int SWIG_arg = -1;
</del><span class="cx">   switch_event_t *arg1 = (switch_event_t *) 0 ;
</span><del>-  int arg2 ;
</del><ins>+  int arg2 = (int) 0 ;
</ins><span class="cx">   Event *result = 0 ;
</span><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;Event&quot;,2,2)
</del><ins>+  SWIG_check_num_args(&quot;Event&quot;,1,2)
</ins><span class="cx">   if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;Event&quot;,1,&quot;switch_event_t *&quot;);
</span><del>-  if(!lua_isnumber(L,2)) SWIG_fail_arg(&quot;Event&quot;,2,&quot;int&quot;);
</del><ins>+  if(lua_gettop(L)&gt;=2 &amp;&amp; !lua_isnumber(L,2)) SWIG_fail_arg(&quot;Event&quot;,2,&quot;int&quot;);
</ins><span class="cx">   
</span><span class="cx">   if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_switch_event_t,0))){
</span><span class="cx">     SWIG_fail_ptr(&quot;new_Event&quot;,1,SWIGTYPE_p_switch_event_t);
</span><span class="cx">   }
</span><span class="cx">   
</span><del>-  arg2 = (int)lua_tonumber(L, 2);
</del><ins>+  if(lua_gettop(L)&gt;=2){
+    arg2 = (int)lua_tonumber(L, 2);
+  }
</ins><span class="cx">   result = (Event *)new Event(arg1,arg2);
</span><span class="cx">   SWIG_arg=0;
</span><span class="cx">   SWIG_NewPointerObj(L,result,SWIGTYPE_p_Event,1); SWIG_arg++; 
</span><span class="lines">@@ -2923,31 +2761,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_new_Event__SWIG_3(lua_State* L) {
-  int SWIG_arg = -1;
-  switch_event_t *arg1 = (switch_event_t *) 0 ;
-  Event *result = 0 ;
-  
-  SWIG_check_num_args(&quot;Event&quot;,1,1)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;Event&quot;,1,&quot;switch_event_t *&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_switch_event_t,0))){
-    SWIG_fail_ptr(&quot;new_Event&quot;,1,SWIGTYPE_p_switch_event_t);
-  }
-  
-  result = (Event *)new Event(arg1);
-  SWIG_arg=0;
-  SWIG_NewPointerObj(L,result,SWIGTYPE_p_Event,1); SWIG_arg++; 
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
</del><span class="cx"> static int _wrap_new_Event(lua_State* L) {
</span><span class="cx">   int argc;
</span><span class="cx">   int argv[3]={
</span><span class="lines">@@ -2955,7 +2768,7 @@
</span><span class="cx">   };
</span><span class="cx">   
</span><span class="cx">   argc = lua_gettop(L);
</span><del>-  if (argc == 1) {
</del><ins>+  if ((argc &gt;= 1) &amp;&amp; (argc &lt;= 2)) {
</ins><span class="cx">     int _v;
</span><span class="cx">     {
</span><span class="cx">       void *ptr;
</span><span class="lines">@@ -2966,43 +2779,26 @@
</span><span class="cx">       }
</span><span class="cx">     }
</span><span class="cx">     if (_v) {
</span><del>-      return _wrap_new_Event__SWIG_3(L);
-    }
-  }
-  if (argc == 1) {
-    int _v;
-    {
-      _v = lua_isstring(L,argv[0]);
-    }
-    if (_v) {
-      return _wrap_new_Event__SWIG_1(L);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_switch_event_t, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
</del><ins>+      if (argc &lt;= 1) {
+        return _wrap_new_Event__SWIG_1(L);
</ins><span class="cx">       }
</span><del>-    }
-    if (_v) {
</del><span class="cx">       {
</span><span class="cx">         _v = lua_isnumber(L,argv[1]);
</span><span class="cx">       }
</span><span class="cx">       if (_v) {
</span><del>-        return _wrap_new_Event__SWIG_2(L);
</del><ins>+        return _wrap_new_Event__SWIG_1(L);
</ins><span class="cx">       }
</span><span class="cx">     }
</span><span class="cx">   }
</span><del>-  if (argc == 2) {
</del><ins>+  if ((argc &gt;= 1) &amp;&amp; (argc &lt;= 2)) {
</ins><span class="cx">     int _v;
</span><span class="cx">     {
</span><span class="cx">       _v = lua_isstring(L,argv[0]);
</span><span class="cx">     }
</span><span class="cx">     if (_v) {
</span><ins>+      if (argc &lt;= 1) {
+        return _wrap_new_Event__SWIG_0(L);
+      }
</ins><span class="cx">       {
</span><span class="cx">         _v = lua_isstring(L,argv[1]);
</span><span class="cx">       }
</span><span class="lines">@@ -3042,21 +2838,23 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_Event_serialize__SWIG_0(lua_State* L) {
</del><ins>+static int _wrap_Event_serialize(lua_State* L) {
</ins><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   Event *arg1 = (Event *) 0 ;
</span><del>-  char *arg2 = (char *) 0 ;
</del><ins>+  char *arg2 = (char *) NULL ;
</ins><span class="cx">   char *result = 0 ;
</span><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;serialize&quot;,2,2)
</del><ins>+  SWIG_check_num_args(&quot;serialize&quot;,1,2)
</ins><span class="cx">   if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;serialize&quot;,1,&quot;Event *&quot;);
</span><del>-  if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;serialize&quot;,2,&quot;char const *&quot;);
</del><ins>+  if(lua_gettop(L)&gt;=2 &amp;&amp; !lua_isstring(L,2)) SWIG_fail_arg(&quot;serialize&quot;,2,&quot;char const *&quot;);
</ins><span class="cx">   
</span><span class="cx">   if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_Event,0))){
</span><span class="cx">     SWIG_fail_ptr(&quot;Event_serialize&quot;,1,SWIGTYPE_p_Event);
</span><span class="cx">   }
</span><span class="cx">   
</span><del>-  arg2 = (char *)lua_tostring(L, 2);
</del><ins>+  if(lua_gettop(L)&gt;=2){
+    arg2 = (char *)lua_tostring(L, 2);
+  }
</ins><span class="cx">   result = (char *)(arg1)-&gt;serialize((char const *)arg2);
</span><span class="cx">   SWIG_arg=0;
</span><span class="cx">   lua_pushstring(L,(const char*)result); SWIG_arg++;
</span><span class="lines">@@ -3070,98 +2868,27 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_Event_serialize__SWIG_1(lua_State* L) {
</del><ins>+static int _wrap_Event_setPriority(lua_State* L) {
</ins><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   Event *arg1 = (Event *) 0 ;
</span><del>-  char *result = 0 ;
-  
-  SWIG_check_num_args(&quot;serialize&quot;,1,1)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;serialize&quot;,1,&quot;Event *&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_Event,0))){
-    SWIG_fail_ptr(&quot;Event_serialize&quot;,1,SWIGTYPE_p_Event);
-  }
-  
-  result = (char *)(arg1)-&gt;serialize();
-  SWIG_arg=0;
-  lua_pushstring(L,(const char*)result); SWIG_arg++;
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_Event_serialize(lua_State* L) {
-  int argc;
-  int argv[3]={
-    1,2,3
-  };
-  
-  argc = lua_gettop(L);
-  if (argc == 1) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_Event, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      return _wrap_Event_serialize__SWIG_1(L);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_Event, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        return _wrap_Event_serialize__SWIG_0(L);
-      }
-    }
-  }
-  
-  lua_pushstring(L,&quot;No matching function for overloaded 'Event_serialize'&quot;);
-  lua_error(L);return 0;
-}
-
-
-static int _wrap_Event_setPriority__SWIG_0(lua_State* L) {
-  int SWIG_arg = -1;
-  Event *arg1 = (Event *) 0 ;
-  switch_priority_t arg2 ;
</del><ins>+  switch_priority_t arg2 = (switch_priority_t) SWITCH_PRIORITY_NORMAL ;
</ins><span class="cx">   bool result;
</span><span class="cx">   switch_priority_t *argp2 ;
</span><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;setPriority&quot;,2,2)
</del><ins>+  SWIG_check_num_args(&quot;setPriority&quot;,1,2)
</ins><span class="cx">   if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;setPriority&quot;,1,&quot;Event *&quot;);
</span><del>-  if(!lua_isuserdata(L,2)) SWIG_fail_arg(&quot;setPriority&quot;,2,&quot;switch_priority_t&quot;);
</del><ins>+  if(lua_gettop(L)&gt;=2 &amp;&amp; !lua_isuserdata(L,2)) SWIG_fail_arg(&quot;setPriority&quot;,2,&quot;switch_priority_t&quot;);
</ins><span class="cx">   
</span><span class="cx">   if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_Event,0))){
</span><span class="cx">     SWIG_fail_ptr(&quot;Event_setPriority&quot;,1,SWIGTYPE_p_Event);
</span><span class="cx">   }
</span><span class="cx">   
</span><del>-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&amp;argp2,SWIGTYPE_p_switch_priority_t,0))){
-    SWIG_fail_ptr(&quot;Event_setPriority&quot;,2,SWIGTYPE_p_switch_priority_t);
</del><ins>+  if(lua_gettop(L)&gt;=2){
+    if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&amp;argp2,SWIGTYPE_p_switch_priority_t,0))){
+      SWIG_fail_ptr(&quot;Event_setPriority&quot;,2,SWIGTYPE_p_switch_priority_t);
+    }
+    arg2 = *argp2;
</ins><span class="cx">   }
</span><del>-  arg2 = *argp2;
-  
</del><span class="cx">   result = (bool)(arg1)-&gt;setPriority(arg2);
</span><span class="cx">   SWIG_arg=0;
</span><span class="cx">   lua_pushboolean(L,(int)(result==true)); SWIG_arg++;
</span><span class="lines">@@ -3175,82 +2902,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_Event_setPriority__SWIG_1(lua_State* L) {
-  int SWIG_arg = -1;
-  Event *arg1 = (Event *) 0 ;
-  bool result;
-  
-  SWIG_check_num_args(&quot;setPriority&quot;,1,1)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;setPriority&quot;,1,&quot;Event *&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_Event,0))){
-    SWIG_fail_ptr(&quot;Event_setPriority&quot;,1,SWIGTYPE_p_Event);
-  }
-  
-  result = (bool)(arg1)-&gt;setPriority();
-  SWIG_arg=0;
-  lua_pushboolean(L,(int)(result==true)); SWIG_arg++;
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_Event_setPriority(lua_State* L) {
-  int argc;
-  int argv[3]={
-    1,2,3
-  };
-  
-  argc = lua_gettop(L);
-  if (argc == 1) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_Event, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      return _wrap_Event_setPriority__SWIG_1(L);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_Event, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        void *ptr;
-        if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &amp;ptr, SWIGTYPE_p_switch_priority_t, 0)) {
-          _v = 0;
-        } else {
-          _v = 1;
-        }
-      }
-      if (_v) {
-        return _wrap_Event_setPriority__SWIG_0(L);
-      }
-    }
-  }
-  
-  lua_pushstring(L,&quot;No matching function for overloaded 'Event_setPriority'&quot;);
-  lua_error(L);return 0;
-}
-
-
</del><span class="cx"> static int _wrap_Event_getHeader(lua_State* L) {
</span><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   Event *arg1 = (Event *) 0 ;
</span><span class="lines">@@ -3586,63 +3237,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_EventConsumer_node_set(lua_State* L) {
-  int SWIG_arg = -1;
-  EventConsumer *arg1 = (EventConsumer *) 0 ;
-  switch_event_node_t *arg2 = (switch_event_node_t *) 0 ;
-  
-  SWIG_check_num_args(&quot;node&quot;,2,2)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;node&quot;,1,&quot;EventConsumer *&quot;);
-  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg(&quot;node&quot;,2,&quot;switch_event_node_t *&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_EventConsumer,0))){
-    SWIG_fail_ptr(&quot;EventConsumer_node_set&quot;,1,SWIGTYPE_p_EventConsumer);
-  }
-  
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&amp;arg2,SWIGTYPE_p_switch_event_node_t,SWIG_POINTER_DISOWN))){
-    SWIG_fail_ptr(&quot;EventConsumer_node_set&quot;,2,SWIGTYPE_p_switch_event_node_t);
-  }
-  
-  if (arg1) (arg1)-&gt;node = arg2;
-  
-  SWIG_arg=0;
-  
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_EventConsumer_node_get(lua_State* L) {
-  int SWIG_arg = -1;
-  EventConsumer *arg1 = (EventConsumer *) 0 ;
-  switch_event_node_t *result = 0 ;
-  
-  SWIG_check_num_args(&quot;node&quot;,1,1)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;node&quot;,1,&quot;EventConsumer *&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_EventConsumer,0))){
-    SWIG_fail_ptr(&quot;EventConsumer_node_get&quot;,1,SWIGTYPE_p_EventConsumer);
-  }
-  
-  result = (switch_event_node_t *) ((arg1)-&gt;node);
-  SWIG_arg=0;
-  SWIG_NewPointerObj(L,result,SWIGTYPE_p_switch_event_node_t,0); SWIG_arg++; 
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
</del><span class="cx"> static int _wrap_EventConsumer_e_callback_set(lua_State* L) {
</span><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   EventConsumer *arg1 = (EventConsumer *) 0 ;
</span><span class="lines">@@ -3823,17 +3417,21 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_new_EventConsumer__SWIG_0(lua_State* L) {
</del><ins>+static int _wrap_new_EventConsumer(lua_State* L) {
</ins><span class="cx">   int SWIG_arg = -1;
</span><del>-  char *arg1 = (char *) 0 ;
-  char *arg2 = (char *) 0 ;
</del><ins>+  char *arg1 = (char *) NULL ;
+  char *arg2 = (char *) &quot;&quot; ;
</ins><span class="cx">   EventConsumer *result = 0 ;
</span><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;EventConsumer&quot;,2,2)
-  if(!lua_isstring(L,1)) SWIG_fail_arg(&quot;EventConsumer&quot;,1,&quot;char const *&quot;);
-  if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;EventConsumer&quot;,2,&quot;char const *&quot;);
-  arg1 = (char *)lua_tostring(L, 1);
-  arg2 = (char *)lua_tostring(L, 2);
</del><ins>+  SWIG_check_num_args(&quot;EventConsumer&quot;,0,2)
+  if(lua_gettop(L)&gt;=1 &amp;&amp; !lua_isstring(L,1)) SWIG_fail_arg(&quot;EventConsumer&quot;,1,&quot;char const *&quot;);
+  if(lua_gettop(L)&gt;=2 &amp;&amp; !lua_isstring(L,2)) SWIG_fail_arg(&quot;EventConsumer&quot;,2,&quot;char const *&quot;);
+  if(lua_gettop(L)&gt;=1){
+    arg1 = (char *)lua_tostring(L, 1);
+  }
+  if(lua_gettop(L)&gt;=2){
+    arg2 = (char *)lua_tostring(L, 2);
+  }
</ins><span class="cx">   result = (EventConsumer *)new EventConsumer((char const *)arg1,(char const *)arg2);
</span><span class="cx">   SWIG_arg=0;
</span><span class="cx">   SWIG_NewPointerObj(L,result,SWIGTYPE_p_EventConsumer,1); SWIG_arg++; 
</span><span class="lines">@@ -3847,63 +3445,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_new_EventConsumer__SWIG_1(lua_State* L) {
-  int SWIG_arg = -1;
-  char *arg1 = (char *) 0 ;
-  EventConsumer *result = 0 ;
-  
-  SWIG_check_num_args(&quot;EventConsumer&quot;,1,1)
-  if(!lua_isstring(L,1)) SWIG_fail_arg(&quot;EventConsumer&quot;,1,&quot;char const *&quot;);
-  arg1 = (char *)lua_tostring(L, 1);
-  result = (EventConsumer *)new EventConsumer((char const *)arg1);
-  SWIG_arg=0;
-  SWIG_NewPointerObj(L,result,SWIGTYPE_p_EventConsumer,1); SWIG_arg++; 
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_new_EventConsumer(lua_State* L) {
-  int argc;
-  int argv[3]={
-    1,2,3
-  };
-  
-  argc = lua_gettop(L);
-  if (argc == 1) {
-    int _v;
-    {
-      _v = lua_isstring(L,argv[0]);
-    }
-    if (_v) {
-      return _wrap_new_EventConsumer__SWIG_1(L);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    {
-      _v = lua_isstring(L,argv[0]);
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        return _wrap_new_EventConsumer__SWIG_0(L);
-      }
-    }
-  }
-  
-  lua_pushstring(L,&quot;No matching function for overloaded 'new_EventConsumer'&quot;);
-  lua_error(L);return 0;
-}
-
-
</del><span class="cx"> static int _wrap_delete_EventConsumer(lua_State* L) {
</span><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   EventConsumer *arg1 = (EventConsumer *) 0 ;
</span><span class="lines">@@ -3929,24 +3470,29 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_EventConsumer_pop__SWIG_0(lua_State* L) {
</del><ins>+static int _wrap_EventConsumer_bind(lua_State* L) {
</ins><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   EventConsumer *arg1 = (EventConsumer *) 0 ;
</span><del>-  int arg2 ;
-  Event *result = 0 ;
</del><ins>+  char *arg2 = (char *) 0 ;
+  char *arg3 = (char *) &quot;&quot; ;
+  int result;
</ins><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;pop&quot;,2,2)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;pop&quot;,1,&quot;EventConsumer *&quot;);
-  if(!lua_isnumber(L,2)) SWIG_fail_arg(&quot;pop&quot;,2,&quot;int&quot;);
</del><ins>+  SWIG_check_num_args(&quot;bind&quot;,2,3)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;bind&quot;,1,&quot;EventConsumer *&quot;);
+  if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;bind&quot;,2,&quot;char const *&quot;);
+  if(lua_gettop(L)&gt;=3 &amp;&amp; !lua_isstring(L,3)) SWIG_fail_arg(&quot;bind&quot;,3,&quot;char const *&quot;);
</ins><span class="cx">   
</span><span class="cx">   if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_EventConsumer,0))){
</span><del>-    SWIG_fail_ptr(&quot;EventConsumer_pop&quot;,1,SWIGTYPE_p_EventConsumer);
</del><ins>+    SWIG_fail_ptr(&quot;EventConsumer_bind&quot;,1,SWIGTYPE_p_EventConsumer);
</ins><span class="cx">   }
</span><span class="cx">   
</span><del>-  arg2 = (int)lua_tonumber(L, 2);
-  result = (Event *)(arg1)-&gt;pop(arg2);
</del><ins>+  arg2 = (char *)lua_tostring(L, 2);
+  if(lua_gettop(L)&gt;=3){
+    arg3 = (char *)lua_tostring(L, 3);
+  }
+  result = (int)(arg1)-&gt;bind((char const *)arg2,(char const *)arg3);
</ins><span class="cx">   SWIG_arg=0;
</span><del>-  SWIG_NewPointerObj(L,result,SWIGTYPE_p_Event,1); SWIG_arg++; 
</del><ins>+  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
</ins><span class="cx">   return SWIG_arg;
</span><span class="cx">   
</span><span class="cx">   if(0) SWIG_fail;
</span><span class="lines">@@ -3957,19 +3503,24 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_EventConsumer_pop__SWIG_1(lua_State* L) {
</del><ins>+static int _wrap_EventConsumer_pop(lua_State* L) {
</ins><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   EventConsumer *arg1 = (EventConsumer *) 0 ;
</span><ins>+  int arg2 = (int) 0 ;
</ins><span class="cx">   Event *result = 0 ;
</span><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;pop&quot;,1,1)
</del><ins>+  SWIG_check_num_args(&quot;pop&quot;,1,2)
</ins><span class="cx">   if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;pop&quot;,1,&quot;EventConsumer *&quot;);
</span><ins>+  if(lua_gettop(L)&gt;=2 &amp;&amp; !lua_isnumber(L,2)) SWIG_fail_arg(&quot;pop&quot;,2,&quot;int&quot;);
</ins><span class="cx">   
</span><span class="cx">   if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_EventConsumer,0))){
</span><span class="cx">     SWIG_fail_ptr(&quot;EventConsumer_pop&quot;,1,SWIGTYPE_p_EventConsumer);
</span><span class="cx">   }
</span><span class="cx">   
</span><del>-  result = (Event *)(arg1)-&gt;pop();
</del><ins>+  if(lua_gettop(L)&gt;=2){
+    arg2 = (int)lua_tonumber(L, 2);
+  }
+  result = (Event *)(arg1)-&gt;pop(arg2);
</ins><span class="cx">   SWIG_arg=0;
</span><span class="cx">   SWIG_NewPointerObj(L,result,SWIGTYPE_p_Event,1); SWIG_arg++; 
</span><span class="cx">   return SWIG_arg;
</span><span class="lines">@@ -3982,64 +3533,18 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_EventConsumer_pop(lua_State* L) {
-  int argc;
-  int argv[3]={
-    1,2,3
-  };
-  
-  argc = lua_gettop(L);
-  if (argc == 1) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_EventConsumer, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      return _wrap_EventConsumer_pop__SWIG_1(L);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_EventConsumer, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isnumber(L,argv[1]);
-      }
-      if (_v) {
-        return _wrap_EventConsumer_pop__SWIG_0(L);
-      }
-    }
-  }
-  
-  lua_pushstring(L,&quot;No matching function for overloaded 'EventConsumer_pop'&quot;);
-  lua_error(L);return 0;
-}
-
-
</del><span class="cx"> static void swig_delete_EventConsumer(void *obj) {
</span><span class="cx"> EventConsumer *arg1 = (EventConsumer *) obj;
</span><span class="cx"> delete arg1;
</span><span class="cx"> }
</span><span class="cx"> static swig_lua_method swig_EventConsumer_methods[] = {
</span><ins>+    {&quot;bind&quot;, _wrap_EventConsumer_bind}, 
</ins><span class="cx">     {&quot;pop&quot;, _wrap_EventConsumer_pop}, 
</span><span class="cx">     {0,0}
</span><span class="cx"> };
</span><span class="cx"> static swig_lua_attribute swig_EventConsumer_attributes[] = {
</span><span class="cx">     { &quot;events&quot;, _wrap_EventConsumer_events_get, _wrap_EventConsumer_events_set},
</span><span class="cx">     { &quot;e_event_id&quot;, _wrap_EventConsumer_e_event_id_get, _wrap_EventConsumer_e_event_id_set},
</span><del>-    { &quot;node&quot;, _wrap_EventConsumer_node_get, _wrap_EventConsumer_node_set},
</del><span class="cx">     { &quot;e_callback&quot;, _wrap_EventConsumer_e_callback_get, _wrap_EventConsumer_e_callback_set},
</span><span class="cx">     { &quot;e_subclass_name&quot;, _wrap_EventConsumer_e_subclass_name_get, _wrap_EventConsumer_e_subclass_name_set},
</span><span class="cx">     { &quot;e_cb_arg&quot;, _wrap_EventConsumer_e_cb_arg_get, _wrap_EventConsumer_e_cb_arg_set},
</span><span class="lines">@@ -4705,20 +4210,22 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_CoreSession_hangup__SWIG_0(lua_State* L) {
</del><ins>+static int _wrap_CoreSession_hangup(lua_State* L) {
</ins><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><del>-  char *arg2 = (char *) 0 ;
</del><ins>+  char *arg2 = (char *) &quot;normal_clearing&quot; ;
</ins><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;hangup&quot;,2,2)
</del><ins>+  SWIG_check_num_args(&quot;hangup&quot;,1,2)
</ins><span class="cx">   if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;hangup&quot;,1,&quot;CoreSession *&quot;);
</span><del>-  if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;hangup&quot;,2,&quot;char const *&quot;);
</del><ins>+  if(lua_gettop(L)&gt;=2 &amp;&amp; !lua_isstring(L,2)) SWIG_fail_arg(&quot;hangup&quot;,2,&quot;char const *&quot;);
</ins><span class="cx">   
</span><span class="cx">   if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
</span><span class="cx">     SWIG_fail_ptr(&quot;CoreSession_hangup&quot;,1,SWIGTYPE_p_CoreSession);
</span><span class="cx">   }
</span><span class="cx">   
</span><del>-  arg2 = (char *)lua_tostring(L, 2);
</del><ins>+  if(lua_gettop(L)&gt;=2){
+    arg2 = (char *)lua_tostring(L, 2);
+  }
</ins><span class="cx">   (arg1)-&gt;hangup((char const *)arg2);
</span><span class="cx">   SWIG_arg=0;
</span><span class="cx">   
</span><span class="lines">@@ -4732,76 +4239,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_CoreSession_hangup__SWIG_1(lua_State* L) {
-  int SWIG_arg = -1;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  
-  SWIG_check_num_args(&quot;hangup&quot;,1,1)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;hangup&quot;,1,&quot;CoreSession *&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
-    SWIG_fail_ptr(&quot;CoreSession_hangup&quot;,1,SWIGTYPE_p_CoreSession);
-  }
-  
-  (arg1)-&gt;hangup();
-  SWIG_arg=0;
-  
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_CoreSession_hangup(lua_State* L) {
-  int argc;
-  int argv[3]={
-    1,2,3
-  };
-  
-  argc = lua_gettop(L);
-  if (argc == 1) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      return _wrap_CoreSession_hangup__SWIG_1(L);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        return _wrap_CoreSession_hangup__SWIG_0(L);
-      }
-    }
-  }
-  
-  lua_pushstring(L,&quot;No matching function for overloaded 'CoreSession_hangup'&quot;);
-  lua_error(L);return 0;
-}
-
-
</del><span class="cx"> static int _wrap_CoreSession_hangupState(lua_State* L) {
</span><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -4973,22 +4410,22 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_CoreSession_say__SWIG_0(lua_State* L) {
</del><ins>+static int _wrap_CoreSession_say(lua_State* L) {
</ins><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><span class="cx">   char *arg3 = (char *) 0 ;
</span><span class="cx">   char *arg4 = (char *) 0 ;
</span><span class="cx">   char *arg5 = (char *) 0 ;
</span><del>-  char *arg6 = (char *) 0 ;
</del><ins>+  char *arg6 = (char *) NULL ;
</ins><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;say&quot;,6,6)
</del><ins>+  SWIG_check_num_args(&quot;say&quot;,5,6)
</ins><span class="cx">   if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;say&quot;,1,&quot;CoreSession *&quot;);
</span><span class="cx">   if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;say&quot;,2,&quot;char const *&quot;);
</span><span class="cx">   if(!lua_isstring(L,3)) SWIG_fail_arg(&quot;say&quot;,3,&quot;char const *&quot;);
</span><span class="cx">   if(!lua_isstring(L,4)) SWIG_fail_arg(&quot;say&quot;,4,&quot;char const *&quot;);
</span><span class="cx">   if(!lua_isstring(L,5)) SWIG_fail_arg(&quot;say&quot;,5,&quot;char const *&quot;);
</span><del>-  if(!lua_isstring(L,6)) SWIG_fail_arg(&quot;say&quot;,6,&quot;char const *&quot;);
</del><ins>+  if(lua_gettop(L)&gt;=6 &amp;&amp; !lua_isstring(L,6)) SWIG_fail_arg(&quot;say&quot;,6,&quot;char const *&quot;);
</ins><span class="cx">   
</span><span class="cx">   if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
</span><span class="cx">     SWIG_fail_ptr(&quot;CoreSession_say&quot;,1,SWIGTYPE_p_CoreSession);
</span><span class="lines">@@ -4998,7 +4435,9 @@
</span><span class="cx">   arg3 = (char *)lua_tostring(L, 3);
</span><span class="cx">   arg4 = (char *)lua_tostring(L, 4);
</span><span class="cx">   arg5 = (char *)lua_tostring(L, 5);
</span><del>-  arg6 = (char *)lua_tostring(L, 6);
</del><ins>+  if(lua_gettop(L)&gt;=6){
+    arg6 = (char *)lua_tostring(L, 6);
+  }
</ins><span class="cx">   (arg1)-&gt;say((char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5,(char const *)arg6);
</span><span class="cx">   SWIG_arg=0;
</span><span class="cx">   
</span><span class="lines">@@ -5012,206 +4451,31 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_CoreSession_say__SWIG_1(lua_State* L) {
</del><ins>+static int _wrap_CoreSession_sayPhrase(lua_State* L) {
</ins><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  char *arg3 = (char *) 0 ;
-  char *arg4 = (char *) 0 ;
-  char *arg5 = (char *) 0 ;
</del><ins>+  char *arg3 = (char *) &quot;&quot; ;
+  char *arg4 = (char *) NULL ;
</ins><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;say&quot;,5,5)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;say&quot;,1,&quot;CoreSession *&quot;);
-  if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;say&quot;,2,&quot;char const *&quot;);
-  if(!lua_isstring(L,3)) SWIG_fail_arg(&quot;say&quot;,3,&quot;char const *&quot;);
-  if(!lua_isstring(L,4)) SWIG_fail_arg(&quot;say&quot;,4,&quot;char const *&quot;);
-  if(!lua_isstring(L,5)) SWIG_fail_arg(&quot;say&quot;,5,&quot;char const *&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
-    SWIG_fail_ptr(&quot;CoreSession_say&quot;,1,SWIGTYPE_p_CoreSession);
-  }
-  
-  arg2 = (char *)lua_tostring(L, 2);
-  arg3 = (char *)lua_tostring(L, 3);
-  arg4 = (char *)lua_tostring(L, 4);
-  arg5 = (char *)lua_tostring(L, 5);
-  (arg1)-&gt;say((char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5);
-  SWIG_arg=0;
-  
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_CoreSession_say(lua_State* L) {
-  int argc;
-  int argv[7]={
-    1,2,3,4,5,6,7
-  };
-  
-  argc = lua_gettop(L);
-  if (argc == 5) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        {
-          _v = lua_isstring(L,argv[2]);
-        }
-        if (_v) {
-          {
-            _v = lua_isstring(L,argv[3]);
-          }
-          if (_v) {
-            {
-              _v = lua_isstring(L,argv[4]);
-            }
-            if (_v) {
-              return _wrap_CoreSession_say__SWIG_1(L);
-            }
-          }
-        }
-      }
-    }
-  }
-  if (argc == 6) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        {
-          _v = lua_isstring(L,argv[2]);
-        }
-        if (_v) {
-          {
-            _v = lua_isstring(L,argv[3]);
-          }
-          if (_v) {
-            {
-              _v = lua_isstring(L,argv[4]);
-            }
-            if (_v) {
-              {
-                _v = lua_isstring(L,argv[5]);
-              }
-              if (_v) {
-                return _wrap_CoreSession_say__SWIG_0(L);
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-  
-  lua_pushstring(L,&quot;No matching function for overloaded 'CoreSession_say'&quot;);
-  lua_error(L);return 0;
-}
-
-
-static int _wrap_CoreSession_sayPhrase__SWIG_0(lua_State* L) {
-  int SWIG_arg = -1;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  char *arg3 = (char *) 0 ;
-  char *arg4 = (char *) 0 ;
-  
-  SWIG_check_num_args(&quot;sayPhrase&quot;,4,4)
</del><ins>+  SWIG_check_num_args(&quot;sayPhrase&quot;,2,4)
</ins><span class="cx">   if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;sayPhrase&quot;,1,&quot;CoreSession *&quot;);
</span><span class="cx">   if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;sayPhrase&quot;,2,&quot;char const *&quot;);
</span><del>-  if(!lua_isstring(L,3)) SWIG_fail_arg(&quot;sayPhrase&quot;,3,&quot;char const *&quot;);
-  if(!lua_isstring(L,4)) SWIG_fail_arg(&quot;sayPhrase&quot;,4,&quot;char const *&quot;);
</del><ins>+  if(lua_gettop(L)&gt;=3 &amp;&amp; !lua_isstring(L,3)) SWIG_fail_arg(&quot;sayPhrase&quot;,3,&quot;char const *&quot;);
+  if(lua_gettop(L)&gt;=4 &amp;&amp; !lua_isstring(L,4)) SWIG_fail_arg(&quot;sayPhrase&quot;,4,&quot;char const *&quot;);
</ins><span class="cx">   
</span><span class="cx">   if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
</span><span class="cx">     SWIG_fail_ptr(&quot;CoreSession_sayPhrase&quot;,1,SWIGTYPE_p_CoreSession);
</span><span class="cx">   }
</span><span class="cx">   
</span><span class="cx">   arg2 = (char *)lua_tostring(L, 2);
</span><del>-  arg3 = (char *)lua_tostring(L, 3);
-  arg4 = (char *)lua_tostring(L, 4);
-  (arg1)-&gt;sayPhrase((char const *)arg2,(char const *)arg3,(char const *)arg4);
-  SWIG_arg=0;
-  
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_CoreSession_sayPhrase__SWIG_1(lua_State* L) {
-  int SWIG_arg = -1;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  char *arg3 = (char *) 0 ;
-  
-  SWIG_check_num_args(&quot;sayPhrase&quot;,3,3)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;sayPhrase&quot;,1,&quot;CoreSession *&quot;);
-  if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;sayPhrase&quot;,2,&quot;char const *&quot;);
-  if(!lua_isstring(L,3)) SWIG_fail_arg(&quot;sayPhrase&quot;,3,&quot;char const *&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
-    SWIG_fail_ptr(&quot;CoreSession_sayPhrase&quot;,1,SWIGTYPE_p_CoreSession);
</del><ins>+  if(lua_gettop(L)&gt;=3){
+    arg3 = (char *)lua_tostring(L, 3);
</ins><span class="cx">   }
</span><del>-  
-  arg2 = (char *)lua_tostring(L, 2);
-  arg3 = (char *)lua_tostring(L, 3);
-  (arg1)-&gt;sayPhrase((char const *)arg2,(char const *)arg3);
-  SWIG_arg=0;
-  
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_CoreSession_sayPhrase__SWIG_2(lua_State* L) {
-  int SWIG_arg = -1;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  
-  SWIG_check_num_args(&quot;sayPhrase&quot;,2,2)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;sayPhrase&quot;,1,&quot;CoreSession *&quot;);
-  if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;sayPhrase&quot;,2,&quot;char const *&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
-    SWIG_fail_ptr(&quot;CoreSession_sayPhrase&quot;,1,SWIGTYPE_p_CoreSession);
</del><ins>+  if(lua_gettop(L)&gt;=4){
+    arg4 = (char *)lua_tostring(L, 4);
</ins><span class="cx">   }
</span><del>-  
-  arg2 = (char *)lua_tostring(L, 2);
-  (arg1)-&gt;sayPhrase((char const *)arg2);
</del><ins>+  (arg1)-&gt;sayPhrase((char const *)arg2,(char const *)arg3,(char const *)arg4);
</ins><span class="cx">   SWIG_arg=0;
</span><span class="cx">   
</span><span class="cx">   return SWIG_arg;
</span><span class="lines">@@ -5224,91 +4488,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_CoreSession_sayPhrase(lua_State* L) {
-  int argc;
-  int argv[5]={
-    1,2,3,4,5
-  };
-  
-  argc = lua_gettop(L);
-  if (argc == 2) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        return _wrap_CoreSession_sayPhrase__SWIG_2(L);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        {
-          _v = lua_isstring(L,argv[2]);
-        }
-        if (_v) {
-          return _wrap_CoreSession_sayPhrase__SWIG_1(L);
-        }
-      }
-    }
-  }
-  if (argc == 4) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        {
-          _v = lua_isstring(L,argv[2]);
-        }
-        if (_v) {
-          {
-            _v = lua_isstring(L,argv[3]);
-          }
-          if (_v) {
-            return _wrap_CoreSession_sayPhrase__SWIG_0(L);
-          }
-        }
-      }
-    }
-  }
-  
-  lua_pushstring(L,&quot;No matching function for overloaded 'CoreSession_sayPhrase'&quot;);
-  lua_error(L);return 0;
-}
-
-
</del><span class="cx"> static int _wrap_CoreSession_hangupCause(lua_State* L) {
</span><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -5359,124 +4538,37 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_CoreSession_recordFile__SWIG_0(lua_State* L) {
</del><ins>+static int _wrap_CoreSession_recordFile(lua_State* L) {
</ins><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  int arg3 ;
-  int arg4 ;
-  int arg5 ;
</del><ins>+  int arg3 = (int) 0 ;
+  int arg4 = (int) 0 ;
+  int arg5 = (int) 0 ;
</ins><span class="cx">   int result;
</span><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;recordFile&quot;,5,5)
</del><ins>+  SWIG_check_num_args(&quot;recordFile&quot;,2,5)
</ins><span class="cx">   if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;recordFile&quot;,1,&quot;CoreSession *&quot;);
</span><span class="cx">   if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;recordFile&quot;,2,&quot;char *&quot;);
</span><del>-  if(!lua_isnumber(L,3)) SWIG_fail_arg(&quot;recordFile&quot;,3,&quot;int&quot;);
-  if(!lua_isnumber(L,4)) SWIG_fail_arg(&quot;recordFile&quot;,4,&quot;int&quot;);
-  if(!lua_isnumber(L,5)) SWIG_fail_arg(&quot;recordFile&quot;,5,&quot;int&quot;);
</del><ins>+  if(lua_gettop(L)&gt;=3 &amp;&amp; !lua_isnumber(L,3)) SWIG_fail_arg(&quot;recordFile&quot;,3,&quot;int&quot;);
+  if(lua_gettop(L)&gt;=4 &amp;&amp; !lua_isnumber(L,4)) SWIG_fail_arg(&quot;recordFile&quot;,4,&quot;int&quot;);
+  if(lua_gettop(L)&gt;=5 &amp;&amp; !lua_isnumber(L,5)) SWIG_fail_arg(&quot;recordFile&quot;,5,&quot;int&quot;);
</ins><span class="cx">   
</span><span class="cx">   if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
</span><span class="cx">     SWIG_fail_ptr(&quot;CoreSession_recordFile&quot;,1,SWIGTYPE_p_CoreSession);
</span><span class="cx">   }
</span><span class="cx">   
</span><span class="cx">   arg2 = (char *)lua_tostring(L, 2);
</span><del>-  arg3 = (int)lua_tonumber(L, 3);
-  arg4 = (int)lua_tonumber(L, 4);
-  arg5 = (int)lua_tonumber(L, 5);
-  result = (int)(arg1)-&gt;recordFile(arg2,arg3,arg4,arg5);
-  SWIG_arg=0;
-  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_CoreSession_recordFile__SWIG_1(lua_State* L) {
-  int SWIG_arg = -1;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  int arg3 ;
-  int arg4 ;
-  int result;
-  
-  SWIG_check_num_args(&quot;recordFile&quot;,4,4)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;recordFile&quot;,1,&quot;CoreSession *&quot;);
-  if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;recordFile&quot;,2,&quot;char *&quot;);
-  if(!lua_isnumber(L,3)) SWIG_fail_arg(&quot;recordFile&quot;,3,&quot;int&quot;);
-  if(!lua_isnumber(L,4)) SWIG_fail_arg(&quot;recordFile&quot;,4,&quot;int&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
-    SWIG_fail_ptr(&quot;CoreSession_recordFile&quot;,1,SWIGTYPE_p_CoreSession);
</del><ins>+  if(lua_gettop(L)&gt;=3){
+    arg3 = (int)lua_tonumber(L, 3);
</ins><span class="cx">   }
</span><del>-  
-  arg2 = (char *)lua_tostring(L, 2);
-  arg3 = (int)lua_tonumber(L, 3);
-  arg4 = (int)lua_tonumber(L, 4);
-  result = (int)(arg1)-&gt;recordFile(arg2,arg3,arg4);
-  SWIG_arg=0;
-  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_CoreSession_recordFile__SWIG_2(lua_State* L) {
-  int SWIG_arg = -1;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  int arg3 ;
-  int result;
-  
-  SWIG_check_num_args(&quot;recordFile&quot;,3,3)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;recordFile&quot;,1,&quot;CoreSession *&quot;);
-  if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;recordFile&quot;,2,&quot;char *&quot;);
-  if(!lua_isnumber(L,3)) SWIG_fail_arg(&quot;recordFile&quot;,3,&quot;int&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
-    SWIG_fail_ptr(&quot;CoreSession_recordFile&quot;,1,SWIGTYPE_p_CoreSession);
</del><ins>+  if(lua_gettop(L)&gt;=4){
+    arg4 = (int)lua_tonumber(L, 4);
</ins><span class="cx">   }
</span><del>-  
-  arg2 = (char *)lua_tostring(L, 2);
-  arg3 = (int)lua_tonumber(L, 3);
-  result = (int)(arg1)-&gt;recordFile(arg2,arg3);
-  SWIG_arg=0;
-  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_CoreSession_recordFile__SWIG_3(lua_State* L) {
-  int SWIG_arg = -1;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  int result;
-  
-  SWIG_check_num_args(&quot;recordFile&quot;,2,2)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;recordFile&quot;,1,&quot;CoreSession *&quot;);
-  if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;recordFile&quot;,2,&quot;char *&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
-    SWIG_fail_ptr(&quot;CoreSession_recordFile&quot;,1,SWIGTYPE_p_CoreSession);
</del><ins>+  if(lua_gettop(L)&gt;=5){
+    arg5 = (int)lua_tonumber(L, 5);
</ins><span class="cx">   }
</span><del>-  
-  arg2 = (char *)lua_tostring(L, 2);
-  result = (int)(arg1)-&gt;recordFile(arg2);
</del><ins>+  result = (int)(arg1)-&gt;recordFile(arg2,arg3,arg4,arg5);
</ins><span class="cx">   SWIG_arg=0;
</span><span class="cx">   lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
</span><span class="cx">   return SWIG_arg;
</span><span class="lines">@@ -5489,140 +4581,21 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_CoreSession_recordFile(lua_State* L) {
-  int argc;
-  int argv[6]={
-    1,2,3,4,5,6
-  };
-  
-  argc = lua_gettop(L);
-  if (argc == 2) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        return _wrap_CoreSession_recordFile__SWIG_3(L);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        {
-          _v = lua_isnumber(L,argv[2]);
-        }
-        if (_v) {
-          return _wrap_CoreSession_recordFile__SWIG_2(L);
-        }
-      }
-    }
-  }
-  if (argc == 4) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        {
-          _v = lua_isnumber(L,argv[2]);
-        }
-        if (_v) {
-          {
-            _v = lua_isnumber(L,argv[3]);
-          }
-          if (_v) {
-            return _wrap_CoreSession_recordFile__SWIG_1(L);
-          }
-        }
-      }
-    }
-  }
-  if (argc == 5) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        {
-          _v = lua_isnumber(L,argv[2]);
-        }
-        if (_v) {
-          {
-            _v = lua_isnumber(L,argv[3]);
-          }
-          if (_v) {
-            {
-              _v = lua_isnumber(L,argv[4]);
-            }
-            if (_v) {
-              return _wrap_CoreSession_recordFile__SWIG_0(L);
-            }
-          }
-        }
-      }
-    }
-  }
-  
-  lua_pushstring(L,&quot;No matching function for overloaded 'CoreSession_recordFile'&quot;);
-  lua_error(L);return 0;
-}
-
-
-static int _wrap_CoreSession_originate__SWIG_0(lua_State* L) {
</del><ins>+static int _wrap_CoreSession_originate(lua_State* L) {
</ins><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   CoreSession *arg2 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg3 = (char *) 0 ;
</span><del>-  int arg4 ;
-  switch_state_handler_table_t *arg5 = (switch_state_handler_table_t *) 0 ;
</del><ins>+  int arg4 = (int) 60 ;
+  switch_state_handler_table_t *arg5 = (switch_state_handler_table_t *) NULL ;
</ins><span class="cx">   int result;
</span><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;originate&quot;,5,5)
</del><ins>+  SWIG_check_num_args(&quot;originate&quot;,3,5)
</ins><span class="cx">   if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;originate&quot;,1,&quot;CoreSession *&quot;);
</span><span class="cx">   if(!SWIG_isptrtype(L,2)) SWIG_fail_arg(&quot;originate&quot;,2,&quot;CoreSession *&quot;);
</span><span class="cx">   if(!lua_isstring(L,3)) SWIG_fail_arg(&quot;originate&quot;,3,&quot;char *&quot;);
</span><del>-  if(!lua_isnumber(L,4)) SWIG_fail_arg(&quot;originate&quot;,4,&quot;int&quot;);
-  if(!SWIG_isptrtype(L,5)) SWIG_fail_arg(&quot;originate&quot;,5,&quot;switch_state_handler_table_t *&quot;);
</del><ins>+  if(lua_gettop(L)&gt;=4 &amp;&amp; !lua_isnumber(L,4)) SWIG_fail_arg(&quot;originate&quot;,4,&quot;int&quot;);
+  if(lua_gettop(L)&gt;=5 &amp;&amp; !SWIG_isptrtype(L,5)) SWIG_fail_arg(&quot;originate&quot;,5,&quot;switch_state_handler_table_t *&quot;);
</ins><span class="cx">   
</span><span class="cx">   if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
</span><span class="cx">     SWIG_fail_ptr(&quot;CoreSession_originate&quot;,1,SWIGTYPE_p_CoreSession);
</span><span class="lines">@@ -5634,12 +4607,14 @@
</span><span class="cx">   }
</span><span class="cx">   
</span><span class="cx">   arg3 = (char *)lua_tostring(L, 3);
</span><del>-  arg4 = (int)lua_tonumber(L, 4);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,5,(void**)&amp;arg5,SWIGTYPE_p_switch_state_handler_table_t,0))){
-    SWIG_fail_ptr(&quot;CoreSession_originate&quot;,5,SWIGTYPE_p_switch_state_handler_table_t);
</del><ins>+  if(lua_gettop(L)&gt;=4){
+    arg4 = (int)lua_tonumber(L, 4);
</ins><span class="cx">   }
</span><del>-  
</del><ins>+  if(lua_gettop(L)&gt;=5){
+    if (!SWIG_IsOK(SWIG_ConvertPtr(L,5,(void**)&amp;arg5,SWIGTYPE_p_switch_state_handler_table_t,0))){
+      SWIG_fail_ptr(&quot;CoreSession_originate&quot;,5,SWIGTYPE_p_switch_state_handler_table_t);
+    }
+  }
</ins><span class="cx">   result = (int)(arg1)-&gt;originate(arg2,arg3,arg4,arg5);
</span><span class="cx">   SWIG_arg=0;
</span><span class="cx">   lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
</span><span class="lines">@@ -5653,199 +4628,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_CoreSession_originate__SWIG_1(lua_State* L) {
-  int SWIG_arg = -1;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  CoreSession *arg2 = (CoreSession *) 0 ;
-  char *arg3 = (char *) 0 ;
-  int arg4 ;
-  int result;
-  
-  SWIG_check_num_args(&quot;originate&quot;,4,4)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;originate&quot;,1,&quot;CoreSession *&quot;);
-  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg(&quot;originate&quot;,2,&quot;CoreSession *&quot;);
-  if(!lua_isstring(L,3)) SWIG_fail_arg(&quot;originate&quot;,3,&quot;char *&quot;);
-  if(!lua_isnumber(L,4)) SWIG_fail_arg(&quot;originate&quot;,4,&quot;int&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
-    SWIG_fail_ptr(&quot;CoreSession_originate&quot;,1,SWIGTYPE_p_CoreSession);
-  }
-  
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&amp;arg2,SWIGTYPE_p_CoreSession,0))){
-    SWIG_fail_ptr(&quot;CoreSession_originate&quot;,2,SWIGTYPE_p_CoreSession);
-  }
-  
-  arg3 = (char *)lua_tostring(L, 3);
-  arg4 = (int)lua_tonumber(L, 4);
-  result = (int)(arg1)-&gt;originate(arg2,arg3,arg4);
-  SWIG_arg=0;
-  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_CoreSession_originate__SWIG_2(lua_State* L) {
-  int SWIG_arg = -1;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  CoreSession *arg2 = (CoreSession *) 0 ;
-  char *arg3 = (char *) 0 ;
-  int result;
-  
-  SWIG_check_num_args(&quot;originate&quot;,3,3)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;originate&quot;,1,&quot;CoreSession *&quot;);
-  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg(&quot;originate&quot;,2,&quot;CoreSession *&quot;);
-  if(!lua_isstring(L,3)) SWIG_fail_arg(&quot;originate&quot;,3,&quot;char *&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
-    SWIG_fail_ptr(&quot;CoreSession_originate&quot;,1,SWIGTYPE_p_CoreSession);
-  }
-  
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&amp;arg2,SWIGTYPE_p_CoreSession,0))){
-    SWIG_fail_ptr(&quot;CoreSession_originate&quot;,2,SWIGTYPE_p_CoreSession);
-  }
-  
-  arg3 = (char *)lua_tostring(L, 3);
-  result = (int)(arg1)-&gt;originate(arg2,arg3);
-  SWIG_arg=0;
-  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_CoreSession_originate(lua_State* L) {
-  int argc;
-  int argv[6]={
-    1,2,3,4,5,6
-  };
-  
-  argc = lua_gettop(L);
-  if (argc == 3) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        void *ptr;
-        if (SWIG_isptrtype(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-          _v = 0;
-        } else {
-          _v = 1;
-        }
-      }
-      if (_v) {
-        {
-          _v = lua_isstring(L,argv[2]);
-        }
-        if (_v) {
-          return _wrap_CoreSession_originate__SWIG_2(L);
-        }
-      }
-    }
-  }
-  if (argc == 4) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        void *ptr;
-        if (SWIG_isptrtype(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-          _v = 0;
-        } else {
-          _v = 1;
-        }
-      }
-      if (_v) {
-        {
-          _v = lua_isstring(L,argv[2]);
-        }
-        if (_v) {
-          {
-            _v = lua_isnumber(L,argv[3]);
-          }
-          if (_v) {
-            return _wrap_CoreSession_originate__SWIG_1(L);
-          }
-        }
-      }
-    }
-  }
-  if (argc == 5) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        void *ptr;
-        if (SWIG_isptrtype(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-          _v = 0;
-        } else {
-          _v = 1;
-        }
-      }
-      if (_v) {
-        {
-          _v = lua_isstring(L,argv[2]);
-        }
-        if (_v) {
-          {
-            _v = lua_isnumber(L,argv[3]);
-          }
-          if (_v) {
-            {
-              void *ptr;
-              if (SWIG_isptrtype(L,argv[4])==0 || SWIG_ConvertPtr(L,argv[4], (void **) &amp;ptr, SWIGTYPE_p_switch_state_handler_table_t, 0)) {
-                _v = 0;
-              } else {
-                _v = 1;
-              }
-            }
-            if (_v) {
-              return _wrap_CoreSession_originate__SWIG_0(L);
-            }
-          }
-        }
-      }
-    }
-  }
-  
-  lua_pushstring(L,&quot;No matching function for overloaded 'CoreSession_originate'&quot;);
-  lua_error(L);return 0;
-}
-
-
</del><span class="cx"> static int _wrap_CoreSession_destroy(lua_State* L) {
</span><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -6220,87 +5002,32 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_CoreSession_transfer__SWIG_0(lua_State* L) {
</del><ins>+static int _wrap_CoreSession_transfer(lua_State* L) {
</ins><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  char *arg3 = (char *) 0 ;
-  char *arg4 = (char *) 0 ;
</del><ins>+  char *arg3 = (char *) NULL ;
+  char *arg4 = (char *) NULL ;
</ins><span class="cx">   int result;
</span><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;transfer&quot;,4,4)
</del><ins>+  SWIG_check_num_args(&quot;transfer&quot;,2,4)
</ins><span class="cx">   if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;transfer&quot;,1,&quot;CoreSession *&quot;);
</span><span class="cx">   if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;transfer&quot;,2,&quot;char *&quot;);
</span><del>-  if(!lua_isstring(L,3)) SWIG_fail_arg(&quot;transfer&quot;,3,&quot;char *&quot;);
-  if(!lua_isstring(L,4)) SWIG_fail_arg(&quot;transfer&quot;,4,&quot;char *&quot;);
</del><ins>+  if(lua_gettop(L)&gt;=3 &amp;&amp; !lua_isstring(L,3)) SWIG_fail_arg(&quot;transfer&quot;,3,&quot;char *&quot;);
+  if(lua_gettop(L)&gt;=4 &amp;&amp; !lua_isstring(L,4)) SWIG_fail_arg(&quot;transfer&quot;,4,&quot;char *&quot;);
</ins><span class="cx">   
</span><span class="cx">   if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
</span><span class="cx">     SWIG_fail_ptr(&quot;CoreSession_transfer&quot;,1,SWIGTYPE_p_CoreSession);
</span><span class="cx">   }
</span><span class="cx">   
</span><span class="cx">   arg2 = (char *)lua_tostring(L, 2);
</span><del>-  arg3 = (char *)lua_tostring(L, 3);
-  arg4 = (char *)lua_tostring(L, 4);
-  result = (int)(arg1)-&gt;transfer(arg2,arg3,arg4);
-  SWIG_arg=0;
-  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_CoreSession_transfer__SWIG_1(lua_State* L) {
-  int SWIG_arg = -1;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  char *arg3 = (char *) 0 ;
-  int result;
-  
-  SWIG_check_num_args(&quot;transfer&quot;,3,3)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;transfer&quot;,1,&quot;CoreSession *&quot;);
-  if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;transfer&quot;,2,&quot;char *&quot;);
-  if(!lua_isstring(L,3)) SWIG_fail_arg(&quot;transfer&quot;,3,&quot;char *&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
-    SWIG_fail_ptr(&quot;CoreSession_transfer&quot;,1,SWIGTYPE_p_CoreSession);
</del><ins>+  if(lua_gettop(L)&gt;=3){
+    arg3 = (char *)lua_tostring(L, 3);
</ins><span class="cx">   }
</span><del>-  
-  arg2 = (char *)lua_tostring(L, 2);
-  arg3 = (char *)lua_tostring(L, 3);
-  result = (int)(arg1)-&gt;transfer(arg2,arg3);
-  SWIG_arg=0;
-  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_CoreSession_transfer__SWIG_2(lua_State* L) {
-  int SWIG_arg = -1;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  int result;
-  
-  SWIG_check_num_args(&quot;transfer&quot;,2,2)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;transfer&quot;,1,&quot;CoreSession *&quot;);
-  if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;transfer&quot;,2,&quot;char *&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
-    SWIG_fail_ptr(&quot;CoreSession_transfer&quot;,1,SWIGTYPE_p_CoreSession);
</del><ins>+  if(lua_gettop(L)&gt;=4){
+    arg4 = (char *)lua_tostring(L, 4);
</ins><span class="cx">   }
</span><del>-  
-  arg2 = (char *)lua_tostring(L, 2);
-  result = (int)(arg1)-&gt;transfer(arg2);
</del><ins>+  result = (int)(arg1)-&gt;transfer(arg2,arg3,arg4);
</ins><span class="cx">   SWIG_arg=0;
</span><span class="cx">   lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
</span><span class="cx">   return SWIG_arg;
</span><span class="lines">@@ -6313,91 +5040,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_CoreSession_transfer(lua_State* L) {
-  int argc;
-  int argv[5]={
-    1,2,3,4,5
-  };
-  
-  argc = lua_gettop(L);
-  if (argc == 2) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        return _wrap_CoreSession_transfer__SWIG_2(L);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        {
-          _v = lua_isstring(L,argv[2]);
-        }
-        if (_v) {
-          return _wrap_CoreSession_transfer__SWIG_1(L);
-        }
-      }
-    }
-  }
-  if (argc == 4) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        {
-          _v = lua_isstring(L,argv[2]);
-        }
-        if (_v) {
-          {
-            _v = lua_isstring(L,argv[3]);
-          }
-          if (_v) {
-            return _wrap_CoreSession_transfer__SWIG_0(L);
-          }
-        }
-      }
-    }
-  }
-  
-  lua_pushstring(L,&quot;No matching function for overloaded 'CoreSession_transfer'&quot;);
-  lua_error(L);return 0;
-}
-
-
</del><span class="cx"> static int _wrap_CoreSession_read(lua_State* L) {
</span><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -6438,7 +5080,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_CoreSession_playAndGetDigits__SWIG_0(lua_State* L) {
</del><ins>+static int _wrap_CoreSession_playAndGetDigits(lua_State* L) {
</ins><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   int arg2 ;
</span><span class="lines">@@ -6449,10 +5091,10 @@
</span><span class="cx">   char *arg7 = (char *) 0 ;
</span><span class="cx">   char *arg8 = (char *) 0 ;
</span><span class="cx">   char *arg9 = (char *) 0 ;
</span><del>-  char *arg10 = (char *) 0 ;
</del><ins>+  char *arg10 = (char *) NULL ;
</ins><span class="cx">   char *result = 0 ;
</span><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;playAndGetDigits&quot;,10,10)
</del><ins>+  SWIG_check_num_args(&quot;playAndGetDigits&quot;,9,10)
</ins><span class="cx">   if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;playAndGetDigits&quot;,1,&quot;CoreSession *&quot;);
</span><span class="cx">   if(!lua_isnumber(L,2)) SWIG_fail_arg(&quot;playAndGetDigits&quot;,2,&quot;int&quot;);
</span><span class="cx">   if(!lua_isnumber(L,3)) SWIG_fail_arg(&quot;playAndGetDigits&quot;,3,&quot;int&quot;);
</span><span class="lines">@@ -6462,7 +5104,7 @@
</span><span class="cx">   if(!lua_isstring(L,7)) SWIG_fail_arg(&quot;playAndGetDigits&quot;,7,&quot;char *&quot;);
</span><span class="cx">   if(!lua_isstring(L,8)) SWIG_fail_arg(&quot;playAndGetDigits&quot;,8,&quot;char *&quot;);
</span><span class="cx">   if(!lua_isstring(L,9)) SWIG_fail_arg(&quot;playAndGetDigits&quot;,9,&quot;char *&quot;);
</span><del>-  if(!lua_isstring(L,10)) SWIG_fail_arg(&quot;playAndGetDigits&quot;,10,&quot;char const *&quot;);
</del><ins>+  if(lua_gettop(L)&gt;=10 &amp;&amp; !lua_isstring(L,10)) SWIG_fail_arg(&quot;playAndGetDigits&quot;,10,&quot;char const *&quot;);
</ins><span class="cx">   
</span><span class="cx">   if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
</span><span class="cx">     SWIG_fail_ptr(&quot;CoreSession_playAndGetDigits&quot;,1,SWIGTYPE_p_CoreSession);
</span><span class="lines">@@ -6476,7 +5118,9 @@
</span><span class="cx">   arg7 = (char *)lua_tostring(L, 7);
</span><span class="cx">   arg8 = (char *)lua_tostring(L, 8);
</span><span class="cx">   arg9 = (char *)lua_tostring(L, 9);
</span><del>-  arg10 = (char *)lua_tostring(L, 10);
</del><ins>+  if(lua_gettop(L)&gt;=10){
+    arg10 = (char *)lua_tostring(L, 10);
+  }
</ins><span class="cx">   result = (char *)(arg1)-&gt;playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,(char const *)arg10);
</span><span class="cx">   SWIG_arg=0;
</span><span class="cx">   lua_pushstring(L,(const char*)result); SWIG_arg++;
</span><span class="lines">@@ -6490,199 +5134,26 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_CoreSession_playAndGetDigits__SWIG_1(lua_State* L) {
</del><ins>+static int _wrap_CoreSession_streamFile(lua_State* L) {
</ins><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><del>-  int arg2 ;
-  int arg3 ;
-  int arg4 ;
-  int arg5 ;
-  char *arg6 = (char *) 0 ;
-  char *arg7 = (char *) 0 ;
-  char *arg8 = (char *) 0 ;
-  char *arg9 = (char *) 0 ;
-  char *result = 0 ;
-  
-  SWIG_check_num_args(&quot;playAndGetDigits&quot;,9,9)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;playAndGetDigits&quot;,1,&quot;CoreSession *&quot;);
-  if(!lua_isnumber(L,2)) SWIG_fail_arg(&quot;playAndGetDigits&quot;,2,&quot;int&quot;);
-  if(!lua_isnumber(L,3)) SWIG_fail_arg(&quot;playAndGetDigits&quot;,3,&quot;int&quot;);
-  if(!lua_isnumber(L,4)) SWIG_fail_arg(&quot;playAndGetDigits&quot;,4,&quot;int&quot;);
-  if(!lua_isnumber(L,5)) SWIG_fail_arg(&quot;playAndGetDigits&quot;,5,&quot;int&quot;);
-  if(!lua_isstring(L,6)) SWIG_fail_arg(&quot;playAndGetDigits&quot;,6,&quot;char *&quot;);
-  if(!lua_isstring(L,7)) SWIG_fail_arg(&quot;playAndGetDigits&quot;,7,&quot;char *&quot;);
-  if(!lua_isstring(L,8)) SWIG_fail_arg(&quot;playAndGetDigits&quot;,8,&quot;char *&quot;);
-  if(!lua_isstring(L,9)) SWIG_fail_arg(&quot;playAndGetDigits&quot;,9,&quot;char *&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
-    SWIG_fail_ptr(&quot;CoreSession_playAndGetDigits&quot;,1,SWIGTYPE_p_CoreSession);
-  }
-  
-  arg2 = (int)lua_tonumber(L, 2);
-  arg3 = (int)lua_tonumber(L, 3);
-  arg4 = (int)lua_tonumber(L, 4);
-  arg5 = (int)lua_tonumber(L, 5);
-  arg6 = (char *)lua_tostring(L, 6);
-  arg7 = (char *)lua_tostring(L, 7);
-  arg8 = (char *)lua_tostring(L, 8);
-  arg9 = (char *)lua_tostring(L, 9);
-  result = (char *)(arg1)-&gt;playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
-  SWIG_arg=0;
-  lua_pushstring(L,(const char*)result); SWIG_arg++;
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_CoreSession_playAndGetDigits(lua_State* L) {
-  int argc;
-  int argv[11]={
-    1,2,3,4,5,6,7,8,9,10,11
-  };
-  
-  argc = lua_gettop(L);
-  if (argc == 9) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isnumber(L,argv[1]);
-      }
-      if (_v) {
-        {
-          _v = lua_isnumber(L,argv[2]);
-        }
-        if (_v) {
-          {
-            _v = lua_isnumber(L,argv[3]);
-          }
-          if (_v) {
-            {
-              _v = lua_isnumber(L,argv[4]);
-            }
-            if (_v) {
-              {
-                _v = lua_isstring(L,argv[5]);
-              }
-              if (_v) {
-                {
-                  _v = lua_isstring(L,argv[6]);
-                }
-                if (_v) {
-                  {
-                    _v = lua_isstring(L,argv[7]);
-                  }
-                  if (_v) {
-                    {
-                      _v = lua_isstring(L,argv[8]);
-                    }
-                    if (_v) {
-                      return _wrap_CoreSession_playAndGetDigits__SWIG_1(L);
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-  if (argc == 10) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isnumber(L,argv[1]);
-      }
-      if (_v) {
-        {
-          _v = lua_isnumber(L,argv[2]);
-        }
-        if (_v) {
-          {
-            _v = lua_isnumber(L,argv[3]);
-          }
-          if (_v) {
-            {
-              _v = lua_isnumber(L,argv[4]);
-            }
-            if (_v) {
-              {
-                _v = lua_isstring(L,argv[5]);
-              }
-              if (_v) {
-                {
-                  _v = lua_isstring(L,argv[6]);
-                }
-                if (_v) {
-                  {
-                    _v = lua_isstring(L,argv[7]);
-                  }
-                  if (_v) {
-                    {
-                      _v = lua_isstring(L,argv[8]);
-                    }
-                    if (_v) {
-                      {
-                        _v = lua_isstring(L,argv[9]);
-                      }
-                      if (_v) {
-                        return _wrap_CoreSession_playAndGetDigits__SWIG_0(L);
-                      }
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-  
-  lua_pushstring(L,&quot;No matching function for overloaded 'CoreSession_playAndGetDigits'&quot;);
-  lua_error(L);return 0;
-}
-
-
-static int _wrap_CoreSession_streamFile__SWIG_0(lua_State* L) {
-  int SWIG_arg = -1;
-  CoreSession *arg1 = (CoreSession *) 0 ;
</del><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  int arg3 ;
</del><ins>+  int arg3 = (int) 0 ;
</ins><span class="cx">   int result;
</span><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;streamFile&quot;,3,3)
</del><ins>+  SWIG_check_num_args(&quot;streamFile&quot;,2,3)
</ins><span class="cx">   if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;streamFile&quot;,1,&quot;CoreSession *&quot;);
</span><span class="cx">   if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;streamFile&quot;,2,&quot;char *&quot;);
</span><del>-  if(!lua_isnumber(L,3)) SWIG_fail_arg(&quot;streamFile&quot;,3,&quot;int&quot;);
</del><ins>+  if(lua_gettop(L)&gt;=3 &amp;&amp; !lua_isnumber(L,3)) SWIG_fail_arg(&quot;streamFile&quot;,3,&quot;int&quot;);
</ins><span class="cx">   
</span><span class="cx">   if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
</span><span class="cx">     SWIG_fail_ptr(&quot;CoreSession_streamFile&quot;,1,SWIGTYPE_p_CoreSession);
</span><span class="cx">   }
</span><span class="cx">   
</span><span class="cx">   arg2 = (char *)lua_tostring(L, 2);
</span><del>-  arg3 = (int)lua_tonumber(L, 3);
</del><ins>+  if(lua_gettop(L)&gt;=3){
+    arg3 = (int)lua_tonumber(L, 3);
+  }
</ins><span class="cx">   result = (int)(arg1)-&gt;streamFile(arg2,arg3);
</span><span class="cx">   SWIG_arg=0;
</span><span class="cx">   lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
</span><span class="lines">@@ -6696,108 +5167,26 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_CoreSession_streamFile__SWIG_1(lua_State* L) {
</del><ins>+static int _wrap_CoreSession_sleep(lua_State* L) {
</ins><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><del>-  char *arg2 = (char *) 0 ;
-  int result;
-  
-  SWIG_check_num_args(&quot;streamFile&quot;,2,2)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;streamFile&quot;,1,&quot;CoreSession *&quot;);
-  if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;streamFile&quot;,2,&quot;char *&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
-    SWIG_fail_ptr(&quot;CoreSession_streamFile&quot;,1,SWIGTYPE_p_CoreSession);
-  }
-  
-  arg2 = (char *)lua_tostring(L, 2);
-  result = (int)(arg1)-&gt;streamFile(arg2);
-  SWIG_arg=0;
-  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_CoreSession_streamFile(lua_State* L) {
-  int argc;
-  int argv[4]={
-    1,2,3,4
-  };
-  
-  argc = lua_gettop(L);
-  if (argc == 2) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        return _wrap_CoreSession_streamFile__SWIG_1(L);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        {
-          _v = lua_isnumber(L,argv[2]);
-        }
-        if (_v) {
-          return _wrap_CoreSession_streamFile__SWIG_0(L);
-        }
-      }
-    }
-  }
-  
-  lua_pushstring(L,&quot;No matching function for overloaded 'CoreSession_streamFile'&quot;);
-  lua_error(L);return 0;
-}
-
-
-static int _wrap_CoreSession_sleep__SWIG_0(lua_State* L) {
-  int SWIG_arg = -1;
-  CoreSession *arg1 = (CoreSession *) 0 ;
</del><span class="cx">   int arg2 ;
</span><del>-  int arg3 ;
</del><ins>+  int arg3 = (int) 0 ;
</ins><span class="cx">   int result;
</span><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;sleep&quot;,3,3)
</del><ins>+  SWIG_check_num_args(&quot;sleep&quot;,2,3)
</ins><span class="cx">   if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;sleep&quot;,1,&quot;CoreSession *&quot;);
</span><span class="cx">   if(!lua_isnumber(L,2)) SWIG_fail_arg(&quot;sleep&quot;,2,&quot;int&quot;);
</span><del>-  if(!lua_isnumber(L,3)) SWIG_fail_arg(&quot;sleep&quot;,3,&quot;int&quot;);
</del><ins>+  if(lua_gettop(L)&gt;=3 &amp;&amp; !lua_isnumber(L,3)) SWIG_fail_arg(&quot;sleep&quot;,3,&quot;int&quot;);
</ins><span class="cx">   
</span><span class="cx">   if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
</span><span class="cx">     SWIG_fail_ptr(&quot;CoreSession_sleep&quot;,1,SWIGTYPE_p_CoreSession);
</span><span class="cx">   }
</span><span class="cx">   
</span><span class="cx">   arg2 = (int)lua_tonumber(L, 2);
</span><del>-  arg3 = (int)lua_tonumber(L, 3);
</del><ins>+  if(lua_gettop(L)&gt;=3){
+    arg3 = (int)lua_tonumber(L, 3);
+  }
</ins><span class="cx">   result = (int)(arg1)-&gt;sleep(arg2,arg3);
</span><span class="cx">   SWIG_arg=0;
</span><span class="cx">   lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
</span><span class="lines">@@ -6811,90 +5200,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_CoreSession_sleep__SWIG_1(lua_State* L) {
-  int SWIG_arg = -1;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  int arg2 ;
-  int result;
-  
-  SWIG_check_num_args(&quot;sleep&quot;,2,2)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;sleep&quot;,1,&quot;CoreSession *&quot;);
-  if(!lua_isnumber(L,2)) SWIG_fail_arg(&quot;sleep&quot;,2,&quot;int&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
-    SWIG_fail_ptr(&quot;CoreSession_sleep&quot;,1,SWIGTYPE_p_CoreSession);
-  }
-  
-  arg2 = (int)lua_tonumber(L, 2);
-  result = (int)(arg1)-&gt;sleep(arg2);
-  SWIG_arg=0;
-  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_CoreSession_sleep(lua_State* L) {
-  int argc;
-  int argv[4]={
-    1,2,3,4
-  };
-  
-  argc = lua_gettop(L);
-  if (argc == 2) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isnumber(L,argv[1]);
-      }
-      if (_v) {
-        return _wrap_CoreSession_sleep__SWIG_1(L);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isnumber(L,argv[1]);
-      }
-      if (_v) {
-        {
-          _v = lua_isnumber(L,argv[2]);
-        }
-        if (_v) {
-          return _wrap_CoreSession_sleep__SWIG_0(L);
-        }
-      }
-    }
-  }
-  
-  lua_pushstring(L,&quot;No matching function for overloaded 'CoreSession_sleep'&quot;);
-  lua_error(L);return 0;
-}
-
-
</del><span class="cx"> static int _wrap_CoreSession_flushEvents(lua_State* L) {
</span><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -7131,23 +5436,25 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_CoreSession_execute__SWIG_0(lua_State* L) {
</del><ins>+static int _wrap_CoreSession_execute(lua_State* L) {
</ins><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  char *arg3 = (char *) 0 ;
</del><ins>+  char *arg3 = (char *) NULL ;
</ins><span class="cx">   
</span><del>-  SWIG_check_num_args(&quot;execute&quot;,3,3)
</del><ins>+  SWIG_check_num_args(&quot;execute&quot;,2,3)
</ins><span class="cx">   if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;execute&quot;,1,&quot;CoreSession *&quot;);
</span><span class="cx">   if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;execute&quot;,2,&quot;char const *&quot;);
</span><del>-  if(!lua_isstring(L,3)) SWIG_fail_arg(&quot;execute&quot;,3,&quot;char const *&quot;);
</del><ins>+  if(lua_gettop(L)&gt;=3 &amp;&amp; !lua_isstring(L,3)) SWIG_fail_arg(&quot;execute&quot;,3,&quot;char const *&quot;);
</ins><span class="cx">   
</span><span class="cx">   if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
</span><span class="cx">     SWIG_fail_ptr(&quot;CoreSession_execute&quot;,1,SWIGTYPE_p_CoreSession);
</span><span class="cx">   }
</span><span class="cx">   
</span><span class="cx">   arg2 = (char *)lua_tostring(L, 2);
</span><del>-  arg3 = (char *)lua_tostring(L, 3);
</del><ins>+  if(lua_gettop(L)&gt;=3){
+    arg3 = (char *)lua_tostring(L, 3);
+  }
</ins><span class="cx">   (arg1)-&gt;execute((char const *)arg2,(char const *)arg3);
</span><span class="cx">   SWIG_arg=0;
</span><span class="cx">   
</span><span class="lines">@@ -7161,89 +5468,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-static int _wrap_CoreSession_execute__SWIG_1(lua_State* L) {
-  int SWIG_arg = -1;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  
-  SWIG_check_num_args(&quot;execute&quot;,2,2)
-  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg(&quot;execute&quot;,1,&quot;CoreSession *&quot;);
-  if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;execute&quot;,2,&quot;char const *&quot;);
-  
-  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&amp;arg1,SWIGTYPE_p_CoreSession,0))){
-    SWIG_fail_ptr(&quot;CoreSession_execute&quot;,1,SWIGTYPE_p_CoreSession);
-  }
-  
-  arg2 = (char *)lua_tostring(L, 2);
-  (arg1)-&gt;execute((char const *)arg2);
-  SWIG_arg=0;
-  
-  return SWIG_arg;
-  
-  if(0) SWIG_fail;
-  
-fail:
-  lua_error(L);
-  return SWIG_arg;
-}
-
-
-static int _wrap_CoreSession_execute(lua_State* L) {
-  int argc;
-  int argv[4]={
-    1,2,3,4
-  };
-  
-  argc = lua_gettop(L);
-  if (argc == 2) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        return _wrap_CoreSession_execute__SWIG_1(L);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    {
-      void *ptr;
-      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &amp;ptr, SWIGTYPE_p_CoreSession, 0)) {
-        _v = 0;
-      } else {
-        _v = 1;
-      }
-    }
-    if (_v) {
-      {
-        _v = lua_isstring(L,argv[1]);
-      }
-      if (_v) {
-        {
-          _v = lua_isstring(L,argv[2]);
-        }
-        if (_v) {
-          return _wrap_CoreSession_execute__SWIG_0(L);
-        }
-      }
-    }
-  }
-  
-  lua_pushstring(L,&quot;No matching function for overloaded 'CoreSession_execute'&quot;);
-  lua_error(L);return 0;
-}
-
-
</del><span class="cx"> static int _wrap_CoreSession_sendEvent(lua_State* L) {
</span><span class="cx">   int SWIG_arg = -1;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -8703,7 +6927,6 @@
</span><span class="cx"> static swig_type_info _swigt__p_switch_channel_state_t = {&quot;_p_switch_channel_state_t&quot;, &quot;switch_channel_state_t *&quot;, 0, 0, (void*)0, 0};
</span><span class="cx"> static swig_type_info _swigt__p_switch_channel_t = {&quot;_p_switch_channel_t&quot;, &quot;switch_channel_t *&quot;, 0, 0, (void*)0, 0};
</span><span class="cx"> static swig_type_info _swigt__p_switch_core_session_t = {&quot;_p_switch_core_session_t&quot;, &quot;switch_core_session_t *&quot;, 0, 0, (void*)0, 0};
</span><del>-static swig_type_info _swigt__p_switch_event_node_t = {&quot;_p_switch_event_node_t&quot;, &quot;switch_event_node_t *&quot;, 0, 0, (void*)0, 0};
</del><span class="cx"> static swig_type_info _swigt__p_switch_event_t = {&quot;_p_switch_event_t&quot;, &quot;switch_event_t *&quot;, 0, 0, (void*)0, 0};
</span><span class="cx"> static swig_type_info _swigt__p_switch_event_types_t = {&quot;_p_switch_event_types_t&quot;, &quot;switch_event_types_t *&quot;, 0, 0, (void*)0, 0};
</span><span class="cx"> static swig_type_info _swigt__p_switch_input_args_t = {&quot;_p_switch_input_args_t&quot;, &quot;switch_input_args_t *&quot;, 0, 0, (void*)0, 0};
</span><span class="lines">@@ -8732,7 +6955,6 @@
</span><span class="cx">   &amp;_swigt__p_switch_channel_state_t,
</span><span class="cx">   &amp;_swigt__p_switch_channel_t,
</span><span class="cx">   &amp;_swigt__p_switch_core_session_t,
</span><del>-  &amp;_swigt__p_switch_event_node_t,
</del><span class="cx">   &amp;_swigt__p_switch_event_t,
</span><span class="cx">   &amp;_swigt__p_switch_event_types_t,
</span><span class="cx">   &amp;_swigt__p_switch_input_args_t,
</span><span class="lines">@@ -8761,7 +6983,6 @@
</span><span class="cx"> static swig_cast_info _swigc__p_switch_channel_state_t[] = {  {&amp;_swigt__p_switch_channel_state_t, 0, 0, 0},{0, 0, 0, 0}};
</span><span class="cx"> static swig_cast_info _swigc__p_switch_channel_t[] = {  {&amp;_swigt__p_switch_channel_t, 0, 0, 0},{0, 0, 0, 0}};
</span><span class="cx"> static swig_cast_info _swigc__p_switch_core_session_t[] = {  {&amp;_swigt__p_switch_core_session_t, 0, 0, 0},{0, 0, 0, 0}};
</span><del>-static swig_cast_info _swigc__p_switch_event_node_t[] = {  {&amp;_swigt__p_switch_event_node_t, 0, 0, 0},{0, 0, 0, 0}};
</del><span class="cx"> static swig_cast_info _swigc__p_switch_event_t[] = {  {&amp;_swigt__p_switch_event_t, 0, 0, 0},{0, 0, 0, 0}};
</span><span class="cx"> static swig_cast_info _swigc__p_switch_event_types_t[] = {  {&amp;_swigt__p_switch_event_types_t, 0, 0, 0},{0, 0, 0, 0}};
</span><span class="cx"> static swig_cast_info _swigc__p_switch_input_args_t[] = {  {&amp;_swigt__p_switch_input_args_t, 0, 0, 0},{0, 0, 0, 0}};
</span><span class="lines">@@ -8790,7 +7011,6 @@
</span><span class="cx">   _swigc__p_switch_channel_state_t,
</span><span class="cx">   _swigc__p_switch_channel_t,
</span><span class="cx">   _swigc__p_switch_core_session_t,
</span><del>-  _swigc__p_switch_event_node_t,
</del><span class="cx">   _swigc__p_switch_event_t,
</span><span class="cx">   _swigc__p_switch_event_types_t,
</span><span class="cx">   _swigc__p_switch_input_args_t,
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_managedfreeswitch_wrapcxx"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx (17515 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx        2010-05-10 17:03:22 UTC (rev 17515)
+++ freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -7975,6 +7975,18 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_codec_reset(void * jarg1) {
+  int jresult ;
+  switch_codec_t *arg1 = (switch_codec_t *) 0 ;
+  switch_status_t result;
+  
+  arg1 = (switch_codec_t *)jarg1; 
+  result = (switch_status_t)switch_core_codec_reset(arg1);
+  jresult = result; 
+  return jresult;
+}
+
+
</ins><span class="cx"> SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_codec_encode(void * jarg1, void * jarg2, void * jarg3, unsigned long jarg4, unsigned long jarg5, void * jarg6, void * jarg7, void * jarg8, void * jarg9) {
</span><span class="cx">   int jresult ;
</span><span class="cx">   switch_codec_t *arg1 = (switch_codec_t *) 0 ;
</span><span class="lines">@@ -31030,29 +31042,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGEXPORT void SWIGSTDCALL CSharp_EventConsumer_node_set(void * jarg1, void * jarg2) {
-  EventConsumer *arg1 = (EventConsumer *) 0 ;
-  switch_event_node_t *arg2 = (switch_event_node_t *) 0 ;
-  
-  arg1 = (EventConsumer *)jarg1; 
-  arg2 = (switch_event_node_t *)jarg2; 
-  if (arg1) (arg1)-&gt;node = arg2;
-  
-}
-
-
-SWIGEXPORT void * SWIGSTDCALL CSharp_EventConsumer_node_get(void * jarg1) {
-  void * jresult ;
-  EventConsumer *arg1 = (EventConsumer *) 0 ;
-  switch_event_node_t *result = 0 ;
-  
-  arg1 = (EventConsumer *)jarg1; 
-  result = (switch_event_node_t *) ((arg1)-&gt;node);
-  jresult = (void *)result; 
-  return jresult;
-}
-
-
</del><span class="cx"> SWIGEXPORT void SWIGSTDCALL CSharp_EventConsumer_e_callback_set(void * jarg1, char * jarg2) {
</span><span class="cx">   EventConsumer *arg1 = (EventConsumer *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><span class="lines">@@ -31145,7 +31134,7 @@
</span><span class="cx"> 
</span><span class="cx"> SWIGEXPORT void * SWIGSTDCALL CSharp_new_EventConsumer(char * jarg1, char * jarg2) {
</span><span class="cx">   void * jresult ;
</span><del>-  char *arg1 = (char *) 0 ;
</del><ins>+  char *arg1 = (char *) NULL ;
</ins><span class="cx">   char *arg2 = (char *) &quot;&quot; ;
</span><span class="cx">   EventConsumer *result = 0 ;
</span><span class="cx">   
</span><span class="lines">@@ -31166,6 +31155,22 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+SWIGEXPORT int SWIGSTDCALL CSharp_EventConsumer_bind(void * jarg1, char * jarg2, char * jarg3) {
+  int jresult ;
+  EventConsumer *arg1 = (EventConsumer *) 0 ;
+  char *arg2 = (char *) 0 ;
+  char *arg3 = (char *) &quot;&quot; ;
+  int result;
+  
+  arg1 = (EventConsumer *)jarg1; 
+  arg2 = (char *)jarg2; 
+  arg3 = (char *)jarg3; 
+  result = (int)(arg1)-&gt;bind((char const *)arg2,(char const *)arg3);
+  jresult = result; 
+  return jresult;
+}
+
+
</ins><span class="cx"> SWIGEXPORT void * SWIGSTDCALL CSharp_EventConsumer_pop(void * jarg1, int jarg2) {
</span><span class="cx">   void * jresult ;
</span><span class="cx">   EventConsumer *arg1 = (EventConsumer *) 0 ;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_managedmanagedswigcs"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs (17515 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs        2010-05-10 17:03:22 UTC (rev 17515)
+++ freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -554,17 +554,6 @@
</span><span class="cx">     } 
</span><span class="cx">   }
</span><span class="cx"> 
</span><del>-  public SWIGTYPE_p_switch_event_node node {
-    set {
-      freeswitchPINVOKE.EventConsumer_node_set(swigCPtr, SWIGTYPE_p_switch_event_node.getCPtr(value));
-    } 
-    get {
-      IntPtr cPtr = freeswitchPINVOKE.EventConsumer_node_get(swigCPtr);
-      SWIGTYPE_p_switch_event_node ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_event_node(cPtr, false);
-      return ret;
-    } 
-  }
-
</del><span class="cx">   public string e_callback {
</span><span class="cx">     set {
</span><span class="cx">       freeswitchPINVOKE.EventConsumer_e_callback_set(swigCPtr, value);
</span><span class="lines">@@ -598,6 +587,11 @@
</span><span class="cx">   public EventConsumer(string event_name, string subclass_name) : this(freeswitchPINVOKE.new_EventConsumer(event_name, subclass_name), true) {
</span><span class="cx">   }
</span><span class="cx"> 
</span><ins>+  public int bind(string event_name, string subclass_name) {
+    int ret = freeswitchPINVOKE.EventConsumer_bind(swigCPtr, event_name, subclass_name);
+    return ret;
+  }
+
</ins><span class="cx">   public Event pop(int block) {
</span><span class="cx">     IntPtr cPtr = freeswitchPINVOKE.EventConsumer_pop(swigCPtr, block);
</span><span class="cx">     Event ret = (cPtr == IntPtr.Zero) ? null : new Event(cPtr, true);
</span><span class="lines">@@ -1644,6 +1638,11 @@
</span><span class="cx">     return ret;
</span><span class="cx">   }
</span><span class="cx"> 
</span><ins>+  public static switch_status_t switch_core_codec_reset(switch_codec codec) {
+    switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_codec_reset(switch_codec.getCPtr(codec));
+    return ret;
+  }
+
</ins><span class="cx">   public static switch_status_t switch_core_codec_encode(switch_codec codec, switch_codec other_codec, SWIGTYPE_p_void decoded_data, uint decoded_data_len, uint decoded_rate, SWIGTYPE_p_void encoded_data, SWIGTYPE_p_unsigned_long encoded_data_len, SWIGTYPE_p_unsigned_long encoded_rate, SWIGTYPE_p_unsigned_int flag) {
</span><span class="cx">     switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_codec_encode(switch_codec.getCPtr(codec), switch_codec.getCPtr(other_codec), SWIGTYPE_p_void.getCPtr(decoded_data), decoded_data_len, decoded_rate, SWIGTYPE_p_void.getCPtr(encoded_data), SWIGTYPE_p_unsigned_long.getCPtr(encoded_data_len), SWIGTYPE_p_unsigned_long.getCPtr(encoded_rate), SWIGTYPE_p_unsigned_int.getCPtr(flag));
</span><span class="cx">     return ret;
</span><span class="lines">@@ -7007,6 +7006,9 @@
</span><span class="cx">   [DllImport(&quot;mod_managed&quot;, EntryPoint=&quot;CSharp_switch_core_codec_copy&quot;)]
</span><span class="cx">   public static extern int switch_core_codec_copy(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3);
</span><span class="cx"> 
</span><ins>+  [DllImport(&quot;mod_managed&quot;, EntryPoint=&quot;CSharp_switch_core_codec_reset&quot;)]
+  public static extern int switch_core_codec_reset(HandleRef jarg1);
+
</ins><span class="cx">   [DllImport(&quot;mod_managed&quot;, EntryPoint=&quot;CSharp_switch_core_codec_encode&quot;)]
</span><span class="cx">   public static extern int switch_core_codec_encode(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3, uint jarg4, uint jarg5, HandleRef jarg6, HandleRef jarg7, HandleRef jarg8, HandleRef jarg9);
</span><span class="cx"> 
</span><span class="lines">@@ -12404,12 +12406,6 @@
</span><span class="cx">   [DllImport(&quot;mod_managed&quot;, EntryPoint=&quot;CSharp_EventConsumer_e_event_id_get&quot;)]
</span><span class="cx">   public static extern int EventConsumer_e_event_id_get(HandleRef jarg1);
</span><span class="cx"> 
</span><del>-  [DllImport(&quot;mod_managed&quot;, EntryPoint=&quot;CSharp_EventConsumer_node_set&quot;)]
-  public static extern void EventConsumer_node_set(HandleRef jarg1, HandleRef jarg2);
-
-  [DllImport(&quot;mod_managed&quot;, EntryPoint=&quot;CSharp_EventConsumer_node_get&quot;)]
-  public static extern IntPtr EventConsumer_node_get(HandleRef jarg1);
-
</del><span class="cx">   [DllImport(&quot;mod_managed&quot;, EntryPoint=&quot;CSharp_EventConsumer_e_callback_set&quot;)]
</span><span class="cx">   public static extern void EventConsumer_e_callback_set(HandleRef jarg1, string jarg2);
</span><span class="cx"> 
</span><span class="lines">@@ -12434,6 +12430,9 @@
</span><span class="cx">   [DllImport(&quot;mod_managed&quot;, EntryPoint=&quot;CSharp_delete_EventConsumer&quot;)]
</span><span class="cx">   public static extern void delete_EventConsumer(HandleRef jarg1);
</span><span class="cx"> 
</span><ins>+  [DllImport(&quot;mod_managed&quot;, EntryPoint=&quot;CSharp_EventConsumer_bind&quot;)]
+  public static extern int EventConsumer_bind(HandleRef jarg1, string jarg2, string jarg3);
+
</ins><span class="cx">   [DllImport(&quot;mod_managed&quot;, EntryPoint=&quot;CSharp_EventConsumer_pop&quot;)]
</span><span class="cx">   public static extern IntPtr EventConsumer_pop(HandleRef jarg1, int jarg2);
</span><span class="cx"> 
</span><span class="lines">@@ -16430,36 +16429,6 @@
</span><span class="cx"> using System;
</span><span class="cx"> using System.Runtime.InteropServices;
</span><span class="cx"> 
</span><del>-public class SWIGTYPE_p_switch_event_node {
-  private HandleRef swigCPtr;
-
-  internal SWIGTYPE_p_switch_event_node(IntPtr cPtr, bool futureUse) {
-    swigCPtr = new HandleRef(this, cPtr);
-  }
-
-  protected SWIGTYPE_p_switch_event_node() {
-    swigCPtr = new HandleRef(null, IntPtr.Zero);
-  }
-
-  internal static HandleRef getCPtr(SWIGTYPE_p_switch_event_node obj) {
-    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
-  }
-}
-
-}
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.35
- *
- * Do not make changes to this file unless you know what you are doing--modify
- * the SWIG interface file instead.
- * ----------------------------------------------------------------------------- */
-
-namespace FreeSWITCH.Native {
-
-using System;
-using System.Runtime.InteropServices;
-
</del><span class="cx"> public class SWIGTYPE_p_switch_event_types_t {
</span><span class="cx">   private HandleRef swigCPtr;
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_perlfreeswitchpm"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm (17515 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm        2010-05-10 17:03:22 UTC (rev 17515)
+++ freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -324,8 +324,6 @@
</span><span class="cx"> *swig_events_set = *freeswitchc::EventConsumer_events_set;
</span><span class="cx"> *swig_e_event_id_get = *freeswitchc::EventConsumer_e_event_id_get;
</span><span class="cx"> *swig_e_event_id_set = *freeswitchc::EventConsumer_e_event_id_set;
</span><del>-*swig_node_get = *freeswitchc::EventConsumer_node_get;
-*swig_node_set = *freeswitchc::EventConsumer_node_set;
</del><span class="cx"> *swig_e_callback_get = *freeswitchc::EventConsumer_e_callback_get;
</span><span class="cx"> *swig_e_callback_set = *freeswitchc::EventConsumer_e_callback_set;
</span><span class="cx"> *swig_e_subclass_name_get = *freeswitchc::EventConsumer_e_subclass_name_get;
</span><span class="lines">@@ -349,6 +347,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+*bind = *freeswitchc::EventConsumer_bind;
</ins><span class="cx"> *pop = *freeswitchc::EventConsumer_pop;
</span><span class="cx"> sub DISOWN {
</span><span class="cx">     my $self = shift;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_perlmod_perl_wrapcpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp (17515 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp        2010-05-10 17:03:22 UTC (rev 17515)
+++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -1462,20 +1462,19 @@
</span><span class="cx"> #define SWIGTYPE_p_switch_channel_state_t swig_types[13]
</span><span class="cx"> #define SWIGTYPE_p_switch_channel_t swig_types[14]
</span><span class="cx"> #define SWIGTYPE_p_switch_core_session_t swig_types[15]
</span><del>-#define SWIGTYPE_p_switch_event_node_t swig_types[16]
-#define SWIGTYPE_p_switch_event_t swig_types[17]
-#define SWIGTYPE_p_switch_event_types_t swig_types[18]
-#define SWIGTYPE_p_switch_input_args_t swig_types[19]
-#define SWIGTYPE_p_switch_input_type_t swig_types[20]
-#define SWIGTYPE_p_switch_priority_t swig_types[21]
-#define SWIGTYPE_p_switch_queue_t swig_types[22]
-#define SWIGTYPE_p_switch_state_handler_table_t swig_types[23]
-#define SWIGTYPE_p_switch_status_t swig_types[24]
-#define SWIGTYPE_p_switch_stream_handle_t swig_types[25]
-#define SWIGTYPE_p_uint32_t swig_types[26]
-#define SWIGTYPE_p_void swig_types[27]
-static swig_type_info *swig_types[29];
-static swig_module_info swig_module = {swig_types, 28, 0, 0, 0, 0};
</del><ins>+#define SWIGTYPE_p_switch_event_t swig_types[16]
+#define SWIGTYPE_p_switch_event_types_t swig_types[17]
+#define SWIGTYPE_p_switch_input_args_t swig_types[18]
+#define SWIGTYPE_p_switch_input_type_t swig_types[19]
+#define SWIGTYPE_p_switch_priority_t swig_types[20]
+#define SWIGTYPE_p_switch_queue_t swig_types[21]
+#define SWIGTYPE_p_switch_state_handler_table_t swig_types[22]
+#define SWIGTYPE_p_switch_status_t swig_types[23]
+#define SWIGTYPE_p_switch_stream_handle_t swig_types[24]
+#define SWIGTYPE_p_uint32_t swig_types[25]
+#define SWIGTYPE_p_void swig_types[26]
+static swig_type_info *swig_types[28];
+static swig_module_info swig_module = {swig_types, 27, 0, 0, 0, 0};
</ins><span class="cx"> #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&amp;swig_module, &amp;swig_module, name)
</span><span class="cx"> #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&amp;swig_module, &amp;swig_module, name)
</span><span class="cx"> 
</span><span class="lines">@@ -2351,11 +2350,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_API_execute__SWIG_0) {
</del><ins>+XS(_wrap_API_execute) {
</ins><span class="cx">   {
</span><span class="cx">     API *arg1 = (API *) 0 ;
</span><span class="cx">     char *arg2 = (char *) 0 ;
</span><del>-    char *arg3 = (char *) 0 ;
</del><ins>+    char *arg3 = (char *) NULL ;
</ins><span class="cx">     char *result = 0 ;
</span><span class="cx">     void *argp1 = 0 ;
</span><span class="cx">     int res1 = 0 ;
</span><span class="lines">@@ -2368,7 +2367,7 @@
</span><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 3) || (items &gt; 3)) {
</del><ins>+    if ((items &lt; 2) || (items &gt; 3)) {
</ins><span class="cx">       SWIG_croak(&quot;Usage: API_execute(self,command,data);&quot;);
</span><span class="cx">     }
</span><span class="cx">     res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_API, 0 |  0 );
</span><span class="lines">@@ -2381,11 +2380,13 @@
</span><span class="cx">       SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;API_execute&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</span><span class="cx">     }
</span><span class="cx">     arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</span><del>-    res3 = SWIG_AsCharPtrAndSize(ST(2), &amp;buf3, NULL, &amp;alloc3);
-    if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;API_execute&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+    if (items &gt; 2) {
+      res3 = SWIG_AsCharPtrAndSize(ST(2), &amp;buf3, NULL, &amp;alloc3);
+      if (!SWIG_IsOK(res3)) {
+        SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;API_execute&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+      }
+      arg3 = reinterpret_cast&lt; char * &gt;(buf3);
</ins><span class="cx">     }
</span><del>-    arg3 = reinterpret_cast&lt; char * &gt;(buf3);
</del><span class="cx">     result = (char *)(arg1)-&gt;execute((char const *)arg2,(char const *)arg3);
</span><span class="cx">     ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
</span><span class="cx">     
</span><span class="lines">@@ -2401,131 +2402,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_API_execute__SWIG_1) {
-  {
-    API *arg1 = (API *) 0 ;
-    char *arg2 = (char *) 0 ;
-    char *result = 0 ;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int res2 ;
-    char *buf2 = 0 ;
-    int alloc2 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 2) || (items &gt; 2)) {
-      SWIG_croak(&quot;Usage: API_execute(self,command);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_API, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;API_execute&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;API *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; API * &gt;(argp1);
-    res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;API_execute&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-    }
-    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-    result = (char *)(arg1)-&gt;execute((char const *)arg2);
-    ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    XSRETURN(argvi);
-  fail:
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_API_execute) {
-  dXSARGS;
-  
-  {
-    unsigned long _index = 0;
-    SWIG_TypeRank _rank = 0; 
-    if (items == 2) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_API, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 1;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_1:
-    
-    if (items == 3) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_API, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 2;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_2:
-    
-  dispatch:
-    switch(_index) {
-    case 1:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_API_execute__SWIG_1); return;
-    case 2:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_API_execute__SWIG_0); return;
-    }
-  }
-  
-  croak(&quot;No matching function for overloaded 'API_execute'&quot;);
-  XSRETURN(0);
-}
-
-
</del><span class="cx"> XS(_wrap_API_executeString) {
</span><span class="cx">   {
</span><span class="cx">     API *arg1 = (API *) 0 ;
</span><span class="lines">@@ -3039,10 +2915,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_new_DTMF__SWIG_0) {
</del><ins>+XS(_wrap_new_DTMF) {
</ins><span class="cx">   {
</span><span class="cx">     char arg1 ;
</span><del>-    uint32_t arg2 ;
</del><ins>+    uint32_t arg2 = (uint32_t) SWITCH_DEFAULT_DTMF_DURATION ;
</ins><span class="cx">     DTMF *result = 0 ;
</span><span class="cx">     char val1 ;
</span><span class="cx">     int ecode1 = 0 ;
</span><span class="lines">@@ -3051,7 +2927,7 @@
</span><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 2) || (items &gt; 2)) {
</del><ins>+    if ((items &lt; 1) || (items &gt; 2)) {
</ins><span class="cx">       SWIG_croak(&quot;Usage: new_DTMF(idigit,iduration);&quot;);
</span><span class="cx">     }
</span><span class="cx">     ecode1 = SWIG_AsVal_char SWIG_PERL_CALL_ARGS_2(ST(0), &amp;val1);
</span><span class="lines">@@ -3059,15 +2935,17 @@
</span><span class="cx">       SWIG_exception_fail(SWIG_ArgError(ecode1), &quot;in method '&quot; &quot;new_DTMF&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;char&quot;&quot;'&quot;);
</span><span class="cx">     } 
</span><span class="cx">     arg1 = static_cast&lt; char &gt;(val1);
</span><del>-    {
-      res2 = SWIG_ConvertPtr(ST(1), &amp;argp2, SWIGTYPE_p_uint32_t,  0 );
-      if (!SWIG_IsOK(res2)) {
-        SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;new_DTMF&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;uint32_t&quot;&quot;'&quot;); 
-      }  
-      if (!argp2) {
-        SWIG_exception_fail(SWIG_ValueError, &quot;invalid null reference &quot; &quot;in method '&quot; &quot;new_DTMF&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;uint32_t&quot;&quot;'&quot;);
-      } else {
-        arg2 = *(reinterpret_cast&lt; uint32_t * &gt;(argp2));
</del><ins>+    if (items &gt; 1) {
+      {
+        res2 = SWIG_ConvertPtr(ST(1), &amp;argp2, SWIGTYPE_p_uint32_t,  0 );
+        if (!SWIG_IsOK(res2)) {
+          SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;new_DTMF&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;uint32_t&quot;&quot;'&quot;); 
+        }  
+        if (!argp2) {
+          SWIG_exception_fail(SWIG_ValueError, &quot;invalid null reference &quot; &quot;in method '&quot; &quot;new_DTMF&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;uint32_t&quot;&quot;'&quot;);
+        } else {
+          arg2 = *(reinterpret_cast&lt; uint32_t * &gt;(argp2));
+        }
</ins><span class="cx">       }
</span><span class="cx">     }
</span><span class="cx">     result = (DTMF *)new DTMF(arg1,arg2);
</span><span class="lines">@@ -3081,107 +2959,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_new_DTMF__SWIG_1) {
-  {
-    char arg1 ;
-    DTMF *result = 0 ;
-    char val1 ;
-    int ecode1 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 1) || (items &gt; 1)) {
-      SWIG_croak(&quot;Usage: new_DTMF(idigit);&quot;);
-    }
-    ecode1 = SWIG_AsVal_char SWIG_PERL_CALL_ARGS_2(ST(0), &amp;val1);
-    if (!SWIG_IsOK(ecode1)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode1), &quot;in method '&quot; &quot;new_DTMF&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;char&quot;&quot;'&quot;);
-    } 
-    arg1 = static_cast&lt; char &gt;(val1);
-    result = (DTMF *)new DTMF(arg1);
-    ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_DTMF, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
-    
-    XSRETURN(argvi);
-  fail:
-    
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_new_DTMF) {
-  dXSARGS;
-  
-  {
-    unsigned long _index = 0;
-    SWIG_TypeRank _rank = 0; 
-    if (items == 1) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        {
-          int res = SWIG_AsVal_char SWIG_PERL_CALL_ARGS_2(ST(0), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 1;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_1:
-    
-    if (items == 2) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        {
-          int res = SWIG_AsVal_char SWIG_PERL_CALL_ARGS_2(ST(0), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(1), &amp;vptr, SWIGTYPE_p_uint32_t, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 2;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_2:
-    
-  dispatch:
-    switch(_index) {
-    case 1:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_DTMF__SWIG_1); return;
-    case 2:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_DTMF__SWIG_0); return;
-    }
-  }
-  
-  croak(&quot;No matching function for overloaded 'new_DTMF'&quot;);
-  XSRETURN(0);
-}
-
-
</del><span class="cx"> XS(_wrap_delete_DTMF) {
</span><span class="cx">   {
</span><span class="cx">     DTMF *arg1 = (DTMF *) 0 ;
</span><span class="lines">@@ -3606,7 +3383,7 @@
</span><span class="cx"> XS(_wrap_new_Event__SWIG_0) {
</span><span class="cx">   {
</span><span class="cx">     char *arg1 = (char *) 0 ;
</span><del>-    char *arg2 = (char *) 0 ;
</del><ins>+    char *arg2 = (char *) NULL ;
</ins><span class="cx">     Event *result = 0 ;
</span><span class="cx">     int res1 ;
</span><span class="cx">     char *buf1 = 0 ;
</span><span class="lines">@@ -3617,7 +3394,7 @@
</span><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 2) || (items &gt; 2)) {
</del><ins>+    if ((items &lt; 1) || (items &gt; 2)) {
</ins><span class="cx">       SWIG_croak(&quot;Usage: new_Event(type,subclass_name);&quot;);
</span><span class="cx">     }
</span><span class="cx">     res1 = SWIG_AsCharPtrAndSize(ST(0), &amp;buf1, NULL, &amp;alloc1);
</span><span class="lines">@@ -3625,11 +3402,13 @@
</span><span class="cx">       SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;new_Event&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</span><span class="cx">     }
</span><span class="cx">     arg1 = reinterpret_cast&lt; char * &gt;(buf1);
</span><del>-    res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;new_Event&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+    if (items &gt; 1) {
+      res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
+      if (!SWIG_IsOK(res2)) {
+        SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;new_Event&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+      }
+      arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</ins><span class="cx">     }
</span><del>-    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</del><span class="cx">     result = (Event *)new Event((char const *)arg1,(char const *)arg2);
</span><span class="cx">     ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
</span><span class="cx">     if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
</span><span class="lines">@@ -3645,37 +3424,8 @@
</span><span class="cx"> 
</span><span class="cx"> XS(_wrap_new_Event__SWIG_1) {
</span><span class="cx">   {
</span><del>-    char *arg1 = (char *) 0 ;
-    Event *result = 0 ;
-    int res1 ;
-    char *buf1 = 0 ;
-    int alloc1 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 1) || (items &gt; 1)) {
-      SWIG_croak(&quot;Usage: new_Event(type);&quot;);
-    }
-    res1 = SWIG_AsCharPtrAndSize(ST(0), &amp;buf1, NULL, &amp;alloc1);
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;new_Event&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-    }
-    arg1 = reinterpret_cast&lt; char * &gt;(buf1);
-    result = (Event *)new Event((char const *)arg1);
-    ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
-    if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
-    XSRETURN(argvi);
-  fail:
-    if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_new_Event__SWIG_2) {
-  {
</del><span class="cx">     switch_event_t *arg1 = (switch_event_t *) 0 ;
</span><del>-    int arg2 ;
</del><ins>+    int arg2 = (int) 0 ;
</ins><span class="cx">     Event *result = 0 ;
</span><span class="cx">     void *argp1 = 0 ;
</span><span class="cx">     int res1 = 0 ;
</span><span class="lines">@@ -3684,7 +3434,7 @@
</span><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 2) || (items &gt; 2)) {
</del><ins>+    if ((items &lt; 1) || (items &gt; 2)) {
</ins><span class="cx">       SWIG_croak(&quot;Usage: new_Event(wrap_me,free_me);&quot;);
</span><span class="cx">     }
</span><span class="cx">     res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_switch_event_t, 0 |  0 );
</span><span class="lines">@@ -3692,11 +3442,13 @@
</span><span class="cx">       SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;new_Event&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;switch_event_t *&quot;&quot;'&quot;); 
</span><span class="cx">     }
</span><span class="cx">     arg1 = reinterpret_cast&lt; switch_event_t * &gt;(argp1);
</span><del>-    ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &amp;val2);
-    if (!SWIG_IsOK(ecode2)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode2), &quot;in method '&quot; &quot;new_Event&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-    } 
-    arg2 = static_cast&lt; int &gt;(val2);
</del><ins>+    if (items &gt; 1) {
+      ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &amp;val2);
+      if (!SWIG_IsOK(ecode2)) {
+        SWIG_exception_fail(SWIG_ArgError(ecode2), &quot;in method '&quot; &quot;new_Event&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+      } 
+      arg2 = static_cast&lt; int &gt;(val2);
+    }
</ins><span class="cx">     result = (Event *)new Event(arg1,arg2);
</span><span class="cx">     ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
</span><span class="cx">     
</span><span class="lines">@@ -3710,41 +3462,13 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_new_Event__SWIG_3) {
-  {
-    switch_event_t *arg1 = (switch_event_t *) 0 ;
-    Event *result = 0 ;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 1) || (items &gt; 1)) {
-      SWIG_croak(&quot;Usage: new_Event(wrap_me);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_switch_event_t, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;new_Event&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;switch_event_t *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; switch_event_t * &gt;(argp1);
-    result = (Event *)new Event(arg1);
-    ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
-    
-    XSRETURN(argvi);
-  fail:
-    
-    SWIG_croak_null();
-  }
-}
-
-
</del><span class="cx"> XS(_wrap_new_Event) {
</span><span class="cx">   dXSARGS;
</span><span class="cx">   
</span><span class="cx">   {
</span><span class="cx">     unsigned long _index = 0;
</span><span class="cx">     SWIG_TypeRank _rank = 0; 
</span><del>-    if (items == 1) {
</del><ins>+    if ((items &gt;= 1) &amp;&amp; (items &lt;= 2)) {
</ins><span class="cx">       SWIG_TypeRank _ranki = 0;
</span><span class="cx">       SWIG_TypeRank _rankm = 0;
</span><span class="cx">       SWIG_TypeRank _pi = 1;
</span><span class="lines">@@ -3758,6 +3482,18 @@
</span><span class="cx">       _ranki += _v*_pi;
</span><span class="cx">       _rankm += _pi;
</span><span class="cx">       _pi *= SWIG_MAXCASTRANK;
</span><ins>+      if (items &gt; 1) {
+        {
+          {
+            int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL);
+            _v = SWIG_CheckState(res);
+          }
+        }
+        if (!_v) goto check_1;
+        _ranki += _v*_pi;
+        _rankm += _pi;
+        _pi *= SWIG_MAXCASTRANK;
+      }
</ins><span class="cx">       if (!_index || (_ranki &lt; _rank)) {
</span><span class="cx">         _rank = _ranki; _index = 1;
</span><span class="cx">         if (_rank == _rankm) goto dispatch;
</span><span class="lines">@@ -3765,7 +3501,7 @@
</span><span class="cx">     }
</span><span class="cx">   check_1:
</span><span class="cx">     
</span><del>-    if (items == 1) {
</del><ins>+    if ((items &gt;= 1) &amp;&amp; (items &lt;= 2)) {
</ins><span class="cx">       SWIG_TypeRank _ranki = 0;
</span><span class="cx">       SWIG_TypeRank _rankm = 0;
</span><span class="cx">       SWIG_TypeRank _pi = 1;
</span><span class="lines">@@ -3778,81 +3514,28 @@
</span><span class="cx">       _ranki += _v*_pi;
</span><span class="cx">       _rankm += _pi;
</span><span class="cx">       _pi *= SWIG_MAXCASTRANK;
</span><del>-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 2;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_2:
-    
-    if (items == 2) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_switch_event_t, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
</del><ins>+      if (items &gt; 1) {
</ins><span class="cx">         {
</span><del>-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL);
</del><ins>+          int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
</ins><span class="cx">           _v = SWIG_CheckState(res);
</span><span class="cx">         }
</span><ins>+        if (!_v) goto check_2;
+        _ranki += _v*_pi;
+        _rankm += _pi;
+        _pi *= SWIG_MAXCASTRANK;
</ins><span class="cx">       }
</span><del>-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
</del><span class="cx">       if (!_index || (_ranki &lt; _rank)) {
</span><del>-        _rank = _ranki; _index = 3;
</del><ins>+        _rank = _ranki; _index = 2;
</ins><span class="cx">         if (_rank == _rankm) goto dispatch;
</span><span class="cx">       }
</span><span class="cx">     }
</span><del>-  check_3:
</del><ins>+  check_2:
</ins><span class="cx">     
</span><del>-    if (items == 2) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(0), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_4;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_4;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 4;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_4:
-    
</del><span class="cx">   dispatch:
</span><span class="cx">     switch(_index) {
</span><span class="cx">     case 1:
</span><del>-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_Event__SWIG_3); return;
-    case 2:
</del><span class="cx">       ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_Event__SWIG_1); return;
</span><del>-    case 3:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_Event__SWIG_2); return;
-    case 4:
</del><ins>+    case 2:
</ins><span class="cx">       ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_Event__SWIG_0); return;
</span><span class="cx">     }
</span><span class="cx">   }
</span><span class="lines">@@ -3890,10 +3573,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_Event_serialize__SWIG_0) {
</del><ins>+XS(_wrap_Event_serialize) {
</ins><span class="cx">   {
</span><span class="cx">     Event *arg1 = (Event *) 0 ;
</span><del>-    char *arg2 = (char *) 0 ;
</del><ins>+    char *arg2 = (char *) NULL ;
</ins><span class="cx">     char *result = 0 ;
</span><span class="cx">     void *argp1 = 0 ;
</span><span class="cx">     int res1 = 0 ;
</span><span class="lines">@@ -3903,7 +3586,7 @@
</span><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 2) || (items &gt; 2)) {
</del><ins>+    if ((items &lt; 1) || (items &gt; 2)) {
</ins><span class="cx">       SWIG_croak(&quot;Usage: Event_serialize(self,format);&quot;);
</span><span class="cx">     }
</span><span class="cx">     res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_Event, 0 |  0 );
</span><span class="lines">@@ -3911,11 +3594,13 @@
</span><span class="cx">       SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;Event_serialize&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;Event *&quot;&quot;'&quot;); 
</span><span class="cx">     }
</span><span class="cx">     arg1 = reinterpret_cast&lt; Event * &gt;(argp1);
</span><del>-    res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;Event_serialize&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+    if (items &gt; 1) {
+      res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
+      if (!SWIG_IsOK(res2)) {
+        SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;Event_serialize&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+      }
+      arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</ins><span class="cx">     }
</span><del>-    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</del><span class="cx">     result = (char *)(arg1)-&gt;serialize((char const *)arg2);
</span><span class="cx">     ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
</span><span class="cx">     
</span><span class="lines">@@ -3929,108 +3614,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_Event_serialize__SWIG_1) {
</del><ins>+XS(_wrap_Event_setPriority) {
</ins><span class="cx">   {
</span><span class="cx">     Event *arg1 = (Event *) 0 ;
</span><del>-    char *result = 0 ;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 1) || (items &gt; 1)) {
-      SWIG_croak(&quot;Usage: Event_serialize(self);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_Event, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;Event_serialize&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;Event *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; Event * &gt;(argp1);
-    result = (char *)(arg1)-&gt;serialize();
-    ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
-    
-    XSRETURN(argvi);
-  fail:
-    
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_Event_serialize) {
-  dXSARGS;
-  
-  {
-    unsigned long _index = 0;
-    SWIG_TypeRank _rank = 0; 
-    if (items == 1) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_Event, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 1;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_1:
-    
-    if (items == 2) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_Event, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 2;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_2:
-    
-  dispatch:
-    switch(_index) {
-    case 1:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Event_serialize__SWIG_1); return;
-    case 2:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Event_serialize__SWIG_0); return;
-    }
-  }
-  
-  croak(&quot;No matching function for overloaded 'Event_serialize'&quot;);
-  XSRETURN(0);
-}
-
-
-XS(_wrap_Event_setPriority__SWIG_0) {
-  {
-    Event *arg1 = (Event *) 0 ;
-    switch_priority_t arg2 ;
</del><ins>+    switch_priority_t arg2 = (switch_priority_t) SWITCH_PRIORITY_NORMAL ;
</ins><span class="cx">     bool result;
</span><span class="cx">     void *argp1 = 0 ;
</span><span class="cx">     int res1 = 0 ;
</span><span class="lines">@@ -4039,7 +3626,7 @@
</span><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 2) || (items &gt; 2)) {
</del><ins>+    if ((items &lt; 1) || (items &gt; 2)) {
</ins><span class="cx">       SWIG_croak(&quot;Usage: Event_setPriority(self,priority);&quot;);
</span><span class="cx">     }
</span><span class="cx">     res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_Event, 0 |  0 );
</span><span class="lines">@@ -4047,15 +3634,17 @@
</span><span class="cx">       SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;Event_setPriority&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;Event *&quot;&quot;'&quot;); 
</span><span class="cx">     }
</span><span class="cx">     arg1 = reinterpret_cast&lt; Event * &gt;(argp1);
</span><del>-    {
-      res2 = SWIG_ConvertPtr(ST(1), &amp;argp2, SWIGTYPE_p_switch_priority_t,  0 );
-      if (!SWIG_IsOK(res2)) {
-        SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;Event_setPriority&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;switch_priority_t&quot;&quot;'&quot;); 
-      }  
-      if (!argp2) {
-        SWIG_exception_fail(SWIG_ValueError, &quot;invalid null reference &quot; &quot;in method '&quot; &quot;Event_setPriority&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;switch_priority_t&quot;&quot;'&quot;);
-      } else {
-        arg2 = *(reinterpret_cast&lt; switch_priority_t * &gt;(argp2));
</del><ins>+    if (items &gt; 1) {
+      {
+        res2 = SWIG_ConvertPtr(ST(1), &amp;argp2, SWIGTYPE_p_switch_priority_t,  0 );
+        if (!SWIG_IsOK(res2)) {
+          SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;Event_setPriority&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;switch_priority_t&quot;&quot;'&quot;); 
+        }  
+        if (!argp2) {
+          SWIG_exception_fail(SWIG_ValueError, &quot;invalid null reference &quot; &quot;in method '&quot; &quot;Event_setPriority&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;switch_priority_t&quot;&quot;'&quot;);
+        } else {
+          arg2 = *(reinterpret_cast&lt; switch_priority_t * &gt;(argp2));
+        }
</ins><span class="cx">       }
</span><span class="cx">     }
</span><span class="cx">     result = (bool)(arg1)-&gt;setPriority(arg2);
</span><span class="lines">@@ -4069,105 +3658,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_Event_setPriority__SWIG_1) {
-  {
-    Event *arg1 = (Event *) 0 ;
-    bool result;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 1) || (items &gt; 1)) {
-      SWIG_croak(&quot;Usage: Event_setPriority(self);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_Event, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;Event_setPriority&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;Event *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; Event * &gt;(argp1);
-    result = (bool)(arg1)-&gt;setPriority();
-    ST(argvi) = SWIG_From_bool  SWIG_PERL_CALL_ARGS_1(static_cast&lt; bool &gt;(result)); argvi++ ;
-    
-    XSRETURN(argvi);
-  fail:
-    
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_Event_setPriority) {
-  dXSARGS;
-  
-  {
-    unsigned long _index = 0;
-    SWIG_TypeRank _rank = 0; 
-    if (items == 1) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_Event, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 1;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_1:
-    
-    if (items == 2) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_Event, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(1), &amp;vptr, SWIGTYPE_p_switch_priority_t, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 2;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_2:
-    
-  dispatch:
-    switch(_index) {
-    case 1:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Event_setPriority__SWIG_1); return;
-    case 2:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Event_setPriority__SWIG_0); return;
-    }
-  }
-  
-  croak(&quot;No matching function for overloaded 'Event_setPriority'&quot;);
-  XSRETURN(0);
-}
-
-
</del><span class="cx"> XS(_wrap_Event_getHeader) {
</span><span class="cx">   {
</span><span class="cx">     Event *arg1 = (Event *) 0 ;
</span><span class="lines">@@ -4555,72 +4045,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_EventConsumer_node_set) {
-  {
-    EventConsumer *arg1 = (EventConsumer *) 0 ;
-    switch_event_node_t *arg2 = (switch_event_node_t *) 0 ;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    void *argp2 = 0 ;
-    int res2 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 2) || (items &gt; 2)) {
-      SWIG_croak(&quot;Usage: EventConsumer_node_set(self,node);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_EventConsumer, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;EventConsumer_node_set&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;EventConsumer *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; EventConsumer * &gt;(argp1);
-    res2 = SWIG_ConvertPtr(ST(1), &amp;argp2,SWIGTYPE_p_switch_event_node_t, SWIG_POINTER_DISOWN |  0 );
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;EventConsumer_node_set&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;switch_event_node_t *&quot;&quot;'&quot;); 
-    }
-    arg2 = reinterpret_cast&lt; switch_event_node_t * &gt;(argp2);
-    if (arg1) (arg1)-&gt;node = arg2;
-    
-    
-    
-    
-    XSRETURN(argvi);
-  fail:
-    
-    
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_EventConsumer_node_get) {
-  {
-    EventConsumer *arg1 = (EventConsumer *) 0 ;
-    switch_event_node_t *result = 0 ;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 1) || (items &gt; 1)) {
-      SWIG_croak(&quot;Usage: EventConsumer_node_get(self);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_EventConsumer, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;EventConsumer_node_get&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;EventConsumer *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; EventConsumer * &gt;(argp1);
-    result = (switch_event_node_t *) ((arg1)-&gt;node);
-    ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_switch_event_node_t, 0 | 0); argvi++ ;
-    
-    XSRETURN(argvi);
-  fail:
-    
-    SWIG_croak_null();
-  }
-}
-
-
</del><span class="cx"> XS(_wrap_EventConsumer_e_callback_set) {
</span><span class="cx">   {
</span><span class="cx">     EventConsumer *arg1 = (EventConsumer *) 0 ;
</span><span class="lines">@@ -4837,10 +4261,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_new_EventConsumer__SWIG_0) {
</del><ins>+XS(_wrap_new_EventConsumer) {
</ins><span class="cx">   {
</span><del>-    char *arg1 = (char *) 0 ;
-    char *arg2 = (char *) 0 ;
</del><ins>+    char *arg1 = (char *) NULL ;
+    char *arg2 = (char *) &quot;&quot; ;
</ins><span class="cx">     EventConsumer *result = 0 ;
</span><span class="cx">     int res1 ;
</span><span class="cx">     char *buf1 = 0 ;
</span><span class="lines">@@ -4851,19 +4275,23 @@
</span><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 2) || (items &gt; 2)) {
</del><ins>+    if ((items &lt; 0) || (items &gt; 2)) {
</ins><span class="cx">       SWIG_croak(&quot;Usage: new_EventConsumer(event_name,subclass_name);&quot;);
</span><span class="cx">     }
</span><del>-    res1 = SWIG_AsCharPtrAndSize(ST(0), &amp;buf1, NULL, &amp;alloc1);
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;new_EventConsumer&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+    if (items &gt; 0) {
+      res1 = SWIG_AsCharPtrAndSize(ST(0), &amp;buf1, NULL, &amp;alloc1);
+      if (!SWIG_IsOK(res1)) {
+        SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;new_EventConsumer&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+      }
+      arg1 = reinterpret_cast&lt; char * &gt;(buf1);
</ins><span class="cx">     }
</span><del>-    arg1 = reinterpret_cast&lt; char * &gt;(buf1);
-    res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;new_EventConsumer&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+    if (items &gt; 1) {
+      res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
+      if (!SWIG_IsOK(res2)) {
+        SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;new_EventConsumer&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+      }
+      arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</ins><span class="cx">     }
</span><del>-    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</del><span class="cx">     result = (EventConsumer *)new EventConsumer((char const *)arg1,(char const *)arg2);
</span><span class="cx">     ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EventConsumer, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
</span><span class="cx">     if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
</span><span class="lines">@@ -4877,103 +4305,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_new_EventConsumer__SWIG_1) {
-  {
-    char *arg1 = (char *) 0 ;
-    EventConsumer *result = 0 ;
-    int res1 ;
-    char *buf1 = 0 ;
-    int alloc1 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 1) || (items &gt; 1)) {
-      SWIG_croak(&quot;Usage: new_EventConsumer(event_name);&quot;);
-    }
-    res1 = SWIG_AsCharPtrAndSize(ST(0), &amp;buf1, NULL, &amp;alloc1);
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;new_EventConsumer&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-    }
-    arg1 = reinterpret_cast&lt; char * &gt;(buf1);
-    result = (EventConsumer *)new EventConsumer((char const *)arg1);
-    ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EventConsumer, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
-    if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
-    XSRETURN(argvi);
-  fail:
-    if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_new_EventConsumer) {
-  dXSARGS;
-  
-  {
-    unsigned long _index = 0;
-    SWIG_TypeRank _rank = 0; 
-    if (items == 1) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(0), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 1;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_1:
-    
-    if (items == 2) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(0), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 2;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_2:
-    
-  dispatch:
-    switch(_index) {
-    case 1:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_EventConsumer__SWIG_1); return;
-    case 2:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_EventConsumer__SWIG_0); return;
-    }
-  }
-  
-  croak(&quot;No matching function for overloaded 'new_EventConsumer'&quot;);
-  XSRETURN(0);
-}
-
-
</del><span class="cx"> XS(_wrap_delete_EventConsumer) {
</span><span class="cx">   {
</span><span class="cx">     EventConsumer *arg1 = (EventConsumer *) 0 ;
</span><span class="lines">@@ -5002,144 +4333,98 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_EventConsumer_pop__SWIG_0) {
</del><ins>+XS(_wrap_EventConsumer_bind) {
</ins><span class="cx">   {
</span><span class="cx">     EventConsumer *arg1 = (EventConsumer *) 0 ;
</span><del>-    int arg2 ;
-    Event *result = 0 ;
</del><ins>+    char *arg2 = (char *) 0 ;
+    char *arg3 = (char *) &quot;&quot; ;
+    int result;
</ins><span class="cx">     void *argp1 = 0 ;
</span><span class="cx">     int res1 = 0 ;
</span><del>-    int val2 ;
-    int ecode2 = 0 ;
</del><ins>+    int res2 ;
+    char *buf2 = 0 ;
+    int alloc2 = 0 ;
+    int res3 ;
+    char *buf3 = 0 ;
+    int alloc3 = 0 ;
</ins><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 2) || (items &gt; 2)) {
-      SWIG_croak(&quot;Usage: EventConsumer_pop(self,block);&quot;);
</del><ins>+    if ((items &lt; 2) || (items &gt; 3)) {
+      SWIG_croak(&quot;Usage: EventConsumer_bind(self,event_name,subclass_name);&quot;);
</ins><span class="cx">     }
</span><span class="cx">     res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_EventConsumer, 0 |  0 );
</span><span class="cx">     if (!SWIG_IsOK(res1)) {
</span><del>-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;EventConsumer_pop&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;EventConsumer *&quot;&quot;'&quot;); 
</del><ins>+      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;EventConsumer_bind&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;EventConsumer *&quot;&quot;'&quot;); 
</ins><span class="cx">     }
</span><span class="cx">     arg1 = reinterpret_cast&lt; EventConsumer * &gt;(argp1);
</span><del>-    ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &amp;val2);
-    if (!SWIG_IsOK(ecode2)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode2), &quot;in method '&quot; &quot;EventConsumer_pop&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-    } 
-    arg2 = static_cast&lt; int &gt;(val2);
-    result = (Event *)(arg1)-&gt;pop(arg2);
-    ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
</del><ins>+    res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;EventConsumer_bind&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+    }
+    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
+    if (items &gt; 2) {
+      res3 = SWIG_AsCharPtrAndSize(ST(2), &amp;buf3, NULL, &amp;alloc3);
+      if (!SWIG_IsOK(res3)) {
+        SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;EventConsumer_bind&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+      }
+      arg3 = reinterpret_cast&lt; char * &gt;(buf3);
+    }
+    result = (int)(arg1)-&gt;bind((char const *)arg2,(char const *)arg3);
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(result)); argvi++ ;
</ins><span class="cx">     
</span><del>-    
</del><ins>+    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+    if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
</ins><span class="cx">     XSRETURN(argvi);
</span><span class="cx">   fail:
</span><span class="cx">     
</span><del>-    
</del><ins>+    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+    if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
</ins><span class="cx">     SWIG_croak_null();
</span><span class="cx">   }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_EventConsumer_pop__SWIG_1) {
</del><ins>+XS(_wrap_EventConsumer_pop) {
</ins><span class="cx">   {
</span><span class="cx">     EventConsumer *arg1 = (EventConsumer *) 0 ;
</span><ins>+    int arg2 = (int) 0 ;
</ins><span class="cx">     Event *result = 0 ;
</span><span class="cx">     void *argp1 = 0 ;
</span><span class="cx">     int res1 = 0 ;
</span><ins>+    int val2 ;
+    int ecode2 = 0 ;
</ins><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 1) || (items &gt; 1)) {
-      SWIG_croak(&quot;Usage: EventConsumer_pop(self);&quot;);
</del><ins>+    if ((items &lt; 1) || (items &gt; 2)) {
+      SWIG_croak(&quot;Usage: EventConsumer_pop(self,block);&quot;);
</ins><span class="cx">     }
</span><span class="cx">     res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_EventConsumer, 0 |  0 );
</span><span class="cx">     if (!SWIG_IsOK(res1)) {
</span><span class="cx">       SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;EventConsumer_pop&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;EventConsumer *&quot;&quot;'&quot;); 
</span><span class="cx">     }
</span><span class="cx">     arg1 = reinterpret_cast&lt; EventConsumer * &gt;(argp1);
</span><del>-    result = (Event *)(arg1)-&gt;pop();
</del><ins>+    if (items &gt; 1) {
+      ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &amp;val2);
+      if (!SWIG_IsOK(ecode2)) {
+        SWIG_exception_fail(SWIG_ArgError(ecode2), &quot;in method '&quot; &quot;EventConsumer_pop&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+      } 
+      arg2 = static_cast&lt; int &gt;(val2);
+    }
+    result = (Event *)(arg1)-&gt;pop(arg2);
</ins><span class="cx">     ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
</span><span class="cx">     
</span><ins>+    
</ins><span class="cx">     XSRETURN(argvi);
</span><span class="cx">   fail:
</span><span class="cx">     
</span><ins>+    
</ins><span class="cx">     SWIG_croak_null();
</span><span class="cx">   }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_EventConsumer_pop) {
-  dXSARGS;
-  
-  {
-    unsigned long _index = 0;
-    SWIG_TypeRank _rank = 0; 
-    if (items == 1) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_EventConsumer, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 1;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_1:
-    
-    if (items == 2) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_EventConsumer, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 2;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_2:
-    
-  dispatch:
-    switch(_index) {
-    case 1:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_EventConsumer_pop__SWIG_1); return;
-    case 2:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_EventConsumer_pop__SWIG_0); return;
-    }
-  }
-  
-  croak(&quot;No matching function for overloaded 'EventConsumer_pop'&quot;);
-  XSRETURN(0);
-}
-
-
</del><span class="cx"> XS(_wrap_delete_CoreSession) {
</span><span class="cx">   {
</span><span class="cx">     CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -5910,10 +5195,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_CoreSession_hangup__SWIG_0) {
</del><ins>+XS(_wrap_CoreSession_hangup) {
</ins><span class="cx">   {
</span><span class="cx">     CoreSession *arg1 = (CoreSession *) 0 ;
</span><del>-    char *arg2 = (char *) 0 ;
</del><ins>+    char *arg2 = (char *) &quot;normal_clearing&quot; ;
</ins><span class="cx">     void *argp1 = 0 ;
</span><span class="cx">     int res1 = 0 ;
</span><span class="cx">     int res2 ;
</span><span class="lines">@@ -5922,7 +5207,7 @@
</span><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 2) || (items &gt; 2)) {
</del><ins>+    if ((items &lt; 1) || (items &gt; 2)) {
</ins><span class="cx">       SWIG_croak(&quot;Usage: CoreSession_hangup(self,cause);&quot;);
</span><span class="cx">     }
</span><span class="cx">     res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="lines">@@ -5930,11 +5215,13 @@
</span><span class="cx">       SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_hangup&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
</span><span class="cx">     }
</span><span class="cx">     arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
</span><del>-    res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_hangup&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+    if (items &gt; 1) {
+      res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
+      if (!SWIG_IsOK(res2)) {
+        SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_hangup&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+      }
+      arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</ins><span class="cx">     }
</span><del>-    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</del><span class="cx">     (arg1)-&gt;hangup((char const *)arg2);
</span><span class="cx">     
</span><span class="cx">     
</span><span class="lines">@@ -5948,103 +5235,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_CoreSession_hangup__SWIG_1) {
-  {
-    CoreSession *arg1 = (CoreSession *) 0 ;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 1) || (items &gt; 1)) {
-      SWIG_croak(&quot;Usage: CoreSession_hangup(self);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_hangup&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-    (arg1)-&gt;hangup();
-    
-    
-    XSRETURN(argvi);
-  fail:
-    
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_CoreSession_hangup) {
-  dXSARGS;
-  
-  {
-    unsigned long _index = 0;
-    SWIG_TypeRank _rank = 0; 
-    if (items == 1) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 1;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_1:
-    
-    if (items == 2) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 2;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_2:
-    
-  dispatch:
-    switch(_index) {
-    case 1:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_hangup__SWIG_1); return;
-    case 2:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_hangup__SWIG_0); return;
-    }
-  }
-  
-  croak(&quot;No matching function for overloaded 'CoreSession_hangup'&quot;);
-  XSRETURN(0);
-}
-
-
</del><span class="cx"> XS(_wrap_CoreSession_hangupState) {
</span><span class="cx">   {
</span><span class="cx">     CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -6284,14 +5474,14 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_CoreSession_say__SWIG_0) {
</del><ins>+XS(_wrap_CoreSession_say) {
</ins><span class="cx">   {
</span><span class="cx">     CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">     char *arg2 = (char *) 0 ;
</span><span class="cx">     char *arg3 = (char *) 0 ;
</span><span class="cx">     char *arg4 = (char *) 0 ;
</span><span class="cx">     char *arg5 = (char *) 0 ;
</span><del>-    char *arg6 = (char *) 0 ;
</del><ins>+    char *arg6 = (char *) NULL ;
</ins><span class="cx">     void *argp1 = 0 ;
</span><span class="cx">     int res1 = 0 ;
</span><span class="cx">     int res2 ;
</span><span class="lines">@@ -6312,7 +5502,7 @@
</span><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 6) || (items &gt; 6)) {
</del><ins>+    if ((items &lt; 5) || (items &gt; 6)) {
</ins><span class="cx">       SWIG_croak(&quot;Usage: CoreSession_say(self,tosay,module_name,say_type,say_method,say_gender);&quot;);
</span><span class="cx">     }
</span><span class="cx">     res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="lines">@@ -6340,11 +5530,13 @@
</span><span class="cx">       SWIG_exception_fail(SWIG_ArgError(res5), &quot;in method '&quot; &quot;CoreSession_say&quot; &quot;', argument &quot; &quot;5&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</span><span class="cx">     }
</span><span class="cx">     arg5 = reinterpret_cast&lt; char * &gt;(buf5);
</span><del>-    res6 = SWIG_AsCharPtrAndSize(ST(5), &amp;buf6, NULL, &amp;alloc6);
-    if (!SWIG_IsOK(res6)) {
-      SWIG_exception_fail(SWIG_ArgError(res6), &quot;in method '&quot; &quot;CoreSession_say&quot; &quot;', argument &quot; &quot;6&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+    if (items &gt; 5) {
+      res6 = SWIG_AsCharPtrAndSize(ST(5), &amp;buf6, NULL, &amp;alloc6);
+      if (!SWIG_IsOK(res6)) {
+        SWIG_exception_fail(SWIG_ArgError(res6), &quot;in method '&quot; &quot;CoreSession_say&quot; &quot;', argument &quot; &quot;6&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+      }
+      arg6 = reinterpret_cast&lt; char * &gt;(buf6);
</ins><span class="cx">     }
</span><del>-    arg6 = reinterpret_cast&lt; char * &gt;(buf6);
</del><span class="cx">     (arg1)-&gt;say((char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5,(char const *)arg6);
</span><span class="cx">     
</span><span class="cx">     
</span><span class="lines">@@ -6366,13 +5558,12 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_CoreSession_say__SWIG_1) {
</del><ins>+XS(_wrap_CoreSession_sayPhrase) {
</ins><span class="cx">   {
</span><span class="cx">     CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">     char *arg2 = (char *) 0 ;
</span><del>-    char *arg3 = (char *) 0 ;
-    char *arg4 = (char *) 0 ;
-    char *arg5 = (char *) 0 ;
</del><ins>+    char *arg3 = (char *) &quot;&quot; ;
+    char *arg4 = (char *) NULL ;
</ins><span class="cx">     void *argp1 = 0 ;
</span><span class="cx">     int res1 = 0 ;
</span><span class="cx">     int res2 ;
</span><span class="lines">@@ -6384,214 +5575,10 @@
</span><span class="cx">     int res4 ;
</span><span class="cx">     char *buf4 = 0 ;
</span><span class="cx">     int alloc4 = 0 ;
</span><del>-    int res5 ;
-    char *buf5 = 0 ;
-    int alloc5 = 0 ;
</del><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 5) || (items &gt; 5)) {
-      SWIG_croak(&quot;Usage: CoreSession_say(self,tosay,module_name,say_type,say_method);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_say&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-    res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_say&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-    }
-    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-    res3 = SWIG_AsCharPtrAndSize(ST(2), &amp;buf3, NULL, &amp;alloc3);
-    if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_say&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-    }
-    arg3 = reinterpret_cast&lt; char * &gt;(buf3);
-    res4 = SWIG_AsCharPtrAndSize(ST(3), &amp;buf4, NULL, &amp;alloc4);
-    if (!SWIG_IsOK(res4)) {
-      SWIG_exception_fail(SWIG_ArgError(res4), &quot;in method '&quot; &quot;CoreSession_say&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-    }
-    arg4 = reinterpret_cast&lt; char * &gt;(buf4);
-    res5 = SWIG_AsCharPtrAndSize(ST(4), &amp;buf5, NULL, &amp;alloc5);
-    if (!SWIG_IsOK(res5)) {
-      SWIG_exception_fail(SWIG_ArgError(res5), &quot;in method '&quot; &quot;CoreSession_say&quot; &quot;', argument &quot; &quot;5&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-    }
-    arg5 = reinterpret_cast&lt; char * &gt;(buf5);
-    (arg1)-&gt;say((char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5);
-    
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-    if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
-    if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
-    XSRETURN(argvi);
-  fail:
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-    if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
-    if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_CoreSession_say) {
-  dXSARGS;
-  
-  {
-    unsigned long _index = 0;
-    SWIG_TypeRank _rank = 0; 
-    if (items == 5) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(3), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(4), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 1;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_1:
-    
-    if (items == 6) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(3), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(4), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(5), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 2;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_2:
-    
-  dispatch:
-    switch(_index) {
-    case 1:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_say__SWIG_1); return;
-    case 2:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_say__SWIG_0); return;
-    }
-  }
-  
-  croak(&quot;No matching function for overloaded 'CoreSession_say'&quot;);
-  XSRETURN(0);
-}
-
-
-XS(_wrap_CoreSession_sayPhrase__SWIG_0) {
-  {
-    CoreSession *arg1 = (CoreSession *) 0 ;
-    char *arg2 = (char *) 0 ;
-    char *arg3 = (char *) 0 ;
-    char *arg4 = (char *) 0 ;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int res2 ;
-    char *buf2 = 0 ;
-    int alloc2 = 0 ;
-    int res3 ;
-    char *buf3 = 0 ;
-    int alloc3 = 0 ;
-    int res4 ;
-    char *buf4 = 0 ;
-    int alloc4 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 4) || (items &gt; 4)) {
</del><ins>+    if ((items &lt; 2) || (items &gt; 4)) {
</ins><span class="cx">       SWIG_croak(&quot;Usage: CoreSession_sayPhrase(self,phrase_name,phrase_data,phrase_lang);&quot;);
</span><span class="cx">     }
</span><span class="cx">     res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="lines">@@ -6604,16 +5591,20 @@
</span><span class="cx">       SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</span><span class="cx">     }
</span><span class="cx">     arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</span><del>-    res3 = SWIG_AsCharPtrAndSize(ST(2), &amp;buf3, NULL, &amp;alloc3);
-    if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+    if (items &gt; 2) {
+      res3 = SWIG_AsCharPtrAndSize(ST(2), &amp;buf3, NULL, &amp;alloc3);
+      if (!SWIG_IsOK(res3)) {
+        SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+      }
+      arg3 = reinterpret_cast&lt; char * &gt;(buf3);
</ins><span class="cx">     }
</span><del>-    arg3 = reinterpret_cast&lt; char * &gt;(buf3);
-    res4 = SWIG_AsCharPtrAndSize(ST(3), &amp;buf4, NULL, &amp;alloc4);
-    if (!SWIG_IsOK(res4)) {
-      SWIG_exception_fail(SWIG_ArgError(res4), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+    if (items &gt; 3) {
+      res4 = SWIG_AsCharPtrAndSize(ST(3), &amp;buf4, NULL, &amp;alloc4);
+      if (!SWIG_IsOK(res4)) {
+        SWIG_exception_fail(SWIG_ArgError(res4), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+      }
+      arg4 = reinterpret_cast&lt; char * &gt;(buf4);
</ins><span class="cx">     }
</span><del>-    arg4 = reinterpret_cast&lt; char * &gt;(buf4);
</del><span class="cx">     (arg1)-&gt;sayPhrase((char const *)arg2,(char const *)arg3,(char const *)arg4);
</span><span class="cx">     
</span><span class="cx">     
</span><span class="lines">@@ -6631,226 +5622,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_CoreSession_sayPhrase__SWIG_1) {
-  {
-    CoreSession *arg1 = (CoreSession *) 0 ;
-    char *arg2 = (char *) 0 ;
-    char *arg3 = (char *) 0 ;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int res2 ;
-    char *buf2 = 0 ;
-    int alloc2 = 0 ;
-    int res3 ;
-    char *buf3 = 0 ;
-    int alloc3 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 3) || (items &gt; 3)) {
-      SWIG_croak(&quot;Usage: CoreSession_sayPhrase(self,phrase_name,phrase_data);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-    res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-    }
-    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-    res3 = SWIG_AsCharPtrAndSize(ST(2), &amp;buf3, NULL, &amp;alloc3);
-    if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-    }
-    arg3 = reinterpret_cast&lt; char * &gt;(buf3);
-    (arg1)-&gt;sayPhrase((char const *)arg2,(char const *)arg3);
-    
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-    XSRETURN(argvi);
-  fail:
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_CoreSession_sayPhrase__SWIG_2) {
-  {
-    CoreSession *arg1 = (CoreSession *) 0 ;
-    char *arg2 = (char *) 0 ;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int res2 ;
-    char *buf2 = 0 ;
-    int alloc2 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 2) || (items &gt; 2)) {
-      SWIG_croak(&quot;Usage: CoreSession_sayPhrase(self,phrase_name);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-    res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-    }
-    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-    (arg1)-&gt;sayPhrase((char const *)arg2);
-    
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    XSRETURN(argvi);
-  fail:
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_CoreSession_sayPhrase) {
-  dXSARGS;
-  
-  {
-    unsigned long _index = 0;
-    SWIG_TypeRank _rank = 0; 
-    if (items == 2) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 1;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_1:
-    
-    if (items == 3) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 2;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_2:
-    
-    if (items == 4) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(3), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 3;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_3:
-    
-  dispatch:
-    switch(_index) {
-    case 1:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_sayPhrase__SWIG_2); return;
-    case 2:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_sayPhrase__SWIG_1); return;
-    case 3:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_sayPhrase__SWIG_0); return;
-    }
-  }
-  
-  croak(&quot;No matching function for overloaded 'CoreSession_sayPhrase'&quot;);
-  XSRETURN(0);
-}
-
-
</del><span class="cx"> XS(_wrap_CoreSession_hangupCause) {
</span><span class="cx">   {
</span><span class="cx">     CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -6907,13 +5678,13 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_CoreSession_recordFile__SWIG_0) {
</del><ins>+XS(_wrap_CoreSession_recordFile) {
</ins><span class="cx">   {
</span><span class="cx">     CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">     char *arg2 = (char *) 0 ;
</span><del>-    int arg3 ;
-    int arg4 ;
-    int arg5 ;
</del><ins>+    int arg3 = (int) 0 ;
+    int arg4 = (int) 0 ;
+    int arg5 = (int) 0 ;
</ins><span class="cx">     int result;
</span><span class="cx">     void *argp1 = 0 ;
</span><span class="cx">     int res1 = 0 ;
</span><span class="lines">@@ -6929,7 +5700,7 @@
</span><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 5) || (items &gt; 5)) {
</del><ins>+    if ((items &lt; 2) || (items &gt; 5)) {
</ins><span class="cx">       SWIG_croak(&quot;Usage: CoreSession_recordFile(self,file_name,time_limit,silence_threshold,silence_hits);&quot;);
</span><span class="cx">     }
</span><span class="cx">     res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="lines">@@ -6942,394 +5713,53 @@
</span><span class="cx">       SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
</span><span class="cx">     }
</span><span class="cx">     arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</span><del>-    ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &amp;val3);
-    if (!SWIG_IsOK(ecode3)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-    } 
-    arg3 = static_cast&lt; int &gt;(val3);
-    ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), &amp;val4);
-    if (!SWIG_IsOK(ecode4)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode4), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-    } 
-    arg4 = static_cast&lt; int &gt;(val4);
-    ecode5 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), &amp;val5);
-    if (!SWIG_IsOK(ecode5)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode5), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;5&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-    } 
-    arg5 = static_cast&lt; int &gt;(val5);
-    result = (int)(arg1)-&gt;recordFile(arg2,arg3,arg4,arg5);
-    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(result)); argvi++ ;
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    
-    
-    
-    XSRETURN(argvi);
-  fail:
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    
-    
-    
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_CoreSession_recordFile__SWIG_1) {
-  {
-    CoreSession *arg1 = (CoreSession *) 0 ;
-    char *arg2 = (char *) 0 ;
-    int arg3 ;
-    int arg4 ;
-    int result;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int res2 ;
-    char *buf2 = 0 ;
-    int alloc2 = 0 ;
-    int val3 ;
-    int ecode3 = 0 ;
-    int val4 ;
-    int ecode4 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 4) || (items &gt; 4)) {
-      SWIG_croak(&quot;Usage: CoreSession_recordFile(self,file_name,time_limit,silence_threshold);&quot;);
</del><ins>+    if (items &gt; 2) {
+      ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &amp;val3);
+      if (!SWIG_IsOK(ecode3)) {
+        SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+      } 
+      arg3 = static_cast&lt; int &gt;(val3);
</ins><span class="cx">     }
</span><del>-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
</del><ins>+    if (items &gt; 3) {
+      ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), &amp;val4);
+      if (!SWIG_IsOK(ecode4)) {
+        SWIG_exception_fail(SWIG_ArgError(ecode4), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+      } 
+      arg4 = static_cast&lt; int &gt;(val4);
</ins><span class="cx">     }
</span><del>-    arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-    res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
</del><ins>+    if (items &gt; 4) {
+      ecode5 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), &amp;val5);
+      if (!SWIG_IsOK(ecode5)) {
+        SWIG_exception_fail(SWIG_ArgError(ecode5), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;5&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+      } 
+      arg5 = static_cast&lt; int &gt;(val5);
</ins><span class="cx">     }
</span><del>-    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-    ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &amp;val3);
-    if (!SWIG_IsOK(ecode3)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-    } 
-    arg3 = static_cast&lt; int &gt;(val3);
-    ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), &amp;val4);
-    if (!SWIG_IsOK(ecode4)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode4), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-    } 
-    arg4 = static_cast&lt; int &gt;(val4);
-    result = (int)(arg1)-&gt;recordFile(arg2,arg3,arg4);
</del><ins>+    result = (int)(arg1)-&gt;recordFile(arg2,arg3,arg4,arg5);
</ins><span class="cx">     ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(result)); argvi++ ;
</span><span class="cx">     
</span><span class="cx">     if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
</span><span class="cx">     
</span><span class="cx">     
</span><del>-    XSRETURN(argvi);
-  fail:
</del><span class="cx">     
</span><del>-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    
-    
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_CoreSession_recordFile__SWIG_2) {
-  {
-    CoreSession *arg1 = (CoreSession *) 0 ;
-    char *arg2 = (char *) 0 ;
-    int arg3 ;
-    int result;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int res2 ;
-    char *buf2 = 0 ;
-    int alloc2 = 0 ;
-    int val3 ;
-    int ecode3 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 3) || (items &gt; 3)) {
-      SWIG_croak(&quot;Usage: CoreSession_recordFile(self,file_name,time_limit);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-    res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-    }
-    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-    ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &amp;val3);
-    if (!SWIG_IsOK(ecode3)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-    } 
-    arg3 = static_cast&lt; int &gt;(val3);
-    result = (int)(arg1)-&gt;recordFile(arg2,arg3);
-    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(result)); argvi++ ;
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    
</del><span class="cx">     XSRETURN(argvi);
</span><span class="cx">   fail:
</span><span class="cx">     
</span><span class="cx">     if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
</span><span class="cx">     
</span><del>-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_CoreSession_recordFile__SWIG_3) {
-  {
-    CoreSession *arg1 = (CoreSession *) 0 ;
-    char *arg2 = (char *) 0 ;
-    int result;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int res2 ;
-    char *buf2 = 0 ;
-    int alloc2 = 0 ;
-    int argvi = 0;
-    dXSARGS;
</del><span class="cx">     
</span><del>-    if ((items &lt; 2) || (items &gt; 2)) {
-      SWIG_croak(&quot;Usage: CoreSession_recordFile(self,file_name);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-    res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-    }
-    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-    result = (int)(arg1)-&gt;recordFile(arg2);
-    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(result)); argvi++ ;
</del><span class="cx">     
</span><del>-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    XSRETURN(argvi);
-  fail:
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
</del><span class="cx">     SWIG_croak_null();
</span><span class="cx">   }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_CoreSession_recordFile) {
-  dXSARGS;
-  
</del><ins>+XS(_wrap_CoreSession_originate) {
</ins><span class="cx">   {
</span><del>-    unsigned long _index = 0;
-    SWIG_TypeRank _rank = 0; 
-    if (items == 2) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 1;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_1:
-    
-    if (items == 3) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 2;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_2:
-    
-    if (items == 4) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 3;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_3:
-    
-    if (items == 5) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_4;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_4;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_4;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_4;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_4;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 4;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_4:
-    
-  dispatch:
-    switch(_index) {
-    case 1:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_recordFile__SWIG_3); return;
-    case 2:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_recordFile__SWIG_2); return;
-    case 3:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_recordFile__SWIG_1); return;
-    case 4:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_recordFile__SWIG_0); return;
-    }
-  }
-  
-  croak(&quot;No matching function for overloaded 'CoreSession_recordFile'&quot;);
-  XSRETURN(0);
-}
-
-
-XS(_wrap_CoreSession_originate__SWIG_0) {
-  {
</del><span class="cx">     CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">     CoreSession *arg2 = (CoreSession *) 0 ;
</span><span class="cx">     char *arg3 = (char *) 0 ;
</span><del>-    int arg4 ;
-    switch_state_handler_table_t *arg5 = (switch_state_handler_table_t *) 0 ;
</del><ins>+    int arg4 = (int) 60 ;
+    switch_state_handler_table_t *arg5 = (switch_state_handler_table_t *) NULL ;
</ins><span class="cx">     int result;
</span><span class="cx">     void *argp1 = 0 ;
</span><span class="cx">     int res1 = 0 ;
</span><span class="lines">@@ -7345,7 +5775,7 @@
</span><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 5) || (items &gt; 5)) {
</del><ins>+    if ((items &lt; 3) || (items &gt; 5)) {
</ins><span class="cx">       SWIG_croak(&quot;Usage: CoreSession_originate(self,a_leg_session,dest,timeout,handlers);&quot;);
</span><span class="cx">     }
</span><span class="cx">     res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="lines">@@ -7363,16 +5793,20 @@
</span><span class="cx">       SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
</span><span class="cx">     }
</span><span class="cx">     arg3 = reinterpret_cast&lt; char * &gt;(buf3);
</span><del>-    ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), &amp;val4);
-    if (!SWIG_IsOK(ecode4)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode4), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-    } 
-    arg4 = static_cast&lt; int &gt;(val4);
-    res5 = SWIG_ConvertPtr(ST(4), &amp;argp5,SWIGTYPE_p_switch_state_handler_table_t, 0 |  0 );
-    if (!SWIG_IsOK(res5)) {
-      SWIG_exception_fail(SWIG_ArgError(res5), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;5&quot;&quot; of type '&quot; &quot;switch_state_handler_table_t *&quot;&quot;'&quot;); 
</del><ins>+    if (items &gt; 3) {
+      ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), &amp;val4);
+      if (!SWIG_IsOK(ecode4)) {
+        SWIG_exception_fail(SWIG_ArgError(ecode4), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+      } 
+      arg4 = static_cast&lt; int &gt;(val4);
</ins><span class="cx">     }
</span><del>-    arg5 = reinterpret_cast&lt; switch_state_handler_table_t * &gt;(argp5);
</del><ins>+    if (items &gt; 4) {
+      res5 = SWIG_ConvertPtr(ST(4), &amp;argp5,SWIGTYPE_p_switch_state_handler_table_t, 0 |  0 );
+      if (!SWIG_IsOK(res5)) {
+        SWIG_exception_fail(SWIG_ArgError(res5), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;5&quot;&quot; of type '&quot; &quot;switch_state_handler_table_t *&quot;&quot;'&quot;); 
+      }
+      arg5 = reinterpret_cast&lt; switch_state_handler_table_t * &gt;(argp5);
+    }
</ins><span class="cx">     result = (int)(arg1)-&gt;originate(arg2,arg3,arg4,arg5);
</span><span class="cx">     ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(result)); argvi++ ;
</span><span class="cx">     
</span><span class="lines">@@ -7392,279 +5826,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_CoreSession_originate__SWIG_1) {
-  {
-    CoreSession *arg1 = (CoreSession *) 0 ;
-    CoreSession *arg2 = (CoreSession *) 0 ;
-    char *arg3 = (char *) 0 ;
-    int arg4 ;
-    int result;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    void *argp2 = 0 ;
-    int res2 = 0 ;
-    int res3 ;
-    char *buf3 = 0 ;
-    int alloc3 = 0 ;
-    int val4 ;
-    int ecode4 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 4) || (items &gt; 4)) {
-      SWIG_croak(&quot;Usage: CoreSession_originate(self,a_leg_session,dest,timeout);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-    res2 = SWIG_ConvertPtr(ST(1), &amp;argp2,SWIGTYPE_p_CoreSession, 0 |  0 );
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-    }
-    arg2 = reinterpret_cast&lt; CoreSession * &gt;(argp2);
-    res3 = SWIG_AsCharPtrAndSize(ST(2), &amp;buf3, NULL, &amp;alloc3);
-    if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-    }
-    arg3 = reinterpret_cast&lt; char * &gt;(buf3);
-    ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), &amp;val4);
-    if (!SWIG_IsOK(ecode4)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode4), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-    } 
-    arg4 = static_cast&lt; int &gt;(val4);
-    result = (int)(arg1)-&gt;originate(arg2,arg3,arg4);
-    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(result)); argvi++ ;
-    
-    
-    if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-    
-    XSRETURN(argvi);
-  fail:
-    
-    
-    if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-    
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_CoreSession_originate__SWIG_2) {
-  {
-    CoreSession *arg1 = (CoreSession *) 0 ;
-    CoreSession *arg2 = (CoreSession *) 0 ;
-    char *arg3 = (char *) 0 ;
-    int result;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    void *argp2 = 0 ;
-    int res2 = 0 ;
-    int res3 ;
-    char *buf3 = 0 ;
-    int alloc3 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 3) || (items &gt; 3)) {
-      SWIG_croak(&quot;Usage: CoreSession_originate(self,a_leg_session,dest);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-    res2 = SWIG_ConvertPtr(ST(1), &amp;argp2,SWIGTYPE_p_CoreSession, 0 |  0 );
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-    }
-    arg2 = reinterpret_cast&lt; CoreSession * &gt;(argp2);
-    res3 = SWIG_AsCharPtrAndSize(ST(2), &amp;buf3, NULL, &amp;alloc3);
-    if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-    }
-    arg3 = reinterpret_cast&lt; char * &gt;(buf3);
-    result = (int)(arg1)-&gt;originate(arg2,arg3);
-    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(result)); argvi++ ;
-    
-    
-    if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-    XSRETURN(argvi);
-  fail:
-    
-    
-    if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_CoreSession_originate) {
-  dXSARGS;
-  
-  {
-    unsigned long _index = 0;
-    SWIG_TypeRank _rank = 0; 
-    if (items == 3) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(1), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 1;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_1:
-    
-    if (items == 4) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(1), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 2;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_2:
-    
-    if (items == 5) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(1), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(4), &amp;vptr, SWIGTYPE_p_switch_state_handler_table_t, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 3;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_3:
-    
-  dispatch:
-    switch(_index) {
-    case 1:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_originate__SWIG_2); return;
-    case 2:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_originate__SWIG_1); return;
-    case 3:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_originate__SWIG_0); return;
-    }
-  }
-  
-  croak(&quot;No matching function for overloaded 'CoreSession_originate'&quot;);
-  XSRETURN(0);
-}
-
-
</del><span class="cx"> XS(_wrap_CoreSession_destroy) {
</span><span class="cx">   {
</span><span class="cx">     CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -8260,12 +6421,12 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_CoreSession_transfer__SWIG_0) {
</del><ins>+XS(_wrap_CoreSession_transfer) {
</ins><span class="cx">   {
</span><span class="cx">     CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">     char *arg2 = (char *) 0 ;
</span><del>-    char *arg3 = (char *) 0 ;
-    char *arg4 = (char *) 0 ;
</del><ins>+    char *arg3 = (char *) NULL ;
+    char *arg4 = (char *) NULL ;
</ins><span class="cx">     int result;
</span><span class="cx">     void *argp1 = 0 ;
</span><span class="cx">     int res1 = 0 ;
</span><span class="lines">@@ -8281,7 +6442,7 @@
</span><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 4) || (items &gt; 4)) {
</del><ins>+    if ((items &lt; 2) || (items &gt; 4)) {
</ins><span class="cx">       SWIG_croak(&quot;Usage: CoreSession_transfer(self,extension,dialplan,context);&quot;);
</span><span class="cx">     }
</span><span class="cx">     res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="lines">@@ -8294,16 +6455,20 @@
</span><span class="cx">       SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
</span><span class="cx">     }
</span><span class="cx">     arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</span><del>-    res3 = SWIG_AsCharPtrAndSize(ST(2), &amp;buf3, NULL, &amp;alloc3);
-    if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
</del><ins>+    if (items &gt; 2) {
+      res3 = SWIG_AsCharPtrAndSize(ST(2), &amp;buf3, NULL, &amp;alloc3);
+      if (!SWIG_IsOK(res3)) {
+        SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
+      }
+      arg3 = reinterpret_cast&lt; char * &gt;(buf3);
</ins><span class="cx">     }
</span><del>-    arg3 = reinterpret_cast&lt; char * &gt;(buf3);
-    res4 = SWIG_AsCharPtrAndSize(ST(3), &amp;buf4, NULL, &amp;alloc4);
-    if (!SWIG_IsOK(res4)) {
-      SWIG_exception_fail(SWIG_ArgError(res4), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
</del><ins>+    if (items &gt; 3) {
+      res4 = SWIG_AsCharPtrAndSize(ST(3), &amp;buf4, NULL, &amp;alloc4);
+      if (!SWIG_IsOK(res4)) {
+        SWIG_exception_fail(SWIG_ArgError(res4), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
+      }
+      arg4 = reinterpret_cast&lt; char * &gt;(buf4);
</ins><span class="cx">     }
</span><del>-    arg4 = reinterpret_cast&lt; char * &gt;(buf4);
</del><span class="cx">     result = (int)(arg1)-&gt;transfer(arg2,arg3,arg4);
</span><span class="cx">     ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(result)); argvi++ ;
</span><span class="cx">     
</span><span class="lines">@@ -8321,228 +6486,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_CoreSession_transfer__SWIG_1) {
-  {
-    CoreSession *arg1 = (CoreSession *) 0 ;
-    char *arg2 = (char *) 0 ;
-    char *arg3 = (char *) 0 ;
-    int result;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int res2 ;
-    char *buf2 = 0 ;
-    int alloc2 = 0 ;
-    int res3 ;
-    char *buf3 = 0 ;
-    int alloc3 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 3) || (items &gt; 3)) {
-      SWIG_croak(&quot;Usage: CoreSession_transfer(self,extension,dialplan);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-    res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-    }
-    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-    res3 = SWIG_AsCharPtrAndSize(ST(2), &amp;buf3, NULL, &amp;alloc3);
-    if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-    }
-    arg3 = reinterpret_cast&lt; char * &gt;(buf3);
-    result = (int)(arg1)-&gt;transfer(arg2,arg3);
-    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(result)); argvi++ ;
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-    XSRETURN(argvi);
-  fail:
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_CoreSession_transfer__SWIG_2) {
-  {
-    CoreSession *arg1 = (CoreSession *) 0 ;
-    char *arg2 = (char *) 0 ;
-    int result;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int res2 ;
-    char *buf2 = 0 ;
-    int alloc2 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 2) || (items &gt; 2)) {
-      SWIG_croak(&quot;Usage: CoreSession_transfer(self,extension);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-    res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-    }
-    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-    result = (int)(arg1)-&gt;transfer(arg2);
-    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(result)); argvi++ ;
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    XSRETURN(argvi);
-  fail:
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_CoreSession_transfer) {
-  dXSARGS;
-  
-  {
-    unsigned long _index = 0;
-    SWIG_TypeRank _rank = 0; 
-    if (items == 2) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 1;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_1:
-    
-    if (items == 3) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 2;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_2:
-    
-    if (items == 4) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(3), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_3;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 3;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_3:
-    
-  dispatch:
-    switch(_index) {
-    case 1:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_transfer__SWIG_2); return;
-    case 2:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_transfer__SWIG_1); return;
-    case 3:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_transfer__SWIG_0); return;
-    }
-  }
-  
-  croak(&quot;No matching function for overloaded 'CoreSession_transfer'&quot;);
-  XSRETURN(0);
-}
-
-
</del><span class="cx"> XS(_wrap_CoreSession_read) {
</span><span class="cx">   {
</span><span class="cx">     CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -8623,7 +6566,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_CoreSession_playAndGetDigits__SWIG_0) {
</del><ins>+XS(_wrap_CoreSession_playAndGetDigits) {
</ins><span class="cx">   {
</span><span class="cx">     CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">     int arg2 ;
</span><span class="lines">@@ -8634,7 +6577,7 @@
</span><span class="cx">     char *arg7 = (char *) 0 ;
</span><span class="cx">     char *arg8 = (char *) 0 ;
</span><span class="cx">     char *arg9 = (char *) 0 ;
</span><del>-    char *arg10 = (char *) 0 ;
</del><ins>+    char *arg10 = (char *) NULL ;
</ins><span class="cx">     char *result = 0 ;
</span><span class="cx">     void *argp1 = 0 ;
</span><span class="cx">     int res1 = 0 ;
</span><span class="lines">@@ -8664,7 +6607,7 @@
</span><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 10) || (items &gt; 10)) {
</del><ins>+    if ((items &lt; 9) || (items &gt; 10)) {
</ins><span class="cx">       SWIG_croak(&quot;Usage: CoreSession_playAndGetDigits(self,min_digits,max_digits,max_tries,timeout,terminators,audio_files,bad_input_audio_files,digits_regex,var_name);&quot;);
</span><span class="cx">     }
</span><span class="cx">     res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="lines">@@ -8712,11 +6655,13 @@
</span><span class="cx">       SWIG_exception_fail(SWIG_ArgError(res9), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;9&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
</span><span class="cx">     }
</span><span class="cx">     arg9 = reinterpret_cast&lt; char * &gt;(buf9);
</span><del>-    res10 = SWIG_AsCharPtrAndSize(ST(9), &amp;buf10, NULL, &amp;alloc10);
-    if (!SWIG_IsOK(res10)) {
-      SWIG_exception_fail(SWIG_ArgError(res10), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;10&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+    if (items &gt; 9) {
+      res10 = SWIG_AsCharPtrAndSize(ST(9), &amp;buf10, NULL, &amp;alloc10);
+      if (!SWIG_IsOK(res10)) {
+        SWIG_exception_fail(SWIG_ArgError(res10), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;10&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+      }
+      arg10 = reinterpret_cast&lt; char * &gt;(buf10);
</ins><span class="cx">     }
</span><del>-    arg10 = reinterpret_cast&lt; char * &gt;(buf10);
</del><span class="cx">     result = (char *)(arg1)-&gt;playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,(char const *)arg10);
</span><span class="cx">     ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
</span><span class="cx">     
</span><span class="lines">@@ -8746,337 +6691,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_CoreSession_playAndGetDigits__SWIG_1) {
</del><ins>+XS(_wrap_CoreSession_streamFile) {
</ins><span class="cx">   {
</span><span class="cx">     CoreSession *arg1 = (CoreSession *) 0 ;
</span><del>-    int arg2 ;
-    int arg3 ;
-    int arg4 ;
-    int arg5 ;
-    char *arg6 = (char *) 0 ;
-    char *arg7 = (char *) 0 ;
-    char *arg8 = (char *) 0 ;
-    char *arg9 = (char *) 0 ;
-    char *result = 0 ;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int val2 ;
-    int ecode2 = 0 ;
-    int val3 ;
-    int ecode3 = 0 ;
-    int val4 ;
-    int ecode4 = 0 ;
-    int val5 ;
-    int ecode5 = 0 ;
-    int res6 ;
-    char *buf6 = 0 ;
-    int alloc6 = 0 ;
-    int res7 ;
-    char *buf7 = 0 ;
-    int alloc7 = 0 ;
-    int res8 ;
-    char *buf8 = 0 ;
-    int alloc8 = 0 ;
-    int res9 ;
-    char *buf9 = 0 ;
-    int alloc9 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 9) || (items &gt; 9)) {
-      SWIG_croak(&quot;Usage: CoreSession_playAndGetDigits(self,min_digits,max_digits,max_tries,timeout,terminators,audio_files,bad_input_audio_files,digits_regex);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-    ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &amp;val2);
-    if (!SWIG_IsOK(ecode2)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode2), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-    } 
-    arg2 = static_cast&lt; int &gt;(val2);
-    ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &amp;val3);
-    if (!SWIG_IsOK(ecode3)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-    } 
-    arg3 = static_cast&lt; int &gt;(val3);
-    ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), &amp;val4);
-    if (!SWIG_IsOK(ecode4)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode4), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-    } 
-    arg4 = static_cast&lt; int &gt;(val4);
-    ecode5 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), &amp;val5);
-    if (!SWIG_IsOK(ecode5)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode5), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;5&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-    } 
-    arg5 = static_cast&lt; int &gt;(val5);
-    res6 = SWIG_AsCharPtrAndSize(ST(5), &amp;buf6, NULL, &amp;alloc6);
-    if (!SWIG_IsOK(res6)) {
-      SWIG_exception_fail(SWIG_ArgError(res6), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;6&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-    }
-    arg6 = reinterpret_cast&lt; char * &gt;(buf6);
-    res7 = SWIG_AsCharPtrAndSize(ST(6), &amp;buf7, NULL, &amp;alloc7);
-    if (!SWIG_IsOK(res7)) {
-      SWIG_exception_fail(SWIG_ArgError(res7), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;7&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-    }
-    arg7 = reinterpret_cast&lt; char * &gt;(buf7);
-    res8 = SWIG_AsCharPtrAndSize(ST(7), &amp;buf8, NULL, &amp;alloc8);
-    if (!SWIG_IsOK(res8)) {
-      SWIG_exception_fail(SWIG_ArgError(res8), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;8&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-    }
-    arg8 = reinterpret_cast&lt; char * &gt;(buf8);
-    res9 = SWIG_AsCharPtrAndSize(ST(8), &amp;buf9, NULL, &amp;alloc9);
-    if (!SWIG_IsOK(res9)) {
-      SWIG_exception_fail(SWIG_ArgError(res9), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;9&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-    }
-    arg9 = reinterpret_cast&lt; char * &gt;(buf9);
-    result = (char *)(arg1)-&gt;playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
-    ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
-    
-    
-    
-    
-    
-    if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
-    if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
-    if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
-    if (alloc9 == SWIG_NEWOBJ) delete[] buf9;
-    XSRETURN(argvi);
-  fail:
-    
-    
-    
-    
-    
-    if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
-    if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
-    if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
-    if (alloc9 == SWIG_NEWOBJ) delete[] buf9;
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_CoreSession_playAndGetDigits) {
-  dXSARGS;
-  
-  {
-    unsigned long _index = 0;
-    SWIG_TypeRank _rank = 0; 
-    if (items == 9) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(5), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(6), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(7), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(8), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 1;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_1:
-    
-    if (items == 10) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(5), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(6), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(7), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(8), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(9), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 2;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_2:
-    
-  dispatch:
-    switch(_index) {
-    case 1:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_playAndGetDigits__SWIG_1); return;
-    case 2:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_playAndGetDigits__SWIG_0); return;
-    }
-  }
-  
-  croak(&quot;No matching function for overloaded 'CoreSession_playAndGetDigits'&quot;);
-  XSRETURN(0);
-}
-
-
-XS(_wrap_CoreSession_streamFile__SWIG_0) {
-  {
-    CoreSession *arg1 = (CoreSession *) 0 ;
</del><span class="cx">     char *arg2 = (char *) 0 ;
</span><del>-    int arg3 ;
</del><ins>+    int arg3 = (int) 0 ;
</ins><span class="cx">     int result;
</span><span class="cx">     void *argp1 = 0 ;
</span><span class="cx">     int res1 = 0 ;
</span><span class="lines">@@ -9088,7 +6707,7 @@
</span><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 3) || (items &gt; 3)) {
</del><ins>+    if ((items &lt; 2) || (items &gt; 3)) {
</ins><span class="cx">       SWIG_croak(&quot;Usage: CoreSession_streamFile(self,file,starting_sample_count);&quot;);
</span><span class="cx">     }
</span><span class="cx">     res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="lines">@@ -9101,11 +6720,13 @@
</span><span class="cx">       SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_streamFile&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
</span><span class="cx">     }
</span><span class="cx">     arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</span><del>-    ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &amp;val3);
-    if (!SWIG_IsOK(ecode3)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_streamFile&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-    } 
-    arg3 = static_cast&lt; int &gt;(val3);
</del><ins>+    if (items &gt; 2) {
+      ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &amp;val3);
+      if (!SWIG_IsOK(ecode3)) {
+        SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_streamFile&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+      } 
+      arg3 = static_cast&lt; int &gt;(val3);
+    }
</ins><span class="cx">     result = (int)(arg1)-&gt;streamFile(arg2,arg3);
</span><span class="cx">     ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(result)); argvi++ ;
</span><span class="cx">     
</span><span class="lines">@@ -9121,138 +6742,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_CoreSession_streamFile__SWIG_1) {
</del><ins>+XS(_wrap_CoreSession_sleep) {
</ins><span class="cx">   {
</span><span class="cx">     CoreSession *arg1 = (CoreSession *) 0 ;
</span><del>-    char *arg2 = (char *) 0 ;
-    int result;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int res2 ;
-    char *buf2 = 0 ;
-    int alloc2 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 2) || (items &gt; 2)) {
-      SWIG_croak(&quot;Usage: CoreSession_streamFile(self,file);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_streamFile&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-    res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_streamFile&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-    }
-    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-    result = (int)(arg1)-&gt;streamFile(arg2);
-    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(result)); argvi++ ;
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    XSRETURN(argvi);
-  fail:
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_CoreSession_streamFile) {
-  dXSARGS;
-  
-  {
-    unsigned long _index = 0;
-    SWIG_TypeRank _rank = 0; 
-    if (items == 2) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 1;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_1:
-    
-    if (items == 3) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 2;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_2:
-    
-  dispatch:
-    switch(_index) {
-    case 1:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_streamFile__SWIG_1); return;
-    case 2:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_streamFile__SWIG_0); return;
-    }
-  }
-  
-  croak(&quot;No matching function for overloaded 'CoreSession_streamFile'&quot;);
-  XSRETURN(0);
-}
-
-
-XS(_wrap_CoreSession_sleep__SWIG_0) {
-  {
-    CoreSession *arg1 = (CoreSession *) 0 ;
</del><span class="cx">     int arg2 ;
</span><del>-    int arg3 ;
</del><ins>+    int arg3 = (int) 0 ;
</ins><span class="cx">     int result;
</span><span class="cx">     void *argp1 = 0 ;
</span><span class="cx">     int res1 = 0 ;
</span><span class="lines">@@ -9263,7 +6757,7 @@
</span><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 3) || (items &gt; 3)) {
</del><ins>+    if ((items &lt; 2) || (items &gt; 3)) {
</ins><span class="cx">       SWIG_croak(&quot;Usage: CoreSession_sleep(self,ms,sync);&quot;);
</span><span class="cx">     }
</span><span class="cx">     res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="lines">@@ -9276,11 +6770,13 @@
</span><span class="cx">       SWIG_exception_fail(SWIG_ArgError(ecode2), &quot;in method '&quot; &quot;CoreSession_sleep&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
</span><span class="cx">     } 
</span><span class="cx">     arg2 = static_cast&lt; int &gt;(val2);
</span><del>-    ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &amp;val3);
-    if (!SWIG_IsOK(ecode3)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_sleep&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-    } 
-    arg3 = static_cast&lt; int &gt;(val3);
</del><ins>+    if (items &gt; 2) {
+      ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &amp;val3);
+      if (!SWIG_IsOK(ecode3)) {
+        SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_sleep&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+      } 
+      arg3 = static_cast&lt; int &gt;(val3);
+    }
</ins><span class="cx">     result = (int)(arg1)-&gt;sleep(arg2,arg3);
</span><span class="cx">     ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(result)); argvi++ ;
</span><span class="cx">     
</span><span class="lines">@@ -9296,136 +6792,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_CoreSession_sleep__SWIG_1) {
-  {
-    CoreSession *arg1 = (CoreSession *) 0 ;
-    int arg2 ;
-    int result;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int val2 ;
-    int ecode2 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 2) || (items &gt; 2)) {
-      SWIG_croak(&quot;Usage: CoreSession_sleep(self,ms);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_sleep&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-    ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &amp;val2);
-    if (!SWIG_IsOK(ecode2)) {
-      SWIG_exception_fail(SWIG_ArgError(ecode2), &quot;in method '&quot; &quot;CoreSession_sleep&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-    } 
-    arg2 = static_cast&lt; int &gt;(val2);
-    result = (int)(arg1)-&gt;sleep(arg2);
-    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(result)); argvi++ ;
-    
-    
-    XSRETURN(argvi);
-  fail:
-    
-    
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_CoreSession_sleep) {
-  dXSARGS;
-  
-  {
-    unsigned long _index = 0;
-    SWIG_TypeRank _rank = 0; 
-    if (items == 2) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 1;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_1:
-    
-    if (items == 3) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        {
-          int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), NULL);
-          _v = SWIG_CheckState(res);
-        }
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 2;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_2:
-    
-  dispatch:
-    switch(_index) {
-    case 1:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_sleep__SWIG_1); return;
-    case 2:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_sleep__SWIG_0); return;
-    }
-  }
-  
-  croak(&quot;No matching function for overloaded 'CoreSession_sleep'&quot;);
-  XSRETURN(0);
-}
-
-
</del><span class="cx"> XS(_wrap_CoreSession_flushEvents) {
</span><span class="cx">   {
</span><span class="cx">     CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -9704,11 +7070,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_CoreSession_execute__SWIG_0) {
</del><ins>+XS(_wrap_CoreSession_execute) {
</ins><span class="cx">   {
</span><span class="cx">     CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">     char *arg2 = (char *) 0 ;
</span><del>-    char *arg3 = (char *) 0 ;
</del><ins>+    char *arg3 = (char *) NULL ;
</ins><span class="cx">     void *argp1 = 0 ;
</span><span class="cx">     int res1 = 0 ;
</span><span class="cx">     int res2 ;
</span><span class="lines">@@ -9720,7 +7086,7 @@
</span><span class="cx">     int argvi = 0;
</span><span class="cx">     dXSARGS;
</span><span class="cx">     
</span><del>-    if ((items &lt; 3) || (items &gt; 3)) {
</del><ins>+    if ((items &lt; 2) || (items &gt; 3)) {
</ins><span class="cx">       SWIG_croak(&quot;Usage: CoreSession_execute(self,app,data);&quot;);
</span><span class="cx">     }
</span><span class="cx">     res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="lines">@@ -9733,11 +7099,13 @@
</span><span class="cx">       SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_execute&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</span><span class="cx">     }
</span><span class="cx">     arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</span><del>-    res3 = SWIG_AsCharPtrAndSize(ST(2), &amp;buf3, NULL, &amp;alloc3);
-    if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_execute&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+    if (items &gt; 2) {
+      res3 = SWIG_AsCharPtrAndSize(ST(2), &amp;buf3, NULL, &amp;alloc3);
+      if (!SWIG_IsOK(res3)) {
+        SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_execute&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+      }
+      arg3 = reinterpret_cast&lt; char * &gt;(buf3);
</ins><span class="cx">     }
</span><del>-    arg3 = reinterpret_cast&lt; char * &gt;(buf3);
</del><span class="cx">     (arg1)-&gt;execute((char const *)arg2,(char const *)arg3);
</span><span class="cx">     
</span><span class="cx">     
</span><span class="lines">@@ -9753,130 +7121,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-XS(_wrap_CoreSession_execute__SWIG_1) {
-  {
-    CoreSession *arg1 = (CoreSession *) 0 ;
-    char *arg2 = (char *) 0 ;
-    void *argp1 = 0 ;
-    int res1 = 0 ;
-    int res2 ;
-    char *buf2 = 0 ;
-    int alloc2 = 0 ;
-    int argvi = 0;
-    dXSARGS;
-    
-    if ((items &lt; 2) || (items &gt; 2)) {
-      SWIG_croak(&quot;Usage: CoreSession_execute(self,app);&quot;);
-    }
-    res1 = SWIG_ConvertPtr(ST(0), &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_execute&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-    }
-    arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-    res2 = SWIG_AsCharPtrAndSize(ST(1), &amp;buf2, NULL, &amp;alloc2);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_execute&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-    }
-    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-    (arg1)-&gt;execute((char const *)arg2);
-    
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    XSRETURN(argvi);
-  fail:
-    
-    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-    SWIG_croak_null();
-  }
-}
-
-
-XS(_wrap_CoreSession_execute) {
-  dXSARGS;
-  
-  {
-    unsigned long _index = 0;
-    SWIG_TypeRank _rank = 0; 
-    if (items == 2) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_1;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 1;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_1:
-    
-    if (items == 3) {
-      SWIG_TypeRank _ranki = 0;
-      SWIG_TypeRank _rankm = 0;
-      SWIG_TypeRank _pi = 1;
-      int _v = 0;
-      {
-        void *vptr = 0;
-        int res = SWIG_ConvertPtr(ST(0), &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      {
-        int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-      }
-      if (!_v) goto check_2;
-      _ranki += _v*_pi;
-      _rankm += _pi;
-      _pi *= SWIG_MAXCASTRANK;
-      if (!_index || (_ranki &lt; _rank)) {
-        _rank = _ranki; _index = 2;
-        if (_rank == _rankm) goto dispatch;
-      }
-    }
-  check_2:
-    
-  dispatch:
-    switch(_index) {
-    case 1:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_execute__SWIG_1); return;
-    case 2:
-      ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_execute__SWIG_0); return;
-    }
-  }
-  
-  croak(&quot;No matching function for overloaded 'CoreSession_execute'&quot;);
-  XSRETURN(0);
-}
-
-
</del><span class="cx"> XS(_wrap_CoreSession_sendEvent) {
</span><span class="cx">   {
</span><span class="cx">     CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -11746,7 +8990,6 @@
</span><span class="cx"> static swig_type_info _swigt__p_switch_channel_state_t = {&quot;_p_switch_channel_state_t&quot;, &quot;switch_channel_state_t *&quot;, 0, 0, (void*)0, 0};
</span><span class="cx"> static swig_type_info _swigt__p_switch_channel_t = {&quot;_p_switch_channel_t&quot;, &quot;switch_channel_t *&quot;, 0, 0, (void*)0, 0};
</span><span class="cx"> static swig_type_info _swigt__p_switch_core_session_t = {&quot;_p_switch_core_session_t&quot;, &quot;switch_core_session_t *&quot;, 0, 0, (void*)0, 0};
</span><del>-static swig_type_info _swigt__p_switch_event_node_t = {&quot;_p_switch_event_node_t&quot;, &quot;switch_event_node_t *&quot;, 0, 0, (void*)0, 0};
</del><span class="cx"> static swig_type_info _swigt__p_switch_event_t = {&quot;_p_switch_event_t&quot;, &quot;switch_event_t *&quot;, 0, 0, (void*)0, 0};
</span><span class="cx"> static swig_type_info _swigt__p_switch_event_types_t = {&quot;_p_switch_event_types_t&quot;, &quot;switch_event_types_t *&quot;, 0, 0, (void*)0, 0};
</span><span class="cx"> static swig_type_info _swigt__p_switch_input_args_t = {&quot;_p_switch_input_args_t&quot;, &quot;switch_input_args_t *&quot;, 0, 0, (void*)0, 0};
</span><span class="lines">@@ -11776,7 +9019,6 @@
</span><span class="cx">   &amp;_swigt__p_switch_channel_state_t,
</span><span class="cx">   &amp;_swigt__p_switch_channel_t,
</span><span class="cx">   &amp;_swigt__p_switch_core_session_t,
</span><del>-  &amp;_swigt__p_switch_event_node_t,
</del><span class="cx">   &amp;_swigt__p_switch_event_t,
</span><span class="cx">   &amp;_swigt__p_switch_event_types_t,
</span><span class="cx">   &amp;_swigt__p_switch_input_args_t,
</span><span class="lines">@@ -11806,7 +9048,6 @@
</span><span class="cx"> static swig_cast_info _swigc__p_switch_channel_state_t[] = {  {&amp;_swigt__p_switch_channel_state_t, 0, 0, 0},{0, 0, 0, 0}};
</span><span class="cx"> static swig_cast_info _swigc__p_switch_channel_t[] = {  {&amp;_swigt__p_switch_channel_t, 0, 0, 0},{0, 0, 0, 0}};
</span><span class="cx"> static swig_cast_info _swigc__p_switch_core_session_t[] = {  {&amp;_swigt__p_switch_core_session_t, 0, 0, 0},{0, 0, 0, 0}};
</span><del>-static swig_cast_info _swigc__p_switch_event_node_t[] = {  {&amp;_swigt__p_switch_event_node_t, 0, 0, 0},{0, 0, 0, 0}};
</del><span class="cx"> static swig_cast_info _swigc__p_switch_event_t[] = {  {&amp;_swigt__p_switch_event_t, 0, 0, 0},{0, 0, 0, 0}};
</span><span class="cx"> static swig_cast_info _swigc__p_switch_event_types_t[] = {  {&amp;_swigt__p_switch_event_types_t, 0, 0, 0},{0, 0, 0, 0}};
</span><span class="cx"> static swig_cast_info _swigc__p_switch_input_args_t[] = {  {&amp;_swigt__p_switch_input_args_t, 0, 0, 0},{0, 0, 0, 0}};
</span><span class="lines">@@ -11836,7 +9077,6 @@
</span><span class="cx">   _swigc__p_switch_channel_state_t,
</span><span class="cx">   _swigc__p_switch_channel_t,
</span><span class="cx">   _swigc__p_switch_core_session_t,
</span><del>-  _swigc__p_switch_event_node_t,
</del><span class="cx">   _swigc__p_switch_event_t,
</span><span class="cx">   _swigc__p_switch_event_types_t,
</span><span class="cx">   _swigc__p_switch_input_args_t,
</span><span class="lines">@@ -11915,8 +9155,6 @@
</span><span class="cx"> {&quot;freeswitchc::EventConsumer_events_get&quot;, _wrap_EventConsumer_events_get},
</span><span class="cx"> {&quot;freeswitchc::EventConsumer_e_event_id_set&quot;, _wrap_EventConsumer_e_event_id_set},
</span><span class="cx"> {&quot;freeswitchc::EventConsumer_e_event_id_get&quot;, _wrap_EventConsumer_e_event_id_get},
</span><del>-{&quot;freeswitchc::EventConsumer_node_set&quot;, _wrap_EventConsumer_node_set},
-{&quot;freeswitchc::EventConsumer_node_get&quot;, _wrap_EventConsumer_node_get},
</del><span class="cx"> {&quot;freeswitchc::EventConsumer_e_callback_set&quot;, _wrap_EventConsumer_e_callback_set},
</span><span class="cx"> {&quot;freeswitchc::EventConsumer_e_callback_get&quot;, _wrap_EventConsumer_e_callback_get},
</span><span class="cx"> {&quot;freeswitchc::EventConsumer_e_subclass_name_set&quot;, _wrap_EventConsumer_e_subclass_name_set},
</span><span class="lines">@@ -11925,6 +9163,7 @@
</span><span class="cx"> {&quot;freeswitchc::EventConsumer_e_cb_arg_get&quot;, _wrap_EventConsumer_e_cb_arg_get},
</span><span class="cx"> {&quot;freeswitchc::new_EventConsumer&quot;, _wrap_new_EventConsumer},
</span><span class="cx"> {&quot;freeswitchc::delete_EventConsumer&quot;, _wrap_delete_EventConsumer},
</span><ins>+{&quot;freeswitchc::EventConsumer_bind&quot;, _wrap_EventConsumer_bind},
</ins><span class="cx"> {&quot;freeswitchc::EventConsumer_pop&quot;, _wrap_EventConsumer_pop},
</span><span class="cx"> {&quot;freeswitchc::delete_CoreSession&quot;, _wrap_delete_CoreSession},
</span><span class="cx"> {&quot;freeswitchc::CoreSession_session_set&quot;, _wrap_CoreSession_session_set},
</span><span class="lines">@@ -12318,17 +9557,17 @@
</span><span class="cx">   SWIG_TypeClientData(SWIGTYPE_p_IVRMenu, (void*) &quot;freeswitch::IVRMenu&quot;);
</span><span class="cx">   SWIG_TypeClientData(SWIGTYPE_p_API, (void*) &quot;freeswitch::API&quot;);
</span><span class="cx">   SWIG_TypeClientData(SWIGTYPE_p_input_callback_state, (void*) &quot;freeswitch::input_callback_state_t&quot;);
</span><del>-  /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
</del><ins>+  /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
</ins><span class="cx">     SV *sv = get_sv((char*) SWIG_prefix &quot;S_HUP&quot;, TRUE | 0x2 | GV_ADDMULTI);
</span><span class="cx">     sv_setsv(sv, SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(S_HUP)));
</span><span class="cx">     SvREADONLY_on(sv);
</span><span class="cx">   } while(0) /*@SWIG@*/;
</span><del>-  /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
</del><ins>+  /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
</ins><span class="cx">     SV *sv = get_sv((char*) SWIG_prefix &quot;S_FREE&quot;, TRUE | 0x2 | GV_ADDMULTI);
</span><span class="cx">     sv_setsv(sv, SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(S_FREE)));
</span><span class="cx">     SvREADONLY_on(sv);
</span><span class="cx">   } while(0) /*@SWIG@*/;
</span><del>-  /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
</del><ins>+  /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
</ins><span class="cx">     SV *sv = get_sv((char*) SWIG_prefix &quot;S_RDLOCK&quot;, TRUE | 0x2 | GV_ADDMULTI);
</span><span class="cx">     sv_setsv(sv, SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast&lt; int &gt;(S_RDLOCK)));
</span><span class="cx">     SvREADONLY_on(sv);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_pythonfreeswitchpy"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py (17515 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py        2010-05-10 17:03:22 UTC (rev 17515)
+++ freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -198,9 +198,6 @@
</span><span class="cx">     __swig_setmethods__[&quot;e_event_id&quot;] = _freeswitch.EventConsumer_e_event_id_set
</span><span class="cx">     __swig_getmethods__[&quot;e_event_id&quot;] = _freeswitch.EventConsumer_e_event_id_get
</span><span class="cx">     if _newclass:e_event_id = _swig_property(_freeswitch.EventConsumer_e_event_id_get, _freeswitch.EventConsumer_e_event_id_set)
</span><del>-    __swig_setmethods__[&quot;node&quot;] = _freeswitch.EventConsumer_node_set
-    __swig_getmethods__[&quot;node&quot;] = _freeswitch.EventConsumer_node_get
-    if _newclass:node = _swig_property(_freeswitch.EventConsumer_node_get, _freeswitch.EventConsumer_node_set)
</del><span class="cx">     __swig_setmethods__[&quot;e_callback&quot;] = _freeswitch.EventConsumer_e_callback_set
</span><span class="cx">     __swig_getmethods__[&quot;e_callback&quot;] = _freeswitch.EventConsumer_e_callback_get
</span><span class="cx">     if _newclass:e_callback = _swig_property(_freeswitch.EventConsumer_e_callback_get, _freeswitch.EventConsumer_e_callback_set)
</span><span class="lines">@@ -216,6 +213,7 @@
</span><span class="cx">         except: self.this = this
</span><span class="cx">     __swig_destroy__ = _freeswitch.delete_EventConsumer
</span><span class="cx">     __del__ = lambda self : None;
</span><ins>+    def bind(*args): return _freeswitch.EventConsumer_bind(*args)
</ins><span class="cx">     def pop(*args): return _freeswitch.EventConsumer_pop(*args)
</span><span class="cx"> EventConsumer_swigregister = _freeswitch.EventConsumer_swigregister
</span><span class="cx"> EventConsumer_swigregister(EventConsumer)
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_pythonmod_python_wrapcpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp (17515 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp        2010-05-10 17:03:22 UTC (rev 17515)
+++ freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -2510,20 +2510,19 @@
</span><span class="cx"> #define SWIGTYPE_p_switch_channel_state_t swig_types[12]
</span><span class="cx"> #define SWIGTYPE_p_switch_channel_t swig_types[13]
</span><span class="cx"> #define SWIGTYPE_p_switch_core_session_t swig_types[14]
</span><del>-#define SWIGTYPE_p_switch_event_node_t swig_types[15]
-#define SWIGTYPE_p_switch_event_t swig_types[16]
-#define SWIGTYPE_p_switch_event_types_t swig_types[17]
-#define SWIGTYPE_p_switch_input_args_t swig_types[18]
-#define SWIGTYPE_p_switch_input_type_t swig_types[19]
-#define SWIGTYPE_p_switch_priority_t swig_types[20]
-#define SWIGTYPE_p_switch_queue_t swig_types[21]
-#define SWIGTYPE_p_switch_state_handler_table_t swig_types[22]
-#define SWIGTYPE_p_switch_status_t swig_types[23]
-#define SWIGTYPE_p_switch_stream_handle_t swig_types[24]
-#define SWIGTYPE_p_uint32_t swig_types[25]
-#define SWIGTYPE_p_void swig_types[26]
-static swig_type_info *swig_types[28];
-static swig_module_info swig_module = {swig_types, 27, 0, 0, 0, 0};
</del><ins>+#define SWIGTYPE_p_switch_event_t swig_types[15]
+#define SWIGTYPE_p_switch_event_types_t swig_types[16]
+#define SWIGTYPE_p_switch_input_args_t swig_types[17]
+#define SWIGTYPE_p_switch_input_type_t swig_types[18]
+#define SWIGTYPE_p_switch_priority_t swig_types[19]
+#define SWIGTYPE_p_switch_queue_t swig_types[20]
+#define SWIGTYPE_p_switch_state_handler_table_t swig_types[21]
+#define SWIGTYPE_p_switch_status_t swig_types[22]
+#define SWIGTYPE_p_switch_stream_handle_t swig_types[23]
+#define SWIGTYPE_p_uint32_t swig_types[24]
+#define SWIGTYPE_p_void swig_types[25]
+static swig_type_info *swig_types[27];
+static swig_module_info swig_module = {swig_types, 26, 0, 0, 0, 0};
</ins><span class="cx"> #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&amp;swig_module, &amp;swig_module, name)
</span><span class="cx"> #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&amp;swig_module, &amp;swig_module, name)
</span><span class="cx"> 
</span><span class="lines">@@ -3418,11 +3417,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_API_execute__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</del><ins>+SWIGINTERN PyObject *_wrap_API_execute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</ins><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   API *arg1 = (API *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  char *arg3 = (char *) 0 ;
</del><ins>+  char *arg3 = (char *) NULL ;
</ins><span class="cx">   char *result = 0 ;
</span><span class="cx">   void *argp1 = 0 ;
</span><span class="cx">   int res1 = 0 ;
</span><span class="lines">@@ -3436,7 +3435,7 @@
</span><span class="cx">   PyObject * obj1 = 0 ;
</span><span class="cx">   PyObject * obj2 = 0 ;
</span><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OOO:API_execute&quot;,&amp;obj0,&amp;obj1,&amp;obj2)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;OO|O:API_execute&quot;,&amp;obj0,&amp;obj1,&amp;obj2)) SWIG_fail;
</ins><span class="cx">   res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_API, 0 |  0 );
</span><span class="cx">   if (!SWIG_IsOK(res1)) {
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;API_execute&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;API *&quot;&quot;'&quot;); 
</span><span class="lines">@@ -3447,11 +3446,13 @@
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;API_execute&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</span><span class="cx">   }
</span><span class="cx">   arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</span><del>-  res3 = SWIG_AsCharPtrAndSize(obj2, &amp;buf3, NULL, &amp;alloc3);
-  if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;API_execute&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+  if (obj2) {
+    res3 = SWIG_AsCharPtrAndSize(obj2, &amp;buf3, NULL, &amp;alloc3);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;API_execute&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+    }
+    arg3 = reinterpret_cast&lt; char * &gt;(buf3);
</ins><span class="cx">   }
</span><del>-  arg3 = reinterpret_cast&lt; char * &gt;(buf3);
</del><span class="cx">   result = (char *)(arg1)-&gt;execute((char const *)arg2,(char const *)arg3);
</span><span class="cx">   resultobj = SWIG_FromCharPtr((const char *)result);
</span><span class="cx">   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
</span><span class="lines">@@ -3464,90 +3465,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_API_execute__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  API *arg1 = (API *) 0 ;
-  char *arg2 = (char *) 0 ;
-  char *result = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int res2 ;
-  char *buf2 = 0 ;
-  int alloc2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;OO:API_execute&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_API, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;API_execute&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;API *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; API * &gt;(argp1);
-  res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;API_execute&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-  }
-  arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-  result = (char *)(arg1)-&gt;execute((char const *)arg2);
-  resultobj = SWIG_FromCharPtr((const char *)result);
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  return resultobj;
-fail:
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_API_execute(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[4];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = (int)PyObject_Length(args);
-  for (ii = 0; (ii &lt; argc) &amp;&amp; (ii &lt; 3); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 2) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_API, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        return _wrap_API_execute__SWIG_1(self, args);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_API, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_API_execute__SWIG_0(self, args);
-        }
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,&quot;Wrong number of arguments for overloaded function 'API_execute'.\n&quot;
-    &quot;  Possible C/C++ prototypes are:\n&quot;
-    &quot;    execute(API *,char const *,char const *)\n&quot;
-    &quot;    execute(API *,char const *)\n&quot;);
-  return NULL;
-}
-
-
</del><span class="cx"> SWIGINTERN PyObject *_wrap_API_executeString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</span><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   API *arg1 = (API *) 0 ;
</span><span class="lines">@@ -3981,10 +3898,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_new_DTMF__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</del><ins>+SWIGINTERN PyObject *_wrap_new_DTMF(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</ins><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   char arg1 ;
</span><del>-  uint32_t arg2 ;
</del><ins>+  uint32_t arg2 = (uint32_t) SWITCH_DEFAULT_DTMF_DURATION ;
</ins><span class="cx">   DTMF *result = 0 ;
</span><span class="cx">   char val1 ;
</span><span class="cx">   int ecode1 = 0 ;
</span><span class="lines">@@ -3993,23 +3910,25 @@
</span><span class="cx">   PyObject * obj0 = 0 ;
</span><span class="cx">   PyObject * obj1 = 0 ;
</span><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OO:new_DTMF&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;O|O:new_DTMF&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
</ins><span class="cx">   ecode1 = SWIG_AsVal_char(obj0, &amp;val1);
</span><span class="cx">   if (!SWIG_IsOK(ecode1)) {
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(ecode1), &quot;in method '&quot; &quot;new_DTMF&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;char&quot;&quot;'&quot;);
</span><span class="cx">   } 
</span><span class="cx">   arg1 = static_cast&lt; char &gt;(val1);
</span><del>-  {
-    res2 = SWIG_ConvertPtr(obj1, &amp;argp2, SWIGTYPE_p_uint32_t,  0  | 0);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;new_DTMF&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;uint32_t&quot;&quot;'&quot;); 
-    }  
-    if (!argp2) {
-      SWIG_exception_fail(SWIG_ValueError, &quot;invalid null reference &quot; &quot;in method '&quot; &quot;new_DTMF&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;uint32_t&quot;&quot;'&quot;);
-    } else {
-      uint32_t * temp = reinterpret_cast&lt; uint32_t * &gt;(argp2);
-      arg2 = *temp;
-      if (SWIG_IsNewObj(res2)) delete temp;
</del><ins>+  if (obj1) {
+    {
+      res2 = SWIG_ConvertPtr(obj1, &amp;argp2, SWIGTYPE_p_uint32_t,  0  | 0);
+      if (!SWIG_IsOK(res2)) {
+        SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;new_DTMF&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;uint32_t&quot;&quot;'&quot;); 
+      }  
+      if (!argp2) {
+        SWIG_exception_fail(SWIG_ValueError, &quot;invalid null reference &quot; &quot;in method '&quot; &quot;new_DTMF&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;uint32_t&quot;&quot;'&quot;);
+      } else {
+        uint32_t * temp = reinterpret_cast&lt; uint32_t * &gt;(argp2);
+        arg2 = *temp;
+        if (SWIG_IsNewObj(res2)) delete temp;
+      }
</ins><span class="cx">     }
</span><span class="cx">   }
</span><span class="cx">   result = (DTMF *)new DTMF(arg1,arg2);
</span><span class="lines">@@ -4020,72 +3939,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_new_DTMF__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  char arg1 ;
-  DTMF *result = 0 ;
-  char val1 ;
-  int ecode1 = 0 ;
-  PyObject * obj0 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;O:new_DTMF&quot;,&amp;obj0)) SWIG_fail;
-  ecode1 = SWIG_AsVal_char(obj0, &amp;val1);
-  if (!SWIG_IsOK(ecode1)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode1), &quot;in method '&quot; &quot;new_DTMF&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;char&quot;&quot;'&quot;);
-  } 
-  arg1 = static_cast&lt; char &gt;(val1);
-  result = (DTMF *)new DTMF(arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_DTMF, SWIG_POINTER_NEW |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_DTMF(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[3];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = (int)PyObject_Length(args);
-  for (ii = 0; (ii &lt; argc) &amp;&amp; (ii &lt; 2); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 1) {
-    int _v;
-    {
-      int res = SWIG_AsVal_char(argv[0], NULL);
-      _v = SWIG_CheckState(res);
-    }
-    if (_v) {
-      return _wrap_new_DTMF__SWIG_1(self, args);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    {
-      int res = SWIG_AsVal_char(argv[0], NULL);
-      _v = SWIG_CheckState(res);
-    }
-    if (_v) {
-      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_uint32_t, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        return _wrap_new_DTMF__SWIG_0(self, args);
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,&quot;Wrong number of arguments for overloaded function 'new_DTMF'.\n&quot;
-    &quot;  Possible C/C++ prototypes are:\n&quot;
-    &quot;    DTMF(char,uint32_t)\n&quot;
-    &quot;    DTMF(char)\n&quot;);
-  return NULL;
-}
-
-
</del><span class="cx"> SWIGINTERN PyObject *_wrap_delete_DTMF(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</span><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   DTMF *arg1 = (DTMF *) 0 ;
</span><span class="lines">@@ -4436,7 +4289,7 @@
</span><span class="cx"> SWIGINTERN PyObject *_wrap_new_Event__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</span><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   char *arg1 = (char *) 0 ;
</span><del>-  char *arg2 = (char *) 0 ;
</del><ins>+  char *arg2 = (char *) NULL ;
</ins><span class="cx">   Event *result = 0 ;
</span><span class="cx">   int res1 ;
</span><span class="cx">   char *buf1 = 0 ;
</span><span class="lines">@@ -4447,17 +4300,19 @@
</span><span class="cx">   PyObject * obj0 = 0 ;
</span><span class="cx">   PyObject * obj1 = 0 ;
</span><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OO:new_Event&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;O|O:new_Event&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
</ins><span class="cx">   res1 = SWIG_AsCharPtrAndSize(obj0, &amp;buf1, NULL, &amp;alloc1);
</span><span class="cx">   if (!SWIG_IsOK(res1)) {
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;new_Event&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</span><span class="cx">   }
</span><span class="cx">   arg1 = reinterpret_cast&lt; char * &gt;(buf1);
</span><del>-  res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;new_Event&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+  if (obj1) {
+    res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;new_Event&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+    }
+    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</ins><span class="cx">   }
</span><del>-  arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</del><span class="cx">   result = (Event *)new Event((char const *)arg1,(char const *)arg2);
</span><span class="cx">   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_POINTER_NEW |  0 );
</span><span class="cx">   if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
</span><span class="lines">@@ -4472,33 +4327,8 @@
</span><span class="cx"> 
</span><span class="cx"> SWIGINTERN PyObject *_wrap_new_Event__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</span><span class="cx">   PyObject *resultobj = 0;
</span><del>-  char *arg1 = (char *) 0 ;
-  Event *result = 0 ;
-  int res1 ;
-  char *buf1 = 0 ;
-  int alloc1 = 0 ;
-  PyObject * obj0 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;O:new_Event&quot;,&amp;obj0)) SWIG_fail;
-  res1 = SWIG_AsCharPtrAndSize(obj0, &amp;buf1, NULL, &amp;alloc1);
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;new_Event&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-  }
-  arg1 = reinterpret_cast&lt; char * &gt;(buf1);
-  result = (Event *)new Event((char const *)arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_POINTER_NEW |  0 );
-  if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
-  return resultobj;
-fail:
-  if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_Event__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
</del><span class="cx">   switch_event_t *arg1 = (switch_event_t *) 0 ;
</span><del>-  int arg2 ;
</del><ins>+  int arg2 = (int) 0 ;
</ins><span class="cx">   Event *result = 0 ;
</span><span class="cx">   void *argp1 = 0 ;
</span><span class="cx">   int res1 = 0 ;
</span><span class="lines">@@ -4507,17 +4337,19 @@
</span><span class="cx">   PyObject * obj0 = 0 ;
</span><span class="cx">   PyObject * obj1 = 0 ;
</span><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OO:new_Event&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;O|O:new_Event&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
</ins><span class="cx">   res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_switch_event_t, 0 |  0 );
</span><span class="cx">   if (!SWIG_IsOK(res1)) {
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;new_Event&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;switch_event_t *&quot;&quot;'&quot;); 
</span><span class="cx">   }
</span><span class="cx">   arg1 = reinterpret_cast&lt; switch_event_t * &gt;(argp1);
</span><del>-  ecode2 = SWIG_AsVal_int(obj1, &amp;val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), &quot;in method '&quot; &quot;new_Event&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-  } 
-  arg2 = static_cast&lt; int &gt;(val2);
</del><ins>+  if (obj1) {
+    ecode2 = SWIG_AsVal_int(obj1, &amp;val2);
+    if (!SWIG_IsOK(ecode2)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode2), &quot;in method '&quot; &quot;new_Event&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+    } 
+    arg2 = static_cast&lt; int &gt;(val2);
+  }
</ins><span class="cx">   result = (Event *)new Event(arg1,arg2);
</span><span class="cx">   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_POINTER_NEW |  0 );
</span><span class="cx">   return resultobj;
</span><span class="lines">@@ -4526,28 +4358,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_new_Event__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  switch_event_t *arg1 = (switch_event_t *) 0 ;
-  Event *result = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;O:new_Event&quot;,&amp;obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_switch_event_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;new_Event&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;switch_event_t *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; switch_event_t * &gt;(argp1);
-  result = (Event *)new Event(arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_POINTER_NEW |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
</del><span class="cx"> SWIGINTERN PyObject *_wrap_new_Event(PyObject *self, PyObject *args) {
</span><span class="cx">   int argc;
</span><span class="cx">   PyObject *argv[3];
</span><span class="lines">@@ -4558,43 +4368,32 @@
</span><span class="cx">   for (ii = 0; (ii &lt; argc) &amp;&amp; (ii &lt; 2); ii++) {
</span><span class="cx">     argv[ii] = PyTuple_GET_ITEM(args,ii);
</span><span class="cx">   }
</span><del>-  if (argc == 1) {
</del><ins>+  if ((argc &gt;= 1) &amp;&amp; (argc &lt;= 2)) {
</ins><span class="cx">     int _v;
</span><span class="cx">     void *vptr = 0;
</span><span class="cx">     int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_switch_event_t, 0);
</span><span class="cx">     _v = SWIG_CheckState(res);
</span><span class="cx">     if (_v) {
</span><del>-      return _wrap_new_Event__SWIG_3(self, args);
-    }
-  }
-  if (argc == 1) {
-    int _v;
-    int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      return _wrap_new_Event__SWIG_1(self, args);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_switch_event_t, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
</del><ins>+      if (argc &lt;= 1) {
+        return _wrap_new_Event__SWIG_1(self, args);
+      }
</ins><span class="cx">       {
</span><span class="cx">         int res = SWIG_AsVal_int(argv[1], NULL);
</span><span class="cx">         _v = SWIG_CheckState(res);
</span><span class="cx">       }
</span><span class="cx">       if (_v) {
</span><del>-        return _wrap_new_Event__SWIG_2(self, args);
</del><ins>+        return _wrap_new_Event__SWIG_1(self, args);
</ins><span class="cx">       }
</span><span class="cx">     }
</span><span class="cx">   }
</span><del>-  if (argc == 2) {
</del><ins>+  if ((argc &gt;= 1) &amp;&amp; (argc &lt;= 2)) {
</ins><span class="cx">     int _v;
</span><span class="cx">     int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0);
</span><span class="cx">     _v = SWIG_CheckState(res);
</span><span class="cx">     if (_v) {
</span><ins>+      if (argc &lt;= 1) {
+        return _wrap_new_Event__SWIG_0(self, args);
+      }
</ins><span class="cx">       int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
</span><span class="cx">       _v = SWIG_CheckState(res);
</span><span class="cx">       if (_v) {
</span><span class="lines">@@ -4607,9 +4406,7 @@
</span><span class="cx">   SWIG_SetErrorMsg(PyExc_NotImplementedError,&quot;Wrong number of arguments for overloaded function 'new_Event'.\n&quot;
</span><span class="cx">     &quot;  Possible C/C++ prototypes are:\n&quot;
</span><span class="cx">     &quot;    Event(char const *,char const *)\n&quot;
</span><del>-    &quot;    Event(char const *)\n&quot;
-    &quot;    Event(switch_event_t *,int)\n&quot;
-    &quot;    Event(switch_event_t *)\n&quot;);
</del><ins>+    &quot;    Event(switch_event_t *,int)\n&quot;);
</ins><span class="cx">   return NULL;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -4636,10 +4433,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_Event_serialize__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</del><ins>+SWIGINTERN PyObject *_wrap_Event_serialize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</ins><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   Event *arg1 = (Event *) 0 ;
</span><del>-  char *arg2 = (char *) 0 ;
</del><ins>+  char *arg2 = (char *) NULL ;
</ins><span class="cx">   char *result = 0 ;
</span><span class="cx">   void *argp1 = 0 ;
</span><span class="cx">   int res1 = 0 ;
</span><span class="lines">@@ -4649,17 +4446,19 @@
</span><span class="cx">   PyObject * obj0 = 0 ;
</span><span class="cx">   PyObject * obj1 = 0 ;
</span><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OO:Event_serialize&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;O|O:Event_serialize&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
</ins><span class="cx">   res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_Event, 0 |  0 );
</span><span class="cx">   if (!SWIG_IsOK(res1)) {
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;Event_serialize&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;Event *&quot;&quot;'&quot;); 
</span><span class="cx">   }
</span><span class="cx">   arg1 = reinterpret_cast&lt; Event * &gt;(argp1);
</span><del>-  res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;Event_serialize&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+  if (obj1) {
+    res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;Event_serialize&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+    }
+    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</ins><span class="cx">   }
</span><del>-  arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</del><span class="cx">   result = (char *)(arg1)-&gt;serialize((char const *)arg2);
</span><span class="cx">   resultobj = SWIG_FromCharPtr((const char *)result);
</span><span class="cx">   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
</span><span class="lines">@@ -4670,74 +4469,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_Event_serialize__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</del><ins>+SWIGINTERN PyObject *_wrap_Event_setPriority(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</ins><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   Event *arg1 = (Event *) 0 ;
</span><del>-  char *result = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;O:Event_serialize&quot;,&amp;obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_Event, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;Event_serialize&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;Event *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; Event * &gt;(argp1);
-  result = (char *)(arg1)-&gt;serialize();
-  resultobj = SWIG_FromCharPtr((const char *)result);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Event_serialize(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[3];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = (int)PyObject_Length(args);
-  for (ii = 0; (ii &lt; argc) &amp;&amp; (ii &lt; 2); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 1) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_Event, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      return _wrap_Event_serialize__SWIG_1(self, args);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_Event, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        return _wrap_Event_serialize__SWIG_0(self, args);
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,&quot;Wrong number of arguments for overloaded function 'Event_serialize'.\n&quot;
-    &quot;  Possible C/C++ prototypes are:\n&quot;
-    &quot;    serialize(Event *,char const *)\n&quot;
-    &quot;    serialize(Event *)\n&quot;);
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Event_setPriority__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  Event *arg1 = (Event *) 0 ;
-  switch_priority_t arg2 ;
</del><ins>+  switch_priority_t arg2 = (switch_priority_t) SWITCH_PRIORITY_NORMAL ;
</ins><span class="cx">   bool result;
</span><span class="cx">   void *argp1 = 0 ;
</span><span class="cx">   int res1 = 0 ;
</span><span class="lines">@@ -4746,23 +4481,25 @@
</span><span class="cx">   PyObject * obj0 = 0 ;
</span><span class="cx">   PyObject * obj1 = 0 ;
</span><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OO:Event_setPriority&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;O|O:Event_setPriority&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
</ins><span class="cx">   res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_Event, 0 |  0 );
</span><span class="cx">   if (!SWIG_IsOK(res1)) {
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;Event_setPriority&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;Event *&quot;&quot;'&quot;); 
</span><span class="cx">   }
</span><span class="cx">   arg1 = reinterpret_cast&lt; Event * &gt;(argp1);
</span><del>-  {
-    res2 = SWIG_ConvertPtr(obj1, &amp;argp2, SWIGTYPE_p_switch_priority_t,  0  | 0);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;Event_setPriority&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;switch_priority_t&quot;&quot;'&quot;); 
-    }  
-    if (!argp2) {
-      SWIG_exception_fail(SWIG_ValueError, &quot;invalid null reference &quot; &quot;in method '&quot; &quot;Event_setPriority&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;switch_priority_t&quot;&quot;'&quot;);
-    } else {
-      switch_priority_t * temp = reinterpret_cast&lt; switch_priority_t * &gt;(argp2);
-      arg2 = *temp;
-      if (SWIG_IsNewObj(res2)) delete temp;
</del><ins>+  if (obj1) {
+    {
+      res2 = SWIG_ConvertPtr(obj1, &amp;argp2, SWIGTYPE_p_switch_priority_t,  0  | 0);
+      if (!SWIG_IsOK(res2)) {
+        SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;Event_setPriority&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;switch_priority_t&quot;&quot;'&quot;); 
+      }  
+      if (!argp2) {
+        SWIG_exception_fail(SWIG_ValueError, &quot;invalid null reference &quot; &quot;in method '&quot; &quot;Event_setPriority&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;switch_priority_t&quot;&quot;'&quot;);
+      } else {
+        switch_priority_t * temp = reinterpret_cast&lt; switch_priority_t * &gt;(argp2);
+        arg2 = *temp;
+        if (SWIG_IsNewObj(res2)) delete temp;
+      }
</ins><span class="cx">     }
</span><span class="cx">   }
</span><span class="cx">   result = (bool)(arg1)-&gt;setPriority(arg2);
</span><span class="lines">@@ -4773,70 +4510,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_Event_setPriority__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  Event *arg1 = (Event *) 0 ;
-  bool result;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;O:Event_setPriority&quot;,&amp;obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_Event, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;Event_setPriority&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;Event *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; Event * &gt;(argp1);
-  result = (bool)(arg1)-&gt;setPriority();
-  resultobj = SWIG_From_bool(static_cast&lt; bool &gt;(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Event_setPriority(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[3];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = (int)PyObject_Length(args);
-  for (ii = 0; (ii &lt; argc) &amp;&amp; (ii &lt; 2); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 1) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_Event, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      return _wrap_Event_setPriority__SWIG_1(self, args);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_Event, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_switch_priority_t, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        return _wrap_Event_setPriority__SWIG_0(self, args);
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,&quot;Wrong number of arguments for overloaded function 'Event_setPriority'.\n&quot;
-    &quot;  Possible C/C++ prototypes are:\n&quot;
-    &quot;    setPriority(Event *,switch_priority_t)\n&quot;
-    &quot;    setPriority(Event *)\n&quot;);
-  return NULL;
-}
-
-
</del><span class="cx"> SWIGINTERN PyObject *_wrap_Event_getHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</span><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   Event *arg1 = (Event *) 0 ;
</span><span class="lines">@@ -5172,59 +4845,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_EventConsumer_node_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  EventConsumer *arg1 = (EventConsumer *) 0 ;
-  switch_event_node_t *arg2 = (switch_event_node_t *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  void *argp2 = 0 ;
-  int res2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;OO:EventConsumer_node_set&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_EventConsumer, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;EventConsumer_node_set&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;EventConsumer *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; EventConsumer * &gt;(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &amp;argp2,SWIGTYPE_p_switch_event_node_t, SWIG_POINTER_DISOWN |  0 );
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;EventConsumer_node_set&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;switch_event_node_t *&quot;&quot;'&quot;); 
-  }
-  arg2 = reinterpret_cast&lt; switch_event_node_t * &gt;(argp2);
-  if (arg1) (arg1)-&gt;node = arg2;
-  
-  resultobj = SWIG_Py_Void();
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_EventConsumer_node_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  EventConsumer *arg1 = (EventConsumer *) 0 ;
-  switch_event_node_t *result = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;O:EventConsumer_node_get&quot;,&amp;obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_EventConsumer, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;EventConsumer_node_get&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;EventConsumer *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; EventConsumer * &gt;(argp1);
-  result = (switch_event_node_t *) ((arg1)-&gt;node);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_switch_event_node_t, 0 |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
</del><span class="cx"> SWIGINTERN PyObject *_wrap_EventConsumer_e_callback_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</span><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   EventConsumer *arg1 = (EventConsumer *) 0 ;
</span><span class="lines">@@ -5408,10 +5028,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_new_EventConsumer__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</del><ins>+SWIGINTERN PyObject *_wrap_new_EventConsumer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</ins><span class="cx">   PyObject *resultobj = 0;
</span><del>-  char *arg1 = (char *) 0 ;
-  char *arg2 = (char *) 0 ;
</del><ins>+  char *arg1 = (char *) NULL ;
+  char *arg2 = (char *) &quot;&quot; ;
</ins><span class="cx">   EventConsumer *result = 0 ;
</span><span class="cx">   int res1 ;
</span><span class="cx">   char *buf1 = 0 ;
</span><span class="lines">@@ -5422,17 +5042,21 @@
</span><span class="cx">   PyObject * obj0 = 0 ;
</span><span class="cx">   PyObject * obj1 = 0 ;
</span><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OO:new_EventConsumer&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
-  res1 = SWIG_AsCharPtrAndSize(obj0, &amp;buf1, NULL, &amp;alloc1);
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;new_EventConsumer&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;|OO:new_EventConsumer&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
+  if (obj0) {
+    res1 = SWIG_AsCharPtrAndSize(obj0, &amp;buf1, NULL, &amp;alloc1);
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;new_EventConsumer&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+    }
+    arg1 = reinterpret_cast&lt; char * &gt;(buf1);
</ins><span class="cx">   }
</span><del>-  arg1 = reinterpret_cast&lt; char * &gt;(buf1);
-  res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;new_EventConsumer&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+  if (obj1) {
+    res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;new_EventConsumer&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+    }
+    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</ins><span class="cx">   }
</span><del>-  arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</del><span class="cx">   result = (EventConsumer *)new EventConsumer((char const *)arg1,(char const *)arg2);
</span><span class="cx">   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EventConsumer, SWIG_POINTER_NEW |  0 );
</span><span class="cx">   if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
</span><span class="lines">@@ -5445,71 +5069,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_new_EventConsumer__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  char *arg1 = (char *) 0 ;
-  EventConsumer *result = 0 ;
-  int res1 ;
-  char *buf1 = 0 ;
-  int alloc1 = 0 ;
-  PyObject * obj0 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;O:new_EventConsumer&quot;,&amp;obj0)) SWIG_fail;
-  res1 = SWIG_AsCharPtrAndSize(obj0, &amp;buf1, NULL, &amp;alloc1);
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;new_EventConsumer&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-  }
-  arg1 = reinterpret_cast&lt; char * &gt;(buf1);
-  result = (EventConsumer *)new EventConsumer((char const *)arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EventConsumer, SWIG_POINTER_NEW |  0 );
-  if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
-  return resultobj;
-fail:
-  if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_EventConsumer(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[3];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = (int)PyObject_Length(args);
-  for (ii = 0; (ii &lt; argc) &amp;&amp; (ii &lt; 2); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 1) {
-    int _v;
-    int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      return _wrap_new_EventConsumer__SWIG_1(self, args);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        return _wrap_new_EventConsumer__SWIG_0(self, args);
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,&quot;Wrong number of arguments for overloaded function 'new_EventConsumer'.\n&quot;
-    &quot;  Possible C/C++ prototypes are:\n&quot;
-    &quot;    EventConsumer(char const *,char const *)\n&quot;
-    &quot;    EventConsumer(char const *)\n&quot;);
-  return NULL;
-}
-
-
</del><span class="cx"> SWIGINTERN PyObject *_wrap_delete_EventConsumer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</span><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   EventConsumer *arg1 = (EventConsumer *) 0 ;
</span><span class="lines">@@ -5532,56 +5091,80 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_EventConsumer_pop__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</del><ins>+SWIGINTERN PyObject *_wrap_EventConsumer_bind(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</ins><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   EventConsumer *arg1 = (EventConsumer *) 0 ;
</span><del>-  int arg2 ;
-  Event *result = 0 ;
</del><ins>+  char *arg2 = (char *) 0 ;
+  char *arg3 = (char *) &quot;&quot; ;
+  int result;
</ins><span class="cx">   void *argp1 = 0 ;
</span><span class="cx">   int res1 = 0 ;
</span><del>-  int val2 ;
-  int ecode2 = 0 ;
</del><ins>+  int res2 ;
+  char *buf2 = 0 ;
+  int alloc2 = 0 ;
+  int res3 ;
+  char *buf3 = 0 ;
+  int alloc3 = 0 ;
</ins><span class="cx">   PyObject * obj0 = 0 ;
</span><span class="cx">   PyObject * obj1 = 0 ;
</span><ins>+  PyObject * obj2 = 0 ;
</ins><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OO:EventConsumer_pop&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;OO|O:EventConsumer_bind&quot;,&amp;obj0,&amp;obj1,&amp;obj2)) SWIG_fail;
</ins><span class="cx">   res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_EventConsumer, 0 |  0 );
</span><span class="cx">   if (!SWIG_IsOK(res1)) {
</span><del>-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;EventConsumer_pop&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;EventConsumer *&quot;&quot;'&quot;); 
</del><ins>+    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;EventConsumer_bind&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;EventConsumer *&quot;&quot;'&quot;); 
</ins><span class="cx">   }
</span><span class="cx">   arg1 = reinterpret_cast&lt; EventConsumer * &gt;(argp1);
</span><del>-  ecode2 = SWIG_AsVal_int(obj1, &amp;val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), &quot;in method '&quot; &quot;EventConsumer_pop&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-  } 
-  arg2 = static_cast&lt; int &gt;(val2);
-  Py_BEGIN_ALLOW_THREADS;
-  result = (Event *)(arg1)-&gt;pop(arg2);
-  Py_END_ALLOW_THREADS;
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_POINTER_OWN |  0 );
</del><ins>+  res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;EventConsumer_bind&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+  }
+  arg2 = reinterpret_cast&lt; char * &gt;(buf2);
+  if (obj2) {
+    res3 = SWIG_AsCharPtrAndSize(obj2, &amp;buf3, NULL, &amp;alloc3);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;EventConsumer_bind&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+    }
+    arg3 = reinterpret_cast&lt; char * &gt;(buf3);
+  }
+  result = (int)(arg1)-&gt;bind((char const *)arg2,(char const *)arg3);
+  resultobj = SWIG_From_int(static_cast&lt; int &gt;(result));
+  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+  if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
</ins><span class="cx">   return resultobj;
</span><span class="cx"> fail:
</span><ins>+  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+  if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
</ins><span class="cx">   return NULL;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_EventConsumer_pop__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</del><ins>+SWIGINTERN PyObject *_wrap_EventConsumer_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</ins><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   EventConsumer *arg1 = (EventConsumer *) 0 ;
</span><ins>+  int arg2 = (int) 0 ;
</ins><span class="cx">   Event *result = 0 ;
</span><span class="cx">   void *argp1 = 0 ;
</span><span class="cx">   int res1 = 0 ;
</span><ins>+  int val2 ;
+  int ecode2 = 0 ;
</ins><span class="cx">   PyObject * obj0 = 0 ;
</span><ins>+  PyObject * obj1 = 0 ;
</ins><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;O:EventConsumer_pop&quot;,&amp;obj0)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;O|O:EventConsumer_pop&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
</ins><span class="cx">   res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_EventConsumer, 0 |  0 );
</span><span class="cx">   if (!SWIG_IsOK(res1)) {
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;EventConsumer_pop&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;EventConsumer *&quot;&quot;'&quot;); 
</span><span class="cx">   }
</span><span class="cx">   arg1 = reinterpret_cast&lt; EventConsumer * &gt;(argp1);
</span><del>-  Py_BEGIN_ALLOW_THREADS;
-  result = (Event *)(arg1)-&gt;pop();
-  Py_END_ALLOW_THREADS;
</del><ins>+  if (obj1) {
+    ecode2 = SWIG_AsVal_int(obj1, &amp;val2);
+    if (!SWIG_IsOK(ecode2)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode2), &quot;in method '&quot; &quot;EventConsumer_pop&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+    } 
+    arg2 = static_cast&lt; int &gt;(val2);
+  }
+  result = (Event *)(arg1)-&gt;pop(arg2);
</ins><span class="cx">   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_POINTER_OWN |  0 );
</span><span class="cx">   return resultobj;
</span><span class="cx"> fail:
</span><span class="lines">@@ -5589,50 +5172,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_EventConsumer_pop(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[3];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = (int)PyObject_Length(args);
-  for (ii = 0; (ii &lt; argc) &amp;&amp; (ii &lt; 2); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 1) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_EventConsumer, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      return _wrap_EventConsumer_pop__SWIG_1(self, args);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_EventConsumer, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_int(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        return _wrap_EventConsumer_pop__SWIG_0(self, args);
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,&quot;Wrong number of arguments for overloaded function 'EventConsumer_pop'.\n&quot;
-    &quot;  Possible C/C++ prototypes are:\n&quot;
-    &quot;    pop(EventConsumer *,int)\n&quot;
-    &quot;    pop(EventConsumer *)\n&quot;);
-  return NULL;
-}
-
-
</del><span class="cx"> SWIGINTERN PyObject *EventConsumer_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</span><span class="cx">   PyObject *obj;
</span><span class="cx">   if (!PyArg_ParseTuple(args,(char*)&quot;O:swigregister&quot;, &amp;obj)) return NULL;
</span><span class="lines">@@ -6276,10 +5815,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_CoreSession_hangup__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</del><ins>+SWIGINTERN PyObject *_wrap_CoreSession_hangup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</ins><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><del>-  char *arg2 = (char *) 0 ;
</del><ins>+  char *arg2 = (char *) &quot;normal_clearing&quot; ;
</ins><span class="cx">   void *argp1 = 0 ;
</span><span class="cx">   int res1 = 0 ;
</span><span class="cx">   int res2 ;
</span><span class="lines">@@ -6288,17 +5827,19 @@
</span><span class="cx">   PyObject * obj0 = 0 ;
</span><span class="cx">   PyObject * obj1 = 0 ;
</span><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OO:CoreSession_hangup&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;O|O:CoreSession_hangup&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
</ins><span class="cx">   res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="cx">   if (!SWIG_IsOK(res1)) {
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_hangup&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
</span><span class="cx">   }
</span><span class="cx">   arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
</span><del>-  res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_hangup&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+  if (obj1) {
+    res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_hangup&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+    }
+    arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</ins><span class="cx">   }
</span><del>-  arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</del><span class="cx">   (arg1)-&gt;hangup((char const *)arg2);
</span><span class="cx">   resultobj = SWIG_Py_Void();
</span><span class="cx">   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
</span><span class="lines">@@ -6309,69 +5850,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_CoreSession_hangup__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;O:CoreSession_hangup&quot;,&amp;obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_hangup&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-  (arg1)-&gt;hangup();
-  resultobj = SWIG_Py_Void();
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_hangup(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[3];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = (int)PyObject_Length(args);
-  for (ii = 0; (ii &lt; argc) &amp;&amp; (ii &lt; 2); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 1) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      return _wrap_CoreSession_hangup__SWIG_1(self, args);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        return _wrap_CoreSession_hangup__SWIG_0(self, args);
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,&quot;Wrong number of arguments for overloaded function 'CoreSession_hangup'.\n&quot;
-    &quot;  Possible C/C++ prototypes are:\n&quot;
-    &quot;    hangup(CoreSession *,char const *)\n&quot;
-    &quot;    hangup(CoreSession *)\n&quot;);
-  return NULL;
-}
-
-
</del><span class="cx"> SWIGINTERN PyObject *_wrap_CoreSession_hangupState(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</span><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -6580,14 +6058,14 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_CoreSession_say__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</del><ins>+SWIGINTERN PyObject *_wrap_CoreSession_say(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</ins><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><span class="cx">   char *arg3 = (char *) 0 ;
</span><span class="cx">   char *arg4 = (char *) 0 ;
</span><span class="cx">   char *arg5 = (char *) 0 ;
</span><del>-  char *arg6 = (char *) 0 ;
</del><ins>+  char *arg6 = (char *) NULL ;
</ins><span class="cx">   void *argp1 = 0 ;
</span><span class="cx">   int res1 = 0 ;
</span><span class="cx">   int res2 ;
</span><span class="lines">@@ -6612,7 +6090,7 @@
</span><span class="cx">   PyObject * obj4 = 0 ;
</span><span class="cx">   PyObject * obj5 = 0 ;
</span><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OOOOOO:CoreSession_say&quot;,&amp;obj0,&amp;obj1,&amp;obj2,&amp;obj3,&amp;obj4,&amp;obj5)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;OOOOO|O:CoreSession_say&quot;,&amp;obj0,&amp;obj1,&amp;obj2,&amp;obj3,&amp;obj4,&amp;obj5)) SWIG_fail;
</ins><span class="cx">   res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="cx">   if (!SWIG_IsOK(res1)) {
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_say&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
</span><span class="lines">@@ -6638,11 +6116,13 @@
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res5), &quot;in method '&quot; &quot;CoreSession_say&quot; &quot;', argument &quot; &quot;5&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</span><span class="cx">   }
</span><span class="cx">   arg5 = reinterpret_cast&lt; char * &gt;(buf5);
</span><del>-  res6 = SWIG_AsCharPtrAndSize(obj5, &amp;buf6, NULL, &amp;alloc6);
-  if (!SWIG_IsOK(res6)) {
-    SWIG_exception_fail(SWIG_ArgError(res6), &quot;in method '&quot; &quot;CoreSession_say&quot; &quot;', argument &quot; &quot;6&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+  if (obj5) {
+    res6 = SWIG_AsCharPtrAndSize(obj5, &amp;buf6, NULL, &amp;alloc6);
+    if (!SWIG_IsOK(res6)) {
+      SWIG_exception_fail(SWIG_ArgError(res6), &quot;in method '&quot; &quot;CoreSession_say&quot; &quot;', argument &quot; &quot;6&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+    }
+    arg6 = reinterpret_cast&lt; char * &gt;(buf6);
</ins><span class="cx">   }
</span><del>-  arg6 = reinterpret_cast&lt; char * &gt;(buf6);
</del><span class="cx">   (arg1)-&gt;say((char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5,(char const *)arg6);
</span><span class="cx">   resultobj = SWIG_Py_Void();
</span><span class="cx">   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
</span><span class="lines">@@ -6661,13 +6141,12 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_CoreSession_say__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</del><ins>+SWIGINTERN PyObject *_wrap_CoreSession_sayPhrase(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</ins><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  char *arg3 = (char *) 0 ;
-  char *arg4 = (char *) 0 ;
-  char *arg5 = (char *) 0 ;
</del><ins>+  char *arg3 = (char *) &quot;&quot; ;
+  char *arg4 = (char *) NULL ;
</ins><span class="cx">   void *argp1 = 0 ;
</span><span class="cx">   int res1 = 0 ;
</span><span class="cx">   int res2 ;
</span><span class="lines">@@ -6679,174 +6158,36 @@
</span><span class="cx">   int res4 ;
</span><span class="cx">   char *buf4 = 0 ;
</span><span class="cx">   int alloc4 = 0 ;
</span><del>-  int res5 ;
-  char *buf5 = 0 ;
-  int alloc5 = 0 ;
</del><span class="cx">   PyObject * obj0 = 0 ;
</span><span class="cx">   PyObject * obj1 = 0 ;
</span><span class="cx">   PyObject * obj2 = 0 ;
</span><span class="cx">   PyObject * obj3 = 0 ;
</span><del>-  PyObject * obj4 = 0 ;
</del><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OOOOO:CoreSession_say&quot;,&amp;obj0,&amp;obj1,&amp;obj2,&amp;obj3,&amp;obj4)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;OO|OO:CoreSession_sayPhrase&quot;,&amp;obj0,&amp;obj1,&amp;obj2,&amp;obj3)) SWIG_fail;
</ins><span class="cx">   res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="cx">   if (!SWIG_IsOK(res1)) {
</span><del>-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_say&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
</del><ins>+    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
</ins><span class="cx">   }
</span><span class="cx">   arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
</span><span class="cx">   res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
</span><span class="cx">   if (!SWIG_IsOK(res2)) {
</span><del>-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_say&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</ins><span class="cx">   }
</span><span class="cx">   arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</span><del>-  res3 = SWIG_AsCharPtrAndSize(obj2, &amp;buf3, NULL, &amp;alloc3);
-  if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_say&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-  }
-  arg3 = reinterpret_cast&lt; char * &gt;(buf3);
-  res4 = SWIG_AsCharPtrAndSize(obj3, &amp;buf4, NULL, &amp;alloc4);
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), &quot;in method '&quot; &quot;CoreSession_say&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-  }
-  arg4 = reinterpret_cast&lt; char * &gt;(buf4);
-  res5 = SWIG_AsCharPtrAndSize(obj4, &amp;buf5, NULL, &amp;alloc5);
-  if (!SWIG_IsOK(res5)) {
-    SWIG_exception_fail(SWIG_ArgError(res5), &quot;in method '&quot; &quot;CoreSession_say&quot; &quot;', argument &quot; &quot;5&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-  }
-  arg5 = reinterpret_cast&lt; char * &gt;(buf5);
-  (arg1)-&gt;say((char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5);
-  resultobj = SWIG_Py_Void();
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-  if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
-  if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
-  return resultobj;
-fail:
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-  if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
-  if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_say(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[7];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = (int)PyObject_Length(args);
-  for (ii = 0; (ii &lt; argc) &amp;&amp; (ii &lt; 6); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 5) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          int res = SWIG_AsCharPtrAndSize(argv[3], 0, NULL, 0);
-          _v = SWIG_CheckState(res);
-          if (_v) {
-            int res = SWIG_AsCharPtrAndSize(argv[4], 0, NULL, 0);
-            _v = SWIG_CheckState(res);
-            if (_v) {
-              return _wrap_CoreSession_say__SWIG_1(self, args);
-            }
-          }
-        }
-      }
</del><ins>+  if (obj2) {
+    res3 = SWIG_AsCharPtrAndSize(obj2, &amp;buf3, NULL, &amp;alloc3);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</ins><span class="cx">     }
</span><ins>+    arg3 = reinterpret_cast&lt; char * &gt;(buf3);
</ins><span class="cx">   }
</span><del>-  if (argc == 6) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          int res = SWIG_AsCharPtrAndSize(argv[3], 0, NULL, 0);
-          _v = SWIG_CheckState(res);
-          if (_v) {
-            int res = SWIG_AsCharPtrAndSize(argv[4], 0, NULL, 0);
-            _v = SWIG_CheckState(res);
-            if (_v) {
-              int res = SWIG_AsCharPtrAndSize(argv[5], 0, NULL, 0);
-              _v = SWIG_CheckState(res);
-              if (_v) {
-                return _wrap_CoreSession_say__SWIG_0(self, args);
-              }
-            }
-          }
-        }
-      }
</del><ins>+  if (obj3) {
+    res4 = SWIG_AsCharPtrAndSize(obj3, &amp;buf4, NULL, &amp;alloc4);
+    if (!SWIG_IsOK(res4)) {
+      SWIG_exception_fail(SWIG_ArgError(res4), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</ins><span class="cx">     }
</span><ins>+    arg4 = reinterpret_cast&lt; char * &gt;(buf4);
</ins><span class="cx">   }
</span><del>-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,&quot;Wrong number of arguments for overloaded function 'CoreSession_say'.\n&quot;
-    &quot;  Possible C/C++ prototypes are:\n&quot;
-    &quot;    say(CoreSession *,char const *,char const *,char const *,char const *,char const *)\n&quot;
-    &quot;    say(CoreSession *,char const *,char const *,char const *,char const *)\n&quot;);
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_sayPhrase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  char *arg3 = (char *) 0 ;
-  char *arg4 = (char *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int res2 ;
-  char *buf2 = 0 ;
-  int alloc2 = 0 ;
-  int res3 ;
-  char *buf3 = 0 ;
-  int alloc3 = 0 ;
-  int res4 ;
-  char *buf4 = 0 ;
-  int alloc4 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
-  PyObject * obj3 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;OOOO:CoreSession_sayPhrase&quot;,&amp;obj0,&amp;obj1,&amp;obj2,&amp;obj3)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-  res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-  }
-  arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-  res3 = SWIG_AsCharPtrAndSize(obj2, &amp;buf3, NULL, &amp;alloc3);
-  if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-  }
-  arg3 = reinterpret_cast&lt; char * &gt;(buf3);
-  res4 = SWIG_AsCharPtrAndSize(obj3, &amp;buf4, NULL, &amp;alloc4);
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-  }
-  arg4 = reinterpret_cast&lt; char * &gt;(buf4);
</del><span class="cx">   (arg1)-&gt;sayPhrase((char const *)arg2,(char const *)arg3,(char const *)arg4);
</span><span class="cx">   resultobj = SWIG_Py_Void();
</span><span class="cx">   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
</span><span class="lines">@@ -6861,156 +6202,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_CoreSession_sayPhrase__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  char *arg3 = (char *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int res2 ;
-  char *buf2 = 0 ;
-  int alloc2 = 0 ;
-  int res3 ;
-  char *buf3 = 0 ;
-  int alloc3 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;OOO:CoreSession_sayPhrase&quot;,&amp;obj0,&amp;obj1,&amp;obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-  res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-  }
-  arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-  res3 = SWIG_AsCharPtrAndSize(obj2, &amp;buf3, NULL, &amp;alloc3);
-  if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-  }
-  arg3 = reinterpret_cast&lt; char * &gt;(buf3);
-  (arg1)-&gt;sayPhrase((char const *)arg2,(char const *)arg3);
-  resultobj = SWIG_Py_Void();
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-  return resultobj;
-fail:
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_sayPhrase__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int res2 ;
-  char *buf2 = 0 ;
-  int alloc2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;OO:CoreSession_sayPhrase&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-  res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_sayPhrase&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-  }
-  arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-  (arg1)-&gt;sayPhrase((char const *)arg2);
-  resultobj = SWIG_Py_Void();
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  return resultobj;
-fail:
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_sayPhrase(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[5];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = (int)PyObject_Length(args);
-  for (ii = 0; (ii &lt; argc) &amp;&amp; (ii &lt; 4); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 2) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        return _wrap_CoreSession_sayPhrase__SWIG_2(self, args);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_CoreSession_sayPhrase__SWIG_1(self, args);
-        }
-      }
-    }
-  }
-  if (argc == 4) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          int res = SWIG_AsCharPtrAndSize(argv[3], 0, NULL, 0);
-          _v = SWIG_CheckState(res);
-          if (_v) {
-            return _wrap_CoreSession_sayPhrase__SWIG_0(self, args);
-          }
-        }
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,&quot;Wrong number of arguments for overloaded function 'CoreSession_sayPhrase'.\n&quot;
-    &quot;  Possible C/C++ prototypes are:\n&quot;
-    &quot;    sayPhrase(CoreSession *,char const *,char const *,char const *)\n&quot;
-    &quot;    sayPhrase(CoreSession *,char const *,char const *)\n&quot;
-    &quot;    sayPhrase(CoreSession *,char const *)\n&quot;);
-  return NULL;
-}
-
-
</del><span class="cx"> SWIGINTERN PyObject *_wrap_CoreSession_hangupCause(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</span><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -7055,13 +6246,13 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_CoreSession_recordFile__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</del><ins>+SWIGINTERN PyObject *_wrap_CoreSession_recordFile(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</ins><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  int arg3 ;
-  int arg4 ;
-  int arg5 ;
</del><ins>+  int arg3 = (int) 0 ;
+  int arg4 = (int) 0 ;
+  int arg5 = (int) 0 ;
</ins><span class="cx">   int result;
</span><span class="cx">   void *argp1 = 0 ;
</span><span class="cx">   int res1 = 0 ;
</span><span class="lines">@@ -7080,7 +6271,7 @@
</span><span class="cx">   PyObject * obj3 = 0 ;
</span><span class="cx">   PyObject * obj4 = 0 ;
</span><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OOOOO:CoreSession_recordFile&quot;,&amp;obj0,&amp;obj1,&amp;obj2,&amp;obj3,&amp;obj4)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;OO|OOO:CoreSession_recordFile&quot;,&amp;obj0,&amp;obj1,&amp;obj2,&amp;obj3,&amp;obj4)) SWIG_fail;
</ins><span class="cx">   res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="cx">   if (!SWIG_IsOK(res1)) {
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
</span><span class="lines">@@ -7091,117 +6282,28 @@
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
</span><span class="cx">   }
</span><span class="cx">   arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</span><del>-  ecode3 = SWIG_AsVal_int(obj2, &amp;val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-  } 
-  arg3 = static_cast&lt; int &gt;(val3);
-  ecode4 = SWIG_AsVal_int(obj3, &amp;val4);
-  if (!SWIG_IsOK(ecode4)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode4), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-  } 
-  arg4 = static_cast&lt; int &gt;(val4);
-  ecode5 = SWIG_AsVal_int(obj4, &amp;val5);
-  if (!SWIG_IsOK(ecode5)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode5), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;5&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-  } 
-  arg5 = static_cast&lt; int &gt;(val5);
-  result = (int)(arg1)-&gt;recordFile(arg2,arg3,arg4,arg5);
-  resultobj = SWIG_From_int(static_cast&lt; int &gt;(result));
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  return resultobj;
-fail:
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_recordFile__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  int arg3 ;
-  int arg4 ;
-  int result;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int res2 ;
-  char *buf2 = 0 ;
-  int alloc2 = 0 ;
-  int val3 ;
-  int ecode3 = 0 ;
-  int val4 ;
-  int ecode4 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
-  PyObject * obj3 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;OOOO:CoreSession_recordFile&quot;,&amp;obj0,&amp;obj1,&amp;obj2,&amp;obj3)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
</del><ins>+  if (obj2) {
+    ecode3 = SWIG_AsVal_int(obj2, &amp;val3);
+    if (!SWIG_IsOK(ecode3)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+    } 
+    arg3 = static_cast&lt; int &gt;(val3);
</ins><span class="cx">   }
</span><del>-  arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-  res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
</del><ins>+  if (obj3) {
+    ecode4 = SWIG_AsVal_int(obj3, &amp;val4);
+    if (!SWIG_IsOK(ecode4)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode4), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+    } 
+    arg4 = static_cast&lt; int &gt;(val4);
</ins><span class="cx">   }
</span><del>-  arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-  ecode3 = SWIG_AsVal_int(obj2, &amp;val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-  } 
-  arg3 = static_cast&lt; int &gt;(val3);
-  ecode4 = SWIG_AsVal_int(obj3, &amp;val4);
-  if (!SWIG_IsOK(ecode4)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode4), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-  } 
-  arg4 = static_cast&lt; int &gt;(val4);
-  result = (int)(arg1)-&gt;recordFile(arg2,arg3,arg4);
-  resultobj = SWIG_From_int(static_cast&lt; int &gt;(result));
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  return resultobj;
-fail:
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_recordFile__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  int arg3 ;
-  int result;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int res2 ;
-  char *buf2 = 0 ;
-  int alloc2 = 0 ;
-  int val3 ;
-  int ecode3 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;OOO:CoreSession_recordFile&quot;,&amp;obj0,&amp;obj1,&amp;obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
</del><ins>+  if (obj4) {
+    ecode5 = SWIG_AsVal_int(obj4, &amp;val5);
+    if (!SWIG_IsOK(ecode5)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode5), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;5&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+    } 
+    arg5 = static_cast&lt; int &gt;(val5);
</ins><span class="cx">   }
</span><del>-  arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-  res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-  }
-  arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-  ecode3 = SWIG_AsVal_int(obj2, &amp;val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-  } 
-  arg3 = static_cast&lt; int &gt;(val3);
-  result = (int)(arg1)-&gt;recordFile(arg2,arg3);
</del><ins>+  result = (int)(arg1)-&gt;recordFile(arg2,arg3,arg4,arg5);
</ins><span class="cx">   resultobj = SWIG_From_int(static_cast&lt; int &gt;(result));
</span><span class="cx">   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
</span><span class="cx">   return resultobj;
</span><span class="lines">@@ -7211,157 +6313,13 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_CoreSession_recordFile__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</del><ins>+SWIGINTERN PyObject *_wrap_CoreSession_originate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</ins><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><del>-  char *arg2 = (char *) 0 ;
-  int result;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int res2 ;
-  char *buf2 = 0 ;
-  int alloc2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;OO:CoreSession_recordFile&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-  res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_recordFile&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-  }
-  arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-  result = (int)(arg1)-&gt;recordFile(arg2);
-  resultobj = SWIG_From_int(static_cast&lt; int &gt;(result));
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  return resultobj;
-fail:
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_recordFile(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[6];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = (int)PyObject_Length(args);
-  for (ii = 0; (ii &lt; argc) &amp;&amp; (ii &lt; 5); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 2) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        return _wrap_CoreSession_recordFile__SWIG_3(self, args);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        {
-          int res = SWIG_AsVal_int(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          return _wrap_CoreSession_recordFile__SWIG_2(self, args);
-        }
-      }
-    }
-  }
-  if (argc == 4) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        {
-          int res = SWIG_AsVal_int(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          {
-            int res = SWIG_AsVal_int(argv[3], NULL);
-            _v = SWIG_CheckState(res);
-          }
-          if (_v) {
-            return _wrap_CoreSession_recordFile__SWIG_1(self, args);
-          }
-        }
-      }
-    }
-  }
-  if (argc == 5) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        {
-          int res = SWIG_AsVal_int(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          {
-            int res = SWIG_AsVal_int(argv[3], NULL);
-            _v = SWIG_CheckState(res);
-          }
-          if (_v) {
-            {
-              int res = SWIG_AsVal_int(argv[4], NULL);
-              _v = SWIG_CheckState(res);
-            }
-            if (_v) {
-              return _wrap_CoreSession_recordFile__SWIG_0(self, args);
-            }
-          }
-        }
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,&quot;Wrong number of arguments for overloaded function 'CoreSession_recordFile'.\n&quot;
-    &quot;  Possible C/C++ prototypes are:\n&quot;
-    &quot;    recordFile(CoreSession *,char *,int,int,int)\n&quot;
-    &quot;    recordFile(CoreSession *,char *,int,int)\n&quot;
-    &quot;    recordFile(CoreSession *,char *,int)\n&quot;
-    &quot;    recordFile(CoreSession *,char *)\n&quot;);
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_originate__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  CoreSession *arg1 = (CoreSession *) 0 ;
</del><span class="cx">   CoreSession *arg2 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg3 = (char *) 0 ;
</span><del>-  int arg4 ;
-  switch_state_handler_table_t *arg5 = (switch_state_handler_table_t *) 0 ;
</del><ins>+  int arg4 = (int) 60 ;
+  switch_state_handler_table_t *arg5 = (switch_state_handler_table_t *) NULL ;
</ins><span class="cx">   int result;
</span><span class="cx">   void *argp1 = 0 ;
</span><span class="cx">   int res1 = 0 ;
</span><span class="lines">@@ -7380,7 +6338,7 @@
</span><span class="cx">   PyObject * obj3 = 0 ;
</span><span class="cx">   PyObject * obj4 = 0 ;
</span><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OOOOO:CoreSession_originate&quot;,&amp;obj0,&amp;obj1,&amp;obj2,&amp;obj3,&amp;obj4)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;OOO|OO:CoreSession_originate&quot;,&amp;obj0,&amp;obj1,&amp;obj2,&amp;obj3,&amp;obj4)) SWIG_fail;
</ins><span class="cx">   res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="cx">   if (!SWIG_IsOK(res1)) {
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
</span><span class="lines">@@ -7396,16 +6354,20 @@
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
</span><span class="cx">   }
</span><span class="cx">   arg3 = reinterpret_cast&lt; char * &gt;(buf3);
</span><del>-  ecode4 = SWIG_AsVal_int(obj3, &amp;val4);
-  if (!SWIG_IsOK(ecode4)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode4), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-  } 
-  arg4 = static_cast&lt; int &gt;(val4);
-  res5 = SWIG_ConvertPtr(obj4, &amp;argp5,SWIGTYPE_p_switch_state_handler_table_t, 0 |  0 );
-  if (!SWIG_IsOK(res5)) {
-    SWIG_exception_fail(SWIG_ArgError(res5), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;5&quot;&quot; of type '&quot; &quot;switch_state_handler_table_t *&quot;&quot;'&quot;); 
</del><ins>+  if (obj3) {
+    ecode4 = SWIG_AsVal_int(obj3, &amp;val4);
+    if (!SWIG_IsOK(ecode4)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode4), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+    } 
+    arg4 = static_cast&lt; int &gt;(val4);
</ins><span class="cx">   }
</span><del>-  arg5 = reinterpret_cast&lt; switch_state_handler_table_t * &gt;(argp5);
</del><ins>+  if (obj4) {
+    res5 = SWIG_ConvertPtr(obj4, &amp;argp5,SWIGTYPE_p_switch_state_handler_table_t, 0 |  0 );
+    if (!SWIG_IsOK(res5)) {
+      SWIG_exception_fail(SWIG_ArgError(res5), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;5&quot;&quot; of type '&quot; &quot;switch_state_handler_table_t *&quot;&quot;'&quot;); 
+    }
+    arg5 = reinterpret_cast&lt; switch_state_handler_table_t * &gt;(argp5);
+  }
</ins><span class="cx">   result = (int)(arg1)-&gt;originate(arg2,arg3,arg4,arg5);
</span><span class="cx">   resultobj = SWIG_From_int(static_cast&lt; int &gt;(result));
</span><span class="cx">   if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
</span><span class="lines">@@ -7416,193 +6378,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_CoreSession_originate__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  CoreSession *arg2 = (CoreSession *) 0 ;
-  char *arg3 = (char *) 0 ;
-  int arg4 ;
-  int result;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  void *argp2 = 0 ;
-  int res2 = 0 ;
-  int res3 ;
-  char *buf3 = 0 ;
-  int alloc3 = 0 ;
-  int val4 ;
-  int ecode4 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
-  PyObject * obj3 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;OOOO:CoreSession_originate&quot;,&amp;obj0,&amp;obj1,&amp;obj2,&amp;obj3)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &amp;argp2,SWIGTYPE_p_CoreSession, 0 |  0 );
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-  }
-  arg2 = reinterpret_cast&lt; CoreSession * &gt;(argp2);
-  res3 = SWIG_AsCharPtrAndSize(obj2, &amp;buf3, NULL, &amp;alloc3);
-  if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-  }
-  arg3 = reinterpret_cast&lt; char * &gt;(buf3);
-  ecode4 = SWIG_AsVal_int(obj3, &amp;val4);
-  if (!SWIG_IsOK(ecode4)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode4), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-  } 
-  arg4 = static_cast&lt; int &gt;(val4);
-  result = (int)(arg1)-&gt;originate(arg2,arg3,arg4);
-  resultobj = SWIG_From_int(static_cast&lt; int &gt;(result));
-  if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-  return resultobj;
-fail:
-  if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_originate__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  CoreSession *arg2 = (CoreSession *) 0 ;
-  char *arg3 = (char *) 0 ;
-  int result;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  void *argp2 = 0 ;
-  int res2 = 0 ;
-  int res3 ;
-  char *buf3 = 0 ;
-  int alloc3 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;OOO:CoreSession_originate&quot;,&amp;obj0,&amp;obj1,&amp;obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &amp;argp2,SWIGTYPE_p_CoreSession, 0 |  0 );
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-  }
-  arg2 = reinterpret_cast&lt; CoreSession * &gt;(argp2);
-  res3 = SWIG_AsCharPtrAndSize(obj2, &amp;buf3, NULL, &amp;alloc3);
-  if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_originate&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-  }
-  arg3 = reinterpret_cast&lt; char * &gt;(buf3);
-  result = (int)(arg1)-&gt;originate(arg2,arg3);
-  resultobj = SWIG_From_int(static_cast&lt; int &gt;(result));
-  if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-  return resultobj;
-fail:
-  if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_originate(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[6];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = (int)PyObject_Length(args);
-  for (ii = 0; (ii &lt; argc) &amp;&amp; (ii &lt; 5); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 3) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      void *vptr = 0;
-      int res = SWIG_ConvertPtr(argv[1], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_CoreSession_originate__SWIG_2(self, args);
-        }
-      }
-    }
-  }
-  if (argc == 4) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      void *vptr = 0;
-      int res = SWIG_ConvertPtr(argv[1], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          {
-            int res = SWIG_AsVal_int(argv[3], NULL);
-            _v = SWIG_CheckState(res);
-          }
-          if (_v) {
-            return _wrap_CoreSession_originate__SWIG_1(self, args);
-          }
-        }
-      }
-    }
-  }
-  if (argc == 5) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      void *vptr = 0;
-      int res = SWIG_ConvertPtr(argv[1], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          {
-            int res = SWIG_AsVal_int(argv[3], NULL);
-            _v = SWIG_CheckState(res);
-          }
-          if (_v) {
-            void *vptr = 0;
-            int res = SWIG_ConvertPtr(argv[4], &amp;vptr, SWIGTYPE_p_switch_state_handler_table_t, 0);
-            _v = SWIG_CheckState(res);
-            if (_v) {
-              return _wrap_CoreSession_originate__SWIG_0(self, args);
-            }
-          }
-        }
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,&quot;Wrong number of arguments for overloaded function 'CoreSession_originate'.\n&quot;
-    &quot;  Possible C/C++ prototypes are:\n&quot;
-    &quot;    originate(CoreSession *,CoreSession *,char *,int,switch_state_handler_table_t *)\n&quot;
-    &quot;    originate(CoreSession *,CoreSession *,char *,int)\n&quot;
-    &quot;    originate(CoreSession *,CoreSession *,char *)\n&quot;);
-  return NULL;
-}
-
-
</del><span class="cx"> SWIGINTERN PyObject *_wrap_CoreSession_destroy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</span><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -8059,12 +6834,12 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_CoreSession_transfer__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</del><ins>+SWIGINTERN PyObject *_wrap_CoreSession_transfer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</ins><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  char *arg3 = (char *) 0 ;
-  char *arg4 = (char *) 0 ;
</del><ins>+  char *arg3 = (char *) NULL ;
+  char *arg4 = (char *) NULL ;
</ins><span class="cx">   int result;
</span><span class="cx">   void *argp1 = 0 ;
</span><span class="cx">   int res1 = 0 ;
</span><span class="lines">@@ -8082,7 +6857,7 @@
</span><span class="cx">   PyObject * obj2 = 0 ;
</span><span class="cx">   PyObject * obj3 = 0 ;
</span><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OOOO:CoreSession_transfer&quot;,&amp;obj0,&amp;obj1,&amp;obj2,&amp;obj3)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;OO|OO:CoreSession_transfer&quot;,&amp;obj0,&amp;obj1,&amp;obj2,&amp;obj3)) SWIG_fail;
</ins><span class="cx">   res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="cx">   if (!SWIG_IsOK(res1)) {
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
</span><span class="lines">@@ -8093,16 +6868,20 @@
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
</span><span class="cx">   }
</span><span class="cx">   arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</span><del>-  res3 = SWIG_AsCharPtrAndSize(obj2, &amp;buf3, NULL, &amp;alloc3);
-  if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
</del><ins>+  if (obj2) {
+    res3 = SWIG_AsCharPtrAndSize(obj2, &amp;buf3, NULL, &amp;alloc3);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
+    }
+    arg3 = reinterpret_cast&lt; char * &gt;(buf3);
</ins><span class="cx">   }
</span><del>-  arg3 = reinterpret_cast&lt; char * &gt;(buf3);
-  res4 = SWIG_AsCharPtrAndSize(obj3, &amp;buf4, NULL, &amp;alloc4);
-  if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
</del><ins>+  if (obj3) {
+    res4 = SWIG_AsCharPtrAndSize(obj3, &amp;buf4, NULL, &amp;alloc4);
+    if (!SWIG_IsOK(res4)) {
+      SWIG_exception_fail(SWIG_ArgError(res4), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
+    }
+    arg4 = reinterpret_cast&lt; char * &gt;(buf4);
</ins><span class="cx">   }
</span><del>-  arg4 = reinterpret_cast&lt; char * &gt;(buf4);
</del><span class="cx">   result = (int)(arg1)-&gt;transfer(arg2,arg3,arg4);
</span><span class="cx">   resultobj = SWIG_From_int(static_cast&lt; int &gt;(result));
</span><span class="cx">   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
</span><span class="lines">@@ -8117,158 +6896,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_CoreSession_transfer__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  char *arg3 = (char *) 0 ;
-  int result;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int res2 ;
-  char *buf2 = 0 ;
-  int alloc2 = 0 ;
-  int res3 ;
-  char *buf3 = 0 ;
-  int alloc3 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;OOO:CoreSession_transfer&quot;,&amp;obj0,&amp;obj1,&amp;obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-  res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-  }
-  arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-  res3 = SWIG_AsCharPtrAndSize(obj2, &amp;buf3, NULL, &amp;alloc3);
-  if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-  }
-  arg3 = reinterpret_cast&lt; char * &gt;(buf3);
-  result = (int)(arg1)-&gt;transfer(arg2,arg3);
-  resultobj = SWIG_From_int(static_cast&lt; int &gt;(result));
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-  return resultobj;
-fail:
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_transfer__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  int result;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int res2 ;
-  char *buf2 = 0 ;
-  int alloc2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;OO:CoreSession_transfer&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-  res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_transfer&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-  }
-  arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-  result = (int)(arg1)-&gt;transfer(arg2);
-  resultobj = SWIG_From_int(static_cast&lt; int &gt;(result));
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  return resultobj;
-fail:
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_transfer(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[5];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = (int)PyObject_Length(args);
-  for (ii = 0; (ii &lt; argc) &amp;&amp; (ii &lt; 4); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 2) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        return _wrap_CoreSession_transfer__SWIG_2(self, args);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_CoreSession_transfer__SWIG_1(self, args);
-        }
-      }
-    }
-  }
-  if (argc == 4) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          int res = SWIG_AsCharPtrAndSize(argv[3], 0, NULL, 0);
-          _v = SWIG_CheckState(res);
-          if (_v) {
-            return _wrap_CoreSession_transfer__SWIG_0(self, args);
-          }
-        }
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,&quot;Wrong number of arguments for overloaded function 'CoreSession_transfer'.\n&quot;
-    &quot;  Possible C/C++ prototypes are:\n&quot;
-    &quot;    transfer(CoreSession *,char *,char *,char *)\n&quot;
-    &quot;    transfer(CoreSession *,char *,char *)\n&quot;
-    &quot;    transfer(CoreSession *,char *)\n&quot;);
-  return NULL;
-}
-
-
</del><span class="cx"> SWIGINTERN PyObject *_wrap_CoreSession_read(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</span><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -8342,7 +6969,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_CoreSession_playAndGetDigits__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</del><ins>+SWIGINTERN PyObject *_wrap_CoreSession_playAndGetDigits(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</ins><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   int arg2 ;
</span><span class="lines">@@ -8353,7 +6980,7 @@
</span><span class="cx">   char *arg7 = (char *) 0 ;
</span><span class="cx">   char *arg8 = (char *) 0 ;
</span><span class="cx">   char *arg9 = (char *) 0 ;
</span><del>-  char *arg10 = (char *) 0 ;
</del><ins>+  char *arg10 = (char *) NULL ;
</ins><span class="cx">   char *result = 0 ;
</span><span class="cx">   void *argp1 = 0 ;
</span><span class="cx">   int res1 = 0 ;
</span><span class="lines">@@ -8391,7 +7018,7 @@
</span><span class="cx">   PyObject * obj8 = 0 ;
</span><span class="cx">   PyObject * obj9 = 0 ;
</span><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OOOOOOOOOO:CoreSession_playAndGetDigits&quot;,&amp;obj0,&amp;obj1,&amp;obj2,&amp;obj3,&amp;obj4,&amp;obj5,&amp;obj6,&amp;obj7,&amp;obj8,&amp;obj9)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;OOOOOOOOO|O:CoreSession_playAndGetDigits&quot;,&amp;obj0,&amp;obj1,&amp;obj2,&amp;obj3,&amp;obj4,&amp;obj5,&amp;obj6,&amp;obj7,&amp;obj8,&amp;obj9)) SWIG_fail;
</ins><span class="cx">   res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="cx">   if (!SWIG_IsOK(res1)) {
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
</span><span class="lines">@@ -8437,11 +7064,13 @@
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res9), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;9&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
</span><span class="cx">   }
</span><span class="cx">   arg9 = reinterpret_cast&lt; char * &gt;(buf9);
</span><del>-  res10 = SWIG_AsCharPtrAndSize(obj9, &amp;buf10, NULL, &amp;alloc10);
-  if (!SWIG_IsOK(res10)) {
-    SWIG_exception_fail(SWIG_ArgError(res10), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;10&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+  if (obj9) {
+    res10 = SWIG_AsCharPtrAndSize(obj9, &amp;buf10, NULL, &amp;alloc10);
+    if (!SWIG_IsOK(res10)) {
+      SWIG_exception_fail(SWIG_ArgError(res10), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;10&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+    }
+    arg10 = reinterpret_cast&lt; char * &gt;(buf10);
</ins><span class="cx">   }
</span><del>-  arg10 = reinterpret_cast&lt; char * &gt;(buf10);
</del><span class="cx">   result = (char *)(arg1)-&gt;playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,(char const *)arg10);
</span><span class="cx">   resultobj = SWIG_FromCharPtr((const char *)result);
</span><span class="cx">   if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
</span><span class="lines">@@ -8460,239 +7089,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_CoreSession_playAndGetDigits__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</del><ins>+SWIGINTERN PyObject *_wrap_CoreSession_streamFile(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</ins><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><del>-  int arg2 ;
-  int arg3 ;
-  int arg4 ;
-  int arg5 ;
-  char *arg6 = (char *) 0 ;
-  char *arg7 = (char *) 0 ;
-  char *arg8 = (char *) 0 ;
-  char *arg9 = (char *) 0 ;
-  char *result = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int val2 ;
-  int ecode2 = 0 ;
-  int val3 ;
-  int ecode3 = 0 ;
-  int val4 ;
-  int ecode4 = 0 ;
-  int val5 ;
-  int ecode5 = 0 ;
-  int res6 ;
-  char *buf6 = 0 ;
-  int alloc6 = 0 ;
-  int res7 ;
-  char *buf7 = 0 ;
-  int alloc7 = 0 ;
-  int res8 ;
-  char *buf8 = 0 ;
-  int alloc8 = 0 ;
-  int res9 ;
-  char *buf9 = 0 ;
-  int alloc9 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
-  PyObject * obj3 = 0 ;
-  PyObject * obj4 = 0 ;
-  PyObject * obj5 = 0 ;
-  PyObject * obj6 = 0 ;
-  PyObject * obj7 = 0 ;
-  PyObject * obj8 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;OOOOOOOOO:CoreSession_playAndGetDigits&quot;,&amp;obj0,&amp;obj1,&amp;obj2,&amp;obj3,&amp;obj4,&amp;obj5,&amp;obj6,&amp;obj7,&amp;obj8)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-  ecode2 = SWIG_AsVal_int(obj1, &amp;val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-  } 
-  arg2 = static_cast&lt; int &gt;(val2);
-  ecode3 = SWIG_AsVal_int(obj2, &amp;val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-  } 
-  arg3 = static_cast&lt; int &gt;(val3);
-  ecode4 = SWIG_AsVal_int(obj3, &amp;val4);
-  if (!SWIG_IsOK(ecode4)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode4), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;4&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-  } 
-  arg4 = static_cast&lt; int &gt;(val4);
-  ecode5 = SWIG_AsVal_int(obj4, &amp;val5);
-  if (!SWIG_IsOK(ecode5)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode5), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;5&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-  } 
-  arg5 = static_cast&lt; int &gt;(val5);
-  res6 = SWIG_AsCharPtrAndSize(obj5, &amp;buf6, NULL, &amp;alloc6);
-  if (!SWIG_IsOK(res6)) {
-    SWIG_exception_fail(SWIG_ArgError(res6), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;6&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-  }
-  arg6 = reinterpret_cast&lt; char * &gt;(buf6);
-  res7 = SWIG_AsCharPtrAndSize(obj6, &amp;buf7, NULL, &amp;alloc7);
-  if (!SWIG_IsOK(res7)) {
-    SWIG_exception_fail(SWIG_ArgError(res7), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;7&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-  }
-  arg7 = reinterpret_cast&lt; char * &gt;(buf7);
-  res8 = SWIG_AsCharPtrAndSize(obj7, &amp;buf8, NULL, &amp;alloc8);
-  if (!SWIG_IsOK(res8)) {
-    SWIG_exception_fail(SWIG_ArgError(res8), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;8&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-  }
-  arg8 = reinterpret_cast&lt; char * &gt;(buf8);
-  res9 = SWIG_AsCharPtrAndSize(obj8, &amp;buf9, NULL, &amp;alloc9);
-  if (!SWIG_IsOK(res9)) {
-    SWIG_exception_fail(SWIG_ArgError(res9), &quot;in method '&quot; &quot;CoreSession_playAndGetDigits&quot; &quot;', argument &quot; &quot;9&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-  }
-  arg9 = reinterpret_cast&lt; char * &gt;(buf9);
-  result = (char *)(arg1)-&gt;playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
-  resultobj = SWIG_FromCharPtr((const char *)result);
-  if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
-  if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
-  if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
-  if (alloc9 == SWIG_NEWOBJ) delete[] buf9;
-  return resultobj;
-fail:
-  if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
-  if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
-  if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
-  if (alloc9 == SWIG_NEWOBJ) delete[] buf9;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_playAndGetDigits(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[11];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = (int)PyObject_Length(args);
-  for (ii = 0; (ii &lt; argc) &amp;&amp; (ii &lt; 10); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 9) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_int(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        {
-          int res = SWIG_AsVal_int(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          {
-            int res = SWIG_AsVal_int(argv[3], NULL);
-            _v = SWIG_CheckState(res);
-          }
-          if (_v) {
-            {
-              int res = SWIG_AsVal_int(argv[4], NULL);
-              _v = SWIG_CheckState(res);
-            }
-            if (_v) {
-              int res = SWIG_AsCharPtrAndSize(argv[5], 0, NULL, 0);
-              _v = SWIG_CheckState(res);
-              if (_v) {
-                int res = SWIG_AsCharPtrAndSize(argv[6], 0, NULL, 0);
-                _v = SWIG_CheckState(res);
-                if (_v) {
-                  int res = SWIG_AsCharPtrAndSize(argv[7], 0, NULL, 0);
-                  _v = SWIG_CheckState(res);
-                  if (_v) {
-                    int res = SWIG_AsCharPtrAndSize(argv[8], 0, NULL, 0);
-                    _v = SWIG_CheckState(res);
-                    if (_v) {
-                      return _wrap_CoreSession_playAndGetDigits__SWIG_1(self, args);
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-  if (argc == 10) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_int(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        {
-          int res = SWIG_AsVal_int(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          {
-            int res = SWIG_AsVal_int(argv[3], NULL);
-            _v = SWIG_CheckState(res);
-          }
-          if (_v) {
-            {
-              int res = SWIG_AsVal_int(argv[4], NULL);
-              _v = SWIG_CheckState(res);
-            }
-            if (_v) {
-              int res = SWIG_AsCharPtrAndSize(argv[5], 0, NULL, 0);
-              _v = SWIG_CheckState(res);
-              if (_v) {
-                int res = SWIG_AsCharPtrAndSize(argv[6], 0, NULL, 0);
-                _v = SWIG_CheckState(res);
-                if (_v) {
-                  int res = SWIG_AsCharPtrAndSize(argv[7], 0, NULL, 0);
-                  _v = SWIG_CheckState(res);
-                  if (_v) {
-                    int res = SWIG_AsCharPtrAndSize(argv[8], 0, NULL, 0);
-                    _v = SWIG_CheckState(res);
-                    if (_v) {
-                      int res = SWIG_AsCharPtrAndSize(argv[9], 0, NULL, 0);
-                      _v = SWIG_CheckState(res);
-                      if (_v) {
-                        return _wrap_CoreSession_playAndGetDigits__SWIG_0(self, args);
-                      }
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,&quot;Wrong number of arguments for overloaded function 'CoreSession_playAndGetDigits'.\n&quot;
-    &quot;  Possible C/C++ prototypes are:\n&quot;
-    &quot;    playAndGetDigits(CoreSession *,int,int,int,int,char *,char *,char *,char *,char const *)\n&quot;
-    &quot;    playAndGetDigits(CoreSession *,int,int,int,int,char *,char *,char *,char *)\n&quot;);
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_streamFile__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  CoreSession *arg1 = (CoreSession *) 0 ;
</del><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  int arg3 ;
</del><ins>+  int arg3 = (int) 0 ;
</ins><span class="cx">   int result;
</span><span class="cx">   void *argp1 = 0 ;
</span><span class="cx">   int res1 = 0 ;
</span><span class="lines">@@ -8705,7 +7106,7 @@
</span><span class="cx">   PyObject * obj1 = 0 ;
</span><span class="cx">   PyObject * obj2 = 0 ;
</span><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OOO:CoreSession_streamFile&quot;,&amp;obj0,&amp;obj1,&amp;obj2)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;OO|O:CoreSession_streamFile&quot;,&amp;obj0,&amp;obj1,&amp;obj2)) SWIG_fail;
</ins><span class="cx">   res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="cx">   if (!SWIG_IsOK(res1)) {
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_streamFile&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
</span><span class="lines">@@ -8716,11 +7117,13 @@
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_streamFile&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
</span><span class="cx">   }
</span><span class="cx">   arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</span><del>-  ecode3 = SWIG_AsVal_int(obj2, &amp;val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_streamFile&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-  } 
-  arg3 = static_cast&lt; int &gt;(val3);
</del><ins>+  if (obj2) {
+    ecode3 = SWIG_AsVal_int(obj2, &amp;val3);
+    if (!SWIG_IsOK(ecode3)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_streamFile&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+    } 
+    arg3 = static_cast&lt; int &gt;(val3);
+  }
</ins><span class="cx">   result = (int)(arg1)-&gt;streamFile(arg2,arg3);
</span><span class="cx">   resultobj = SWIG_From_int(static_cast&lt; int &gt;(result));
</span><span class="cx">   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
</span><span class="lines">@@ -8731,97 +7134,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_CoreSession_streamFile__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</del><ins>+SWIGINTERN PyObject *_wrap_CoreSession_sleep(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</ins><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><del>-  char *arg2 = (char *) 0 ;
-  int result;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int res2 ;
-  char *buf2 = 0 ;
-  int alloc2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;OO:CoreSession_streamFile&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_streamFile&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-  res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_streamFile&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char *&quot;&quot;'&quot;);
-  }
-  arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-  result = (int)(arg1)-&gt;streamFile(arg2);
-  resultobj = SWIG_From_int(static_cast&lt; int &gt;(result));
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  return resultobj;
-fail:
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_streamFile(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[4];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = (int)PyObject_Length(args);
-  for (ii = 0; (ii &lt; argc) &amp;&amp; (ii &lt; 3); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 2) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        return _wrap_CoreSession_streamFile__SWIG_1(self, args);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        {
-          int res = SWIG_AsVal_int(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          return _wrap_CoreSession_streamFile__SWIG_0(self, args);
-        }
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,&quot;Wrong number of arguments for overloaded function 'CoreSession_streamFile'.\n&quot;
-    &quot;  Possible C/C++ prototypes are:\n&quot;
-    &quot;    streamFile(CoreSession *,char *,int)\n&quot;
-    &quot;    streamFile(CoreSession *,char *)\n&quot;);
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_sleep__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  CoreSession *arg1 = (CoreSession *) 0 ;
</del><span class="cx">   int arg2 ;
</span><del>-  int arg3 ;
</del><ins>+  int arg3 = (int) 0 ;
</ins><span class="cx">   int result;
</span><span class="cx">   void *argp1 = 0 ;
</span><span class="cx">   int res1 = 0 ;
</span><span class="lines">@@ -8833,7 +7150,7 @@
</span><span class="cx">   PyObject * obj1 = 0 ;
</span><span class="cx">   PyObject * obj2 = 0 ;
</span><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OOO:CoreSession_sleep&quot;,&amp;obj0,&amp;obj1,&amp;obj2)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;OO|O:CoreSession_sleep&quot;,&amp;obj0,&amp;obj1,&amp;obj2)) SWIG_fail;
</ins><span class="cx">   res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="cx">   if (!SWIG_IsOK(res1)) {
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_sleep&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
</span><span class="lines">@@ -8844,11 +7161,13 @@
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(ecode2), &quot;in method '&quot; &quot;CoreSession_sleep&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
</span><span class="cx">   } 
</span><span class="cx">   arg2 = static_cast&lt; int &gt;(val2);
</span><del>-  ecode3 = SWIG_AsVal_int(obj2, &amp;val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_sleep&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-  } 
-  arg3 = static_cast&lt; int &gt;(val3);
</del><ins>+  if (obj2) {
+    ecode3 = SWIG_AsVal_int(obj2, &amp;val3);
+    if (!SWIG_IsOK(ecode3)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode3), &quot;in method '&quot; &quot;CoreSession_sleep&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+    } 
+    arg3 = static_cast&lt; int &gt;(val3);
+  }
</ins><span class="cx">   result = (int)(arg1)-&gt;sleep(arg2,arg3);
</span><span class="cx">   resultobj = SWIG_From_int(static_cast&lt; int &gt;(result));
</span><span class="cx">   return resultobj;
</span><span class="lines">@@ -8857,93 +7176,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_CoreSession_sleep__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  int arg2 ;
-  int result;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int val2 ;
-  int ecode2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;OO:CoreSession_sleep&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_sleep&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-  ecode2 = SWIG_AsVal_int(obj1, &amp;val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), &quot;in method '&quot; &quot;CoreSession_sleep&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
-  } 
-  arg2 = static_cast&lt; int &gt;(val2);
-  result = (int)(arg1)-&gt;sleep(arg2);
-  resultobj = SWIG_From_int(static_cast&lt; int &gt;(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_sleep(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[4];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = (int)PyObject_Length(args);
-  for (ii = 0; (ii &lt; argc) &amp;&amp; (ii &lt; 3); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 2) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_int(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        return _wrap_CoreSession_sleep__SWIG_1(self, args);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_int(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        {
-          int res = SWIG_AsVal_int(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          return _wrap_CoreSession_sleep__SWIG_0(self, args);
-        }
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,&quot;Wrong number of arguments for overloaded function 'CoreSession_sleep'.\n&quot;
-    &quot;  Possible C/C++ prototypes are:\n&quot;
-    &quot;    sleep(CoreSession *,int,int)\n&quot;
-    &quot;    sleep(CoreSession *,int)\n&quot;);
-  return NULL;
-}
-
-
</del><span class="cx"> SWIGINTERN PyObject *_wrap_CoreSession_flushEvents(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</span><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -9165,11 +7397,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_CoreSession_execute__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</del><ins>+SWIGINTERN PyObject *_wrap_CoreSession_execute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</ins><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="cx">   char *arg2 = (char *) 0 ;
</span><del>-  char *arg3 = (char *) 0 ;
</del><ins>+  char *arg3 = (char *) NULL ;
</ins><span class="cx">   void *argp1 = 0 ;
</span><span class="cx">   int res1 = 0 ;
</span><span class="cx">   int res2 ;
</span><span class="lines">@@ -9182,7 +7414,7 @@
</span><span class="cx">   PyObject * obj1 = 0 ;
</span><span class="cx">   PyObject * obj2 = 0 ;
</span><span class="cx">   
</span><del>-  if (!PyArg_ParseTuple(args,(char *)&quot;OOO:CoreSession_execute&quot;,&amp;obj0,&amp;obj1,&amp;obj2)) SWIG_fail;
</del><ins>+  if (!PyArg_ParseTuple(args,(char *)&quot;OO|O:CoreSession_execute&quot;,&amp;obj0,&amp;obj1,&amp;obj2)) SWIG_fail;
</ins><span class="cx">   res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
</span><span class="cx">   if (!SWIG_IsOK(res1)) {
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_execute&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
</span><span class="lines">@@ -9193,11 +7425,13 @@
</span><span class="cx">     SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_execute&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</span><span class="cx">   }
</span><span class="cx">   arg2 = reinterpret_cast&lt; char * &gt;(buf2);
</span><del>-  res3 = SWIG_AsCharPtrAndSize(obj2, &amp;buf3, NULL, &amp;alloc3);
-  if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_execute&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
</del><ins>+  if (obj2) {
+    res3 = SWIG_AsCharPtrAndSize(obj2, &amp;buf3, NULL, &amp;alloc3);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), &quot;in method '&quot; &quot;CoreSession_execute&quot; &quot;', argument &quot; &quot;3&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
+    }
+    arg3 = reinterpret_cast&lt; char * &gt;(buf3);
</ins><span class="cx">   }
</span><del>-  arg3 = reinterpret_cast&lt; char * &gt;(buf3);
</del><span class="cx">   (arg1)-&gt;execute((char const *)arg2,(char const *)arg3);
</span><span class="cx">   resultobj = SWIG_Py_Void();
</span><span class="cx">   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
</span><span class="lines">@@ -9210,89 +7444,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWIGINTERN PyObject *_wrap_CoreSession_execute__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  CoreSession *arg1 = (CoreSession *) 0 ;
-  char *arg2 = (char *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int res2 ;
-  char *buf2 = 0 ;
-  int alloc2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)&quot;OO:CoreSession_execute&quot;,&amp;obj0,&amp;obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;CoreSession_execute&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;CoreSession *&quot;&quot;'&quot;); 
-  }
-  arg1 = reinterpret_cast&lt; CoreSession * &gt;(argp1);
-  res2 = SWIG_AsCharPtrAndSize(obj1, &amp;buf2, NULL, &amp;alloc2);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), &quot;in method '&quot; &quot;CoreSession_execute&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;char const *&quot;&quot;'&quot;);
-  }
-  arg2 = reinterpret_cast&lt; char * &gt;(buf2);
-  (arg1)-&gt;execute((char const *)arg2);
-  resultobj = SWIG_Py_Void();
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  return resultobj;
-fail:
-  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_CoreSession_execute(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[4];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = (int)PyObject_Length(args);
-  for (ii = 0; (ii &lt; argc) &amp;&amp; (ii &lt; 3); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 2) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        return _wrap_CoreSession_execute__SWIG_1(self, args);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &amp;vptr, SWIGTYPE_p_CoreSession, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0);
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_CoreSession_execute__SWIG_0(self, args);
-        }
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,&quot;Wrong number of arguments for overloaded function 'CoreSession_execute'.\n&quot;
-    &quot;  Possible C/C++ prototypes are:\n&quot;
-    &quot;    execute(CoreSession *,char const *,char const *)\n&quot;
-    &quot;    execute(CoreSession *,char const *)\n&quot;);
-  return NULL;
-}
-
-
</del><span class="cx"> SWIGINTERN PyObject *_wrap_CoreSession_sendEvent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
</span><span class="cx">   PyObject *resultobj = 0;
</span><span class="cx">   CoreSession *arg1 = (CoreSession *) 0 ;
</span><span class="lines">@@ -10585,8 +8736,6 @@
</span><span class="cx">          { (char *)&quot;EventConsumer_events_get&quot;, _wrap_EventConsumer_events_get, METH_VARARGS, NULL},
</span><span class="cx">          { (char *)&quot;EventConsumer_e_event_id_set&quot;, _wrap_EventConsumer_e_event_id_set, METH_VARARGS, NULL},
</span><span class="cx">          { (char *)&quot;EventConsumer_e_event_id_get&quot;, _wrap_EventConsumer_e_event_id_get, METH_VARARGS, NULL},
</span><del>-         { (char *)&quot;EventConsumer_node_set&quot;, _wrap_EventConsumer_node_set, METH_VARARGS, NULL},
-         { (char *)&quot;EventConsumer_node_get&quot;, _wrap_EventConsumer_node_get, METH_VARARGS, NULL},
</del><span class="cx">          { (char *)&quot;EventConsumer_e_callback_set&quot;, _wrap_EventConsumer_e_callback_set, METH_VARARGS, NULL},
</span><span class="cx">          { (char *)&quot;EventConsumer_e_callback_get&quot;, _wrap_EventConsumer_e_callback_get, METH_VARARGS, NULL},
</span><span class="cx">          { (char *)&quot;EventConsumer_e_subclass_name_set&quot;, _wrap_EventConsumer_e_subclass_name_set, METH_VARARGS, NULL},
</span><span class="lines">@@ -10595,6 +8744,7 @@
</span><span class="cx">          { (char *)&quot;EventConsumer_e_cb_arg_get&quot;, _wrap_EventConsumer_e_cb_arg_get, METH_VARARGS, NULL},
</span><span class="cx">          { (char *)&quot;new_EventConsumer&quot;, _wrap_new_EventConsumer, METH_VARARGS, NULL},
</span><span class="cx">          { (char *)&quot;delete_EventConsumer&quot;, _wrap_delete_EventConsumer, METH_VARARGS, NULL},
</span><ins>+         { (char *)&quot;EventConsumer_bind&quot;, _wrap_EventConsumer_bind, METH_VARARGS, NULL},
</ins><span class="cx">          { (char *)&quot;EventConsumer_pop&quot;, _wrap_EventConsumer_pop, METH_VARARGS, NULL},
</span><span class="cx">          { (char *)&quot;EventConsumer_swigregister&quot;, EventConsumer_swigregister, METH_VARARGS, NULL},
</span><span class="cx">          { (char *)&quot;delete_CoreSession&quot;, _wrap_delete_CoreSession, METH_VARARGS, NULL},
</span><span class="lines">@@ -10716,7 +8866,6 @@
</span><span class="cx"> static swig_type_info _swigt__p_switch_channel_state_t = {&quot;_p_switch_channel_state_t&quot;, &quot;switch_channel_state_t *&quot;, 0, 0, (void*)0, 0};
</span><span class="cx"> static swig_type_info _swigt__p_switch_channel_t = {&quot;_p_switch_channel_t&quot;, &quot;switch_channel_t *&quot;, 0, 0, (void*)0, 0};
</span><span class="cx"> static swig_type_info _swigt__p_switch_core_session_t = {&quot;_p_switch_core_session_t&quot;, &quot;switch_core_session_t *&quot;, 0, 0, (void*)0, 0};
</span><del>-static swig_type_info _swigt__p_switch_event_node_t = {&quot;_p_switch_event_node_t&quot;, &quot;switch_event_node_t *&quot;, 0, 0, (void*)0, 0};
</del><span class="cx"> static swig_type_info _swigt__p_switch_event_t = {&quot;_p_switch_event_t&quot;, &quot;switch_event_t *&quot;, 0, 0, (void*)0, 0};
</span><span class="cx"> static swig_type_info _swigt__p_switch_event_types_t = {&quot;_p_switch_event_types_t&quot;, &quot;switch_event_types_t *&quot;, 0, 0, (void*)0, 0};
</span><span class="cx"> static swig_type_info _swigt__p_switch_input_args_t = {&quot;_p_switch_input_args_t&quot;, &quot;switch_input_args_t *&quot;, 0, 0, (void*)0, 0};
</span><span class="lines">@@ -10745,7 +8894,6 @@
</span><span class="cx">   &amp;_swigt__p_switch_channel_state_t,
</span><span class="cx">   &amp;_swigt__p_switch_channel_t,
</span><span class="cx">   &amp;_swigt__p_switch_core_session_t,
</span><del>-  &amp;_swigt__p_switch_event_node_t,
</del><span class="cx">   &amp;_swigt__p_switch_event_t,
</span><span class="cx">   &amp;_swigt__p_switch_event_types_t,
</span><span class="cx">   &amp;_swigt__p_switch_input_args_t,
</span><span class="lines">@@ -10774,7 +8922,6 @@
</span><span class="cx"> static swig_cast_info _swigc__p_switch_channel_state_t[] = {  {&amp;_swigt__p_switch_channel_state_t, 0, 0, 0},{0, 0, 0, 0}};
</span><span class="cx"> static swig_cast_info _swigc__p_switch_channel_t[] = {  {&amp;_swigt__p_switch_channel_t, 0, 0, 0},{0, 0, 0, 0}};
</span><span class="cx"> static swig_cast_info _swigc__p_switch_core_session_t[] = {  {&amp;_swigt__p_switch_core_session_t, 0, 0, 0},{0, 0, 0, 0}};
</span><del>-static swig_cast_info _swigc__p_switch_event_node_t[] = {  {&amp;_swigt__p_switch_event_node_t, 0, 0, 0},{0, 0, 0, 0}};
</del><span class="cx"> static swig_cast_info _swigc__p_switch_event_t[] = {  {&amp;_swigt__p_switch_event_t, 0, 0, 0},{0, 0, 0, 0}};
</span><span class="cx"> static swig_cast_info _swigc__p_switch_event_types_t[] = {  {&amp;_swigt__p_switch_event_types_t, 0, 0, 0},{0, 0, 0, 0}};
</span><span class="cx"> static swig_cast_info _swigc__p_switch_input_args_t[] = {  {&amp;_swigt__p_switch_input_args_t, 0, 0, 0},{0, 0, 0, 0}};
</span><span class="lines">@@ -10803,7 +8950,6 @@
</span><span class="cx">   _swigc__p_switch_channel_state_t,
</span><span class="cx">   _swigc__p_switch_channel_t,
</span><span class="cx">   _swigc__p_switch_core_session_t,
</span><del>-  _swigc__p_switch_event_node_t,
</del><span class="cx">   _swigc__p_switch_event_t,
</span><span class="cx">   _swigc__p_switch_event_types_t,
</span><span class="cx">   _swigc__p_switch_input_args_t,
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_pythonmod_python_wrapcpprej"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp.rej (0 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp.rej                                (rev 0)
+++ freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp.rej        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+***************
+*** 5555,5561 ****
+      SWIG_exception_fail(SWIG_ArgError(ecode2), &quot;in method '&quot; &quot;EventConsumer_pop&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+    } 
+    arg2 = static_cast&lt; int &gt;(val2);
+    result = (Event *)(arg1)-&gt;pop(arg2);
+    resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_POINTER_OWN |  0 );
+    return resultobj;
+  fail:
+--- 5555,5563 ----
+      SWIG_exception_fail(SWIG_ArgError(ecode2), &quot;in method '&quot; &quot;EventConsumer_pop&quot; &quot;', argument &quot; &quot;2&quot;&quot; of type '&quot; &quot;int&quot;&quot;'&quot;);
+    } 
+    arg2 = static_cast&lt; int &gt;(val2);
++   Py_BEGIN_ALLOW_THREADS;
+    result = (Event *)(arg1)-&gt;pop(arg2);
++   Py_END_ALLOW_THREADS;
+    resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_POINTER_OWN |  0 );
+    return resultobj;
+  fail:
+***************
+*** 5577,5583 ****
+      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;EventConsumer_pop&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;EventConsumer *&quot;&quot;'&quot;); 
+    }
+    arg1 = reinterpret_cast&lt; EventConsumer * &gt;(argp1);
+    result = (Event *)(arg1)-&gt;pop();
+    resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_POINTER_OWN |  0 );
+    return resultobj;
+  fail:
+--- 5579,5587 ----
+      SWIG_exception_fail(SWIG_ArgError(res1), &quot;in method '&quot; &quot;EventConsumer_pop&quot; &quot;', argument &quot; &quot;1&quot;&quot; of type '&quot; &quot;EventConsumer *&quot;&quot;'&quot;); 
+    }
+    arg1 = reinterpret_cast&lt; EventConsumer * &gt;(argp1);
++   Py_BEGIN_ALLOW_THREADS;
+    result = (Event *)(arg1)-&gt;pop();
++   Py_END_ALLOW_THREADS;
+    resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_POINTER_OWN |  0 );
+    return resultobj;
+  fail:
</ins></span></pre></div>
<a id="freeswitchtrunksrcswitch_corecorig"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/src/switch_core.c.orig (0 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core.c.orig                                (rev 0)
+++ freeswitch/trunk/src/switch_core.c.orig        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -0,0 +1,2018 @@
</span><ins>+/* 
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the &quot;License&quot;); 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 &quot;AS IS&quot; 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 &lt;anthm@freeswitch.org&gt;
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * 
+ * Anthony Minessale II &lt;anthm@freeswitch.org&gt;
+ * Michael Jerris &lt;mike@jerris.com&gt;
+ * Paul D. Tinsley &lt;pdt at jackhammer.org&gt;
+ * Marcel Barbulescu &lt;marcelbarbulescu@gmail.com&gt;
+ *
+ *
+ * switch_core.c -- Main Core Library
+ *
+ */
+
+
+
+#include &lt;switch.h&gt;
+#include &lt;switch_stun.h&gt;
+#include &lt;switch_nat.h&gt;
+#include &lt;switch_version.h&gt;
+#include &quot;private/switch_core_pvt.h&quot;
+#ifndef WIN32
+#include &lt;switch_private.h&gt;
+#ifdef HAVE_SETRLIMIT
+#include &lt;sys/resource.h&gt;
+#endif
+#endif
+#include &lt;errno.h&gt;
+
+
+SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = { 0 };
+
+/* The main runtime obj we keep this hidden for ourselves */
+struct switch_runtime runtime = { 0 };
+static void switch_load_core_config(const char *file);
+
+static void send_heartbeat(void)
+{
+        switch_event_t *event;
+        switch_core_time_duration_t duration;
+
+        switch_core_measure_time(switch_core_uptime(), &amp;duration);
+
+        if (switch_event_create(&amp;event, SWITCH_EVENT_HEARTBEAT) == SWITCH_STATUS_SUCCESS) {
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Event-Info&quot;, &quot;System Ready&quot;);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Up-Time&quot;,
+                                                                &quot;%u year%s, &quot;
+                                                                &quot;%u day%s, &quot;
+                                                                &quot;%u hour%s, &quot;
+                                                                &quot;%u minute%s, &quot;
+                                                                &quot;%u second%s, &quot;
+                                                                &quot;%u millisecond%s, &quot;
+                                                                &quot;%u microsecond%s&quot;,
+                                                                duration.yr, duration.yr == 1 ? &quot;&quot; : &quot;s&quot;,
+                                                                duration.day, duration.day == 1 ? &quot;&quot; : &quot;s&quot;,
+                                                                duration.hr, duration.hr == 1 ? &quot;&quot; : &quot;s&quot;,
+                                                                duration.min, duration.min == 1 ? &quot;&quot; : &quot;s&quot;,
+                                                                duration.sec, duration.sec == 1 ? &quot;&quot; : &quot;s&quot;,
+                                                                duration.ms, duration.ms == 1 ? &quot;&quot; : &quot;s&quot;, duration.mms, duration.mms == 1 ? &quot;&quot; : &quot;s&quot;);
+
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Session-Count&quot;, &quot;%u&quot;, switch_core_session_count());
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Session-Per-Sec&quot;, &quot;%u&quot;, runtime.sps);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Session-Since-Startup&quot;, &quot;%&quot; SWITCH_SIZE_T_FMT, switch_core_session_id() - 1);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Idle-CPU&quot;, &quot;%f&quot;, switch_core_idle_cpu());
+                switch_event_fire(&amp;event);
+        }
+}
+
+static char main_ip4[256] = &quot;&quot;;
+static char main_ip6[256] = &quot;&quot;;
+
+static void check_ip(void)
+{
+        char guess_ip4[256] = &quot;&quot;;
+        char guess_ip6[256] = &quot;&quot;;
+        char old_ip4[256] = &quot;&quot;;
+        char old_ip6[256] = &quot;&quot;;
+        int ok4 = 1, ok6 = 1;
+        int mask = 0;
+        static char hostname[256] = &quot;&quot;;
+
+        gethostname(hostname, sizeof(hostname));
+        switch_core_set_variable(&quot;hostname&quot;, hostname);
+
+        switch_find_local_ip(guess_ip4, sizeof(guess_ip4), &amp;mask, AF_INET);
+        switch_find_local_ip(guess_ip6, sizeof(guess_ip6), NULL, AF_INET6);
+
+        if (!*main_ip4) {
+                switch_set_string(main_ip4, guess_ip4);
+        } else {
+                if (!(ok4 = !strcmp(main_ip4, guess_ip4))) {
+                        struct in_addr in;
+
+                        in.s_addr = mask;
+                        switch_set_string(old_ip4, main_ip4);
+                        switch_set_string(main_ip4, guess_ip4);
+                        switch_core_set_variable(&quot;local_ip_v4&quot;, guess_ip4);
+                        switch_core_set_variable(&quot;local_mask_v4&quot;, inet_ntoa(in));
+                }
+        }
+
+        if (!*main_ip6) {
+                switch_set_string(main_ip6, guess_ip6);
+        } else {
+                if (!(ok6 = !strcmp(main_ip6, guess_ip6))) {
+                        switch_set_string(old_ip6, main_ip6);
+                        switch_set_string(main_ip6, guess_ip6);
+                        switch_core_set_variable(&quot;local_ip_v6&quot;, guess_ip6);
+                }
+        }
+
+        if (!ok4 || !ok6) {
+                switch_event_t *event;
+
+                if (switch_event_create(&amp;event, SWITCH_EVENT_TRAP) == SWITCH_STATUS_SUCCESS) {
+                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;condition&quot;, &quot;network-address-change&quot;);
+                        if (!ok4) {
+                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;network-address-previous-v4&quot;, old_ip4);
+                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;network-address-change-v4&quot;, main_ip4);
+                        }
+                        if (!ok6) {
+                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;network-address-previous-v6&quot;, old_ip6);
+                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;network-address-change-v6&quot;, main_ip6);
+                        }
+                        switch_event_fire(&amp;event);
+                }
+        }
+}
+
+SWITCH_STANDARD_SCHED_FUNC(heartbeat_callback)
+{
+        send_heartbeat();
+        check_ip();
+
+        /* reschedule this task */
+        task-&gt;runtime = switch_epoch_time_now(NULL) + 20;
+}
+
+
+SWITCH_DECLARE(switch_status_t) switch_core_set_console(const char *console)
+{
+        if ((runtime.console = fopen(console, &quot;a&quot;)) == 0) {
+                fprintf(stderr, &quot;Cannot open output file %s.\n&quot;, console);
+                return SWITCH_STATUS_FALSE;
+        }
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_DECLARE(FILE *) switch_core_get_console(void)
+{
+        return runtime.console;
+}
+
+SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel_t channel)
+{
+        FILE *handle = stdout;
+
+        switch (channel) {
+        case SWITCH_CHANNEL_ID_LOG:
+        case SWITCH_CHANNEL_ID_LOG_CLEAN:
+                handle = runtime.console;
+                break;
+        default:
+                handle = runtime.console;
+                break;
+        }
+
+        return handle;
+}
+
+SWITCH_DECLARE(void) switch_core_remove_state_handler(const switch_state_handler_table_t *state_handler)
+{
+        int index, tmp_index = 0;
+        const switch_state_handler_table_t *tmp[SWITCH_MAX_STATE_HANDLERS + 1] = { 0 };
+
+        switch_mutex_lock(runtime.global_mutex);
+
+        for (index = 0; index &lt; runtime.state_handler_index; index++) {
+                const switch_state_handler_table_t *cur = runtime.state_handlers[index];
+                runtime.state_handlers[index] = NULL;
+                if (cur == state_handler) {
+                        continue;
+                }
+                tmp[tmp_index++] = cur;
+        }
+
+        runtime.state_handler_index = 0;
+
+        for (index = 0; index &lt; tmp_index; index++) {
+                runtime.state_handlers[runtime.state_handler_index++] = tmp[index];
+        }
+        switch_mutex_unlock(runtime.global_mutex);
+}
+
+
+SWITCH_DECLARE(int) switch_core_add_state_handler(const switch_state_handler_table_t *state_handler)
+{
+        int index;
+
+        switch_mutex_lock(runtime.global_mutex);
+        index = runtime.state_handler_index++;
+
+        if (runtime.state_handler_index &gt;= SWITCH_MAX_STATE_HANDLERS) {
+                index = -1;
+        } else {
+                runtime.state_handlers[index] = state_handler;
+        }
+
+        switch_mutex_unlock(runtime.global_mutex);
+        return index;
+}
+
+SWITCH_DECLARE(const switch_state_handler_table_t *) switch_core_get_state_handler(int index)
+{
+
+        if (index &gt;= SWITCH_MAX_STATE_HANDLERS || index &gt; runtime.state_handler_index) {
+                return NULL;
+        }
+
+        return runtime.state_handlers[index];
+}
+
+SWITCH_DECLARE(void) switch_core_dump_variables(switch_stream_handle_t *stream)
+{
+        switch_hash_index_t *hi;
+        const void *var;
+        void *val;
+        switch_mutex_lock(runtime.global_mutex);
+        for (hi = switch_hash_first(NULL, runtime.global_vars); hi; hi = switch_hash_next(hi)) {
+                char *vvar, *vval;
+                switch_hash_this(hi, &amp;var, NULL, &amp;val);
+                vvar = (char *) var;
+                vval = (char *) val;
+                stream-&gt;write_function(stream, &quot;%s=%s\n&quot;, vvar, vval);
+        }
+        switch_mutex_unlock(runtime.global_mutex);
+}
+
+SWITCH_DECLARE(char *) switch_core_get_variable(const char *varname)
+{
+        char *val;
+        switch_mutex_lock(runtime.global_var_mutex);
+        val = (char *) switch_core_hash_find(runtime.global_vars, varname);
+        switch_mutex_unlock(runtime.global_var_mutex);
+        return val;
+}
+
+static void switch_core_unset_variables(void)
+{
+        switch_hash_index_t *hi;
+        const void *var;
+        void *val;
+
+        switch_mutex_lock(runtime.global_var_mutex);
+        for (hi = switch_hash_first(NULL, runtime.global_vars); hi; hi = switch_hash_next(hi)) {
+                switch_hash_this(hi, &amp;var, NULL, &amp;val);
+                free(val);
+        }
+        switch_mutex_unlock(runtime.global_var_mutex);
+}
+
+SWITCH_DECLARE(void) switch_core_set_variable(const char *varname, const char *value)
+{
+        char *val;
+
+        if (varname) {
+                switch_mutex_lock(runtime.global_var_mutex);
+                val = (char *) switch_core_hash_find(runtime.global_vars, varname);
+                if (val) {
+                        free(val);
+                }
+                if (value) {
+                        char *v = strdup(value);
+                        switch_string_var_check(v, SWITCH_TRUE);
+                        switch_core_hash_insert(runtime.global_vars, varname, v);
+                } else {
+                        switch_core_hash_delete(runtime.global_vars, varname);
+                }
+                switch_mutex_unlock(runtime.global_var_mutex);
+        }
+}
+
+SWITCH_DECLARE(char *) switch_core_get_uuid(void)
+{
+        return runtime.uuid_str;
+}
+
+
+static void *SWITCH_THREAD_FUNC switch_core_service_thread(switch_thread_t *thread, void *obj)
+{
+        switch_core_session_t *session = obj;
+        switch_channel_t *channel;
+        switch_frame_t *read_frame;
+
+//  switch_assert(thread != NULL);
+//  switch_assert(session != NULL);
+
+        if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
+                return NULL;
+        }
+
+        switch_mutex_lock(session-&gt;frame_read_mutex);
+
+        channel = switch_core_session_get_channel(session);
+
+        switch_channel_set_flag(channel, CF_SERVICE);
+        while (switch_channel_test_flag(channel, CF_SERVICE)) {
+                switch (switch_core_session_read_frame(session, &amp;read_frame, SWITCH_IO_FLAG_NONE, 0)) {
+                case SWITCH_STATUS_SUCCESS:
+                case SWITCH_STATUS_TIMEOUT:
+                case SWITCH_STATUS_BREAK:
+                        break;
+                default:
+                        switch_channel_clear_flag(channel, CF_SERVICE);
+                        continue;
+                }
+        }
+
+        switch_mutex_unlock(session-&gt;frame_read_mutex);
+
+        switch_core_session_rwunlock(session);
+
+        return NULL;
+}
+
+/* Either add a timeout here or make damn sure the thread cannot get hung somehow (my preference) */
+SWITCH_DECLARE(void) switch_core_thread_session_end(switch_core_session_t *session)
+{
+        switch_channel_t *channel;
+        switch_assert(session);
+
+        channel = switch_core_session_get_channel(session);
+        switch_assert(channel);
+
+        switch_channel_clear_flag(channel, CF_SERVICE);
+}
+
+SWITCH_DECLARE(void) switch_core_service_session(switch_core_session_t *session)
+{
+        switch_channel_t *channel;
+        switch_assert(session);
+
+        channel = switch_core_session_get_channel(session);
+        switch_assert(channel);
+
+        switch_core_session_launch_thread(session, (void *(*)(switch_thread_t *,void *))switch_core_service_thread, session);
+}
+
+/* This function abstracts the thread creation for modules by allowing you to pass a function ptr and
+   a void object and trust that that the function will be run in a thread with arg  This lets
+   you request and activate a thread without giving up any knowledge about what is in the thread
+   neither the core nor the calling module know anything about each other.
+
+   This thread is expected to never exit until the application exits so the func is responsible
+   to make sure that is the case.
+
+   The typical use for this is so switch_loadable_module.c can start up a thread for each module
+   passing the table of module methods as a session obj into the core without actually allowing
+   the core to have any clue and keeping switch_loadable_module.c from needing any thread code.
+
+*/
+
+SWITCH_DECLARE(switch_thread_t *) switch_core_launch_thread(switch_thread_start_t func, void *obj, switch_memory_pool_t *pool)
+{
+        switch_thread_t *thread = NULL;
+        switch_threadattr_t *thd_attr = NULL;
+        switch_core_thread_session_t *ts;
+        int mypool;
+
+        mypool = pool ? 0 : 1;
+
+        if (!pool &amp;&amp; switch_core_new_memory_pool(&amp;pool) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Could not allocate memory pool\n&quot;);
+                return NULL;
+        }
+
+        switch_threadattr_create(&amp;thd_attr, pool);
+
+        if ((ts = switch_core_alloc(pool, sizeof(*ts))) == 0) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Could not allocate memory\n&quot;);
+        } else {
+                if (mypool) {
+                        ts-&gt;pool = pool;
+                }
+                ts-&gt;objs[0] = obj;
+                ts-&gt;objs[1] = thread;
+                switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+                switch_threadattr_priority_increase(thd_attr);
+                switch_thread_create(&amp;thread, thd_attr, func, ts, pool);
+        }
+
+        return thread;
+}
+
+SWITCH_DECLARE(void) switch_core_set_globals(void)
+{
+#define BUFSIZE 1024
+#ifdef WIN32
+        char lpPathBuffer[BUFSIZE];
+        DWORD dwBufSize = BUFSIZE;
+        char base_dir[1024];
+        char *lastbacklash;
+        GetModuleFileName(NULL, base_dir, BUFSIZE);
+        lastbacklash = strrchr(base_dir, '\\');
+        base_dir[(lastbacklash - base_dir)] = '\0';
+#else
+        char base_dir[1024] = SWITCH_PREFIX_DIR;
+#endif
+
+        if (!SWITCH_GLOBAL_dirs.base_dir &amp;&amp; (SWITCH_GLOBAL_dirs.base_dir = (char *) malloc(BUFSIZE))) {
+                switch_snprintf(SWITCH_GLOBAL_dirs.base_dir, BUFSIZE, &quot;%s&quot;, base_dir);
+        }
+
+        if (!SWITCH_GLOBAL_dirs.mod_dir &amp;&amp; (SWITCH_GLOBAL_dirs.mod_dir = (char *) malloc(BUFSIZE))) {
+#ifdef SWITCH_MOD_DIR
+                switch_snprintf(SWITCH_GLOBAL_dirs.mod_dir, BUFSIZE, &quot;%s&quot;, SWITCH_MOD_DIR);
+#else
+                switch_snprintf(SWITCH_GLOBAL_dirs.mod_dir, BUFSIZE, &quot;%s%smod&quot;, base_dir, SWITCH_PATH_SEPARATOR);
+#endif
+        }
+
+        if (!SWITCH_GLOBAL_dirs.conf_dir &amp;&amp; (SWITCH_GLOBAL_dirs.conf_dir = (char *) malloc(BUFSIZE))) {
+#ifdef SWITCH_CONF_DIR
+                switch_snprintf(SWITCH_GLOBAL_dirs.conf_dir, BUFSIZE, &quot;%s&quot;, SWITCH_CONF_DIR);
+#else
+                switch_snprintf(SWITCH_GLOBAL_dirs.conf_dir, BUFSIZE, &quot;%s%sconf&quot;, base_dir, SWITCH_PATH_SEPARATOR);
+#endif
+        }
+
+        if (!SWITCH_GLOBAL_dirs.log_dir &amp;&amp; (SWITCH_GLOBAL_dirs.log_dir = (char *) malloc(BUFSIZE))) {
+#ifdef SWITCH_LOG_DIR
+                switch_snprintf(SWITCH_GLOBAL_dirs.log_dir, BUFSIZE, &quot;%s&quot;, SWITCH_LOG_DIR);
+#else
+                switch_snprintf(SWITCH_GLOBAL_dirs.log_dir, BUFSIZE, &quot;%s%slog&quot;, base_dir, SWITCH_PATH_SEPARATOR);
+#endif
+        }
+
+        if (!SWITCH_GLOBAL_dirs.run_dir &amp;&amp; (SWITCH_GLOBAL_dirs.run_dir = (char *) malloc(BUFSIZE))) {
+#ifdef SWITCH_RUN_DIR
+                switch_snprintf(SWITCH_GLOBAL_dirs.run_dir, BUFSIZE, &quot;%s&quot;, SWITCH_RUN_DIR);
+#else
+                switch_snprintf(SWITCH_GLOBAL_dirs.run_dir, BUFSIZE, &quot;%s%srun&quot;, base_dir, SWITCH_PATH_SEPARATOR);
+#endif
+        }
+
+        if (!SWITCH_GLOBAL_dirs.recordings_dir &amp;&amp; (SWITCH_GLOBAL_dirs.recordings_dir = (char *) malloc(BUFSIZE))) {
+#ifdef SWITCH_RECORDINGS_DIR
+                switch_snprintf(SWITCH_GLOBAL_dirs.recordings_dir, BUFSIZE, &quot;%s&quot;, SWITCH_RECORDINGS_DIR);
+#else
+                switch_snprintf(SWITCH_GLOBAL_dirs.recordings_dir, BUFSIZE, &quot;%s%srecordings&quot;, base_dir, SWITCH_PATH_SEPARATOR);
+#endif
+        }
+
+        if (!SWITCH_GLOBAL_dirs.sounds_dir &amp;&amp; (SWITCH_GLOBAL_dirs.sounds_dir = (char *) malloc(BUFSIZE))) {
+#ifdef SWITCH_SOUNDS_DIR
+                switch_snprintf(SWITCH_GLOBAL_dirs.sounds_dir, BUFSIZE, &quot;%s&quot;, SWITCH_SOUNDS_DIR);
+#else
+                switch_snprintf(SWITCH_GLOBAL_dirs.sounds_dir, BUFSIZE, &quot;%s%ssounds&quot;, base_dir, SWITCH_PATH_SEPARATOR);
+#endif
+        }
+
+        if (!SWITCH_GLOBAL_dirs.storage_dir &amp;&amp; (SWITCH_GLOBAL_dirs.storage_dir = (char *) malloc(BUFSIZE))) {
+#ifdef SWITCH_STORAGE_DIR
+                switch_snprintf(SWITCH_GLOBAL_dirs.storage_dir, BUFSIZE, &quot;%s&quot;, SWITCH_STORAGE_DIR);
+#else
+                switch_snprintf(SWITCH_GLOBAL_dirs.storage_dir, BUFSIZE, &quot;%s%sstorage&quot;, base_dir, SWITCH_PATH_SEPARATOR);
+#endif
+        }
+
+        if (!SWITCH_GLOBAL_dirs.db_dir &amp;&amp; (SWITCH_GLOBAL_dirs.db_dir = (char *) malloc(BUFSIZE))) {
+#ifdef SWITCH_DB_DIR
+                switch_snprintf(SWITCH_GLOBAL_dirs.db_dir, BUFSIZE, &quot;%s&quot;, SWITCH_DB_DIR);
+#else
+                switch_snprintf(SWITCH_GLOBAL_dirs.db_dir, BUFSIZE, &quot;%s%sdb&quot;, base_dir, SWITCH_PATH_SEPARATOR);
+#endif
+        }
+
+        if (!SWITCH_GLOBAL_dirs.script_dir &amp;&amp; (SWITCH_GLOBAL_dirs.script_dir = (char *) malloc(BUFSIZE))) {
+#ifdef SWITCH_SCRIPT_DIR
+                switch_snprintf(SWITCH_GLOBAL_dirs.script_dir, BUFSIZE, &quot;%s&quot;, SWITCH_SCRIPT_DIR);
+#else
+                switch_snprintf(SWITCH_GLOBAL_dirs.script_dir, BUFSIZE, &quot;%s%sscripts&quot;, base_dir, SWITCH_PATH_SEPARATOR);
+#endif
+        }
+
+        if (!SWITCH_GLOBAL_dirs.htdocs_dir &amp;&amp; (SWITCH_GLOBAL_dirs.htdocs_dir = (char *) malloc(BUFSIZE))) {
+#ifdef SWITCH_HTDOCS_DIR
+                switch_snprintf(SWITCH_GLOBAL_dirs.htdocs_dir, BUFSIZE, &quot;%s&quot;, SWITCH_HTDOCS_DIR);
+#else
+                switch_snprintf(SWITCH_GLOBAL_dirs.htdocs_dir, BUFSIZE, &quot;%s%shtdocs&quot;, base_dir, SWITCH_PATH_SEPARATOR);
+#endif
+        }
+
+        if (!SWITCH_GLOBAL_dirs.grammar_dir &amp;&amp; (SWITCH_GLOBAL_dirs.grammar_dir = (char *) malloc(BUFSIZE))) {
+#ifdef SWITCH_GRAMMAR_DIR
+                switch_snprintf(SWITCH_GLOBAL_dirs.grammar_dir, BUFSIZE, &quot;%s&quot;, SWITCH_GRAMMAR_DIR);
+#else
+                switch_snprintf(SWITCH_GLOBAL_dirs.grammar_dir, BUFSIZE, &quot;%s%sgrammar&quot;, base_dir, SWITCH_PATH_SEPARATOR);
+#endif
+        }
+
+        if (!SWITCH_GLOBAL_dirs.temp_dir &amp;&amp; (SWITCH_GLOBAL_dirs.temp_dir = (char *) malloc(BUFSIZE))) {
+#ifdef SWITCH_TEMP_DIR
+                switch_snprintf(SWITCH_GLOBAL_dirs.temp_dir, BUFSIZE, &quot;%s&quot;, SWITCH_TEMP_DIR);
+#else
+#ifdef WIN32
+                GetTempPath(dwBufSize, lpPathBuffer);
+                switch_snprintf(SWITCH_GLOBAL_dirs.temp_dir, BUFSIZE, &quot;%s&quot;, lpPathBuffer);
+#else
+                switch_snprintf(SWITCH_GLOBAL_dirs.temp_dir, BUFSIZE, &quot;%s&quot;, &quot;/tmp/&quot;);
+#endif
+#endif
+        }
+
+        switch_assert(SWITCH_GLOBAL_dirs.base_dir);
+        switch_assert(SWITCH_GLOBAL_dirs.mod_dir);
+        switch_assert(SWITCH_GLOBAL_dirs.conf_dir);
+        switch_assert(SWITCH_GLOBAL_dirs.log_dir);
+        switch_assert(SWITCH_GLOBAL_dirs.run_dir);
+        switch_assert(SWITCH_GLOBAL_dirs.db_dir);
+        switch_assert(SWITCH_GLOBAL_dirs.script_dir);
+        switch_assert(SWITCH_GLOBAL_dirs.htdocs_dir);
+        switch_assert(SWITCH_GLOBAL_dirs.grammar_dir);
+        switch_assert(SWITCH_GLOBAL_dirs.recordings_dir);
+        switch_assert(SWITCH_GLOBAL_dirs.sounds_dir);
+        switch_assert(SWITCH_GLOBAL_dirs.temp_dir);
+}
+
+SWITCH_DECLARE(int32_t) set_high_priority(void)
+{
+#ifdef WIN32
+        SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
+#else
+
+#ifdef USE_SETRLIMIT
+        struct rlimit lim = { RLIM_INFINITY, RLIM_INFINITY };
+#endif
+
+#ifdef USE_SCHED_SETSCHEDULER
+        /*
+         * Try to use a round-robin scheduler
+         * with a fallback if that does not work
+         */
+        struct sched_param sched = { 0 };
+        sched.sched_priority = 1;
+        if (sched_setscheduler(0, SCHED_RR, &amp;sched)) {
+                sched.sched_priority = 0;
+                if (sched_setscheduler(0, SCHED_OTHER, &amp;sched)) {
+                        return -1;
+                }
+        }
+#endif
+
+#ifdef HAVE_SETPRIORITY
+        /*
+         * setpriority() works on FreeBSD (6.2), nice() doesn't
+         */
+        if (setpriority(PRIO_PROCESS, getpid(), -10) &lt; 0) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Could not set nice level\n&quot;);
+        }
+#else
+        if (nice(-10) != -10) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Could not set nice level\n&quot;);
+        }
+#endif
+
+#ifdef USE_SETRLIMIT
+        /*
+         * The amount of memory which can be mlocked is limited for non-root users.
+         * FS will segfault (= hitting the limit) soon after mlockall has been called
+         * and we've switched to a different user.
+         * So let's try to remove the mlock limit here...
+         */
+        if (setrlimit(RLIMIT_MEMLOCK, &amp;lim) &lt; 0) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Failed to disable memlock limit, application may crash if run as non-root user!\n&quot;);
+        }
+#endif
+
+#ifdef USE_MLOCKALL
+        /*
+         * Pin memory pages to RAM to prevent being swapped to disk
+         */
+        mlockall(MCL_CURRENT | MCL_FUTURE);
+#endif
+
+#endif
+        return 0;
+}
+
+SWITCH_DECLARE(int32_t) change_user_group(const char *user, const char *group)
+{
+#ifndef WIN32
+        uid_t runas_uid = 0;
+        gid_t runas_gid = 0;
+        struct passwd *runas_pw = NULL;
+
+        if (user) {
+                /*
+                 * Lookup user information in the system's db
+                 */
+                runas_pw = getpwnam(user);
+                if (!runas_pw) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Unknown user \&quot;%s\&quot;\n&quot;, user);
+                        return -1;
+                }
+                runas_uid = runas_pw-&gt;pw_uid;
+        }
+
+        if (group) {
+                struct group *gr = NULL;
+
+                /*
+                 * Lookup group information in the system's db
+                 */
+                gr = getgrnam(group);
+                if (!gr) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Unknown group \&quot;%s\&quot;\n&quot;, group);
+                        return -1;
+                }
+                runas_gid = gr-&gt;gr_gid;
+        }
+
+        if (runas_uid &amp;&amp; getuid() == runas_uid &amp;&amp; (!runas_gid || runas_gid == getgid())) {
+                /* already running as the right user and group, nothing to do! */
+                return 0;
+        }
+
+        if (runas_uid) {
+#ifdef HAVE_SETGROUPS
+                /*
+                 * Drop all group memberships prior to changing anything
+                 * or else we're going to inherit the parent's list of groups
+                 * (which is not what we want...)
+                 */
+                if (setgroups(0, NULL) &lt; 0) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Failed to drop group access list\n&quot;);
+                        return -1;
+                }
+#endif
+                if (runas_gid) {
+                        /*
+                         * A group has been passed, switch to it
+                         * (without loading the user's other groups)
+                         */
+                        if (setgid(runas_gid) &lt; 0) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Failed to change gid!\n&quot;);
+                                return -1;
+                        }
+                } else {
+                        /*
+                         * No group has been passed, use the user's primary group in this case
+                         */
+                        if (setgid(runas_pw-&gt;pw_gid) &lt; 0) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Failed to change gid!\n&quot;);
+                                return -1;
+                        }
+#ifdef HAVE_INITGROUPS
+                        /*
+                         * Set all the other groups the user is a member of
+                         * (This can be really useful for fine-grained access control)
+                         */
+                        if (initgroups(runas_pw-&gt;pw_name, runas_pw-&gt;pw_gid) &lt; 0) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Failed to set group access list for user\n&quot;);
+                                return -1;
+                        }
+#endif
+                }
+
+                /*
+                 * Finally drop all privileges by switching to the new userid
+                 */
+                if (setuid(runas_uid) &lt; 0) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Failed to change uid!\n&quot;);
+                        return -1;
+                }
+        }
+#endif
+        return 0;
+}
+
+SWITCH_DECLARE(void) switch_core_runtime_loop(int bg)
+{
+#ifdef WIN32
+        HANDLE shutdown_event;
+        char path[256] = &quot;&quot;;
+#endif
+        if (bg) {
+                bg = 0;
+#ifdef WIN32
+                switch_snprintf(path, sizeof(path), &quot;Global\\Freeswitch.%d&quot;, getpid());
+                shutdown_event = CreateEvent(NULL, FALSE, FALSE, path);
+                if (shutdown_event) {
+                        WaitForSingleObject(shutdown_event, INFINITE);
+                }
+#else
+                runtime.running = 1;
+                while (runtime.running) {
+                        switch_yield(1000000);
+                }
+#endif
+        } else {
+                /* wait for console input */
+                switch_console_loop();
+        }
+}
+
+SWITCH_DECLARE(const char *) switch_core_mime_ext2type(const char *ext)
+{
+        if (!ext) {
+                return NULL;
+        }
+        return (const char *) switch_core_hash_find(runtime.mime_types, ext);
+}
+
+
+SWITCH_DECLARE(switch_hash_index_t *) switch_core_mime_index(void)
+{
+        return switch_hash_first(NULL, runtime.mime_types);
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_mime_add_type(const char *type, const char *ext)
+{
+        const char *check;
+        switch_status_t status = SWITCH_STATUS_FALSE;
+
+        switch_assert(type);
+        switch_assert(ext);
+
+        check = (const char *) switch_core_hash_find(runtime.mime_types, ext);
+
+        if (!check) {
+                char *ptype = switch_core_permanent_strdup(type);
+                char *ext_list = strdup(ext);
+                int argc = 0;
+                char *argv[20] = { 0 };
+                int x;
+
+                switch_assert(ext_list);
+
+                if ((argc = switch_separate_string(ext_list, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+
+                        for (x = 0; x &lt; argc; x++) {
+                                if (argv[x] &amp;&amp; ptype) {
+                                        switch_core_hash_insert(runtime.mime_types, argv[x], ptype);
+                                }
+                        }
+
+                        status = SWITCH_STATUS_SUCCESS;
+                }
+
+                free(ext_list);
+        }
+
+        return status;
+}
+
+static void load_mime_types(void)
+{
+        char *cf = &quot;mime.types&quot;;
+        int fd = -1;
+        char line_buf[1024] = &quot;&quot;;
+        char *mime_path = NULL;
+
+        mime_path = switch_mprintf(&quot;%s/%s&quot;, SWITCH_GLOBAL_dirs.conf_dir, cf);
+        switch_assert(mime_path);
+
+        fd = open(mime_path, O_RDONLY | O_BINARY);
+        if (fd &lt;= 0) {
+                goto end;
+        }
+
+        while ((switch_fd_read_line(fd, line_buf, sizeof(line_buf)))) {
+                char *p;
+                char *type = line_buf;
+
+                if (*line_buf == '#') {
+                        continue;
+                }
+
+                if ((p = strchr(line_buf, '\r')) || (p = strchr(line_buf, '\n'))) {
+                        *p = '\0';
+                }
+
+                if ((p = strchr(type, '\t')) || (p = strchr(type, ' '))) {
+                        *p++ = '\0';
+
+                        while (*p == ' ' || *p == '\t') {
+                                p++;
+                        }
+
+                        switch_core_mime_add_type(type, p);
+                }
+
+        }
+
+        if (fd &gt; -1) {
+                close(fd);
+                fd = -1;
+        }
+
+  end:
+
+        switch_safe_free(mime_path);
+
+}
+
+SWITCH_DECLARE(void) switch_core_setrlimits(void)
+{
+#ifdef HAVE_SETRLIMIT
+        struct rlimit rlp;
+
+        /* 
+           Setting the stack size on FreeBSD results in an instant crash.
+
+           If anyone knows how to fix this,
+           feel free to submit a patch to http://jira.freeswitch.org 
+         */
+
+#ifndef __FreeBSD__
+        memset(&amp;rlp, 0, sizeof(rlp));
+        rlp.rlim_cur = SWITCH_THREAD_STACKSIZE;
+        rlp.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE;
+        setrlimit(RLIMIT_STACK, &amp;rlp);
+#endif
+
+        memset(&amp;rlp, 0, sizeof(rlp));
+        rlp.rlim_cur = 999999;
+        rlp.rlim_max = 999999;
+        setrlimit(RLIMIT_NOFILE, &amp;rlp);
+
+        memset(&amp;rlp, 0, sizeof(rlp));
+        rlp.rlim_cur = RLIM_INFINITY;
+        rlp.rlim_max = RLIM_INFINITY;
+
+        setrlimit(RLIMIT_CPU, &amp;rlp);
+        setrlimit(RLIMIT_DATA, &amp;rlp);
+        setrlimit(RLIMIT_FSIZE, &amp;rlp);
+#ifdef RLIMIT_NPROC
+        setrlimit(RLIMIT_NPROC, &amp;rlp);
+#endif
+#ifdef RLIMIT_RTPRIO
+        setrlimit(RLIMIT_RTPRIO, &amp;rlp);
+#endif
+
+#if !defined(__OpenBSD__) &amp;&amp; !defined(__NetBSD__)
+        setrlimit(RLIMIT_AS, &amp;rlp);
+#endif
+#endif
+        return;
+}
+
+typedef struct {
+        switch_memory_pool_t *pool;
+        switch_hash_t *hash;
+} switch_ip_list_t;
+
+static switch_ip_list_t IP_LIST = { 0 };
+
+SWITCH_DECLARE(switch_bool_t) switch_check_network_list_ip_token(const char *ip_str, const char *list_name, const char **token)
+{
+        switch_network_list_t *list;
+        uint32_t ip, net, mask, bits;
+        switch_bool_t ok = SWITCH_FALSE;
+
+        switch_mutex_lock(runtime.global_mutex);
+        switch_inet_pton(AF_INET, ip_str, &amp;ip);
+
+        ip = htonl(ip);
+
+        if ((list = switch_core_hash_find(IP_LIST.hash, list_name))) {
+                ok = switch_network_list_validate_ip_token(list, ip, token);
+        } else if (strchr(list_name, '/')) {
+                if (strchr(list_name, ',')) {
+                        char *list_name_dup = strdup(list_name);
+                        char *argv[32];
+                        int argc;
+
+                        switch_assert(list_name_dup);
+
+                        if ((argc = switch_separate_string(list_name_dup, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+                                int i;
+                                for (i = 0; i &lt; argc; i++) {
+                                        switch_parse_cidr(argv[i], &amp;net, &amp;mask, &amp;bits);
+                                        if ((ok = switch_test_subnet(ip, net, mask))) {
+                                                break;
+                                        }
+                                }
+                        }
+                        free(list_name_dup);
+                } else {
+                        switch_parse_cidr(list_name, &amp;net, &amp;mask, &amp;bits);
+                        ok = switch_test_subnet(ip, net, mask);
+                }
+        }
+        switch_mutex_unlock(runtime.global_mutex);
+
+        return ok;
+}
+
+
+SWITCH_DECLARE(void) switch_load_network_lists(switch_bool_t reload)
+{
+        switch_xml_t xml = NULL, x_lists = NULL, x_list = NULL, x_node = NULL, cfg = NULL;
+        switch_network_list_t *rfc_list, *list;
+        char guess_ip[16] = &quot;&quot;;
+        int mask = 0;
+        char guess_mask[16] = &quot;&quot;;
+        char *tmp_name;
+        struct in_addr in;
+
+        switch_find_local_ip(guess_ip, sizeof(guess_ip), &amp;mask, AF_INET);
+        in.s_addr = mask;
+        switch_set_string(guess_mask, inet_ntoa(in));
+
+        switch_mutex_lock(runtime.global_mutex);
+
+        if (IP_LIST.hash) {
+                switch_core_hash_destroy(&amp;IP_LIST.hash);
+        }
+
+        if (IP_LIST.pool) {
+                switch_core_destroy_memory_pool(&amp;IP_LIST.pool);
+        }
+
+        memset(&amp;IP_LIST, 0, sizeof(IP_LIST));
+        switch_core_new_memory_pool(&amp;IP_LIST.pool);
+        switch_core_hash_init(&amp;IP_LIST.hash, IP_LIST.pool);
+
+
+        tmp_name = &quot;rfc1918.auto&quot;;
+        switch_network_list_create(&amp;rfc_list, tmp_name, SWITCH_FALSE, IP_LIST.pool);
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Created ip list %s default (deny)\n&quot;, tmp_name);
+        switch_network_list_add_cidr(rfc_list, &quot;10.0.0.0/8&quot;, SWITCH_TRUE);
+        switch_network_list_add_cidr(rfc_list, &quot;172.16.0.0/12&quot;, SWITCH_TRUE);
+        switch_network_list_add_cidr(rfc_list, &quot;192.168.0.0/16&quot;, SWITCH_TRUE);
+        switch_core_hash_insert(IP_LIST.hash, tmp_name, rfc_list);
+
+        tmp_name = &quot;wan.auto&quot;;
+        switch_network_list_create(&amp;rfc_list, tmp_name, SWITCH_TRUE, IP_LIST.pool);
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Created ip list %s default (allow)\n&quot;, tmp_name);
+        switch_network_list_add_cidr(rfc_list, &quot;10.0.0.0/8&quot;, SWITCH_FALSE);
+        switch_network_list_add_cidr(rfc_list, &quot;172.16.0.0/12&quot;, SWITCH_FALSE);
+        switch_network_list_add_cidr(rfc_list, &quot;192.168.0.0/16&quot;, SWITCH_FALSE);
+        switch_core_hash_insert(IP_LIST.hash, tmp_name, rfc_list);
+
+        tmp_name = &quot;nat.auto&quot;;
+        switch_network_list_create(&amp;rfc_list, tmp_name, SWITCH_FALSE, IP_LIST.pool);
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Created ip list %s default (deny)\n&quot;, tmp_name);
+        if (switch_network_list_add_host_mask(rfc_list, guess_ip, guess_mask, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Adding %s/%s (deny) to list %s\n&quot;, guess_ip, guess_mask, tmp_name);
+        }
+        switch_network_list_add_cidr(rfc_list, &quot;10.0.0.0/8&quot;, SWITCH_TRUE);
+        switch_network_list_add_cidr(rfc_list, &quot;172.16.0.0/12&quot;, SWITCH_TRUE);
+        switch_network_list_add_cidr(rfc_list, &quot;192.168.0.0/16&quot;, SWITCH_TRUE);
+        switch_core_hash_insert(IP_LIST.hash, tmp_name, rfc_list);
+
+        tmp_name = &quot;loopback.auto&quot;;
+        switch_network_list_create(&amp;rfc_list, tmp_name, SWITCH_FALSE, IP_LIST.pool);
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Created ip list %s default (deny)\n&quot;, tmp_name);
+        switch_network_list_add_cidr(rfc_list, &quot;127.0.0.0/8&quot;, SWITCH_TRUE);
+        switch_core_hash_insert(IP_LIST.hash, tmp_name, rfc_list);
+
+        tmp_name = &quot;localnet.auto&quot;;
+        switch_network_list_create(&amp;list, tmp_name, SWITCH_FALSE, IP_LIST.pool);
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Created ip list %s default (deny)\n&quot;, tmp_name);
+
+        if (switch_network_list_add_host_mask(list, guess_ip, guess_mask, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Adding %s/%s (allow) to list %s\n&quot;, guess_ip, guess_mask, tmp_name);
+        }
+        switch_core_hash_insert(IP_LIST.hash, tmp_name, list);
+
+
+        if ((xml = switch_xml_open_cfg(&quot;acl.conf&quot;, &amp;cfg, NULL))) {
+                if ((x_lists = switch_xml_child(cfg, &quot;network-lists&quot;))) {
+                        for (x_list = switch_xml_child(x_lists, &quot;list&quot;); x_list; x_list = x_list-&gt;next) {
+                                const char *name = switch_xml_attr(x_list, &quot;name&quot;);
+                                const char *dft = switch_xml_attr(x_list, &quot;default&quot;);
+                                switch_bool_t default_type = SWITCH_TRUE;
+
+                                if (zstr(name)) {
+                                        continue;
+                                }
+
+                                if (dft) {
+                                        default_type = switch_true(dft);
+                                }
+
+                                if (switch_network_list_create(&amp;list, name, default_type, IP_LIST.pool) != SWITCH_STATUS_SUCCESS) {
+                                        abort();
+                                }
+
+                                if (reload) {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Created ip list %s default (%s)\n&quot;, name, default_type ? &quot;allow&quot; : &quot;deny&quot;);
+                                } else {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Created ip list %s default (%s)\n&quot;, name, default_type ? &quot;allow&quot; : &quot;deny&quot;);
+                                }
+
+
+                                for (x_node = switch_xml_child(x_list, &quot;node&quot;); x_node; x_node = x_node-&gt;next) {
+                                        const char *cidr = NULL, *host = NULL, *mask = NULL, *domain = NULL;
+                                        switch_bool_t ok = default_type;
+                                        const char *type = switch_xml_attr(x_node, &quot;type&quot;);
+
+                                        if (type) {
+                                                ok = switch_true(type);
+                                        }
+
+                                        cidr = switch_xml_attr(x_node, &quot;cidr&quot;);
+                                        host = switch_xml_attr(x_node, &quot;host&quot;);
+                                        mask = switch_xml_attr(x_node, &quot;mask&quot;);
+                                        domain = switch_xml_attr(x_node, &quot;domain&quot;);
+
+                                        if (domain) {
+                                                switch_event_t *my_params = NULL;
+                                                switch_xml_t x_domain, xml_root;
+                                                switch_xml_t gt, gts, ut, uts;
+
+                                                switch_event_create(&amp;my_params, SWITCH_EVENT_GENERAL);
+                                                switch_assert(my_params);
+                                                switch_event_add_header_string(my_params, SWITCH_STACK_BOTTOM, &quot;domain&quot;, domain);
+                                                switch_event_add_header_string(my_params, SWITCH_STACK_BOTTOM, &quot;purpose&quot;, &quot;network-list&quot;);
+
+                                                if (switch_xml_locate_domain(domain, my_params, &amp;xml_root, &amp;x_domain) != SWITCH_STATUS_SUCCESS) {
+                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Cannot locate domain %s\n&quot;, domain);
+                                                        switch_event_destroy(&amp;my_params);
+                                                        continue;
+                                                }
+
+                                                switch_event_destroy(&amp;my_params);
+
+                                                for (ut = switch_xml_child(x_domain, &quot;user&quot;); ut; ut = ut-&gt;next) {
+                                                        const char *user_cidr = switch_xml_attr(ut, &quot;cidr&quot;);
+                                                        const char *id = switch_xml_attr(ut, &quot;id&quot;);
+
+                                                        if (id &amp;&amp; user_cidr) {
+                                                                char *token = switch_mprintf(&quot;%s@%s&quot;, id, domain);
+                                                                switch_assert(token);
+                                                                switch_network_list_add_cidr_token(list, user_cidr, ok, token);
+                                                                free(token);
+                                                        }
+                                                }
+
+                                                for (gts = switch_xml_child(x_domain, &quot;groups&quot;); gts; gts = gts-&gt;next) {
+                                                        for (gt = switch_xml_child(gts, &quot;group&quot;); gt; gt = gt-&gt;next) {
+                                                                for (uts = switch_xml_child(gt, &quot;users&quot;); uts; uts = uts-&gt;next) {
+                                                                        for (ut = switch_xml_child(uts, &quot;user&quot;); ut; ut = ut-&gt;next) {
+                                                                                const char *user_cidr = switch_xml_attr(ut, &quot;cidr&quot;);
+                                                                                const char *id = switch_xml_attr(ut, &quot;id&quot;);
+
+                                                                                if (id &amp;&amp; user_cidr) {
+                                                                                        char *token = switch_mprintf(&quot;%s@%s&quot;, id, domain);
+                                                                                        switch_assert(token);
+                                                                                        switch_network_list_add_cidr_token(list, user_cidr, ok, token);
+                                                                                        free(token);
+                                                                                }
+                                                                        }
+                                                                }
+                                                        }
+                                                }
+
+                                                switch_xml_free(xml_root);
+                                        } else if (cidr) {
+                                                if (switch_network_list_add_cidr(list, cidr, ok) == SWITCH_STATUS_SUCCESS) {
+                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Adding %s (%s) to list %s\n&quot;, cidr, ok ? &quot;allow&quot; : &quot;deny&quot;, name);
+                                                } else {
+                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+                                                                                          &quot;Error Adding %s (%s) to list %s\n&quot;, cidr, ok ? &quot;allow&quot; : &quot;deny&quot;, name);
+                                                }
+                                        } else if (host &amp;&amp; mask) {
+                                                if (switch_network_list_add_host_mask(list, host, mask, ok) == SWITCH_STATUS_SUCCESS) {
+                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
+                                                                                          &quot;Adding %s/%s (%s) to list %s\n&quot;, host, mask, ok ? &quot;allow&quot; : &quot;deny&quot;, name);
+                                                }
+                                        }
+
+                                        switch_core_hash_insert(IP_LIST.hash, name, list);
+                                }
+                        }
+                }
+
+                switch_xml_free(xml);
+        }
+
+        switch_mutex_unlock(runtime.global_mutex);
+}
+
+SWITCH_DECLARE(uint32_t) switch_core_max_dtmf_duration(uint32_t duration)
+{
+        if (duration) {
+                if (duration &gt; SWITCH_MAX_DTMF_DURATION) {
+                        duration = SWITCH_MAX_DTMF_DURATION;
+                }
+                if (duration &lt; SWITCH_MIN_DTMF_DURATION) {
+                        duration = SWITCH_MIN_DTMF_DURATION;
+                }
+                runtime.max_dtmf_duration = duration;
+        }
+        return runtime.max_dtmf_duration;
+}
+
+SWITCH_DECLARE(uint32_t) switch_core_default_dtmf_duration(uint32_t duration)
+{
+        if (duration) {
+                if (duration &lt; SWITCH_MIN_DTMF_DURATION) {
+                        duration = SWITCH_MIN_DTMF_DURATION;
+                }
+                if (duration &gt; SWITCH_MAX_DTMF_DURATION) {
+                        duration = SWITCH_MAX_DTMF_DURATION;
+                }
+                runtime.default_dtmf_duration = duration;
+        }
+        return runtime.default_dtmf_duration;
+}
+
+SWITCH_DECLARE(uint32_t) switch_core_min_dtmf_duration(uint32_t duration)
+{
+        if (duration) {
+                if (duration &lt; SWITCH_MIN_DTMF_DURATION) {
+                        duration = SWITCH_MIN_DTMF_DURATION;
+                }
+                if (duration &gt; SWITCH_MAX_DTMF_DURATION) {
+                        duration = SWITCH_MAX_DTMF_DURATION;
+                }
+        }
+        return runtime.min_dtmf_duration;
+}
+
+static void switch_core_set_serial(void)
+{
+        char buf[13] = &quot;&quot;;
+        char path[256];
+
+        int fd = -1, write_fd = -1;
+        switch_ssize_t bytes = 0;
+
+        switch_snprintf(path, sizeof(path), &quot;%s%sfreeswitch.serial&quot;, SWITCH_GLOBAL_dirs.conf_dir, SWITCH_PATH_SEPARATOR);
+
+
+        if ((fd = open(path, O_RDONLY, 0)) &lt; 0) {
+                char *ip = switch_core_get_variable(&quot;local_ip_v4&quot;);
+                uint32_t ipi = 0;
+                switch_byte_t *byte;
+                int i = 0;
+
+                switch_inet_pton(AF_INET, ip, &amp;ipi);
+                byte = (switch_byte_t *) &amp; ipi;
+
+                for (i = 0; i &lt; 8; i += 2) {
+                        switch_snprintf(buf + i, sizeof(buf) - i, &quot;%0.2x&quot;, *byte);
+                        byte++;
+                }
+
+                switch_stun_random_string(buf + 8, 4, &quot;0123456789abcdef&quot;);
+
+                if ((write_fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) &gt;= 0) {
+                        bytes = write(write_fd, buf, sizeof(buf));
+                        close(write_fd);
+                        write_fd = -1;
+                }
+        } else {
+                bytes = read(fd, buf, sizeof(buf));
+                close(fd);
+                fd = -1;
+        }
+
+        switch_core_set_variable(&quot;switch_serial&quot;, buf);
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switch_bool_t console, const char **err)
+{
+        switch_uuid_t uuid;
+        char guess_ip[256];
+        int mask = 0;
+        struct in_addr in;
+        char hostname[256] = &quot;&quot;;
+
+        if (runtime.runlevel &gt; 0) {
+                /* one per customer */
+                return SWITCH_STATUS_SUCCESS;
+        }
+
+        runtime.runlevel++;
+
+        runtime.dummy_cng_frame.data = runtime.dummy_data;
+        runtime.dummy_cng_frame.datalen = sizeof(runtime.dummy_data);
+        runtime.dummy_cng_frame.buflen = sizeof(runtime.dummy_data);
+        switch_set_flag((&amp;runtime.dummy_cng_frame), SFF_CNG);
+
+        switch_set_flag((&amp;runtime), SCF_NO_NEW_SESSIONS);
+        runtime.hard_log_level = SWITCH_LOG_DEBUG;
+        runtime.mailer_app = &quot;sendmail&quot;;
+        runtime.mailer_app_args = &quot;-t&quot;;
+        runtime.max_dtmf_duration = SWITCH_MAX_DTMF_DURATION;
+        runtime.default_dtmf_duration = SWITCH_DEFAULT_DTMF_DURATION;
+        runtime.min_dtmf_duration = SWITCH_MIN_DTMF_DURATION;
+
+        /* INIT APR and Create the pool context */
+        if (apr_initialize() != SWITCH_STATUS_SUCCESS) {
+                *err = &quot;FATAL ERROR! Could not initialize APR\n&quot;;
+                return SWITCH_STATUS_MEMERR;
+        }
+
+        if (!(runtime.memory_pool = switch_core_memory_init())) {
+                *err = &quot;FATAL ERROR! Could not allocate memory pool\n&quot;;
+                return SWITCH_STATUS_MEMERR;
+        }
+        switch_assert(runtime.memory_pool != NULL);
+
+        switch_dir_make_recursive(SWITCH_GLOBAL_dirs.base_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
+        switch_dir_make_recursive(SWITCH_GLOBAL_dirs.mod_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
+        switch_dir_make_recursive(SWITCH_GLOBAL_dirs.conf_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
+        switch_dir_make_recursive(SWITCH_GLOBAL_dirs.log_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
+        switch_dir_make_recursive(SWITCH_GLOBAL_dirs.run_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
+        switch_dir_make_recursive(SWITCH_GLOBAL_dirs.db_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
+        switch_dir_make_recursive(SWITCH_GLOBAL_dirs.script_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
+        switch_dir_make_recursive(SWITCH_GLOBAL_dirs.htdocs_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
+        switch_dir_make_recursive(SWITCH_GLOBAL_dirs.grammar_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
+        switch_dir_make_recursive(SWITCH_GLOBAL_dirs.recordings_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
+        switch_dir_make_recursive(SWITCH_GLOBAL_dirs.sounds_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
+        switch_dir_make_recursive(SWITCH_GLOBAL_dirs.temp_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
+
+        switch_mutex_init(&amp;runtime.uuid_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool);
+
+        switch_mutex_init(&amp;runtime.throttle_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool);
+        switch_mutex_init(&amp;runtime.session_hash_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool);
+        switch_mutex_init(&amp;runtime.global_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool);
+        switch_mutex_init(&amp;runtime.global_var_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool);
+        switch_core_set_globals();
+        switch_core_session_init(runtime.memory_pool);
+        switch_core_hash_init(&amp;runtime.global_vars, runtime.memory_pool);
+        switch_core_hash_init(&amp;runtime.mime_types, runtime.memory_pool);
+        load_mime_types();
+        runtime.flags = flags;
+        runtime.sps_total = 30;
+
+        *err = NULL;
+
+        if (console) {
+                runtime.console = stdout;
+        }
+
+        gethostname(hostname, sizeof(hostname));
+        switch_core_set_variable(&quot;hostname&quot;, hostname);
+
+        switch_find_local_ip(guess_ip, sizeof(guess_ip), &amp;mask, AF_INET);
+        switch_core_set_variable(&quot;local_ip_v4&quot;, guess_ip);
+        in.s_addr = mask;
+        switch_core_set_variable(&quot;local_mask_v4&quot;, inet_ntoa(in));
+
+
+        switch_find_local_ip(guess_ip, sizeof(guess_ip), NULL, AF_INET6);
+        switch_core_set_variable(&quot;local_ip_v6&quot;, guess_ip);
+        switch_core_set_variable(&quot;base_dir&quot;, SWITCH_GLOBAL_dirs.base_dir);
+        switch_core_set_variable(&quot;recordings_dir&quot;, SWITCH_GLOBAL_dirs.recordings_dir);
+        switch_core_set_variable(&quot;sound_prefix&quot;, SWITCH_GLOBAL_dirs.sounds_dir);
+        switch_core_set_variable(&quot;sounds_dir&quot;, SWITCH_GLOBAL_dirs.sounds_dir);
+        switch_core_set_serial();
+
+        switch_console_init(runtime.memory_pool);
+        switch_event_init(runtime.memory_pool);
+
+        if (switch_xml_init(runtime.memory_pool, err) != SWITCH_STATUS_SUCCESS) {
+                apr_terminate();
+                return SWITCH_STATUS_MEMERR;
+        }
+
+        if (switch_test_flag((&amp;runtime), SCF_USE_AUTO_NAT)) {
+                switch_nat_init(runtime.memory_pool);
+        }
+
+        switch_log_init(runtime.memory_pool, runtime.colorize_console);
+
+        runtime.tipping_point = 5000;
+        runtime.timer_affinity = -1;
+        switch_load_core_config(&quot;switch.conf&quot;);
+
+
+        switch_core_state_machine_init(runtime.memory_pool);
+
+        if (switch_core_sqldb_start(runtime.memory_pool, switch_test_flag((&amp;runtime), SCF_USE_SQL) ? SWITCH_TRUE : SWITCH_FALSE) != SWITCH_STATUS_SUCCESS) {
+                abort();
+        }
+
+        switch_scheduler_task_thread_start();
+
+        switch_rtp_init(runtime.memory_pool);
+
+        runtime.running = 1;
+        runtime.initiated = switch_time_now();
+        
+        switch_scheduler_add_task(switch_epoch_time_now(NULL), heartbeat_callback, &quot;heartbeat&quot;, &quot;core&quot;, 0, NULL, SSHF_NONE | SSHF_NO_DEL);
+
+        switch_uuid_get(&amp;uuid);
+        switch_uuid_format(runtime.uuid_str, &amp;uuid);
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+
+#ifdef SIGQUIT
+static void handle_SIGQUIT(int sig)
+{
+        if (sig);
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Sig Quit!\n&quot;);
+        return;
+}
+#endif
+
+#ifdef SIGPIPE
+static void handle_SIGPIPE(int sig)
+{
+        if (sig);
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Sig Pipe!\n&quot;);
+        return;
+}
+#endif
+
+#ifdef SIGPOLL
+static void handle_SIGPOLL(int sig)
+{
+        if (sig);
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Sig Poll!\n&quot;);
+        return;
+}
+#endif
+
+#ifdef SIGIO
+static void handle_SIGIO(int sig)
+{
+        if (sig);
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Sig I/O!\n&quot;);
+        return;
+}
+#endif
+
+#ifdef TRAP_BUS
+static void handle_SIGBUS(int sig)
+{
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Sig BUS!\n&quot;);
+        return;
+}
+#endif
+
+static void handle_SIGHUP(int sig)
+{
+        if (sig) {
+                switch_event_t *event;
+
+                if (switch_event_create(&amp;event, SWITCH_EVENT_TRAP) == SWITCH_STATUS_SUCCESS) {
+                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Trapped-Signal&quot;, &quot;HUP&quot;);
+                        switch_event_fire(&amp;event);
+                }
+        }
+        return;
+}
+
+
+static void switch_load_core_config(const char *file)
+{
+        switch_xml_t xml = NULL, cfg = NULL;
+
+        if ((xml = switch_xml_open_cfg(file, &amp;cfg, NULL))) {
+                switch_xml_t settings, param;
+
+                if ((settings = switch_xml_child(cfg, &quot;settings&quot;))) {
+                        for (param = switch_xml_child(settings, &quot;param&quot;); param; param = param-&gt;next) {
+                                const char *var = switch_xml_attr_soft(param, &quot;name&quot;);
+                                const char *val = switch_xml_attr_soft(param, &quot;value&quot;);
+
+                                if (!strcasecmp(var, &quot;loglevel&quot;)) {
+                                        int level;
+                                        if (*val &gt; 47 &amp;&amp; *val &lt; 58) {
+                                                level = atoi(val);
+                                        } else {
+                                                level = switch_log_str2level(val);
+                                        }
+
+                                        if (level != SWITCH_LOG_INVALID) {
+                                                switch_core_session_ctl(SCSC_LOGLEVEL, &amp;level);
+                                        }
+#ifdef HAVE_SETRLIMIT
+                                } else if (!strcasecmp(var, &quot;dump-cores&quot;)) {
+                                        struct rlimit rlp;
+                                        memset(&amp;rlp, 0, sizeof(rlp));
+                                        rlp.rlim_cur = RLIM_INFINITY;
+                                        rlp.rlim_max = RLIM_INFINITY;
+                                        setrlimit(RLIMIT_CORE, &amp;rlp);
+#endif
+                                } else if (!strcasecmp(var, &quot;debug-level&quot;)) {
+                                        int tmp = atoi(val);
+                                        if (tmp &gt; -1 &amp;&amp; tmp &lt; 11) {
+                                                switch_core_session_ctl(SCSC_DEBUG_LEVEL, &amp;tmp);
+                                        }
+                                } else if (!strcasecmp(var, &quot;enable-early-hangup&quot;) &amp;&amp; switch_true(val)) {
+                                        switch_set_flag((&amp;runtime), SCF_EARLY_HANGUP);
+                                } else if (!strcasecmp(var, &quot;colorize-console&quot;) &amp;&amp; switch_true(val)) {
+                                        runtime.colorize_console = SWITCH_TRUE;
+                                } else if (!strcasecmp(var, &quot;mailer-app&quot;) &amp;&amp; !zstr(val)) {
+                                        runtime.mailer_app = switch_core_strdup(runtime.memory_pool, val);
+                                } else if (!strcasecmp(var, &quot;mailer-app-args&quot;) &amp;&amp; val) {
+                                        runtime.mailer_app_args = switch_core_strdup(runtime.memory_pool, val);
+                                } else if (!strcasecmp(var, &quot;sessions-per-second&quot;) &amp;&amp; !zstr(val)) {
+                                        switch_core_sessions_per_second(atoi(val));
+                                } else if (!strcasecmp(var, &quot;max-dtmf-duration&quot;) &amp;&amp; !zstr(val)) {
+                                        int tmp = atoi(val);
+                                        if (tmp &gt; 0) {
+                                                switch_core_max_dtmf_duration((uint32_t) tmp);
+                                        }
+                                } else if (!strcasecmp(var, &quot;min-dtmf-duration&quot;) &amp;&amp; !zstr(val)) {
+                                        int tmp = atoi(val);
+                                        if (tmp &gt; 0) {
+                                                switch_core_min_dtmf_duration((uint32_t) tmp);
+                                        }
+                                } else if (!strcasecmp(var, &quot;default-dtmf-duration&quot;) &amp;&amp; !zstr(val)) {
+                                        int tmp = atoi(val);
+                                        if (tmp &gt; 0) {
+                                                switch_core_default_dtmf_duration((uint32_t) tmp);
+                                        }
+                                } else if (!strcasecmp(var, &quot;enable-monotonic-timing&quot;)) {
+                                        switch_time_set_monotonic(switch_true(var));
+                                } else if (!strcasecmp(var, &quot;enable-clock-nanosleep&quot;)) {
+                                        switch_time_set_nanosleep(switch_true(var));
+                                } else if (!strcasecmp(var, &quot;enable-cond-yield&quot;)) {
+                                        switch_time_set_cond_yield(switch_true(var));
+                                } else if (!strcasecmp(var, &quot;enable-timer-matrix&quot;)) {
+                                        switch_time_set_matrix(switch_true(var));
+                                } else if (!strcasecmp(var, &quot;max-sessions&quot;) &amp;&amp; !zstr(val)) {
+                                        switch_core_session_limit(atoi(val));
+                                } else if (!strcasecmp(var, &quot;min-idle-cpu&quot;) &amp;&amp; !zstr(val)) {
+                                        switch_core_min_idle_cpu(atof(val));
+                                } else if (!strcasecmp(var, &quot;tipping-point&quot;) &amp;&amp; !zstr(val)) {
+                                        runtime.tipping_point = atoi(val);
+                                } else if (!strcasecmp(var, &quot;timer-affinity&quot;) &amp;&amp; !zstr(val)) {
+                                        if (!strcasecmp(val, &quot;disabled&quot;)) {
+                                                runtime.timer_affinity = -1;
+                                        } else {
+                                                runtime.timer_affinity = atoi(val);
+                                        }
+                                } else if (!strcasecmp(var, &quot;rtp-start-port&quot;) &amp;&amp; !zstr(val)) {
+                                        switch_rtp_set_start_port((switch_port_t) atoi(val));
+                                } else if (!strcasecmp(var, &quot;rtp-end-port&quot;) &amp;&amp; !zstr(val)) {
+                                        switch_rtp_set_end_port((switch_port_t) atoi(val));
+                                } else if (!strcasecmp(var, &quot;core-db-dsn&quot;) &amp;&amp; !zstr(val)) {
+                                        if (switch_odbc_available()) {
+                                                runtime.odbc_dsn = switch_core_strdup(runtime.memory_pool, val);
+                                                if ((runtime.odbc_user = strchr(runtime.odbc_dsn, ':'))) {
+                                                        *runtime.odbc_user++ = '\0';
+                                                        if ((runtime.odbc_pass = strchr(runtime.odbc_user, ':'))) {
+                                                                *runtime.odbc_pass++ = '\0';
+                                                        }
+                                                }
+                                        } else {
+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;ODBC IS NOT AVAILABLE!\n&quot;);
+                                        }
+#ifdef ENABLE_ZRTP
+                                } else if (!strcasecmp(var, &quot;rtp-enable-zrtp&quot;)) {
+                                        switch_core_set_variable(&quot;zrtp_enabled&quot;, val);
+#endif
+                                }
+                        }
+                }
+
+                if ((settings = switch_xml_child(cfg, &quot;variables&quot;))) {
+                        for (param = switch_xml_child(settings, &quot;variable&quot;); param; param = param-&gt;next) {
+                                const char *var = switch_xml_attr_soft(param, &quot;name&quot;);
+                                const char *val = switch_xml_attr_soft(param, &quot;value&quot;);
+                                if (var &amp;&amp; val) {
+                                        switch_core_set_variable(var, val);
+                                }
+                        }
+                }
+
+                switch_xml_free(xml);
+        }
+
+
+}
+
+SWITCH_DECLARE(const char *) switch_core_banner(void)
+{
+
+
+        return (&quot;\n&quot;
+                        &quot;   _____              ______        _____ _____ ____ _   _  \n&quot;
+                        &quot;  |  ___| __ ___  ___/ ___\\ \\      / /_ _|_   _/ ___| | | | \n&quot;
+                        &quot;  | |_ | '__/ _ \\/ _ \\___ \\\\ \\ /\\ / / | |  | || |   | |_| | \n&quot;
+                        &quot;  |  _|| | |  __/  __/___) |\\ V  V /  | |  | || |___|  _  | \n&quot;
+                        &quot;  |_|  |_|  \\___|\\___|____/  \\_/\\_/  |___| |_| \\____|_| |_| \n&quot;
+                        &quot;\n&quot;
+                        &quot;************************************************************\n&quot;
+                        &quot;* Anthony Minessale II, Michael Jerris, Brian West, Others *\n&quot;
+                        &quot;* FreeSWITCH (http://www.freeswitch.org)                   *\n&quot;
+                        &quot;* Paypal Donations Appreciated: paypal@freeswitch.org      *\n&quot;
+                        &quot;* Brought to you by ClueCon http://www.cluecon.com/        *\n&quot; &quot;************************************************************\n&quot; &quot;\n&quot;);
+}
+
+
+SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t flags, switch_bool_t console, const char **err)
+{
+        switch_event_t *event;
+
+        if (switch_core_init(flags, console, err) != SWITCH_STATUS_SUCCESS) {
+                return SWITCH_STATUS_GENERR;
+        }
+
+        if (runtime.runlevel &gt; 1) {
+                /* one per customer */
+                return SWITCH_STATUS_SUCCESS;
+        }
+
+        runtime.runlevel++;
+
+        /* set signal handlers */
+        signal(SIGINT, SIG_IGN);
+#ifdef SIGPIPE
+        signal(SIGPIPE, handle_SIGPIPE);
+#endif
+#ifdef SIGQUIT
+        signal(SIGQUIT, handle_SIGQUIT);
+#endif
+#ifdef SIGPOLL
+        signal(SIGPOLL, handle_SIGPOLL);
+#endif
+#ifdef SIGIO
+        signal(SIGIO, handle_SIGIO);
+#endif
+#ifdef TRAP_BUS
+        signal(SIGBUS, handle_SIGBUS);
+#endif
+#ifdef SIGUSR1
+        signal(SIGUSR1, handle_SIGHUP);
+#endif
+        signal(SIGHUP, handle_SIGHUP);
+
+
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Bringing up environment.\n&quot;);
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Loading Modules.\n&quot;);
+        if (switch_loadable_module_init() != SWITCH_STATUS_SUCCESS) {
+                *err = &quot;Cannot load modules&quot;;
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Error: %s\n&quot;, *err);
+                return SWITCH_STATUS_GENERR;
+        }
+
+        switch_load_network_lists(SWITCH_FALSE);
+
+        switch_load_core_config(&quot;post_load_switch.conf&quot;);
+
+        if (switch_event_create(&amp;event, SWITCH_EVENT_STARTUP) == SWITCH_STATUS_SUCCESS) {
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Event-Info&quot;, &quot;System Ready&quot;);
+                switch_event_fire(&amp;event);
+        }
+
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;%s&quot;, switch_core_banner());
+
+
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,
+                                          &quot;\nFreeSWITCH Version %s Started.\nMax Sessions[%u]\nSession Rate[%d]\nSQL [%s]\n&quot;, SWITCH_VERSION_FULL,
+                                          switch_core_session_limit(0),
+                                          switch_core_sessions_per_second(0), switch_test_flag((&amp;runtime), SCF_USE_SQL) ? &quot;Enabled&quot; : &quot;Disabled&quot;);
+
+        switch_clear_flag((&amp;runtime), SCF_NO_NEW_SESSIONS);
+
+        return SWITCH_STATUS_SUCCESS;
+
+}
+
+SWITCH_DECLARE(void) switch_core_measure_time(switch_time_t total_ms, switch_core_time_duration_t *duration)
+{
+        switch_time_t temp = total_ms / 1000;
+        memset(duration, 0, sizeof(*duration));
+        duration-&gt;mms = (uint32_t) (total_ms % 1000);
+        duration-&gt;ms = (uint32_t) (temp % 1000);
+        temp = temp / 1000;
+        duration-&gt;sec = (uint32_t) (temp % 60);
+        temp = temp / 60;
+        duration-&gt;min = (uint32_t) (temp % 60);
+        temp = temp / 60;
+        duration-&gt;hr = (uint32_t) (temp % 24);
+        temp = temp / 24;
+        duration-&gt;day = (uint32_t) (temp % 365);
+        duration-&gt;yr = (uint32_t) (temp / 365);
+}
+
+SWITCH_DECLARE(switch_time_t) switch_core_uptime(void)
+{
+        return switch_micro_time_now() - runtime.initiated;
+}
+
+
+#ifdef _MSC_VER
+static void win_shutdown(void)
+{
+
+        HANDLE shutdown_event;
+        char path[512];
+        /* for windows we need the event to signal for shutting down a background FreeSWITCH */
+        snprintf(path, sizeof(path), &quot;Global\\Freeswitch.%d&quot;, getpid());
+
+        /* open the event so we can signal it */
+        shutdown_event = OpenEvent(EVENT_MODIFY_STATE, FALSE, path);
+
+        if (shutdown_event) {
+                /* signal the event to shutdown */
+                SetEvent(shutdown_event);
+                /* cleanup */
+                CloseHandle(shutdown_event);
+        }
+}
+#endif
+
+SWITCH_DECLARE(uint32_t) switch_core_debug_level(void)
+{
+        return runtime.debug_level;
+}
+
+
+SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, void *val)
+{
+        int *intval = (int *) val;
+
+        if (switch_test_flag((&amp;runtime), SCF_SHUTTING_DOWN)) {
+                return -1;
+        }
+
+        switch (cmd) {
+        case SCSC_CALIBRATE_CLOCK:
+                switch_time_calibrate_clock();
+                break;
+        case SCSC_FLUSH_DB_HANDLES:
+                switch_cache_db_flush_handles();
+                break;
+        case SCSC_SEND_SIGHUP:
+                handle_SIGHUP(1);
+                break;
+        case SCSC_SYNC_CLOCK:
+                switch_time_sync();
+                *intval = 0;
+                break;
+        case SCSC_PAUSE_INBOUND:
+                if (*intval) {
+                        switch_set_flag((&amp;runtime), SCF_NO_NEW_SESSIONS);
+                } else {
+                        switch_clear_flag((&amp;runtime), SCF_NO_NEW_SESSIONS);
+                }
+                break;
+        case SCSC_HUPALL:
+                switch_core_session_hupall(SWITCH_CAUSE_MANAGER_REQUEST);
+                break;
+        case SCSC_CANCEL_SHUTDOWN:
+                switch_clear_flag((&amp;runtime), SCF_SHUTDOWN_REQUESTED);
+                break;
+        case SCSC_SAVE_HISTORY:
+                switch_console_save_history();
+                break;
+        case SCSC_CRASH:
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Declinatio Mortuus Obfirmo!\n&quot;);
+                switch_console_save_history();
+                abort();
+                break;
+        case SCSC_SHUTDOWN_NOW:
+                switch_console_save_history();
+                exit(0);
+                break;
+        case SCSC_SHUTDOWN_ELEGANT:
+        case SCSC_SHUTDOWN_ASAP:
+                {
+                        int x = 19;
+                        uint32_t count;
+
+                        switch_set_flag((&amp;runtime), SCF_SHUTDOWN_REQUESTED);
+                        if (cmd == SCSC_SHUTDOWN_ASAP) {
+                                switch_set_flag((&amp;runtime), SCF_NO_NEW_SESSIONS);
+                        }
+
+                        while (runtime.running &amp;&amp; switch_test_flag((&amp;runtime), SCF_SHUTDOWN_REQUESTED) &amp;&amp; (count = switch_core_session_count())) {
+                                switch_yield(500000);
+                                if (++x == 20) {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                          &quot;Shutdown in progress, %u session(s) remain.\nShutting down %s\n&quot;,
+                                                                          count, cmd == SCSC_SHUTDOWN_ASAP ? &quot;ASAP&quot; : &quot;once there are no active calls.&quot;);
+                                        x = 0;
+                                }
+                        }
+
+                        if (switch_test_flag((&amp;runtime), SCF_SHUTDOWN_REQUESTED)) {
+                                switch_set_flag((&amp;runtime), SCF_NO_NEW_SESSIONS);
+#ifdef _MSC_VER
+                                win_shutdown();
+#endif
+
+                                if (*intval) {
+                                        switch_set_flag((&amp;runtime), SCF_RESTART);
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Restarting\n&quot;);
+                                } else {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Shutting down\n&quot;);
+#ifdef _MSC_VER
+                                        fclose(stdin);
+#endif
+                                }
+                                runtime.running = 0;
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Shutdown Cancelled\n&quot;);
+                                switch_clear_flag((&amp;runtime), SCF_NO_NEW_SESSIONS);
+                        }
+                }
+                break;
+        case SCSC_SHUTDOWN:
+
+#ifdef _MSC_VER
+                win_shutdown();
+#endif
+
+                if (*intval) {
+                        switch_set_flag((&amp;runtime), SCF_RESTART);
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Restarting\n&quot;);
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Shutting down\n&quot;);
+#ifdef _MSC_VER
+                        fclose(stdin);
+#endif
+                }
+                runtime.running = 0;
+                break;
+        case SCSC_CHECK_RUNNING:
+                *intval = runtime.running;
+                break;
+        case SCSC_LOGLEVEL:
+                if (*intval &gt; -1) {
+                        runtime.hard_log_level = *intval;
+                }
+
+                if (runtime.hard_log_level &gt; SWITCH_LOG_DEBUG) {
+                        runtime.hard_log_level = SWITCH_LOG_DEBUG;
+                }
+                *intval = runtime.hard_log_level;
+                break;
+        case SCSC_DEBUG_LEVEL:
+                if (*intval &gt; -1) {
+                        if (*intval &gt; 10)
+                                *intval = 10;
+                        runtime.debug_level = *intval;
+                }
+                *intval = runtime.debug_level;
+                break;
+        case SCSC_MIN_IDLE_CPU:
+                {
+                        double *dval = (double *) val;
+                        *dval = switch_core_min_idle_cpu(*dval);
+                }
+                break;
+        case SCSC_MAX_SESSIONS:
+                *intval = switch_core_session_limit(*intval);
+                break;
+        case SCSC_LAST_SPS:
+                *intval = runtime.sps_last;
+                break;
+        case SCSC_MAX_DTMF_DURATION:
+                *intval = switch_core_max_dtmf_duration(*intval);
+                break;
+        case SCSC_MIN_DTMF_DURATION:
+                *intval = switch_core_min_dtmf_duration(*intval);
+                break;
+        case SCSC_DEFAULT_DTMF_DURATION:
+                *intval = switch_core_default_dtmf_duration(*intval);
+                break;
+        case SCSC_SPS:
+                switch_mutex_lock(runtime.throttle_mutex);
+                if (*intval &gt; 0) {
+                        runtime.sps_total = *intval;
+                }
+                *intval = runtime.sps_total;
+                switch_mutex_unlock(runtime.throttle_mutex);
+                break;
+
+        case SCSC_RECLAIM:
+                switch_core_memory_reclaim_all();
+                *intval = 0;
+                break;
+        }
+
+
+        return 0;
+}
+
+SWITCH_DECLARE(switch_core_flag_t) switch_core_flags(void)
+{
+        return runtime.flags;
+}
+
+SWITCH_DECLARE(switch_bool_t) switch_core_ready(void)
+{
+        return (switch_test_flag((&amp;runtime), SCF_SHUTTING_DOWN) || switch_test_flag((&amp;runtime), SCF_NO_NEW_SESSIONS)) ? SWITCH_FALSE : SWITCH_TRUE;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
+{
+        switch_event_t *event;
+
+        if (switch_event_create(&amp;event, SWITCH_EVENT_SHUTDOWN) == SWITCH_STATUS_SUCCESS) {
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Event-Info&quot;, &quot;System Shutting Down&quot;);
+                switch_event_fire(&amp;event);
+        }
+
+        switch_set_flag((&amp;runtime), SCF_NO_NEW_SESSIONS);
+        switch_set_flag((&amp;runtime), SCF_SHUTTING_DOWN);
+
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;End existing sessions\n&quot;);
+        switch_core_session_hupall(SWITCH_CAUSE_SYSTEM_SHUTDOWN);
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Clean up modules.\n&quot;);
+
+        switch_loadable_module_shutdown();
+
+        if (switch_test_flag((&amp;runtime), SCF_USE_SQL)) {
+                switch_core_sqldb_stop();
+        }
+        switch_scheduler_task_thread_stop();
+
+        switch_rtp_shutdown();
+        if (switch_test_flag((&amp;runtime), SCF_USE_AUTO_NAT)) {
+                switch_nat_shutdown();
+        }
+        switch_xml_destroy();
+
+        switch_console_shutdown();
+
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Closing Event Engine.\n&quot;);
+        switch_event_shutdown();
+
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Finalizing Shutdown.\n&quot;);
+        switch_log_shutdown();
+
+        switch_core_unset_variables();
+        switch_core_memory_stop();
+
+        if (runtime.console &amp;&amp; runtime.console != stdout &amp;&amp; runtime.console != stderr) {
+                fclose(runtime.console);
+                runtime.console = NULL;
+        }
+
+        switch_safe_free(SWITCH_GLOBAL_dirs.base_dir);
+        switch_safe_free(SWITCH_GLOBAL_dirs.mod_dir);
+        switch_safe_free(SWITCH_GLOBAL_dirs.conf_dir);
+        switch_safe_free(SWITCH_GLOBAL_dirs.log_dir);
+        switch_safe_free(SWITCH_GLOBAL_dirs.db_dir);
+        switch_safe_free(SWITCH_GLOBAL_dirs.script_dir);
+        switch_safe_free(SWITCH_GLOBAL_dirs.htdocs_dir);
+        switch_safe_free(SWITCH_GLOBAL_dirs.grammar_dir);
+        switch_safe_free(SWITCH_GLOBAL_dirs.recordings_dir);
+        switch_safe_free(SWITCH_GLOBAL_dirs.sounds_dir);
+        switch_safe_free(SWITCH_GLOBAL_dirs.temp_dir);
+
+        switch_core_hash_destroy(&amp;runtime.global_vars);
+        switch_core_hash_destroy(&amp;runtime.mime_types);
+
+        if (runtime.memory_pool) {
+                apr_pool_destroy(runtime.memory_pool);
+                apr_terminate();
+        }
+
+        return switch_test_flag((&amp;runtime), SCF_RESTART) ? SWITCH_STATUS_RESTART : SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *name, const char *proto, const char *from, const char *to,
+                                                                                                          const char *subject, const char *body, const char *type, const char *hint)
+{
+        switch_chat_interface_t *ci;
+        switch_status_t status;
+
+        if (!name || !(ci = switch_loadable_module_get_chat_interface(name)) || !ci-&gt;chat_send) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid Chat Interface [%s]!\n&quot;, name);
+                return SWITCH_STATUS_FALSE;
+        }
+
+        status = ci-&gt;chat_send(proto, from, to, subject, body, type, hint);
+
+        UNPROTECT_INTERFACE(ci);
+
+        return status;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_management_exec(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen)
+{
+        const switch_management_interface_t *ptr;
+        switch_status_t status = SWITCH_STATUS_FALSE;
+
+        if ((ptr = switch_loadable_module_get_management_interface(relative_oid))) {
+                status = ptr-&gt;management_function(relative_oid, action, data, datalen);
+        }
+
+        return status;
+}
+
+SWITCH_DECLARE(void) switch_core_memory_reclaim_all(void)
+{
+        switch_core_memory_reclaim_logger();
+        switch_core_memory_reclaim_events();
+        switch_core_memory_reclaim();
+}
+
+
+struct system_thread_handle {
+        const char *cmd;
+        switch_thread_cond_t *cond;
+        switch_mutex_t *mutex;
+        switch_memory_pool_t *pool;
+        int ret;
+};
+
+static void *SWITCH_THREAD_FUNC system_thread(switch_thread_t *thread, void *obj)
+{
+        struct system_thread_handle *sth = (struct system_thread_handle *) obj;
+
+#if 0                                                        // if we are a luser we can never turn this back down, didn't we already set the stack size?
+#if defined(HAVE_SETRLIMIT) &amp;&amp; !defined(__FreeBSD__)
+        struct rlimit rlim;
+
+        rlim.rlim_cur = SWITCH_SYSTEM_THREAD_STACKSIZE;
+        rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE;
+        if (setrlimit(RLIMIT_STACK, &amp;rlim) &lt; 0) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Setting stack size failed! (%s)\n&quot;, strerror(errno));
+        }
+#endif
+#endif
+
+        sth-&gt;ret = system(sth-&gt;cmd);
+
+#if 0
+#if defined(HAVE_SETRLIMIT) &amp;&amp; !defined(__FreeBSD__)
+        rlim.rlim_cur = SWITCH_THREAD_STACKSIZE;
+        rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE;
+        if (setrlimit(RLIMIT_STACK, &amp;rlim) &lt; 0) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Setting stack size failed! (%s)\n&quot;, strerror(errno));
+        }
+#endif
+#endif
+
+        switch_mutex_lock(sth-&gt;mutex);
+        switch_thread_cond_signal(sth-&gt;cond);
+        switch_mutex_unlock(sth-&gt;mutex);
+
+        switch_core_destroy_memory_pool(&amp;sth-&gt;pool);
+
+        return NULL;
+}
+
+SWITCH_DECLARE(int) switch_system(const char *cmd, switch_bool_t wait)
+{
+        switch_thread_t *thread;
+        switch_threadattr_t *thd_attr;
+        int ret = 0;
+        struct system_thread_handle *sth;
+        switch_memory_pool_t *pool;
+
+        if (switch_core_new_memory_pool(&amp;pool) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Pool Failure\n&quot;);
+                return 1;
+        }
+
+        if (!(sth = switch_core_alloc(pool, sizeof(struct system_thread_handle)))) {
+                switch_core_destroy_memory_pool(&amp;pool);
+                return 1;
+        }
+
+        sth-&gt;pool = pool;
+        sth-&gt;cmd = switch_core_strdup(pool, cmd);
+
+        switch_thread_cond_create(&amp;sth-&gt;cond, sth-&gt;pool);
+        switch_mutex_init(&amp;sth-&gt;mutex, SWITCH_MUTEX_NESTED, sth-&gt;pool);
+        switch_mutex_lock(sth-&gt;mutex);
+
+        switch_threadattr_create(&amp;thd_attr, sth-&gt;pool);
+        switch_threadattr_stacksize_set(thd_attr, SWITCH_SYSTEM_THREAD_STACKSIZE);
+        switch_threadattr_detach_set(thd_attr, 1);
+        switch_thread_create(&amp;thread, thd_attr, system_thread, sth, sth-&gt;pool);
+
+        if (wait) {
+                switch_thread_cond_wait(sth-&gt;cond, sth-&gt;mutex);
+                ret = sth-&gt;ret;
+        }
+        switch_mutex_unlock(sth-&gt;mutex);
+
+        return ret;
+}
+
+
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
+ */
</ins></span></pre></div>
<a id="freeswitchtrunksrcswitch_cppcpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_cpp.cpp (17515 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_cpp.cpp        2010-05-10 17:03:22 UTC (rev 17515)
+++ freeswitch/trunk/src/switch_cpp.cpp        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -52,23 +52,33 @@
</span><span class="cx"> 
</span><span class="cx"> SWITCH_DECLARE_CONSTRUCTOR EventConsumer::EventConsumer(const char *event_name, const char *subclass_name)
</span><span class="cx"> {
</span><del>-        switch_name_event(event_name, &amp;e_event_id);
-        switch_core_new_memory_pool(&amp;pool);
</del><ins>+
+        switch_core_new_memory_pool(&amp;pool);        
+        switch_queue_create(&amp;events, 5000, pool);
</ins><span class="cx">         
</span><del>-        if (!zstr(subclass_name)) {
-                e_subclass_name = switch_core_strdup(pool, subclass_name);
-        } else {
-                e_subclass_name = NULL;
</del><ins>+        if (!zstr(event_name)) {
+                bind(event_name, subclass_name);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        switch_queue_create(&amp;events, 5000, pool);
</del><ins>+}
+
+SWITCH_DECLARE(int) EventConsumer::bind(const char *event_name, const char *subclass_name)
+{
+        switch_event_types_t event_id = SWITCH_EVENT_CUSTOM;
+        switch_name_event(event_name, &amp;event_id);
+
+
+        if (zstr(subclass_name)) {
+                subclass_name = NULL;
+        }
</ins><span class="cx">         
</span><del>-        if (switch_event_bind_removable(__FILE__, e_event_id, e_subclass_name, event_handler, this, &amp;node) == SWITCH_STATUS_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;bound to %s %s\n&quot;, event_name, switch_str_nil(e_subclass_name));
</del><ins>+        if (switch_event_bind(__FILE__, event_id, subclass_name, event_handler, this) == SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;bound to %s %s\n&quot;, event_name, switch_str_nil(subclass_name));
+                return 1;
</ins><span class="cx">         } else {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Cannot bind to %s %s\n&quot;, event_name, switch_str_nil(e_subclass_name));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Cannot bind to %s %s\n&quot;, event_name, switch_str_nil(subclass_name));
+                return 0;
</ins><span class="cx">         }
</span><del>-
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -93,10 +103,9 @@
</span><span class="cx"> 
</span><span class="cx"> SWITCH_DECLARE_CONSTRUCTOR EventConsumer::~EventConsumer()
</span><span class="cx"> {
</span><del>-        if (node) {
-                switch_event_unbind(&amp;node);
-        }
</del><span class="cx"> 
</span><ins>+        switch_event_unbind_callback(event_handler);
+
</ins><span class="cx">         if (events) {
</span><span class="cx">                 switch_queue_interrupt_all(events);
</span><span class="cx">         }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_eventc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_event.c (17515 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_event.c        2010-05-10 17:03:22 UTC (rev 17515)
+++ freeswitch/trunk/src/switch_event.c        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -1198,7 +1198,7 @@
</span><span class="cx">         if (node) {
</span><span class="cx">                 *node = NULL;
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         if (subclass_name) {
</span><span class="cx">                 if (!(subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name))) {
</span><span class="cx">                         switch_event_reserve_subclass_detailed(id, subclass_name);
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_timecorig"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/src/switch_time.c.orig (0 => 17516)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_time.c.orig                                (rev 0)
+++ freeswitch/trunk/src/switch_time.c.orig        2010-05-10 18:07:34 UTC (rev 17516)
</span><span class="lines">@@ -0,0 +1,1962 @@
</span><ins>+/* 
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the &quot;License&quot;); 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 &quot;AS IS&quot; 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 &lt;anthm@freeswitch.org&gt;
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * 
+ * Anthony Minessale II &lt;anthm@freeswitch.org&gt;
+ * Massimo Cetra &lt;devel@navynet.it&gt; - Timezone functionality
+ *
+ *
+ * softtimer.c -- Software Timer Module
+ *
+ */
+
+#include &lt;switch.h&gt;
+#include &lt;stdio.h&gt;
+#include &quot;private/switch_core_pvt.h&quot;
+
+//#if defined(DARWIN)
+#define DISABLE_1MS_COND
+//#endif
+
+#ifndef UINT32_MAX
+#define UINT32_MAX 0xffffffff
+#endif
+
+#define MAX_TICK UINT32_MAX - 1024
+
+#define MAX_ELEMENTS 3600
+#define IDLE_SPEED 100
+
+#if defined(HAVE_CLOCK_GETTIME) &amp;&amp; defined(CLOCK_MONOTONIC)
+static int MONO = 1;
+#else
+static int MONO = 0;
+#endif
+
+#if defined(HAVE_CLOCK_NANOSLEEP)
+static int NANO = 1;
+#else
+static int NANO = 0;
+#endif
+
+
+static int OFFSET = 0;
+
+static int COND = 1;
+
+static int MATRIX = 1;
+
+#define ONEMS
+#ifdef ONEMS
+static int STEP_MS = 1;
+static int STEP_MIC = 1000;
+static uint32_t TICK_PER_SEC = 1000;
+static int MS_PER_TICK = 10;
+#else
+static int STEP_MS = 10;
+static int STEP_MIC = 10000;
+static uint32_t TICK_PER_SEC = 1000;
+static int MS_PER_TICK = 10;
+#endif
+
+static switch_memory_pool_t *module_pool = NULL;
+
+static struct {
+        int32_t RUNNING;
+        int32_t STARTED;
+        int32_t use_cond_yield;
+        switch_mutex_t *mutex;
+        uint32_t timer_count;
+} globals;
+
+#ifdef WIN32
+#undef SWITCH_MOD_DECLARE_DATA
+#define SWITCH_MOD_DECLARE_DATA __declspec(dllexport)
+#endif
+
+SWITCH_MODULE_LOAD_FUNCTION(softtimer_load);
+SWITCH_MODULE_SHUTDOWN_FUNCTION(softtimer_shutdown);
+SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime);
+SWITCH_MODULE_DEFINITION(CORE_SOFTTIMER_MODULE, softtimer_load, softtimer_shutdown, softtimer_runtime);
+
+struct timer_private {
+        switch_size_t reference;
+        switch_size_t start;
+        uint32_t roll;
+        uint32_t ready;
+};
+typedef struct timer_private timer_private_t;
+
+struct timer_matrix {
+        switch_size_t tick;
+        uint32_t count;
+        uint32_t roll;
+        switch_mutex_t *mutex;
+        switch_thread_cond_t *cond;
+        switch_thread_rwlock_t *rwlock;
+};
+typedef struct timer_matrix timer_matrix_t;
+
+static timer_matrix_t TIMER_MATRIX[MAX_ELEMENTS + 1];
+
+static void os_yield(void)
+{
+#if defined(WIN32)
+        SwitchToThread();
+#else
+        sched_yield();
+#endif
+}
+
+static void do_sleep(switch_interval_time_t t)
+{
+#if defined(HAVE_CLOCK_NANOSLEEP) || defined(DARWIN)
+        struct timespec ts;
+#endif
+
+#if defined(WIN32)
+        if (t &lt; 1000) {
+                t = 1000;
+        }
+#endif
+
+#if !defined(DARWIN)
+        if (t &gt; 100000 || !NANO) {
+                apr_sleep(t);
+                return;
+        }
+#endif
+
+#if defined(HAVE_CLOCK_NANOSLEEP)
+        t -= OFFSET;
+        ts.tv_sec = t / 1000000;
+        ts.tv_nsec = ((t % 1000000) * 1000);
+        clock_nanosleep(CLOCK_MONOTONIC, 0, &amp;ts, NULL);
+
+#elif defined(DARWIN)
+        ts.tv_sec = t / APR_USEC_PER_SEC;
+        ts.tv_nsec = (t % APR_USEC_PER_SEC) * 1000;
+        nanosleep(&amp;ts, NULL);
+#else
+        apr_sleep(t);
+#endif
+
+#if defined(DARWIN)
+        sched_yield();
+#endif
+
+}
+
+static switch_interval_time_t average_time(switch_interval_time_t t, int reps)
+{
+        int x = 0;
+        switch_time_t start, stop, sum = 0;
+
+        for (x = 0; x &lt; reps; x++) {
+                start = switch_time_now();
+                do_sleep(t);
+                stop = switch_time_now();
+                sum += (stop - start);
+        }
+
+        return sum / reps;
+
+}
+
+#define calc_step() if (step &gt; 11) step -= 10; else if (step &gt; 1) step--
+SWITCH_DECLARE(void) switch_time_calibrate_clock(void)
+{
+        int x;
+        switch_interval_time_t avg, val = 1000, want = 1000;
+        int over = 0, under = 0, good = 0, step = 50, diff = 0, retry = 0, lastgood = 0, one_k = 0;
+
+#ifdef HAVE_CLOCK_GETRES
+        struct timespec ts;
+        long res = 0;
+        clock_getres(CLOCK_MONOTONIC, &amp;ts);
+        res = ts.tv_nsec / 1000;
+
+
+        if (res &gt; 900 &amp;&amp; res &lt; 1100) {
+                one_k = 1;
+        }
+        
+        if (res &gt; 1500) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                  &quot;Timer resolution of %ld microseconds detected!\n&quot;
+                                                  &quot;Do you have your kernel timer frequency set to lower than 1,000Hz? You may experience audio problems.\n&quot;, ts.tv_nsec / 1000);
+                do_sleep(5000000);
+                switch_time_set_cond_yield(SWITCH_TRUE);
+                return;
+        }
+#endif
+
+  top:
+        val = 1000;
+        step = 50;
+        over = under = good = 0;
+        OFFSET = 0;
+
+        for (x = 0; x &lt; 100; x++) {
+                avg = average_time(val, 50);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Test: %ld Average: %ld Step: %d\n&quot;, (long) val, (long) avg, step);
+
+                diff = abs((int) (want - avg));
+                if (diff &gt; 1500) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                          &quot;Abnormally large timer gap %d detected!\n&quot;
+                                                          &quot;Do you have your kernel timer frequency set to lower than 1,000Hz? You may experience audio problems.\n&quot;, diff);
+                        do_sleep(5000000);
+                        switch_time_set_cond_yield(SWITCH_TRUE);
+                        return;
+                }
+
+                if (diff &lt;= 100) {
+                        lastgood = (int) val;
+                }
+
+                if (diff &lt;= 2) {
+                        under = over = 0;
+                        lastgood = (int) val;
+                        if (++good &gt; 10) {
+                                break;
+                        }
+                } else if (avg &gt; want) {
+                        if (under) {
+                                calc_step();
+                        }
+                        under = good = 0;
+                        if ((val - step) &lt; 0) {
+                                if (++retry &gt; 2)
+                                        break;
+                                goto top;
+                        }
+                        val -= step;
+                        over++;
+                } else if (avg &lt; want) {
+                        if (over) {
+                                calc_step();
+                        }
+                        over = good = 0;
+                        if ((val - step) &lt; 0) {
+                                if (++retry &gt; 2)
+                                        break;
+                                goto top;
+                        }
+                        val += step;
+                        under++;
+                }
+        }
+
+        if (good &gt;= 10) {
+                OFFSET = (int) (want - val);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Timer offset of %d calculated\n&quot;, OFFSET);
+        } else if (lastgood) {
+                OFFSET = (int) (want - lastgood);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Timer offset of %d calculated (fallback)\n&quot;, OFFSET);
+                switch_time_set_cond_yield(SWITCH_TRUE);
+        } else if (one_k) {
+                OFFSET = 900;
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Timer offset CANNOT BE DETECTED, forcing OFFSET to 900\n&quot;);
+                switch_time_set_cond_yield(SWITCH_TRUE);
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Timer offset NOT calculated\n&quot;);
+                switch_time_set_cond_yield(SWITCH_TRUE);
+        }
+}
+
+
+SWITCH_DECLARE(switch_time_t) switch_micro_time_now(void)
+{
+        return (globals.RUNNING == 1 &amp;&amp; runtime.timestamp) ? runtime.timestamp : switch_time_now();
+}
+
+
+SWITCH_DECLARE(time_t) switch_epoch_time_now(time_t *t)
+{
+        time_t now = switch_micro_time_now() / APR_USEC_PER_SEC;
+        if (t) {
+                *t = now;
+        }
+        return now;
+}
+
+SWITCH_DECLARE(void) switch_time_set_monotonic(switch_bool_t enable)
+{
+        MONO = enable ? 1 : 0;
+        switch_time_sync();
+}
+
+
+SWITCH_DECLARE(void) switch_time_set_matrix(switch_bool_t enable)
+{
+        MATRIX = enable ? 1 : 0;
+        switch_time_sync();
+}
+
+SWITCH_DECLARE(void) switch_time_set_nanosleep(switch_bool_t enable)
+{
+#if defined(HAVE_CLOCK_NANOSLEEP)
+        NANO = enable ? 1 : 0;
+#endif
+}
+
+SWITCH_DECLARE(void) switch_time_set_cond_yield(switch_bool_t enable)
+{
+        COND = enable ? 1 : 0;
+        if (COND) {
+                MATRIX = 1;
+        }
+        switch_time_sync();
+}
+
+static switch_time_t time_now(int64_t offset)
+{
+        switch_time_t now;
+
+#if defined(HAVE_CLOCK_GETTIME) &amp;&amp; defined(CLOCK_MONOTONIC)
+        if (MONO) {
+                struct timespec ts;
+                clock_gettime(CLOCK_MONOTONIC, &amp;ts);
+                now = ts.tv_sec * APR_USEC_PER_SEC + (ts.tv_nsec / 1000) + offset;
+        } else {
+#endif
+                now = switch_time_now();
+
+#if defined(HAVE_CLOCK_GETTIME) &amp;&amp; defined(CLOCK_MONOTONIC)
+        }
+#endif
+
+        return now;
+}
+
+SWITCH_DECLARE(void) switch_time_sync(void)
+{
+        runtime.reference = switch_time_now();
+        runtime.offset = runtime.reference - time_now(0);
+        runtime.reference = time_now(runtime.offset);
+}
+
+SWITCH_DECLARE(void) switch_micro_sleep(switch_interval_time_t t)
+{
+        do_sleep(t);
+}
+
+SWITCH_DECLARE(void) switch_sleep(switch_interval_time_t t)
+{
+
+        if (globals.RUNNING != 1 || t &lt; 1000 || t &gt;= 10000) {
+                do_sleep(t);
+                return;
+        }
+#ifndef DISABLE_1MS_COND
+        if (globals.use_cond_yield == 1) {
+                switch_cond_yield(t);
+                return;
+        }
+#endif
+
+        do_sleep(t);
+}
+
+
+SWITCH_DECLARE(void) switch_cond_next(void)
+{
+        if (globals.timer_count &gt;= runtime.tipping_point) {
+                os_yield();
+                return;
+        }
+#ifdef DISABLE_1MS_COND
+        do_sleep(1000);
+#else
+        if (globals.RUNNING != 1 || !runtime.timestamp || globals.use_cond_yield != 1) {
+                do_sleep(1000);
+                return;
+        }
+        switch_mutex_lock(TIMER_MATRIX[1].mutex);
+        switch_thread_cond_wait(TIMER_MATRIX[1].cond, TIMER_MATRIX[1].mutex);
+        switch_mutex_unlock(TIMER_MATRIX[1].mutex);
+#endif
+}
+
+SWITCH_DECLARE(void) switch_cond_yield(switch_interval_time_t t)
+{
+        switch_time_t want;
+        if (!t)
+                return;
+
+        if (globals.RUNNING != 1 || !runtime.timestamp || globals.use_cond_yield != 1) {
+                do_sleep(t);
+                return;
+        }
+        want = runtime.timestamp + t;
+        while (globals.RUNNING == 1 &amp;&amp; globals.use_cond_yield == 1 &amp;&amp; runtime.timestamp &lt; want) {
+                switch_mutex_lock(TIMER_MATRIX[1].mutex);
+                if (runtime.timestamp &lt; want) {
+                        switch_thread_cond_wait(TIMER_MATRIX[1].cond, TIMER_MATRIX[1].mutex);
+                }
+                switch_mutex_unlock(TIMER_MATRIX[1].mutex);
+        }
+
+
+}
+
+static switch_status_t timer_init(switch_timer_t *timer)
+{
+        timer_private_t *private_info;
+        int sanity = 0;
+
+        while (globals.STARTED == 0) {
+                do_sleep(100000);
+                if (++sanity == 300) {
+                        abort();
+                }
+        }
+
+        if (globals.RUNNING != 1 || !globals.mutex || timer-&gt;interval &lt; 1) {
+                return SWITCH_STATUS_FALSE;
+        }
+
+        if ((private_info = switch_core_alloc(timer-&gt;memory_pool, sizeof(*private_info)))) {
+                switch_mutex_lock(globals.mutex);
+                if (!TIMER_MATRIX[timer-&gt;interval].mutex) {
+                        switch_mutex_init(&amp;TIMER_MATRIX[timer-&gt;interval].mutex, SWITCH_MUTEX_NESTED, module_pool);
+                        switch_thread_cond_create(&amp;TIMER_MATRIX[timer-&gt;interval].cond, module_pool);
+                }
+                TIMER_MATRIX[timer-&gt;interval].count++;
+                switch_mutex_unlock(globals.mutex);
+                timer-&gt;private_info = private_info;
+                private_info-&gt;start = private_info-&gt;reference = TIMER_MATRIX[timer-&gt;interval].tick;
+                private_info-&gt;roll = TIMER_MATRIX[timer-&gt;interval].roll;
+                private_info-&gt;ready = 1;
+
+                if (timer-&gt;interval &gt; 0 &amp;&amp; timer-&gt;interval &lt; MS_PER_TICK) {
+                        MS_PER_TICK = timer-&gt;interval;
+                        STEP_MS = 1;
+                        STEP_MIC = 1000;
+                        TICK_PER_SEC = 10000;
+                        switch_time_sync();
+                }
+
+                switch_mutex_lock(globals.mutex);
+                globals.timer_count++;
+                if (globals.timer_count == (runtime.tipping_point + 1)) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Crossed tipping point of %u, shifting into high-gear.\n&quot;, runtime.tipping_point);
+                }
+                switch_mutex_unlock(globals.mutex);
+
+                return SWITCH_STATUS_SUCCESS;
+        }
+
+        return SWITCH_STATUS_MEMERR;
+}
+
+#define check_roll() if (private_info-&gt;roll &lt; TIMER_MATRIX[timer-&gt;interval].roll) {        \
+                private_info-&gt;roll++;                                                                                        \
+                private_info-&gt;reference = private_info-&gt;start = TIMER_MATRIX[timer-&gt;interval].tick;        \
+        }                                                                                                                                        \
+
+
+static switch_status_t timer_step(switch_timer_t *timer)
+{
+        timer_private_t *private_info = timer-&gt;private_info;
+        uint64_t samples;
+
+        if (globals.RUNNING != 1 || private_info-&gt;ready == 0) {
+                return SWITCH_STATUS_FALSE;
+        }
+
+        check_roll();
+        samples = timer-&gt;samples * (private_info-&gt;reference - private_info-&gt;start);
+
+        if (samples &gt; UINT32_MAX) {
+                private_info-&gt;start = private_info-&gt;reference;
+                samples = timer-&gt;samples;
+        }
+
+        timer-&gt;samplecount = (uint32_t) samples;
+        private_info-&gt;reference++;
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t timer_sync(switch_timer_t *timer)
+{
+        timer_private_t *private_info = timer-&gt;private_info;
+
+        if (globals.RUNNING != 1 || private_info-&gt;ready == 0) {
+                return SWITCH_STATUS_FALSE;
+        }
+
+        /* sync the clock */
+        private_info-&gt;reference = timer-&gt;tick = TIMER_MATRIX[timer-&gt;interval].tick;
+
+        /* apply timestamp */
+        if (timer_step(timer) == SWITCH_STATUS_SUCCESS) {
+                /* push the reference into the future to prevent collision */
+                private_info-&gt;reference++;
+        }
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+
+static switch_status_t timer_next(switch_timer_t *timer)
+{
+        timer_private_t *private_info = timer-&gt;private_info;
+
+#ifdef DISABLE_1MS_COND
+        int cond_index = timer-&gt;interval;
+#else
+        int cond_index = 1;
+#endif
+        int delta = (int) (private_info-&gt;reference - TIMER_MATRIX[timer-&gt;interval].tick);
+
+        /* sync up timer if it's not been called for a while otherwise it will return instantly several times until it catches up */
+        if (delta &lt; -1) {
+                private_info-&gt;reference = timer-&gt;tick = TIMER_MATRIX[timer-&gt;interval].tick;
+        }
+        timer_step(timer);
+
+        if (!MATRIX) {
+                do_sleep(1000 * timer-&gt;interval);
+                goto end;
+        }
+
+        while (globals.RUNNING == 1 &amp;&amp; private_info-&gt;ready &amp;&amp; TIMER_MATRIX[timer-&gt;interval].tick &lt; private_info-&gt;reference) {
+                check_roll();
+
+                if (globals.timer_count &gt;= runtime.tipping_point) {
+                        os_yield();
+                        globals.use_cond_yield = 0;
+                } else {
+                        if (globals.use_cond_yield == 1) {
+                                switch_mutex_lock(TIMER_MATRIX[cond_index].mutex);
+                                if (TIMER_MATRIX[timer-&gt;interval].tick &lt; private_info-&gt;reference) {
+                                        switch_thread_cond_wait(TIMER_MATRIX[cond_index].cond, TIMER_MATRIX[cond_index].mutex);
+                                }
+                                switch_mutex_unlock(TIMER_MATRIX[cond_index].mutex);
+                        } else {
+                                do_sleep(1000);
+                        }
+                }
+        }
+
+  end:
+        return globals.RUNNING == 1 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
+}
+
+static switch_status_t timer_check(switch_timer_t *timer, switch_bool_t step)
+{
+        timer_private_t *private_info = timer-&gt;private_info;
+        switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+        if (globals.RUNNING != 1 || !private_info-&gt;ready) {
+                return SWITCH_STATUS_SUCCESS;
+        }
+
+        check_roll();
+
+        timer-&gt;tick = TIMER_MATRIX[timer-&gt;interval].tick;
+
+        if (timer-&gt;tick &lt; private_info-&gt;reference) {
+                timer-&gt;diff = private_info-&gt;reference - timer-&gt;tick;
+        } else {
+                timer-&gt;diff = 0;
+        }
+
+        if (timer-&gt;diff) {
+                status = SWITCH_STATUS_FALSE;
+        } else if (step) {
+                timer_step(timer);
+        }
+
+
+        return status;
+}
+
+static switch_status_t timer_destroy(switch_timer_t *timer)
+{
+        timer_private_t *private_info = timer-&gt;private_info;
+        if (timer-&gt;interval &lt; MAX_ELEMENTS) {
+                switch_mutex_lock(globals.mutex);
+                TIMER_MATRIX[timer-&gt;interval].count--;
+                if (TIMER_MATRIX[timer-&gt;interval].count == 0) {
+                        TIMER_MATRIX[timer-&gt;interval].tick = 0;
+                }
+                switch_mutex_unlock(globals.mutex);
+        }
+        if (private_info) {
+                private_info-&gt;ready = 0;
+        }
+
+        switch_mutex_lock(globals.mutex);
+        if (globals.timer_count) {
+                globals.timer_count--;
+                if (globals.timer_count == (runtime.tipping_point - 1)) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Fell Below tipping point of %u, shifting into low-gear.\n&quot;, runtime.tipping_point);
+                }
+        }
+        switch_mutex_unlock(globals.mutex);
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime)
+{
+        switch_time_t too_late = STEP_MIC * 1000;
+        uint32_t current_ms = 0;
+        uint32_t x, tick = 0;
+        switch_time_t ts = 0, last = 0;
+        int fwd_errs = 0, rev_errs = 0;
+        int profile_tick = 0;
+
+        runtime.profile_timer = switch_new_profile_timer();
+        switch_get_system_idle_time(runtime.profile_timer, &amp;runtime.profile_time);
+
+#ifdef HAVE_CPU_SET_MACROS
+        if (runtime.timer_affinity &gt; -1) {
+                cpu_set_t set;
+                CPU_ZERO(&amp;set);
+                CPU_SET(0, &amp;set);
+                sched_setaffinity(runtime.timer_affinity, sizeof(set), &amp;set);
+        }
+#endif
+
+        switch_time_sync();
+
+        globals.STARTED = globals.RUNNING = 1;
+        switch_mutex_lock(runtime.throttle_mutex);
+        runtime.sps = runtime.sps_total;
+        switch_mutex_unlock(runtime.throttle_mutex);
+
+        if (MONO) {
+                int loops;
+                for (loops = 0; loops &lt; 3; loops++) {
+                        ts = time_now(0);
+                        /* if it returns the same value every time it won't be of much use. */
+                        if (ts == last) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Broken MONOTONIC Clock Detected!, Support Disabled.\n&quot;);
+                                MONO = 0;
+                                NANO = 0;
+                                runtime.reference = switch_time_now();
+                                runtime.initiated = runtime.reference;
+                                break;
+                        }
+                        do_sleep(STEP_MIC);
+                        last = ts;
+                }
+        }
+
+        ts = 0;
+        last = 0;
+        fwd_errs = rev_errs = 0;
+
+#ifndef DISABLE_1MS_COND
+        if (!NANO) {
+                switch_mutex_init(&amp;TIMER_MATRIX[1].mutex, SWITCH_MUTEX_NESTED, module_pool);
+                switch_thread_cond_create(&amp;TIMER_MATRIX[1].cond, module_pool);
+        }
+#endif
+
+
+        switch_time_sync();
+
+        globals.use_cond_yield = COND;
+        globals.RUNNING = 1;
+
+        while (globals.RUNNING == 1) {
+                runtime.reference += STEP_MIC;
+                while ((ts = time_now(runtime.offset)) &lt; runtime.reference) {
+                        if (ts &lt; last) {
+                                if (MONO) {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Virtual Migration Detected! Syncing Clock\n&quot;);
+                                        switch_time_sync();
+                                } else {
+                                        int64_t diff = (int64_t) (ts - last);
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Reverse Clock Skew Detected!\n&quot;);
+                                        runtime.reference = switch_time_now();
+                                        current_ms = 0;
+                                        tick = 0;
+                                        runtime.initiated += diff;
+                                        rev_errs++;
+                                }
+                        } else {
+                                rev_errs = 0;
+                        }
+
+                        if (globals.timer_count &gt;= runtime.tipping_point) {
+                                os_yield();
+                        } else {
+                                do_sleep(1000);
+                        }
+
+                        last = ts;
+                }
+
+                if (ts &gt; (runtime.reference + too_late)) {
+                        if (MONO) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Virtual Migration Detected! Syncing Clock\n&quot;);
+                                switch_time_sync();
+                        } else {
+                                switch_time_t diff = ts - runtime.reference - STEP_MIC;
+#ifndef WIN32
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Forward Clock Skew Detected!\n&quot;);
+#endif
+                                fwd_errs++;
+                                runtime.reference = switch_time_now();
+                                current_ms = 0;
+                                tick = 0;
+                                runtime.initiated += diff;
+                        }
+                } else {
+                        fwd_errs = 0;
+                }
+
+                if (fwd_errs &gt; 9 || rev_errs &gt; 9) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Auto Re-Syncing clock.\n&quot;);
+                        switch_time_sync();
+                        fwd_errs = rev_errs = 0;
+                }
+
+                runtime.timestamp = ts;
+                current_ms += STEP_MS;
+                tick += STEP_MS;
+
+                if (tick &gt;= TICK_PER_SEC) {
+                        if (++profile_tick == 1) {
+                                switch_get_system_idle_time(runtime.profile_timer, &amp;runtime.profile_time);
+                                profile_tick = 0;
+                        }
+                        
+                        if (runtime.sps &lt;= 0) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Over Session Rate of %d!\n&quot;, runtime.sps_total);
+                        }
+                        switch_mutex_lock(runtime.throttle_mutex);
+                        runtime.sps_last = runtime.sps_total - runtime.sps;
+                        runtime.sps = runtime.sps_total;
+                        switch_mutex_unlock(runtime.throttle_mutex);
+                        tick = 0;
+                }
+#ifndef DISABLE_1MS_COND
+                TIMER_MATRIX[1].tick++;
+                if (switch_mutex_trylock(TIMER_MATRIX[1].mutex) == SWITCH_STATUS_SUCCESS) {
+                        switch_thread_cond_broadcast(TIMER_MATRIX[1].cond);
+                        switch_mutex_unlock(TIMER_MATRIX[1].mutex);
+                }
+                if (TIMER_MATRIX[1].tick == MAX_TICK) {
+                        TIMER_MATRIX[1].tick = 0;
+                        TIMER_MATRIX[1].roll++;
+                }
+#endif
+
+
+                if (MATRIX &amp;&amp; (current_ms % MS_PER_TICK) == 0) {
+                        for (x = MS_PER_TICK; x &lt;= MAX_ELEMENTS; x += MS_PER_TICK) {
+                                if ((current_ms % x) == 0) {
+                                        if (TIMER_MATRIX[x].count) {
+                                                TIMER_MATRIX[x].tick++;
+#ifdef DISABLE_1MS_COND
+
+                                                if (TIMER_MATRIX[x].mutex &amp;&amp; switch_mutex_trylock(TIMER_MATRIX[x].mutex) == SWITCH_STATUS_SUCCESS) {
+                                                        switch_thread_cond_broadcast(TIMER_MATRIX[x].cond);
+                                                        switch_mutex_unlock(TIMER_MATRIX[x].mutex);
+                                                }
+#endif
+                                                if (TIMER_MATRIX[x].tick == MAX_TICK) {
+                                                        TIMER_MATRIX[x].tick = 0;
+                                                        TIMER_MATRIX[x].roll++;
+                                                }
+                                        }
+                                }
+                        }
+                }
+
+                if (current_ms == MAX_ELEMENTS) {
+                        current_ms = 0;
+                }
+        }
+
+        globals.use_cond_yield = 0;
+
+        for (x = MS_PER_TICK; x &lt;= MAX_ELEMENTS; x += MS_PER_TICK) {
+                if (TIMER_MATRIX[x].mutex &amp;&amp; switch_mutex_trylock(TIMER_MATRIX[x].mutex) == SWITCH_STATUS_SUCCESS) {
+                        switch_thread_cond_broadcast(TIMER_MATRIX[x].cond);
+                        switch_mutex_unlock(TIMER_MATRIX[x].mutex);
+                }
+        }
+
+
+        switch_mutex_lock(globals.mutex);
+        globals.RUNNING = 0;
+        switch_mutex_unlock(globals.mutex);
+
+        switch_delete_profile_timer(&amp;runtime.profile_timer);
+
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Soft timer thread exiting.\n&quot;);
+
+        return SWITCH_STATUS_TERM;
+}
+
+/* 
+   This converts a struct tm to a switch_time_exp_t
+   We have to use UNIX structures to do our exams
+   and use switch_* functions for the output.
+*/
+
+static void tm2switchtime(struct tm *tm, switch_time_exp_t *xt)
+{
+
+        if (!xt || !tm) {
+                return;
+        }
+        memset(xt, 0, sizeof(xt));
+
+        xt-&gt;tm_sec = tm-&gt;tm_sec;
+        xt-&gt;tm_min = tm-&gt;tm_min;
+        xt-&gt;tm_hour = tm-&gt;tm_hour;
+        xt-&gt;tm_mday = tm-&gt;tm_mday;
+        xt-&gt;tm_mon = tm-&gt;tm_mon;
+        xt-&gt;tm_year = tm-&gt;tm_year;
+        xt-&gt;tm_wday = tm-&gt;tm_wday;
+        xt-&gt;tm_yday = tm-&gt;tm_yday;
+        xt-&gt;tm_isdst = tm-&gt;tm_isdst;
+
+#if defined(HAVE_STRUCT_TM_TM_GMTOFF)
+        xt-&gt;tm_gmtoff = tm-&gt;tm_gmtoff;
+#endif
+
+        return;
+}
+
+/* **************************************************************************
+   LOADING OF THE XML DATA - HASH TABLE &amp; MEMORY POOL MANAGEMENT
+   ************************************************************************** */
+
+typedef struct {
+        switch_memory_pool_t *pool;
+        switch_hash_t *hash;
+} switch_timezones_list_t;
+
+static switch_timezones_list_t TIMEZONES_LIST = { 0 };
+static switch_event_node_t *NODE = NULL;
+
+const char *switch_lookup_timezone(const char *tz_name)
+{
+        char *value = NULL;
+
+        if (tz_name &amp;&amp; (value = switch_core_hash_find(TIMEZONES_LIST.hash, tz_name)) == NULL) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Timezone '%s' not found!\n&quot;, tz_name);
+        }
+
+        return value;
+}
+
+void switch_load_timezones(switch_bool_t reload)
+{
+        switch_xml_t xml = NULL, x_lists = NULL, x_list = NULL, cfg = NULL;
+        unsigned total = 0;
+
+        if (TIMEZONES_LIST.hash) {
+                switch_core_hash_destroy(&amp;TIMEZONES_LIST.hash);
+        }
+
+        if (TIMEZONES_LIST.pool) {
+                switch_core_destroy_memory_pool(&amp;TIMEZONES_LIST.pool);
+        }
+
+        memset(&amp;TIMEZONES_LIST, 0, sizeof(TIMEZONES_LIST));
+        switch_core_new_memory_pool(&amp;TIMEZONES_LIST.pool);
+        switch_core_hash_init(&amp;TIMEZONES_LIST.hash, TIMEZONES_LIST.pool);
+
+        if ((xml = switch_xml_open_cfg(&quot;timezones.conf&quot;, &amp;cfg, NULL))) {
+                if ((x_lists = switch_xml_child(cfg, &quot;timezones&quot;))) {
+                        for (x_list = switch_xml_child(x_lists, &quot;zone&quot;); x_list; x_list = x_list-&gt;next) {
+                                const char *name = switch_xml_attr(x_list, &quot;name&quot;);
+                                const char *value = switch_xml_attr(x_list, &quot;value&quot;);
+
+                                if (zstr(name)) {
+                                        continue;
+                                }
+
+                                if (zstr(value)) {
+                                        continue;
+                                }
+
+                                switch_core_hash_insert(TIMEZONES_LIST.hash, name, switch_core_strdup(TIMEZONES_LIST.pool, value));
+                                total++;
+                        }
+                }
+
+                switch_xml_free(xml);
+        }
+
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Timezone %sloaded %d definitions\n&quot;, reload ? &quot;re&quot; : &quot;&quot;, total);
+}
+
+static void event_handler(switch_event_t *event)
+{
+        switch_mutex_lock(globals.mutex);
+        switch_load_timezones(1);
+        switch_mutex_unlock(globals.mutex);
+}
+
+static void tztime(const time_t *const timep, const char *tzstring, struct tm *const tmp);
+
+SWITCH_DECLARE(switch_status_t) switch_time_exp_tz_name(const char *tz, switch_time_exp_t *tm, switch_time_t thetime)
+{
+        struct tm xtm = { 0 };
+        const char *tz_name = tz;
+        const char *tzdef;
+        time_t timep;
+
+        if (!thetime) {
+                thetime = switch_micro_time_now();
+        }
+
+        timep = (thetime) / (int64_t) (1000000);
+
+        if (!zstr(tz_name)) {
+                tzdef = switch_lookup_timezone(tz_name);
+        } else {
+                /* We set the default timezone to GMT. */
+                tz_name = &quot;GMT&quot;;
+                tzdef = &quot;GMT&quot;;
+        }
+
+        if (tzdef) {                                /* The lookup of the zone may fail. */
+                tztime(&amp;timep, tzdef, &amp;xtm);
+                tm2switchtime(&amp;xtm, tm);
+                return SWITCH_STATUS_SUCCESS;
+        }
+
+        return SWITCH_STATUS_FALSE;
+
+}
+
+SWITCH_DECLARE(switch_status_t) switch_strftime_tz(const char *tz, const char *format, char *date, size_t len, switch_time_t thetime)
+{
+        time_t timep;
+
+        const char *tz_name = tz;
+        const char *tzdef;
+
+        switch_size_t retsize;
+
+        struct tm tm = { 0 };
+        switch_time_exp_t stm;
+
+        if (!thetime) {
+                thetime = switch_micro_time_now();
+        }
+
+        timep = (thetime) / (int64_t) (1000000);
+
+        if (!zstr(tz_name)) {
+                tzdef = switch_lookup_timezone(tz_name);
+        } else {
+                /* We set the default timezone to GMT. */
+                tz_name = &quot;GMT&quot;;
+                tzdef = &quot;GMT&quot;;
+        }
+
+        if (tzdef) {                                /* The lookup of the zone may fail. */
+                tztime(&amp;timep, tzdef, &amp;tm);
+                tm2switchtime(&amp;tm, &amp;stm);
+                switch_strftime_nocheck(date, &amp;retsize, len, zstr(format) ? &quot;%Y-%m-%d %T&quot; : format, &amp;stm);
+                if (!zstr_buf(date)) {
+                        return SWITCH_STATUS_SUCCESS;
+                }
+        }
+        return SWITCH_STATUS_FALSE;
+}
+
+SWITCH_MODULE_LOAD_FUNCTION(softtimer_load)
+{
+        switch_timer_interface_t *timer_interface;
+        module_pool = pool;
+
+#if defined(WIN32)
+        timeBeginPeriod(1);
+#endif
+
+        memset(&amp;globals, 0, sizeof(globals));
+        switch_mutex_init(&amp;globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
+
+        if ((switch_event_bind_removable(modname, SWITCH_EVENT_RELOADXML, NULL, event_handler, NULL, &amp;NODE) != SWITCH_STATUS_SUCCESS)) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn't bind!\n&quot;);
+        }
+        switch_load_timezones(0);
+
+        /* connect my internal structure to the blank pointer passed to me */
+        *module_interface = switch_loadable_module_create_module_interface(pool, modname);
+        timer_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_TIMER_INTERFACE);
+        timer_interface-&gt;interface_name = &quot;soft&quot;;
+        timer_interface-&gt;timer_init = timer_init;
+        timer_interface-&gt;timer_next = timer_next;
+        timer_interface-&gt;timer_step = timer_step;
+        timer_interface-&gt;timer_sync = timer_sync;
+        timer_interface-&gt;timer_check = timer_check;
+        timer_interface-&gt;timer_destroy = timer_destroy;
+
+        if (!switch_test_flag((&amp;runtime), SCF_USE_CLOCK_RT)) {
+                switch_time_set_nanosleep(SWITCH_FALSE);
+        }
+
+        if (switch_test_flag((&amp;runtime), SCF_USE_HEAVY_TIMING)) {
+                switch_time_set_cond_yield(SWITCH_FALSE);
+        }
+
+        if (switch_test_flag((&amp;runtime), SCF_CALIBRATE_CLOCK)) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Calibrating timer, please wait...\n&quot;);
+                switch_time_calibrate_clock();
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Clock calibration disabled.\n&quot;);
+        }
+
+        /* indicate that the module should continue to be loaded */
+        return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_MODULE_SHUTDOWN_FUNCTION(softtimer_shutdown)
+{
+        globals.use_cond_yield = 0;
+
+        if (globals.RUNNING == 1) {
+                switch_mutex_lock(globals.mutex);
+                globals.RUNNING = -1;
+                switch_mutex_unlock(globals.mutex);
+
+                while (globals.RUNNING == -1) {
+                        do_sleep(10000);
+                }
+        }
+#if defined(WIN32)
+        timeEndPeriod(1);
+#endif
+
+        if (TIMEZONES_LIST.hash) {
+                switch_core_hash_destroy(&amp;TIMEZONES_LIST.hash);
+        }
+
+        if (TIMEZONES_LIST.pool) {
+                switch_core_destroy_memory_pool(&amp;TIMEZONES_LIST.pool);
+        }
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+
+
+
+/*
+ *    This file was originally written for NetBSD and is in the public domain, 
+ *    so clarified as of 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
+ *    
+ *    Iw was modified by Massimo Cetra in order to be used with Callweaver and Freeswitch.
+ */
+
+//#define TESTING_IT 1
+
+#include &lt;stdlib.h&gt;
+#include &lt;stdio.h&gt;
+#include &lt;time.h&gt;
+#include &lt;string.h&gt;
+#include &lt;assert.h&gt;
+
+
+#ifdef TESTING_IT
+#include &lt;sys/time.h&gt;
+#endif
+
+
+#ifndef TRUE
+#define TRUE        1
+#endif /* !defined TRUE */
+
+#ifndef FALSE
+#define FALSE        0
+#endif /* !defined FALSE */
+
+
+
+#ifndef TZ_MAX_TIMES
+/*
+** The TZ_MAX_TIMES value below is enough to handle a bit more than a
+** year's worth of solar time (corrected daily to the nearest second) or
+** 138 years of Pacific Presidential Election time
+** (where there are three time zone transitions every fourth year).
+*/
+#define TZ_MAX_TIMES        370
+#endif /* !defined TZ_MAX_TIMES */
+
+#ifndef TZ_MAX_TYPES
+
+#ifndef NOSOLAR
+#define TZ_MAX_TYPES        256                /* Limited by what (unsigned char)'s can hold */
+#endif /* !defined NOSOLAR */
+
+#ifdef NOSOLAR
+/*
+** Must be at least 14 for Europe/Riga as of Jan 12 1995,
+** as noted by Earl Chew &lt;earl@hpato.aus.hp.com&gt;.
+*/
+#define TZ_MAX_TYPES        20                /* Maximum number of local time types */
+#endif /* !defined NOSOLAR */
+
+#endif /* !defined TZ_MAX_TYPES */
+
+#ifndef TZ_MAX_CHARS
+#define TZ_MAX_CHARS        50                /* Maximum number of abbreviation characters */
+                                /* (limited by what unsigned chars can hold) */
+#endif /* !defined TZ_MAX_CHARS */
+
+#ifndef TZ_MAX_LEAPS
+#define TZ_MAX_LEAPS        50                /* Maximum number of leap second corrections */
+#endif /* !defined TZ_MAX_LEAPS */
+
+#ifdef TZNAME_MAX
+#define MY_TZNAME_MAX        TZNAME_MAX
+#endif /* defined TZNAME_MAX */
+
+#ifndef TZNAME_MAX
+#define MY_TZNAME_MAX        255
+#endif /* !defined TZNAME_MAX */
+
+
+#define SECSPERMIN        60
+#define MINSPERHOUR        60
+#define HOURSPERDAY        24
+#define DAYSPERWEEK        7
+#define DAYSPERNYEAR        365
+#define DAYSPERLYEAR        366
+#define SECSPERHOUR        (SECSPERMIN * MINSPERHOUR)
+#define SECSPERDAY        ((long) SECSPERHOUR * HOURSPERDAY)
+#define MONSPERYEAR        12
+
+#define JULIAN_DAY                0                /* Jn - Julian day */
+#define DAY_OF_YEAR                1                /* n - day of year */
+#define MONTH_NTH_DAY_OF_WEEK        2        /* Mm.n.d - month, week, day of week */
+
+#define EPOCH_YEAR        1970
+#define EPOCH_WDAY        TM_THURSDAY
+
+
+#ifndef TZ_MAX_TIMES
+/*
+** The TZ_MAX_TIMES value below is enough to handle a bit more than a
+** year's worth of solar time (corrected daily to the nearest second) or
+** 138 years of Pacific Presidential Election time
+** (where there are three time zone transitions every fourth year).
+*/
+#define TZ_MAX_TIMES        370
+#endif /* !defined TZ_MAX_TIMES */
+
+#ifndef TZDEFRULES
+#define TZDEFRULES        &quot;posixrules&quot;
+#endif /* !defined TZDEFRULES */
+
+/*
+** The DST rules to use if TZ has no rules and we can't load TZDEFRULES.
+** We default to US rules as of 1999-08-17.
+** POSIX 1003.1 section 8.1.1 says that the default DST rules are
+** implementation dependent; for historical reasons, US rules are a
+** common default.
+*/
+#ifndef TZDEFRULESTRING
+#define TZDEFRULESTRING &quot;,M4.1.0,M10.5.0&quot;
+#endif /* !defined TZDEFDST */
+
+/* Unlike &lt;ctype.h&gt;'s isdigit, this also works if c &lt; 0 | c &gt; UCHAR_MAX.  */
+#define is_digit(c) ((unsigned)(c) - '0' &lt;= 9)
+
+#define BIGGEST(a, b)        (((a) &gt; (b)) ? (a) : (b))
+
+#define isleap(y) (((y) % 4) == 0 &amp;&amp; (((y) % 100) != 0 || ((y) % 400) == 0))
+
+
+
+/*
+** INITIALIZE(x)
+*/
+
+#ifndef GNUC_or_lint
+#ifdef lint
+#define GNUC_or_lint
+#endif /* defined lint */
+#ifndef lint
+#ifdef __GNUC__
+#define GNUC_or_lint
+#endif /* defined __GNUC__ */
+#endif /* !defined lint */
+#endif /* !defined GNUC_or_lint */
+#ifdef WIN32
+#define GNUC_or_lint
+#endif
+
+#ifndef INITIALIZE
+#ifdef GNUC_or_lint
+#define INITIALIZE(x)        ((x) = 0)
+#endif /* defined GNUC_or_lint */
+#ifndef GNUC_or_lint
+#define INITIALIZE(x)
+#endif /* !defined GNUC_or_lint */
+#endif /* !defined INITIALIZE */
+
+
+#define TM_SUNDAY        0
+#define TM_MONDAY        1
+#define TM_TUESDAY        2
+#define TM_WEDNESDAY        3
+#define TM_THURSDAY        4
+#define TM_FRIDAY        5
+#define TM_SATURDAY        6
+
+#define TM_JANUARY        0
+#define TM_FEBRUARY        1
+#define TM_MARCH        2
+#define TM_APRIL        3
+#define TM_MAY                4
+#define TM_JUNE                5
+#define TM_JULY                6
+#define TM_AUGUST        7
+#define TM_SEPTEMBER        8
+#define TM_OCTOBER        9
+#define TM_NOVEMBER        10
+#define TM_DECEMBER        11
+
+#define TM_YEAR_BASE        1900
+
+#define EPOCH_YEAR        1970
+#define EPOCH_WDAY        TM_THURSDAY
+
+
+/* **************************************************************************
+            
+   ************************************************************************** */
+
+static const char gmt[] = &quot;GMT&quot;;
+
+#define CHARS_DEF BIGGEST(BIGGEST(TZ_MAX_CHARS + 1, sizeof gmt), (2 * (MY_TZNAME_MAX + 1)))
+
+struct rule {
+        int r_type;                                        /* type of rule--see below */
+        int r_day;                                        /* day number of rule */
+        int r_week;                                        /* week number of rule */
+        int r_mon;                                        /* month number of rule */
+        long r_time;                                /* transition time of rule */
+};
+
+struct ttinfo {                                        /* time type information */
+        long tt_gmtoff;                                /* UTC offset in seconds */
+        int tt_isdst;                                /* used to set tm_isdst */
+        int tt_abbrind;                                /* abbreviation list index */
+        int tt_ttisstd;                                /* TRUE if transition is std time */
+        int tt_ttisgmt;                                /* TRUE if transition is UTC */
+};
+
+struct lsinfo {                                        /* leap second information */
+        time_t ls_trans;                        /* transition time */
+        long ls_corr;                                /* correction to apply */
+};
+
+
+struct state {
+        int leapcnt;
+        int timecnt;
+        int typecnt;
+        int charcnt;
+        time_t ats[TZ_MAX_TIMES];
+        unsigned char types[TZ_MAX_TIMES];
+        struct ttinfo ttis[TZ_MAX_TYPES];
+        char chars[ /* LINTED constant */ CHARS_DEF];
+        struct lsinfo lsis[TZ_MAX_LEAPS];
+};
+
+
+static const int mon_lengths[2][MONSPERYEAR] = {
+        {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
+        {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
+};
+
+static const int year_lengths[2] = {
+        DAYSPERNYEAR, DAYSPERLYEAR
+};
+
+
+/* **************************************************************************
+            
+   ************************************************************************** */
+
+
+/*
+    Given a pointer into a time zone string, scan until a character that is not
+    a valid character in a zone name is found.  Return a pointer to that
+    character.
+*/
+
+static const char *getzname(register const char *strp)
+{
+        register char c;
+
+        while ((c = *strp) != '\0' &amp;&amp; !is_digit(c) &amp;&amp; c != ',' &amp;&amp; c != '-' &amp;&amp; c != '+')
+                ++strp;
+        return strp;
+}
+
+
+/*
+    Given a pointer into a time zone string, extract a number from that string.
+    Check that the number is within a specified range; if it is not, return
+    NULL.
+    Otherwise, return a pointer to the first character not part of the number.
+*/
+
+static const char *getnum(register const char *strp, int *const nump, const int min, const int max)
+{
+        register char c;
+        register int num;
+
+        if (strp == NULL || !is_digit(c = *strp))
+                return NULL;
+        num = 0;
+        do {
+                num = num * 10 + (c - '0');
+                if (num &gt; max)
+                        return NULL;                /* illegal value */
+                c = *++strp;
+        } while (is_digit(c));
+        if (num &lt; min)
+                return NULL;                        /* illegal value */
+        *nump = num;
+        return strp;
+}
+
+/*
+    Given a pointer into a time zone string, extract a number of seconds,
+    in hh[:mm[:ss]] form, from the string.
+    If any error occurs, return NULL.
+    Otherwise, return a pointer to the first character not part of the number
+    of seconds.
+*/
+
+static const char *getsecs(register const char *strp, long *const secsp)
+{
+        int num;
+
+        /*
+         ** `HOURSPERDAY * DAYSPERWEEK - 1' allows quasi-Posix rules like
+         ** &quot;M10.4.6/26&quot;, which does not conform to Posix,
+         ** but which specifies the equivalent of
+         ** ``02:00 on the first Sunday on or after 23 Oct''.
+         */
+        strp = getnum(strp, &amp;num, 0, HOURSPERDAY * DAYSPERWEEK - 1);
+        if (strp == NULL)
+                return NULL;
+        *secsp = num * (long) SECSPERHOUR;
+        if (*strp == ':') {
+                ++strp;
+                strp = getnum(strp, &amp;num, 0, MINSPERHOUR - 1);
+                if (strp == NULL)
+                        return NULL;
+                *secsp += num * SECSPERMIN;
+                if (*strp == ':') {
+                        ++strp;
+                        /* `SECSPERMIN' allows for leap seconds.  */
+                        strp = getnum(strp, &amp;num, 0, SECSPERMIN);
+                        if (strp == NULL)
+                                return NULL;
+                        *secsp += num;
+                }
+        }
+        return strp;
+}
+
+/*
+    Given a pointer into a time zone string, extract an offset, in
+    [+-]hh[:mm[:ss]] form, from the string.
+    If any error occurs, return NULL.
+    Otherwise, return a pointer to the first character not part of the time.
+*/
+
+static const char *getoffset(register const char *strp, long *const offsetp)
+{
+        register int neg = 0;
+
+        if (*strp == '-') {
+                neg = 1;
+                ++strp;
+        } else if (*strp == '+')
+                ++strp;
+        strp = getsecs(strp, offsetp);
+        if (strp == NULL)
+                return NULL;                        /* illegal time */
+        if (neg)
+                *offsetp = -*offsetp;
+        return strp;
+}
+
+/*
+    Given a pointer into a time zone string, extract a rule in the form
+    date[/time].  See POSIX section 8 for the format of &quot;date&quot; and &quot;time&quot;.
+    If a valid rule is not found, return NULL.
+    Otherwise, return a pointer to the first character not part of the rule.
+*/
+
+static const char *getrule(const char *strp, register struct rule *const rulep)
+{
+        if (*strp == 'J') {
+                /*
+                 ** Julian day.
+                 */
+                rulep-&gt;r_type = JULIAN_DAY;
+                ++strp;
+                strp = getnum(strp, &amp;rulep-&gt;r_day, 1, DAYSPERNYEAR);
+        } else if (*strp == 'M') {
+                /*
+                 ** Month, week, day.
+                 */
+                rulep-&gt;r_type = MONTH_NTH_DAY_OF_WEEK;
+                ++strp;
+                strp = getnum(strp, &amp;rulep-&gt;r_mon, 1, MONSPERYEAR);
+                if (strp == NULL)
+                        return NULL;
+                if (*strp++ != '.')
+                        return NULL;
+                strp = getnum(strp, &amp;rulep-&gt;r_week, 1, 5);
+                if (strp == NULL)
+                        return NULL;
+                if (*strp++ != '.')
+                        return NULL;
+                strp = getnum(strp, &amp;rulep-&gt;r_day, 0, DAYSPERWEEK - 1);
+        } else if (is_digit(*strp)) {
+                /*
+                 ** Day of year.
+                 */
+                rulep-&gt;r_type = DAY_OF_YEAR;
+                strp = getnum(strp, &amp;rulep-&gt;r_day, 0, DAYSPERLYEAR - 1);
+        } else
+                return NULL;                        /* invalid format */
+        if (strp == NULL)
+                return NULL;
+        if (*strp == '/') {
+                /*
+                 ** Time specified.
+                 */
+                ++strp;
+                strp = getsecs(strp, &amp;rulep-&gt;r_time);
+        } else
+                rulep-&gt;r_time = 2 * SECSPERHOUR;        /* default = 2:00:00 */
+        return strp;
+}
+
+
+/*
+    Given the Epoch-relative time of January 1, 00:00:00 UTC, in a year, the
+    year, a rule, and the offset from UTC at the time that rule takes effect,
+    calculate the Epoch-relative time that rule takes effect.
+*/
+
+static time_t transtime(const time_t janfirst, const int year, register const struct rule *const rulep, const long offset)
+{
+        register int leapyear;
+        register time_t value;
+        register int i;
+        int d, m1, yy0, yy1, yy2, dow;
+
+        INITIALIZE(value);
+        leapyear = isleap(year);
+        switch (rulep-&gt;r_type) {
+
+        case JULIAN_DAY:
+                /*
+                 ** Jn - Julian day, 1 == January 1, 60 == March 1 even in leap
+                 ** years.
+                 ** In non-leap years, or if the day number is 59 or less, just
+                 ** add SECSPERDAY times the day number-1 to the time of
+                 ** January 1, midnight, to get the day.
+                 */
+                value = janfirst + (rulep-&gt;r_day - 1) * SECSPERDAY;
+                if (leapyear &amp;&amp; rulep-&gt;r_day &gt;= 60)
+                        value += SECSPERDAY;
+                break;
+
+        case DAY_OF_YEAR:
+                /*
+                 ** n - day of year.
+                 ** Just add SECSPERDAY times the day number to the time of
+                 ** January 1, midnight, to get the day.
+                 */
+                value = janfirst + rulep-&gt;r_day * SECSPERDAY;
+                break;
+
+        case MONTH_NTH_DAY_OF_WEEK:
+                /*
+                 ** Mm.n.d - nth &quot;dth day&quot; of month m.
+                 */
+                value = janfirst;
+                for (i = 0; i &lt; rulep-&gt;r_mon - 1; ++i)
+                        value += mon_lengths[leapyear][i] * SECSPERDAY;
+
+                /*
+                 ** Use Zeller's Congruence to get day-of-week of first day of
+                 ** month.
+                 */
+                m1 = (rulep-&gt;r_mon + 9) % 12 + 1;
+                yy0 = (rulep-&gt;r_mon &lt;= 2) ? (year - 1) : year;
+                yy1 = yy0 / 100;
+                yy2 = yy0 % 100;
+                dow = ((26 * m1 - 2) / 10 + 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7;
+                if (dow &lt; 0)
+                        dow += DAYSPERWEEK;
+
+                /*
+                 ** &quot;dow&quot; is the day-of-week of the first day of the month.  Get
+                 ** the day-of-month (zero-origin) of the first &quot;dow&quot; day of the
+                 ** month.
+                 */
+                d = rulep-&gt;r_day - dow;
+                if (d &lt; 0)
+                        d += DAYSPERWEEK;
+                for (i = 1; i &lt; rulep-&gt;r_week; ++i) {
+                        if (d + DAYSPERWEEK &gt;= mon_lengths[leapyear][rulep-&gt;r_mon - 1])
+                                break;
+                        d += DAYSPERWEEK;
+                }
+
+                /*
+                 ** &quot;d&quot; is the day-of-month (zero-origin) of the day we want.
+                 */
+                value += d * SECSPERDAY;
+                break;
+        }
+
+        /*
+         ** &quot;value&quot; is the Epoch-relative time of 00:00:00 UTC on the day in
+         ** question.  To get the Epoch-relative time of the specified local
+         ** time on that day, add the transition time and the current offset
+         ** from UTC.
+         */
+        return value + rulep-&gt;r_time + offset;
+}
+
+
+
+/*
+    Given a POSIX section 8-style TZ string, fill in the rule tables as
+    appropriate.
+*/
+
+static int tzparse(const char *name, register struct state *const sp, const int lastditch)
+{
+        const char *stdname;
+        const char *dstname;
+        size_t stdlen;
+        size_t dstlen;
+        long stdoffset;
+        long dstoffset;
+        register time_t *atp;
+        register unsigned char *typep;
+        register char *cp;
+
+
+        INITIALIZE(dstname);
+        stdname = name;
+
+        if (lastditch) {
+                stdlen = strlen(name);        /* length of standard zone name */
+                name += stdlen;
+                if (stdlen &gt;= sizeof sp-&gt;chars)
+                        stdlen = (sizeof sp-&gt;chars) - 1;
+                stdoffset = 0;
+        } else {
+                name = getzname(name);
+                stdlen = name - stdname;
+                if (stdlen &lt; 3)
+                        return -1;
+                if (*name == '\0')
+                        return -1;
+                name = getoffset(name, &amp;stdoffset);
+                if (name == NULL)
+                        return -1;
+        }
+
+        sp-&gt;leapcnt = 0;                        /* so, we're off a little */
+
+        if (*name != '\0') {
+                dstname = name;
+                name = getzname(name);
+                dstlen = name - dstname;        /* length of DST zone name */
+                if (dstlen &lt; 3)
+                        return -1;
+                if (*name != '\0' &amp;&amp; *name != ',' &amp;&amp; *name != ';') {
+                        name = getoffset(name, &amp;dstoffset);
+                        if (name == NULL)
+                                return -1;
+                } else
+                        dstoffset = stdoffset - SECSPERHOUR;
+
+                /* Go parsing the daylight saving stuff */
+                if (*name == ',' || *name == ';') {
+                        struct rule start;
+                        struct rule end;
+                        register int year;
+                        register time_t janfirst;
+                        time_t starttime;
+                        time_t endtime;
+
+                        ++name;
+                        if ((name = getrule(name, &amp;start)) == NULL)
+                                return -1;
+                        if (*name++ != ',')
+                                return -1;
+                        if ((name = getrule(name, &amp;end)) == NULL)
+                                return -1;
+                        if (*name != '\0')
+                                return -1;
+
+                        sp-&gt;typecnt = 2;        /* standard time and DST */
+
+                        /*
+                         ** Two transitions per year, from EPOCH_YEAR to 2037.
+                         */
+                        sp-&gt;timecnt = 2 * (2037 - EPOCH_YEAR + 1);
+
+                        if (sp-&gt;timecnt &gt; TZ_MAX_TIMES)
+                                return -1;
+
+                        sp-&gt;ttis[0].tt_gmtoff = -dstoffset;
+                        sp-&gt;ttis[0].tt_isdst = 1;
+                        sp-&gt;ttis[0].tt_abbrind = (int) (stdlen + 1);
+                        sp-&gt;ttis[1].tt_gmtoff = -stdoffset;
+                        sp-&gt;ttis[1].tt_isdst = 0;
+                        sp-&gt;ttis[1].tt_abbrind = 0;
+
+                        atp = sp-&gt;ats;
+                        typep = sp-&gt;types;
+                        janfirst = 0;
+
+                        for (year = EPOCH_YEAR; year &lt;= 2037; ++year) {
+                                starttime = transtime(janfirst, year, &amp;start, stdoffset);
+                                endtime = transtime(janfirst, year, &amp;end, dstoffset);
+                                if (starttime &gt; endtime) {
+                                        *atp++ = endtime;
+                                        *typep++ = 1;        /* DST ends */
+                                        *atp++ = starttime;
+                                        *typep++ = 0;        /* DST begins */
+                                } else {
+                                        *atp++ = starttime;
+                                        *typep++ = 0;        /* DST begins */
+                                        *atp++ = endtime;
+                                        *typep++ = 1;        /* DST ends */
+                                }
+
+                                janfirst += year_lengths[isleap(year)] * SECSPERDAY;
+                        }
+
+                } else {
+                        register long theirstdoffset;
+                        register long theirdstoffset;
+                        register long theiroffset;
+                        register int isdst;
+                        register int i;
+                        register int j;
+
+                        if (*name != '\0')
+                                return -1;
+                        /*
+                           Initial values of theirstdoffset and theirdstoffset.
+                         */
+                        theirstdoffset = 0;
+                        for (i = 0; i &lt; sp-&gt;timecnt; ++i) {
+                                j = sp-&gt;types[i];
+                                if (!sp-&gt;ttis[j].tt_isdst) {
+                                        theirstdoffset = -sp-&gt;ttis[j].tt_gmtoff;
+                                        break;
+                                }
+                        }
+                        theirdstoffset = 0;
+                        for (i = 0; i &lt; sp-&gt;timecnt; ++i) {
+                                j = sp-&gt;types[i];
+                                if (sp-&gt;ttis[j].tt_isdst) {
+                                        theirdstoffset = -sp-&gt;ttis[j].tt_gmtoff;
+                                        break;
+                                }
+                        }
+                        /*
+                         ** Initially we're assumed to be in standard time.
+                         */
+                        isdst = FALSE;
+                        theiroffset = theirstdoffset;
+                        /*
+                         ** Now juggle transition times and types
+                         ** tracking offsets as you do.
+                         */
+                        for (i = 0; i &lt; sp-&gt;timecnt; ++i) {
+                                j = sp-&gt;types[i];
+                                sp-&gt;types[i] = (unsigned char) sp-&gt;ttis[j].tt_isdst;
+                                if (sp-&gt;ttis[j].tt_ttisgmt) {
+                                        /* No adjustment to transition time */
+                                } else {
+                                        /*
+                                         ** If summer time is in effect, and the
+                                         ** transition time was not specified as
+                                         ** standard time, add the summer time
+                                         ** offset to the transition time;
+                                         ** otherwise, add the standard time
+                                         ** offset to the transition time.
+                                         */
+                                        /*
+                                         ** Transitions from DST to DDST
+                                         ** will effectively disappear since
+                                         ** POSIX provides for only one DST
+                                         ** offset.
+                                         */
+                                        if (isdst &amp;&amp; !sp-&gt;ttis[j].tt_ttisstd) {
+                                                sp-&gt;ats[i] += dstoffset - theirdstoffset;
+                                        } else {
+                                                sp-&gt;ats[i] += stdoffset - theirstdoffset;
+                                        }
+                                }
+                                theiroffset = -sp-&gt;ttis[j].tt_gmtoff;
+                                if (sp-&gt;ttis[j].tt_isdst)
+                                        theirdstoffset = theiroffset;
+                                else
+                                        theirstdoffset = theiroffset;
+                        }
+                        /*
+                         ** Finally, fill in ttis.
+                         ** ttisstd and ttisgmt need not be handled.
+                         */
+                        sp-&gt;ttis[0].tt_gmtoff = -stdoffset;
+                        sp-&gt;ttis[0].tt_isdst = FALSE;
+                        sp-&gt;ttis[0].tt_abbrind = 0;
+                        sp-&gt;ttis[1].tt_gmtoff = -dstoffset;
+                        sp-&gt;ttis[1].tt_isdst = TRUE;
+                        sp-&gt;ttis[1].tt_abbrind = (int) (stdlen + 1);
+                        sp-&gt;typecnt = 2;
+                }
+        } else {
+                dstlen = 0;
+                sp-&gt;typecnt = 1;                /* only standard time */
+                sp-&gt;timecnt = 0;
+                sp-&gt;ttis[0].tt_gmtoff = -stdoffset;
+                sp-&gt;ttis[0].tt_isdst = 0;
+                sp-&gt;ttis[0].tt_abbrind = 0;
+        }
+
+        sp-&gt;charcnt = (int) (stdlen + 1);
+        if (dstlen != 0)
+                sp-&gt;charcnt += (int) (dstlen + 1);
+        if ((size_t) sp-&gt;charcnt &gt; sizeof sp-&gt;chars)
+                return -1;
+        cp = sp-&gt;chars;
+        (void) strncpy(cp, stdname, stdlen);
+        cp += stdlen;
+        *cp++ = '\0';
+        if (dstlen != 0) {
+                (void) strncpy(cp, dstname, dstlen);
+                *(cp + dstlen) = '\0';
+        }
+        return 0;
+}
+
+/* **************************************************************************
+            
+   ************************************************************************** */
+#if (_MSC_VER &gt;= 1400)                        // VC8+
+#define switch_assert(expr) assert(expr);__analysis_assume( expr )
+#else
+#define switch_assert(expr) assert(expr)
+#endif
+
+static void timesub(const time_t *const timep, const long offset, register const struct state *const sp, register struct tm *const tmp)
+{
+        register const struct lsinfo *lp;
+        register long days;
+        register time_t rem;
+        register int y;
+        register int yleap;
+        register const int *ip;
+        register long corr;
+        register int hit;
+        register int i;
+
+        switch_assert(timep != NULL);
+        switch_assert(sp != NULL);
+        switch_assert(tmp != NULL);
+
+        corr = 0;
+        hit = 0;
+        i = (sp == NULL) ? 0 : sp-&gt;leapcnt;
+
+        while (--i &gt;= 0) {
+                lp = &amp;sp-&gt;lsis[i];
+                if (*timep &gt;= lp-&gt;ls_trans) {
+                        if (*timep == lp-&gt;ls_trans) {
+                                hit = ((i == 0 &amp;&amp; lp-&gt;ls_corr &gt; 0) || (i &gt; 0 &amp;&amp; lp-&gt;ls_corr &gt; sp-&gt;lsis[i - 1].ls_corr));
+                                if (hit)
+                                        while (i &gt; 0 &amp;&amp; sp-&gt;lsis[i].ls_trans == sp-&gt;lsis[i - 1].ls_trans + 1 &amp;&amp; sp-&gt;lsis[i].ls_corr == sp-&gt;lsis[i - 1].ls_corr + 1) {
+                                                ++hit;
+                                                --i;
+                                        }
+                        }
+                        corr = lp-&gt;ls_corr;
+                        break;
+                }
+        }
+        days = (long) (*timep / SECSPERDAY);
+        rem = *timep % SECSPERDAY;
+
+
+#ifdef mc68k
+        /* If this is for CPU bugs workarounds, i would remove this anyway. Who would use it on an old mc68k ? */
+        if (*timep == 0x80000000) {
+                /*
+                 ** A 3B1 muffs the division on the most negative number.
+                 */
+                days = -24855;
+                rem = -11648;
+        }
+#endif
+
+        rem += (offset - corr);
+        while (rem &lt; 0) {
+                rem += SECSPERDAY;
+                --days;
+        }
+        while (rem &gt;= SECSPERDAY) {
+                rem -= SECSPERDAY;
+                ++days;
+        }
+        tmp-&gt;tm_hour = (int) (rem / SECSPERHOUR);
+        rem = rem % SECSPERHOUR;
+        tmp-&gt;tm_min = (int) (rem / SECSPERMIN);
+
+        /*
+         ** A positive leap second requires a special
+         ** representation.  This uses &quot;... ??:59:60&quot; et seq.
+         */
+        tmp-&gt;tm_sec = (int) (rem % SECSPERMIN) + hit;
+        tmp-&gt;tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK);
+
+        if (tmp-&gt;tm_wday &lt; 0)
+                tmp-&gt;tm_wday += DAYSPERWEEK;
+
+        y = EPOCH_YEAR;
+
+#define LEAPS_THRU_END_OF(y)        ((y) / 4 - (y) / 100 + (y) / 400)
+
+        while (days &lt; 0 || days &gt;= (long) year_lengths[yleap = isleap(y)]) {
+                register int newy;
+
+                newy = (int) (y + days / DAYSPERNYEAR);
+                if (days &lt; 0)
+                        --newy;
+                days -= (newy - y) * DAYSPERNYEAR + LEAPS_THRU_END_OF(newy - 1) - LEAPS_THRU_END_OF(y - 1);
+                y = newy;
+        }
+
+        tmp-&gt;tm_year = y - TM_YEAR_BASE;
+        tmp-&gt;tm_yday = (int) days;
+
+        ip = mon_lengths[yleap];
+
+        for (tmp-&gt;tm_mon = 0; days &gt;= (long) ip[tmp-&gt;tm_mon]; ++(tmp-&gt;tm_mon))
+                days = days - (long) ip[tmp-&gt;tm_mon];
+
+        tmp-&gt;tm_mday = (int) (days + 1);
+        tmp-&gt;tm_isdst = 0;
+#if defined(HAVE_STRUCT_TM_TM_GMTOFF)
+        tmp-&gt;tm_gmtoff = offset;
+#endif
+}
+
+/* **************************************************************************
+            
+   ************************************************************************** */
+
+static void tztime(const time_t *const timep, const char *tzstring, struct tm *const tmp)
+{
+        struct state *tzptr, *sp;
+        const time_t t = *timep;
+        register int i;
+        register const struct ttinfo *ttisp;
+
+        if (tzstring == NULL)
+                tzstring = gmt;
+
+        tzptr = (struct state *) malloc(sizeof(struct state));
+        sp = tzptr;
+
+        if (tzptr != NULL) {
+
+                memset(tzptr, 0, sizeof(struct state));
+
+                (void) tzparse(tzstring, tzptr, FALSE);
+
+                if (sp-&gt;timecnt == 0 || t &lt; sp-&gt;ats[0]) {
+                        i = 0;
+                        while (sp-&gt;ttis[i].tt_isdst)
+                                if (++i &gt;= sp-&gt;typecnt) {
+                                        i = 0;
+                                        break;
+                                }
+                } else {
+                        for (i = 1; i &lt; sp-&gt;timecnt; ++i)
+                                if (t &lt; sp-&gt;ats[i])
+                                        break;
+                        i = sp-&gt;types[i - 1];        // DST begin or DST end
+                }
+                ttisp = &amp;sp-&gt;ttis[i];
+
+                /*
+                   To get (wrong) behavior that's compatible with System V Release 2.0
+                   you'd replace the statement below with
+                   t += ttisp-&gt;tt_gmtoff;
+                   timesub(&amp;t, 0L, sp, tmp);
+                 */
+                if (tmp != NULL) {                /* Just a check not to assert */
+                        timesub(&amp;t, ttisp-&gt;tt_gmtoff, sp, tmp);
+                        tmp-&gt;tm_isdst = ttisp-&gt;tt_isdst;
+#if defined(HAVE_STRUCT_TM_TM_ZONE)
+                        tmp-&gt;tm_zone = &amp;sp-&gt;chars[ttisp-&gt;tt_abbrind];
+#endif
+                }
+
+                free(tzptr);
+        }
+
+}
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
+ */
</ins></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>