diff --git a/src/mod/endpoints/mod_h323/Makefile b/src/mod/endpoints/mod_h323/Makefile
index 8cb68189bb..8287b34cad 100644
--- a/src/mod/endpoints/mod_h323/Makefile
+++ b/src/mod/endpoints/mod_h323/Makefile
@@ -1,5 +1,5 @@
BASE=../../../..
-LOCAL_CFLAGS+=-g -ggdb -I/usr/include/ptlib -I/usr/include/openh323 -I. -DPTRACING=1 -D_REENTRANT -fno-exceptions
+LOCAL_CFLAGS+=-g -ggdb -I/usr/local/include/ptlib -I/usr/local/include/openh323 -I. -DPTRACING=1 -D_REENTRANT -fno-exceptions
LOCAL_LDFLAGS= -lopenh323 -lpt -lrt
include $(BASE)/build/modmake.rules
diff --git a/src/mod/endpoints/mod_h323/changes.txt b/src/mod/endpoints/mod_h323/changes.txt
index 0db6dfac07..5bc4c1a03e 100644
--- a/src/mod/endpoints/mod_h323/changes.txt
+++ b/src/mod/endpoints/mod_h323/changes.txt
@@ -1,3 +1,4 @@
+apply changes from mod_h323-patch.diff by Peter Olsson.
some t.38 and lockinng improvements.
replace ptrace with switch_log_printf.
initial t.38 support.
diff --git a/src/mod/endpoints/mod_h323/h323.conf.xml b/src/mod/endpoints/mod_h323/h323.conf.xml
index a176855ef6..df2056767c 100644
--- a/src/mod/endpoints/mod_h323/h323.conf.xml
+++ b/src/mod/endpoints/mod_h323/h323.conf.xml
@@ -4,6 +4,9 @@
+
+
+
@@ -15,7 +18,6 @@
-
diff --git a/src/mod/endpoints/mod_h323/mod_h323.cpp b/src/mod/endpoints/mod_h323/mod_h323.cpp
index 4c194a9cf8..cfd84e93f2 100644
--- a/src/mod/endpoints/mod_h323/mod_h323.cpp
+++ b/src/mod/endpoints/mod_h323/mod_h323.cpp
@@ -1,19 +1,40 @@
-/*
- Version 0.0.50
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005-2010, Anthony Minessale II
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * Anthony Minessale II
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ *
+ * mod_h323.cpp -- H323 endpoint
+ *
+ * Version 0.0.55
*/
#include "mod_h323.h"
-
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, mod_h323_globals.codec_string);
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_context, mod_h323_globals.context);
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, mod_h323_globals.dialplan);
+SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_rtp_timer_name, mod_h323_globals.rtp_timer_name);
-SWITCH_MODULE_LOAD_FUNCTION(mod_h323_load);
-SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_h323_shutdown);
-SWITCH_MODULE_DEFINITION(mod_h323, mod_h323_load, mod_h323_shutdown, NULL);
-
#define CF_NEED_FLUSH (1 << 1)
struct mod_h323_globals mod_h323_globals = { 0 };
@@ -24,19 +45,19 @@ static switch_call_cause_t create_outgoing_channel(switch_core_session_t *sessio
static const char modulename[] = "h323";
static const char* h323_formats[] = {
- "G.711-ALaw-64k", "PCMA",
- "G.711-uLaw-64k", "PCMU",
- "GSM-06.10", "GSM",
- "G.723", "G723",
- "G.729B", "G729b",
- "G.729", "G729",
- "G.729A", "G729a",
- "G.729A/B", "G729ab",
- "G.723.1", "G723.1",
- "G.723.1(5.3k)", "G723.1-5k3",
- "G.723.1A(5.3k)", "G723.1a-5k3",
- "G.723.1A(6.3k)", "G723.1a-6k3",
- 0
+ "G.711-ALaw-64k", "PCMA",
+ "G.711-uLaw-64k", "PCMU",
+ "GSM-06.10", "GSM",
+ "G.723", "G723",
+ "G.729B", "G729b",
+ "G.729", "G729",
+ "G.729A", "G729a",
+ "G.729A/B", "G729ab",
+ "G.723.1", "G723.1",
+ "G.723.1(5.3k)", "G723.1-5k3",
+ "G.723.1A(5.3k)", "G723.1a-5k3",
+ "G.723.1A(6.3k)", "G723.1a-6k3",
+ 0
};
static char encodingName_COR[7] = "t38";
@@ -84,72 +105,92 @@ static switch_status_t on_hangup(switch_core_session_t *session);
static switch_status_t on_destroy(switch_core_session_t *session);
static switch_io_routines_t h323fs_io_routines = {
- /*.outgoing_channel */ create_outgoing_channel,
- /*.read_frame */ FSH323Connection::read_audio_frame,
- /*.write_frame */ FSH323Connection::write_audio_frame,
- /*.kill_channel */ FSH323Connection::kill_channel,
- /*.send_dtmf */ FSH323Connection::send_dtmf,
- /*.receive_message */ FSH323Connection::receive_message,
- /*.receive_event */ FSH323Connection::receive_event,
- /*.state_change */ FSH323Connection::state_change,
- /*.read_video_frame */ FSH323Connection::read_video_frame,
- /*.write_video_frame */ FSH323Connection::write_video_frame
+ /*.outgoing_channel */ create_outgoing_channel,
+ /*.read_frame */ FSH323Connection::read_audio_frame,
+ /*.write_frame */ FSH323Connection::write_audio_frame,
+ /*.kill_channel */ FSH323Connection::kill_channel,
+ /*.send_dtmf */ FSH323Connection::send_dtmf,
+ /*.receive_message */ FSH323Connection::receive_message,
+ /*.receive_event */ FSH323Connection::receive_event,
+ /*.state_change */ FSH323Connection::state_change,
+ /*.read_video_frame */ FSH323Connection::read_video_frame,
+ /*.write_video_frame */ FSH323Connection::write_video_frame
};
static switch_state_handler_table_t h323fs_event_handlers = {
- /*.on_init */ FSH323Connection::on_init,
- /*.on_routing */ FSH323Connection::on_routing,
- /*.on_execute */ FSH323Connection::on_execute,
- /*.on_hangup */ on_hangup,
- /*.on_exchange_media */ FSH323Connection::on_exchange_media,
- /*.on_soft_execute */ FSH323Connection::on_soft_execute,
- /*.on_consume_media*/ NULL,
- /*.on_hibernate*/ NULL,
- /*.on_reset*/ NULL,
- /*.on_park*/ NULL,
- /*.on_reporting*/ NULL,
- /*.on_destroy*/ on_destroy
+ /*.on_init */ FSH323Connection::on_init,
+ /*.on_routing */ FSH323Connection::on_routing,
+ /*.on_execute */ FSH323Connection::on_execute,
+ /*.on_hangup */ on_hangup,
+ /*.on_exchange_media */ FSH323Connection::on_exchange_media,
+ /*.on_soft_execute */ FSH323Connection::on_soft_execute,
+ /*.on_consume_media*/ NULL,
+ /*.on_hibernate*/ NULL,
+ /*.on_reset*/ NULL,
+ /*.on_park*/ NULL,
+ /*.on_reporting*/ NULL,
+ /*.on_destroy*/ on_destroy
};
-//static FSProcess *h323_process = NULL;
-SWITCH_MODULE_LOAD_FUNCTION(mod_h323_load){
+SWITCH_BEGIN_EXTERN_C
+/*******************************************************************************/
+
+static switch_memory_pool_t *module_pool = NULL;
+
+SWITCH_MODULE_LOAD_FUNCTION(mod_h323_load);
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_h323_shutdown);
+SWITCH_MODULE_DEFINITION(mod_h323, mod_h323_load, mod_h323_shutdown, NULL);
+
+SWITCH_MODULE_LOAD_FUNCTION(mod_h323_load)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Starting loading mod_h323\n");
- *module_interface = switch_loadable_module_create_module_interface(pool, modname);
-
- if (!*module_interface) {
- return SWITCH_STATUS_MEMERR;
- }
- h323_process = new FSProcess();
- if (h323_process == NULL) {
- return SWITCH_STATUS_MEMERR;
- }
+ *module_interface = switch_loadable_module_create_module_interface(pool, modname);
- if (h323_process->Initialise(*module_interface)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "H323 mod initialized and running\n");
- return SWITCH_STATUS_SUCCESS;
- }
+ if (!*module_interface) {
+ return SWITCH_STATUS_MEMERR;
+ }
- delete h323_process;
- h323_process = NULL;
- return SWITCH_STATUS_FALSE;
+ module_pool = pool;
+
+ h323_process = new FSProcess();
+
+ if (h323_process == NULL) {
+ return SWITCH_STATUS_MEMERR;
+ }
+
+ if (h323_process->Initialise(*module_interface)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "H323 mod initialized and running\n");
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ delete h323_process;
+ h323_process = NULL;
+
+ return SWITCH_STATUS_FALSE;
}
-SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_h323_shutdown){
-
- switch_safe_free(mod_h323_globals.context);
- switch_safe_free(mod_h323_globals.dialplan);
- switch_safe_free(mod_h323_globals.codec_string);
- delete h323_process;
- h323_process = NULL;
- return SWITCH_STATUS_SUCCESS;
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_h323_shutdown)
+{
+ switch_safe_free(mod_h323_globals.context);
+ switch_safe_free(mod_h323_globals.dialplan);
+ switch_safe_free(mod_h323_globals.codec_string);
+
+ delete h323_process;
+ h323_process = NULL;
+
+ return SWITCH_STATUS_SUCCESS;
}
-void h_timer(unsigned sec){
+SWITCH_END_EXTERN_C
+/*******************************************************************************/
+
+void h_timer(unsigned sec)
+{
timeval timeout;
timeout.tv_sec = sec;
timeout.tv_usec = 0;
- select(NULL, NULL, NULL, NULL, &timeout);
+ select(0, NULL, NULL, NULL, &timeout);
}
@@ -265,8 +306,8 @@ class FSTrace : public ostream {
#endif
-PString GetH245CodecName(const H323Capability* cap){
-
+PString GetH245CodecName(const H323Capability* cap)
+{
switch (cap->GetSubType()) {
case H245_AudioCapability::e_g711Alaw64k:
case H245_AudioCapability::e_g711Alaw56k:
@@ -297,43 +338,48 @@ PString GetH245CodecName(const H323Capability* cap){
}
FSProcess::FSProcess()
- : PLibraryProcess("Test", "mod_h323", 1, 0, AlphaCode, 1)
- , m_h323endpoint(NULL){
-
+ : PProcess("FreeSWITCH", "mod_h323", 1, 0, AlphaCode, 1)
+ , m_h323endpoint(NULL)
+{
PTrace::SetLevel(4);
- PTrace::SetOptions(PTrace::TraceLevel);
- PTrace::SetStream(new FSTrace);
+ PTrace::SetOptions(PTrace::TraceLevel);
+ PTrace::SetStream(new FSTrace);
}
-FSProcess::~FSProcess(){
- delete m_h323endpoint;
+FSProcess::~FSProcess()
+{
+ delete m_h323endpoint;
}
-bool FSProcess::Initialise(switch_loadable_module_interface_t *iface){
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "======>FSProcess::Initialise [%p]\n", this);
+bool FSProcess::Initialise(switch_loadable_module_interface_t *iface)
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "======>FSProcess::Initialise [%p]\n", this);
- m_h323endpoint = new FSH323EndPoint();
- return m_h323endpoint != NULL && m_h323endpoint->Initialise(iface);
+ m_h323endpoint = new FSH323EndPoint();
+ return m_h323endpoint != NULL && m_h323endpoint->Initialise(iface);
}
-bool FSH323EndPoint::Initialise(switch_loadable_module_interface_t *iface){
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSManager::Initialise [%p]\n",this);
- ReadConfig(false);
+bool FSH323EndPoint::Initialise(switch_loadable_module_interface_t *iface)
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSManager::Initialise [%p]\n", this);
+ ReadConfig(false);
+ /* Update tracing level for h323 */
+ PTrace::SetLevel(mod_h323_globals.trace_level);
+ PTrace::SetOptions(PTrace::TraceLevel);
-
- m_freeswitch = (switch_endpoint_interface_t *) switch_loadable_module_create_interface(iface, SWITCH_ENDPOINT_INTERFACE);
- m_freeswitch->interface_name = modulename;
- m_freeswitch->io_routines = &h323fs_io_routines;
- m_freeswitch->state_handler = &h323fs_event_handlers;
+ m_freeswitch = (switch_endpoint_interface_t *) switch_loadable_module_create_interface(iface, SWITCH_ENDPOINT_INTERFACE);
+ m_freeswitch->interface_name = modulename;
+ m_freeswitch->io_routines = &h323fs_io_routines;
+ m_freeswitch->state_handler = &h323fs_event_handlers;
PString codec = ((const char *)mod_h323_globals.codec_string);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Config capabilliti %s \n",(const char *)codec);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Config capability %s \n", (const char *)codec);
if (!codec.IsEmpty()) {
const char** f = h323_formats;
for (; *f; f += 2) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Find capabilliti %s to %s\n",f[1],(const char *)codec);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Find capability %s to %s\n",f[1], (const char *)codec);
if (codec.Find(f[1]) != P_MAX_INDEX) {
PString tmp = f[0];
tmp += "*{sw}";
@@ -356,96 +402,110 @@ bool FSH323EndPoint::Initialise(switch_loadable_module_interface_t *iface){
}
}
}
- if (m_fax_old_asn){
+
+ if (m_fax_old_asn) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "--->fax_old_asn\n");
SetT38_IFP_PRE();
SetCapability(0, 0, new FSH323_T38Capability(OpalT38_IFP_PRE));
- }else{
+ } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "--->fax_asn\n");
SetCapability(0, 0, new FSH323_T38Capability(OpalT38_IFP_COR));
}
- AddAllUserInputCapabilities(0,1);
+ AddAllUserInputCapabilities(0, 1);
- DisableFastStart(!m_faststart);
- DisableH245Tunneling(!m_h245tunneling);
- DisableH245inSetup(!m_h245insetup);
- DisableDetectInBandDTMF(!m_dtmfinband);
- SetLocalUserName(m_endpointname);
+ DisableFastStart(!m_faststart);
+ DisableH245Tunneling(!m_h245tunneling);
+ DisableH245inSetup(!m_h245insetup);
+ DisableDetectInBandDTMF(!m_dtmfinband);
+ if (!m_endpointname.IsEmpty())
+ SetLocalUserName(m_endpointname);
- if (m_listeners.empty()) {
- StartListener("");
- } else {
- for (std::list < FSListener >::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) {
- if (!StartListener(it->listenAddress)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cannot start listener for %s\n", (const char*)(it->name));
- }
- }
- }
+ if (m_listeners.empty()) {
+ StartListener("");
+ } else {
+ for (std::list < FSListener >::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) {
+ if (!StartListener(it->listenAddress)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cannot start listener for %s\n", (const char*)(it->name));
+ }
+ }
+ }
- if (!m_gkAddress.IsEmpty() && !m_gkIdentifer.IsEmpty() && !m_gkInterface.IsEmpty()) {
+ if (!m_gkAddress.IsEmpty() && !m_gkIdentifer.IsEmpty() && !m_gkInterface.IsEmpty()) {
m_thread = new FSGkRegThread(this,&m_gkAddress,&m_gkIdentifer,&m_gkInterface,m_gkretry);
m_thread->SetAutoDelete();
m_thread->Resume();
- }
+ }
- return TRUE;
+ return TRUE;
}
-switch_status_t FSH323EndPoint::ReadConfig(int reload){
+switch_status_t FSH323EndPoint::ReadConfig(int reload)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::ReadConfig [%p]\n",this);
- const char *cf = "h323.conf";
- switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+ const char *cf = "h323.conf";
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_memory_pool_t *pool = NULL;
- if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
- return status;
- }
+
+ if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+ return status;
+ }
- set_global_context("default");
- set_global_dialplan("XML");
+ set_global_context("default");
+ set_global_dialplan("XML");
- switch_event_t *params = NULL;
- switch_event_create(¶ms, SWITCH_EVENT_REQUEST_PARAMS);
- switch_assert(params);
- switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "profile", switch_str_nil(""));
- switch_xml_t cfg;
- switch_xml_t xml = switch_xml_open_cfg(cf, &cfg, params);
- if (xml == NULL) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
- return SWITCH_STATUS_FALSE;
- }
+ switch_event_t *params = NULL;
+ switch_event_create(¶ms, SWITCH_EVENT_REQUEST_PARAMS);
+ switch_assert(params);
+ switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "profile", switch_str_nil(""));
+ switch_xml_t cfg;
+ switch_xml_t xml = switch_xml_open_cfg(cf, &cfg, params);
- switch_xml_t xmlSettings = switch_xml_child(cfg, "settings");
+ if (xml == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
+ return SWITCH_STATUS_FALSE;
+ }
+
+ switch_xml_t xmlSettings = switch_xml_child(cfg, "settings");
m_pi = 8;
m_ai = 0;
m_endpointname = "FreeSwitch";
- if (xmlSettings) {
- for (switch_xml_t xmlParam = switch_xml_child(xmlSettings, "param"); xmlParam != NULL; xmlParam = xmlParam->next) {
- const char *var = switch_xml_attr_soft(xmlParam, "name");
- const char *val = switch_xml_attr_soft(xmlParam, "value");
+ mod_h323_globals.ptime_override_value = -1;
- if (!strcasecmp(var, "trace-level")) {
- int level = atoi(val);
- if (level > 0) {
- mod_h323_globals.trace_level = level;
- }
- } else if (!strcasecmp(var, "context")) {
- set_global_context(val);
- } else if (!strcasecmp(var, "dialplan")) {
- set_global_dialplan(val);
- } else if (!strcasecmp(var, "codec-prefs")) {
- set_global_codec_string(val);
- } else if (!strcasecmp(var, "jitter-size")) {
- char * next;
- unsigned minJitter = strtoul(val, &next, 10);
- if (minJitter >= 10) {
- unsigned maxJitter = minJitter;
- if (*next == ',')
- maxJitter = atoi(next+1);
- SetAudioJitterDelay(minJitter, maxJitter); // In milliseconds
- } else{
+ if (xmlSettings) {
+ for (switch_xml_t xmlParam = switch_xml_child(xmlSettings, "param"); xmlParam != NULL; xmlParam = xmlParam->next) {
+ const char *var = switch_xml_attr_soft(xmlParam, "name");
+ const char *val = switch_xml_attr_soft(xmlParam, "value");
+
+ if (!strcasecmp(var, "trace-level")) {
+ int level = atoi(val);
+ if (level > 0) {
+ mod_h323_globals.trace_level = level;
+ }
+ } else if (!strcasecmp(var, "context")) {
+ set_global_context(val);
+ } else if (!strcasecmp(var, "dialplan")) {
+ set_global_dialplan(val);
+ } else if (!strcasecmp(var, "codec-prefs")) {
+ set_global_codec_string(val);
+ } else if (!strcasecmp(var, "use-rtp-timer")) {
+ mod_h323_globals.use_rtp_timer = switch_true(val);
+ } else if (!strcasecmp(var, "rtp-timer-name")) {
+ set_global_rtp_timer_name(val);
+ } else if (!strcasecmp(var, "ptime-override-value")) {
+ mod_h323_globals.ptime_override_value = atoi(val);
+ } else if (!strcasecmp(var, "jitter-size")) {
+ char * next;
+ unsigned minJitter = strtoul(val, &next, 10);
+ if (minJitter >= 10) {
+ unsigned maxJitter = minJitter;
+ if (*next == ',')
+ maxJitter = atoi(next+1);
+ SetAudioJitterDelay(minJitter, maxJitter); // In milliseconds
+ } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set zero Jitter buffer\n");
SetAudioJitterDelay(0, 0);
}
@@ -457,15 +517,15 @@ switch_status_t FSH323EndPoint::ReadConfig(int reload){
m_h245insetup = switch_true(val);
} else if (!strcasecmp(var, "dtmfinband")) {
m_dtmfinband = switch_true(val);
- } else if (!strcasecmp(var, "gk-address")) {
- m_gkAddress = val;
- } else if (!strcasecmp(var, "gk-identifer")) {
- m_gkIdentifer = val;
- } else if (!strcasecmp(var, "endpoint-name")) {
- m_endpointname = val;
- } else if (!strcasecmp(var, "gk-interface")) {
- m_gkInterface = val;
- } else if (!strcasecmp(var, "gk-prefix")) {
+ } else if (!strcasecmp(var, "gk-address")) {
+ m_gkAddress = val;
+ } else if (!strcasecmp(var, "gk-identifer")) {
+ m_gkIdentifer = val;
+ } else if (!strcasecmp(var, "endpoint-name")) {
+ m_endpointname = val;
+ } else if (!strcasecmp(var, "gk-interface")) {
+ m_gkInterface = val;
+ } else if (!strcasecmp(var, "gk-prefix")) {
m_gkPrefixes.AppendString(val);
} else if (!strcasecmp(var, "gk-retry")) {
m_gkretry = atoi(val);
@@ -476,44 +536,47 @@ switch_status_t FSH323EndPoint::ReadConfig(int reload){
} else if (!strcasecmp(var, "fax-old-asn")) {
m_fax_old_asn = switch_true(val);
}
- }
- }
+ }
+ }
- switch_xml_t xmlListeners = switch_xml_child(cfg, "listeners");
- if (xmlListeners != NULL) {
- for (switch_xml_t xmlListener = switch_xml_child(xmlListeners, "listener"); xmlListener != NULL; xmlListener = xmlListener->next) {
+ switch_xml_t xmlListeners = switch_xml_child(cfg, "listeners");
+ if (xmlListeners != NULL) {
+ for (switch_xml_t xmlListener = switch_xml_child(xmlListeners, "listener"); xmlListener != NULL; xmlListener = xmlListener->next) {
- m_listeners.push_back(FSListener());
- FSListener & listener = m_listeners.back();
+ m_listeners.push_back(FSListener());
+ FSListener & listener = m_listeners.back();
- listener.name = switch_xml_attr_soft(xmlListener, "name");
- if (listener.name.IsEmpty())
- listener.name = "unnamed";
+ listener.name = switch_xml_attr_soft(xmlListener, "name");
+ if (listener.name.IsEmpty())
+ listener.name = "unnamed";
- PIPSocket::Address ip;
- WORD port = 1720;
+ PIPSocket::Address ip;
+ WORD port = 1720;
- for (switch_xml_t xmlParam = switch_xml_child(xmlListener, "param"); xmlParam != NULL; xmlParam = xmlParam->next) {
- const char *var = switch_xml_attr_soft(xmlParam, "name");
- const char *val = switch_xml_attr_soft(xmlParam, "value");
+ for (switch_xml_t xmlParam = switch_xml_child(xmlListener, "param"); xmlParam != NULL; xmlParam = xmlParam->next) {
+ const char *var = switch_xml_attr_soft(xmlParam, "name");
+ const char *val = switch_xml_attr_soft(xmlParam, "value");
- if (!strcasecmp(var, "h323-ip"))
- ip = val;
- else if (!strcasecmp(var, "h323-port"))
- port = (WORD) atoi(val);
- }
+ if (!strcasecmp(var, "h323-ip"))
+ ip = val;
+ else if (!strcasecmp(var, "h323-port"))
+ port = (WORD) atoi(val);
+ }
- listener.listenAddress = new H323ListenerTCP(*this,ip,port);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created Listener '%s'\n", (const char *) listener.name);
- }
- }
+ listener.listenAddress = new H323ListenerTCP(*this, ip, port);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created Listener '%s'\n", (const char *) listener.name);
+ }
+ }
- switch_event_destroy(¶ms);
+ switch_event_destroy(¶ms);
- if (xml)
- switch_xml_free(xml);
+ if (xml)
+ switch_xml_free(xml);
- return status;
+ if (mod_h323_globals.use_rtp_timer && !mod_h323_globals.rtp_timer_name)
+ set_global_rtp_timer_name("soft");
+
+ return status;
}
FSH323EndPoint::FSH323EndPoint()
@@ -528,42 +591,45 @@ FSH323EndPoint::FSH323EndPoint()
terminalType = e_GatewayOnly;
}
-FSH323EndPoint::~FSH323EndPoint(){
+FSH323EndPoint::~FSH323EndPoint()
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::~FSH323EndPoint [%p]\n",this);
StopGkClient();
- ClearAllCalls(H323Connection::EndedByLocalUser,false);
+ ClearAllCalls(H323Connection::EndedByLocalUser, false);
}
H323Connection *FSH323EndPoint::CreateConnection(
unsigned callReference,
void* userData,
H323Transport* transport,
- H323SignalPDU* setupPDU){
+ H323SignalPDU* setupPDU)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::CreateConnection callReference = %u userDate = %p [%p]\n",callReference,userData,this);
- if ((switch_caller_profile_t *)userData){
+ if ((switch_caller_profile_t *)userData) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------> SWITCH_CALL_DIRECTION_OUTBOUND\n");
- } else{
+ } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------> SWITCH_CALL_DIRECTION_INBOUND\n");
}
- switch_core_session_t *fsSession = switch_core_session_request(GetSwitchInterface(),
- (switch_caller_profile_t *)userData ? SWITCH_CALL_DIRECTION_OUTBOUND : SWITCH_CALL_DIRECTION_INBOUND, NULL);
- if (fsSession == NULL)
- return NULL;
+ switch_core_session_t *fsSession = switch_core_session_request(GetSwitchInterface(),
+ (switch_caller_profile_t *)userData ? SWITCH_CALL_DIRECTION_OUTBOUND : SWITCH_CALL_DIRECTION_INBOUND, NULL);
+ if (fsSession == NULL)
+ return NULL;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------> fsSession = %p\n",fsSession);
- switch_channel_t *fsChannel = switch_core_session_get_channel(fsSession);
+ switch_channel_t *fsChannel = switch_core_session_get_channel(fsSession);
if (fsChannel == NULL) {
- switch_core_session_destroy(&fsSession);
- return NULL;
+ switch_core_session_destroy(&fsSession);
+ return NULL;
}
- return new FSH323Connection(*this,transport,callReference,(switch_caller_profile_t *)userData, fsSession, fsChannel);
+ return new FSH323Connection(*this, transport, callReference, (switch_caller_profile_t *)userData, fsSession, fsChannel);
}
-bool FSH323EndPoint::OnSetGatewayPrefixes(PStringList & prefixes) const{
+bool FSH323EndPoint::OnSetGatewayPrefixes(PStringList & prefixes) const
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::OnSetGatewayPrefixes [%p]\n",this);
if(m_gkPrefixes.GetSize() > 0) {
// PTRACE(4, "mod_h323\tOnSetGatewayPrefixes " << m_gkPrefixes);
@@ -573,16 +639,18 @@ bool FSH323EndPoint::OnSetGatewayPrefixes(PStringList & prefixes) const{
return false;
}
-void FSH323EndPoint::StartGkClient(int retry, PString* gkAddress,PString* gkIdentifer,PString* gkInterface){
+void FSH323EndPoint::StartGkClient(int retry, PString* gkAddress,PString* gkIdentifer,PString* gkInterface)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::StartGkClient [%p]\n",this);
- while(!UseGatekeeper(m_gkAddress, m_gkIdentifer, m_gkInterface) && retry > 0 ){
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "Could not start gatekeeper: gw name=\"%s\", addr=\"%s\", id=\"%s\", if=\"%s\"\n",
- (const char *)m_endpointname,
- (const char *)m_gkAddress,
- (const char *)m_gkIdentifer,
- (const char *)m_gkInterface);
- if (m_stop_gk) {
+
+ while (!UseGatekeeper(m_gkAddress, m_gkIdentifer, m_gkInterface) && retry > 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "Could not start gatekeeper: gw name=\"%s\", addr=\"%s\", id=\"%s\", if=\"%s\"\n",
+ (const char *)m_endpointname,
+ (const char *)m_gkAddress,
+ (const char *)m_gkIdentifer,
+ (const char *)m_gkInterface);
+ if (m_stop_gk) {
m_stop_gk = false;
return;
}
@@ -594,15 +662,18 @@ void FSH323EndPoint::StartGkClient(int retry, PString* gkAddress,PString* gkIden
}
RemoveGatekeeper();
}
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Started gatekeeper: %s\n",
(const char *)GetGatekeeper()->GetName());
m_thread = NULL;
}
-void FSH323EndPoint::StopGkClient(){
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::StopGkClient [%p]\n",this);
+void FSH323EndPoint::StopGkClient()
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::StopGkClient [%p]\n", this);
+
if (m_thread) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stop gatekeeper thread\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stop gatekeeper thread\n");
m_stop_gk = true;
while (m_stop_gk){
@@ -611,83 +682,88 @@ void FSH323EndPoint::StopGkClient(){
}
RemoveGatekeeper();
m_thread = NULL;
- }
+ }
}
-
FSH323Connection::FSH323Connection(FSH323EndPoint& endpoint, H323Transport* transport, unsigned callReference, switch_caller_profile_t *outbound_profile, switch_core_session_t *fsSession, switch_channel_t *fsChannel)
: H323Connection(endpoint,callReference)
, m_endpoint(&endpoint)
, m_fsSession(fsSession)
- , m_fsChannel(fsChannel)
+ , m_fsChannel(fsChannel)
, m_callOnPreAnswer(false)
, m_startRTP(false)
- , m_rxChennel(false)
- , m_txChennel(false)
- , m_ChennelAnswer(false)
- , m_ChennelProgress(false)
+ , m_rxChannel(false)
+ , m_txChannel(false)
+ , m_ChannelAnswer(false)
+ , m_ChannelProgress(false)
, m_select_dtmf(0)
, m_active_sessionID(0)
- , m_active_chennel_fax(false)
+ , m_active_channel_fax(false)
, m_rtp_resetting(0)
, m_isRequst_fax(false)
- , m_channel_hangup(false){
+ , m_channel_hangup(false)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::FSH323Connection [%p]\n",this);
- h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_alloc(m_fsSession, sizeof(*tech_pvt));
- tech_pvt->me = this;
- switch_core_session_set_private(m_fsSession, tech_pvt);
+ h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_alloc(m_fsSession, sizeof(*tech_pvt));
+ tech_pvt->me = this;
+ switch_core_session_set_private(m_fsSession, tech_pvt);
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(m_fsSession));
switch_mutex_init(&tech_pvt->h323_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(m_fsSession));
switch_mutex_init(&tech_pvt->h323_io_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(m_fsSession));
- if (outbound_profile != NULL) {
- SetLocalPartyName(outbound_profile->caller_id_number);
- SetDisplayName(outbound_profile->caller_id_name);
+ if (outbound_profile != NULL) {
+ SetLocalPartyName(outbound_profile->caller_id_number);
+ SetDisplayName(outbound_profile->caller_id_name);
- switch_caller_profile_t *caller_profile = switch_caller_profile_clone(m_fsSession, outbound_profile);
- switch_channel_set_caller_profile(m_fsChannel, caller_profile);
+ switch_caller_profile_t *caller_profile = switch_caller_profile_clone(m_fsSession, outbound_profile);
+ switch_channel_set_caller_profile(m_fsChannel, caller_profile);
- PString name = "h323/";
- name += outbound_profile->destination_number;
- switch_channel_set_name(m_fsChannel, name);
+ PString name = "h323/";
+ name += outbound_profile->destination_number;
+ switch_channel_set_name(m_fsChannel, name);
- switch_channel_set_flag(m_fsChannel, CF_OUTBOUND);
- switch_channel_set_state(m_fsChannel, CS_INIT);
- }
+ switch_channel_set_flag(m_fsChannel, CF_OUTBOUND);
+ switch_channel_set_state(m_fsChannel, CS_INIT);
+ }
m_RTPlocalPort = switch_rtp_request_port((const char *)m_RTPlocalIP.AsString());
}
-FSH323Connection::~FSH323Connection(){
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::~FSH323Connection [%p]\n",this);
+FSH323Connection::~FSH323Connection()
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::~FSH323Connection [%p]\n",this);
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
if ((m_rtp_resetting == 1)) {
- switch_core_session_unlock_codec_read(m_fsSession);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_read [%p]\n",m_fsSession);
- switch_core_session_unlock_codec_write(m_fsSession);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_write [%p]\n",m_fsSession);
+ switch_core_session_unlock_codec_read(m_fsSession);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_read [%p]\n",m_fsSession);
+ switch_core_session_unlock_codec_write(m_fsSession);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_write [%p]\n",m_fsSession);
}
- tech_pvt->me = NULL;
+ tech_pvt->me = NULL;
// switch_mutex_unlock(tech_pvt->h323_mutex);
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
}
-void FSH323Connection::OnSetLocalCapabilities(){
+void FSH323Connection::OnSetLocalCapabilities()
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnSetLocalCapabilities() [%p]\n",this);
H323Connection::OnSetLocalCapabilities();
SetLocalCapabilities();
}
-bool FSH323Connection::SetLocalCapabilities(){
+bool FSH323Connection::SetLocalCapabilities()
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::SetLocalCapabilities() Size local capability = %d [%p]\n",localCapabilities.GetSize(),this);
- if (!mod_h323_globals.codec_string)
+
+ if (!mod_h323_globals.codec_string)
return false;
- bool nocodecs = true;
- bool changed = false;
- for (int i = 0; i < localCapabilities.GetSize(); i++) {
+ bool nocodecs = true;
+ bool changed = false;
+
+ for (int i = 0; i < localCapabilities.GetSize(); i++) {
const char* format = 0;
PString fname;
decodeCapability(localCapabilities[i],&format,0,&fname);
@@ -704,39 +780,45 @@ bool FSH323Connection::SetLocalCapabilities(){
}
localCapabilities.Remove(fname);
i--;
- } else nocodecs = false;
+ } else
+ nocodecs = false;
}
- }
- if (nocodecs) {
+ }
+
+ if (nocodecs) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No codecs remaining for H323 connection [%p]\n",this);
changed = false;
ClearCall(EndedByCapabilityExchange);
- }
- return changed;
+ }
+
+ return changed;
}
-bool FSH323Connection::decodeCapability(const H323Capability& capability, const char** dataFormat, int* payload, PString* capabName){
+bool FSH323Connection::decodeCapability(const H323Capability& capability, const char** dataFormat, int* payload, PString* capabName)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::decodeCapability [%p]\n",this);
- PString fname((const char *)capability.GetFormatName());
+
+ PString fname((const char *)capability.GetFormatName());
- if (fname.Find("{sw}") == (fname.GetLength() - 4))
+ if (fname.Find("{sw}") == (fname.GetLength() - 4))
fname = fname.Mid(0,fname.GetLength()-4);
- if (fname.Find("{hw}") == (fname.GetLength() - 4))
+ if (fname.Find("{hw}") == (fname.GetLength() - 4))
fname = fname.Mid(0,fname.GetLength()-4);
- OpalMediaFormat oformat(fname, false);
- int pload = oformat.GetPayloadType();
- const char *format = 0;
- const char** f = h323_formats;
- for (; *f; f += 2) {
+ OpalMediaFormat oformat(fname, false);
+ int pload = oformat.GetPayloadType();
+ const char *format = 0;
+ const char** f = h323_formats;
+
+ for (; *f; f += 2) {
if (fname.Find(*f) == 0) {
format = f[1];
break;
}
- }
+ }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"capability '%s' format '%s' %d",(const char*)fname,format,pload);
- if (format) {
+ if (format) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"capability '%s' format '%s' %d",(const char*)fname,format,pload);
if (capabName)
*capabName = fname;
if (dataFormat)
@@ -744,46 +826,51 @@ bool FSH323Connection::decodeCapability(const H323Capability& capability, const
if (payload)
*payload = pload;
return true;
- }
- return false;
+ }
+
+ return false;
}
H323Connection::AnswerCallResponse FSH323Connection::OnAnswerCall(const PString &caller,
- const H323SignalPDU &setupPDU, H323SignalPDU &connectPDU){
+ const H323SignalPDU &setupPDU, H323SignalPDU &connectPDU)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnAnswerCall caller = %s [%p]\n",(const char*)caller,this);
if (m_fsSession == NULL) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session request failed.\n");
- return H323Connection::AnswerCallDenied;
- }
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session request failed.\n");
+ return H323Connection::AnswerCallDenied;
+ }
- switch_core_session_add_stream(m_fsSession, NULL);
+ switch_core_session_add_stream(m_fsSession, NULL);
- switch_channel_t *channel = switch_core_session_get_channel(m_fsSession);
- if (channel == NULL) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session does not have a channel\n");
- return H323Connection::AnswerCallDenied;
- }
+ switch_channel_t *channel = switch_core_session_get_channel(m_fsSession);
+ if (channel == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session does not have a channel\n");
+ return H323Connection::AnswerCallDenied;
+ }
const Q931& q931 = setupPDU.GetQ931();
const H225_Setup_UUIE& setup = setupPDU.m_h323_uu_pdu.m_h323_message_body;
- const H225_ArrayOf_AliasAddress& address = setup.m_destinationAddress;
- for (int i = 0; i 0)
+
+ if (address.GetSize() > 0)
called = (const char *)H323GetAliasAddressString(address[0]);
- if (!called.IsEmpty())
+ if (!called.IsEmpty())
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"Called number or alias = %s\n",(const char*)called);
- else {
+ else {
PString callnam;
if (q931.GetCalledPartyNumber(callnam)) {
called=(const char *)callnam;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"Called-Party-Number = %s\n",(const char*)called);
}
- }
+ }
- switch_caller_profile_t *caller_profile = switch_caller_profile_new(switch_core_session_get_pool(m_fsSession),
+ switch_caller_profile_t *caller_profile = switch_caller_profile_new(switch_core_session_get_pool(m_fsSession),
NULL,
/** username */
mod_h323_globals.dialplan,
@@ -807,10 +894,11 @@ H323Connection::AnswerCallResponse FSH323Connection::OnAnswerCall(const PString
called
/** destination_number */
);
- if (caller_profile == NULL) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not create caller profile\n");
- return H323Connection::AnswerCallDenied;
- }
+ if (caller_profile == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not create caller profile\n");
+ return H323Connection::AnswerCallDenied;
+ }
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Created switch caller profile:\n"
" username = %s\n"
" dialplan = %s\n"
@@ -830,22 +918,23 @@ H323Connection::AnswerCallResponse FSH323Connection::OnAnswerCall(const PString
,caller_profile->destination_number);
- switch_channel_set_caller_profile(channel, caller_profile);
+ switch_channel_set_caller_profile(channel, caller_profile);
- char name[256] = "h323/";
- switch_copy_string(name + 5, caller_profile->destination_number, sizeof(name)-5);
- switch_channel_set_name(channel, name);
- switch_channel_set_state(channel, CS_INIT);
+ char name[256] = "h323/";
+ switch_copy_string(name + 5, caller_profile->destination_number, sizeof(name)-5);
+ switch_channel_set_name(channel, name);
+ switch_channel_set_state(channel, CS_INIT);
- if (switch_core_session_thread_launch(m_fsSession) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not launch session thread\n");
- return H323Connection::AnswerCallDenied;
- }
+ if (switch_core_session_thread_launch(m_fsSession) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not launch session thread\n");
+ return H323Connection::AnswerCallDenied;
+ }
return H323Connection::AnswerCallDeferred;
}
-H323Channel* FSH323Connection::CreateRealTimeLogicalChannel(const H323Capability& capability,H323Channel::Directions dir,unsigned sessionID,const H245_H2250LogicalChannelParameters* param, RTP_QOS * rtpqos){
+H323Channel* FSH323Connection::CreateRealTimeLogicalChannel(const H323Capability& capability,H323Channel::Directions dir,unsigned sessionID,const H245_H2250LogicalChannelParameters* param, RTP_QOS * rtpqos)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::CreateRealTimeLogicalChannel [%p]\n",this);
H323TransportAddress m_h323transportadd = GetSignallingChannel()->GetLocalAddress();
@@ -854,19 +943,22 @@ H323Channel* FSH323Connection::CreateRealTimeLogicalChannel(const H323Capability
return new FSH323_ExternalRTPChannel(*this, capability, dir, sessionID,m_RTPlocalIP,m_RTPlocalPort);
}
-PBoolean FSH323Connection::OnStartLogicalChannel(H323Channel & channel){
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnStartLogicalChannel chennel = %p [%p]\n",&channel,this);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnStartLogicalChannel connectionState = %s [%p]\n",ConnectionStatesNames[connectionState],this);
+PBoolean FSH323Connection::OnStartLogicalChannel(H323Channel & channel)
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnStartLogicalChannel chennel = %p [%p]\n",&channel,this);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnStartLogicalChannel connectionState = %s [%p]\n",ConnectionStatesNames[connectionState],this);
return connectionState != ShuttingDownConnection;
}
-PBoolean FSH323Connection::OnCreateLogicalChannel(const H323Capability& capability, H323Channel::Directions dir, unsigned& errorCode){
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnCreateLogicalChannel ('%s',%s) [%p]\n",(const char *)capability.GetFormatName(),GetDirections[dir],this);
+PBoolean FSH323Connection::OnCreateLogicalChannel(const H323Capability& capability, H323Channel::Directions dir, unsigned& errorCode)
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnCreateLogicalChannel ('%s',%s) [%p]\n",(const char *)capability.GetFormatName(),GetDirections[dir],this);
return H323Connection::OnCreateLogicalChannel(capability,dir,errorCode);
}
-void FSH323Connection::OnReceivedReleaseComplete(const H323SignalPDU & pdu){
+void FSH323Connection::OnReceivedReleaseComplete(const H323SignalPDU & pdu)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnReceivedReleaseComplete value = %d\n",(switch_call_cause_t)pdu.GetQ931().GetCause());
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
if ((tech_pvt->me != NULL) && (m_rtp_resetting == 1)) {
@@ -877,39 +969,44 @@ void FSH323Connection::OnReceivedReleaseComplete(const H323SignalPDU & pdu){
}
tech_pvt->me = NULL;
switch_channel_hangup(switch_core_session_get_channel(m_fsSession),(switch_call_cause_t)pdu.GetQ931().GetCause());
+
return H323Connection::OnReceivedReleaseComplete(pdu);
}
bool FSH323Connection::OnReceivedProgress(const H323SignalPDU &pdu)
{
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnReceivedProgress [%p]\n",this);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnReceivedProgress [%p]\n", this);
H323Connection::OnReceivedProgress(pdu);
- if ((m_rxChennel && m_txChennel) || (m_ChennelProgress && m_rxChennel))
+ if ((m_rxChannel && m_txChannel) || (m_ChannelProgress && m_rxChannel))
switch_channel_mark_pre_answered(m_fsChannel);
else{
- m_ChennelProgress = true;
+ m_ChannelProgress = true;
}
return true;
}
-bool FSH323Connection::OnReceivedSignalSetup(const H323SignalPDU & setupPDU){
-
+bool FSH323Connection::OnReceivedSignalSetup(const H323SignalPDU & setupPDU)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnReceivedSignalSetup [%p]\n",this);
- if (!H323Connection::OnReceivedSignalSetup(setupPDU)) return false;
+
+ if (!H323Connection::OnReceivedSignalSetup(setupPDU))
+ return false;
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"---------> after FSH323Connection::OnReceivedSignalSetup connectionState = %s [%p]\n",ConnectionStatesNames[connectionState],this);
H323SignalPDU callProceedingPDU;
H225_CallProceeding_UUIE & callProceeding = callProceedingPDU.BuildCallProceeding(*this);
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"---------> after callProceedingPDU.BuildCallProceeding connectionState = %s [%p]\n",ConnectionStatesNames[connectionState],this);
if (connectionState == ShuttingDownConnection){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"---------> connectionState = ShuttingDownConnection [%p]\n",this);
return false;
}
-
- if (SendFastStartAcknowledge(callProceeding.m_fastStart)){
- callProceeding.IncludeOptionalField(H225_CallProceeding_UUIE::e_fastStart);
+
+ if (SendFastStartAcknowledge(callProceeding.m_fastStart)) {
+ callProceeding.IncludeOptionalField(H225_CallProceeding_UUIE::e_fastStart);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"SendFastStartAcknowledge = FALSE\n");
- if (connectionState == ShuttingDownConnection){
+ if (connectionState == ShuttingDownConnection) {
return true;
}
earlyStart = TRUE;
@@ -921,36 +1018,41 @@ bool FSH323Connection::OnReceivedSignalSetup(const H323SignalPDU & setupPDU){
controlChannel->SetUpTransportPDU(callProceeding.m_h245Address, TRUE);
}
}
- if (connectionState == ShuttingDownConnection){
- return true;
- }
-
- if (!WriteSignalPDU(callProceedingPDU)){
- return false;
+ if (connectionState == ShuttingDownConnection) {
+ return true;
}
+
+ if (!WriteSignalPDU(callProceedingPDU)) {
+ return false;
+ }
+
return true;
}
-bool FSH323Connection::OnReceivedCallProceeding(const H323SignalPDU & pdu){
+bool FSH323Connection::OnReceivedCallProceeding(const H323SignalPDU & pdu)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>PFSH323Connection::OnReceivedCallProceeding [%p]\n",this);
unsigned pi;
-
if (!pdu.GetQ931().GetProgressIndicator(pi))
pi = 0;
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----------->OnAlerting PI = %u",pi);
- if (pi > 0){
- if ((m_rxChennel && m_txChennel) || (m_ChennelProgress && m_rxChennel))
+ if (pi > 0) {
+ if ((m_rxChannel && m_txChannel) || (m_ChannelProgress && m_rxChannel))
switch_channel_mark_pre_answered(m_fsChannel);
- else{
- m_ChennelProgress = true;
+ else {
+ m_ChannelProgress = true;
}
}
+
return H323Connection::OnReceivedCallProceeding(pdu);
}
-bool FSH323Connection::OnSendCallProceeding(H323SignalPDU & callProceedingPDU){
+bool FSH323Connection::OnSendCallProceeding(H323SignalPDU & callProceedingPDU)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnSendCallProceeding fastStartState = %s [%p]\n",FastStartStateNames[fastStartState],this);
+
return false;
// return true;
}
@@ -958,20 +1060,23 @@ bool FSH323Connection::OnSendCallProceeding(H323SignalPDU & callProceedingPDU){
bool FSH323Connection::OnSendReleaseComplete(H323SignalPDU & pdu)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnSendReleaseComplete cause = %u\n",(switch_call_cause_t)pdu.GetQ931().GetCause());
+
switch_channel_hangup(m_fsChannel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return H323Connection::OnSendReleaseComplete(pdu);
}
-PBoolean FSH323Connection::OpenLogicalChannel(const H323Capability& capability, unsigned sessionID, H323Channel::Directions dir){
+PBoolean FSH323Connection::OpenLogicalChannel(const H323Capability& capability, unsigned sessionID, H323Channel::Directions dir)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OpenLogicalChannel ('%s', %d, %s) [%p]\n",(const char *)capability.GetFormatName(),sessionID,GetDirections[dir],this);
- return H323Connection::OpenLogicalChannel(capability,sessionID,dir);
+
+ return H323Connection::OpenLogicalChannel(capability,sessionID,dir);
}
bool FSH323Connection::OnReceivedCapabilitySet(const H323Capabilities & remoteCaps,
const H245_MultiplexCapability * muxCap,
- H245_TerminalCapabilitySetReject & reject){
-
+ H245_TerminalCapabilitySetReject & reject)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnReceivedCapabilitySet [%p]\n",this);
if (connectionState == ShuttingDownConnection)
return false;
@@ -994,9 +1099,8 @@ bool FSH323Connection::OnReceivedCapabilitySet(const H323Capabilities & remoteCa
return connectionState != ShuttingDownConnection;
}
-
-bool FSH323Connection::OnAlerting(const H323SignalPDU &alertingPDU, const PString &user){
-
+bool FSH323Connection::OnAlerting(const H323SignalPDU &alertingPDU, const PString &user)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>PFSH323Connection::OnAlerting user = %s [%p]\n",(const char *)user,this);
unsigned pi;
switch_status_t status = switch_channel_mark_ring_ready(m_fsChannel);
@@ -1005,18 +1109,18 @@ bool FSH323Connection::OnAlerting(const H323SignalPDU &alertingPDU, const PStrin
if (!alertingPDU.GetQ931().GetProgressIndicator(pi))
pi = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----------->OnAlerting PI = %u\n",pi);
- if (pi > 0){
- if ((m_rxChennel && m_txChennel) || (m_ChennelProgress && m_rxChennel))
+ if (pi > 0) {
+ if ((m_rxChannel && m_txChannel) || (m_ChannelProgress && m_rxChannel))
switch_channel_mark_pre_answered(m_fsChannel);
- else{
- m_ChennelProgress = true;
+ else {
+ m_ChannelProgress = true;
}
}
return ( status == SWITCH_STATUS_SUCCESS);
}
-void FSH323Connection::AnsweringCall(AnswerCallResponse response){
-
+void FSH323Connection::AnsweringCall(AnswerCallResponse response)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::AnsweringCall [%p]\n",this);
switch (response) {
@@ -1029,7 +1133,7 @@ void FSH323Connection::AnsweringCall(AnswerCallResponse response){
if (!mediaWaitForConnect) {
// create a new facility PDU if doing AnswerDeferredWithMedia
H323SignalPDU want245PDU;
- H225_Progress_UUIE & prog = want245PDU.BuildProgress(*this);
+ //H225_Progress_UUIE & prog = want245PDU.BuildProgress(*this);
PBoolean sendPDU = TRUE;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"mediaWaitForConnect = FALSE\n");
/* if (SendFastStartAcknowledge(prog.m_fastStart)){
@@ -1107,16 +1211,18 @@ void FSH323Connection::AnsweringCall(AnswerCallResponse response){
}
}
-void FSH323Connection::OnEstablished(){
-
+void FSH323Connection::OnEstablished()
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>PFSH323Connection::OnEstablished [%p]\n",this);
if(m_startRTP)
switch_channel_mark_answered(m_fsChannel);
- else m_ChennelAnswer = true;
- if (m_active_chennel_fax)
+ else
+ m_ChannelAnswer = true;
+
+ if (m_active_channel_fax)
RequestModeChangeT38("T.38\nT.38");
else
- m_active_chennel_fax = true;
+ m_active_channel_fax = true;
}
PBoolean FSH323Connection::OnRequestModeChange(const H245_RequestMode & pdu,
H245_RequestModeAck & /*ack*/,
@@ -1138,7 +1244,8 @@ PBoolean FSH323Connection::OnRequestModeChange(const H245_RequestMode & pdu,
return false;
}
-void FSH323Connection::OnModeChanged(const H245_ModeDescription & newMode){
+void FSH323Connection::OnModeChanged(const H245_ModeDescription & newMode)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>PFSH323Connection::OnModeChanged [%p]\n",this);
for (PINDEX i = 0; i < newMode.GetSize(); i++) {
H323Capability * capability = localCapabilities.FindCapability(newMode[i]);
@@ -1150,7 +1257,7 @@ void FSH323Connection::OnModeChanged(const H245_ModeDescription & newMode){
if (type.m_application.GetTag() == H245_DataMode_application::e_t38fax){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"ttype.m_application.GetTag() = H245_DataMode_application::e_t38fax\n");
H245_DataMode_application_t38fax & fax = type.m_application;
- H245_DataProtocolCapability & proto = fax.m_t38FaxProtocol;
+ //H245_DataProtocolCapability & proto = fax.m_t38FaxProtocol;
const H245_T38FaxProfile & profile = fax.m_t38FaxProfile;
switch_t38_options_t* t38_options = (switch_t38_options_t*)switch_channel_get_private(m_fsChannel, "t38_options");
@@ -1160,7 +1267,7 @@ void FSH323Connection::OnModeChanged(const H245_ModeDescription & newMode){
}
t38_options->T38VendorInfo = "0 0 0";
- t38_options->T38FaxVersion = profile.m_version;
+ t38_options->T38FaxVersion = (uint16_t)profile.m_version;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38FaxVersion:%lu\n",(unsigned long)profile.m_version);
t38_options->T38MaxBitRate = type.m_bitRate*100;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38MaxBitRate:%d\n",t38_options->T38MaxBitRate);
@@ -1188,7 +1295,7 @@ void FSH323Connection::OnModeChanged(const H245_ModeDescription & newMode){
t38_options->T38FaxUdpEC = "t38UDPRedundancy";
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38FaxUdpEC:%s\n",t38_options->T38FaxUdpEC);
const char *uuid = switch_channel_get_variable(m_fsChannel, SWITCH_SIGNAL_BOND_VARIABLE);
- if (uuid != NULL){
+ if (uuid != NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"uuid:%s\n",uuid);
switch_channel_set_private(switch_core_session_get_channel(switch_core_session_locate(switch_channel_get_variable(m_fsChannel, SWITCH_SIGNAL_BOND_VARIABLE))), "t38_options", t38_options);
@@ -1215,41 +1322,49 @@ void FSH323Connection::OnModeChanged(const H245_ModeDescription & newMode){
H323Connection::OnModeChanged(newMode);
}
-bool FSH323Connection::OnSendSignalSetup(H323SignalPDU & setupPDU){
+bool FSH323Connection::OnSendSignalSetup(H323SignalPDU & setupPDU)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>PFSH323Connection::OnSendSignalSetup [%p]\n",this);
setupPDU.GetQ931().SetBearerCapabilities(Q931::TransferSpeech, 1);
return true;
}
-void FSH323Connection::setRemoteAddress(const char* remoteIP, WORD remotePort){
+void FSH323Connection::setRemoteAddress(const char* remoteIP, WORD remotePort)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>PFSH323Connection::setRemoteAddress remoteIP = %s , remotePort = %d [%p]\n",remoteIP,remotePort,this);
- if (!m_remotePort) {
+
+ if (!m_remotePort) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Got remote RTP address %s:%d [%p]\n",remoteIP,remotePort,this);
m_remotePort = remotePort;
m_remoteAddr = remoteIP;
- }
+ }
}
-switch_status_t FSH323Connection::on_execute(){
+switch_status_t FSH323Connection::on_execute()
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::on_execute [%p]\n",this);
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
-switch_status_t FSH323Connection::on_routing(){
+switch_status_t FSH323Connection::on_routing()
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::on_routing [%p]\n",this);
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
-switch_status_t FSH323Connection::kill_channel(int sig){
+switch_status_t FSH323Connection::kill_channel(int sig)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::kill_channel sig = %d [%p]\n",sig,this);
+
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
+
if (!tech_pvt) {
return SWITCH_STATUS_FALSE;
}
- switch (sig) {
+ switch (sig) {
case SWITCH_SIG_BREAK:
if (switch_rtp_ready(tech_pvt->rtp_session)) {
switch_rtp_break(tech_pvt->rtp_session);
@@ -1270,15 +1385,17 @@ switch_status_t FSH323Connection::kill_channel(int sig){
switch_rtp_kill_socket(tech_pvt->rtp_session);
}
break;
- }
+ }
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
-switch_status_t FSH323Connection::send_dtmf(const switch_dtmf_t *dtmf){
+switch_status_t FSH323Connection::send_dtmf(const switch_dtmf_t *dtmf)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::send_dtmf [%p]\n",this);
- SendUserInputTone(dtmf->digit, dtmf->duration);
- return SWITCH_STATUS_SUCCESS;
+
+ SendUserInputTone(dtmf->digit, dtmf->duration);
+ return SWITCH_STATUS_SUCCESS;
}
void FSH323Connection::SendUserInputTone(char tone, unsigned duration, unsigned logicalChannel, unsigned rtpTimestamp)
@@ -1309,39 +1426,43 @@ void FSH323Connection::OnUserInputString(const PString &value)
}
}
-void FSH323Connection::CleanUpOnCall(){
+void FSH323Connection::CleanUpOnCall()
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::CleanUpOnCall [%p]\n",this);
connectionState = ShuttingDownConnection;
}
-switch_status_t FSH323Connection::receive_message(switch_core_session_message_t *msg){
- h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
+switch_status_t FSH323Connection::receive_message(switch_core_session_message_t *msg)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::receive_message MSG = %d\n",msg->message_id);
-
- switch_channel_t *channel = switch_core_session_get_channel(m_fsSession);
- switch (msg->message_id) {
- case SWITCH_MESSAGE_INDICATE_BRIDGE:
- case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
- case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC:
- switch_channel_set_private_flag(channel, CF_NEED_FLUSH);
- break;
- default:
- break;
- }
+ switch_channel_t *channel = switch_core_session_get_channel(m_fsSession);
+ h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
- switch (msg->message_id) {
+ switch (msg->message_id) {
+ case SWITCH_MESSAGE_INDICATE_BRIDGE:
+ case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
+ case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC:
+ switch_channel_set_private_flag(channel, CF_NEED_FLUSH);
+ break;
+ default:
+ break;
+ }
+
+ switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_RINGING: {
- AnsweringCall(AnswerCallPending);
+ AnsweringCall(AnswerCallPending);
break;
}
case SWITCH_MESSAGE_INDICATE_DEFLECT: {
+ if (msg->string_arg != NULL)
+ TransferCall(msg->string_arg);
break;
}
case SWITCH_MESSAGE_INDICATE_PROGRESS: {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_mutex);
- if (m_txChennel && m_rxChennel){
+ if (m_txChannel && m_rxChannel){
m_callOnPreAnswer = true;
}
switch_mutex_unlock(tech_pvt->h323_mutex);
@@ -1349,7 +1470,7 @@ switch_status_t FSH323Connection::receive_message(switch_core_session_message_t
AnsweringCall(AnswerCallPending);
AnsweringCall(AnswerCallDeferredWithMedia);
- if (m_txChennel && m_rxChennel){
+ if (m_txChannel && m_rxChannel){
if (!switch_channel_test_flag(m_fsChannel, CF_EARLY_MEDIA)) {
switch_channel_mark_pre_answered(m_fsChannel);
}
@@ -1370,13 +1491,13 @@ switch_status_t FSH323Connection::receive_message(switch_core_session_message_t
AnsweringCall(H323Connection::AnswerCallNow);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Media started on connection [%p]\n",this);
- if (m_txChennel && m_rxChennel){
+ if (m_txChannel && m_rxChannel){
if (!switch_channel_test_flag(m_fsChannel, CF_EARLY_MEDIA)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-------------------->switch_channel_mark_answered(m_fsChannel) [%p]\n",this);
switch_channel_mark_answered(m_fsChannel);
}
} else{
- m_ChennelAnswer = true;
+ m_ChannelAnswer = true;
if (fastStartState == FastStartDisabled){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-------------------->m_txAudioOpened.Wait START [%p]\n",this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-------------------->m_rxAudioOpened.Wait START [%p]\n",this);
@@ -1396,10 +1517,10 @@ switch_status_t FSH323Connection::receive_message(switch_core_session_message_t
m_isRequst_fax = true;
switch_mutex_unlock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
- if (m_active_chennel_fax)
+ if (m_active_channel_fax)
RequestModeChangeT38("T.38\nT.38");
else
- m_active_chennel_fax = true;
+ m_active_channel_fax = true;
break;
}
case SWITCH_MESSAGE_INDICATE_UDPTL_MODE:{
@@ -1422,57 +1543,143 @@ switch_status_t FSH323Connection::receive_message(switch_core_session_message_t
default:{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Received message id = %d [%p]\n", msg->message_id,this);
}
- }
- return SWITCH_STATUS_SUCCESS;
+ }
+
+ return SWITCH_STATUS_SUCCESS;
}
-switch_status_t FSH323Connection::receive_event(switch_event_t *event){
+switch_status_t FSH323Connection::receive_event(switch_event_t *event)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::receive_event event id = %d [%p]\n",event->event_id,this);
-// PTRACE(4, "mod_h323\tReceived event " << event->event_id << " on connection " << *this);
- return SWITCH_STATUS_SUCCESS;
+// PTRACE(4, "mod_h323\tReceived event " << event->event_id << " on connection " << *this);
+
+ return SWITCH_STATUS_SUCCESS;
}
-switch_status_t FSH323Connection::state_change(){
+switch_status_t FSH323Connection::state_change()
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::state_change [%p]\n",this);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"State changed on connection [%p]\n",this);
- return SWITCH_STATUS_SUCCESS;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"State changed on connection [%p]\n",this);
+
+ return SWITCH_STATUS_SUCCESS;
}
-switch_status_t FSH323Connection::on_init(){
+switch_status_t FSH323Connection::on_init()
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::on_init [%p]\n",this);
- switch_channel_t *channel = switch_core_session_get_channel(m_fsSession);
- if (channel == NULL) {
- return SWITCH_STATUS_FALSE;
- }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Started routing for connection [%p]\n",this);
- switch_channel_set_state(channel, CS_ROUTING);
- return SWITCH_STATUS_SUCCESS;
+ switch_channel_t *channel = switch_core_session_get_channel(m_fsSession);
+ if (channel == NULL) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Started routing for connection [%p]\n",this);
+ switch_channel_set_state(channel, CS_ROUTING);
+
+ return SWITCH_STATUS_SUCCESS;
}
-switch_status_t FSH323Connection::on_exchange_media(){
+switch_status_t FSH323Connection::on_exchange_media()
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::on_exchange_media [%p]\n",this);
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
-switch_status_t FSH323Connection::on_soft_execute(){
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::on_soft_execute [%p]\n",this);
+switch_status_t FSH323Connection::on_soft_execute()
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::on_soft_execute [%p]\n",this);
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
-switch_status_t FSH323Connection::read_audio_frame(switch_frame_t **frame, switch_io_flag_t flags, int stream_id){
+switch_status_t FSH323Connection::read_audio_frame(switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame [%p]\n",this);
+
+ /*switch_channel_t *channel = NULL;
+ h323_private_t *tech_pvt = NULL;
+ int payload = 0;
+
+ channel = m_fsChannel;
+ assert(channel != NULL);
+
+ tech_pvt = (h323_private_t *)switch_core_session_get_private(m_fsSession);
+ assert(tech_pvt != NULL);
+
+ while (!(tech_pvt->read_codec.implementation && switch_rtp_ready(tech_pvt->rtp_session))) {
+ if (switch_channel_ready(channel)) {
+ switch_yield(10000);
+ } else {
+ PTRACE(4, "mod_h323\t<======FSH323Connection::read_audio_frame " << this);
+ return SWITCH_STATUS_GENERR;
+ }
+ }
+
+ tech_pvt->read_frame.datalen = 0;
+ switch_set_flag_locked(tech_pvt, TFLAG_READING);
+
+ switch_status_t status;
+
+ switch_assert(tech_pvt->rtp_session != NULL);
+ tech_pvt->read_frame.datalen = 0;
+
+
+ while (tech_pvt->read_frame.datalen == 0) {
+ tech_pvt->read_frame.flags = SFF_NONE;
+
+ status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame, flags);
+ if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
+ PTRACE(4, "mod_h323\t<======FSH323Connection::read_audio_frame " << this);
+ return SWITCH_STATUS_FALSE;
+ }
+
+ payload = tech_pvt->read_frame.payload;
+
+ if (switch_rtp_has_dtmf(tech_pvt->rtp_session)) {
+ switch_dtmf_t dtmf = { 0 };
+ switch_rtp_dequeue_dtmf(tech_pvt->rtp_session, &dtmf);
+ switch_channel_queue_dtmf(channel, &dtmf);
+ }
+
+ if (tech_pvt->read_frame.datalen > 0) {
+ size_t bytes = 0;
+ int frames = 1;
+
+ if (!switch_test_flag((&tech_pvt->read_frame), SFF_CNG)) {
+ if ((bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_packet)) {
+ frames = (tech_pvt->read_frame.datalen / bytes);
+ }
+ tech_pvt->read_frame.samples = (int) (frames * tech_pvt->read_codec.implementation->samples_per_packet);
+ }
+ break;
+ }
+ }
+
+ switch_clear_flag_locked(tech_pvt, TFLAG_READING);
+
+ if (tech_pvt->read_frame.datalen == 0) {
+ *frame = NULL;
+ PTRACE(4, "mod_h323\t<======FSH323Connection::read_audio_frame " << this);
+ return SWITCH_STATUS_GENERR;
+ }
+
+ *frame = &tech_pvt->read_frame;
+
+ PTRACE(4, "mod_h323\t<======FSH323Connection::read_audio_frame " << this);
+ return SWITCH_STATUS_SUCCESS;*/
+
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
tech_pvt->read_frame.flags = 0;
switch_set_flag_locked(tech_pvt, TFLAG_READING);
- if (!switch_channel_ready(m_fsChannel)) {
+
+ if (!switch_channel_ready(m_fsChannel)) {
switch_clear_flag_locked(tech_pvt, TFLAG_READING);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame END\n");
- return SWITCH_STATUS_FALSE;
- }
+ return SWITCH_STATUS_FALSE;
+ }
+
switch_mutex_lock(tech_pvt->h323_io_mutex);
if (switch_test_flag(tech_pvt, TFLAG_IO)) {
if (!switch_core_codec_ready(&tech_pvt->read_codec )) {
@@ -1490,7 +1697,9 @@ switch_status_t FSH323Connection::read_audio_frame(switch_frame_t **frame, switc
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame END\n\n");
return status;
}
- // PTRACE(4, "mod_h323\t--------->\n source = "<read_frame.source<< "\n packetlen = "<read_frame.packetlen<<"\n datalen = "<read_frame.datalen<<"\n samples = "<read_frame.samples<<"\n rate = "<read_frame.rate<<"\n payload = "<<(int)tech_pvt->read_frame.payload<<"\n timestamp = "<read_frame.timestamp<<"\n seq = "<read_frame.seq<<"\n ssrc = "<read_frame.ssrc);
+
+// PTRACE(4, "mod_h323\t--------->\n source = "<read_frame.source<< "\n packetlen = "<read_frame.packetlen<<"\n datalen = "<read_frame.datalen<<"\n samples = "<read_frame.samples<<"\n rate = "<read_frame.rate<<"\n payload = "<<(int)tech_pvt->read_frame.payload<<"\n timestamp = "<read_frame.timestamp<<"\n seq = "<read_frame.seq<<"\n ssrc = "<read_frame.ssrc);
+
if (tech_pvt->read_frame.flags & SFF_CNG) {
tech_pvt->read_frame.buflen = sizeof(m_buf);
tech_pvt->read_frame.data = m_buf;
@@ -1500,34 +1709,62 @@ switch_status_t FSH323Connection::read_audio_frame(switch_frame_t **frame, switc
tech_pvt->read_frame.m = SWITCH_FALSE;
tech_pvt->read_frame.seq = 0;
tech_pvt->read_frame.ssrc = 0;
- tech_pvt->read_frame.codec = &tech_pvt->read_codec ;
+ /* The codec has alrady been set here */ //tech_pvt->read_frame.codec = &tech_pvt->read_codec ;
} else {
- tech_pvt->read_frame.codec = &tech_pvt->read_codec ;
+ /* The codec has alrady been set here */ //tech_pvt->read_frame.codec = &tech_pvt->read_codec ;
}
- }else{
+ } else {
switch_mutex_unlock(tech_pvt->h323_io_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"--------->TFLAG_IO OFF\n");
switch_yield(10000);
}
+
switch_mutex_unlock(tech_pvt->h323_io_mutex);
switch_clear_flag_locked(tech_pvt, TFLAG_READING);
- *frame = &tech_pvt->read_frame;
+ *frame = &tech_pvt->read_frame;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame END\n\n");
- return SWITCH_STATUS_SUCCESS;
+
+ return SWITCH_STATUS_SUCCESS;
}
-switch_status_t FSH323Connection::write_audio_frame(switch_frame_t *frame, switch_io_flag_t flags, int stream_id){
+switch_status_t FSH323Connection::write_audio_frame(switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame [%p]\n",this);
+ /*switch_channel_t *channel = NULL;
+ h323_private_t *tech_pvt = NULL;
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+ channel = switch_core_session_get_channel(m_fsSession);
+ assert(channel != NULL);
+
+ tech_pvt = (h323_private_t *)switch_core_session_get_private(m_fsSession);
+ assert(tech_pvt != NULL);
+
+#if SWITCH_BYTE_ORDER == __BIG_ENDIAN
+ if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
+ switch_swap_linear(frame->data, (int) frame->datalen / 2);
+ }
+#endif
+
+ switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
+
+ switch_rtp_write_frame(tech_pvt->rtp_session, frame);
+
+ switch_clear_flag_locked(tech_pvt, TFLAG_WRITING);
+
+ PTRACE(4, "mod_h323\t<======FSH323Connection::write_audio_frame " << this);
+ return status;*/
+
switch_status_t status = SWITCH_STATUS_SUCCESS;
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
switch_assert(tech_pvt != NULL);
if (!switch_channel_ready(m_fsChannel)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame END\n\n");
- return SWITCH_STATUS_FALSE;
- }
+ return SWITCH_STATUS_FALSE;
+ }
while (!(tech_pvt->read_codec.implementation && switch_rtp_ready(tech_pvt->rtp_session))) {
if (switch_channel_ready(m_fsChannel)) {
@@ -1545,120 +1782,119 @@ switch_status_t FSH323Connection::write_audio_frame(switch_frame_t *frame, switc
if ((frame->flags & SFF_CNG)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame END\n\n");
- return SWITCH_STATUS_SUCCESS;
- }
+ return SWITCH_STATUS_SUCCESS;
+ }
+
switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
- if (switch_rtp_write_frame(tech_pvt->rtp_session, frame)< 0) {
+ if (switch_rtp_write_frame(tech_pvt->rtp_session, frame) < 0) {
status = SWITCH_STATUS_GENERR;
}
switch_clear_flag_locked(tech_pvt, TFLAG_WRITING);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame END\n\n");
+
return status;
}
-switch_status_t FSH323Connection::read_video_frame(switch_frame_t **frame, switch_io_flag_t flag, int stream_id){
+switch_status_t FSH323Connection::read_video_frame(switch_frame_t **frame, switch_io_flag_t flag, int stream_id)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_video_frame [%p]\n",this);
-
+ return SWITCH_STATUS_FALSE; /* Not yet implemented */
}
-switch_status_t FSH323Connection::write_video_frame(switch_frame_t *frame, switch_io_flag_t flag, int stream_id){
+switch_status_t FSH323Connection::write_video_frame(switch_frame_t *frame, switch_io_flag_t flag, int stream_id)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_video_frame [%p]\n",this);
+ return SWITCH_STATUS_FALSE; /* Not yet implemented */
}
///////////////////////////////////////////////////////////////////////
-FSH323_ExternalRTPChannel::FSH323_ExternalRTPChannel(
- FSH323Connection& connection,
- const H323Capability& capability,
- Directions direction,
- unsigned sessionID,
- const PIPSocket::Address& ip,
- WORD dataPort)
- : H323_ExternalRTPChannel(connection, capability, direction, sessionID,ip,dataPort)
+FSH323_ExternalRTPChannel::FSH323_ExternalRTPChannel(FSH323Connection& connection,
+ const H323Capability& capability,
+ Directions direction,
+ unsigned sessionID,
+ const PIPSocket::Address& ip,
+ WORD dataPort)
+ : H323_ExternalRTPChannel(connection, capability, direction, sessionID,ip,dataPort)
, m_conn(&connection)
, m_fsSession(connection.GetSession())
, m_capability(&capability)
, m_RTPlocalPort(dataPort)
- , m_sessionID(sessionID){
-
- h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
+ , m_sessionID(sessionID)
+{
m_RTPlocalIP = (const char *)ip.AsString();
SetExternalAddress(H323TransportAddress(ip, dataPort), H323TransportAddress(ip, dataPort+1));
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::FSH323_ExternalRTPChannel sessionID = %d :%s addr = %s:%d [%p]\n",sessionID,GetDirections[GetDirection()],(const char*)m_RTPlocalIP,m_RTPlocalPort,this);
-
- memset(&m_readFrame, 0, sizeof(m_readFrame));
- m_readFrame.codec = m_switchCodec;
- m_readFrame.flags = SFF_RAW_RTP;
-
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::FSH323_ExternalRTPChannel sessionID = %d :%s addr = %s:%d [%p]\n",sessionID,GetDirections[GetDirection()],(const char*)m_RTPlocalIP,m_RTPlocalPort,this);
+
m_fsChannel = switch_core_session_get_channel(m_fsSession);
- //SetExternalAddress(H323TransportAddress(localIpAddress, m_RTPlocalPort), H323TransportAddress(localIpAddress, m_RTPlocalPort+1));
+ //SetExternalAddress(H323TransportAddress(localIpAddress, m_RTPlocalPort), H323TransportAddress(localIpAddress, m_RTPlocalPort+1));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------->capability.GetPayloadType() return = %s\n",((capability.GetPayloadType() <= RTP_DataFrame::LastKnownPayloadType)?PayloadTypesNames[capability.GetPayloadType()]:"[pt=128]"));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------->capability.GetFormatName() return = %s\n",(const char*)(capability.GetFormatName()));
PString fname((const char *)capability.GetFormatName());
- if (fname.Find("{sw}") == (fname.GetLength() - 4))
+ if (fname.Find("{sw}") == (fname.GetLength() - 4))
fname = fname.Mid(0,fname.GetLength()-4);
- if (fname.Find("{hw}") == (fname.GetLength() - 4))
+ if (fname.Find("{hw}") == (fname.GetLength() - 4))
fname = fname.Mid(0,fname.GetLength()-4);
OpalMediaFormat format(fname, FALSE);
m_format = &format;
- payloadCode = format.GetPayloadType();
+ payloadCode = (BYTE)format.GetPayloadType();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------->payloadCode = %d\n",(int)payloadCode);
}
-FSH323_ExternalRTPChannel::~FSH323_ExternalRTPChannel(){
- h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::~FSH323_ExternalRTPChannel %s [%p]\n",GetDirections[GetDirection()],this);
+FSH323_ExternalRTPChannel::~FSH323_ExternalRTPChannel()
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::~FSH323_ExternalRTPChannel %s [%p]\n",GetDirections[GetDirection()],this);
if (m_rtp_resetting) {
switch_core_session_unlock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_read [%p]\n",m_fsSession);
switch_core_session_unlock_codec_write(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_write [%p]\n",m_fsSession);
}
-
}
-PBoolean FSH323_ExternalRTPChannel::Start(){
+PBoolean FSH323_ExternalRTPChannel::Start()
+{
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_mutex);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::Start() [%p]\n",this);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::Start() [%p]\n",this);
+
const char *err = NULL;
switch_rtp_flag_t flags;
char * timer_name = NULL;
const char *var;
-
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->m_sessionID = %d m_active_sessionID = %d\n",sessionID,m_conn->m_active_sessionID);
- if (!(m_conn && H323_ExternalRTPChannel::Start())){
+ if (!(m_conn && H323_ExternalRTPChannel::Start())) {
switch_mutex_unlock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
return false;
}
- if ((tech_pvt->me == NULL)||((tech_pvt->me != NULL) && tech_pvt->me->m_channel_hangup)){
+ if ((tech_pvt->me == NULL) || ((tech_pvt->me != NULL) && tech_pvt->me->m_channel_hangup)) {
switch_mutex_unlock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
return false;
}
- if ((m_conn->m_active_sessionID != 0) && (m_conn->m_active_sessionID != sessionID)){
+ if ((m_conn->m_active_sessionID != 0) && (m_conn->m_active_sessionID != sessionID)) {
if (switch_core_codec_ready(&tech_pvt->read_codec) || switch_core_codec_ready(&tech_pvt->write_codec)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->Changing Codec to %s\n",(const char*)GetH245CodecName(m_capability));
- m_conn->m_rxChennel = false;
- m_conn->m_txChennel = false;
+ m_conn->m_rxChannel = false;
+ m_conn->m_txChannel = false;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_lock_codec_read [%p]\n",m_fsSession);
switch_core_session_lock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_lock_codec_write [%p]\n",m_fsSession);
switch_core_session_lock_codec_write(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_io_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_io_mutex);
- switch_clear_flag_locked(tech_pvt, TFLAG_IO);
+ switch_clear_flag_locked(tech_pvt, TFLAG_IO);
switch_mutex_unlock(tech_pvt->h323_io_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_io_mutex_unlock\n");
m_conn->m_rtp_resetting = 1;
@@ -1674,8 +1910,13 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
}
}
m_conn->m_active_sessionID = sessionID;
- bool isAudio;
+ bool isAudio = false;
+ switch_codec_t *codec = NULL;
unsigned m_codec_ms = m_capability->GetTxFramesInPacket();
+
+ if (mod_h323_globals.ptime_override_value > -1)
+ m_codec_ms = mod_h323_globals.ptime_override_value;
+
switch (m_capability->GetMainType()){
case H323Capability::e_Audio:{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------------->H323Capability::e_Audio\n");
@@ -1696,7 +1937,6 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
}
default:break;
}
- H323Codec *codec = GetCodec();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->GetFrameSize() return = %u\n",(unsigned)m_format->GetFrameSize());
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->GetFrameTime() return = %u\n",m_format->GetFrameTime());
@@ -1705,73 +1945,77 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->m_capability->GetFormatName() return = %s\n",(const char*)(m_capability->GetFormatName()));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->GetH245CodecName() return = %s\n",(const char*)GetH245CodecName(m_capability));
- if (GetDirection() == IsReceiver){
- m_switchCodec = isAudio ? &tech_pvt->read_codec : &tech_pvt->vid_read_codec;
- m_switchTimer = isAudio ? &tech_pvt->read_timer : &tech_pvt->vid_read_timer;
- m_conn->m_rxChennel = true;
- }else{
- m_switchCodec = isAudio ? &tech_pvt->write_codec : &tech_pvt->vid_write_codec;
- m_conn->m_txChennel = true;
- if (m_conn->m_callOnPreAnswer){
- m_switchCodec = isAudio ? &tech_pvt->read_codec : &tech_pvt->vid_read_codec;
- m_switchTimer = isAudio ? &tech_pvt->read_timer : &tech_pvt->vid_read_timer;
+ if (GetDirection() == IsReceiver) {
+ codec = isAudio ? &tech_pvt->read_codec : &tech_pvt->vid_read_codec;
+ //m_switchTimer = isAudio ? &tech_pvt->read_timer : &tech_pvt->vid_read_timer;
+ m_conn->m_rxChannel = true;
+ } else {
+ codec = isAudio ? &tech_pvt->write_codec : &tech_pvt->vid_write_codec;
+ m_conn->m_txChannel = true;
+ if (m_conn->m_callOnPreAnswer) {
+ codec = isAudio ? &tech_pvt->read_codec : &tech_pvt->vid_read_codec;
+ //m_switchTimer = isAudio ? &tech_pvt->read_timer : &tech_pvt->vid_read_timer;
}
}
- if (switch_core_codec_init(m_switchCodec, GetH245CodecName(m_capability), NULL, // FMTP
- 8000, m_codec_ms, 1, // Channels
- SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, // Settings
- switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) {
+ tech_pvt->read_frame.codec = &tech_pvt->read_codec; /* Set codec here - no need to set it every time a frame is read */
+
+ if (switch_core_codec_init(codec, GetH245CodecName(m_capability), NULL, // FMTP
+ 8000, m_codec_ms, 1, // Channels
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, // Settings
+ switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) {
- if (switch_core_codec_init(m_switchCodec, GetH245CodecName(m_capability), NULL, // FMTP
- 8000, 0, 1, // Channels
- SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, // Settings
- switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) {
+ if (switch_core_codec_init(codec, GetH245CodecName(m_capability), NULL, // FMTP
+ 8000, 0, 1, // Channels
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, // Settings
+ switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) {
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"%s Cannot initialise %s %s codec for connection [%p]\n",switch_channel_get_name(m_fsChannel), ((GetDirection() == IsReceiver)? " read" : " write")
, GetMainTypes[m_capability->GetMainType()],(const char*)(m_capability->GetFormatName()),this);
- switch_channel_hangup(m_fsChannel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
+ switch_channel_hangup(m_fsChannel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
switch_mutex_unlock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
- return false;
- }
+ return false;
+ }
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"%s Unsupported ptime of %u on %s %s codec %s for connection [%p]\n",switch_channel_get_name(m_fsChannel),m_codec_ms,((GetDirection() == IsReceiver)? " read" : " write")
- ,GetMainTypes[m_capability->GetMainType()],(const char*)(m_capability->GetFormatName()),this);
- }
+ , GetMainTypes[m_capability->GetMainType()],(const char*)(m_capability->GetFormatName()),this);
+ }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"%s initialise %s codec %s for connection [%p]\n",switch_channel_get_name(m_fsChannel),((GetDirection() == IsReceiver)? " read" : " write")
- ,GetMainTypes[m_capability->GetMainType()],(const char*)(m_capability->GetFormatName()),this);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"%s initialise %s codec %s for connection [%p]\n",switch_channel_get_name(m_fsChannel),((GetDirection() == IsReceiver)? " read" : " write")
+ , GetMainTypes[m_capability->GetMainType()],(const char*)(m_capability->GetFormatName()),this);
-
- if (GetDirection() == IsReceiver) {
- m_readFrame.rate = tech_pvt->read_codec.implementation->actual_samples_per_second;
-
- if (isAudio) {
- switch_core_session_set_read_codec(m_fsSession, m_switchCodec);
- if (switch_core_timer_init(m_switchTimer,
- "soft",
- m_switchCodec->implementation->microseconds_per_packet / 1000,
- m_switchCodec->implementation->samples_per_packet,
- switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) {
- switch_core_codec_destroy(m_switchCodec);
- m_switchCodec = NULL;
+ if (GetDirection() == IsReceiver) {
+ //m_readFrame.rate = tech_pvt->read_codec.implementation->actual_samples_per_second;
+
+ if (isAudio) {
+ switch_core_session_set_read_codec(m_fsSession, codec);
+ /*if (switch_core_timer_init(m_switchTimer,
+ "soft",
+ codec->implementation->microseconds_per_packet / 1000,
+ codec->implementation->samples_per_packet,
+ switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) {
+
+ switch_core_codec_destroy(codec);
+ codec = NULL;
switch_mutex_unlock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
- return false;
- }
- switch_channel_set_variable(m_fsChannel,"timer_name","soft");
- if (m_conn->m_ChennelProgress)
- switch_core_session_set_write_codec(m_fsSession, m_switchCodec);
- } else {
- switch_core_session_set_video_read_codec(m_fsSession, m_switchCodec);
- switch_channel_set_flag(m_fsChannel, CF_VIDEO);
- }
- } else {
- if (isAudio) {
- switch_core_session_set_write_codec(m_fsSession, m_switchCodec);
+ return false;
+ }
+ switch_channel_set_variable(m_fsChannel,"timer_name", "soft");*/
+ if (m_conn->m_ChannelProgress)
+ switch_core_session_set_write_codec(m_fsSession, codec);
+ } else {
+ switch_core_session_set_video_read_codec(m_fsSession, codec);
+ switch_channel_set_flag(m_fsChannel, CF_VIDEO);
+ }
+ } else {
+ if (isAudio) {
+ switch_core_session_set_write_codec(m_fsSession, codec);
if (m_conn->m_callOnPreAnswer){
- m_readFrame.rate = tech_pvt->read_codec.implementation->actual_samples_per_second;
- switch_core_session_set_read_codec(m_fsSession, m_switchCodec);
- if (switch_core_timer_init(m_switchTimer,
+ //m_readFrame.rate = tech_pvt->read_codec.implementation->actual_samples_per_second;
+ switch_core_session_set_read_codec(m_fsSession, codec);
+ /*if (switch_core_timer_init(m_switchTimer,
"soft",
m_switchCodec->implementation->microseconds_per_packet / 1000,
m_switchCodec->implementation->samples_per_packet,
@@ -1782,26 +2026,26 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
return false;
}
- switch_channel_set_variable(m_fsChannel,"timer_name","soft");
+ switch_channel_set_variable(m_fsChannel,"timer_name","soft");*/
}
- } else {
- switch_core_session_set_video_write_codec(m_fsSession, m_switchCodec);
- switch_channel_set_flag(m_fsChannel, CF_VIDEO);
- }
- }
+ } else {
+ switch_core_session_set_video_write_codec(m_fsSession, codec);
+ switch_channel_set_flag(m_fsChannel, CF_VIDEO);
+ }
+ }
-// PTRACE(4, "mod_h323\tSet " << ((GetDirection() == IsReceiver)? " read" : " write") << ' '
-// << m_capability->GetMainType() << " codec to << " << m_capability << " for connection " << *this);
+// PTRACE(4, "mod_h323\tSet " << ((GetDirection() == IsReceiver)? " read" : " write") << ' '
+// << m_capability->GetMainType() << " codec to << " << m_capability << " for connection " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Set %s %s codec to %s for connection [%p]\n",((GetDirection() == IsReceiver)? " read" : " write")
,GetMainTypes[m_capability->GetMainType()],(const char*)m_capability->GetFormatName(),this);
PIPSocket::Address remoteIpAddress;
- GetRemoteAddress(remoteIpAddress,m_RTPremotePort);
+ GetRemoteAddress(remoteIpAddress,m_RTPremotePort);
m_RTPremoteIP = (const char *)remoteIpAddress.AsString();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->tech_pvt->rtp_session = [%p]\n",tech_pvt->rtp_session);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->samples_per_packet = %lu\n",m_switchCodec->implementation->samples_per_packet);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->actual_samples_per_second = %lu\n",m_switchCodec->implementation->actual_samples_per_second);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->samples_per_packet = %lu\n", codec->implementation->samples_per_packet);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->actual_samples_per_second = %lu\n", codec->implementation->actual_samples_per_second);
bool ch_port = false;
if (tech_pvt->rtp_session != NULL){
@@ -1824,25 +2068,35 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
if ((!m_conn->m_startRTP)) {
flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_DATAWAIT|SWITCH_RTP_FLAG_AUTO_CNG|SWITCH_RTP_FLAG_RAW_WRITE);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->timer_name = %s\n",switch_channel_get_variable(m_fsChannel, "timer_name"));
- if ((var = switch_channel_get_variable(m_fsChannel, "timer_name"))) {
- timer_name = (char *) var;
+
+ if (mod_h323_globals.use_rtp_timer) {
+ flags |= SWITCH_RTP_FLAG_USE_TIMER;
+ timer_name = mod_h323_globals.rtp_timer_name;
+ } else {
+ if ((var = switch_channel_get_variable(m_fsChannel, "timer_name"))) {
+ timer_name = (char *) var;
+ flags |= SWITCH_RTP_FLAG_USE_TIMER;
+ }
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->timer_name = %s\n",timer_name);
+
+ if (timer_name)
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->timer_name = %s\n", timer_name);
+
tech_pvt->rtp_session = switch_rtp_new((const char *)m_RTPlocalIP,
- m_RTPlocalPort,
- (const char *)m_RTPremoteIP,
- m_RTPremotePort,
- (switch_payload_t)payloadCode,
- m_switchCodec->implementation->samples_per_packet,
- m_codec_ms * 1000,
- (switch_rtp_flag_t) flags, timer_name, &err,
- switch_core_session_get_pool(m_fsSession));
+ m_RTPlocalPort,
+ (const char *)m_RTPremoteIP,
+ m_RTPremotePort,
+ (switch_payload_t)payloadCode,
+ codec->implementation->samples_per_packet,
+ codec->implementation->microseconds_per_packet,
+ flags, timer_name, &err,
+ switch_core_session_get_pool(m_fsSession));
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------------->tech_pvt->rtp_session = %p\n",tech_pvt->rtp_session);
m_conn->m_startRTP = true;
if (switch_rtp_ready(tech_pvt->rtp_session)) {
switch_channel_set_flag(m_fsChannel, CF_FS_RTP);
- }else{
+ } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", switch_str_nil(err));
switch_channel_hangup(m_fsChannel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
switch_mutex_unlock(tech_pvt->h323_mutex);
@@ -1850,6 +2104,7 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
return SWITCH_STATUS_FALSE;
}
}
+
if (ch_port){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_io_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_io_mutex);
@@ -1859,8 +2114,8 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
switch_core_session_unlock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_read [%p]\n",m_fsSession);
}
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->External RTP address %s:%u\n",(const char*)m_RTPremoteIP,m_RTPremotePort);
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->External RTP address %s:%u\n",(const char*)m_RTPremoteIP,m_RTPremotePort);
if (GetDirection() == IsReceiver) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_io_mutex_lock\n");
@@ -1871,35 +2126,35 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
}
if (m_conn->m_rtp_resetting) {
- if (GetDirection() == IsReceiver){
+ if (GetDirection() == IsReceiver) {
switch_core_session_unlock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_read [%p]\n",m_fsSession);
- }else{
+ } else {
switch_core_session_unlock_codec_write(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_write [%p]\n",m_fsSession);
- if (m_conn->m_callOnPreAnswer){
+ if (m_conn->m_callOnPreAnswer) {
switch_core_session_unlock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_read [%p]\n",m_fsSession);
}
}
}
- if (GetDirection() == IsReceiver) m_conn->m_rxAudioOpened.Signal();
- else m_conn->m_txAudioOpened.Signal();
+ if (GetDirection() == IsReceiver)
+ m_conn->m_rxAudioOpened.Signal();
+ else
+ m_conn->m_txAudioOpened.Signal();
- if ( m_conn->m_ChennelAnswer && m_conn->m_rxChennel && m_conn->m_txChennel){
- switch_channel_mark_answered(m_fsChannel);
- }
+ if (m_conn->m_ChannelAnswer && m_conn->m_rxChannel && m_conn->m_txChannel)
+ switch_channel_mark_answered(m_fsChannel);
- if ((m_conn->m_ChennelProgress && m_conn->m_rxChennel)||(m_conn->m_callOnPreAnswer && m_conn->m_txChennel)){
+ if ((m_conn->m_ChannelProgress && m_conn->m_rxChannel)||(m_conn->m_callOnPreAnswer && m_conn->m_txChannel))
switch_channel_mark_pre_answered(m_fsChannel);
- }
-
- if ((m_capability->GetMainType() == H323Capability::e_Data) && m_conn->m_rxChennel && m_conn->m_txChennel ) {
+
+ if (m_capability->GetMainType() == H323Capability::e_Data && m_conn->m_rxChannel && m_conn->m_txChannel) {
const char *uuid = switch_channel_get_variable(m_fsChannel, SWITCH_SIGNAL_BOND_VARIABLE);
if (uuid != NULL){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------------->switch_rtp_udptl_mode\n");
- switch_rtp_udptl_mode(tech_pvt->rtp_session);
+ switch_rtp_udptl_mode(tech_pvt->rtp_session);
switch_core_session_message_t msg = { 0 };
msg.from = switch_channel_get_name(m_fsChannel);
msg.message_id = SWITCH_MESSAGE_INDICATE_UDPTL_MODE;
@@ -1908,96 +2163,101 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
switch_mutex_unlock(tech_pvt->h323_mutex);
+
return true;
}
-
-PBoolean FSH323_ExternalRTPChannel::OnReceivedPDU(
- const H245_H2250LogicalChannelParameters& param,
- unsigned& errorCode){
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::OnReceivedPDU [%p]\n",this);
+PBoolean FSH323_ExternalRTPChannel::OnReceivedPDU(const H245_H2250LogicalChannelParameters& param, unsigned& errorCode)
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::OnReceivedPDU [%p]\n",this);
- if (!H323_ExternalRTPChannel::OnReceivedPDU(param,errorCode))
+ if (!H323_ExternalRTPChannel::OnReceivedPDU(param,errorCode))
return true;
- PIPSocket::Address remoteIpAddress;
- WORD remotePort;
- GetRemoteAddress(remoteIpAddress,remotePort);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Remote RTP address %s:%u\n",(const char *)remoteIpAddress.AsString(),remotePort);
- m_conn->setRemoteAddress((const char *)remoteIpAddress.AsString(), remotePort);
- return true;
+ PIPSocket::Address remoteIpAddress;
+ WORD remotePort;
+ GetRemoteAddress(remoteIpAddress,remotePort);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Remote RTP address %s:%u\n",(const char *)remoteIpAddress.AsString(),remotePort);
+ m_conn->setRemoteAddress((const char *)remoteIpAddress.AsString(), remotePort);
+ return true;
}
-PBoolean FSH323_ExternalRTPChannel::OnSendingPDU(H245_H2250LogicalChannelParameters& param){
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"FSH323_ExternalRTPChannel::OnSendingPDU [%p]\n",this);
- return H323_ExternalRTPChannel::OnSendingPDU(param);
+PBoolean FSH323_ExternalRTPChannel::OnSendingPDU(H245_H2250LogicalChannelParameters& param)
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"FSH323_ExternalRTPChannel::OnSendingPDU [%p]\n",this);
+ return H323_ExternalRTPChannel::OnSendingPDU(param);
}
-PBoolean FSH323_ExternalRTPChannel::OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters& param){
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::OnReceivedAckPDU [%p]\n",this);
- return H323_ExternalRTPChannel::OnReceivedAckPDU(param);
+PBoolean FSH323_ExternalRTPChannel::OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters& param)
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::OnReceivedAckPDU [%p]\n",this);
+ return H323_ExternalRTPChannel::OnReceivedAckPDU(param);
}
-void FSH323_ExternalRTPChannel::OnSendOpenAck(H245_H2250LogicalChannelAckParameters& param){
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::OnSendOpenAck [%p]\n",this);
- H323_ExternalRTPChannel::OnSendOpenAck(param);
+void FSH323_ExternalRTPChannel::OnSendOpenAck(H245_H2250LogicalChannelAckParameters& param)
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::OnSendOpenAck [%p]\n",this);
+ H323_ExternalRTPChannel::OnSendOpenAck(param);
}
-FSH323Connection * FSH323EndPoint::FSMakeCall(const PString & dest, void *userData){
+FSH323Connection * FSH323EndPoint::FSMakeCall(const PString & dest, void *userData)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::FSMakeCall DST NUMBER = %s [%p]\n",(const char*)dest,this);
FSH323Connection * connection;
PString token;
H323Transport *transport = NULL;
- if (listeners.GetSize() > 0) {
- H323TransportAddress taddr = listeners[0].GetTransportAddress();
- PIPSocket::Address addr;
- WORD port;
- if (taddr.GetIpAndPort(addr, port)) {
- if (addr) {
- transport = new H323TransportTCP(*this, addr,false);
- if (!transport)
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----> Unable to create transport for outgoing call\n");
- }
- } else
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----> Unable to get address and port\n");
+ if (listeners.GetSize() > 0) {
+ H323TransportAddress taddr = listeners[0].GetTransportAddress();
+ PIPSocket::Address addr;
+ WORD port;
+ if (taddr.GetIpAndPort(addr, port)) {
+ if (addr) {
+ transport = new H323TransportTCP(*this, addr,false);
+ if (!transport)
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----> Unable to create transport for outgoing call\n");
+ }
+ } else
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----> Unable to get address and port\n");
}
- if (!(connection = (FSH323Connection *)H323EndPoint::MakeCall(dest, token, userData))) {
- return NULL;
- }
+ if (!(connection = (FSH323Connection *)H323EndPoint::MakeCall(dest, token, userData))) {
+ return NULL;
+ }
+
return connection;
}
-
static switch_call_cause_t create_outgoing_channel(switch_core_session_t *session,
switch_event_t *var_event,
switch_caller_profile_t *outbound_profile,
- switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause){
+ switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>create_outgoing_channel DST NUMBER = %s\n",outbound_profile->destination_number);
FSH323Connection * connection;
- if (h323_process == NULL) {
- return SWITCH_CAUSE_CRASH;
- }
+ if (h323_process == NULL) {
+ return SWITCH_CAUSE_CRASH;
+ }
FSH323EndPoint & ep = h323_process->GetH323EndPoint();
if (!(connection = ep.FSMakeCall(outbound_profile->destination_number,outbound_profile))){
return SWITCH_CAUSE_PROTOCOL_ERROR;
}
- *new_session = connection->GetSession();
+ *new_session = connection->GetSession();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"--------->GetSession() return = [%p]\n",connection->GetSession());
- return SWITCH_CAUSE_SUCCESS;
+ return SWITCH_CAUSE_SUCCESS;
}
-static switch_status_t on_destroy(switch_core_session_t *session){
+static switch_status_t on_destroy(switch_core_session_t *session)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>on_destroy\n");
- h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(session);
+ h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(session);
- if (tech_pvt) {
+ if (tech_pvt) {
if (tech_pvt->read_codec.implementation) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
@@ -2016,20 +2276,23 @@ static switch_status_t on_destroy(switch_core_session_t *session){
if (tech_pvt->vid_read_timer.timer_interface) {
switch_core_timer_destroy(&tech_pvt->vid_read_timer);
}
- }
+ }
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t on_hangup(switch_core_session_t *session){
+static switch_status_t on_hangup(switch_core_session_t *session)
+{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>switch_status_t on_hangup [%p]\n",session);
+
+ switch_channel_t *channel = switch_core_session_get_channel(session);
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(session);
-
-
- switch_channel_t *channel = switch_core_session_get_channel(session);
- if (tech_pvt->me) {
- if (tech_pvt->me->m_rtp_resetting == 1) {
+ FSH323Connection *me = tech_pvt->me;
+ tech_pvt->me = NULL;
+
+ if (me) {
+ if (me->m_rtp_resetting == 1) {
switch_core_session_unlock_codec_read(session);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_read [%p]\n",session);
switch_core_session_unlock_codec_write(session);
@@ -2037,46 +2300,39 @@ static switch_status_t on_hangup(switch_core_session_t *session){
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_mutex);
- tech_pvt->me->m_channel_hangup = true;
+ me->m_channel_hangup = true;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
switch_mutex_unlock(tech_pvt->h323_mutex);
- if (tech_pvt->me->TryLock() == 1){
- tech_pvt->me->CloseAllLogicalChannels(true);
- tech_pvt->me->CloseAllLogicalChannels(false);
- tech_pvt->me->Unlock();
- }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----->%s\n",(const char *)(tech_pvt->me->GetCallToken()));
- Q931::CauseValues cause = (Q931::CauseValues)switch_channel_get_cause_q850(channel);
- int trylock = tech_pvt->me->TryLock();
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> () = %d\n",trylock);
- if (trylock == 1){
- const PString currentToken(tech_pvt->me->GetCallToken());
- FSH323Connection *connection = (FSH323Connection *)tech_pvt->me->GetEndPoint()->FindConnectionWithLock(currentToken);
+ if (me->TryLock() == 1) {
+ me->CloseAllLogicalChannels(true);
+ me->CloseAllLogicalChannels(false);
+ me->Unlock();
+ }
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----->%s\n",(const char *)(me->GetCallToken()));
+ Q931::CauseValues cause = (Q931::CauseValues)switch_channel_get_cause_q850(channel);
+ int trylock = me->TryLock();
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> () = %d\n",trylock);
+ if (trylock == 1) {
+ const PString currentToken(me->GetCallToken());
+ FSH323Connection *connection = (FSH323Connection *)me->GetEndPoint()->FindConnectionWithLock(currentToken);
connection->Unlock();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> UnLock()\n");
- tech_pvt->me->Unlock();
+ me->Unlock();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> UnLock()\n");
- }else if (trylock == -1){
- tech_pvt->me->Unlock();
+ } else if (trylock == -1) {
+ me->Unlock();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> UnLock()\n");
}
- tech_pvt->me->SetQ931Cause(cause);
- tech_pvt->me->ClearCallSynchronous(NULL, H323TranslateToCallEndReason(cause, UINT_MAX));
- tech_pvt->me = NULL;
+ me->SetQ931Cause(cause);
+ me->ClearCallSynchronous(NULL, H323TranslateToCallEndReason(cause, UINT_MAX));
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_lock\n");
// switch_mutex_lock(tech_pvt->h323_mutex);
- }
+ }
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
switch_mutex_unlock(tech_pvt->h323_mutex);
- return SWITCH_STATUS_SUCCESS;
+
+ return SWITCH_STATUS_SUCCESS;
}
-
-
-
-
-
-
-
-
diff --git a/src/mod/endpoints/mod_h323/mod_h323.h b/src/mod/endpoints/mod_h323/mod_h323.h
index 9d8369ddfc..a88abf5301 100644
--- a/src/mod/endpoints/mod_h323/mod_h323.h
+++ b/src/mod/endpoints/mod_h323/mod_h323.h
@@ -1,4 +1,30 @@
-
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005-2010, Anthony Minessale II
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * Anthony Minessale II
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ *
+ * mod_h323.h -- H323 endpoint
+ *
+ */
#if defined(__GNUC__) && defined(HAVE_VISIBILITY)
#pragma GCC visibility push(default)
@@ -39,34 +65,34 @@ const char* const GetDirections[H323Channel::NumDirections+1] = {
};
const char * const PayloadTypesNames[RTP_DataFrame::LastKnownPayloadType] = {
- "PCMU",
- "FS1016",
- "G721",
- "GSM",
- "G7231",
- "DVI4_8k",
- "DVI4_16k",
- "LPC",
- "PCMA",
- "G722",
- "L16_Stereo",
- "L16_Mono",
- "G723",
- "CN",
- "MPA",
- "G728",
- "DVI4_11k",
- "DVI4_22k",
- "G729",
- "CiscoCN",
- NULL, NULL, NULL, NULL, NULL,
- "CelB",
- "JPEG",
- NULL, NULL, NULL, NULL,
- "H261",
- "MPV",
- "MP2T",
- "H263"
+ "PCMU",
+ "FS1016",
+ "G721",
+ "GSM",
+ "G7231",
+ "DVI4_8k",
+ "DVI4_16k",
+ "LPC",
+ "PCMA",
+ "G722",
+ "L16_Stereo",
+ "L16_Mono",
+ "G723",
+ "CN",
+ "MPA",
+ "G728",
+ "DVI4_11k",
+ "DVI4_22k",
+ "G729",
+ "CiscoCN",
+ NULL, NULL, NULL, NULL, NULL,
+ "CelB",
+ "JPEG",
+ NULL, NULL, NULL, NULL,
+ "H261",
+ "MPV",
+ "MP2T",
+ "H263"
};
@@ -94,7 +120,6 @@ const char* const GetMainTypes[H323Capability::e_NumMainTypes+1] = {
"NumMainTypes"
};
-
extern void SetT38_IFP_PRE();
class OpalMediaFormat;
class H245_T38FaxProfile;
@@ -133,6 +158,9 @@ struct mod_h323_globals {
char *codec_string;
char *context;
char *dialplan;
+ int use_rtp_timer;
+ char *rtp_timer_name;
+ int ptime_override_value;
};
extern struct mod_h323_globals mod_h323_globals;
@@ -161,24 +189,27 @@ typedef struct {
#define DECLARE_CALLBACK0(name) \
static switch_status_t name(switch_core_session_t *session) { \
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(session); \
- return tech_pvt && tech_pvt->me != NULL ? tech_pvt->me->name() : SWITCH_STATUS_FALSE; } \
+ FSH323Connection *me = (tech_pvt && tech_pvt->me != NULL) ? tech_pvt->me : NULL; \
+ return me != NULL ? me->name() : SWITCH_STATUS_FALSE; } \
switch_status_t name()
#define DECLARE_CALLBACK1(name, type1, name1) \
static switch_status_t name(switch_core_session_t *session, type1 name1) { \
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(session); \
- return tech_pvt && tech_pvt->me != NULL ? tech_pvt->me->name(name1) : SWITCH_STATUS_FALSE; } \
+ FSH323Connection *me = (tech_pvt && tech_pvt->me != NULL) ? tech_pvt->me : NULL; \
+ return me != NULL ? me->name(name1) : SWITCH_STATUS_FALSE; } \
switch_status_t name(type1 name1)
#define DECLARE_CALLBACK3(name, type1, name1, type2, name2, type3, name3) \
static switch_status_t name(switch_core_session_t *session, type1 name1, type2 name2, type3 name3) { \
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(session); \
- return tech_pvt && tech_pvt->me != NULL ? tech_pvt->me->name(name1, name2, name3) : SWITCH_STATUS_FALSE; } \
+ FSH323Connection *me = (tech_pvt && tech_pvt->me != NULL) ? tech_pvt->me : NULL; \
+ return me != NULL ? me->name(name1, name2, name3) : SWITCH_STATUS_FALSE; } \
switch_status_t name(type1 name1, type2 name2, type3 name3)
class FSH323EndPoint;
-class FSProcess:public PLibraryProcess {
- PCLASSINFO(FSProcess, PLibraryProcess);
+class FSProcess:public PProcess {
+ PCLASSINFO(FSProcess, PProcess);
public:
FSProcess();
@@ -186,6 +217,8 @@ class FSProcess:public PLibraryProcess {
bool Initialise(switch_loadable_module_interface_t *iface);
+ void Main()
+ { }
FSH323EndPoint & GetH323EndPoint() const {
return *m_h323endpoint;
} protected:
@@ -193,8 +226,9 @@ class FSProcess:public PLibraryProcess {
};
struct FSListener {
- FSListener() {
- } PString name;
+ FSListener()
+ { }
+ PString name;
H323ListenerTCP *listenAddress;
PString localUserName;
PString gatekeeper;
@@ -210,13 +244,12 @@ class FSH323EndPoint:public H323EndPoint {
~FSH323EndPoint();
- /**Create a connection that uses the specified call.
- */
+ /* Create a connection that uses the specified call. */
virtual H323Connection *CreateConnection(unsigned callReference, void *userData, H323Transport * transport, H323SignalPDU * setupPDU);
virtual bool OnSetGatewayPrefixes(PStringList & prefixes) const;
bool Initialise(switch_loadable_module_interface_t *iface);
-
+
switch_status_t ReadConfig(int reload);
void StartGkClient(int retry, PString * gkAddress, PString * gkIdentifer, PString * gkInterface);
@@ -224,8 +257,9 @@ class FSH323EndPoint:public H323EndPoint {
switch_endpoint_interface_t *GetSwitchInterface() const {
return m_freeswitch;
- } FSH323Connection *FSMakeCall(const PString & dest, void *userData);
- list < FSListener > m_listeners;
+ }
+ FSH323Connection *FSMakeCall(const PString & dest, void *userData);
+ list < FSListener > m_listeners;
int m_ai;
int m_pi;
protected:
@@ -274,8 +308,8 @@ class FSH323Connection:public H323Connection {
~FSH323Connection();
virtual H323Channel *CreateRealTimeLogicalChannel(const H323Capability & capability,
- H323Channel::Directions dir,
- unsigned sessionID, const H245_H2250LogicalChannelParameters * param, RTP_QOS * rtpqos = NULL);
+ H323Channel::Directions dir,
+ unsigned sessionID, const H245_H2250LogicalChannelParameters * param, RTP_QOS * rtpqos = NULL);
virtual PBoolean OnStartLogicalChannel(H323Channel & channel);
virtual PBoolean OnCreateLogicalChannel(const H323Capability & capability, H323Channel::Directions dir, unsigned &errorCode);
virtual bool OnReceivedSignalSetup(const H323SignalPDU & setupPDU);
@@ -313,32 +347,32 @@ class FSH323Connection:public H323Connection {
void CleanUpOnCall();
DECLARE_CALLBACK0(on_init);
- DECLARE_CALLBACK0(on_routing);
- DECLARE_CALLBACK0(on_execute);
- DECLARE_CALLBACK0(on_exchange_media);
- DECLARE_CALLBACK0(on_soft_execute);
- DECLARE_CALLBACK1(kill_channel, int, sig);
- DECLARE_CALLBACK1(send_dtmf, const switch_dtmf_t *, dtmf);
- DECLARE_CALLBACK1(receive_message, switch_core_session_message_t *, msg);
- DECLARE_CALLBACK1(receive_event, switch_event_t *, event);
- DECLARE_CALLBACK0(state_change);
+ DECLARE_CALLBACK0(on_routing);
+ DECLARE_CALLBACK0(on_execute);
+ DECLARE_CALLBACK0(on_exchange_media);
+ DECLARE_CALLBACK0(on_soft_execute);
+ DECLARE_CALLBACK1(kill_channel, int, sig);
+ DECLARE_CALLBACK1(send_dtmf, const switch_dtmf_t *, dtmf);
+ DECLARE_CALLBACK1(receive_message, switch_core_session_message_t *, msg);
+ DECLARE_CALLBACK1(receive_event, switch_event_t *, event);
+ DECLARE_CALLBACK0(state_change);
- DECLARE_CALLBACK3(read_audio_frame, switch_frame_t **, frame, switch_io_flag_t, flags, int, stream_id);
- DECLARE_CALLBACK3(write_audio_frame, switch_frame_t *, frame, switch_io_flag_t, flags, int, stream_id);
- DECLARE_CALLBACK3(read_video_frame, switch_frame_t **, frame, switch_io_flag_t, flag, int, stream_id);
- DECLARE_CALLBACK3(write_video_frame, switch_frame_t *, frame, switch_io_flag_t, flag, int, stream_id);
+ DECLARE_CALLBACK3(read_audio_frame, switch_frame_t **, frame, switch_io_flag_t, flags, int, stream_id);
+ DECLARE_CALLBACK3(write_audio_frame, switch_frame_t *, frame, switch_io_flag_t, flags, int, stream_id);
+ DECLARE_CALLBACK3(read_video_frame, switch_frame_t **, frame, switch_io_flag_t, flag, int, stream_id);
+ DECLARE_CALLBACK3(write_video_frame, switch_frame_t *, frame, switch_io_flag_t, flag, int, stream_id);
bool m_callOnPreAnswer;
bool m_startRTP;
- bool m_rxChennel;
- bool m_txChennel;
- bool m_ChennelAnswer;
- bool m_ChennelProgress;
+ bool m_rxChannel;
+ bool m_txChannel;
+ bool m_ChannelAnswer;
+ bool m_ChannelProgress;
unsigned char m_select_dtmf;
PSyncPoint m_rxAudioOpened;
PSyncPoint m_txAudioOpened;
unsigned m_active_sessionID;
- bool m_active_chennel_fax;
+ bool m_active_channel_fax;
int m_rtp_resetting;
bool m_isRequst_fax;
bool m_channel_hangup;
@@ -350,7 +384,7 @@ class FSH323Connection:public H323Connection {
switch_channel_t *m_fsChannel;
PIPSocket::Address m_RTPlocalIP;
WORD m_RTPlocalPort;
- unsigned char m_buf[SWITCH_RECOMMENDED_BUFFER_SIZE];
+ unsigned char m_buf[SWITCH_RECOMMENDED_BUFFER_SIZE];
};
@@ -358,10 +392,9 @@ class FSH323_ExternalRTPChannel:public H323_ExternalRTPChannel {
PCLASSINFO(FSH323_ExternalRTPChannel, H323_ExternalRTPChannel);
public:
/* Create a new channel. */
- FSH323_ExternalRTPChannel(FSH323Connection & connection,
- const H323Capability & capability, Directions direction, unsigned sessionID, const PIPSocket::Address & ip, WORD dataPort);
+ FSH323_ExternalRTPChannel(FSH323Connection & connection, const H323Capability & capability, Directions direction, unsigned sessionID, const PIPSocket::Address & ip, WORD dataPort);
/* Destructor */
- ~FSH323_ExternalRTPChannel();
+ ~FSH323_ExternalRTPChannel();
virtual PBoolean Start();
virtual PBoolean OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters & param);
@@ -375,15 +408,12 @@ class FSH323_ExternalRTPChannel:public H323_ExternalRTPChannel {
const H323Capability *m_capability;
switch_core_session_t *m_fsSession;
switch_channel_t *m_fsChannel;
- switch_codec_t *m_switchCodec;
OpalMediaFormat *m_format;
- switch_frame_t m_readFrame;
- switch_timer_t *m_switchTimer;
PString m_RTPremoteIP;
WORD m_RTPremotePort;
PString m_RTPlocalIP;
WORD m_RTPlocalPort;
- BYTE payloadCode;
+ BYTE payloadCode;
unsigned m_sessionID;
int m_rtp_resetting;
};
@@ -393,15 +423,20 @@ class BaseG7231Capab:public H323AudioCapability {
public:
BaseG7231Capab(const char *fname, bool annexA = true)
: H323AudioCapability(7, 4), m_name(fname), m_aa(annexA) {
- } virtual PObject *Clone() const {
+ }
+ virtual PObject *Clone() const {
return new BaseG7231Capab(*this);
- } virtual unsigned GetSubType() const {
+ }
+ virtual unsigned GetSubType() const {
return H245_AudioCapability::e_g7231;
- } virtual PString GetFormatName() const {
+ }
+ virtual PString GetFormatName() const {
return m_name;
- } virtual H323Codec *CreateCodec(H323Codec::Direction direction) const {
+ }
+ virtual H323Codec *CreateCodec(H323Codec::Direction direction) const {
return 0;
- } virtual Comparison Compare(const PObject & obj) const {
+ }
+ virtual Comparison Compare(const PObject & obj) const {
Comparison res = H323AudioCapability::Compare(obj);
if (res != EqualTo)
return res;
@@ -411,13 +446,15 @@ class BaseG7231Capab:public H323AudioCapability {
if (m_aa && !aa)
return GreaterThan;
return EqualTo;
- } virtual bool OnSendingPDU(H245_AudioCapability & pdu, unsigned packetSize) const {
+ }
+ virtual bool OnSendingPDU(H245_AudioCapability & pdu, unsigned packetSize) const {
pdu.SetTag(GetSubType());
H245_AudioCapability_g7231 & g7231 = pdu;
g7231.m_maxAl_sduAudioFrames = packetSize;
g7231.m_silenceSuppression = m_aa;
return true;
- } virtual bool OnReceivedPDU(const H245_AudioCapability & pdu, unsigned &packetSize) {
+ }
+ virtual bool OnReceivedPDU(const H245_AudioCapability & pdu, unsigned &packetSize) {
if (pdu.GetTag() != H245_AudioCapability::e_g7231)
return false;
const H245_AudioCapability_g7231 & g7231 = pdu;
@@ -440,13 +477,13 @@ class BaseG729Capab:public H323AudioCapability {
virtual PObject *Clone() const
{
return new BaseG729Capab(*this);
- }
+ }
virtual unsigned GetSubType() const {
return m_type;
- }
+ }
virtual PString GetFormatName() const {
return m_name;
- }
+ }
virtual H323Codec *CreateCodec(H323Codec::Direction direction) const {
return 0;
}
@@ -462,23 +499,29 @@ class BaseGSM0610Cap:public H323AudioCapability {
BaseGSM0610Cap(const char *fname, unsigned type = H245_AudioCapability::e_gsmFullRate)
: H323AudioCapability(24, 2), m_name(fname), m_type(type), m_comfortNoise(0), m_scrambled(0) {
- } virtual PObject *Clone() const {
+ }
+ virtual PObject *Clone() const {
return new BaseGSM0610Cap(*this);
- } virtual H323Codec *CreateCodec(H323Codec::Direction direction) const {
+ }
+ virtual H323Codec *CreateCodec(H323Codec::Direction direction) const {
return 0;
- } virtual unsigned GetSubType() const {
+ }
+ virtual unsigned GetSubType() const {
return H245_AudioCapability::e_gsmFullRate;
- } virtual PString GetFormatName() const {
+ }
+ virtual PString GetFormatName() const {
return m_name;
- } virtual bool OnSendingPDU(H245_AudioCapability & pdu, unsigned packetSize) const {
+ }
+ virtual bool OnSendingPDU(H245_AudioCapability & pdu, unsigned packetSize) const {
pdu.SetTag(H245_AudioCapability::e_gsmFullRate);
H245_GSMAudioCapability & gsm = pdu;
gsm.m_audioUnitSize = packetSize * 33;
gsm.m_comfortNoise = m_comfortNoise;
gsm.m_scrambled = m_scrambled;
return true;
- } virtual bool OnReceivedPDU(const H245_AudioCapability & pdu, unsigned &packetSize) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"==============>BaseGSM0610Cap::OnReceivedPDU [%p]\n",this);
+ }
+ virtual bool OnReceivedPDU(const H245_AudioCapability & pdu, unsigned &packetSize) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"==============>BaseGSM0610Cap::OnReceivedPDU [%p]\n", this);
if (pdu.GetTag() != H245_AudioCapability::e_gsmFullRate)
return false;
const H245_GSMAudioCapability & gsm = pdu;
@@ -537,9 +580,9 @@ H323Channel * FSH323_T38Capability::CreateChannel(
const H245_H2250LogicalChannelParameters * params) const
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"FSH323_T38Capability::CreateChannel %p sessionID= %u direction=%s [%p]\n"
- ,&connection
- ,sessionID
- ,GetDirections[direction]);
+ , &connection
+ , sessionID
+ , GetDirections[direction]);
return connection.CreateRealTimeLogicalChannel(*this, direction, sessionID, params);
}