From 43e39619ae76be00bedf2f15276b04cc0fbb6ec5 Mon Sep 17 00:00:00 2001 From: Mathieu Rene Date: Wed, 25 Jul 2012 22:24:12 -0400 Subject: [PATCH] prevent writes if we dont have a remote addr --- src/mod/endpoints/mod_sofia/rtp.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/rtp.c b/src/mod/endpoints/mod_sofia/rtp.c index b24bb1653a..a12b3c6e55 100644 --- a/src/mod/endpoints/mod_sofia/rtp.c +++ b/src/mod/endpoints/mod_sofia/rtp.c @@ -188,11 +188,12 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi tech_pvt->dtmf_type = DTMF_2833; /* XXX */ if (zstr(local_addr) || local_port == 0) { - tech_pvt->mode = RTP_SENDONLY; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "The local address and port must be set\n"); + goto fail; } else if (zstr(remote_addr) || remote_port == 0) { - tech_pvt->mode = RTP_SENDRECV; + tech_pvt->mode = RTP_RECVONLY; } else { - + tech_pvt->mode = RTP_SENDRECV; } switch_core_session_set_private(*new_session, tech_pvt); @@ -314,7 +315,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch tech_pvt = switch_core_session_get_private(session); assert(tech_pvt != NULL); - if (!tech_pvt->rtp_session) { + if (!tech_pvt->rtp_session || tech_pvt->mode == RTP_RECVONLY) { goto cng; } @@ -429,6 +430,7 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error setting RTP remote address: %s\n", err); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set RTP remote: %s:%d\n", remote_addr, (int)remote_port); + tech_pvt->mode = RTP_SENDRECV; } } @@ -439,6 +441,15 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi /* Reset codec */ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Switching codec not yet implemented\n"); } + + if (compare_var(event, channel, kRFC2833PT)) { + const char *szpt = switch_channel_get_variable(channel, kRFC2833PT); + int pt = !zstr(szpt) ? atoi(szpt) : 0; + + switch_channel_set_variable(channel, kRFC2833PT, szpt); + switch_rtp_set_telephony_event(tech_pvt->rtp_session, pt); + } + } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Received unknown command [%s] in event.\n", !command ? "null" : command); }