working towards stability with new functions

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2368 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2006-08-22 22:34:48 +00:00
parent b2392afa2f
commit 31892070a6
4 changed files with 30 additions and 18 deletions

View 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"); 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 */ /* 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; 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); peer_channel = switch_core_session_get_channel(peer_session);
assert(peer_channel != NULL); assert(peer_channel != NULL);

View File

@ -1717,7 +1717,6 @@ static void handle_answer(eXosip_event_t *event)
uint8_t pre_answer = 0; uint8_t pre_answer = 0;
if ((tech_pvt = get_pvt_by_call_id(event->cid)) == 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); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "cannot answer nonexistant call [%d]!\n", event->cid);
return; 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); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "one pre-answer is enough for call [%d]!\n", event->cid);
return; return;
} }
switch_set_flag_locked(tech_pvt, TFLAG_PRE_ANSWER);
} }
channel = switch_core_session_get_channel(tech_pvt->session); 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 */ /* Get all of the remote SDP elements... stuff */
if ((remote_sdp = eXosip_get_sdp_info(event->response)) == 0) { if ((remote_sdp = eXosip_get_sdp_info(event->response)) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cant Find SDP?\n"); /* Exosip is daft, they send the same event for both 180 and 183 WTF!!*/
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); 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; return;
} }
@ -1767,13 +1771,8 @@ static void handle_answer(eXosip_event_t *event)
tech_pvt->did = event->did; tech_pvt->did = event->did;
tech_pvt->tid = event->tid; tech_pvt->tid = event->tid;
if (switch_test_flag(tech_pvt, TFLAG_USING_CODEC)) { 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);
}
{
int rate = atoi(drate); int rate = atoi(drate);
int ms = globals.codec_ms; 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); channel = switch_core_session_get_channel(tech_pvt->session);
assert(channel != NULL); assert(channel != NULL);
if (pre_answer) { if (pre_answer) {
switch_set_flag_locked(tech_pvt, TFLAG_PRE_ANSWER);
switch_channel_pre_answer(channel); switch_channel_pre_answer(channel);
} else { } else {
switch_channel_answer(channel); switch_channel_answer(channel);

View File

@ -1470,8 +1470,6 @@ static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
return JS_TRUE; return JS_TRUE;
} }
switch_core_session_rwunlock(peer_session);
jss = switch_core_session_alloc(peer_session, sizeof(*jss)); jss = switch_core_session_alloc(peer_session, sizeof(*jss));
jss->session = peer_session; jss->session = peer_session;
jss->flags = 0; jss->flags = 0;

View File

@ -1189,10 +1189,16 @@ static void *SWITCH_THREAD_FUNC collect_thread_run(switch_thread_t *thread, void
goto wbreak; goto wbreak;
} }
if (!switch_channel_ready(channel)) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
goto wbreak;
}
while(switch_channel_ready(channel)) { while(switch_channel_ready(channel)) {
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
if (collect->file) { if (collect->file) {
switch_ivr_play_file(collect->session, NULL, collect->file, NULL, NULL, buf, sizeof(buf)); switch_ivr_play_file(collect->session, NULL, collect->file, NULL, NULL, buf, sizeof(buf));
} else { } else {
switch_ivr_collect_digits_count(collect->session, buf, sizeof(buf), 1, "", &term, 0); 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) { if (key) {
struct key_collect *collect; struct key_collect *collect;
if ((collect = switch_core_session_alloc(peer_sessions[i], sizeof(*collect)))) { if ((collect = switch_core_session_alloc(peer_sessions[i], sizeof(*collect)))) {
switch_channel_set_flag(peer_channels[i], CF_TAGGED); switch_channel_set_flag(peer_channels[i], CF_TAGGED);
collect->key = key; collect->key = key;
if (file) { if (file) {
collect->file = switch_core_session_strdup(peer_sessions[i], file); collect->file = switch_core_session_strdup(peer_sessions[i], file);
} }
collect->session = peer_sessions[i]; collect->session = peer_sessions[i];
launch_collect_thread(collect); launch_collect_thread(collect);
} }
@ -1461,15 +1468,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
time(&start); time(&start);
for (;;) { for (;;) {
uint32_t valid_channels = 0;
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
int state; int state;
if (!peer_channels[i]) { if (!peer_channels[i]) {
continue; continue;
} }
valid_channels++;
state = switch_channel_get_state(peer_channels[i]); state = switch_channel_get_state(peer_channels[i]);
if (state >= CS_RING) { if (state >= CS_RING) {
goto endfor1; goto endfor1;
} }
@ -1483,6 +1491,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
} }
switch_yield(1000); switch_yield(1000);
} }
if (valid_channels == 0) {
status = SWITCH_STATUS_GENERR;
goto done;
}
} }
endfor1: 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)) && 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)) { 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 */ /* 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))) { 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); switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);