]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix FSCORE-74
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 20 Dec 2007 21:42:00 +0000 (21:42 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 20 Dec 2007 21:42:00 +0000 (21:42 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6921 d0543943-73ff-0310-b7d9-9358b9ac24b2

24 files changed:
src/include/switch_channel.h
src/include/switch_core.h
src/include/switch_core_event_hook.h
src/include/switch_ivr.h
src/include/switch_module_interfaces.h
src/include/switch_types.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/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_portaudio/mod_portaudio.c
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
src/mod/endpoints/mod_woomera/mod_woomera.c
src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
src/switch_channel.c
src/switch_core_session.c
src/switch_cpp.cpp
src/switch_ivr_originate.c
src/switch_swig.c

index a50c3b83f103811618d1d5db6fbea17ec8b9948f..7cd448196df40c7e8da9f8ed8135593a578d6d57 100644 (file)
@@ -210,6 +210,8 @@ SWITCH_DECLARE(char *) switch_channel_get_uuid(switch_channel_t *channel);
 */
 SWITCH_DECLARE(switch_status_t) switch_channel_set_variable(switch_channel_t *channel, const char *varname, const char *value);
 
+SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_partner(switch_channel_t *channel, const char *varname, const char *value);
+
 /*!
   \brief Retrieve a variable from a given channel
   \param channel channel to retrieve variable from
index 577a3d186bf28a8071355b7bd324611ebec95d79..d6e034d5804a0071ccb99684990e4208bb9effa7 100644 (file)
@@ -698,12 +698,15 @@ 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
+  \paeam flags flags to use
   \return the cause code of the attempted call
 */
 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_core_session_t **new_session,
+                                                                                                                                                switch_memory_pool_t **pool,
+                                                                                                                                                switch_originate_flag_t flags);
 
 /*! 
   \brief Receive a message on a given session
index 8f48d87df770990fb768e2d73401588e852d14f4..0e2f5751b37a3e0a16f0a73b23696ecf777a0524 100644 (file)
@@ -48,7 +48,8 @@ typedef struct switch_io_event_hook_waitfor_write switch_io_event_hook_waitfor_w
 typedef struct switch_io_event_hook_send_dtmf switch_io_event_hook_send_dtmf_t;
 typedef struct switch_io_event_hook_recv_dtmf switch_io_event_hook_recv_dtmf_t;
 typedef struct switch_io_event_hook_state_change switch_io_event_hook_state_change_t;
-typedef switch_status_t (*switch_outgoing_channel_hook_t) (switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t *);
+typedef switch_status_t (*switch_outgoing_channel_hook_t)
+(switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t *, switch_originate_flag_t);
 typedef switch_status_t (*switch_receive_message_hook_t) (switch_core_session_t *, switch_core_session_message_t *);
 typedef switch_status_t (*switch_receive_event_hook_t) (switch_core_session_t *, switch_event_t *);
 typedef switch_status_t (*switch_read_frame_hook_t) (switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
index bbc05e087e5232737efb1a278e8885b8d99d74da..b6ce42ace24872d571b185f1c9e2d2f554763bf7 100644 (file)
@@ -355,6 +355,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses
   \param cid_name_override override the caller id name
   \param cid_num_override override the caller id number
   \param caller_profile_override override the entire calling caller profile
+  \param flags flags to pass
   \return SWITCH_STATUS_SUCCESS if bleg is a running session.
   \note bleg will be read locked which must be unlocked with switch_core_session_rwunlock() before losing scope
 */
@@ -364,7 +365,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                                                                                         const char *bridgeto,
                                                                                                         uint32_t timelimit_sec,
                                                                                                         const switch_state_handler_table_t *table,
-                                                                                                        const char *cid_name_override, const char *cid_num_override, switch_caller_profile_t *caller_profile_override);
+                                                                                                        const char *cid_name_override,
+                                                                                                        const char *cid_num_override,
+                                                                                                        switch_caller_profile_t *caller_profile_override,
+                                                                                                        switch_originate_flag_t flags);
 
 /*!
   \brief Bridge Audio from one session to another
index 19d3f9b081b22deffc41287e151fc64c419e6ecf..b5e4ed9a5534d2944b3c364e0f5165d7d94a4288 100644 (file)
@@ -98,8 +98,8 @@ struct switch_stream_handle {
 struct switch_io_event_hooks;
 
 
-typedef switch_call_cause_t 
-(*switch_io_outgoing_channel_t)(switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **);
+typedef switch_call_cause_t (*switch_io_outgoing_channel_t)
+(switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **, switch_originate_flag_t);
 typedef switch_status_t (*switch_io_read_frame_t) (switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
 typedef switch_status_t (*switch_io_write_frame_t) (switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int);
 typedef switch_status_t (*switch_io_kill_channel_t) (switch_core_session_t *, int);
index 728dc93f174fc843f14831d7dc998c8c1523f209..3969165f0b65955d1bb2dee1e4d0125c81a0bb11 100644 (file)
@@ -136,6 +136,12 @@ SWITCH_BEGIN_EXTERN_C
 #define SWITCH_BITS_PER_BYTE 8
 typedef uint8_t switch_byte_t;
 
+typedef enum {
+       SOF_NONE = 0,
+       SOF_NOBLOCK = (1 << 0),
+       SOF_FORKED_DIAL = (1 << 1) 
+} switch_originate_flag_t;
+
 typedef enum {
        SPF_NONE = 0,
        SPF_ODD = (1 << 0),
index 6d7e6072ca0397533f1d3b4dd285ef8fdfe82114..58e54b73fdb3ff716aec5158c96cfa3f53091738 100644 (file)
@@ -1432,7 +1432,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) != SWITCH_STATUS_SUCCESS) {
+       if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
                if (machine) {
                        stream->write_function(stream, "-ERR %s\n", switch_channel_cause2str(cause));
                } else {
index fba600254947874054abfa3e42191bbe9a9144d9..0796847e57c5aff64f77b8952c24438caea9a794 100644 (file)
@@ -3630,7 +3630,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);
+               status = switch_ivr_originate(NULL, &peer_session, cause, dialstr, 60, NULL, cid_name, cid_num, NULL, SOF_NONE);
                switch_safe_free(dialstr);
 
                if (status != SWITCH_STATUS_SUCCESS) {
@@ -3667,7 +3667,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, &audio_bridge_peer_state_handlers, cid_name, cid_num,
-                                                        NULL) != SWITCH_STATUS_SUCCESS) {
+                                                        NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create outgoing channel, cause: %s\n", switch_channel_cause2str(*cause));
                if (caller_channel) {
                        switch_channel_hangup(caller_channel, *cause);
index f7ac9ee165c87392867a2ee3a95b5aa75ba4de8b..729ab57b1edd111f9f6391e2a6b215ee19cfb20d 100644 (file)
@@ -1374,7 +1374,7 @@ SWITCH_STANDARD_APP(audio_bridge_function)
                }
        }
 
-       if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
+       if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Originate Failed.  Cause: %s\n", switch_channel_cause2str(cause));
 
                /* no answer is *always* a reason to continue */
