]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
MODENDP-310
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 15 Jun 2010 20:48:12 +0000 (15:48 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 15 Jun 2010 20:48:12 +0000 (15:48 -0500)
src/include/switch_channel.h
src/include/switch_types.h
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia.c
src/switch_channel.c
src/switch_ivr_originate.c

index 7afc6edf6349624fdb6f760fe6b5fbf4bdef200b..a983121ba37e6fb9937c2d8e63f497d7d890e914 100644 (file)
@@ -380,20 +380,26 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan
 */
 #define switch_channel_mark_pre_answered(channel) switch_channel_perform_mark_pre_answered(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
 
-SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel_t *channel, const char *file, const char *func, int line);
+SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready_value(switch_channel_t *channel, 
+                                                                                                                                               switch_ring_ready_t rv,
+                                                                                                                                               const char *file, const char *func, int line);
 /*!
   \brief Send Ringing message to a channel
   \param channel channel to ring
   \return SWITCH_STATUS_SUCCESS if successful
 */
-#define switch_channel_ring_ready(channel) switch_channel_perform_ring_ready(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
+#define switch_channel_ring_ready(channel) switch_channel_perform_ring_ready_value(channel, SWITCH_RING_READY_RINGING, __FILE__, __SWITCH_FUNC__, __LINE__)
+#define switch_channel_ring_ready_value(channel, _rv)                                  \
+       switch_channel_perform_ring_ready_value(channel, _rv, __FILE__, __SWITCH_FUNC__, __LINE__)
 
 
 SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel_t *channel, const char *file, const char *func, int line);
 
 SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_channel_t *channel, const char *file, const char *func, int line);
 
-SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_channel_t *channel, const char *file, const char *func, int line);
+SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready_value(switch_channel_t *channel, 
+                                                                                                                                                        switch_ring_ready_t rv,
+                                                                                                                                                        const char *file, const char *func, int line);
 
 /*!
   \brief Indicate progress on a channel to attempt early media
@@ -407,7 +413,11 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_ch
   \param channel channel
   \return SWITCH_STATUS_SUCCESS
 */
