]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-3326 revert 68c389d
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 15 Jun 2011 15:10:37 +0000 (10:10 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 15 Jun 2011 15:10:37 +0000 (10:10 -0500)
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_ivr_originate.c

index b06eacb36d9fb1ed3c898501badf016f10266b28..8558aeee1d177a105c02f5565ca291a41ace58e2 100644 (file)
@@ -575,31 +575,9 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
        const char *val;
        const char *b_sdp = NULL;
        int is_proxy = 0;
-       int is_3pcc = 0;
        char *sticky = NULL;
        const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full");
 
-
-       if(sofia_test_flag(tech_pvt, TFLAG_3PCC_INVITE)) {
-               // SNARK: complete hack to get final ack sent when a 3pcc invite has been passed from the other leg in bypass_media mode.
-               // This code handles the pass_indication sent after the 3pcc ack is received by the other leg in the is_3pcc && is_proxy case below.
-               // Is there a better place to hang this...?
-               b_sdp = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE);
-               sofia_glue_tech_set_local_sdp(tech_pvt, b_sdp, SWITCH_TRUE);
-
-               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY nomedia - sending ack\n");
-               nua_ack(tech_pvt->nh,
-                       TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
-                       SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
-                       SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
-                       SOATAG_REUSE_REJECTED(1),
-                       SOATAG_RTP_SELECT(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"),
-                       TAG_IF(sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)),
-                       TAG_END());
-               sofia_clear_flag(tech_pvt, TFLAG_3PCC_INVITE); // all done
-               return SWITCH_STATUS_SUCCESS;
-       }
-
        if (sofia_test_flag(tech_pvt, TFLAG_ANS) || switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
                return SWITCH_STATUS_SUCCESS;
        }
@@ -607,9 +585,8 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
 
        b_sdp = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE);
        is_proxy = (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA));
-       is_3pcc = (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC));
 
-       if (b_sdp && is_proxy && !is_3pcc) {
+       if (b_sdp && is_proxy) {
                sofia_glue_tech_set_local_sdp(tech_pvt, b_sdp, SWITCH_TRUE);
 
                if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
@@ -620,35 +597,23 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
                }
        } else {
                /* This if statement check and handles the 3pcc proxy mode */
-               if (is_3pcc) {
+               if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
 
-                       if(!is_proxy) {
                        tech_pvt->num_codecs = 0;
                        sofia_glue_tech_prepare_codecs(tech_pvt);
                        tech_pvt->local_sdp_str = NULL;
                        sofia_glue_tech_choose_port(tech_pvt, 0);
                        sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
-                       } else {
-                               sofia_glue_tech_set_local_sdp(tech_pvt, b_sdp, SWITCH_TRUE);
-
-                               if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
-                                       sofia_glue_tech_patch_sdp(tech_pvt);
-                                       if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
-                                               return SWITCH_STATUS_FALSE;
-                                       }
-                               }
-                       }
 
                        /* Send the 200 OK */
                        if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
                                char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_RESPONSE_HEADER_PREFIX);
                                if (sofia_use_soa(tech_pvt)) {
                                        nua_respond(tech_pvt->nh, SIP_200_OK,
-                                                               TAG_IF(is_proxy, NUTAG_AUTOANSWER(0)),
                                                                SIPTAG_CONTACT_STR(tech_pvt->profile->url),
                                                                SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
                                                                TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
-                                                               SOATAG_REUSE_REJECTED(1), TAG_IF(is_proxy, SOATAG_RTP_SELECT(1)),
+                                                               SOATAG_REUSE_REJECTED(1),
                                                                SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1),
                                                                TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
                                                                TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
@@ -680,14 +645,6 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
                        /*  Regain lock on sofia */
                        switch_mutex_lock(tech_pvt->sofia_mutex);
 
-                       if(is_proxy) {
-                               sofia_clear_flag(tech_pvt, TFLAG_3PCC_HAS_ACK);
-                               sofia_clear_flag(tech_pvt, TFLAG_3PCC);
-                               // This sends the message to the other leg that causes it to call the TFLAG_3PCC_INVITE code at the start of this function.
-                               // Is there another message it would be better to hang this on though?
-                               switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_ANSWER);
-                       }
-
                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Done waiting for ACK\n");
                        return SWITCH_STATUS_SUCCESS;
                }