@@ -1449,19 +1449,23 @@ SWITCH_STANDARD_APP(audio_bridge_function)
 switch_endpoint_interface_t *user_endpoint_interface;
 static switch_call_cause_t user_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_core_session_t **new_session, 
+                                                                                                switch_memory_pool_t **pool,
+                                                                                                switch_originate_flag_t flags);
 switch_io_routines_t user_io_routines = {
        /*.outgoing_channel */ user_outgoing_channel
 };
 
 static switch_call_cause_t user_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_core_session_t **new_session, 
+                                                                                                switch_memory_pool_t **pool,
+                                                                                                switch_originate_flag_t flags)
 {
        switch_xml_t x_domain = NULL, xml = NULL, x_user = NULL, x_param, x_params;     
        char *user = NULL, *domain = NULL;
        const char *dest = NULL;
-       static switch_call_cause_t cause;
+       static switch_call_cause_t cause = SWITCH_CAUSE_SUCCESS;
        unsigned int timelimit = 60;
        switch_channel_t *new_channel = NULL;
 
@@ -1472,7 +1476,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
        }
 
        *domain++ = '\0';
-       
+
        if (switch_xml_locate_user("id", user, domain, NULL, &xml, &x_domain, &x_user, "as_channel=true") != SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", user, domain);
                goto done;
@@ -1510,7 +1514,8 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
                const char *var;
                char *d_dest = NULL;
                switch_channel_t *channel;
-               
+               switch_originate_flag_t myflags = SOF_NONE;
+
                channel = switch_core_session_get_channel(session);
                if ((var = switch_channel_get_variable(channel, "call_timeout"))) {
                        timelimit = atoi(var);
@@ -1521,7 +1526,11 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
 
                d_dest = switch_channel_expand_variables(channel, dest);
                
-               if (switch_ivr_originate(session, new_session, &cause, d_dest, timelimit, NULL, NULL, NULL, NULL) == SWITCH_STATUS_SUCCESS) {
+               if ((flags & SOF_FORKED_DIAL)) {
+                       myflags |= SOF_NOBLOCK;
+               }
+
+               if (switch_ivr_originate(session, new_session, &cause, d_dest, timelimit, NULL, NULL, NULL, NULL, myflags) == SWITCH_STATUS_SUCCESS) {
                        const char *context;
                        switch_caller_profile_t *cp;
 
index afc041b5e47f5e4f13e9658ef8dc330961539eb8..c6fa3ead9a6506be63bcf50040ada58562691f1e 100644 (file)
@@ -312,15 +312,19 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt)
 /* fake chan_sip */
 switch_endpoint_interface_t *sip_endpoint_interface;
 static switch_call_cause_t sip_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_caller_profile_t *outbound_profile,
+                                                                                               switch_core_session_t **new_session, 
+                                                                                               switch_memory_pool_t **pool,
+                                                                                               switch_originate_flag_t flags);
 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_caller_profile_t *outbound_profile,
-                                                                                                       switch_core_session_t **new_session, switch_memory_pool_t **pool)
+                                                                                               switch_caller_profile_t *outbound_profile,
+                                                                                               switch_core_session_t **new_session, 
+                                                                                               switch_memory_pool_t **pool,
+                                                                                               switch_originate_flag_t flags)
 {
        const char *profile;
 
@@ -334,7 +338,7 @@ static switch_call_cause_t sip_outgoing_channel(switch_core_session_t *session,
        }
 
        outbound_profile->destination_number = switch_core_sprintf(outbound_profile->pool, "%s/%s", profile, outbound_profile->destination_number);
-       return switch_core_session_outgoing_channel(session, "sofia", outbound_profile, new_session, pool);
+       return switch_core_session_outgoing_channel(session, "sofia", outbound_profile, new_session, pool, SOF_NONE);
 }
 
 
@@ -343,17 +347,21 @@ static switch_call_cause_t sip_outgoing_channel(switch_core_session_t *session,
 /* fake chan_iax2 */
 switch_endpoint_interface_t *iax2_endpoint_interface;
 static switch_call_cause_t iax2_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_caller_profile_t *outbound_profile,
+                                                                                                switch_core_session_t **new_session, 
+                                                                                                switch_memory_pool_t **pool,
+                                                                                                switch_originate_flag_t flags);
 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_caller_profile_t *outbound_profile,
-                                                                                                       switch_core_session_t **new_session, switch_memory_pool_t **pool)
+                                                                                                switch_caller_profile_t *outbound_profile,
+                                                                                                switch_core_session_t **new_session, 
+                                                                                                switch_memory_pool_t **pool,
+                                                                                                switch_originate_flag_t flags)
 {
-       return switch_core_session_outgoing_channel(session, "iax", outbound_profile, new_session, pool);
+       return switch_core_session_outgoing_channel(session, "iax", outbound_profile, new_session, pool, SOF_NONE);
 }
 
 
index a2b9647410d83fc9e4b8dd0033b0f4c5e8308518..e1b2bd17116f6a5a031813461a0feb07c387ce2a 100644 (file)
@@ -148,7 +148,7 @@ 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_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);
+                                                                                                       switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags);
 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, 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_loadable_module_interface_t channel_module_interface = {
 */
 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)
+                                                                                                       switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
 {
 
        if ((*new_session = switch_core_session_request(&channel_endpoint_interface, pool)) != 0) {
index 97b79561f4df9fa76619233d484d5d4697521840..eec909d09b75491d2be261b2517f2de4ff77fed6 100644 (file)
@@ -206,7 +206,7 @@ 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_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);
+                                                                                                       switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags);
 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, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
@@ -1616,7 +1616,7 @@ switch_io_routines_t dingaling_io_routines = {
 */
 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)
