]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
working towards stability with new functions
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 22 Aug 2006 22:34:48 +0000 (22:34 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 22 Aug 2006 22:34:48 +0000 (22:34 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2368 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_conference/mod_conference.c
src/mod/endpoints/mod_exosip/mod_exosip.c
src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
src/switch_ivr.c

index bf9632ab648d43b3926d2d0ca6e12e9aafd1050d..37aa66bca896026e51da24fa99d7481ff5c2203c 100644 (file)
@@ -1963,6 +1963,7 @@ static switch_status_t audio_bridge_on_ring(switch_core_session_t *session)
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CUSTOM RING\n");
 
        /* put the channel in a passive state so we can loop audio to it */
+       switch_channel_set_state(channel, CS_TRANSMIT);
        return SWITCH_STATUS_FALSE;
 }
 
@@ -1999,7 +2000,6 @@ static switch_status_t conference_outcall(conference_obj_t *conference,
        } 
 
 
-       switch_core_session_rwunlock(peer_session);
        peer_channel = switch_core_session_get_channel(peer_session);
        assert(peer_channel != NULL);
        
index 2db368450bdb2a5dde8227cc51b41a3974b3ee60..6a768eec8103db3c5021fb23d1d204e6ccde9f6d 100644 (file)
@@ -1717,7 +1717,6 @@ static void handle_answer(eXosip_event_t *event)
        uint8_t pre_answer = 0;
 
 
-
        if ((tech_pvt = get_pvt_by_call_id(event->cid)) == 0) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "cannot answer nonexistant call [%d]!\n", event->cid);
                return;
@@ -1729,7 +1728,6 @@ static void handle_answer(eXosip_event_t *event)
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "one pre-answer is enough for call [%d]!\n", event->cid);
                        return;
                }
-               switch_set_flag_locked(tech_pvt, TFLAG_PRE_ANSWER);
        }
 
        channel = switch_core_session_get_channel(tech_pvt->session);
@@ -1743,8 +1741,14 @@ static void handle_answer(eXosip_event_t *event)
 
        /* Get all of the remote SDP elements... stuff */
        if ((remote_sdp = eXosip_get_sdp_info(event->response)) == 0) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cant Find SDP?\n");
-               switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+               /* Exosip is daft, they send the same event for both 180 and 183 WTF!!*/
+               if (!pre_answer) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cant Find SDP?\n");
+                       switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+               } else {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "I am daft, don't mind me.\n");
+               }
+               
                return;
        }
 
@@ -1767,13 +1771,8 @@ static void handle_answer(eXosip_event_t *event)
        tech_pvt->did = event->did;
        tech_pvt->tid = event->tid;
 
-       if (switch_test_flag(tech_pvt, TFLAG_USING_CODEC)) {
-               switch_core_codec_destroy(&tech_pvt->read_codec);
-               switch_core_codec_destroy(&tech_pvt->write_codec);
-               switch_clear_flag_locked(tech_pvt, TFLAG_USING_CODEC);
-       }
-
-       {
+       if (!switch_test_flag(tech_pvt, TFLAG_USING_CODEC)) {
+       
                int rate = atoi(drate);
                int ms = globals.codec_ms;
 
@@ -1842,6 +1841,7 @@ static void handle_answer(eXosip_event_t *event)
                channel = switch_core_session_get_channel(tech_pvt->session);
                assert(channel != NULL);
                if (pre_answer) {
+                       switch_set_flag_locked(tech_pvt, TFLAG_PRE_ANSWER);
                        switch_channel_pre_answer(channel);
                } else {
                        switch_channel_answer(channel);
index 4472f2947f835b42c26fa006cce439e54f069d0f..124f391f53b171e8f00c9f3d2b764a3e766b8438 100644 (file)
@@ -1470,8 +1470,6 @@ static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
                        return JS_TRUE;
                }
 
-               switch_core_session_rwunlock(peer_session);
-
                jss = switch_core_session_alloc(peer_session, sizeof(*jss));
                jss->session = peer_session;
                jss->flags = 0;
index 6ec076db25ac212b0541fba038279b27d04b0844..349a71fa4f2de5abfb754f8887b7cf7583c2ed87 100644 (file)
@@ -1189,10 +1189,16 @@ static void *SWITCH_THREAD_FUNC collect_thread_run(switch_thread_t *thread, void
                goto wbreak;
        }
 
+       if (!switch_channel_ready(channel)) {
+               switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+               goto wbreak;
+       }
+
        while(switch_channel_ready(channel)) {
                memset(buf, 0, sizeof(buf));
 
                if (collect->file) {
+
                        switch_ivr_play_file(collect->session, NULL, collect->file, NULL, NULL, buf, sizeof(buf));
                } else {
                        switch_ivr_collect_digits_count(collect->session, buf, sizeof(buf), 1, "", &term, 0);
@@ -1244,13 +1250,14 @@ static uint8_t check_channel_status(switch_channel_t **peer_channels,
 
                        if (key) {
                                struct key_collect *collect;
-
+                               
                                if ((collect = switch_core_session_alloc(peer_sessions[i], sizeof(*collect)))) {
                                        switch_channel_set_flag(peer_channels[i], CF_TAGGED);
                                        collect->key = key;
                                        if (file) {
                                                collect->file = switch_core_session_strdup(peer_sessions[i], file);
                                        }
+                               
                                        collect->session = peer_sessions[i];
                                        launch_collect_thread(collect);
                                }
@@ -1461,15 +1468,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
        time(&start);
 
        for (;;) {
+               uint32_t valid_channels = 0;
                for (i = 0; i < argc; i++) {
                        int state;
 
                        if (!peer_channels[i]) {
                                continue;
                        }
-
+                       valid_channels++;
                        state = switch_channel_get_state(peer_channels[i]);
-
+                       
                        if (state >= CS_RING) {
                                goto endfor1;
                        }
@@ -1483,6 +1491,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                        }
                        switch_yield(1000);
                }
+
+               if (valid_channels == 0) {
+                       status = SWITCH_STATUS_GENERR;
+                       goto done;
+               }
+
        }
  endfor1:
 
@@ -1513,7 +1527,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
 
        while ((!caller_channel || switch_channel_ready(caller_channel)) && 
                   check_channel_status(peer_channels, peer_sessions, argc, &idx, file, key) && ((time(NULL) - start) < (time_t)timelimit_sec)) {
-               
+
                /* read from the channel while we wait if the audio is up on it */
                if (session && (switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA))) {
                        switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);