]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-4779 try this instead
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 1 Nov 2012 14:14:34 +0000 (09:14 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 1 Nov 2012 14:14:34 +0000 (09:14 -0500)
src/mod/endpoints/mod_sofia/sofia.c

index adb06caaba2eafe0de9de3a9a474f496e546ce46..4a074088fc706b0aa426d5e21bea7d82ac3fd0c8 100644 (file)
@@ -1133,6 +1133,8 @@ static void our_sofia_event_callback(nua_event_t event,
        case nua_i_ack:
                {
                        if (channel && sip) {
+                               char *r_sdp = NULL;
+
                                if (sip->sip_to && sip->sip_to->a_tag) {
                                        switch_channel_set_variable(channel, "sip_to_tag", sip->sip_to->a_tag);
                                }
@@ -1155,6 +1157,34 @@ static void our_sofia_event_callback(nua_event_t event,
                                switch_core_recovery_track(session);
                                sofia_set_flag(tech_pvt, TFLAG_GOT_ACK);
 
+                               if (sip->sip_payload && sip->sip_payload->pl_data && sip->sip_content_type && 
+                                       sip->sip_content_type->c_subtype && switch_stristr("sdp", sip->sip_content_type->c_subtype)) {
+                                       r_sdp = sip->sip_payload->pl_data;
+                               }
+
+                               if (!zstr(r_sdp) && (sofia_test_flag(tech_pvt, TFLAG_3PCC_INVITE) || switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE))) {
+                                       switch_core_session_t *other_session;
+                                       sofia_set_flag(tech_pvt, TFLAG_SDP);
+                                       if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
+                                               switch_core_session_message_t *msg;
+                                               switch_channel_t *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);
+                                               }
+                                               
+                                               msg = switch_core_session_alloc(other_session, sizeof(*msg));
+                                               msg->message_id = SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT;
+                                               msg->from = __FILE__;
+                                               msg->string_arg = switch_core_session_strdup(other_session, r_sdp);
+                                               msg->numeric_arg = 1; // send ack
+                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Passing SDP ACK to other leg.\n%s\n", r_sdp);
+                                               
+                                               switch_core_session_queue_message(other_session, msg);
+                                               
+                                               switch_core_session_rwunlock(other_session);
+                                       }
+                               }
 
                                if (sofia_test_flag(tech_pvt, TFLAG_PASS_ACK)) {
                                        switch_core_session_t *other_session;
@@ -5748,32 +5778,6 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                                }
                        }
 
-                       if (r_sdp && sofia_test_flag(tech_pvt, TFLAG_3PCC_INVITE) && !sofia_test_flag(tech_pvt, TFLAG_SDP)) {
-                               sofia_set_flag(tech_pvt, TFLAG_SDP);
-                               if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
-                                       switch_core_session_message_t *msg;
-
-                                       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);
-                                       }
-
-                                       msg = switch_core_session_alloc(other_session, sizeof(*msg));
-                                       msg->message_id = SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT;
-                                       msg->from = __FILE__;
-                                       msg->string_arg = switch_core_session_strdup(other_session, r_sdp);
-                                       msg->numeric_arg = 1; // send ack
-                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Passing SDP ACK to other leg.\n%s\n", r_sdp);
-
-                                       switch_core_session_queue_message(other_session, msg);
-
-                                       switch_core_session_rwunlock(other_session);
-                               }
-                               goto done;
-
-                       }
-
                        if (send_ack) {
                                tech_send_ack(nh, tech_pvt);
                        } else {