git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10540 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2008-11-26 15:22:26 +00:00
parent 8b87e4bac7
commit f6ae3b3c44
3 changed files with 27 additions and 18 deletions

View File

@@ -1269,32 +1269,35 @@ SWITCH_DECLARE(void) rtp_flush_read_buffer(switch_rtp_t *rtp_session)
switch_size_t bytes;
switch_status_t status;
if (!switch_rtp_ready(rtp_session)) {
if (!switch_rtp_ready(rtp_session) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
return;
}
READ_INC(rtp_session);
if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK)) {
was_blocking = 1;
switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, TRUE);
}
if (switch_rtp_ready(rtp_session)) {
if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK)) {
was_blocking = 1;
switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, TRUE);
}
do {
bytes = sizeof(rtp_msg_t);
status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock_input, 0, (void *) &rtp_session->recv_msg, &bytes);
} while(bytes);
if (was_blocking) {
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, FALSE);
do {
if (switch_rtp_ready(rtp_session)) {
bytes = sizeof(rtp_msg_t);
status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock_input, 0, (void *) &rtp_session->recv_msg, &bytes);
} else {
break;
}
} while(bytes > 0);
if (was_blocking && switch_rtp_ready(rtp_session)) {
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, FALSE);
}
}
READ_DEC(rtp_session);
}
#define return_cng_frame() do_cng = 1; goto timer_check