提交 43e39619 authored 作者: Mathieu Rene's avatar Mathieu Rene

prevent writes if we dont have a remote addr

上级 84796f84
...@@ -188,11 +188,12 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi ...@@ -188,11 +188,12 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
tech_pvt->dtmf_type = DTMF_2833; /* XXX */ tech_pvt->dtmf_type = DTMF_2833; /* XXX */
if (zstr(local_addr) || local_port == 0) { 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) { } else if (zstr(remote_addr) || remote_port == 0) {
tech_pvt->mode = RTP_SENDRECV; tech_pvt->mode = RTP_RECVONLY;
} else { } else {
tech_pvt->mode = RTP_SENDRECV;
} }
switch_core_session_set_private(*new_session, tech_pvt); 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 ...@@ -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); tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL); assert(tech_pvt != NULL);
if (!tech_pvt->rtp_session) { if (!tech_pvt->rtp_session || tech_pvt->mode == RTP_RECVONLY) {
goto cng; goto cng;
} }
...@@ -429,6 +430,7 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi ...@@ -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); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error setting RTP remote address: %s\n", err);
} else { } else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set RTP remote: %s:%d\n", remote_addr, (int)remote_port); 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 ...@@ -439,6 +441,15 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi
/* Reset codec */ /* Reset codec */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Switching codec not yet implemented\n"); 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 { } else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Received unknown command [%s] in event.\n", !command ? "null" : command); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Received unknown command [%s] in event.\n", !command ? "null" : command);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论