diff --git a/libs/libdingaling/src/libdingaling.c b/libs/libdingaling/src/libdingaling.c index 57670be0af..4912ecac85 100644 --- a/libs/libdingaling/src/libdingaling.c +++ b/libs/libdingaling/src/libdingaling.c @@ -389,6 +389,7 @@ static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from, if (!strcasecmp(type, "initiate") || !strcasecmp(type, "accept")) { dl_signal = LDL_SIGNAL_INITIATE; + if (!strcasecmp(type, "accept")) { msg = "accept"; } @@ -1432,10 +1433,10 @@ static void *APR_THREAD_FUNC queue_thread(apr_thread_t *thread, void *obj) ldl_set_flag_locked(handle, LDL_FLAG_QUEUE_RUNNING); - while (ldl_test_flag((&globals), LDL_FLAG_READY) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) { + while (ldl_test_flag(handle, LDL_FLAG_RUNNING)) { ldl_flush_queue(handle, 0); - if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS) { + if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS || !ldl_test_flag((&globals), LDL_FLAG_READY)) { int fd; if ((fd = iks_fd(handle->parser)) > -1) { @@ -1470,6 +1471,7 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass) while (ldl_test_flag((&globals), LDL_FLAG_READY) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) { int e; char tmp[512], *sl; + int fd; handle->parser = iks_stream_new(ldl_test_flag(handle, LDL_FLAG_COMPONENT) ? IKS_NS_COMPONENT : IKS_NS_CLIENT, handle, @@ -1570,6 +1572,10 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass) ldl_clear_flag_locked(handle, LDL_FLAG_CONNECTED); ldl_clear_flag_locked(handle, LDL_FLAG_AUTHORIZED); handle->state = CS_NEW; + + if ((fd = iks_fd(handle->parser)) > -1) { + shutdown(fd, 0x02); + } while(ldl_test_flag(handle, LDL_FLAG_QUEUE_RUNNING)) { microsleep(100); @@ -2224,7 +2230,7 @@ void ldl_global_set_log_stream(FILE *log_stream) int8_t ldl_handle_ready(ldl_handle_t *handle) { - return (int8_t)ldl_test_flag(handle, LDL_FLAG_READY); + return (int8_t) (ldl_test_flag(handle, LDL_FLAG_READY) && ldl_test_flag((&globals), LDL_FLAG_READY)); } ldl_status ldl_handle_init(ldl_handle_t **handle, diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index 8e7b49a900..29cd6f56f7 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -873,11 +873,16 @@ static int activate_rtp(struct private_object *tech_pvt) tech_pvt->local_port, tech_pvt->remote_ip, tech_pvt->remote_port); flags = SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_GOOGLEHACK | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_RAW_WRITE | SWITCH_RTP_FLAG_AUTO_CNG; + if (switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) { flags |= SWITCH_RTP_FLAG_USE_TIMER; } + if (switch_true(switch_channel_get_variable(channel, "disable_rtp_auto_adjust"))) { + flags &= ~SWITCH_RTP_FLAG_AUTOADJ; + } + if (!(tech_pvt->rtp_session = switch_rtp_new(tech_pvt->profile->ip, tech_pvt->local_port, tech_pvt->remote_ip, @@ -1131,7 +1136,9 @@ static switch_status_t negotiate_media(switch_core_session_t *session) if (!do_candidates(tech_pvt, 0)) { goto out; } - switch_channel_answer(channel); + if (switch_test_flag(tech_pvt, TFLAG_TRANSPORT_ACCEPT)) { + switch_channel_answer(channel); + } } ret = SWITCH_STATUS_SUCCESS; @@ -2549,7 +2556,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi status = LDL_STATUS_FALSE; goto done; } - + } else { if (dl_signal != LDL_SIGNAL_INITIATE && !msg) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Session is already dead\n"); @@ -2746,6 +2753,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) { if (!strcasecmp(msg, "accept")) { switch_set_flag_locked(tech_pvt, TFLAG_ANSWER); + switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT); if (!do_candidates(tech_pvt, 0)) { terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); status = LDL_STATUS_FALSE; @@ -2909,7 +2917,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi } if (!strcasecmp(subject, "candidates")) { - switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT); + //switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT); switch_set_flag_locked(tech_pvt, TFLAG_ANSWER); }