]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
refactor enterprise_originate
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 20 Nov 2009 02:17:08 +0000 (02:17 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 20 Nov 2009 02:17:08 +0000 (02:17 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15565 d0543943-73ff-0310-b7d9-9358b9ac24b2

23 files changed:
src/include/switch_core.h
src/include/switch_ivr.h
src/include/switch_module_interfaces.h
src/mod/applications/mod_commands/mod_commands.c
src/mod/applications/mod_conference/mod_conference.c
src/mod/applications/mod_dptools/mod_dptools.c
src/mod/applications/mod_fifo/mod_fifo.c
src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c
src/mod/endpoints/mod_alsa/mod_alsa.c
src/mod/endpoints/mod_dingaling/mod_dingaling.c
src/mod/endpoints/mod_iax/mod_iax.c
src/mod/endpoints/mod_loopback/mod_loopback.c
src/mod/endpoints/mod_portaudio/mod_portaudio.c
src/mod/endpoints/mod_reference/mod_reference.c
src/mod/endpoints/mod_skypiax/mod_skypiax.c
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c
src/mod/endpoints/mod_unicall/mod_unicall.c
src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
src/switch_core_session.c
src/switch_cpp.cpp
src/switch_ivr_originate.c

index 61c39a08435e7860230f6fe62231f1ead348706b..718d6c4da861c0f1a78751fc9c515f8b441e306f 100644 (file)
@@ -908,7 +908,7 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(_In_opt
                                                                                                                                                 _In_z_ const char *endpoint_name,
                                                                                                                                                 _In_ switch_caller_profile_t *caller_profile,
                                                                                                                                                 _Inout_ switch_core_session_t **new_session,
-                                                                                                                                                _Inout_ switch_memory_pool_t **pool, _In_ switch_originate_flag_t flags);
+                                                                                                                                                _Inout_ switch_memory_pool_t **pool, _In_ switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
 
 SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(_In_z_ const char *endpoint_name,
                                                                                                                                                  _Inout_ switch_core_session_t **new_session,
index c78d64f79b69abd9bfc54b388e5a9daa6d93362a..2a99ed75591d155c8f052534a8997691c1a89095 100644 (file)
@@ -406,7 +406,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                                                                                         const char *cid_num_override,
                                                                                                         switch_caller_profile_t *caller_profile_override, 
                                                                                                         switch_event_t *ovars,
-                                                                                                        switch_originate_flag_t flags
+                                                                                                        switch_originate_flag_t flags,
+                                                                                                        switch_call_cause_t *cancel_cause
                                                                                                         );
 
 SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_session_t *session,
index 118e63331faf57991cadfd069f30b708d6088af1..5b2d2baab42c5d2c3d73ae4ab0bf7ce9d9d49caa 100644 (file)
@@ -106,7 +106,7 @@ struct switch_io_event_hooks;
 
 
 typedef switch_call_cause_t (*switch_io_outgoing_channel_t)
-(switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **, switch_originate_flag_t);
+(switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **, switch_originate_flag_t, switch_call_cause_t *);
 typedef switch_status_t (*switch_io_read_frame_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int);
 typedef switch_status_t (*switch_io_write_frame_t) (switch_core_session_t *, switch_frame_t *, switch_io_flag_t, int);
 typedef switch_status_t (*switch_io_kill_channel_t) (switch_core_session_t *, int);
index bc58f196c1309e8bcd5060e1c015a8b0e20ae3c5..ed0b3b4e6a0678628c5cf7170d75aaf4b6d05808 100644 (file)
@@ -2448,7 +2448,7 @@ SWITCH_STANDARD_API(originate_function)
                timeout = atoi(argv[6]);
        }
 
-       if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS
+       if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE, NULL) != SWITCH_STATUS_SUCCESS
                || !caller_session) {
                if (machine) {
                        stream->write_function(stream, "-ERR %s\n", switch_channel_cause2str(cause));
index 1c31037ac3e968d30b3f69ef0e4084f4c6fcfcc5..1206d6bf7ca67cc9e0ec76a9021dee0d946ba5ec 100644 (file)
@@ -4448,7 +4448,7 @@ static switch_status_t conference_outcall(conference_obj_t *conference,
 
        if (conference == NULL) {
                char *dialstr = switch_mprintf("{ignore_early_media=true}%s", bridgeto);
-               status = switch_ivr_originate(NULL, &peer_session, cause, dialstr, 60, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE);
+               status = switch_ivr_originate(NULL, &peer_session, cause, dialstr, 60, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE, NULL);
                switch_safe_free(dialstr);
 
                if (status != SWITCH_STATUS_SUCCESS) {
@@ -4481,7 +4481,7 @@ static switch_status_t conference_outcall(conference_obj_t *conference,
 
        /* establish an outbound call leg */
 
-       if (switch_ivr_originate(session, &peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
+       if (switch_ivr_originate(session, &peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE, NULL) != SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot create outgoing channel, cause: %s\n", switch_channel_cause2str(*cause));
                if (caller_channel) {
                        switch_channel_hangup(caller_channel, *cause);
index fb2d9d003818fa8f93c26080f9c04aa88bd5b0f4..0d7f92cbcc88bbfb9f316fbf0dd0da827209f42a 100644 (file)
@@ -1565,7 +1565,7 @@ SWITCH_STANDARD_APP(att_xfer_function)
        switch_channel_set_variable(channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE, bond);
        switch_channel_set_flag(channel, CF_XFER_ZOMBIE);
 
-       if (switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE) 
+       if (switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL
                != SWITCH_STATUS_SUCCESS || !peer_session) {
                goto end;
        }
@@ -2223,7 +2223,7 @@ SWITCH_STANDARD_APP(audio_bridge_function)
 
                do {
                        fail = 0;
-                       status = switch_ivr_originate(NULL, &peer_session, &cause, camp_data, campon_timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE);
+                       status = switch_ivr_originate(NULL, &peer_session, &cause, camp_data, campon_timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL);
                        
                        if (!switch_channel_ready(caller_channel)) {
                                fail = 1;
@@ -2286,7 +2286,7 @@ SWITCH_STANDARD_APP(audio_bridge_function)
                }
 
        } else {
-               if ((status = switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE)) != SWITCH_STATUS_SUCCESS) {
+               if ((status = switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL)) != SWITCH_STATUS_SUCCESS) {
                        fail = 1;
                }
        }
@@ -2403,7 +2403,7 @@ switch_endpoint_interface_t *error_endpoint_interface;
 static switch_call_cause_t error_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
 switch_io_routines_t error_io_routines = {
        /*.outgoing_channel */ error_outgoing_channel
 };
@@ -2411,7 +2411,7 @@ switch_io_routines_t error_io_routines = {
 static switch_call_cause_t error_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
 {
        switch_call_cause_t cause = switch_channel_str2cause(outbound_profile->destination_number);
        if (cause == SWITCH_CAUSE_NONE) {
@@ -2427,7 +2427,7 @@ switch_endpoint_interface_t *group_endpoint_interface;
 static switch_call_cause_t group_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
 switch_io_routines_t group_io_routines = {
        /*.outgoing_channel */ group_outgoing_channel
 };
@@ -2435,7 +2435,7 @@ switch_io_routines_t group_io_routines = {
 static switch_call_cause_t group_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
 {
        char *group = NULL;
        switch_call_cause_t cause = SWITCH_CAUSE_NONE;
@@ -2507,7 +2507,7 @@ static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session
        
        
        if (switch_ivr_originate(session, new_session, &cause, dest, timelimit, NULL, 
-                                                        cid_name_override, cid_num_override, NULL, var_event, myflags) == SWITCH_STATUS_SUCCESS) {
+                                                        cid_name_override, cid_num_override, NULL, var_event, myflags, cancel_cause) == SWITCH_STATUS_SUCCESS) {
                const char *context;
                switch_caller_profile_t *cp;
                
@@ -2545,7 +2545,7 @@ switch_endpoint_interface_t *user_endpoint_interface;
 static switch_call_cause_t user_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
 switch_io_routines_t user_io_routines = {
        /*.outgoing_channel */ user_outgoing_channel
 };
@@ -2553,7 +2553,7 @@ switch_io_routines_t user_io_routines = {
 static switch_call_cause_t user_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
 {
        switch_xml_t x_domain = NULL, xml = NULL, x_user = NULL, x_group = NULL, x_param, x_params;
        char *user = NULL, *domain = NULL;
@@ -2717,7 +2717,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Waddya Daft? You almost called '%s' in an infinate loop!\n", stupid);
                        cause = SWITCH_CAUSE_INVALID_IE_CONTENTS;
                } else if (switch_ivr_originate(session, new_session, &cause, d_dest, timelimit, NULL, 
-                                                                cid_name_override, cid_num_override, NULL, var_event, myflags) == SWITCH_STATUS_SUCCESS) {
+                                                                               cid_name_override, cid_num_override, outbound_profile, var_event, myflags, cancel_cause) == SWITCH_STATUS_SUCCESS) {
                        const char *context;
                        switch_caller_profile_t *cp;
 
index ab680b5134ceb5a76bbd541faa082837ee5d60aa..05164d8881a4cbc4c162cd44fb7ef3722d44b00a 100644 (file)
@@ -492,7 +492,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
        switch_assert(ovars);
        switch_event_add_header(ovars, SWITCH_STACK_BOTTOM, "originate_timeout", "%d", h->timeout);
        
-       if (switch_ivr_originate(NULL, &session, &cause, h->originate_string, h->timeout, NULL, NULL, NULL, NULL, ovars, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
+       if (switch_ivr_originate(NULL, &session, &cause, h->originate_string, h->timeout, NULL, NULL, NULL, NULL, ovars, SOF_NONE, NULL) != SWITCH_STATUS_SUCCESS) {
                switch_snprintf(sql, sizeof(sql), "update fifo_outbound set use_count=use_count-1, outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag where uuid='%s'", 
                                                (long)switch_epoch_time_now(NULL), h->uuid);
                fifo_execute_sql(sql, globals.sql_mutex);
@@ -1307,7 +1307,7 @@ SWITCH_STANDARD_APP(fifo_function)
                                        switch_ivr_play_file(session, NULL, o_announce, NULL);
                                }
 
-                               if (switch_ivr_originate(session, &other_session, &cause, url, 120, NULL, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
+                               if (switch_ivr_originate(session, &other_session, &cause, url, 120, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL) != SWITCH_STATUS_SUCCESS) {
                                        other_session = NULL;
                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Originate to [%s] failed, cause: %s\n", url, switch_channel_cause2str(cause));
 
index 5fff1b2cea35e9874b94f577cd7ced82f17c6858..e328437a3bcc602a469cb78b3508e24db3c3542f 100644 (file)
@@ -297,14 +297,14 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt)
 switch_endpoint_interface_t *sip_endpoint_interface;
 static switch_call_cause_t sip_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
 switch_io_routines_t sip_io_routines = {
        /*.outgoing_channel */ sip_outgoing_channel
 };
 
 static switch_call_cause_t sip_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
 {
        const char *profile;
 
@@ -321,7 +321,7 @@ static switch_call_cause_t sip_outgoing_channel(switch_core_session_t *session,
 
        UNPROTECT_INTERFACE(sip_endpoint_interface);
 
-       return switch_core_session_outgoing_channel(session, var_event, "sofia", outbound_profile, new_session, pool, SOF_NONE);
+       return switch_core_session_outgoing_channel(session, var_event, "sofia", outbound_profile, new_session, pool, SOF_NONE, cancel_cause);
 }
 
 
@@ -331,18 +331,18 @@ static switch_call_cause_t sip_outgoing_channel(switch_core_session_t *session,
 switch_endpoint_interface_t *iax2_endpoint_interface;
 static switch_call_cause_t iax2_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
 switch_io_routines_t iax2_io_routines = {
        /*.outgoing_channel */ iax2_outgoing_channel
 };
 
 static switch_call_cause_t iax2_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
 {
        UNPROTECT_INTERFACE(iax2_endpoint_interface);
 
-       return switch_core_session_outgoing_channel(session, var_event, "iax", outbound_profile, new_session, pool, SOF_NONE);
+       return switch_core_session_outgoing_channel(session, var_event, "iax", outbound_profile, new_session, pool, SOF_NONE, cancel_cause);
 }
 
 
index f544857ee74924a59a403bf8c7fa7bd7d7993ab8..1332f5a4add66650390833bd0f7fa55b99444310 100644 (file)
@@ -151,7 +151,7 @@ static switch_status_t channel_on_exchange_media(switch_core_session_t *session)
 static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
 static switch_call_cause_t channel_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
 static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
@@ -761,7 +761,7 @@ static switch_endpoint_interface_t channel_endpoint_interface = {
 */
 static switch_call_cause_t channel_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
 {
 
        if ((*new_session = switch_core_session_request(&channel_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
index 4fc2b6ced7849d1a18bb516fe4eb2286cd64dbb2..ac9a9a1154e51c71fe96fcace83f56bc0a21acee 100644 (file)
@@ -206,7 +206,7 @@ static switch_status_t channel_on_exchange_media(switch_core_session_t *session)
 static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
 static switch_call_cause_t channel_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
 static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
@@ -1618,7 +1618,7 @@ switch_io_routines_t dingaling_io_routines = {
 */
 static switch_call_cause_t channel_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
 {
        if ((*new_session = switch_core_session_request(dingaling_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
                struct private_object *tech_pvt;
index 219f35e227cc99873b3effebafc0ae9bc9926191..054ce2586c056354764c7749e2689d73ea47c751 100644 (file)
@@ -435,7 +435,7 @@ static switch_status_t channel_on_exchange_media(switch_core_session_t *session)
 static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
 static switch_call_cause_t channel_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
 static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
@@ -744,7 +744,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
 */
 static switch_call_cause_t channel_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
 {
        if ((*new_session = switch_core_session_request(iax_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
                private_t *tech_pvt;
index 30a95dc6d404c81ae3f99e2e9b2488976443420a..876a2df9015185313e55baad73082c0938009c13 100644 (file)
@@ -97,7 +97,7 @@ static switch_status_t channel_on_exchange_media(switch_core_session_t *session)
 static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
 static switch_call_cause_t channel_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
 static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
@@ -778,7 +778,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
 
 static switch_call_cause_t channel_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
 {
        char name[128];
 
index f0f1e6f98169ab998ebc29825f074f37dc653d15..24458e440b1544096025588120fdf0d16dd9ff24 100644 (file)
@@ -156,7 +156,7 @@ static switch_status_t channel_on_exchange_media(switch_core_session_t *session)
 static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
 static switch_call_cause_t channel_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
 static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
@@ -725,7 +725,7 @@ switch_io_routines_t portaudio_io_routines = {
 */
 static switch_call_cause_t channel_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
 {
 
        if ((*new_session = switch_core_session_request(portaudio_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
index 4bf5b6eb6448373a27ea3ee4f2215349e9a000a6..aec59e41c8712f089fca31a7ae482b2f8ee1d297 100644 (file)
@@ -106,7 +106,7 @@ static switch_status_t channel_on_exchange_media(switch_core_session_t *session)
 static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
 static switch_call_cause_t channel_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
 static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
@@ -414,7 +414,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
 */
 static switch_call_cause_t channel_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
 {
        if ((*new_session = switch_core_session_request(reference_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
                private_t *tech_pvt;
index 6bc9356dc65014ec09e74d8d874e4a045f963f0b..07f36f550de6f46c88fcd9bed9c584e2c86ce0a8 100644 (file)
@@ -193,7 +193,7 @@ static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
 static switch_call_cause_t channel_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
 static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
@@ -864,7 +864,7 @@ switch_io_routines_t skypiax_io_routines = {
 static switch_call_cause_t channel_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_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
 {
        private_t *tech_pvt = NULL;
        if ((*new_session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
index 4890a54c851ec7f87a0fd1304cc6560026aa80ae..955d79e775388a9ee255c03a693a63a41b049225 100644 (file)
@@ -54,7 +54,7 @@ static switch_status_t sofia_on_exchange_media(switch_core_session_t *session);
 static switch_status_t sofia_on_soft_execute(switch_core_session_t *session);
 static switch_call_cause_t sofia_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_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
 static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t sofia_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t sofia_read_video_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
@@ -2870,7 +2870,7 @@ static switch_status_t sofia_manage(char *relative_oid, switch_management_action
 
 static switch_call_cause_t sofia_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_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
 {
        switch_call_cause_t cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
        switch_core_session_t *nsession = NULL;
index cf2f33e41aa7d92ba19eda6d04340987503c7a0e..a60fab97ae76aad625fe4a6104fc663657785796 100644 (file)
@@ -4292,7 +4292,7 @@ void *SWITCH_THREAD_FUNC nightmare_xfer_thread_run(switch_thread_t *thread, void
                        switch_channel_t *channel_a = switch_core_session_get_channel(session);
 
                        status = switch_ivr_originate(NULL, &tsession, &cause, nhelper->exten, timeout, NULL, NULL, NULL,
-                                          switch_channel_get_caller_profile(channel_a), nhelper->vars, SOF_NONE);
+                                          switch_channel_get_caller_profile(channel_a), nhelper->vars, SOF_NONE, NULL);
 
                        if ((switch_channel_up(channel_a))) {
                                if (status != SWITCH_STATUS_SUCCESS || cause != SWITCH_CAUSE_SUCCESS) {
index 5c38b4c09a68c367a28887f8042f1e718096cc57..e17b22d57e73903d1a2ea73255eed4438c9a6005 100644 (file)
@@ -2536,88 +2536,89 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
          video:
 
                sofia_glue_check_video_codecs(tech_pvt);
+               if (sofia_test_flag(tech_pvt, TFLAG_VIDEO) && tech_pvt->video_rm_encoding && tech_pvt->remote_sdp_video_port) {
+                       
+                       /******************************************************************************************/
+                       if (tech_pvt->video_rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
+                               //const char *ip = switch_channel_get_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE);
+                               //const char *port = switch_channel_get_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE);
+                               char *remote_host = switch_rtp_get_remote_host(tech_pvt->video_rtp_session);
+                               switch_port_t remote_port = switch_rtp_get_remote_port(tech_pvt->video_rtp_session);
+
+                               if (remote_host && remote_port && !strcmp(remote_host, tech_pvt->remote_sdp_video_ip) && remote_port == tech_pvt->remote_sdp_video_port) {
+                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Video params are unchanged for %s.\n", switch_channel_get_name(tech_pvt->channel));
+                                       goto video_up;
+                               } else {
+                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Video params changed for %s from %s:%d to %s:%d\n", 
+                                                                         switch_channel_get_name(tech_pvt->channel),
+                                                                         remote_host, remote_port, tech_pvt->remote_sdp_video_ip, tech_pvt->remote_sdp_video_port);
+                               }
+                       }
 
-               /******************************************************************************************/
-               if (tech_pvt->video_rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
-                       //const char *ip = switch_channel_get_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE);
-                       //const char *port = switch_channel_get_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE);
-                       char *remote_host = switch_rtp_get_remote_host(tech_pvt->video_rtp_session);
-                       switch_port_t remote_port = switch_rtp_get_remote_port(tech_pvt->video_rtp_session);
-
-                       if (remote_host && remote_port && !strcmp(remote_host, tech_pvt->remote_sdp_video_ip) && remote_port == tech_pvt->remote_sdp_video_port) {
-                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Video params are unchanged for %s.\n", switch_channel_get_name(tech_pvt->channel));
-                               goto video_up;
-                       } else {
-                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Video params changed for %s from %s:%d to %s:%d\n", 
+                       if (!switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) {
+                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "VIDEO RTP [%s] %s port %d -> %s port %d codec: %u ms: %d\n",
                                                                  switch_channel_get_name(tech_pvt->channel),
-                                                                 remote_host, remote_port, tech_pvt->remote_sdp_video_ip, tech_pvt->remote_sdp_video_port);
+                                                                 tech_pvt->local_sdp_audio_ip,
+                                                                 tech_pvt->local_sdp_video_port,
+                                                                 tech_pvt->remote_sdp_video_ip,
+                                                                 tech_pvt->remote_sdp_video_port, tech_pvt->video_agreed_pt, tech_pvt->read_impl.microseconds_per_packet / 1000);
                        }
-               }
 
-               if (!switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) {
-                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "VIDEO RTP [%s] %s port %d -> %s port %d codec: %u ms: %d\n",
-                                                         switch_channel_get_name(tech_pvt->channel),
-                                                         tech_pvt->local_sdp_audio_ip,
-                                                         tech_pvt->local_sdp_video_port,
-                                                         tech_pvt->remote_sdp_video_ip,
-                                                         tech_pvt->remote_sdp_video_port, tech_pvt->video_agreed_pt, tech_pvt->read_impl.microseconds_per_packet / 1000);
-               }
+                       switch_snprintf(tmp, sizeof(tmp), "%d", tech_pvt->local_sdp_video_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_PORT_VARIABLE, tmp);
 
-               switch_snprintf(tmp, sizeof(tmp), "%d", tech_pvt->local_sdp_video_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_PORT_VARIABLE, tmp);
-
-               if (tech_pvt->video_rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
-                       sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
+                       if (tech_pvt->video_rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
+                               sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
                
-                       if (switch_rtp_set_remote_address(tech_pvt->video_rtp_session, tech_pvt->remote_sdp_video_ip, tech_pvt->remote_sdp_video_port, SWITCH_TRUE, &err) !=
-                               SWITCH_STATUS_SUCCESS) {
-                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "VIDEO RTP REPORTS ERROR: [%s]\n", err);
-                       } else {
-                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "VIDEO RTP CHANGING DEST TO: [%s:%d]\n",
-                                                                 tech_pvt->remote_sdp_video_ip, tech_pvt->remote_sdp_video_port);
-                               if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) &&
-                                       !((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
-                                       /* Reactivate the NAT buster flag. */
-                                       switch_rtp_set_flag(tech_pvt->video_rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
+                               if (switch_rtp_set_remote_address(tech_pvt->video_rtp_session, tech_pvt->remote_sdp_video_ip, tech_pvt->remote_sdp_video_port, SWITCH_TRUE, &err) !=
+                                       SWITCH_STATUS_SUCCESS) {
+                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "VIDEO RTP REPORTS ERROR: [%s]\n", err);
+                               } else {
+                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "VIDEO RTP CHANGING DEST TO: [%s:%d]\n",
+                                                                         tech_pvt->remote_sdp_video_ip, tech_pvt->remote_sdp_video_port);
+                                       if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) &&
+                                               !((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
+                                               /* Reactivate the NAT buster flag. */
+                                               switch_rtp_set_flag(tech_pvt->video_rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
+                                       }
                                }
+                               goto video_up;
                        }
-                       goto video_up;
-               }
 
-               if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) {
-                       if ((status = sofia_glue_tech_proxy_remote_addr(tech_pvt)) != SWITCH_STATUS_SUCCESS) {
-                               goto end;
-                       }
+                       if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) {
+                               if ((status = sofia_glue_tech_proxy_remote_addr(tech_pvt)) != SWITCH_STATUS_SUCCESS) {
+                                       goto end;
+                               }
 
-                       if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) &&
-                               !((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
-                               flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_PROXY_MEDIA | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_DATAWAIT);
-                       } else {
-                               flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_PROXY_MEDIA | SWITCH_RTP_FLAG_DATAWAIT);
-                       }
-                       timer_name = NULL;
+                               if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) &&
+                                       !((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
+                                       flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_PROXY_MEDIA | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_DATAWAIT);
+                               } else {
+                                       flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_PROXY_MEDIA | SWITCH_RTP_FLAG_DATAWAIT);
+                               }
+                               timer_name = NULL;
 
-                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG,
-                                                         "PROXY VIDEO RTP [%s] %s:%d->%s:%d codec: %u ms: %d\n",
-                                                         switch_channel_get_name(tech_pvt->channel),
-                                                         tech_pvt->local_sdp_audio_ip,
-                                                         tech_pvt->local_sdp_video_port,
-                                                         tech_pvt->remote_sdp_video_ip,
-                                                         tech_pvt->remote_sdp_video_port, tech_pvt->video_agreed_pt, tech_pvt->read_impl.microseconds_per_packet / 1000);
+                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG,
+                                                                 "PROXY VIDEO RTP [%s] %s:%d->%s:%d codec: %u ms: %d\n",
+                                                                 switch_channel_get_name(tech_pvt->channel),
+                                                                 tech_pvt->local_sdp_audio_ip,
+                                                                 tech_pvt->local_sdp_video_port,
+                                                                 tech_pvt->remote_sdp_video_ip,
+                                                                 tech_pvt->remote_sdp_video_port, tech_pvt->video_agreed_pt, tech_pvt->read_impl.microseconds_per_packet / 1000);
 
-               } else {
-                       timer_name = tech_pvt->profile->timer_name;
+                       } else {
+                               timer_name = tech_pvt->profile->timer_name;
 
-                       if ((var = switch_channel_get_variable(tech_pvt->channel, "rtp_timer_name"))) {
-                               timer_name = (char *) var;
+                               if ((var = switch_channel_get_variable(tech_pvt->channel, "rtp_timer_name"))) {
+                                       timer_name = (char *) var;
+                               }
                        }
-               }
 
-               /******************************************************************************************/
+                       /******************************************************************************************/
+
 
 
-               if (sofia_test_flag(tech_pvt, TFLAG_VIDEO) && tech_pvt->video_rm_encoding && tech_pvt->remote_sdp_video_port) {
                        if (!tech_pvt->local_sdp_video_port) {
                                sofia_glue_tech_choose_video_port(tech_pvt, 1);
                        }
index aa3353b450f233d16c6eebb5952e448704338cbd..996c8687f6eac118d42d984888127b941b389983 100644 (file)
@@ -137,7 +137,7 @@ static switch_call_cause_t unicall_outgoing_channel(switch_core_session_t *sessi
                                                     switch_caller_profile_t *outbound_profile,
                                                     switch_core_session_t **new_session,
                                                     switch_memory_pool_t **pool,
-                                                    switch_originate_flag_t flags);
+                                                    switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
 static switch_status_t unicall_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t unicall_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t unicall_kill_channel(switch_core_session_t *session, int sig);
@@ -1543,7 +1543,7 @@ static switch_call_cause_t unicall_outgoing_channel(switch_core_session_t *sessi
                                                     switch_caller_profile_t *outbound_profile,
                                                     switch_core_session_t **new_session,
                                                     switch_memory_pool_t **pool,
-                                                    switch_originate_flag_t flags)
+                                                    switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
 {
     private_t *tech_pvt;
     switch_channel_t *channel;
index c5fd2ccd0cded933d9db524a14d3f5d657b6cdba..fdb983ad9ce4a0026a54127cf71416ec5e12496f 100644 (file)
@@ -2852,7 +2852,7 @@ static JSBool session_construct(JSContext * cx, JSObject * obj, uintN argc, jsva
                                }
                        }
                        if (switch_ivr_originate(old_jss ? old_jss->session : NULL, 
-                                                                        &jss->session, &jss->cause, uuid, 60, NULL, NULL, NULL, NULL, NULL, SOF_NONE) == SWITCH_STATUS_SUCCESS) {
+                                                                        &jss->session, &jss->cause, uuid, 60, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL) == SWITCH_STATUS_SUCCESS) {
                                switch_set_flag(jss, S_HUP);
                                switch_channel_set_state(switch_core_session_get_channel(jss->session), CS_SOFT_EXECUTE);
                                *rval = BOOLEAN_TO_JSVAL(JS_TRUE);
@@ -3013,7 +3013,7 @@ static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsva
                caller_profile = switch_caller_profile_new(pool, username, dialplan, cid_name, cid_num, network_addr, ani, aniii, rdnis, modname, context, dest);
 
                saveDepth = JS_SuspendRequest(cx);
-               status = switch_ivr_originate(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile, NULL, SOF_NONE);
+               status = switch_ivr_originate(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile, NULL, SOF_NONE, NULL);
                JS_ResumeRequest(cx, saveDepth);
 
                if (status != SWITCH_STATUS_SUCCESS) {
index 8081171c6a15fe8199b4730d25c4823a60500657..6cf9bad11eca3de70f8aafe38a1d0bc15091f902 100644 (file)
@@ -346,7 +346,9 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
                                                                                                                                                 const char *endpoint_name,
                                                                                                                                                 switch_caller_profile_t *caller_profile,
                                                                                                                                                 switch_core_session_t **new_session,
-                                                                                                                                                switch_memory_pool_t **pool, switch_originate_flag_t flags)
+                                                                                                                                                switch_memory_pool_t **pool, 
+                                                                                                                                                switch_originate_flag_t flags,
+                                                                                                                                                switch_call_cause_t *cancel_cause)
 {
        switch_io_event_hook_outgoing_channel_t *ptr;
        switch_status_t status = SWITCH_STATUS_FALSE;
@@ -408,7 +410,7 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
        }
 
        if ((cause =
-                endpoint_interface->io_routines->outgoing_channel(session, var_event, outgoing_profile, new_session, pool, flags)) != SWITCH_CAUSE_SUCCESS) {
+                endpoint_interface->io_routines->outgoing_channel(session, var_event, outgoing_profile, new_session, pool, flags, cancel_cause)) != SWITCH_CAUSE_SUCCESS) {
                UNPROTECT_INTERFACE(endpoint_interface);
                return cause;
        }
index db0b385680ea8b3ff39f23c0ebad8217034ed6dc..38af96b7938110bf6ca360e092fe7c8478557e53 100644 (file)
@@ -488,7 +488,7 @@ SWITCH_DECLARE_CONSTRUCTOR CoreSession::CoreSession(char *nuuid, CoreSession *a_
                allocated = 1;
     } else {
                cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
-               if (switch_ivr_originate(a_leg ? a_leg->session : NULL, &session, &cause, nuuid, 60, NULL, NULL, NULL, NULL, NULL, SOF_NONE) 
+               if (switch_ivr_originate(a_leg ? a_leg->session : NULL, &session, &cause, nuuid, 60, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL
                        == SWITCH_STATUS_SUCCESS) {
                        channel = switch_core_session_get_channel(session);
                        allocated = 1;
@@ -993,7 +993,8 @@ SWITCH_DECLARE(int) CoreSession::originate(CoreSession *a_leg_session, char *des
                                                         NULL, 
                                                         NULL,
                                                         NULL,
-                                                        SOF_NONE) != SWITCH_STATUS_SUCCESS) {
+                                                        SOF_NONE,
+                                                        NULL) != SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error Creating Outgoing Channel! [%s]\n", dest);
                goto failed;
 
index 9d45af65fc26e1720e83fad7a0a5ad6616664940..4e31fce9e7fc711cf1e5467eb6cacf9c57c75493 100644 (file)
@@ -1141,6 +1141,7 @@ typedef struct {
        switch_core_session_t *session;
        switch_core_session_t *bleg;
        switch_call_cause_t cause;
+       switch_call_cause_t cancel_cause;
        const char *bridgeto;
        uint32_t timelimit_sec;
        const switch_state_handler_table_t *table;
@@ -1152,6 +1153,7 @@ typedef struct {
        switch_status_t status;
        int done;
        switch_thread_t *thread;
+       switch_mutex_t *mutex;
 } enterprise_originate_handle_t;
 
 
@@ -1174,12 +1176,22 @@ static void *SWITCH_THREAD_FUNC enterprise_originate_thread(switch_thread_t *thr
                                                                                  handle->cid_num_override,
                                                                                  handle->caller_profile_override,
                                                                                  handle->ovars,
-                                                                                 handle->flags
+                                                                                 handle->flags,
+                                                                                 &handle->cancel_cause
                                                                                  );
 
 
        handle->done = 1;
+       switch_mutex_lock(handle->mutex);
+       switch_mutex_unlock(handle->mutex);
        
+       if (handle->done != 2) {
+               if (handle->status == SWITCH_STATUS_SUCCESS) {
+                       switch_channel_hangup(switch_core_session_get_channel(handle->bleg), SWITCH_CAUSE_LOSE_RACE);
+                       switch_core_session_rwunlock(handle->bleg);
+               }
+       }
+
        return NULL;
 }
 
@@ -1236,7 +1248,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess
        char *data;
        switch_status_t status = SWITCH_STATUS_FALSE;
        switch_threadattr_t *thd_attr = NULL;
-       int running = 0;
+       int running = 0, over = 0;
        switch_status_t tstatus = SWITCH_STATUS_FALSE;
        switch_memory_pool_t *pool;
        switch_event_header_t *hi = NULL;
@@ -1358,6 +1370,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess
                }
        }
 
+       switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "ignore_early_media", "true");
 
        if (!(x_argc = switch_separate_string_string(data, SWITCH_ENT_ORIGINATE_DELIM, x_argv, MAX_PEERS))) {
                *cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
@@ -1376,6 +1389,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess
                handles[i].session = session;
                handles[i].bleg = NULL;
                handles[i].cause = 0;
+               handles[i].cancel_cause = 0;
                handles[i].bridgeto = x_argv[i];
                handles[i].timelimit_sec = timelimit_sec;
                handles[i].table = table;
@@ -1384,6 +1398,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess
                handles[i].caller_profile_override = cp;
                switch_event_dup(&handles[i].ovars, var_event);         
                handles[i].flags = flags;
+               switch_mutex_init(&handles[i].mutex, SWITCH_MUTEX_NESTED, pool);
+               switch_mutex_lock(handles[i].mutex);
                switch_thread_create(&handles[i].thread, thd_attr, enterprise_originate_thread, &handles[i], pool);
        }
        
@@ -1412,26 +1428,33 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess
 
        for(;;) {
                running = 0;
+               over = 0;
                
                if (channel && !switch_channel_ready(channel)) {
                        break;
                }
 
                for(i = 0; i < x_argc; i++) {
+
+
                        if (handles[i].done == 0) {
                                running++;
                        } else if (handles[i].done == 1) {
                                if (handles[i].status == SWITCH_STATUS_SUCCESS) {
+                                       handles[i].done = 2;
                                        hp = &handles[i];
                                        goto done;
                                } else {
-                                       handles[i].done = 2;
+                                       handles[i].done = -1;
                                }
+                       } else {
+                               over++;
                        }
-                       switch_cond_next();
+
+                       switch_yield(10000);
                }
 
-               if (!running) {
+               if (!running || over == x_argc) {
                        break;
                }
        }
@@ -1439,36 +1462,39 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess
 
  done:
 
-       if (channel && rb_data.thread) {
-               switch_channel_set_flag(channel, CF_NOT_READY);
-               switch_thread_join(&tstatus, rb_data.thread);
-               switch_channel_clear_flag(channel, CF_NOT_READY);
+       if (hp) {
+               *cause = hp->cause;
+               status = hp->status;
+               *bleg = hp->bleg;
+               switch_mutex_unlock(hp->mutex);
+               switch_thread_join(&tstatus, hp->thread);
+               switch_event_destroy(&hp->ovars);
        }
 
-
        for(i = 0; i < x_argc; i++) {
-               if (hp && hp == &handles[i]) {
+               if (hp == &handles[i]) {
                        continue;
                }
-               if (handles[i].bleg) {
-                       switch_channel_hangup(switch_core_session_get_channel(handles[i].bleg), SWITCH_CAUSE_LOSE_RACE);
-                       switch_core_session_rwunlock(handles[i].bleg);
-               }
+               handles[i].cancel_cause = SWITCH_CAUSE_LOSE_RACE;
+       }
 
-               handles[i].cause = SWITCH_CAUSE_LOSE_RACE;
+       for(i = 0; i < x_argc; i++) {
+               if (hp == &handles[i]) {
+                       continue;
+               }
+               switch_mutex_unlock(handles[i].mutex);
                switch_thread_join(&tstatus, handles[i].thread);
                switch_event_destroy(&handles[i].ovars);
        }
        
 
-       if (hp) {
-               *cause = hp->cause;
-               status = hp->status;
-               *bleg = hp->bleg;
-               switch_thread_join(&tstatus, hp->thread);
-               switch_event_destroy(&hp->ovars);
+       if (channel && rb_data.thread) {
+               switch_channel_set_flag(channel, CF_NOT_READY);
+               switch_thread_join(&tstatus, rb_data.thread);
+               switch_channel_clear_flag(channel, CF_NOT_READY);
        }
 
+
  end:
 
        if (var_event && var_event != ovars) {
@@ -1498,7 +1524,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                                                                                         const char *cid_num_override,
                                                                                                         switch_caller_profile_t *caller_profile_override, 
                                                                                                         switch_event_t *ovars,
-                                                                                                        switch_originate_flag_t flags
+                                                                                                        switch_originate_flag_t flags,
+                                                                                                        switch_call_cause_t *cancel_cause
                                                                                                         )
 {
        originate_status_t originate_status[MAX_PEERS] = { { 0 } }; 
@@ -1547,7 +1574,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                                                                  caller_profile_override, ovars, flags);
        }
 
-
        oglobals.ringback_ok = 1;
 
        if (session) {
@@ -2218,7 +2244,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "originate_early_media", oglobals.early_ok ? "true" : "false");
 
                                if ((reason = switch_core_session_outgoing_channel(oglobals.session, var_event, chan_type, 
-                                                                                                                                  new_profile, &new_session, &pool, myflags)) != SWITCH_CAUSE_SUCCESS) {
+                                                                                                                                  new_profile, &new_session, &pool, myflags, cancel_cause)) != SWITCH_CAUSE_SUCCESS) {
                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot create outgoing channel of type [%s] cause: [%s]\n", 
                                                                          chan_type, switch_channel_cause2str(reason));
                                        
@@ -2439,11 +2465,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                oglobals.ringback_ok = 0;
                        }
                        
-                       *cause = 0;
-                       while (*cause == 0 && ((!caller_channel || switch_channel_ready(caller_channel) || switch_channel_test_flag(caller_channel, CF_XFER_ZOMBIE))) && 
-                                  check_channel_status(&oglobals, originate_status, and_argc)) {
+                       while ((!caller_channel || switch_channel_ready(caller_channel) || switch_channel_test_flag(caller_channel, CF_XFER_ZOMBIE)) &&
+                   check_channel_status(&oglobals, originate_status, and_argc)) {
                                time_t elapsed = switch_epoch_time_now(NULL) - start;
                                
+                               if (cancel_cause && *cancel_cause > 0) {
+                                       force_reason = *cancel_cause;
+                                       oglobals.idx = IDX_CANCEL;
+                                       goto notready;
+                               }
+
                                check_per_channel_timeouts(&oglobals, originate_status, and_argc, start);
 
                                if (oglobals.session) {
@@ -2603,11 +2634,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                }
                                
                        }
-
-                       if (*cause) {
-                               force_reason = *cause;
-                       }
-
+                       
                  notready:
 
                        if (caller_channel) {
@@ -2812,7 +2839,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                             switch_ivr_uuid_bridge(holding, switch_core_session_get_uuid(originate_status[i].peer_session));
                                                        holding = NULL;
                         } else {
-                                                       switch_channel_hangup(originate_status[i].peer_channel, reason);
+                                                       switch_channel_hangup(originate_status[i].peer_channel, force_reason ? force_reason : reason);
                                                }
                                        }
                                }