re-factor, cleanup ODBC ifdefs, whitespace and comment cleanup.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6349 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-11-20 02:27:48 +00:00
parent 69c580316e
commit 50c2f14906
4 changed files with 64 additions and 156 deletions

View File

@ -54,7 +54,6 @@ typedef enum {
SWITCH_ODBC_STATE_CONNECTED, SWITCH_ODBC_STATE_CONNECTED,
SWITCH_ODBC_STATE_ERROR SWITCH_ODBC_STATE_ERROR
} switch_odbc_state_t; } switch_odbc_state_t;
typedef struct switch_odbc_handle switch_odbc_handle_t;
typedef enum { typedef enum {
SWITCH_ODBC_SUCCESS = 0, SWITCH_ODBC_SUCCESS = 0,

View File

@ -1047,7 +1047,7 @@ typedef struct switch_core_thread_session switch_core_thread_session_t;
typedef struct switch_codec_implementation switch_codec_implementation_t; typedef struct switch_codec_implementation switch_codec_implementation_t;
typedef struct switch_buffer switch_buffer_t; typedef struct switch_buffer switch_buffer_t;
typedef struct switch_codec_settings switch_codec_settings_t; typedef struct switch_codec_settings switch_codec_settings_t;
typedef struct switch_odbc_handle switch_odbc_handle_t;
typedef struct switch_io_routines switch_io_routines_t; typedef struct switch_io_routines switch_io_routines_t;
typedef struct switch_speech_handle switch_speech_handle_t; typedef struct switch_speech_handle switch_speech_handle_t;

View File

@ -254,17 +254,10 @@ struct sofia_profile {
uint32_t session_timeout; uint32_t session_timeout;
uint32_t max_proceeding; uint32_t max_proceeding;
uint32_t rtp_timeout_sec; uint32_t rtp_timeout_sec;
#ifdef SWITCH_HAVE_ODBC
char *odbc_dsn; char *odbc_dsn;
char *odbc_user; char *odbc_user;
char *odbc_pass; char *odbc_pass;
switch_odbc_handle_t *master_odbc; switch_odbc_handle_t *master_odbc;
#else
void *filler1;
void *filler2;
void *filler3;
void *filler4;
#endif
}; };
struct private_object { struct private_object {

View File

@ -67,7 +67,6 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
} }
} }
if (!sr) { if (!sr) {
sr = "sendrecv"; sr = "sendrecv";
} }
@ -182,7 +181,6 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=ptime:%d\n", ptime); snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=ptime:%d\n", ptime);
} }
if (switch_test_flag(tech_pvt, TFLAG_VIDEO) && tech_pvt->video_rm_encoding) { if (switch_test_flag(tech_pvt, TFLAG_VIDEO) && tech_pvt->video_rm_encoding) {
sofia_glue_tech_choose_video_port(tech_pvt); sofia_glue_tech_choose_video_port(tech_pvt);
if ((v_port = tech_pvt->adv_sdp_video_port)) { if ((v_port = tech_pvt->adv_sdp_video_port)) {
@ -190,7 +188,6 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
sofia_glue_tech_set_video_codec(tech_pvt, 0); sofia_glue_tech_set_video_codec(tech_pvt, 0);
/*****************************/ /*****************************/
if (tech_pvt->video_rm_encoding) { if (tech_pvt->video_rm_encoding) {
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->video_pt); snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->video_pt);
@ -208,7 +205,6 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
if (already_did[imp->ianacode]) { if (already_did[imp->ianacode]) {
continue; continue;
} }
already_did[imp->ianacode] = 1; already_did[imp->ianacode] = 1;
} }
@ -241,15 +237,13 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
if (already_did[imp->ianacode]) { if (already_did[imp->ianacode]) {
continue; continue;
} }
already_did[imp->ianacode] = 1; already_did[imp->ianacode] = 1;
} }
if (!rate) { if (!rate) {
rate = imp->samples_per_second; rate = imp->samples_per_second;
} }
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", imp->ianacode, imp->iananame, imp->samples_per_second); snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", imp->ianacode, imp->iananame, imp->samples_per_second);
if (imp->fmtp) { if (imp->fmtp) {
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", imp->ianacode, imp->fmtp); snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", imp->ianacode, imp->fmtp);
@ -258,7 +252,6 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
} }
} }
} }
/*****************************/
tech_pvt->local_sdp_str = switch_core_session_strdup(tech_pvt->session, buf); tech_pvt->local_sdp_str = switch_core_session_strdup(tech_pvt->session, buf);
} }
@ -278,7 +271,6 @@ void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt)
assert(tech_pvt->session != NULL); assert(tech_pvt->session != NULL);
if ((abs = switch_channel_get_variable(tech_pvt->channel, "absolute_codec_string"))) { if ((abs = switch_channel_get_variable(tech_pvt->channel, "absolute_codec_string"))) {
codec_string = abs; codec_string = abs;
} else { } else {
@ -308,14 +300,10 @@ void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt)
} }
} else { } else {
tech_pvt->num_codecs = tech_pvt->num_codecs =
switch_loadable_module_get_codecs(tech_pvt->codecs, switch_loadable_module_get_codecs(tech_pvt->codecs, sizeof(tech_pvt->codecs) / sizeof(tech_pvt->codecs[0]));
sizeof(tech_pvt->codecs) / sizeof(tech_pvt->codecs[0]));
} }
end: end:
sofia_glue_check_video_codecs(tech_pvt); sofia_glue_check_video_codecs(tech_pvt);
} }
void sofia_glue_check_video_codecs(private_object_t *tech_pvt) void sofia_glue_check_video_codecs(private_object_t *tech_pvt)
@ -345,7 +333,6 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
switch_core_session_add_stream(session, NULL); switch_core_session_add_stream(session, NULL);
switch_mutex_lock(tech_pvt->flag_mutex); switch_mutex_lock(tech_pvt->flag_mutex);
switch_mutex_lock(profile->flag_mutex); switch_mutex_lock(profile->flag_mutex);
tech_pvt->flags = profile->flags; tech_pvt->flags = profile->flags;
@ -373,8 +360,6 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
snprintf(name, sizeof(name), "sofia/%s/%s", profile->name, channame); snprintf(name, sizeof(name), "sofia/%s/%s", profile->name, channame);
switch_channel_set_name(tech_pvt->channel, name); switch_channel_set_name(tech_pvt->channel, name);
//sofia_glue_tech_prepare_codecs(tech_pvt);
} }
switch_status_t sofia_glue_ext_address_lookup(char **ip, switch_port_t *port, char *sourceip, switch_memory_pool_t *pool) switch_status_t sofia_glue_ext_address_lookup(char **ip, switch_port_t *port, char *sourceip, switch_memory_pool_t *pool)
@ -402,14 +387,12 @@ switch_status_t sofia_glue_ext_address_lookup(char **ip, switch_port_t *port, ch
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt) switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt)
{ {
char *ip = tech_pvt->profile->rtpip; char *ip = tech_pvt->profile->rtpip;
switch_port_t sdp_port; switch_port_t sdp_port;
char tmp[50]; char tmp[50];
if (switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA) || tech_pvt->adv_sdp_audio_port) { if (switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA) || tech_pvt->adv_sdp_audio_port) {
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
@ -432,24 +415,19 @@ switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt)
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip); switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp); switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
switch_status_t sofia_glue_tech_choose_video_port(private_object_t *tech_pvt) switch_status_t sofia_glue_tech_choose_video_port(private_object_t *tech_pvt)
{ {
char *ip = tech_pvt->profile->rtpip; char *ip = tech_pvt->profile->rtpip;
switch_port_t sdp_port; switch_port_t sdp_port;
char tmp[50]; char tmp[50];
if (switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA) || tech_pvt->adv_sdp_video_port) { if (switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA) || tech_pvt->adv_sdp_video_port) {
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
tech_pvt->local_sdp_video_port = switch_rtp_request_port(); tech_pvt->local_sdp_video_port = switch_rtp_request_port();
sdp_port = tech_pvt->local_sdp_video_port; sdp_port = tech_pvt->local_sdp_video_port;
@ -466,7 +444,6 @@ switch_status_t sofia_glue_tech_choose_video_port(private_object_t *tech_pvt)
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip); switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, tmp); switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, tmp);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
@ -497,7 +474,6 @@ char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char
return new_uri; return new_uri;
} }
switch_status_t sofia_glue_do_invite(switch_core_session_t *session) switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
{ {
char *rpid = NULL; char *rpid = NULL;
@ -544,11 +520,8 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
cid_num, cid_num,
!switch_strlen_zero(cid_num) ? "@" : "", !switch_strlen_zero(cid_num) ? "@" : "",
tech_pvt->profile->extsipip ? tech_pvt->profile->extsipip : tech_pvt->profile->sipip); tech_pvt->profile->extsipip ? tech_pvt->profile->extsipip : tech_pvt->profile->sipip);
} }
assert(tech_pvt->from_str != NULL);
if ((alertbuf = switch_channel_get_variable(channel, "alert_info"))) { if ((alertbuf = switch_channel_get_variable(channel, "alert_info"))) {
alert_info = switch_core_session_sprintf(tech_pvt->session, "Alert-Info: %s", alertbuf); alert_info = switch_core_session_sprintf(tech_pvt->session, "Alert-Info: %s", alertbuf);
} }
@ -566,7 +539,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
switch_set_flag_locked(tech_pvt, TFLAG_READY); switch_set_flag_locked(tech_pvt, TFLAG_READY);
// forge a RPID for now KHR -- Should wrap this in an if statement so it can be turned on and off /* TODO: We should use the new tags for making an rpid and add profile options to turn this on/off */
if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) { if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) {
const char *priv = "off"; const char *priv = "off";
const char *screen = "no"; const char *screen = "no";
@ -652,7 +625,6 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
tech_pvt->sofia_private = sofia_private; tech_pvt->sofia_private = sofia_private;
switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(tech_pvt->sofia_private->uuid)); switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(tech_pvt->sofia_private->uuid));
nua_handle_bind(tech_pvt->nh, tech_pvt->sofia_private); nua_handle_bind(tech_pvt->nh, tech_pvt->sofia_private);
} }
if (tech_pvt->e_dest) { if (tech_pvt->e_dest) {
@ -691,7 +663,6 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
const char *hname = name + strlen(SOFIA_SIP_HEADER_PREFIX); const char *hname = name + strlen(SOFIA_SIP_HEADER_PREFIX);
stream.write_function(&stream, "%s: %s\r\n", hname, value); stream.write_function(&stream, "%s: %s\r\n", hname, value);
} }
} }
switch_channel_variable_last(channel); switch_channel_variable_last(channel);
} }
@ -717,16 +688,11 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE), SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE),
SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL), TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), SOATAG_HOLD(holdstr), TAG_END()); SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL), TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), SOATAG_HOLD(holdstr), TAG_END());
switch_safe_free(stream.data); switch_safe_free(stream.data);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
void sofia_glue_do_xfer_invite(switch_core_session_t *session) void sofia_glue_do_xfer_invite(switch_core_session_t *session)
{ {
private_object_t *tech_pvt; private_object_t *tech_pvt;
@ -741,20 +707,19 @@ void sofia_glue_do_xfer_invite(switch_core_session_t *session)
caller_profile = switch_channel_get_caller_profile(channel); caller_profile = switch_channel_get_caller_profile(channel);
if ((tech_pvt->from_str = switch_core_session_sprintf(session, "\"%s\" <sip:%s@%s>", if ((tech_pvt->from_str = switch_core_session_sprintf(session, "\"%s\" <sip:%s@%s>",
(char *) caller_profile->caller_id_name, caller_profile->caller_id_name,
(char *) caller_profile->caller_id_number, caller_profile->caller_id_number,
tech_pvt->profile->extsipip ? tech_pvt->profile->extsipip : tech_pvt->profile->sipip))) { tech_pvt->profile->extsipip ? tech_pvt->profile->extsipip : tech_pvt->profile->sipip))) {
const char *rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER); const char *rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER);
tech_pvt->nh2 = nua_handle(tech_pvt->profile->nua, NULL, tech_pvt->nh2 = nua_handle(tech_pvt->profile->nua, NULL,
SIPTAG_TO_STR(tech_pvt->dest), SIPTAG_FROM_STR(tech_pvt->from_str), SIPTAG_CONTACT_STR(tech_pvt->profile->url), SIPTAG_TO_STR(tech_pvt->dest),
SIPTAG_FROM_STR(tech_pvt->from_str),
SIPTAG_CONTACT_STR(tech_pvt->profile->url),
TAG_END()); TAG_END());
nua_handle_bind(tech_pvt->nh2, tech_pvt->sofia_private); nua_handle_bind(tech_pvt->nh2, tech_pvt->sofia_private);
nua_invite(tech_pvt->nh2, nua_invite(tech_pvt->nh2,
@ -764,7 +729,6 @@ void sofia_glue_do_xfer_invite(switch_core_session_t *session)
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
} }
} }
void sofia_glue_tech_absorb_sdp(private_object_t *tech_pvt) void sofia_glue_tech_absorb_sdp(private_object_t *tech_pvt)
@ -833,14 +797,12 @@ switch_status_t sofia_glue_tech_set_video_codec(private_object_t *tech_pvt, int
tech_pvt->video_read_codec.implementation->iananame, tech_pvt->video_rm_encoding); tech_pvt->video_read_codec.implementation->iananame, tech_pvt->video_rm_encoding);
switch_core_codec_destroy(&tech_pvt->video_read_codec); switch_core_codec_destroy(&tech_pvt->video_read_codec);
switch_core_codec_destroy(&tech_pvt->video_write_codec); switch_core_codec_destroy(&tech_pvt->video_write_codec);
//switch_core_session_reset(tech_pvt->session);
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Already using %s\n", tech_pvt->video_read_codec.implementation->iananame); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Already using %s\n", tech_pvt->video_read_codec.implementation->iananame);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
} }
if (!tech_pvt->video_rm_encoding) { if (!tech_pvt->video_rm_encoding) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec with no name?\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec with no name?\n");
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
@ -851,7 +813,6 @@ switch_status_t sofia_glue_tech_set_video_codec(private_object_t *tech_pvt, int
tech_pvt->video_rm_fmtp, tech_pvt->video_rm_fmtp,
tech_pvt->video_rm_rate, tech_pvt->video_rm_rate,
0, 0,
//tech_pvt->video_codec_ms,
1, 1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
@ -862,7 +823,7 @@ switch_status_t sofia_glue_tech_set_video_codec(private_object_t *tech_pvt, int
tech_pvt->video_rm_encoding, tech_pvt->video_rm_encoding,
tech_pvt->video_rm_fmtp, tech_pvt->video_rm_fmtp,
tech_pvt->video_rm_rate, tech_pvt->video_rm_rate,
0,//tech_pvt->video_codec_ms, 0,
1, 1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
@ -876,8 +837,6 @@ switch_status_t sofia_glue_tech_set_video_codec(private_object_t *tech_pvt, int
switch_channel_get_name(tech_pvt->channel), tech_pvt->video_rm_encoding, tech_pvt->video_rm_rate, tech_pvt->video_codec_ms); switch_channel_get_name(tech_pvt->channel), tech_pvt->video_rm_encoding, tech_pvt->video_rm_rate, tech_pvt->video_codec_ms);
tech_pvt->video_read_frame.codec = &tech_pvt->video_read_codec; tech_pvt->video_read_frame.codec = &tech_pvt->video_read_codec;
//switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
//switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec);
tech_pvt->fmtp_out = switch_core_session_strdup(tech_pvt->session, tech_pvt->video_write_codec.fmtp_out); tech_pvt->fmtp_out = switch_core_session_strdup(tech_pvt->session, tech_pvt->video_write_codec.fmtp_out);
} }
} }
@ -949,10 +908,6 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_flag_t myflags) switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_flag_t myflags)
{ {
int bw, ms; int bw, ms;
@ -1010,7 +965,9 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
tech_pvt->local_sdp_audio_ip, tech_pvt->local_sdp_audio_ip,
tech_pvt->local_sdp_audio_port, tech_pvt->local_sdp_audio_port,
tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_ip,
tech_pvt->remote_sdp_audio_port, tech_pvt->agreed_pt, tech_pvt->read_codec.implementation->microseconds_per_frame / 1000); tech_pvt->remote_sdp_audio_port,
tech_pvt->agreed_pt,
tech_pvt->read_codec.implementation->microseconds_per_frame / 1000);
snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_audio_port); snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_audio_port);
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip); switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
@ -1086,7 +1043,6 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
} }
} }
if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_timeout_sec"))) { if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_timeout_sec"))) {
int v = atoi(val); int v = atoi(val);
if (v >= 0) { if (v >= 0) {
@ -1120,28 +1076,25 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
tech_pvt->remote_sdp_video_port, tech_pvt->remote_sdp_video_port,
tech_pvt->video_agreed_pt, tech_pvt->video_agreed_pt,
tech_pvt->video_read_codec.implementation->samples_per_frame, tech_pvt->video_read_codec.implementation->samples_per_frame,
0,//tech_pvt->video_codec_ms * 1000, 0,
(switch_rtp_flag_t) flags, (switch_rtp_flag_t) flags,
NULL, NULL,
NULL,//tech_pvt->profile->timer_name, NULL,
&err, switch_core_session_get_pool(tech_pvt->session)); &err, switch_core_session_get_pool(tech_pvt->session));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VIDEO RTP [%s] %s:%d->%s:%d codec: %u ms: %d [%s]\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VIDEO RTP [%s] %s:%d->%s:%d codec: %u ms: %d [%s]\n",
switch_channel_get_name(tech_pvt->channel), switch_channel_get_name(tech_pvt->channel),
tech_pvt->local_sdp_audio_ip, tech_pvt->local_sdp_audio_ip,
tech_pvt->local_sdp_video_port, tech_pvt->local_sdp_video_port,
tech_pvt->remote_sdp_video_ip, tech_pvt->remote_sdp_video_ip,
tech_pvt->remote_sdp_video_port, tech_pvt->video_agreed_pt, tech_pvt->remote_sdp_video_port, tech_pvt->video_agreed_pt,
0,//tech_pvt->video_read_codec.implementation->microseconds_per_frame / 1000, 0,
switch_rtp_ready(tech_pvt->video_rtp_session) ? "SUCCESS" : err); switch_rtp_ready(tech_pvt->video_rtp_session) ? "SUCCESS" : err);
if (switch_rtp_ready(tech_pvt->video_rtp_session)) { if (switch_rtp_ready(tech_pvt->video_rtp_session)) {
switch_channel_set_flag(tech_pvt->channel, CF_VIDEO); switch_channel_set_flag(tech_pvt->channel, CF_VIDEO);
} }
} }
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP REPORTS ERROR: [%s]\n", err); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP REPORTS ERROR: [%s]\n", err);
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
@ -1272,13 +1225,11 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
} }
} }
for (m = sdp->sdp_media; m; m = m->m_next) { for (m = sdp->sdp_media; m; m = m->m_next) {
sdp_connection_t *connection; sdp_connection_t *connection;
ptime = dptime; ptime = dptime;
if (m->m_type == sdp_media_audio) { if (m->m_type == sdp_media_audio) {
sdp_rtpmap_t *map; sdp_rtpmap_t *map;
@ -1504,7 +1455,6 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
} }
} }
} }
} }
switch_set_flag_locked(tech_pvt, TFLAG_SDP); switch_set_flag_locked(tech_pvt, TFLAG_SDP);
@ -1512,7 +1462,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
return match; return match;
} }
// map sip responses to QSIG cause codes ala RFC4497 section 8.4.4 /* map sip responses to QSIG cause codes ala RFC4497 section 8.4.4 */
switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status) switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status)
{ {
switch (status) { switch (status) {
@ -1571,21 +1521,17 @@ switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status)
return SWITCH_CAUSE_EXCHANGE_ROUTING_ERROR; return SWITCH_CAUSE_EXCHANGE_ROUTING_ERROR;
case 487: case 487:
return SWITCH_CAUSE_ORIGINATOR_CANCEL; return SWITCH_CAUSE_ORIGINATOR_CANCEL;
default: default:
return SWITCH_CAUSE_NORMAL_UNSPECIFIED; return SWITCH_CAUSE_NORMAL_UNSPECIFIED;
} }
} }
void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp) void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp)
{ {
const char *val; const char *val;
switch_core_session_t *other_session; switch_core_session_t *other_session;
switch_channel_t *other_channel; switch_channel_t *other_channel;
if ((val = switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE)) if ((val = switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE))
&& (other_session = switch_core_session_locate(val))) { && (other_session = switch_core_session_locate(val))) {
other_channel = switch_core_session_get_channel(other_session); other_channel = switch_core_session_get_channel(other_session);
@ -1593,18 +1539,15 @@ void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp)
switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, sdp); switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, sdp);
if (!switch_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) && (switch_channel_test_flag(other_channel, CF_OUTBOUND) && if (!switch_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) && (switch_channel_test_flag(other_channel, CF_OUTBOUND) &&
//switch_channel_test_flag(other_channel, CF_BYPASS_MEDIA) &&
switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND) && switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND) &&
switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA))) { switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA))) {
switch_ivr_nomedia(val, SMF_FORCE); switch_ivr_nomedia(val, SMF_FORCE);
switch_set_flag_locked(tech_pvt, TFLAG_CHANGE_MEDIA); switch_set_flag_locked(tech_pvt, TFLAG_CHANGE_MEDIA);
} }
switch_core_session_rwunlock(other_session); switch_core_session_rwunlock(other_session);
} }
} }
char *sofia_glue_get_url_from_contact(char *buf, uint8_t to_dup) char *sofia_glue_get_url_from_contact(char *buf, uint8_t to_dup)
{ {
char *url = NULL, *e; char *url = NULL, *e;
@ -1624,7 +1567,6 @@ char *sofia_glue_get_url_from_contact(char *buf, uint8_t to_dup)
url = buf; url = buf;
} }
} }
return url; return url;
} }
@ -1655,7 +1597,6 @@ sofia_profile_t *sofia_glue_find_profile__(const char *file, const char *func, i
return profile; return profile;
} }
void sofia_glue_release_profile__(const char *file, const char *func, int line, sofia_profile_t *profile) void sofia_glue_release_profile__(const char *file, const char *func, int line, sofia_profile_t *profile)
{ {
if (profile) { if (profile) {
@ -1713,13 +1654,10 @@ void sofia_glue_del_profile(sofia_profile_t *profile)
} }
switch_mutex_unlock(mod_sofia_globals.hash_mutex); switch_mutex_unlock(mod_sofia_globals.hash_mutex);
} }
int sofia_glue_init_sql(sofia_profile_t *profile) int sofia_glue_init_sql(sofia_profile_t *profile)
{ {
char reg_sql[] = char reg_sql[] =
"CREATE TABLE sip_registrations (\n" "CREATE TABLE sip_registrations (\n"
" call_id VARCHAR(255),\n" " call_id VARCHAR(255),\n"
@ -1731,7 +1669,6 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
" expires INTEGER" " expires INTEGER"
");\n"; ");\n";
char sub_sql[] = char sub_sql[] =
"CREATE TABLE sip_subscriptions (\n" "CREATE TABLE sip_subscriptions (\n"
" proto VARCHAR(255),\n" " proto VARCHAR(255),\n"
@ -1754,8 +1691,8 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
" expires INTEGER" " expires INTEGER"
");\n"; ");\n";
#ifdef SWITCH_HAVE_ODBC
if (profile->odbc_dsn) { if (profile->odbc_dsn) {
#ifdef SWITCH_HAVE_ODBC
if (!(profile->master_odbc = switch_odbc_handle_new(profile->odbc_dsn, profile->odbc_user, profile->odbc_pass))) { if (!(profile->master_odbc = switch_odbc_handle_new(profile->odbc_dsn, profile->odbc_user, profile->odbc_pass))) {
return 0; return 0;
} }
@ -1780,8 +1717,10 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_authentication", NULL); switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_authentication", NULL);
switch_odbc_handle_exec(profile->master_odbc, auth_sql, NULL); switch_odbc_handle_exec(profile->master_odbc, auth_sql, NULL);
} }
} else { #else
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
#endif #endif
} else {
if (!(profile->master_db = switch_core_db_open_file(profile->dbname))) { if (!(profile->master_db = switch_core_db_open_file(profile->dbname))) {
return 0; return 0;
} }
@ -1790,9 +1729,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
switch_core_db_test_reactive(profile->master_db, "delete from sip_subscriptions where sip_user != ''", "DROP TABLE sip_subscriptions", sub_sql); switch_core_db_test_reactive(profile->master_db, "delete from sip_subscriptions where sip_user != ''", "DROP TABLE sip_subscriptions", sub_sql);
switch_core_db_test_reactive(profile->master_db, "select * from sip_authentication", "DROP TABLE sip_authentication", auth_sql); switch_core_db_test_reactive(profile->master_db, "select * from sip_authentication", "DROP TABLE sip_authentication", auth_sql);
#ifdef SWITCH_HAVE_ODBC
} }
#endif
#ifdef SWITCH_HAVE_ODBC #ifdef SWITCH_HAVE_ODBC
if (profile->odbc_dsn) { if (profile->odbc_dsn) {
@ -1801,8 +1738,6 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
#endif #endif
return profile->master_db ? 1: 0; return profile->master_db ? 1: 0;
} }
void sofia_glue_sql_close(sofia_profile_t *profile) void sofia_glue_sql_close(sofia_profile_t *profile)
@ -1810,13 +1745,12 @@ void sofia_glue_sql_close(sofia_profile_t *profile)
#ifdef SWITCH_HAVE_ODBC #ifdef SWITCH_HAVE_ODBC
if (profile->odbc_dsn) { if (profile->odbc_dsn) {
switch_odbc_handle_destroy(&profile->master_odbc); switch_odbc_handle_destroy(&profile->master_odbc);
} else { return;
#endif
switch_core_db_close(profile->master_db);
profile->master_db = NULL;
#ifdef SWITCH_HAVE_ODBC
} }
#endif #endif
switch_core_db_close(profile->master_db);
profile->master_db = NULL;
} }
@ -1828,8 +1762,8 @@ void sofia_glue_execute_sql(sofia_profile_t *profile, switch_bool_t master, char
switch_mutex_lock(mutex); switch_mutex_lock(mutex);
} }
#ifdef SWITCH_HAVE_ODBC
if (profile->odbc_dsn) { if (profile->odbc_dsn) {
#ifdef SWITCH_HAVE_ODBC
SQLHSTMT stmt; SQLHSTMT stmt;
if (switch_odbc_handle_exec(profile->master_odbc, sql, &stmt) != SWITCH_ODBC_SUCCESS) { if (switch_odbc_handle_exec(profile->master_odbc, sql, &stmt) != SWITCH_ODBC_SUCCESS) {
char *err_str; char *err_str;
@ -1838,28 +1772,23 @@ void sofia_glue_execute_sql(sofia_profile_t *profile, switch_bool_t master, char
switch_safe_free(err_str); switch_safe_free(err_str);
} }
SQLFreeHandle(SQL_HANDLE_STMT, stmt); SQLFreeHandle(SQL_HANDLE_STMT, stmt);
} else { #else
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
#endif #endif
if (master) {
db = profile->master_db;
} else { } else {
if (!(db = switch_core_db_open_file(profile->dbname))) { if (master) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname); db = profile->master_db;
goto end; } else {
if (!(db = switch_core_db_open_file(profile->dbname))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
goto end;
}
}
switch_core_db_persistant_execute(db, sql, 25);
if (!master) {
switch_core_db_close(db);
} }
}
switch_core_db_persistant_execute(db, sql, 25);
if (!master) {
switch_core_db_close(db);
}
#ifdef SWITCH_HAVE_ODBC
} }
#endif
end: end:
if (mutex) { if (mutex) {
@ -1867,7 +1796,6 @@ void sofia_glue_execute_sql(sofia_profile_t *profile, switch_bool_t master, char
} }
} }
switch_bool_t sofia_glue_execute_sql_callback(sofia_profile_t *profile, switch_bool_t sofia_glue_execute_sql_callback(sofia_profile_t *profile,
switch_bool_t master, switch_bool_t master,
switch_mutex_t *mutex, switch_mutex_t *mutex,
@ -1884,48 +1812,40 @@ switch_bool_t sofia_glue_execute_sql_callback(sofia_profile_t *profile,
} }
#ifdef SWITCH_HAVE_ODBC
if (profile->odbc_dsn) { if (profile->odbc_dsn) {
switch_odbc_handle_callback_exec(profile->master_odbc, sql, callback, pdata);
} else {
#endif
if (master) {
db = profile->master_db;
} else {
if (!(db = switch_core_db_open_file(profile->dbname))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
goto end;
}
}
switch_core_db_exec(db, sql, callback, pdata, &errmsg);
if (errmsg) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR: [%s] %s\n", sql, errmsg);
free(errmsg);
}
if (!master && db) {
switch_core_db_close(db);
}
#ifdef SWITCH_HAVE_ODBC #ifdef SWITCH_HAVE_ODBC
} switch_odbc_handle_callback_exec(profile->master_odbc, sql, callback, pdata);
#else
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
#endif #endif
} else {
if (master) {
db = profile->master_db;
} else {
if (!(db = switch_core_db_open_file(profile->dbname))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
goto end;
}
}
switch_core_db_exec(db, sql, callback, pdata, &errmsg);
if (errmsg) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR: [%s] %s\n", sql, errmsg);
free(errmsg);
}
if (!master && db) {
switch_core_db_close(db);
}
}
end: end:
if (mutex) { if (mutex) {
switch_mutex_unlock(mutex); switch_mutex_unlock(mutex);
} }
return ret; return ret;
} }
#ifdef SWITCH_HAVE_ODBC #ifdef SWITCH_HAVE_ODBC
@ -1957,7 +1877,6 @@ static char *sofia_glue_execute_sql2str_odbc(sofia_profile_t *profile, switch_mu
return ret; return ret;
} }
#endif #endif
char *sofia_glue_execute_sql2str(sofia_profile_t *profile, switch_mutex_t *mutex, char *sql, char *resbuf, size_t len) char *sofia_glue_execute_sql2str(sofia_profile_t *profile, switch_mutex_t *mutex, char *sql, char *resbuf, size_t len)
@ -2008,9 +1927,7 @@ char *sofia_glue_execute_sql2str(sofia_profile_t *profile, switch_mutex_t *mutex
switch_core_db_finalize(stmt); switch_core_db_finalize(stmt);
} }
fail: fail:
switch_core_db_close(db); switch_core_db_close(db);
end: end:
@ -2048,5 +1965,4 @@ int sofia_glue_get_user_host(char *in, char **user, char **host)
*host = h; *host = h;
return 1; return 1;
} }