]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix outbound event_socket + late negotiation
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 8 Jul 2008 23:30:17 +0000 (23:30 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 8 Jul 2008 23:30:17 +0000 (23:30 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8949 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_ivr.c

index 6e3c20b2a24741e90fc51d7b3b4ef7d3a079e351..7ebb131a647f3f933b303d3941863e0b3aa06b76 100644 (file)
@@ -481,15 +481,25 @@ 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;
-       switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
+       switch_codec_t *read_codec;
        uint32_t rate;
        uint32_t bpf;
 
        if (switch_channel_test_flag(channel, CF_CONTROLLED)) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot park channels that is under control already.\n");
+               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;
+               }
+       }
+
+       read_codec = switch_core_session_get_read_codec(session);
+
        if (!read_codec || !read_codec->implementation) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot park channels that have no read codec.\n");
                return SWITCH_STATUS_FALSE;
@@ -498,11 +508,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
        rate = read_codec->implementation->actual_samples_per_second;
        bpf = read_codec->implementation->bytes_per_frame;
 
-       if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Careful, Channel is unanswered. Pre-answering...\n");
-               switch_channel_pre_answer(channel);
-       }
-
        switch_channel_set_flag(channel, CF_CONTROLLED);
        if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_PARK) == SWITCH_STATUS_SUCCESS) {
                switch_channel_event_set_data(channel, event);