]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
clear up some more display issues and fix resume-media-on-hold sofia option
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 19 Oct 2009 19:58:23 +0000 (19:58 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 19 Oct 2009 19:58:23 +0000 (19:58 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15177 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_channel.h
src/include/switch_types.h
src/mod/applications/mod_dptools/mod_dptools.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/switch_channel.c
src/switch_core_session.c
src/switch_ivr_bridge.c
src/switch_ivr_originate.c

index 78d71d4f7514f7618ec6fd6dcef744fe3434f139..05b11c6d9782f4a14f9151724589d634d0e10d58 100644 (file)
@@ -229,6 +229,8 @@ SWITCH_DECLARE(char *) switch_channel_get_uuid(switch_channel_t *channel);
   \returns SWITCH_STATUS_SUCCESS if successful
 */
 
+SWITCH_DECLARE(switch_status_t) switch_channel_set_profile_var(switch_channel_t *channel, const char *name, const char *val);
+
 SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_var_check(switch_channel_t *channel, 
                                                                                                                                          const char *varname, const char *value, switch_bool_t var_check);
 SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_printf(switch_channel_t *channel, const char *varname,  const char *fmt, ...);
index d672e98a42308b10f51c70fd4486bfc124fa114c..e7737fddf2d22c022e7b326a49933490c7349c9e 100644 (file)
@@ -868,6 +868,7 @@ CF_STOP_BROADCAST   - Signal to stop broadcast
 
 typedef enum {
        CC_MEDIA_ACK = 1,
+       CC_BYPASS_MEDIA = 1,
        /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
        CC_FLAG_MAX
 } switch_channel_cap_t;
index 78733f872932db3fa11ba976d4cca7ab908aa006..8aa72bd553ba219b5bd7cad8977acff8df2003a2 100644 (file)
@@ -784,15 +784,12 @@ SWITCH_STANDARD_APP(set_global_function)
 
 SWITCH_STANDARD_APP(set_profile_var_function)
 {
-       switch_caller_profile_t *caller_profile;
        char *name, *val = NULL;
 
-       caller_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(session));
-
        if (switch_strlen_zero(data)) {
                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n");
        } else {
-               name = switch_core_strdup(caller_profile->pool, data);
+               name = switch_core_session_strdup(session, data);
                val = strchr(name, '=');
 
                if (val) {
@@ -801,66 +798,8 @@ SWITCH_STANDARD_APP(set_profile_var_function)
                                val = NULL;
                        }
                }
-
-               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "SET_PROFILE_VAR [%s]=[%s]\n", name, val ? val : "UNDEF");
-
-               if (!strcasecmp(name, "dialplan")) {
-                       caller_profile->dialplan = val;
-               }
-               if (!strcasecmp(name, "username")) {
-                       caller_profile->username = val;
-               }
-               if (!strcasecmp(name, "caller_id_name")) {
-                       caller_profile->caller_id_name = val;
-               }
-               if (!strcasecmp(name, "caller_id_number")) {
-                       caller_profile->caller_id_number = val;
-               }
-               if (!strcasecmp(name, "callee_id_name")) {
-                       caller_profile->callee_id_name = val;
-               }
-               if (!strcasecmp(name, "callee_id_number")) {
-                       caller_profile->callee_id_number = val;
-               }
-               if (val && !strcasecmp(name, "caller_ton")) {
-                       caller_profile->caller_ton = (uint8_t) atoi(val);
-               }
-               if (val && !strcasecmp(name, "caller_numplan")) {
-                       caller_profile->caller_numplan = (uint8_t) atoi(val);
-               }
-               if (val && !strcasecmp(name, "destination_number_ton")) {
-                       caller_profile->destination_number_ton = (uint8_t) atoi(val);
-               }
-               if (val && !strcasecmp(name, "destination_number_numplan")) {
-                       caller_profile->destination_number_numplan = (uint8_t) atoi(val);
-               }
-               if (!strcasecmp(name, "ani")) {
-                       caller_profile->ani = val;
-               }
-               if (!strcasecmp(name, "aniii")) {
-                       caller_profile->aniii = val;
-               }
-               if (!strcasecmp(name, "network_addr")) {
-                       caller_profile->network_addr = val;
-               }
-               if (!strcasecmp(name, "rdnis")) {
-                       caller_profile->rdnis = val;
-               }
-               if (!strcasecmp(name, "destination_number")) {
-                       caller_profile->destination_number = val;
-               }
-               if (!strcasecmp(name, "uuid")) {
-                       caller_profile->uuid = val;
-               }
-               if (!strcasecmp(name, "source")) {
-                       caller_profile->source = val;
-               }
-               if (!strcasecmp(name, "context")) {
-                       caller_profile->context = val;
-               }
-               if (!strcasecmp(name, "chan_name")) {
-                       caller_profile->chan_name = val;
-               }
+               
+               switch_channel_set_profile_var(switch_core_session_get_channel(session), name, val);
        }
 }
 
index a146e460cad6c2be47d5e0ae16df618529fb54c0..4a99b5e5f99d09f9f6bcec4dc53878b3b362587c 100644 (file)
@@ -1232,7 +1232,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                        switch_channel_clear_flag(channel, CF_PROXY_MODE);
                        sofia_glue_tech_set_local_sdp(tech_pvt, NULL, SWITCH_FALSE);
 
-                       if (!switch_channel_media_ready(channel)) {
+                       if (!(switch_channel_test_flag(channel, CF_ANSWERED) || switch_channel_test_flag(channel, CF_EARLY_MEDIA))) {
                                if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) {
                                        const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
 
@@ -2989,6 +2989,14 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
                switch_channel_set_variable(nchannel, "sip_invite_params", "intercom=true");
        }
 
+       if ((hval = switch_event_get_header(var_event, "sip_callee_id_name"))) {
+               caller_profile->callee_id_name = switch_core_strdup(caller_profile->pool, hval);
+       }
+
+       if ((hval = switch_event_get_header(var_event, "sip_callee_id_number"))) {
+               caller_profile->callee_id_number = switch_core_strdup(caller_profile->pool, hval);
+       }
+
        if (session) {
                switch_channel_t *o_channel = switch_core_session_get_channel(session);
                const char *vval = NULL;
@@ -3005,7 +3013,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
                switch_ivr_transfer_variable(session, nsession, "sip-force-contact");
                switch_ivr_transfer_variable(session, nsession, "sip_sticky_contact");
                switch_ivr_transfer_variable(session, nsession, "sip_cid_type");
-
+               
                if (switch_core_session_compare(session, nsession)) {
                        /* It's another sofia channel! so lets cache what they use as a pt for telephone event so 
                           we can keep it the same
index 4d03bcda28e44ec242adf70ee44e352fd300d140..b39415ed09e8a9ec20add862543a4cf06d60d251 100644 (file)
@@ -3113,11 +3113,12 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
                        caller_profile->network_addr = switch_core_strdup(caller_profile->pool, network_ip);
                }
 
+               switch_channel_clear_flag(channel, CF_REQ_MEDIA);
+
                if ((status == 180 || status == 183 || status == 200)) { 
                        const char *x_actually_support;
 
                        switch_channel_set_flag(channel, CF_MEDIA_ACK);
-                       switch_channel_clear_flag(channel, CF_REQ_MEDIA);
 
                        if ((x_actually_support = sofia_glue_get_unknown_header(sip, "X-Actually-Support"))) {
                                tech_pvt->x_actually_support_remote = switch_core_session_strdup(session, x_actually_support);
index 9e401e644f040427192148329c9fdd260176bc96..861762b25ffbd3e8ebb1a0c1f0ba8411b9bc5b90 100644 (file)
@@ -522,6 +522,7 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
        tech_pvt->session = session;
        tech_pvt->channel = switch_core_session_get_channel(session);
        switch_channel_set_cap(tech_pvt->channel, CC_MEDIA_ACK);
+       switch_channel_set_cap(tech_pvt->channel, CC_BYPASS_MEDIA);
        
        switch_core_session_set_private(session, tech_pvt);
 
index 2836edcff7d5227ffbe226862165f4efef3fec0a..3b7d39d37fef48bae8b8dd881a30df8c06bf8a53 100644 (file)
@@ -622,6 +622,65 @@ SWITCH_DECLARE(char *) switch_channel_get_name(switch_channel_t *channel)
        return (!switch_strlen_zero(channel->name)) ? channel->name : "N/A";
 }
 
+SWITCH_DECLARE(switch_status_t) switch_channel_set_profile_var(switch_channel_t *channel, const char *name, const char *val)
+{
+       char *v;
+       switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+       switch_mutex_lock(channel->profile_mutex);
+
+       if (!switch_strlen_zero(val)) {
+               v = switch_core_strdup(channel->caller_profile->pool, val);
+       } else {
+               v = SWITCH_BLANK_STRING;
+       }
+       
+       if (!strcasecmp(name, "dialplan")) {
+               channel->caller_profile->dialplan = v;
+       } else if (!strcasecmp(name, "username")) {
+               channel->caller_profile->username = v;
+       } else if (!strcasecmp(name, "caller_id_name")) {
+               channel->caller_profile->caller_id_name = v;
+       } else if (!strcasecmp(name, "caller_id_number")) {
+               channel->caller_profile->caller_id_number = v;
+       } else if (!strcasecmp(name, "callee_id_name")) {
+               channel->caller_profile->callee_id_name = v;
+       } else if (!strcasecmp(name, "callee_id_number")) {
+               channel->caller_profile->callee_id_number = v;
+       } else if (val && !strcasecmp(name, "caller_ton")) {
+               channel->caller_profile->caller_ton = (uint8_t) atoi(v);
+       } else if (val && !strcasecmp(name, "caller_numplan")) {
+               channel->caller_profile->caller_numplan = (uint8_t) atoi(v);
+       } else if (val && !strcasecmp(name, "destination_number_ton")) {
+               channel->caller_profile->destination_number_ton = (uint8_t) atoi(v);
+       } else if (val && !strcasecmp(name, "destination_number_numplan")) {
+               channel->caller_profile->destination_number_numplan = (uint8_t) atoi(v);
+       } else if (!strcasecmp(name, "ani")) {
+               channel->caller_profile->ani = v;
+       } else if (!strcasecmp(name, "aniii")) {
+               channel->caller_profile->aniii = v;
+       } else if (!strcasecmp(name, "network_addr")) {
+               channel->caller_profile->network_addr = v;
+       } else if (!strcasecmp(name, "rdnis")) {
+               channel->caller_profile->rdnis = v;
+       } else if (!strcasecmp(name, "destination_number")) {
+               channel->caller_profile->destination_number = v;
+       } else if (!strcasecmp(name, "uuid")) {
+               channel->caller_profile->uuid = v;
+       } else if (!strcasecmp(name, "source")) {
+               channel->caller_profile->source = v;
+       } else if (!strcasecmp(name, "context")) {
+               channel->caller_profile->context = v;
+       } else if (!strcasecmp(name, "chan_name")) {
+               channel->caller_profile->chan_name = v;
+       } else {
+               status = SWITCH_STATUS_FALSE;
+       }
+       switch_mutex_unlock(channel->profile_mutex);
+
+       return status;
+}
+
 SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_var_check(switch_channel_t *channel, 
                                                                                                                                          const char *varname, const char *value, switch_bool_t var_check)
 {
index b892524cbda9dd6476ecbcdde256a786ea0ba38c..eff4c537bb1daef3398d46da21526126c20e6749 100644 (file)
@@ -506,13 +506,21 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
                        }
 
                        if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
-                               switch_channel_set_flag(peer_channel, CF_PROXY_MODE);
-                       }
-
-                       if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
-                               switch_channel_set_flag(peer_channel, CF_PROXY_MEDIA);
-                               if (switch_channel_test_flag(channel, CF_VIDEO)) {
-                                       switch_channel_set_flag(peer_channel, CF_VIDEO);
+                               if (switch_channel_test_cap(peer_channel, CC_BYPASS_MEDIA)) {
+                                       switch_channel_set_flag(peer_channel, CF_PROXY_MODE);
+                       
+                                       if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
+                                               switch_channel_set_flag(peer_channel, CF_PROXY_MEDIA);
+                                               if (switch_channel_test_flag(channel, CF_VIDEO)) {
+                                                       switch_channel_set_flag(peer_channel, CF_VIDEO);
+                                               }
+                                       }
+                               } else {
+                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, 
+                                                                         "%s does not support the proxy feature, disabling.\n", 
+                                                                         switch_channel_get_name(peer_channel));
+                                       switch_channel_clear_flag(channel, CF_PROXY_MODE);
+                                       switch_channel_clear_flag(channel, CF_PROXY_MEDIA);
                                }
                        }
 
index 0a76484edc181ad50d017e8bcdf1385a558d4753..24248fd4d67eab8143f5f69e1b02bbc40aeabc1b 100644 (file)
@@ -84,7 +84,7 @@ static void send_display(switch_core_session_t *session, switch_core_session_t *
        switch_core_session_message_t *msg;
        switch_caller_profile_t *caller_profile;
        switch_channel_t *caller_channel;
-       const char *name, *number;
+       const char *name, *number, *p;
 
        caller_channel = switch_core_session_get_channel(session);
        caller_profile = switch_channel_get_caller_profile(caller_channel);
@@ -111,6 +111,13 @@ static void send_display(switch_core_session_t *session, switch_core_session_t *
                }
        }
 
+       if ((p = strrchr(number, '/'))) {
+               number = p+1;
+       }
+       if ((p = strrchr(name, '/'))) {
+               name = p+1;
+       }
+
        msg = switch_core_session_alloc(peer_session, sizeof(*msg));
        MESSAGE_STAMP_FFL(msg);
        msg->message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
@@ -394,9 +401,9 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Media Establishment Failed.\n", switch_channel_get_name(un));
                                        goto end_of_bridge_loop;
                                }
-                               
-                               if (ans_a) ans_b = 1; else ans_a = 1;
                        }
+
+                       if (ans_a) ans_b = 1; else ans_a = 1;
                }
                
                if (originator && !sent_update && ans_a && ans_b && switch_channel_media_ack(chan_a) && switch_channel_media_ack(chan_b)) {
@@ -866,6 +873,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_signal_bridge(switch_core_session_t *
                switch_channel_set_flag(peer_channel, CF_TRANSFER);
        }
 
+       switch_ivr_bridge_display(session, peer_session);
+
        return SWITCH_STATUS_SUCCESS;
 }
 
index cb023b139c18869383a353bbaa2907ccdfc3a115..67cb3f873cce5cfda6ceeb0659413de5d5fbc1ae 100644 (file)
@@ -1725,6 +1725,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                if (originate_status[i].peer_channel) {
                                        const char *vvar;
                                        
+                                       if ((vvar = switch_channel_get_variable(originate_status[i].peer_channel, "origination_callee_id_name"))) {
+                                               switch_channel_set_profile_var(originate_status[i].peer_channel, "callee_id_name", vvar);
+                                       }
+
+                                       if ((vvar = switch_channel_get_variable(originate_status[i].peer_channel, "origination_callee_id_number"))) {
+                                               switch_channel_set_profile_var(originate_status[i].peer_channel, "callee_id_number", vvar);
+                                       }
+
                                        if ((vvar = switch_channel_get_variable(originate_status[i].peer_channel, "leg_timeout"))) {
                                                int val = atoi(vvar);
                                                if (val > 0) {