-#define switch_channel_mark_ring_ready(channel) switch_channel_perform_mark_ring_ready(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
+#define switch_channel_mark_ring_ready(channel) \
+       switch_channel_perform_mark_ring_ready_value(channel, SWITCH_RING_READY_RINGING, __FILE__, __SWITCH_FUNC__, __LINE__)
+
+#define switch_channel_mark_ring_ready_value(channel, _rv)                                     \
+       switch_channel_perform_mark_ring_ready_value(channel, _rv, __FILE__, __SWITCH_FUNC__, __LINE__)
 
 /*!
   \brief add a state handler table to a given channel
index eadbdac97e7565e813c1831c0570d5755c1e86f4..fb4b423bfdeef81930ce92e4caa8fe8d6ccb3bd4 100644 (file)
@@ -934,6 +934,12 @@ typedef enum {
        CS_NONE
 } switch_channel_state_t;
 
+typedef enum {
+       SWITCH_RING_READY_NONE,
+       SWITCH_RING_READY_RINGING,
+       SWITCH_RING_READY_QUEUED
+}  switch_ring_ready_t;
+
 
 /*!
   \enum switch_channel_flag_t
index 9b621329bb252f134b348550444a79a99c616317..21733bd2e622fa005bc0e35c339f41aa09b9ecb5 100644 (file)
@@ -2007,29 +2007,54 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                }
                break;
        case SWITCH_MESSAGE_INDICATE_RINGING:
+               {
+                       switch_ring_ready_t ring_ready_val = msg->numeric_arg;
 
-               if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
-                       switch_channel_mark_ring_ready(channel);
-                       status = SWITCH_STATUS_SUCCESS;
-                       switch_log_printf(SWITCH_CHANNEL_ID_LOG, msg->_file, msg->_func, msg->_line, NULL, SWITCH_LOG_INFO,
-                                                         "Pretending to send ringing.  Not available for 3pcc calls\n");
-                       goto end_lock;
-               }
+                       if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
+                               switch_channel_mark_ring_ready(channel);
+                               status = SWITCH_STATUS_SUCCESS;
+                               switch_log_printf(SWITCH_CHANNEL_ID_LOG, msg->_file, msg->_func, msg->_line, NULL, SWITCH_LOG_INFO,
+                                                                 "Pretending to send ringing.  Not available for 3pcc calls\n");
+                               goto end_lock;
+                       }
 
-               if (!switch_channel_test_flag(channel, CF_RING_READY) && !sofia_test_flag(tech_pvt, TFLAG_BYE) &&
-                       !switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_ANSWERED)) {
-                       char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
-                       const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full");
+                       if (!switch_channel_test_flag(channel, CF_RING_READY) && !sofia_test_flag(tech_pvt, TFLAG_BYE) &&
+                               !switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_ANSWERED)) {
+                               char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
+                               const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full");
 
-                       nua_respond(tech_pvt->nh, SIP_180_RINGING,
-                                               SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
-                                               SIPTAG_HEADER_STR(generate_pai_str(session)),
-                                               TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
-                                               TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
-                                               TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
-                                                          SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END());
-                       switch_safe_free(extra_header);
-                       switch_channel_mark_ring_ready(channel);
+                       
+                               switch (ring_ready_val) {
+
+                               case SWITCH_RING_READY_QUEUED:
+
+                                       nua_respond(tech_pvt->nh, SIP_182_QUEUED,
+                                                               SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
+                                                               SIPTAG_HEADER_STR(generate_pai_str(session)),
+                                                               TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
+                                                               TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
+                                                               TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
+                                                                          SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END());
+                                       break;
+
+                               case SWITCH_RING_READY_RINGING:
+                               default:
+
+                                       nua_respond(tech_pvt->nh, SIP_180_RINGING,
+                                                               SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
+                                                               SIPTAG_HEADER_STR(generate_pai_str(session)),
+                                                               TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
+                                                               TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
+                                                               TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
+                                                                          SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END());
+
+                                       break;
+                               }
+
+
+                               switch_safe_free(extra_header);
+                               switch_channel_mark_ring_ready(channel);
+                       }
                }
                break;
        case SWITCH_MESSAGE_INDICATE_ANSWER:
index a2b75d480ef704fef156d55a647e9987d385c40f..22f8fc23ad6cdecdc076a920aedf47ccb500d04b 100644 (file)
@@ -4350,8 +4350,16 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
        case nua_callstate_calling:
                break;
        case nua_callstate_proceeding:
-               if (status == 180) {
+
+               switch (status) {
+               case 180:
                        switch_channel_mark_ring_ready(channel);
+                       break;
+               case 182:
+                       switch_channel_mark_ring_ready_value(channel, SWITCH_RING_READY_QUEUED);
+                       break;
+               default:
+                       break;
                }
 
                if (r_sdp) {
index 6218a7a5c866366d6a26e337f3d193a09edfb879..36a4989a0aa26d2a039c97b1b1ad005074b04935 100644 (file)
@@ -2278,7 +2278,9 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_chan
        return channel->state;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_channel_t *channel, const char *file, const char *func, int line)
+SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready_value(switch_channel_t *channel, 
+                                                                                                                                                        switch_ring_ready_t rv,
+                                                                                                                                                        const char *file, const char *func, int line)
 {
        const char *var;
        char *app;
@@ -2287,7 +2289,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_ch
        if (!switch_channel_test_flag(channel, CF_RING_READY) && !switch_channel_test_flag(channel, CF_EARLY_MEDIA &&
                                                                                                                                                                           !switch_channel_test_flag(channel, CF_ANSWERED))) {
                switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Ring-Ready %s!\n", channel->name);
-               switch_channel_set_flag(channel, CF_RING_READY);
+               switch_channel_set_flag_value(channel, CF_RING_READY, rv);
                if (channel->caller_profile && channel->caller_profile->times) {
                        switch_mutex_lock(channel->profile_mutex);
                        channel->caller_profile->times->progress = switch_micro_time_now();
@@ -2423,7 +2425,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel
        return status;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel_t *channel, const char *file, const char *func, int line)
+SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready_value(switch_channel_t *channel, switch_ring_ready_t rv, 
+                                                                                                                                               const char *file, const char *func, int line)
 {
        switch_core_session_message_t msg = { 0 };
        switch_status_t status = SWITCH_STATUS_SUCCESS;
@@ -2445,11 +2448,13 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel
        if (!switch_channel_test_flag(channel, CF_OUTBOUND)) {
                msg.message_id = SWITCH_MESSAGE_INDICATE_RINGING;
                msg.from = channel->name;
+               msg.numeric_arg = rv;
                status = switch_core_session_perform_receive_message(channel->session, &msg, file, func, line);
        }
 
        if (status == SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name);
+               switch_channel_perform_mark_ring_ready_value(channel, rv, file, func, line);
        } else {
                switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
        }
index c962d979a09039a6e0c9a6379a0414c5b4814f55..fa12b3719ec4c9c0bd4a6c211e00c0f484eb950e 100644 (file)
@@ -413,6 +413,7 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat
        int pindex = -1;
        char bug_key[256] = "";
        int send_ringback = 0;
+       uint32_t ring_ready_val = 0;
 
        oglobals->hups = 0;
        oglobals->idx = IDX_NADA;
@@ -451,9 +452,9 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat
                        continue;
                }
 
-               if (switch_channel_test_flag(originate_status[i].peer_channel, CF_RING_READY)) {
+               if ((ring_ready_val = switch_channel_test_flag(originate_status[i].peer_channel, CF_RING_READY))) {
                        if (!originate_status[i].ring_ready) {
-                               originate_status[i].ring_ready = 1;
+                               originate_status[i].ring_ready = ring_ready_val;
                        }
 
                        if (oglobals->sending_ringback == 1) {
@@ -461,13 +462,13 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat
                                pindex = (uint32_t) i;
                        } else {
                                if (!oglobals->ring_ready) {
-                                       oglobals->ring_ready = 1;
+                                       oglobals->ring_ready = ring_ready_val;
                                        if (caller_channel && !oglobals->ignore_ring_ready) {
                                                if (len == 1) {
                                                        switch_channel_pass_callee_id(originate_status[0].peer_channel, caller_channel);
                                                }
-                                               switch_channel_ring_ready(caller_channel);
-                                               oglobals->sent_ring = 1;
+                                               switch_channel_ring_ready_value(caller_channel, ring_ready_val);
+                                               oglobals->sent_ring = ring_ready_val;
                                        }
                                }
                        }
@@ -485,7 +486,7 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat
                                pindex = (uint32_t) i;
                        } else if (!oglobals->sent_ring && oglobals->ignore_early_media == 2 && len == 1 && caller_channel && !oglobals->ignore_ring_ready) {
                                switch_channel_pass_callee_id(originate_status[0].peer_channel, caller_channel);
-                               switch_channel_ring_ready(caller_channel);
+                               //switch_channel_ring_ready(caller_channel);
                                oglobals->sent_ring = 1;
                        }