mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-13 07:45:26 +00:00
FSCORE-594
This commit is contained in:
parent
5c5d260bc7
commit
05a1e4003c
@ -168,7 +168,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
|
||||
\param port the remote port
|
||||
\param err pointer for error messages
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port,
|
||||
SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port, switch_port_t remote_rtcp_port,
|
||||
switch_bool_t change_adv_addr, const char **err);
|
||||
|
||||
SWITCH_DECLARE(char *) switch_rtp_get_remote_host(switch_rtp_t *rtp_session);
|
||||
|
@ -1127,8 +1127,16 @@ switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt)
|
||||
sofia_set_flag_locked(tech_pvt, TFLAG_VIDEO);
|
||||
switch_channel_set_flag(tech_pvt->channel, CF_VIDEO);
|
||||
if (switch_rtp_ready(tech_pvt->video_rtp_session)) {
|
||||
const char *rport = NULL;
|
||||
switch_port_t remote_rtcp_port = 0;
|
||||
|
||||
if ((rport = switch_channel_get_variable(tech_pvt->channel, "sip_remote_video_rtcp_port"))) {
|
||||
remote_rtcp_port = atoi(rport);
|
||||
}
|
||||
|
||||
|
||||
if (switch_rtp_set_remote_address(tech_pvt->video_rtp_session, tech_pvt->remote_sdp_video_ip,
|
||||
tech_pvt->remote_sdp_video_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
|
||||
tech_pvt->remote_sdp_video_port, remote_rtcp_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "VIDEO RTP REPORTS ERROR: [%s]\n", err);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "VIDEO RTP CHANGING DEST TO: [%s:%d]\n",
|
||||
@ -1149,6 +1157,8 @@ switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt)
|
||||
if (switch_rtp_ready(tech_pvt->rtp_session)) {
|
||||
char *remote_host = switch_rtp_get_remote_host(tech_pvt->rtp_session);
|
||||
switch_port_t remote_port = switch_rtp_get_remote_port(tech_pvt->rtp_session);
|
||||
const char *rport = NULL;
|
||||
switch_port_t remote_rtcp_port = 0;
|
||||
|
||||
if (remote_host && remote_port && !strcmp(remote_host, tech_pvt->remote_sdp_audio_ip) && remote_port == tech_pvt->remote_sdp_audio_port) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Remote address:port [%s:%d] has not changed.\n",
|
||||
@ -1156,8 +1166,13 @@ switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if ((rport = switch_channel_get_variable(tech_pvt->channel, "sip_remote_audio_rtcp_port"))) {
|
||||
remote_rtcp_port = atoi(rport);
|
||||
}
|
||||
|
||||
|
||||
if (switch_rtp_set_remote_address(tech_pvt->rtp_session, tech_pvt->remote_sdp_audio_ip,
|
||||
tech_pvt->remote_sdp_audio_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
|
||||
tech_pvt->remote_sdp_audio_port, remote_rtcp_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", err);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "AUDIO RTP CHANGING DEST TO: [%s:%d]\n",
|
||||
@ -2605,9 +2620,17 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
|
||||
|
||||
if (tech_pvt->rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
|
||||
const char *rport = NULL;
|
||||
switch_port_t remote_rtcp_port = 0;
|
||||
|
||||
sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
|
||||
|
||||
if (switch_rtp_set_remote_address(tech_pvt->rtp_session, tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port, SWITCH_TRUE, &err) !=
|
||||
if ((rport = switch_channel_get_variable(tech_pvt->channel, "sip_remote_audio_rtcp_port"))) {
|
||||
remote_rtcp_port = atoi(rport);
|
||||
}
|
||||
|
||||
if (switch_rtp_set_remote_address(tech_pvt->rtp_session, tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port,
|
||||
remote_rtcp_port, SWITCH_TRUE, &err) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", err);
|
||||
} else {
|
||||
@ -2859,10 +2882,17 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, tmp);
|
||||
|
||||
if (tech_pvt->video_rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
|
||||
const char *rport = NULL;
|
||||
switch_port_t remote_rtcp_port = 0;
|
||||
|
||||
sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
|
||||
|
||||
if ((rport = switch_channel_get_variable(tech_pvt->channel, "sip_remote_video_rtcp_port"))) {
|
||||
remote_rtcp_port = atoi(rport);
|
||||
}
|
||||
|
||||
if (switch_rtp_set_remote_address
|
||||
(tech_pvt->video_rtp_session, tech_pvt->remote_sdp_video_ip, tech_pvt->remote_sdp_video_port, SWITCH_TRUE,
|
||||
(tech_pvt->video_rtp_session, tech_pvt->remote_sdp_video_ip, tech_pvt->remote_sdp_video_port, remote_rtcp_port, SWITCH_TRUE,
|
||||
&err) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "VIDEO RTP REPORTS ERROR: [%s]\n", err);
|
||||
} else {
|
||||
|
@ -778,19 +778,27 @@ static switch_status_t enable_remote_rtcp_socket(switch_rtp_t *rtp_session, cons
|
||||
rtp_session->remote_rtcp_port, 0, rtp_session->pool) != SWITCH_STATUS_SUCCESS || !rtp_session->rtcp_remote_addr) {
|
||||
*err = "RTCP Remote Address Error!";
|
||||
return SWITCH_STATUS_FALSE;
|
||||
} else {
|
||||
const char *host;
|
||||
char bufa[30];
|
||||
host = switch_get_addr(bufa, sizeof(bufa), rtp_session->rtcp_remote_addr);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting RTCP remote addr to %s:%d\n", host, rtp_session->remote_rtcp_port);
|
||||
}
|
||||
|
||||
if (rtp_session->rtcp_sock_input && switch_sockaddr_get_family(rtp_session->rtcp_remote_addr) ==
|
||||
switch_sockaddr_get_family(rtp_session->rtcp_local_addr)) {
|
||||
rtp_session->rtcp_sock_output = rtp_session->rtcp_sock_input;
|
||||
} else {
|
||||
if (rtp_session->rtcp_sock_output && rtp_session->rtcp_sock_output != rtp_session->rtcp_sock_input) {
|
||||
switch_socket_close(rtp_session->rtcp_sock_output);
|
||||
}
|
||||
if ((status = switch_socket_create(&rtp_session->rtcp_sock_output,
|
||||
switch_sockaddr_get_family(rtp_session->rtcp_remote_addr),
|
||||
SOCK_DGRAM, 0, rtp_session->pool)) != SWITCH_STATUS_SUCCESS) {
|
||||
*err = "RTCP Socket Error!";
|
||||
if (!(rtp_session->rtcp_sock_input && rtp_session->rtcp_sock_output)) {
|
||||
if (rtp_session->rtcp_sock_input && switch_sockaddr_get_family(rtp_session->rtcp_remote_addr) ==
|
||||
switch_sockaddr_get_family(rtp_session->rtcp_local_addr)) {
|
||||
rtp_session->rtcp_sock_output = rtp_session->rtcp_sock_input;
|
||||
} else {
|
||||
if (rtp_session->rtcp_sock_output && rtp_session->rtcp_sock_output != rtp_session->rtcp_sock_input) {
|
||||
switch_socket_close(rtp_session->rtcp_sock_output);
|
||||
}
|
||||
if ((status = switch_socket_create(&rtp_session->rtcp_sock_output,
|
||||
switch_sockaddr_get_family(rtp_session->rtcp_remote_addr),
|
||||
SOCK_DGRAM, 0, rtp_session->pool)) != SWITCH_STATUS_SUCCESS) {
|
||||
*err = "RTCP Socket Error!";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1020,7 +1028,7 @@ SWITCH_DECLARE(switch_port_t) switch_rtp_get_remote_port(switch_rtp_t *rtp_sessi
|
||||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port,
|
||||
SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port, switch_port_t remote_rtcp_port,
|
||||
switch_bool_t change_adv_addr, const char **err)
|
||||
{
|
||||
switch_sockaddr_t *remote_addr;
|
||||
@ -1056,6 +1064,11 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_
|
||||
}
|
||||
|
||||
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_ENABLE_RTCP)) {
|
||||
if (remote_rtcp_port) {
|
||||
rtp_session->remote_rtcp_port = remote_rtcp_port;
|
||||
} else {
|
||||
rtp_session->remote_rtcp_port = rtp_session->remote_port + 1;
|
||||
}
|
||||
status = enable_remote_rtcp_socket(rtp_session, err);
|
||||
}
|
||||
|
||||
@ -1462,7 +1475,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (switch_rtp_set_remote_address(rtp_session, tx_host, tx_port, SWITCH_TRUE, err) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_rtp_set_remote_address(rtp_session, tx_host, tx_port, 0, SWITCH_TRUE, err) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_mutex_unlock(rtp_session->flag_mutex);
|
||||
rtp_session = NULL;
|
||||
goto end;
|
||||
@ -2426,7 +2439,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
|
||||
switch_channel_set_variable(channel, "rtp_auto_adjust", "true");
|
||||
}
|
||||
|
||||
switch_rtp_set_remote_address(rtp_session, tx_host, switch_sockaddr_get_port(rtp_session->from_addr), SWITCH_FALSE, &err);
|
||||
switch_rtp_set_remote_address(rtp_session, tx_host, switch_sockaddr_get_port(rtp_session->from_addr), 0, SWITCH_FALSE, &err);
|
||||
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user