From f03226debba13900c5d2c9d869d9abfd7efa6433 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 9 Feb 2007 20:03:07 +0000 Subject: [PATCH] update core git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4181 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- conf/wanpipe.conf.xml | 2 +- src/include/switch_core.h | 12 +- src/include/switch_module_interfaces.h | 2 +- .../endpoints/mod_dingaling/mod_dingaling.c | 30 +-- src/mod/endpoints/mod_iax/mod_iax.c | 20 +- .../endpoints/mod_portaudio/mod_portaudio.c | 18 +- src/mod/endpoints/mod_sofia/mod_sofia.c | 23 +- src/mod/endpoints/mod_wanpipe/mod_wanpipe.c | 201 +++++++++--------- src/mod/endpoints/mod_woomera/mod_woomera.c | 14 +- src/switch_core.c | 27 +-- src/switch_ivr.c | 4 +- 11 files changed, 176 insertions(+), 177 deletions(-) diff --git a/conf/wanpipe.conf.xml b/conf/wanpipe.conf.xml index 07c302f983..adad25f852 100644 --- a/conf/wanpipe.conf.xml +++ b/conf/wanpipe.conf.xml @@ -2,7 +2,7 @@ - + diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 18db67eb5b..086f1965e3 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -612,13 +612,13 @@ SWITCH_DECLARE(void) switch_core_service_session(switch_core_session_t *session, \param caller_profile the originator's caller profile \param new_session a NULL pointer to aim at the newly created session \param pool optional existing memory pool to donate to the session - \return SWITCH_STATUS_SUCCESS if the session was created + \return the cause code of the attempted call */ -SWITCH_DECLARE(switch_status_t) switch_core_session_outgoing_channel(switch_core_session_t *session, - char *endpoint_name, - switch_caller_profile_t *caller_profile, - switch_core_session_t **new_session, - switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_core_session_t *session, + char *endpoint_name, + switch_caller_profile_t *caller_profile, + switch_core_session_t **new_session, + switch_memory_pool_t *pool); /*! \brief Answer the channel of a given session diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h index ba8d300849..704ec248ba 100644 --- a/src/include/switch_module_interfaces.h +++ b/src/include/switch_module_interfaces.h @@ -172,7 +172,7 @@ struct switch_io_event_hooks { /*! \brief A table of i/o routines that an endpoint interface can implement */ struct switch_io_routines { /*! creates an outgoing session from given session, caller profile */ - switch_status_t (*outgoing_channel)(switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t *); + switch_call_cause_t (*outgoing_channel)(switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t *); /*! answers the given session's channel */ switch_status_t (*answer_channel)(switch_core_session_t *); /*! read a frame from a session */ diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index 803a7a33ea..d578d2d8b1 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -180,8 +180,8 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session); static switch_status_t channel_on_ring(switch_core_session_t *session); static switch_status_t channel_on_loopback(switch_core_session_t *session); static switch_status_t channel_on_transmit(switch_core_session_t *session); -static switch_status_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t *pool); +static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t *pool); static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id); static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, @@ -1508,8 +1508,8 @@ static const switch_loadable_module_interface_t channel_module_interface = { /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines that allocate memory or you will have 1 channel with memory allocated from another channel's pool! */ -static switch_status_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t *pool) +static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t *pool) { if ((*new_session = switch_core_session_request(&channel_endpoint_interface, pool)) != 0) { struct private_object *tech_pvt; @@ -1534,7 +1534,7 @@ static switch_status_t channel_outgoing_channel(switch_core_session_t *session, } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Invalid URL!\n"); terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_INVALID_NUMBER_FORMAT; } if ((dnis = strchr(callto, ':'))) { @@ -1571,17 +1571,17 @@ static switch_status_t channel_outgoing_channel(switch_core_session_t *session, if (!ldl_handle_ready(mdl_profile->handle)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doh! we are not logged in yet!\n"); terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } if (!(full_id = ldl_handle_probe(mdl_profile->handle, callto, user, idbuf, sizeof(idbuf)))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unknown Recipient!\n"); - terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - return SWITCH_STATUS_GENERR; + terminate_session(new_session, __LINE__, SWITCH_CAUSE_NO_USER_RESPONSE); + return SWITCH_CAUSE_NO_USER_RESPONSE; } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unknown Profile!\n"); terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } @@ -1601,7 +1601,7 @@ static switch_status_t channel_outgoing_channel(switch_core_session_t *session, } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n"); terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } if (outbound_profile) { @@ -1616,7 +1616,7 @@ static switch_status_t channel_outgoing_channel(switch_core_session_t *session, } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doh! no caller profile\n"); terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } switch_channel_set_flag(channel, CF_OUTBOUND); @@ -1633,15 +1633,15 @@ static switch_status_t channel_outgoing_channel(switch_core_session_t *session, ldl_session_set_value(dlsession, "caller_id_number", outbound_profile->caller_id_number); tech_pvt->dlsession = dlsession; if (!get_codecs(tech_pvt)) { - terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - return SWITCH_STATUS_GENERR; + terminate_session(new_session, __LINE__, SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL); + return SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL; } switch_channel_set_state(channel, CS_INIT); - return SWITCH_STATUS_SUCCESS; + return SWITCH_CAUSE_SUCCESS; } - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } diff --git a/src/mod/endpoints/mod_iax/mod_iax.c b/src/mod/endpoints/mod_iax/mod_iax.c index 9d3b2e4c24..46908bbac2 100644 --- a/src/mod/endpoints/mod_iax/mod_iax.c +++ b/src/mod/endpoints/mod_iax/mod_iax.c @@ -426,8 +426,8 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session); static switch_status_t channel_on_ring(switch_core_session_t *session); static switch_status_t channel_on_loopback(switch_core_session_t *session); static switch_status_t channel_on_transmit(switch_core_session_t *session); -static switch_status_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t *pool); +static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t *pool); static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id); static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, @@ -802,8 +802,8 @@ static const switch_loadable_module_interface_t channel_module_interface = { /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines that allocate memory or you will have 1 channel with memory allocated from another channel's pool! */ -static switch_status_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t *pool) +static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t *pool) { if ((*new_session = switch_core_session_request(&channel_endpoint_interface, pool)) != 0) { private_t *tech_pvt; @@ -819,7 +819,7 @@ static switch_status_t channel_outgoing_channel(switch_core_session_t *session, } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n"); switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } if (outbound_profile) { @@ -834,18 +834,18 @@ static switch_status_t channel_outgoing_channel(switch_core_session_t *session, } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n"); switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; + SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } if ((tech_pvt->iax_session = iax_session_new()) == 0) { switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } if (iax_set_codec(tech_pvt, tech_pvt->iax_session, &req, &cap, &samprate, IAX_QUERY) != SWITCH_STATUS_SUCCESS) { switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_BEARERCAPABILITY_NOTIMPL; } if (samprate) { @@ -859,10 +859,10 @@ static switch_status_t channel_outgoing_channel(switch_core_session_t *session, switch_channel_set_flag(channel, CF_OUTBOUND); switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND); switch_channel_set_state(channel, CS_INIT); - return SWITCH_STATUS_SUCCESS; + return SWITCH_CAUSE_SUCCESS; } - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index ef12849bc8..6d31a63c6d 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -142,9 +142,9 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session); static switch_status_t channel_on_ring(switch_core_session_t *session); static switch_status_t channel_on_loopback(switch_core_session_t *session); static switch_status_t channel_on_transmit(switch_core_session_t *session); -static switch_status_t channel_outgoing_channel(switch_core_session_t *session, - switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t *pool); +static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, + switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t *pool); static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id); static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, @@ -824,8 +824,8 @@ static const switch_loadable_module_interface_t channel_module_interface = { /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines that allocate memory or you will have 1 channel with memory allocated from another channel's pool! */ -static switch_status_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t *pool) +static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t *pool) { if ((*new_session = switch_core_session_request(&channel_endpoint_interface, pool)) != 0) { @@ -844,7 +844,7 @@ static switch_status_t channel_outgoing_channel(switch_core_session_t *session, } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n"); switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } if (outbound_profile) { @@ -860,16 +860,16 @@ static switch_status_t channel_outgoing_channel(switch_core_session_t *session, } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n"); switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } switch_channel_set_flag(channel, CF_OUTBOUND); switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND); switch_channel_set_state(channel, CS_INIT); - return SWITCH_STATUS_SUCCESS; + return SWITCH_CAUSE_SUCCESS; } - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index a88d75fd77..11539ac4c8 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -330,8 +330,8 @@ static switch_status_t sofia_on_loopback(switch_core_session_t *session); static switch_status_t sofia_on_transmit(switch_core_session_t *session); -static switch_status_t sofia_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t *pool); +static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t *pool); static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id); @@ -1246,6 +1246,7 @@ static int hangup_cause_to_sip(switch_call_cause_t cause) { return 501; case SWITCH_CAUSE_NORMAL_UNSPECIFIED: return 480; + case SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL: case SWITCH_CAUSE_NORMAL_CIRCUIT_CONGESTION: case SWITCH_CAUSE_NETWORK_OUT_OF_ORDER: case SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE: @@ -2182,10 +2183,10 @@ static void logger(void *logarg, char const *fmt, va_list ap) } -static switch_status_t sofia_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t *pool) +static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t *pool) { - switch_status_t status = SWITCH_STATUS_FALSE; + switch_call_cause_t cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; switch_core_session_t *nsession; char *data, *profile_name, *dest; sofia_profile_t *profile; @@ -2213,6 +2214,7 @@ static switch_status_t sofia_outgoing_channel(switch_core_session_t *session, sw if (!(dest = strchr(profile_name, '/'))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid URL\n"); terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__); + cause = SWITCH_CAUSE_INVALID_NUMBER_FORMAT; goto done; } @@ -2221,6 +2223,7 @@ static switch_status_t sofia_outgoing_channel(switch_core_session_t *session, sw if (!(profile = (sofia_profile_t *) switch_core_hash_find(globals.profile_hash, profile_name))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Profile\n"); terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__); + cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; goto done; } @@ -2233,7 +2236,8 @@ static switch_status_t sofia_outgoing_channel(switch_core_session_t *session, sw tech_pvt->dest = switch_core_session_strdup(nsession, buf); } else { - terminate_session(&nsession, SWITCH_CAUSE_NO_ROUTE_DESTINATION, __LINE__); + cause = SWITCH_CAUSE_NO_ROUTE_DESTINATION; + terminate_session(&nsession, cause, __LINE__); goto done; } } else if (!strchr(dest, '@')) { @@ -2243,7 +2247,8 @@ static switch_status_t sofia_outgoing_channel(switch_core_session_t *session, sw tech_pvt->dest = switch_core_session_strdup(nsession, buf); } else { - terminate_session(&nsession, SWITCH_CAUSE_NO_ROUTE_DESTINATION, __LINE__); + cause = SWITCH_CAUSE_NO_ROUTE_DESTINATION; + terminate_session(&nsession, cause, __LINE__); goto done; } } else { @@ -2261,7 +2266,7 @@ static switch_status_t sofia_outgoing_channel(switch_core_session_t *session, sw switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND); switch_channel_set_state(nchannel, CS_INIT); *new_session = nsession; - status = SWITCH_STATUS_SUCCESS; + cause = SWITCH_CAUSE_SUCCESS; if (session) { //char *val; //switch_channel_t *channel = switch_core_session_get_channel(session); @@ -2269,7 +2274,7 @@ static switch_status_t sofia_outgoing_channel(switch_core_session_t *session, sw } done: - return status; + return cause; } diff --git a/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c b/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c index 73645d0b91..493b1c8b20 100644 --- a/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c +++ b/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c @@ -71,12 +71,12 @@ typedef enum { } TFLAGS; -#define DEFAULT_MTU 160 +#define DEFAULT_SAMPLES_PER_FRAME 160 static struct { int debug; int panic; - uint32_t mtu; + uint32_t samples_per_frame; int dtmf_on; int dtmf_off; int supress_dtmf_tone; @@ -92,7 +92,6 @@ struct wanpipe_pri_span { int dchan; unsigned int bchans; int node; - int mtu; int pswitch; char *dialplan; unsigned int l1; @@ -134,6 +133,7 @@ struct private_object { unsigned int skip_read_frames; unsigned int skip_write_frames; switch_mutex_t *flag_mutex; + int frame_size; #ifdef DOTRACE int fd; int fd2; @@ -296,8 +296,8 @@ static switch_status_t wanpipe_on_init(switch_core_session_t *session); static switch_status_t wanpipe_on_hangup(switch_core_session_t *session); static switch_status_t wanpipe_on_loopback(switch_core_session_t *session); static switch_status_t wanpipe_on_transmit(switch_core_session_t *session); -static switch_status_t wanpipe_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t *pool); +static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t *pool); static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id); static switch_status_t wanpipe_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, @@ -323,9 +323,8 @@ static switch_status_t wanpipe_on_init(switch_core_session_t *session) switch_channel_t *channel = NULL; wanpipe_tdm_api_t tdm_api = {{0}}; int err = 0; - unsigned int mtu_mru; unsigned int rate = 8000; - int new_mtu = ((globals.mtu / 8) / 2); + channel = switch_core_session_get_channel(session); assert(channel != NULL); @@ -337,23 +336,11 @@ static switch_status_t wanpipe_on_init(switch_core_session_t *session) err = sangoma_tdm_set_codec(tech_pvt->wpsock->fd, &tdm_api, WP_SLINEAR); - mtu_mru = sangoma_tdm_get_usr_mtu_mru(tech_pvt->wpsock->fd, &tdm_api); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "WANPIPE INIT MTU is %d\n", mtu_mru); - - if (mtu_mru != globals.mtu) { - sangoma_tdm_set_usr_period(tech_pvt->wpsock->fd, &tdm_api, 40); - err = sangoma_tdm_set_usr_period(tech_pvt->wpsock->fd, &tdm_api, new_mtu); - mtu_mru = sangoma_tdm_get_usr_mtu_mru(tech_pvt->wpsock->fd, &tdm_api); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "ADJUSTED MTU AFTER SETTING IT TO %d is %d %d [%s]\n", new_mtu, mtu_mru, err, strerror(err)); - if (mtu_mru != globals.mtu) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure to adjust MTU\n"); - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - return SWITCH_STATUS_FALSE; - } - } + sangoma_tdm_set_usr_period(tech_pvt->wpsock->fd, &tdm_api, globals.samples_per_frame / 8); + tech_pvt->frame_size = sangoma_tdm_get_usr_mtu_mru(tech_pvt->wpsock->fd, &tdm_api); if (switch_core_codec_init - (&tech_pvt->read_codec, "L16", NULL, rate, 20, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, + (&tech_pvt->read_codec, "L16", NULL, rate, globals.samples_per_frame / 8, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel)); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); @@ -361,7 +348,7 @@ static switch_status_t wanpipe_on_init(switch_core_session_t *session) } if (switch_core_codec_init - (&tech_pvt->write_codec, "L16", NULL, rate, 20, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, + (&tech_pvt->write_codec, "L16", NULL, rate, globals.samples_per_frame / 8, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel)); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); @@ -449,12 +436,14 @@ static switch_status_t wanpipe_on_hangup(switch_core_session_t *session) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "WANPIPE HANGUP\n"); if (!switch_test_flag(tech_pvt, TFLAG_NOSIG)) { - pri_hangup(tech_pvt->spri->pri, tech_pvt->call, tech_pvt->cause); + pri_hangup(tech_pvt->spri->pri, tech_pvt->call, switch_channel_get_cause(channel)); pri_destroycall(tech_pvt->spri->pri, tech_pvt->call); + switch_mutex_lock(globals.channel_mutex); if (chanmap->map[tech_pvt->callno]) { chanmap->map[tech_pvt->callno][0] = '\0'; } + switch_mutex_unlock(globals.channel_mutex); /* pri_hangup(tech_pvt->spri->pri, tech_pvt->hangup_event.hangup.call ? tech_pvt->hangup_event.hangup.call : tech_pvt->ring_event.ring.call, @@ -521,7 +510,7 @@ static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch switch_channel_t *channel = NULL; uint8_t *bp; uint32_t bytes = 0; - int res = 0; + int bread = 0; char digit_str[80]; channel = switch_core_session_get_channel(session); @@ -530,7 +519,6 @@ static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch tech_pvt = switch_core_session_get_private(session); assert(tech_pvt != NULL); - if (switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->wpsock->fd < 0) { return SWITCH_STATUS_GENERR; } @@ -539,8 +527,7 @@ static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch *frame = NULL; memset(tech_pvt->databuf, 0, sizeof(tech_pvt->databuf)); - while (bytes < globals.mtu) { - + while (bytes < globals.samples_per_frame * 2) { if (switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->wpsock->fd < 0) { return SWITCH_STATUS_GENERR; } @@ -550,7 +537,7 @@ static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch return SWITCH_STATUS_GENERR; } - if ((res = sangoma_readmsg_socket(tech_pvt->wpsock->fd, + if ((bread = sangoma_readmsg_socket(tech_pvt->wpsock->fd, &tech_pvt->hdrframe, sizeof(tech_pvt->hdrframe), bp, sizeof(tech_pvt->databuf) - bytes, 0)) < 0) { if (errno == EBUSY) { @@ -560,7 +547,7 @@ static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch } } - bytes += res; + bytes += bread; bp += bytes; } @@ -571,8 +558,8 @@ static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch tech_pvt->read_frame.datalen = bytes; tech_pvt->read_frame.samples = bytes / 2; - res = teletone_dtmf_detect (&tech_pvt->dtmf_detect, tech_pvt->read_frame.data, tech_pvt->read_frame.samples); - res = teletone_dtmf_get(&tech_pvt->dtmf_detect, digit_str, sizeof(digit_str)); + teletone_dtmf_detect (&tech_pvt->dtmf_detect, tech_pvt->read_frame.data, tech_pvt->read_frame.samples); + teletone_dtmf_get(&tech_pvt->dtmf_detect, digit_str, sizeof(digit_str)); if(digit_str[0]) { switch_channel_queue_dtmf(channel, digit_str); @@ -622,8 +609,8 @@ static switch_status_t wanpipe_write_frame(switch_core_session_t *session, switc return SWITCH_STATUS_GENERR; } - if ((bread = switch_buffer_read(tech_pvt->dtmf_buffer, dtmf, globals.mtu)) < globals.mtu) { - while (bread < globals.mtu) { + if ((bread = switch_buffer_read(tech_pvt->dtmf_buffer, dtmf, tech_pvt->frame_size)) < tech_pvt->frame_size) { + while (bread < tech_pvt->frame_size) { dtmf[bread++] = 0; } } @@ -674,14 +661,14 @@ static switch_status_t wanpipe_write_frame(switch_core_session_t *session, switc #endif #ifdef DOTRACE - write(tech_pvt->fd, bp, (int) globals.mtu); + write(tech_pvt->fd, bp, (int) tech_pvt->frame_size); #endif - towrite = bytes >= globals.mtu ? globals.mtu : bytes; + towrite = bytes >= tech_pvt->frame_size ? tech_pvt->frame_size : bytes; - if (towrite < globals.mtu) { - int diff = globals.mtu - towrite; + if (towrite < tech_pvt->frame_size) { + int diff = tech_pvt->frame_size - towrite; memset(bp + towrite, 0, diff); - towrite = globals.mtu; + towrite = tech_pvt->frame_size; } result = sangoma_sendmsg_socket(tech_pvt->wpsock->fd, @@ -689,7 +676,7 @@ static switch_status_t wanpipe_write_frame(switch_core_session_t *session, switc if (result < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Bad Write frame len %u write %d bytes returned %d (%s)!\n", towrite, - globals.mtu, result, strerror(errno)); + tech_pvt->frame_size, result, strerror(errno)); if (errno == EBUSY) { continue; } @@ -846,8 +833,8 @@ static const switch_loadable_module_interface_t wanpipe_module_interface = { }; -static switch_status_t wanpipe_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t *pool) +static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t *pool) { char *bchan = NULL; char name[128] = ""; @@ -862,12 +849,12 @@ static switch_status_t wanpipe_outgoing_channel(switch_core_session_t *session, if (bchan) { bchan++; if (!bchan) { - return SWITCH_STATUS_FALSE; + return SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL; } outbound_profile->destination_number++; } else if (!globals.configured_spans) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error No Spans Configured.\n"); - return SWITCH_STATUS_FALSE; + SWITCH_CAUSE_NETWORK_OUT_OF_ORDER; } @@ -885,7 +872,7 @@ static switch_status_t wanpipe_outgoing_channel(switch_core_session_t *session, } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n"); switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; + SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } @@ -902,17 +889,21 @@ static switch_status_t wanpipe_outgoing_channel(switch_core_session_t *session, num = caller_profile->destination_number; if ((p = strchr(num, '/'))) { *p++ = '\0'; - if (*num != 'a') { + + if (*num == 'a') { + span = 1; + autospan = 1; + } else if (*num = 'A') { + span = MAX_SPANS - 1; + autospan = -1; + } else { if (num && *num > 47 && *num < 58) { span = atoi(num); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invlid Syntax\n"); switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } - } else { - span = 0; - autospan = 1; } num = p; if ((p = strchr(num, '/'))) { @@ -926,13 +917,13 @@ static switch_status_t wanpipe_outgoing_channel(switch_core_session_t *session, } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invlid Syntax\n"); switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } caller_profile->destination_number = p; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invlid Syntax\n"); switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } } } @@ -946,64 +937,70 @@ static switch_status_t wanpipe_outgoing_channel(switch_core_session_t *session, if (!wp_open(tech_pvt, span, chan)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd for s%dc%d! [%s]\n", span, chan, strerror(errno)); switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } switch_set_flag_locked(tech_pvt, TFLAG_NOSIG); - snprintf(name, sizeof(name), "WanPipe/%s/nosig-%04x", bchan, rand() & 0xffff); + snprintf(name, sizeof(name), "WanPipe/%s/nosig", bchan); switch_channel_set_name(channel, name); switch_channel_set_caller_profile(channel, caller_profile); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid address\n"); switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL; } } else { switch_mutex_lock(globals.channel_mutex); - do { - if (autospan) { - span++; + channo = 0; + while (!channo) { + if (autospan > 0 && span == MAX_SPANS - 1) { + break; } - if ((spri = &SPANS[span]->spri) && switch_test_flag(spri, SANGOMA_PRI_READY)) { - chanmap = spri->private_info; - if (channo == 0) { - if (autochan > 0) { - for(channo = 1; channo < SANGOMA_MAX_CHAN_PER_SPAN; channo++) { - if ((SPANS[span]->bchans & (1 << channo)) && !chanmap->map[channo][0]) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing channel %d\n", channo); - break; - } - } - } else if (autochan < 0) { - for(channo = SANGOMA_MAX_CHAN_PER_SPAN; channo > 0; channo--) { - if ((SPANS[span]->bchans & (1 << channo)) && !chanmap->map[channo][0]) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing channel %d\n", channo); - break; - } - } - } - if (channo <= 0 || channo == (SANGOMA_MAX_CHAN_PER_SPAN)) { - channo = 0; - break; + if (autospan < 0 && span == 0) { + break; + } + + if (SPANS[span] && (spri = &SPANS[span]->spri) && switch_test_flag(spri, SANGOMA_PRI_READY)) { + chanmap = spri->private_info; + + if (autochan > 0) { + for(channo = 1; channo < SANGOMA_MAX_CHAN_PER_SPAN; channo++) { + if ((SPANS[span]->bchans & (1 << channo)) && !chanmap->map[channo][0]) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing channel s%dc%d\n", span, channo); + goto done; + } } - } - if (channo) { - break; + channo = 0; + } else if (autochan < 0) { + for(channo = SANGOMA_MAX_CHAN_PER_SPAN; channo > 0; channo--) { + if ((SPANS[span]->bchans & (1 << channo)) && !chanmap->map[channo][0]) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing channel s%dc%d\n", span, channo); + goto done; + } + } + channo = 0; } } - } while(autospan && span < MAX_SPANS && !spri && !channo); + + if (autospan > 0) { + span++; + } else if (autospan < 0) { + span--; + } + } + done: switch_mutex_unlock(globals.channel_mutex); - + if (!spri || channo == 0 || channo == (SANGOMA_MAX_CHAN_PER_SPAN)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No Free Channels!\n"); switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_SWITCH_CONGESTION; } if (spri && (tech_pvt->call = pri_new_call(spri->pri))) { struct pri_sr *sr; - snprintf(name, sizeof(name), "WanPipe/s%dc%d/%s-%04x", spri->span, channo, caller_profile->destination_number, rand() & 0xffff); + snprintf(name, sizeof(name), "WanPipe/s%dc%d/%s", spri->span, channo, caller_profile->destination_number); switch_channel_set_name(channel, name); switch_channel_set_caller_profile(channel, caller_profile); sr = pri_sr_new(); @@ -1024,14 +1021,14 @@ static switch_status_t wanpipe_outgoing_channel(switch_core_session_t *session, if (pri_setup(spri->pri, tech_pvt->call , sr)) { switch_core_session_destroy(new_session); pri_sr_free(sr); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } if (!wp_open(tech_pvt, spri->span, channo)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd!\n"); switch_core_session_destroy(new_session); pri_sr_free(sr); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } pri_sr_free(sr); switch_copy_string(chanmap->map[channo], @@ -1043,16 +1040,16 @@ static switch_status_t wanpipe_outgoing_channel(switch_core_session_t *session, } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n"); switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } switch_channel_set_flag(channel, CF_OUTBOUND); switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND); switch_channel_set_state(channel, CS_INIT); - return SWITCH_STATUS_SUCCESS; + return SWITCH_CAUSE_SUCCESS; } - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } @@ -1144,9 +1141,12 @@ static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, p tech_pvt->cause = pevent->hangup.cause; - switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); + switch_channel_hangup(channel, tech_pvt->cause); + switch_mutex_lock(globals.channel_mutex); chanmap->map[pevent->hangup.channel][0] = '\0'; + switch_mutex_unlock(globals.channel_mutex); + switch_core_session_rwunlock(session); } @@ -1190,6 +1190,7 @@ static int on_proceed(struct sangoma_pri *spri, sangoma_pri_event_t event_type, switch_core_session_message_t *msg; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Proceeding on channel s%dc%d\n", spri->span, pevent->proceeding.channel); + channel = switch_core_session_get_channel(session); assert(channel != NULL); @@ -1203,7 +1204,7 @@ static int on_proceed(struct sangoma_pri *spri, sangoma_pri_event_t event_type, } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); } - + switch_core_session_rwunlock(session); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Proceeding on channel s%dc%d but it's not in use?\n", @@ -1463,7 +1464,7 @@ static switch_status_t config_wanpipe(int reload) int current_span = 0, min_span = 0, max_span = 0; switch_xml_t cfg, xml, settings, param, span; - globals.mtu = DEFAULT_MTU; + globals.samples_per_frame = DEFAULT_SAMPLES_PER_FRAME; globals.dtmf_on = 150; globals.dtmf_off = 50; @@ -1482,8 +1483,8 @@ static switch_status_t config_wanpipe(int reload) if (!strcmp(var, "debug")) { globals.debug = atoi(val); - } else if (!strcmp(var, "mtu")) { - globals.mtu = atoi(val); + } else if (!strcmp(var, "ms-per-frame")) { + globals.samples_per_frame = atoi(val) * 8; } else if (!strcmp(var, "dtmf-on")) { globals.dtmf_on = atoi(val); } else if (!strcmp(var, "dtmf-off")) { @@ -1578,14 +1579,6 @@ static switch_status_t config_wanpipe(int reload) SPANS[current_span]->l1 = str2l1(val); } else if (!strcmp(var, "dialplan")) { set_global_dialplan(val); - } else if (!strcmp(var, "mtu")) { - int mtu = atoi(val); - - if (mtu >= 10 && mtu < 960) { - SPANS[current_span]->mtu = mtu; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid MTU (%s)!\n", val); - } } } } diff --git a/src/mod/endpoints/mod_woomera/mod_woomera.c b/src/mod/endpoints/mod_woomera/mod_woomera.c index e4f7cd0434..741851eb81 100644 --- a/src/mod/endpoints/mod_woomera/mod_woomera.c +++ b/src/mod/endpoints/mod_woomera/mod_woomera.c @@ -169,7 +169,7 @@ static switch_status_t woomera_on_hangup(switch_core_session_t *session); static switch_status_t woomera_on_ring(switch_core_session_t *session); static switch_status_t woomera_on_loopback(switch_core_session_t *session); static switch_status_t woomera_on_transmit(switch_core_session_t *session); -static switch_status_t woomera_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, +static switch_call_cause_t woomera_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, switch_core_session_t **new_session, switch_memory_pool_t *pool); static switch_status_t woomera_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id); @@ -481,8 +481,8 @@ static const switch_loadable_module_interface_t woomera_module_interface = { /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines that allocate memory or you will have 1 channel with memory allocated from another channel's pool! */ -static switch_status_t woomera_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t *pool) +static switch_call_cause_t woomera_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t *pool) { if ((*new_session = switch_core_session_request(&woomera_endpoint_interface, pool)) != 0) { struct private_object *tech_pvt; @@ -500,7 +500,7 @@ static switch_status_t woomera_outgoing_channel(switch_core_session_t *session, } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n"); switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } if (outbound_profile) { @@ -516,16 +516,16 @@ static switch_status_t woomera_outgoing_channel(switch_core_session_t *session, } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n"); switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } switch_channel_set_flag(channel, CF_OUTBOUND); switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND); switch_channel_set_state(channel, CS_INIT); - return SWITCH_STATUS_SUCCESS; + return SWITCH_CAUSE_SUCCESS; } - return SWITCH_STATUS_GENERR; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } diff --git a/src/switch_core.c b/src/switch_core.c index 73eebec397..a3cf47af8e 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -1542,21 +1542,22 @@ SWITCH_DECLARE(int) switch_core_session_get_stream_count(switch_core_session_t * return session->stream_count; } -SWITCH_DECLARE(switch_status_t) switch_core_session_outgoing_channel(switch_core_session_t *session, - char *endpoint_name, - switch_caller_profile_t *caller_profile, - switch_core_session_t **new_session, - switch_memory_pool_t *pool) +SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_core_session_t *session, + char *endpoint_name, + switch_caller_profile_t *caller_profile, + switch_core_session_t **new_session, + switch_memory_pool_t *pool) { switch_io_event_hook_outgoing_channel_t *ptr; switch_status_t status = SWITCH_STATUS_FALSE; const switch_endpoint_interface_t *endpoint_interface; switch_channel_t *channel = NULL; switch_caller_profile_t *outgoing_profile = caller_profile; + switch_call_cause_t cause = SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL; if ((endpoint_interface = switch_loadable_module_get_endpoint_interface(endpoint_name)) == 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not locate channel type %s\n", endpoint_name); - return SWITCH_STATUS_FALSE; + return SWITCH_CAUSE_CHAN_NOT_IMPLEMENTED; } if (endpoint_interface->io_routines->outgoing_channel) { @@ -1595,10 +1596,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_outgoing_channel(switch_core } } - if ((status = endpoint_interface->io_routines->outgoing_channel(session, - outgoing_profile, - new_session, - pool)) == SWITCH_STATUS_SUCCESS) { + if ((cause = endpoint_interface->io_routines->outgoing_channel(session, + outgoing_profile, + new_session, + pool)) == SWITCH_CAUSE_SUCCESS) { if (session) { for (ptr = session->event_hooks.outgoing_channel; ptr; ptr = ptr->next) { if ((status = ptr->outgoing_channel(session, caller_profile, *new_session)) != SWITCH_STATUS_SUCCESS) { @@ -1607,11 +1608,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_outgoing_channel(switch_core } } } else { - return status; + return cause; } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not locate outgoing channel interface for %s\n", endpoint_name); - return SWITCH_STATUS_FALSE; + return SWITCH_CAUSE_CHAN_NOT_IMPLEMENTED; } if (*new_session) { @@ -1688,7 +1689,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_outgoing_channel(switch_core } } - return status; + return cause; } SWITCH_DECLARE(switch_status_t) switch_core_session_answer_channel(switch_core_session_t *session) diff --git a/src/switch_ivr.c b/src/switch_ivr.c index dd3698b97e..82096cfe0a 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -2678,8 +2678,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess } } - if (switch_core_session_outgoing_channel(session, chan_type, caller_profiles[i], &peer_sessions[i], pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n"); + if ((reason = switch_core_session_outgoing_channel(session, chan_type, caller_profiles[i], &peer_sessions[i], pool)) != SWITCH_CAUSE_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel! cause: %s\n", switch_channel_cause2str(reason)); if (pool) { switch_core_destroy_memory_pool(&pool); }