]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add ring ready flag to core
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 13 Feb 2007 02:32:10 +0000 (02:32 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 13 Feb 2007 02:32:10 +0000 (02:32 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4221 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_channel.h
src/include/switch_types.h
src/mod/endpoints/mod_sofia/mod_sofia.c
src/switch_channel.c
src/switch_ivr.c

index 9a25d5041f7f9cd1ce04e227990dee6ea780c6b7..1fa668b1836718842fa934590c048e354143d09e 100644 (file)
@@ -330,6 +330,13 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_
 */                                                             
 #define switch_channel_pre_answer(channel) switch_channel_perform_pre_answer(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
 
+/*!
+  \brief Indicate a channel is ready to provide ringback
+  \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__)
+
 /*!
   \brief add a state handler table to a given channel
   \param channel channel on which to add the state handler table
index 25c0400f8862f02b0cb7ddea8318cbdacc651b90..ab440c5aa9737dfda0c2fc2c6b6b4d94bb267468 100644 (file)
@@ -487,6 +487,7 @@ CF_SUSPEND          = (1 << 14) - Suspend i/o
 CF_EVENT_PARSE  = (1 << 15) - Suspend control events
 CF_NO_INDICATE  = (1 << 16) - Disable Indications
 CF_REPEAT_STATE = (1 << 17) - Tell the state machine to repeat a state
+CF_RING_READY   = (1 << 18) - Channel is ready to send ringback
 </pre>
  */
 
@@ -508,7 +509,8 @@ typedef enum {
        CF_SUSPEND              = (1 << 14),
        CF_EVENT_PARSE  = (1 << 15),
        CF_NO_INDICATE  = (1 << 16),
-    CF_REPEAT_STATE = (1 << 17)
+    CF_REPEAT_STATE = (1 << 17),
+       CF_RING_READY   = (1 << 18)
 } switch_channel_flag_t;
 
 
index 69879af8eb1db1150c328494926a824c8b4a6a7e..4b464962f071faa3b8c7ece7a2fea05ae7e81496 100644 (file)
@@ -2811,6 +2811,7 @@ static void sip_i_state(int status,
        case nua_callstate_proceeding:
                if (channel) {
                        if (status == 180 && !(switch_channel_test_flag(channel, CF_NO_INDICATE))) {
+                               switch_channel_mark_ring_ready(channel);
                                if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
                                        if ((uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
                                                switch_core_session_message_t msg;
index cab0ec3d92b1bfe3f714609fd4831df542416798..7fa57ccab8a55af52277f9bad9f97b408b36d90e 100644 (file)
@@ -978,13 +978,32 @@ 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)
+{
+       if (!switch_channel_test_flag(channel, CF_RING_READY)) {
+        switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Ring-Ready %s!\n", channel->name);
+               switch_channel_set_flag(channel, CF_RING_READY);
+               return SWITCH_STATUS_SUCCESS;
+       }
+
+       return SWITCH_STATUS_FALSE;
+}
+
+
+
 SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_channel_t *channel,
-                                                                       const char *file,
-                                                                       const char *func,
-                                                                       int line)
+                                                                                                                                                const char *file,
+                                                                                                                                                const char *func,
+                                                                                                                                                int line)
 {
     switch_event_t *event;
 
+       switch_channel_mark_ring_ready(channel);
+
     if (!switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
         char *uuid;
         switch_core_session_t *other_session;
index c64cdee1db3de404ab72bb342965b6edbf9782fb..7d256c6475d051388b1319364ba888f66449666f 100644 (file)
@@ -2789,7 +2789,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                        write_frame.datalen = read_codec->implementation->bytes_per_frame;
                                        write_frame.samples = write_frame.datalen / 2;
                                        memset(write_frame.data, 255, write_frame.datalen);
-
+                                       
                                        if (ringback_data) {
                                                char *tmp_data = NULL;
                                                
@@ -2882,7 +2882,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                        break;
                                }
 
-                               if (read_frame && !pass && !switch_test_flag(read_frame, SFF_CNG) && read_frame->datalen > 1) {
+                               if (switch_channel_test_flag(caller_channel, CF_RING_READY) && 
+                                       read_frame && !pass && !switch_test_flag(read_frame, SFF_CNG) && read_frame->datalen > 1) {
                                        if (ringback.fh) {
                                                uint8_t abuf[1024];
                                                switch_size_t mlen, olen;