+                                                                                                       switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
 {
        if ((*new_session = switch_core_session_request(dingaling_endpoint_interface, pool)) != 0) {
                struct private_object *tech_pvt;
index f73e6dcdf602640f7fcc0a7d0dd28678fbfcd6b8..650f59228dc068eb87051e98c30471057ecea986 100644 (file)
@@ -421,7 +421,7 @@ 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_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);
+                                                                                                       switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags);
 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, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
@@ -789,7 +789,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_caller_profile_t *outbound_profile,
-                                                                                                       switch_core_session_t **new_session, switch_memory_pool_t **pool)
+                                                                                                       switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
 {
        if ((*new_session = switch_core_session_request(iax_endpoint_interface, pool)) != 0) {
                private_t *tech_pvt;
index e382d73b1276325f4fe5699b036b79fab836f31e..1ad69c5581d8820d30d8c10bc65ee27eaadec2d1 100644 (file)
@@ -145,7 +145,7 @@ 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_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);
+                                                                                                       switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags);
 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, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
@@ -741,7 +741,7 @@ switch_io_routines_t portaudio_io_routines = {
 */
 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)
+                                                                                                       switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
 {
 
        if ((*new_session = switch_core_session_request(portaudio_endpoint_interface, pool)) != 0) {
index b209ea226a520f8221ce1dd884008ecb7152aa63..6c0fc19659ba33aaf594e3d27f844ced959f269b 100644 (file)
@@ -56,7 +56,7 @@ 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_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_memory_pool_t **pool, switch_originate_flag_t flags);
 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);
 static switch_status_t sofia_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, 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, int timeout, switch_io_flag_t flags, int stream_id);
@@ -1490,7 +1490,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_caller_profile_t *outbound_profile, switch_core_session_t **new_session,
-                                                                                                 switch_memory_pool_t **pool)
+                                                                                                 switch_memory_pool_t **pool, switch_originate_flag_t flags)
 {
        switch_call_cause_t cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
        switch_core_session_t *nsession;
index d0c84be93af9b1f2a21f34f4533d44a856c6daaf..486a1e70bce4a68a5768ff4e84aca5bb17984e64 100644 (file)
@@ -1827,7 +1827,8 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
                                                        switch_channel_set_variable(channel, SOFIA_REPLACES_HEADER, rep);
 
                                                        if (switch_ivr_originate(a_session,
-                                                                                                        &tsession, &cause, exten, timeout, &noop_state_handler, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
+                                                                                                        &tsession, &cause, exten, timeout, &noop_state_handler, NULL, NULL, NULL, SOF_NONE) 
+                                                               != SWITCH_STATUS_SUCCESS) {
                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel! [%s]\n", exten);
                                                                nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
                                                                                   NUTAG_SUBSTATE(nua_substate_terminated),
index b719bd33c6140dd05e5eb715255aa7e24f885c41..38125acf0c95cdeb9a0e07dfe5c11cb9385aa8d5 100644 (file)
@@ -467,7 +467,7 @@ 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_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);
+                                                                                                       switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags);
 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,
@@ -1003,7 +1003,7 @@ switch_state_handler_table_t wanpipe_state_handlers = {
 };
 
 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)
+                                                                                                       switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
 {
        char *bchan = NULL;
        char name[128] = "";
index 3c1d9813c090685135502a1e09b4ddffbfdf8557..4ebe0b142b7d20bdfb6fc96c14f5e61c117c9302 100644 (file)
@@ -175,7 +175,7 @@ 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_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);
+                                                                                                       switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags);
 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);
 static switch_status_t woomera_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id);
 static switch_status_t woomera_kill_channel(switch_core_session_t *session, int sig);
@@ -482,7 +482,7 @@ static switch_io_routines_t woomera_io_routines = {
 */
 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)
