]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
second try at sip_wait_for_aleg_ack
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 5 Sep 2012 18:11:32 +0000 (13:11 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 5 Sep 2012 18:11:32 +0000 (13:11 -0500)
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c

index 7d6659cdfc13f89e14793025c7ef907c9ad8d6f1..f0c57cb988fd4a9d14a18562d51e8e1b27f0a96d 100644 (file)
@@ -341,6 +341,7 @@ typedef enum {
        TFLAG_REINVITED,
        TFLAG_SLA_BARGE,
        TFLAG_SLA_BARGING,
+       TFLAG_PASS_ACK,
        /* No new flags below this line */
        TFLAG_MAX
 } TFLAGS;
index d132d159188bf2638e93b53a569c78d040e918fb..2523f7ae5d865b144736f954607fbafeec57601c 100644 (file)
@@ -954,6 +954,36 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro
        switch_safe_free(dup);
 }
 
+static void tech_send_ack(nua_handle_t *nh, private_object_t *tech_pvt)
+{
+       const char *invite_full_from = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_from");
+       const char *invite_full_to = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_to");
+
+
+       if (sofia_test_pflag(tech_pvt->profile, PFLAG_TRACK_CALLS)) {
+               const char *invite_full_via = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_via");
+               const char *invite_route_uri = switch_channel_get_variable(tech_pvt->channel, "sip_invite_route_uri");                  
+               
+               nua_ack(nh, 
+                               TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
+                               TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
+                               TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
+                               TAG_IF((zstr(tech_pvt->user_via) && !zstr(invite_full_via)), SIPTAG_VIA_STR(invite_full_via)),
+                               TAG_IF(!zstr(invite_route_uri), SIPTAG_ROUTE_STR(invite_route_uri)),
+                               TAG_END());
+               
+                                               
+       } else {
+               nua_ack(nh, 
+                               TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
+                               TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
+                               TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), 
+                               TAG_END());
+       }
+
+}
+
+
 //sofia_dispatch_event_t *de
 static void our_sofia_event_callback(nua_event_t event,
                                                  int status,
@@ -1124,6 +1154,24 @@ static void our_sofia_event_callback(nua_event_t event,
                                extract_header_vars(profile, sip, session, nh);
                                switch_core_recovery_track(session);
                                sofia_set_flag(tech_pvt, TFLAG_GOT_ACK);
+
+                               if (sofia_test_flag(tech_pvt, TFLAG_PASS_ACK)) {
+                                       switch_core_session_t *other_session;
+                                       
+                                       sofia_clear_flag(tech_pvt, TFLAG_PASS_ACK);
+
+
+                                       if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
+                                               if (switch_core_session_compare(session, other_session)) {
+                                                       private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
+                                                       tech_send_ack(other_tech_pvt->nh, other_tech_pvt);
+                                               }
+                                               switch_core_session_rwunlock(other_session);
+                                       }               
+                                       
+                               }
+
+
                        }
                }
        case nua_r_ack:
@@ -6311,16 +6359,18 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                break;
        case nua_callstate_completing:
                {
-                       const char *invite_full_from = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_from");
-                       const char *invite_full_to = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_to");
                        const char *wait_for_ack = switch_channel_get_variable(channel, "sip_wait_for_aleg_ack");
+                       int send_ack = 1;
 
                        if (switch_true(wait_for_ack)) {
                                switch_core_session_t *other_session;
 
                                if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
-                                       switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
-                                       switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
+                                       if (switch_core_session_compare(session, other_session)) {
+                                               private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
+                                               sofia_set_flag(other_tech_pvt, TFLAG_PASS_ACK);
+                                               send_ack = 0;
+                                       }
                                        switch_core_session_rwunlock(other_session);
                                }
                        }
@@ -6341,26 +6391,10 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
 
                        }
 
-                       if (sofia_test_pflag(profile, PFLAG_TRACK_CALLS)) {
-                               const char *invite_full_via = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_via");
-                               const char *invite_route_uri = switch_channel_get_variable(tech_pvt->channel, "sip_invite_route_uri");                  
-
-                               nua_ack(nh, 
-                                               TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
-                                               TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
-                                               TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
-                                               TAG_IF((zstr(tech_pvt->user_via) && !zstr(invite_full_via)), SIPTAG_VIA_STR(invite_full_via)),
-
-                                               TAG_IF(!zstr(invite_route_uri), SIPTAG_ROUTE_STR(invite_route_uri)),
-                                               TAG_END());
-                                               
-                       } else {
-                               nua_ack(nh, 
-                                       TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
-                                       TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
-                                       TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), 
-                                       TAG_END());
+                       if (send_ack) {
+                               tech_send_ack(nh, tech_pvt);
                        }
+                       
                }
                goto done;
        case nua_callstate_received: