mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-14 16:15:04 +00:00
more nat goodies for proxy media mode
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8563 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
5297a2c982
commit
292b94e058
@ -1130,7 +1130,34 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytes > 0) {
|
if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ) && switch_sockaddr_get_port(rtp_session->from_addr)) {
|
||||||
|
const char *tx_host;
|
||||||
|
const char *old_host;
|
||||||
|
char bufa[30], bufb[30];
|
||||||
|
tx_host = switch_get_addr(bufa, sizeof(bufa), rtp_session->from_addr);
|
||||||
|
old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session->remote_addr);
|
||||||
|
if ((switch_sockaddr_get_port(rtp_session->from_addr) != rtp_session->remote_port) || strcmp(tx_host, old_host)) {
|
||||||
|
const char *err;
|
||||||
|
uint32_t old = rtp_session->remote_port;
|
||||||
|
|
||||||
|
if (!switch_strlen_zero(tx_host) && switch_sockaddr_get_port(rtp_session->from_addr) > 0) {
|
||||||
|
if (++rtp_session->autoadj_tally >= 10) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||||
|
"Auto Changing port from %s:%u to %s:%u\n", old_host, old, tx_host,
|
||||||
|
switch_sockaddr_get_port(rtp_session->from_addr));
|
||||||
|
switch_rtp_set_remote_address(rtp_session, tx_host, switch_sockaddr_get_port(rtp_session->from_addr), &err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bytes && rtp_session->autoadj_window) {
|
||||||
|
if (--rtp_session->autoadj_window == 0) {
|
||||||
|
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bytes) {
|
||||||
rtp_session->missed_count = 0;
|
rtp_session->missed_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1372,33 +1399,6 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ) && switch_sockaddr_get_port(rtp_session->from_addr)) {
|
|
||||||
const char *tx_host;
|
|
||||||
const char *old_host;
|
|
||||||
char bufa[30], bufb[30];
|
|
||||||
tx_host = switch_get_addr(bufa, sizeof(bufa), rtp_session->from_addr);
|
|
||||||
old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session->remote_addr);
|
|
||||||
if ((switch_sockaddr_get_port(rtp_session->from_addr) != rtp_session->remote_port) || strcmp(tx_host, old_host)) {
|
|
||||||
const char *err;
|
|
||||||
uint32_t old = rtp_session->remote_port;
|
|
||||||
|
|
||||||
if (!switch_strlen_zero(tx_host) && switch_sockaddr_get_port(rtp_session->from_addr) > 0) {
|
|
||||||
if (++rtp_session->autoadj_tally >= 10) {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
|
||||||
"Auto Changing port from %s:%u to %s:%u\n", old_host, old, tx_host,
|
|
||||||
switch_sockaddr_get_port(rtp_session->from_addr));
|
|
||||||
switch_rtp_set_remote_address(rtp_session, tx_host, switch_sockaddr_get_port(rtp_session->from_addr), &err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rtp_session->autoadj_window) {
|
|
||||||
if (--rtp_session->autoadj_window == 0) {
|
|
||||||
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bytes && rtp_session->cng_pt && rtp_session->recv_msg.header.pt == rtp_session->cng_pt) {
|
if (bytes && rtp_session->cng_pt && rtp_session->recv_msg.header.pt == rtp_session->cng_pt) {
|
||||||
goto do_continue;
|
goto do_continue;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user