@@ -1734,10 +1691,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                                                          switch_channel_get_name(channel), msg->string_arg);
                        sofia_glue_tech_set_local_sdp(tech_pvt, msg->string_arg, SWITCH_TRUE);
 
-                       if(zstr(tech_pvt->local_sdp_str)) {
-                               sofia_set_flag(tech_pvt, TFLAG_3PCC_INVITE);
-                       }
-
                        sofia_set_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
                        switch_channel_set_flag(channel, CF_REQ_MEDIA);
                        sofia_glue_do_invite(session);
@@ -2236,23 +2189,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                                                                                SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),
                                                                                TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
                                                }
-                                               if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
-                                                       /* Unlock the session signal to allow the ack to make it in */
-                                                       // Maybe we should timeout?
-                                                       switch_mutex_unlock(tech_pvt->sofia_mutex);
-
-                                                       while (switch_channel_ready(channel) && !sofia_test_flag(tech_pvt, TFLAG_3PCC_HAS_ACK)) {
-                                                               switch_cond_next();
-                                                       }
-
-                                                       /*  Regain lock on sofia */
-                                                       switch_mutex_lock(tech_pvt->sofia_mutex);
-                               
-                                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Done waiting for ACK\n");
-                                                       sofia_clear_flag(tech_pvt, TFLAG_3PCC);
-                                                       sofia_clear_flag(tech_pvt, TFLAG_3PCC_HAS_ACK);
-                                                       switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_ANSWER);
-                                               }
                                        } else {
                                                nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
                                                                        TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
@@ -4461,14 +4397,6 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
                        } else {
                                sofia_clear_flag(ctech_pvt, TFLAG_ENABLE_SOA);
                        }
-
-                       /* SNARK: lets copy this across so we can see if we're the other leg of 3PCC + bypass_media... */
-                       if (sofia_test_flag(ctech_pvt, TFLAG_3PCC) && (switch_channel_test_flag(o_channel, CF_PROXY_MODE) || switch_channel_test_flag(o_channel, CF_PROXY_MEDIA))) {
-                               sofia_set_flag(tech_pvt, TFLAG_3PCC_INVITE);
-                               sofia_set_flag(tech_pvt, TFLAG_LATE_NEGOTIATION);
-                       } else {
-                               sofia_clear_flag(tech_pvt, TFLAG_3PCC_INVITE);
-                       }
                }
 
                if (switch_channel_test_flag(o_channel, CF_PROXY_MEDIA)) {
index dcb4235bc33431d189821856a9a7421cee86f037..12ca7bd01d59b3bbd040270ecd159ee7a3b782ed 100644 (file)
@@ -4547,9 +4547,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
                                                }
                                        }
 
-                                       /* SNARK: message to respond to reinvite wasn't being delivered in 3pcc+bypass media case. */
-                                       //switch_core_session_queue_message(other_session, msg);
-                                       switch_core_session_receive_message(other_session, msg);
+                                       switch_core_session_queue_message(other_session, msg);
 
                                        switch_core_session_rwunlock(other_session);
                                }
@@ -5054,12 +5052,10 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                                        switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
                                }
                        } else {
-                               if (sofia_test_pflag(profile, PFLAG_3PCC)) {
                                if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
-                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "No SDP in INVITE and 3pcc=yes cannot work with bypass or proxy media, hanging up.\n");
-                                               switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "3PCC DISABLED");
-                                               switch_channel_hangup(channel, SWITCH_CAUSE_MANDATORY_IE_MISSING);
+                                       goto done;
                                } else {
+                                       if (sofia_test_pflag(profile, PFLAG_3PCC)) {
                                                switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED_NOSDP");
                                                sofia_glue_tech_choose_port(tech_pvt, 0);
                                                sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
@@ -5078,10 +5074,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                                                                                SIPTAG_CONTACT_STR(tech_pvt->profile->url),
                                                                                SIPTAG_CONTENT_TYPE_STR("application/sdp"), SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str), TAG_END());
                                                }