+                                                                                                       switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
 {
        if ((*new_session = switch_core_session_request(woomera_endpoint_interface, pool)) != 0) {
                struct private_object *tech_pvt;
index 7b24ea9ca31c8145fb990d4125350f9b10a81c9f..7f76b3dfc7606b6cf586753e3a3bb3ff4723ff3a 100644 (file)
@@ -2709,7 +2709,8 @@ 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);
 
-               if (switch_ivr_originate(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile) != SWITCH_STATUS_SUCCESS) {
+               if (switch_ivr_originate(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile, SOF_NONE) 
+                       != SWITCH_STATUS_SUCCESS) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot Create Outgoing Channel! [%s]\n", dest);
                        goto done;
                }
index 1cddf649646b3f53ab987995e3f0f1aa68f8b59f..41f357df32f78ca6aa7f59faca3b40a4365bda0d 100644 (file)
@@ -434,6 +434,34 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_variable(switch_channel_t *ch
        return SWITCH_STATUS_FALSE;
 }
 
+
+SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_partner(switch_channel_t *channel, const char *varname, const char *value)
+{
+       const char *uuid;
+       switch_assert(channel != NULL);
+       
+       if (!switch_strlen_zero(varname)) {
+               if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
+                       switch_core_session_t *session;
+                       switch_mutex_lock(channel->profile_mutex);
+                       if ((session = switch_core_session_locate(uuid))) {
+                               switch_channel_t *tchannel = switch_core_session_get_channel(session);
+                               switch_mutex_lock(tchannel->profile_mutex);
+                               switch_event_del_header(tchannel->variables, varname);
+                               if (value) {
+                                       switch_event_add_header(tchannel->variables, SWITCH_STACK_BOTTOM, varname, "%s", value);
+                               }
+                               switch_mutex_unlock(tchannel->profile_mutex);
+                               switch_core_session_rwunlock(session);
+                       }
+                       switch_mutex_unlock(channel->profile_mutex);
+                       return SWITCH_STATUS_SUCCESS;
+               }
+       }
+
+       return SWITCH_STATUS_FALSE;
+}
+
 SWITCH_DECLARE(int) switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flags)
 {
        switch_assert(channel != NULL);
index b2c8495612c4b7e24072fdcea76c5dead62913b8..1cc88bc773676921800387428661680260ab7d3d 100644 (file)
@@ -176,7 +176,9 @@ SWITCH_DECLARE(int) switch_core_session_get_stream_count(switch_core_session_t *
 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_core_session_t **new_session, 
+                                                                                                                                                switch_memory_pool_t **pool,
+                                                                                                                                                switch_originate_flag_t flags)
 {
        switch_io_event_hook_outgoing_channel_t *ptr;
        switch_status_t status = SWITCH_STATUS_FALSE;
@@ -215,13 +217,13 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
                        }
                }
 
-               if ((cause = endpoint_interface->io_routines->outgoing_channel(session, outgoing_profile, new_session, pool)) != SWITCH_CAUSE_SUCCESS) {
+               if ((cause = endpoint_interface->io_routines->outgoing_channel(session, outgoing_profile, new_session, pool, flags)) != SWITCH_CAUSE_SUCCESS) {
                        return cause;
                }
 
                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) {
+                               if ((status = ptr->outgoing_channel(session, caller_profile, *new_session, flags)) != SWITCH_STATUS_SUCCESS) {
                                        break;
                                }
                        }
index 5b6739f41c8daa76999f8161121c0befd18a0d87..038a0a27018ca58f1714e815525cad16c16892d3 100644 (file)
@@ -341,7 +341,8 @@ int CoreSession::originate(CoreSession *a_leg_session,
                                                         NULL, 
                                                         NULL, 
                                                         NULL, 
-                                                        &caller_profile) != SWITCH_STATUS_SUCCESS) {
+                                                        &caller_profile,
+                                                        SOF_NONE) != SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error Creating Outgoing Channel! [%s]\n", dest);
                goto failed;
 
index 0e177e8acbfcaec2d12f99d98f7f30dec2ea09cf..0111974bbabb4e66305f517c657f78353e15d0ab 100644 (file)
@@ -240,8 +240,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                                                                                         const char *bridgeto,
                                                                                                         uint32_t timelimit_sec,
                                                                                                         const switch_state_handler_table_t *table,
