diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index df6d0a7031..5ac52f79b6 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -667,6 +667,7 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra switch_size_t samples = 0, frames = 0, ms = 0; switch_channel *channel = NULL; int payload = 0; + switch_status status; channel = switch_core_session_get_channel(session); assert(channel != NULL); @@ -691,15 +692,12 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra while (!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) { payload = -1; tech_pvt->read_frame.flags = 0; + status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame); - if (switch_rtp_zerocopy_read(tech_pvt->rtp_session, - &tech_pvt->read_frame.data, - &tech_pvt->read_frame.datalen, - &payload, - &tech_pvt->read_frame.flags) != SWITCH_STATUS_SUCCESS) { - + if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) { return SWITCH_STATUS_FALSE; - } + } + payload = tech_pvt->read_frame.payload; /* RFC2833 ... TBD try harder to honor the duration etc.*/ if (payload == 101) { @@ -857,8 +855,7 @@ static switch_status channel_write_frame(switch_core_session *session, switch_fr //printf("%s send %d bytes %d samples in %d frames ts=%d\n", switch_channel_get_name(channel), frame->datalen, samples, frames, tech_pvt->timestamp_send); - - if (switch_rtp_write(tech_pvt->rtp_session, frame->data, frame->datalen, samples, &frame->flags) < 0) { + if (switch_rtp_write_frame(tech_pvt->rtp_session, frame, samples) < 0) { return SWITCH_STATUS_FALSE; } tech_pvt->timestamp_send += (int) samples; diff --git a/src/switch_rtp.c b/src/switch_rtp.c index ebe3889827..cf9208844f 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -496,11 +496,7 @@ static int rtp_common_read(switch_rtp *rtp_session, int *payload_type, switch_fr bytes = sizeof(rtp_msg_t); status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *)&rtp_session->recv_msg, &bytes); - if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ) && rtp_session->from_addr->port != rtp_session->remote_port) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Auto Changing port to %u\n", rtp_session->from_addr->port); - rtp_session->remote_addr->port = rtp_session->from_addr->port; - } - + if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO)) { return -1; } @@ -544,7 +540,14 @@ static int rtp_common_read(switch_rtp *rtp_session, int *payload_type, switch_fr return 0; } - if (rtp_session->recv_msg.header.version != 2) { + if (rtp_session->recv_msg.header.version == 2) { + if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ) && rtp_session->from_addr->port && + (rtp_session->from_addr->port != rtp_session->remote_port)) { + uint32_t old = rtp_session->remote_port; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Auto Changing port from %u to %u\n", old, rtp_session->from_addr->port); + rtp_session->remote_port = rtp_session->from_addr->port; + } + } else { if (rtp_session->recv_msg.header.version == 0 && rtp_session->ice_user) { handle_ice(rtp_session, (void *) &rtp_session->recv_msg, bytes); }