-                                       }
                                        } else if (sofia_test_pflag(profile, PFLAG_3PCC_PROXY)) {
                                                //3PCC proxy mode delays the 200 OK until the call is answered
-                                       // so can be made to work with bypass media as we have time to find out what the other end thinks codec offer should be...
                                                switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED_NOSDP");
                                                sofia_set_flag_locked(tech_pvt, TFLAG_3PCC);
                                                //sofia_glue_tech_choose_port(tech_pvt, 0);
@@ -5096,29 +5090,11 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                                        }
                                        goto done;
                                }
+                       }
 
                } else if (tech_pvt && sofia_test_flag(tech_pvt, TFLAG_SDP) && !r_sdp) {
-                       sofia_set_flag_locked(tech_pvt, TFLAG_NOSDP_REINVITE);
-                       if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
-                               sofia_set_flag_locked(tech_pvt, TFLAG_3PCC);
-                               if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
-                                       && (other_session = switch_core_session_locate(uuid))) {
-                                       switch_core_session_message_t *msg;
-                                       msg = switch_core_session_alloc(other_session, sizeof(*msg));
-                                       msg->message_id = SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT;
-                                       msg->from = __FILE__;
-                                       msg->string_arg = NULL;
-                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Passing NOSDP to other leg.\n");
-                                       switch_core_session_queue_message(other_session, msg);
-                                       switch_core_session_rwunlock(other_session);
-                               } else {
-                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
-                                                 "NOSDP Re-INVITE to a proxy mode channel that is not in a bridge.\n");
-                                       switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-                               }
-                               goto done;
-                       }
                        nua_respond(tech_pvt->nh, SIP_200_OK, TAG_END());
+                       sofia_set_flag_locked(tech_pvt, TFLAG_NOSDP_REINVITE);
                        goto done;
                } else {
                        ss_state = nua_callstate_completed;
@@ -5130,10 +5106,12 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                break;
        case nua_callstate_completed:
                if (r_sdp) {
-                       const char *var;
                        uint8_t match = 0, is_ok = 1, is_t38 = 0;
                        tech_pvt->hold_laps = 0;
 
+                       if (r_sdp) {
+                               const char *var;
+
                                if ((var = switch_channel_get_variable(channel, "sip_ignore_reinvites")) && switch_true(var)) {
                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Ignoring Re-invite\n");
                                        nua_respond(tech_pvt->nh, SIP_200_OK, TAG_END());
@@ -5295,6 +5273,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                                        nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
                                }
                        }
+               }
                break;
        case nua_callstate_ready:
                if (r_sdp && !is_dup_sdp && switch_rtp_ready(tech_pvt->rtp_session)) {
@@ -5327,34 +5306,10 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                }
 
                if (r_sdp && sofia_test_flag(tech_pvt, TFLAG_NOSDP_REINVITE)) {
-                       sofia_clear_flag_locked(tech_pvt, TFLAG_NOSDP_REINVITE);
-                       if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
-                               if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
-                                       if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
-                                               goto done;
-                                       }
-                               }
-
-                               if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
-                                       && (other_session = switch_core_session_locate(uuid))) {
-                                       other_channel = switch_core_session_get_channel(other_session);
-                                       if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) {
-                                               switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, r_sdp);
-                                       }
-                                               
-                                       if (sofia_test_flag(tech_pvt, TFLAG_3PCC) && sofia_test_pflag(profile, PFLAG_3PCC_PROXY)) {
-                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Got my ACK\n");
-                                               sofia_set_flag(tech_pvt, TFLAG_3PCC_HAS_ACK);
-                                       } else {
-                                               switch_core_session_queue_indication(other_session, SWITCH_MESSAGE_INDICATE_ANSWER);
-                                       }
-
-                                       switch_core_session_rwunlock(other_session);
-                               }
-                       } else {
                        uint8_t match = 0;
                        int is_ok = 1;
 
+                       sofia_clear_flag_locked(tech_pvt, TFLAG_NOSDP_REINVITE);
 
                        if (tech_pvt->num_codecs) {
                                match = sofia_glue_negotiate_sdp(session, r_sdp);
@@ -5377,7 +5332,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                                nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
                                switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
                        }
-                       }
+
                        goto done;
                }
 
