]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6833 #resolve [Allow Freeswitch to initiate Late offer calls.] #comment Regression...
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 2 Feb 2016 23:15:20 +0000 (17:15 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 2 Feb 2016 23:15:27 +0000 (17:15 -0600)
src/mod/applications/mod_commands/mod_commands.c
src/mod/endpoints/mod_sofia/mod_sofia.c
src/switch_ivr.c

index b97042f838a12928bafe6c6007f5e82d61273cdf..35a4965172d922130ba96ffd19b8a8fab404815f 100644 (file)
@@ -7377,6 +7377,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
        switch_console_set_complete("add uuid_loglevel ::console::list_uuid debug");
        switch_console_set_complete("add uuid_media ::console::list_uuid");
        switch_console_set_complete("add uuid_media off ::console::list_uuid");
+       switch_console_set_complete("add uuid_media_3p ::console::list_uuid");
+       switch_console_set_complete("add uuid_media_3p off ::console::list_uuid");
        switch_console_set_complete("add uuid_park ::console::list_uuid");
        switch_console_set_complete("add uuid_media_reneg ::console::list_uuid");
        switch_console_set_complete("add uuid_phone_event ::console::list_uuid talk");
index 2434b443e501c25a76fa817fa6009a4473a5076b..2a742be19f60d754c09b3eca330ec324a873513b 100644 (file)
@@ -1458,6 +1458,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                {
                        char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_HEADER_PREFIX);
 
+                       switch_channel_clear_flag(tech_pvt->channel, CF_MEDIA_ACK);
+                       switch_channel_set_flag(tech_pvt->channel, CF_REQ_MEDIA);
+                       
                        nua_invite(tech_pvt->nh, NUTAG_MEDIA_ENABLE(0),
                                           TAG_IF(msg->string_arg, SIPTAG_CONTENT_TYPE_STR("application/sdp")), 
                                           TAG_IF(msg->string_arg, SIPTAG_PAYLOAD_STR(msg->string_arg)), 
@@ -1469,6 +1472,12 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
        case SWITCH_MESSAGE_INDICATE_3P_MEDIA:
                {
                        char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_HEADER_PREFIX);
+
+                       switch_channel_clear_flag(tech_pvt->channel, CF_MEDIA_ACK);
+                       switch_channel_clear_flag(tech_pvt->channel, CF_MEDIA_SET);
+                       switch_channel_set_flag(tech_pvt->channel, CF_REQ_MEDIA);
+
+
                        nua_invite(tech_pvt->nh, NUTAG_MEDIA_ENABLE(0), SIPTAG_PAYLOAD_STR(""), 
                                           TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
 
index 467c9e63096ebb6016a7a92fde0ca02f62c0d11b..f2f09c801b67f4c61af62cb00a954c1634c5b456 100644 (file)
@@ -1573,7 +1573,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_3p_media(const char *uuid, switch_med
        if ((session = switch_core_session_locate(uuid))) {
                channel = switch_core_session_get_channel(session);
                
-               if (switch_channel_test_flag(channel, CF_MEDIA_TRANS)) {
+               if (switch_channel_test_flag(channel, CF_MEDIA_TRANS) || !switch_channel_test_flag(channel, CF_PROXY_MODE)) {
+                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,  "Operation is invalid\n");
                        switch_core_session_rwunlock(session);
                        return SWITCH_STATUS_INUSE;
                }
@@ -1584,70 +1585,69 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_3p_media(const char *uuid, switch_med
                        swap = 1;
                }
 
-               if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
-                       status = SWITCH_STATUS_SUCCESS;
 
-                       /* If we had early media in bypass mode before, it is no longer relevant */
-                       if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
-                               switch_core_session_message_t msg2 = { 0 };
+               status = SWITCH_STATUS_SUCCESS;
+
+               /* If we had early media in bypass mode before, it is no longer relevant */
+               if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
+                       switch_core_session_message_t msg2 = { 0 };
                                
-                               msg2.message_id = SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS;
-                               msg2.from = __FILE__;
-                               switch_core_session_receive_message(session, &msg2);
-                       }
+                       msg2.message_id = SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS;
+                       msg2.from = __FILE__;
+                       switch_core_session_receive_message(session, &msg2);
+               }
                        
-                       if ((flags & SMF_REPLYONLY_A)) {
-                               msg.numeric_arg = 1;
-                       }
+               if ((flags & SMF_REPLYONLY_A)) {
+                       msg.numeric_arg = 1;
+               }
                        
-                       switch_channel_set_flag(channel, CF_3P_MEDIA_REQUESTED);
+               switch_channel_set_flag(channel, CF_3P_MEDIA_REQUESTED);
 
-                       if (switch_core_session_receive_message(session, &msg) != SWITCH_STATUS_SUCCESS) {
-                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't re-establsh media on %s\n", switch_channel_get_name(channel));
-                               switch_channel_clear_flag(channel, CF_3P_MEDIA_REQUESTED);
-                               switch_core_session_rwunlock(session);
-                               return SWITCH_STATUS_GENERR;
-                       }
+               if (switch_core_session_receive_message(session, &msg) != SWITCH_STATUS_SUCCESS) {
+                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't re-establsh media on %s\n", switch_channel_get_name(channel));
+                       switch_channel_clear_flag(channel, CF_3P_MEDIA_REQUESTED);
+                       switch_core_session_rwunlock(session);
+                       return SWITCH_STATUS_GENERR;
+               }
 
-                       if ((flags & SMF_REPLYONLY_B)) {
-                               msg.numeric_arg = 1;
-                       } else {
-                               msg.numeric_arg = 0;
-                       }
+               if ((flags & SMF_REPLYONLY_B)) {
+                       msg.numeric_arg = 1;
+               } else {
+                       msg.numeric_arg = 0;
+               }
 
-                       if ((flags & SMF_IMMEDIATE)) {
-                               switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 250, NULL);
-                               switch_yield(250000);
-                       } else {
-                               switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
-                               switch_channel_wait_for_flag(channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
-                               switch_channel_wait_for_flag(channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL);
-                               //switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
-                       }
+               if ((flags & SMF_IMMEDIATE)) {
+                       switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 250, NULL);
+                       switch_yield(250000);
+               } else {
+                       switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
+                       switch_channel_wait_for_flag(channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
+                       switch_channel_wait_for_flag(channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL);
+                       //switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
+               }
 
-                       if ((flags & SMF_REBRIDGE)
-                               && (other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE))
-                               && (other_session = switch_core_session_locate(other_uuid))) {
+               if ((flags & SMF_REBRIDGE)
+                       && (other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE))
+                       && (other_session = switch_core_session_locate(other_uuid))) {
 
-                               other_channel = switch_core_session_get_channel(other_session);
-                               switch_assert(other_channel != NULL);
+                       other_channel = switch_core_session_get_channel(other_session);
+                       switch_assert(other_channel != NULL);
                                
-                               switch_channel_set_flag(other_channel, CF_3P_MEDIA_REQUESTED);
-                               switch_channel_set_variable(other_channel, "rtp_secure_media", "optional");
+                       switch_channel_set_flag(other_channel, CF_3P_MEDIA_REQUESTED);
+                       switch_channel_set_variable(other_channel, "rtp_secure_media", "optional");
                                
-                               switch_core_session_receive_message(other_session, &msg);
-                               switch_channel_wait_for_flag(other_channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
-                               switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
-                               switch_channel_wait_for_flag(other_channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL);
-                               //switch_core_session_read_frame(other_session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
-                               switch_channel_clear_state_handler(other_channel, NULL);
-                               switch_core_session_rwunlock(other_session);
-                       }
-                       if (other_channel) {
-                               switch_channel_clear_state_handler(channel, NULL);
-                       }
+                       switch_core_session_receive_message(other_session, &msg);
+                       switch_channel_wait_for_flag(other_channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
+                       switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
+                       switch_channel_wait_for_flag(other_channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL);
+                       //switch_core_session_read_frame(other_session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
+                       switch_channel_clear_state_handler(other_channel, NULL);
+                       switch_core_session_rwunlock(other_session);
                }
-
+               if (other_channel) {
+                       switch_channel_clear_state_handler(channel, NULL);
+               }
+       
                switch_channel_clear_flag(channel, CF_MEDIA_TRANS);
                switch_core_session_rwunlock(session);
 
@@ -1781,7 +1781,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_3p_nomedia(const char *uuid, switch_m
                status = SWITCH_STATUS_SUCCESS;
                channel = switch_core_session_get_channel(session);
                
-               if (switch_channel_test_flag(channel, CF_MEDIA_TRANS)) {
+               if (switch_channel_test_flag(channel, CF_MEDIA_TRANS) || (!(flags & SMF_FORCE) && switch_channel_test_flag(channel, CF_PROXY_MODE))) {
+                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,  "Operation is invalid\n");
                        switch_core_session_rwunlock(session);
                        return SWITCH_STATUS_INUSE;
                }