]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
allow socket app to operate without pre_answer (please test)
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 13 May 2009 16:34:39 +0000 (16:34 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 13 May 2009 16:34:39 +0000 (16:34 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13294 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/event_handlers/mod_event_socket/mod_event_socket.c
src/switch_ivr.c

index 9f02e5cdcae1464fae1f072c448859d975a5c944..861cc2e3ae6800d0f5818583abb879b9153305e7 100644 (file)
@@ -1401,7 +1401,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                        if (!sofia_test_flag(tech_pvt, TFLAG_ANS) && !sofia_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
 
                                sofia_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
-                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from);
+                               switch_log_printf(SWITCH_CHANNEL_ID_LOG, msg->_file, msg->_func, msg->_line, NULL, SWITCH_LOG_INFO, "Sending early media\n");
 
                                /* Transmit 183 Progress with SDP */
                                if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
index 84fb2999c9726dc04fa5b94e91a2a758ec06a5eb..2353faee279621925d92eb5be28ea5a39e628350 100644 (file)
@@ -432,10 +432,6 @@ SWITCH_STANDARD_APP(socket_function)
                
                launch_listener_thread(listener);
 
-               if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
-                       return;
-               }
-               
                while(switch_channel_ready(channel) && !switch_test_flag(listener, LFLAG_CONNECTED)) {
                        switch_cond_next();
                }
index 23dfc2469ab95ab561a1c4fbdbf55b2dbdf51c45..cab280b7f9ca84062710996476dc8e0580ac9c2a 100644 (file)
@@ -642,40 +642,23 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
        int stream_id = 0;
        switch_event_t *event;
        switch_unicast_conninfo_t *conninfo = NULL;
-       uint32_t rate;
-       uint32_t bpf;
+       uint32_t rate = 0;
+       uint32_t bpf = 0;
        const char *to;
        int timeout = 0;
        time_t expires = 0;
-
        switch_codec_implementation_t read_impl = {0};
-    switch_core_session_get_read_impl(session, &read_impl);
+
        
        if (switch_channel_test_flag(channel, CF_CONTROLLED)) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot park channels that are under control already.\n");
                return SWITCH_STATUS_FALSE;
        }
 
-       if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Careful, Channel is unanswered. Pre-answering...\n");
-               if ((status = switch_channel_pre_answer(channel)) != SWITCH_STATUS_SUCCESS) {
-                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot establish media.\n");
-                       return SWITCH_STATUS_FALSE;
-               }
-       }
-       
        if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_get_state(channel) == CS_RESET) {
                return SWITCH_STATUS_FALSE;
        }
        
-       if (!switch_channel_media_ready(channel)) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot park channels that have no read codec.\n");
-               return SWITCH_STATUS_FALSE;
-       }
-
-       rate = read_impl.actual_samples_per_second;
-       bpf = read_impl.decoded_bytes_per_packet;
-
        if ((to = switch_channel_get_variable(channel, "park_timeout"))) {
                if ((timeout = atoi(to)) < 0) {
                        timeout = 0;
@@ -693,20 +676,36 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
                switch_event_fire(&event);
        }
 
-       while (switch_channel_media_ready(channel) && switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_CONTROLLED) 
-                  && switch_channel_test_flag(channel, CF_PARK)) {
-               
-               if ((status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, stream_id)) == SWITCH_STATUS_SUCCESS) {
-                       if (!SWITCH_READ_ACCEPTABLE(status)) {
-                               break;
-                       }
+       while (switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_CONTROLLED) && switch_channel_test_flag(channel, CF_PARK)) {
+       
+               if (!rate && switch_channel_media_ready(channel)) {
+                       switch_core_session_get_read_impl(session, &read_impl);
+                       rate = read_impl.actual_samples_per_second;
+                       bpf = read_impl.decoded_bytes_per_packet;
+               }
+       
+               if (rate) {
+                       status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, stream_id);
+               } else {
+                       switch_yield(20000);
+                       status = SWITCH_STATUS_SUCCESS;
+               }
 
+               if (!SWITCH_READ_ACCEPTABLE(status)) {
+                       break;
+               } else {
                        if (expires && switch_epoch_time_now(NULL) >= expires) {
                                switch_channel_hangup(channel, SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE);
                                break;
                        }
 
                        if (switch_channel_test_flag(channel, CF_UNICAST)) {
+                               if (!switch_channel_media_ready(channel)) {
+                                       if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
+                                               return SWITCH_STATUS_FALSE;
+                                       }
+                               }
+
                                if (!conninfo) {
                                        if (!(conninfo = switch_channel_get_private(channel, "unicast"))) {
                                                switch_channel_clear_flag(channel, CF_UNICAST);