@@ -5444,12 +5399,6 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
 
                                                switch_core_session_rwunlock(other_session);
                                        }
-
-                                       if (sofia_test_flag(tech_pvt, TFLAG_3PCC) && sofia_test_pflag(profile, PFLAG_3PCC_PROXY)) {
-                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Got my ACK\n");
-                                               sofia_set_flag(tech_pvt, TFLAG_3PCC_HAS_ACK);
-                                       }
-
                                        goto done;
                                } else {
                                        uint8_t match = 0;
index dba65d2aacce8fb4afd4dd60db3acf2572baae93..2ab0e723b0dab64e94ac4e0b3538a32d931350e8 100644 (file)
@@ -2396,7 +2396,6 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
        if (sofia_use_soa(tech_pvt)) {
                nua_invite(tech_pvt->nh,
                                   NUTAG_AUTOANSWER(0),
-                                  NUTAG_AUTOACK(0),
                                   NUTAG_SESSION_TIMER(session_timeout),
                                   NUTAG_SESSION_REFRESHER(session_timeout ? nua_local_refresher : nua_no_refresher),
                                   TAG_IF(sofia_test_flag(tech_pvt, TFLAG_RECOVERED), NUTAG_INVITE_TIMER(UINT_MAX)),
@@ -2418,19 +2417,15 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
                                   TAG_IF(!zstr(route), SIPTAG_ROUTE_STR(route)),
                                   TAG_IF(tech_pvt->profile->minimum_session_expires, NUTAG_MIN_SE(tech_pvt->profile->minimum_session_expires)),
                                   TAG_IF(cseq, SIPTAG_CSEQ(cseq)),
-                                  TAG_IF(zstr(tech_pvt->local_sdp_str), SIPTAG_PAYLOAD_STR("")),
-                                  TAG_IF(!zstr(tech_pvt->local_sdp_str), SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip)),
-                                  TAG_IF(!zstr(tech_pvt->local_sdp_str), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str)),
-                                  TAG_IF(!zstr(tech_pvt->local_sdp_str), SOATAG_REUSE_REJECTED(1)),
-                                  TAG_IF(!zstr(tech_pvt->local_sdp_str), SOATAG_ORDERED_USER(1)),
-                                  TAG_IF(!zstr(tech_pvt->local_sdp_str), SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE)),
-                                  TAG_IF(!zstr(tech_pvt->local_sdp_str), SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL)),
-                                  TAG_IF(rep, SIPTAG_REPLACES_STR(rep)),
-                                  TAG_IF(!zstr(tech_pvt->local_sdp_str), SOATAG_HOLD(holdstr)), TAG_END());
+                                  SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip),
+                                  SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
+                                  SOATAG_REUSE_REJECTED(1),
+                                  SOATAG_ORDERED_USER(1),
+                                  SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE),
+                                  SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL), TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), SOATAG_HOLD(holdstr), TAG_END());
        } else {
                nua_invite(tech_pvt->nh,
                                   NUTAG_AUTOANSWER(0),
-                                  NUTAG_AUTOACK(0),
                                   NUTAG_SESSION_TIMER(session_timeout),
                                   TAG_IF(session_timeout, NUTAG_SESSION_REFRESHER(nua_remote_refresher)),
                                   TAG_IF(sofia_test_flag(tech_pvt, TFLAG_RECOVERED), NUTAG_INVITE_TIMER(UINT_MAX)),
index 872c11cf64c2d38930152454818537bdcb35c17f..2329780a8b16f253c44a386fdbbf69f40bc23739 100644 (file)
@@ -2934,7 +2934,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                oglobals.idx = IDX_CANCEL;
                        }
 
-                       if (oglobals.session && (ringback_data || !(switch_channel_test_flag(caller_channel, CF_PROXY_MODE) ||
+                       if (oglobals.session && (ringback_data || !(switch_channel_test_flag(caller_channel, CF_PROXY_MODE) &&
                                                                                                                switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA)))) {
                                switch_core_session_reset(oglobals.session, SWITCH_FALSE, SWITCH_TRUE);
                        }