-                                                                                                        const char *cid_name_override, const char *cid_num_override, switch_caller_profile_t *caller_profile_override)
+                                                                                                        const char *cid_name_override, 
+                                                                                                        const char *cid_num_override, 
+                                                                                                        switch_caller_profile_t *caller_profile_override,
+                                                                                                        switch_originate_flag_t flags)
 {
+       switch_originate_flag_t myflags = SOF_NONE;
        char *pipe_names[MAX_PEERS] = { 0 };
        char *data = NULL;
        switch_status_t status = SWITCH_STATUS_SUCCESS;
@@ -392,7 +396,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
 
 
        if (caller_channel) {           /* ringback is only useful when there is an originator */
-               ringback_data = switch_channel_get_variable(caller_channel, "ringback");
+               ringback_data = NULL;
+
+               if (switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
+                       ringback_data = switch_channel_get_variable(caller_channel, "transfer_ringback");
+               } 
+                       
+               if (!ringback_data) {
+                       ringback_data = switch_channel_get_variable(caller_channel, "ringback");
+               }
+               
                switch_channel_set_variable(caller_channel, "originate_disposition", "failure");
        }
 
@@ -454,6 +467,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                switch_assert(loop_data);
                or_argc = switch_separate_string(loop_data, '|', pipe_names, (sizeof(pipe_names) / sizeof(pipe_names[0])));
 
+               if ((flags & SOF_NOBLOCK) && or_argc > 1) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Only calling the first element in the list in this mode.\n");
+                       or_argc = 1;
+               }
+
                if (caller_channel && or_argc > 1 && !ringback_data) {
                        switch_channel_ring_ready(caller_channel);
                        sent_ring = 1;
@@ -486,6 +504,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
 
                        and_argc = switch_separate_string(pipe_names[r], ',', peer_names, (sizeof(peer_names) / sizeof(peer_names[0])));
 
+                       if ((flags & SOF_NOBLOCK) && and_argc > 1) {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Only calling the first elemnent in the list in this mode.\n");
+                               and_argc = 1;
+                       }
+                       
                        if (caller_channel && !sent_ring && and_argc > 1 && !ringback_data) {
                                switch_channel_ring_ready(caller_channel);
                                sent_ring = 1;
@@ -566,8 +589,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                peer_channels[i] = NULL;
                                peer_sessions[i] = NULL;
                                new_session = NULL;
-
-                               if ((reason = switch_core_session_outgoing_channel(session, chan_type, new_profile, &new_session, &pool)) != SWITCH_CAUSE_SUCCESS) {
+                               
+                               if (and_argc > 1 || or_argc > 1) {
+                                       myflags |= SOF_FORKED_DIAL;
+                               }
+                               if ((reason = switch_core_session_outgoing_channel(session, chan_type, new_profile, &new_session, &pool, myflags)) != 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);
@@ -623,12 +649,25 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                        switch_channel_add_state_handler(peer_channels[i], table);
                                }
 
+
+                               if ((flags & SOF_NOBLOCK) && peer_sessions[i]) {
+                                       status = SWITCH_STATUS_SUCCESS;
+                                       *bleg = peer_sessions[i];
+                                       *cause = SWITCH_CAUSE_SUCCESS;
+                                       goto outer_for;
+                               }
+
+                               
                                if (switch_core_session_running(peer_sessions[i])) {
-                                       switch_channel_set_state(peer_channels[i], CS_RING);
+                                       if (!(flags & SOF_NOBLOCK)) {
+                                               switch_channel_set_state(peer_channels[i], CS_RING);
+                                       }
                                } else {
                                        switch_core_session_thread_launch(peer_sessions[i]);
                                }
-                       }
+
+
+                       }                       
 
                        time(&start);
 
@@ -704,7 +743,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                                        if (switch_is_file_path(ringback_data)) {
                                                                char *ext;
                                                                
-                                                               if ((ext = strrchr(ringback_data, '.'))) {
+                                                               if (strrchr(ringback_data, '.') || strstr(ringback_data, SWITCH_URL_SEPARATOR)) {
                                                                        switch_core_session_set_read_codec(session, &write_codec);
                                                                        ext++;
                                                                } else {
index dad4919ad044c26b7e4a07abbc3ae383288fe933..83e00fbfa561fda4498f8b177bb7c09600e96fdc 100644 (file)
@@ -240,7 +240,7 @@ int fs_switch_ivr_originate(switch_core_session_t *session, switch_core_session_
                timelimit = atoi(var);
        }
 
-       if (switch_ivr_originate(session, &peer_session, &cause, bridgeto, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
+       if (switch_ivr_originate(session, &peer_session, &cause, bridgeto, timelimit, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n");
                switch_channel_hangup(caller_channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL);
                return;