提交 e4117136 authored 作者: Anthony Minessale's avatar Anthony Minessale

drop excess frames on loopback channel

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13156 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 972fe26b
...@@ -187,7 +187,7 @@ static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *ses ...@@ -187,7 +187,7 @@ static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *ses
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
switch_mutex_init(&tech_pvt->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); switch_mutex_init(&tech_pvt->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
switch_core_session_set_private(session, tech_pvt); switch_core_session_set_private(session, tech_pvt);
switch_queue_create(&tech_pvt->frame_queue, 50000, switch_core_session_get_pool(session)); switch_queue_create(&tech_pvt->frame_queue, 3, switch_core_session_get_pool(session));
tech_pvt->session = session; tech_pvt->session = session;
tech_pvt->channel = switch_core_session_get_channel(session); tech_pvt->channel = switch_core_session_get_channel(session);
} }
...@@ -503,7 +503,7 @@ static switch_status_t channel_on_consume_media(switch_core_session_t *session) ...@@ -503,7 +503,7 @@ static switch_status_t channel_on_consume_media(switch_core_session_t *session)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL CONSUME_MEDIA\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL CONSUME_MEDIA\n");
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf) static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
...@@ -548,9 +548,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch ...@@ -548,9 +548,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
goto end; goto end;
} }
if (!switch_queue_size(tech_pvt->frame_queue)) { switch_core_timer_next(&tech_pvt->timer);
switch_core_timer_next(&tech_pvt->timer);
}
if (switch_queue_trypop(tech_pvt->frame_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) { if (switch_queue_trypop(tech_pvt->frame_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
if (tech_pvt->write_frame) { if (tech_pvt->write_frame) {
...@@ -669,8 +667,11 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc ...@@ -669,8 +667,11 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
if (switch_frame_dup(frame, &clone) != SWITCH_STATUS_SUCCESS) { if (switch_frame_dup(frame, &clone) != SWITCH_STATUS_SUCCESS) {
abort(); abort();
} }
if (switch_queue_trypush(tech_pvt->other_tech_pvt->frame_queue, clone) != SWITCH_STATUS_SUCCESS) {
switch_frame_free(&clone);
}
switch_queue_push(tech_pvt->other_tech_pvt->frame_queue, clone);
switch_set_flag_locked(tech_pvt->other_tech_pvt, TFLAG_WRITE); switch_set_flag_locked(tech_pvt->other_tech_pvt, TFLAG_WRITE);
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
} }
...@@ -727,10 +728,10 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s ...@@ -727,10 +728,10 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
switch_frame_t *frame = (switch_frame_t *) pop; switch_frame_t *frame = (switch_frame_t *) pop;
switch_frame_free(&frame); switch_frame_free(&frame);
} }
/* avoid endless loop by not forwarding it when it came from this same place */
if (tech_pvt->other_session && strcmp(msg->_file, __FILE__)) { while (switch_queue_trypop(tech_pvt->other_tech_pvt->frame_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
/* pass message over to the other leg */ switch_frame_t *frame = (switch_frame_t *) pop;
switch_core_session_receive_message(tech_pvt->other_session, msg); switch_frame_free(&frame);
} }
} }
break; break;
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
* *
*/ */
//#define DEBUG_2833 //#define DEBUG_2833
#define RTP_DEBUG_WRITE_DELTA
#include <switch.h> #include <switch.h>
#include <switch_stun.h> #include <switch_stun.h>
#undef PACKAGE_NAME #undef PACKAGE_NAME
...@@ -203,6 +204,11 @@ struct switch_rtp { ...@@ -203,6 +204,11 @@ struct switch_rtp {
uint32_t cng_count; uint32_t cng_count;
switch_rtp_bug_flag_t rtp_bugs; switch_rtp_bug_flag_t rtp_bugs;
switch_rtp_stats_t stats; switch_rtp_stats_t stats;
#ifdef RTP_DEBUG_WRITE_DELTA
switch_time_t send_time;
#endif
}; };
static int global_init = 0; static int global_init = 0;
...@@ -2229,6 +2235,18 @@ static int rtp_common_write(switch_rtp_t *rtp_session, ...@@ -2229,6 +2235,18 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
bytes = sbytes; bytes = sbytes;
} }
#undef RTP_DEBUG_WRITE_DELTA
#ifdef RTP_DEBUG_WRITE_DELTA
{
switch_time_t now = switch_time_now();
int delta = (int) (now - rtp_session->send_time) / 1000;
//assert(delta);
//printf("WRITE %d delta %d\n", (int)bytes, delta);
rtp_session->send_time = now;
}
#endif
if (switch_socket_sendto(rtp_session->sock_output, rtp_session->remote_addr, 0, (void *) send_msg, &bytes) != SWITCH_STATUS_SUCCESS) { if (switch_socket_sendto(rtp_session->sock_output, rtp_session->remote_addr, 0, (void *) send_msg, &bytes) != SWITCH_STATUS_SUCCESS) {
rtp_session->seq--; rtp_session->seq--;
ret = -1; ret = -1;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论