FS-7602 FS-7499 FS-7587 #comment another refactoring pass on candidate parsing and ipv4/6 parsing
This commit is contained in:
parent
fc075a75e5
commit
6c135e15c1
|
@ -103,7 +103,7 @@ typedef struct icand_s {
|
||||||
typedef struct ice_s {
|
typedef struct ice_s {
|
||||||
|
|
||||||
icand_t cands[MAX_CAND][2];
|
icand_t cands[MAX_CAND][2];
|
||||||
int cand_idx;
|
int cand_idx[2];
|
||||||
int chosen[2];
|
int chosen[2];
|
||||||
int is_chosen[2];
|
int is_chosen[2];
|
||||||
char *ufrag;
|
char *ufrag;
|
||||||
|
|
|
@ -143,7 +143,7 @@ static void verto_deinit_ssl(verto_profile_t *profile)
|
||||||
|
|
||||||
static void close_file(ws_socket_t *sock)
|
static void close_file(ws_socket_t *sock)
|
||||||
{
|
{
|
||||||
if (*sock > -1) {
|
if (*sock != ws_sock_invalid) {
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
close(*sock);
|
close(*sock);
|
||||||
#else
|
#else
|
||||||
|
@ -155,7 +155,7 @@ static void close_file(ws_socket_t *sock)
|
||||||
|
|
||||||
static void close_socket(ws_socket_t *sock)
|
static void close_socket(ws_socket_t *sock)
|
||||||
{
|
{
|
||||||
if (*sock > -1) {
|
if (*sock != ws_sock_invalid) {
|
||||||
shutdown(*sock, 2);
|
shutdown(*sock, 2);
|
||||||
close_file(sock);
|
close_file(sock);
|
||||||
}
|
}
|
||||||
|
@ -1914,7 +1914,7 @@ static void *SWITCH_THREAD_FUNC client_thread(switch_thread_t *thread, void *obj
|
||||||
switch_event_destroy(&jsock->vars);
|
switch_event_destroy(&jsock->vars);
|
||||||
switch_event_destroy(&jsock->user_vars);
|
switch_event_destroy(&jsock->user_vars);
|
||||||
|
|
||||||
if (jsock->client_socket > -1) {
|
if (jsock->client_socket != ws_sock_invalid) {
|
||||||
close_socket(&jsock->client_socket);
|
close_socket(&jsock->client_socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3655,7 +3655,7 @@ static switch_bool_t verto__broadcast_func(const char *method, cJSON *params, js
|
||||||
jevent = cJSON_Duplicate(params, 1);
|
jevent = cJSON_Duplicate(params, 1);
|
||||||
switch_event_channel_broadcast(event_channel, &jevent, modname, globals.event_channel_id);
|
switch_event_channel_broadcast(event_channel, &jevent, modname, globals.event_channel_id);
|
||||||
|
|
||||||
if (jsock->profile->mcast_pub.sock > -1) {
|
if (jsock->profile->mcast_pub.sock != ws_sock_invalid) {
|
||||||
if ((json_text = cJSON_PrintUnformatted(params))) {
|
if ((json_text = cJSON_PrintUnformatted(params))) {
|
||||||
|
|
||||||
if ( mcast_socket_send(&jsock->profile->mcast_pub, json_text, strlen(json_text) + 1) < 0 ) {
|
if ( mcast_socket_send(&jsock->profile->mcast_pub, json_text, strlen(json_text) + 1) < 0 ) {
|
||||||
|
@ -3894,7 +3894,7 @@ static int start_jsock(verto_profile_t *profile, ws_socket_t sock, int family)
|
||||||
error:
|
error:
|
||||||
|
|
||||||
if (jsock) {
|
if (jsock) {
|
||||||
if (jsock->client_socket > -1) {
|
if (jsock->client_socket != ws_sock_invalid) {
|
||||||
close_socket(&jsock->client_socket);
|
close_socket(&jsock->client_socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3965,7 +3965,13 @@ static ws_socket_t prepare_socket(ips_t *ips)
|
||||||
|
|
||||||
static void handle_mcast_sub(verto_profile_t *profile)
|
static void handle_mcast_sub(verto_profile_t *profile)
|
||||||
{
|
{
|
||||||
int bytes = mcast_socket_recv(&profile->mcast_sub, NULL, 0, 0);
|
int bytes;
|
||||||
|
|
||||||
|
if (profile->mcast_sub.sock == ws_sock_invalid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bytes = mcast_socket_recv(&profile->mcast_sub, NULL, 0, 0);
|
||||||
|
|
||||||
if (bytes > 0) {
|
if (bytes > 0) {
|
||||||
cJSON *json;
|
cJSON *json;
|
||||||
|
@ -4100,27 +4106,36 @@ static int runtime(verto_profile_t *profile)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
int listeners = 0;
|
||||||
|
|
||||||
for (i = 0; i < profile->i; i++) {
|
for (i = 0; i < profile->i; i++) {
|
||||||
//if ((profile->server_socket[i] = prepare_socket(profile->ip[i].local_ip_addr, profile->ip[i].local_port)) < 0) {
|
//if ((profile->server_socket[i] = prepare_socket(profile->ip[i].local_ip_addr, profile->ip[i].local_port)) < 0) {
|
||||||
if ((profile->server_socket[i] = prepare_socket(&profile->ip[i])) < 0) {
|
if ((profile->server_socket[i] = prepare_socket(&profile->ip[i])) != ws_sock_invalid) {
|
||||||
die("Client Socket Error!\n");
|
listeners++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!listeners) {
|
||||||
|
die("Client Socket Error! No Listeners!\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (profile->mcast_ip) {
|
if (profile->mcast_ip) {
|
||||||
|
int ok = 1;
|
||||||
|
|
||||||
if (mcast_socket_create(profile->mcast_ip, profile->mcast_port, &profile->mcast_sub, MCAST_RECV | MCAST_TTL_HOST) < 0) {
|
if (mcast_socket_create(profile->mcast_ip, profile->mcast_port, &profile->mcast_sub, MCAST_RECV | MCAST_TTL_HOST) < 0) {
|
||||||
r = -1;
|
ok++;
|
||||||
die("mcast recv socket create\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mcast_socket_create(profile->mcast_ip, profile->mcast_port + 1, &profile->mcast_pub, MCAST_SEND | MCAST_TTL_HOST) > 0) {
|
if (ok && mcast_socket_create(profile->mcast_ip, profile->mcast_port + 1, &profile->mcast_pub, MCAST_SEND | MCAST_TTL_HOST) > 0) {
|
||||||
mcast_socket_close(&profile->mcast_sub);
|
mcast_socket_close(&profile->mcast_sub);
|
||||||
r = -1;
|
ok = 0;
|
||||||
die("mcast send socket create\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "MCAST Bound to %s:%d/%d\n", profile->mcast_ip, profile->mcast_port, profile->mcast_port + 1);
|
if (ok) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "MCAST Bound to %s:%d/%d\n", profile->mcast_ip, profile->mcast_port, profile->mcast_port + 1);
|
||||||
|
} else {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "MCAST Disabled\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4132,11 +4147,11 @@ static int runtime(verto_profile_t *profile)
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
|
||||||
if (profile->mcast_sub.sock > -1) {
|
if (profile->mcast_sub.sock != ws_sock_invalid) {
|
||||||
mcast_socket_close(&profile->mcast_sub);
|
mcast_socket_close(&profile->mcast_sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile->mcast_pub.sock > -1) {
|
if (profile->mcast_pub.sock != ws_sock_invalid) {
|
||||||
mcast_socket_close(&profile->mcast_pub);
|
mcast_socket_close(&profile->mcast_pub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -864,11 +864,15 @@ SWITCH_DECLARE(const char *) switch_get_addr(char *buf, switch_size_t len, switc
|
||||||
return SWITCH_BLANK_STRING;
|
return SWITCH_BLANK_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(buf, 0, len);
|
||||||
|
|
||||||
if (in->family == AF_INET) {
|
if (in->family == AF_INET) {
|
||||||
return get_addr(buf, len, (struct sockaddr *) &in->sa, in->salen);
|
get_addr(buf, len, (struct sockaddr *) &in->sa, in->salen);
|
||||||
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
return get_addr6(buf, len, (struct sockaddr_in6 *) &in->sa, in->salen);
|
get_addr6(buf, len, (struct sockaddr_in6 *) &in->sa, in->salen);
|
||||||
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(uint16_t) switch_sockaddr_get_port(switch_sockaddr_t *sa)
|
SWITCH_DECLARE(uint16_t) switch_sockaddr_get_port(switch_sockaddr_t *sa)
|
||||||
|
|
|
@ -1420,6 +1420,20 @@ SWITCH_DECLARE(void) switch_load_network_lists(switch_bool_t reload)
|
||||||
switch_core_hash_insert(IP_LIST.hash, tmp_name, rfc_list);
|
switch_core_hash_insert(IP_LIST.hash, tmp_name, rfc_list);
|
||||||
|
|
||||||
|
|
||||||
|
tmp_name = "any_v6.auto";
|
||||||
|
switch_network_list_create(&rfc_list, tmp_name, SWITCH_TRUE, IP_LIST.pool);
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Created ip list %s default (allow)\n", tmp_name);
|
||||||
|
switch_network_list_add_cidr(rfc_list, "0.0.0.0/0", SWITCH_FALSE);
|
||||||
|
switch_core_hash_insert(IP_LIST.hash, tmp_name, rfc_list);
|
||||||
|
|
||||||
|
|
||||||
|
tmp_name = "any_v4.auto";
|
||||||
|
switch_network_list_create(&rfc_list, tmp_name, SWITCH_TRUE, IP_LIST.pool);
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Created ip list %s default (allow)\n", tmp_name);
|
||||||
|
switch_network_list_add_cidr(rfc_list, "::/0", SWITCH_FALSE);
|
||||||
|
switch_core_hash_insert(IP_LIST.hash, tmp_name, rfc_list);
|
||||||
|
|
||||||
|
|
||||||
tmp_name = "nat.auto";
|
tmp_name = "nat.auto";
|
||||||
switch_network_list_create(&rfc_list, tmp_name, SWITCH_FALSE, IP_LIST.pool);
|
switch_network_list_create(&rfc_list, tmp_name, SWITCH_FALSE, IP_LIST.pool);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Created ip list %s default (deny)\n", tmp_name);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Created ip list %s default (deny)\n", tmp_name);
|
||||||
|
|
|
@ -339,6 +339,9 @@ SWITCH_DECLARE(uint32_t) switch_core_media_get_video_fps(switch_core_session_t *
|
||||||
fps = switch_round_to_step(smh->vid_frames / (now - smh->vid_started), 5);
|
fps = switch_round_to_step(smh->vid_frames / (now - smh->vid_started), 5);
|
||||||
if (fps < 15) fps = 15;
|
if (fps < 15) fps = 15;
|
||||||
|
|
||||||
|
smh->vid_started = switch_epoch_time_now(NULL);
|
||||||
|
smh->vid_frames = 1;
|
||||||
|
|
||||||
return fps;
|
return fps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2885,7 +2888,8 @@ static void clear_ice(switch_core_session_t *session, switch_media_type_t type)
|
||||||
engine->ice_in.chosen[1] = 0;
|
engine->ice_in.chosen[1] = 0;
|
||||||
engine->ice_in.is_chosen[0] = 0;
|
engine->ice_in.is_chosen[0] = 0;
|
||||||
engine->ice_in.is_chosen[1] = 0;
|
engine->ice_in.is_chosen[1] = 0;
|
||||||
engine->ice_in.cand_idx = 0;
|
engine->ice_in.cand_idx[0] = 0;
|
||||||
|
engine->ice_in.cand_idx[1] = 0;
|
||||||
memset(&engine->ice_in, 0, sizeof(engine->ice_in));
|
memset(&engine->ice_in, 0, sizeof(engine->ice_in));
|
||||||
engine->remote_rtcp_port = 0;
|
engine->remote_rtcp_port = 0;
|
||||||
|
|
||||||
|
@ -3094,22 +3098,24 @@ static switch_bool_t ip_possible(switch_media_handle_t *smh, const char *ip)
|
||||||
}
|
}
|
||||||
|
|
||||||
//?
|
//?
|
||||||
static void check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_session_t *sdp, sdp_media_t *m)
|
static switch_status_t check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_session_t *sdp, sdp_media_t *m)
|
||||||
{
|
{
|
||||||
switch_rtp_engine_t *engine = &smh->engines[type];
|
switch_rtp_engine_t *engine = &smh->engines[type];
|
||||||
sdp_attribute_t *attr;
|
sdp_attribute_t *attr;
|
||||||
int i = 0, got_rtcp_mux = 0;
|
int i = 0, got_rtcp_mux = 0;
|
||||||
const char *val;
|
const char *val;
|
||||||
|
int ice_seen = 0, cid = 0, ai = 0;
|
||||||
|
|
||||||
if (engine->ice_in.is_chosen[0] && engine->ice_in.is_chosen[1] && !switch_channel_test_flag(smh->session->channel, CF_REINVITE)) {
|
if (engine->ice_in.is_chosen[0] && engine->ice_in.is_chosen[1] && !switch_channel_test_flag(smh->session->channel, CF_REINVITE)) {
|
||||||
return;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
engine->ice_in.chosen[0] = 0;
|
engine->ice_in.chosen[0] = 0;
|
||||||
engine->ice_in.chosen[1] = 0;
|
engine->ice_in.chosen[1] = 0;
|
||||||
engine->ice_in.is_chosen[0] = 0;
|
engine->ice_in.is_chosen[0] = 0;
|
||||||
engine->ice_in.is_chosen[1] = 0;
|
engine->ice_in.is_chosen[1] = 0;
|
||||||
engine->ice_in.cand_idx = 0;
|
engine->ice_in.cand_idx[0] = 0;
|
||||||
|
engine->ice_in.cand_idx[1] = 0;
|
||||||
|
|
||||||
if (m) {
|
if (m) {
|
||||||
attr = m->m_attributes;
|
attr = m->m_attributes;
|
||||||
|
@ -3121,8 +3127,6 @@ static void check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_
|
||||||
char *data;
|
char *data;
|
||||||
char *fields[15];
|
char *fields[15];
|
||||||
int argc = 0, j = 0;
|
int argc = 0, j = 0;
|
||||||
int cid = 0;
|
|
||||||
int pass_acl = 0;
|
|
||||||
|
|
||||||
if (zstr(attr->a_name)) {
|
if (zstr(attr->a_name)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -3130,6 +3134,7 @@ static void check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_
|
||||||
|
|
||||||
if (!strcasecmp(attr->a_name, "ice-ufrag")) {
|
if (!strcasecmp(attr->a_name, "ice-ufrag")) {
|
||||||
engine->ice_in.ufrag = switch_core_session_strdup(smh->session, attr->a_value);
|
engine->ice_in.ufrag = switch_core_session_strdup(smh->session, attr->a_value);
|
||||||
|
ice_seen++;
|
||||||
} else if (!strcasecmp(attr->a_name, "ice-pwd")) {
|
} else if (!strcasecmp(attr->a_name, "ice-pwd")) {
|
||||||
engine->ice_in.pwd = switch_core_session_strdup(smh->session, attr->a_value);
|
engine->ice_in.pwd = switch_core_session_strdup(smh->session, attr->a_value);
|
||||||
} else if (!strcasecmp(attr->a_name, "ice-options")) {
|
} else if (!strcasecmp(attr->a_name, "ice-options")) {
|
||||||
|
@ -3185,169 +3190,105 @@ static void check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_
|
||||||
|
|
||||||
argc = switch_split(data, ' ', fields);
|
argc = switch_split(data, ' ', fields);
|
||||||
|
|
||||||
if (argc < 5 || engine->ice_in.cand_idx >= MAX_CAND - 1) {
|
cid = fields[1] ? atoi(fields[1]) - 1 : 0;
|
||||||
|
|
||||||
|
if (argc < 5 || engine->ice_in.cand_idx[cid] >= MAX_CAND - 1) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_WARNING, "Invalid data\n");
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_WARNING, "Invalid data\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
cid = atoi(fields[1]) - 1;
|
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG1, "CAND %d [%s]\n", i, fields[i]);
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG1, "CAND %d [%s]\n", i, fields[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
|
if (!ip_possible(smh, fields[4])) {
|
||||||
"Checking Candidate cid: %d proto: %s type: %s addr: %s:%s\n", cid+1, fields[2], fields[7], fields[4], fields[5]);
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
|
||||||
|
"Drop %s Candidate cid: %d proto: %s type: %s addr: %s:%s (no network path)\n",
|
||||||
pass_acl = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < engine->cand_acl_count; i++) {
|
|
||||||
if (switch_check_network_list_ip(fields[4], engine->cand_acl[i])) {
|
|
||||||
pass_acl = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!engine->ice_in.is_chosen[cid] && ip_possible(smh, fields[4]) && pass_acl) {
|
|
||||||
engine->ice_in.chosen[cid] = engine->ice_in.cand_idx;
|
|
||||||
engine->ice_in.is_chosen[cid] = 1;
|
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_NOTICE,
|
|
||||||
"Choose %s Candidate cid: %d proto: %s type: %s addr: %s:%s\n",
|
|
||||||
type == SWITCH_MEDIA_TYPE_VIDEO ? "video" : "audio",
|
type == SWITCH_MEDIA_TYPE_VIDEO ? "video" : "audio",
|
||||||
cid+1, fields[2], fields[7], fields[4], fields[5]);
|
cid+1, fields[2], fields[7], fields[4], fields[5]);
|
||||||
ip_choose_family(smh, fields[4]);
|
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_NOTICE,
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
|
||||||
"Save %s Candidate cid: %d proto: %s type: %s addr: %s:%s\n",
|
"Save %s Candidate cid: %d proto: %s type: %s addr: %s:%s\n",
|
||||||
type == SWITCH_MEDIA_TYPE_VIDEO ? "video" : "audio",
|
type == SWITCH_MEDIA_TYPE_VIDEO ? "video" : "audio",
|
||||||
cid+1, fields[2], fields[7], fields[4], fields[5]);
|
cid+1, fields[2], fields[7], fields[4], fields[5]);
|
||||||
}
|
}
|
||||||
|
|
||||||
engine->ice_in.cands[engine->ice_in.cand_idx][cid].foundation = switch_core_session_strdup(smh->session, fields[0]);
|
|
||||||
engine->ice_in.cands[engine->ice_in.cand_idx][cid].component_id = atoi(fields[1]);
|
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].foundation = switch_core_session_strdup(smh->session, fields[0]);
|
||||||
engine->ice_in.cands[engine->ice_in.cand_idx][cid].transport = switch_core_session_strdup(smh->session, fields[2]);
|
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].component_id = atoi(fields[1]);
|
||||||
engine->ice_in.cands[engine->ice_in.cand_idx][cid].priority = atol(fields[3]);
|
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].transport = switch_core_session_strdup(smh->session, fields[2]);
|
||||||
engine->ice_in.cands[engine->ice_in.cand_idx][cid].con_addr = switch_core_session_strdup(smh->session, fields[4]);
|
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].priority = atol(fields[3]);
|
||||||
engine->ice_in.cands[engine->ice_in.cand_idx][cid].con_port = (switch_port_t)atoi(fields[5]);
|
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].con_addr = switch_core_session_strdup(smh->session, fields[4]);
|
||||||
|
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].con_port = (switch_port_t)atoi(fields[5]);
|
||||||
|
|
||||||
j = 6;
|
j = 6;
|
||||||
|
|
||||||
while(j < argc && fields[j+1]) {
|
while(j < argc && fields[j+1]) {
|
||||||
if (!strcasecmp(fields[j], "typ")) {
|
if (!strcasecmp(fields[j], "typ")) {
|
||||||
engine->ice_in.cands[engine->ice_in.cand_idx][cid].cand_type = switch_core_session_strdup(smh->session, fields[j+1]);
|
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].cand_type = switch_core_session_strdup(smh->session, fields[j+1]);
|
||||||
} else if (!strcasecmp(fields[j], "raddr")) {
|
} else if (!strcasecmp(fields[j], "raddr")) {
|
||||||
engine->ice_in.cands[engine->ice_in.cand_idx][cid].raddr = switch_core_session_strdup(smh->session, fields[j+1]);
|
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].raddr = switch_core_session_strdup(smh->session, fields[j+1]);
|
||||||
} else if (!strcasecmp(fields[j], "rport")) {
|
} else if (!strcasecmp(fields[j], "rport")) {
|
||||||
engine->ice_in.cands[engine->ice_in.cand_idx][cid].rport = (switch_port_t)atoi(fields[j+1]);
|
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].rport = (switch_port_t)atoi(fields[j+1]);
|
||||||
} else if (!strcasecmp(fields[j], "generation")) {
|
} else if (!strcasecmp(fields[j], "generation")) {
|
||||||
engine->ice_in.cands[engine->ice_in.cand_idx][cid].generation = switch_core_session_strdup(smh->session, fields[j+1]);
|
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].generation = switch_core_session_strdup(smh->session, fields[j+1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
j += 2;
|
j += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
engine->ice_in.cand_idx[cid]++;
|
||||||
if (engine->ice_in.is_chosen[cid]) {
|
|
||||||
engine->ice_in.cands[engine->ice_in.chosen[cid]][cid].ready++;
|
|
||||||
}
|
|
||||||
|
|
||||||
engine->ice_in.cand_idx++;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* still no candidates, so start searching for some based on sane deduction */
|
|
||||||
|
|
||||||
/* look for candidates on the same network */
|
|
||||||
if (!engine->ice_in.is_chosen[0] || !engine->ice_in.is_chosen[1]) {
|
|
||||||
for (i = 0; i <= engine->ice_in.cand_idx && (!engine->ice_in.is_chosen[0] || !engine->ice_in.is_chosen[1]); i++) {
|
|
||||||
if (!engine->ice_in.is_chosen[0] && engine->ice_in.cands[i][0].component_id == 1 &&
|
|
||||||
!engine->ice_in.cands[i][0].rport && ip_possible(smh, engine->ice_in.cands[i][0].con_addr) &&
|
|
||||||
switch_check_network_list_ip(engine->ice_in.cands[i][0].con_addr, "localnet.auto")) {
|
|
||||||
engine->ice_in.chosen[0] = i;
|
|
||||||
engine->ice_in.is_chosen[0] = 1;
|
|
||||||
engine->ice_in.cands[engine->ice_in.chosen[0]][0].ready++;
|
|
||||||
ip_choose_family(smh, engine->ice_in.cands[i][0].con_addr);
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_NOTICE,
|
|
||||||
"No %s RTP candidate found; defaulting to the first local one.\n", type2str(type));
|
|
||||||
}
|
|
||||||
if (!engine->ice_in.is_chosen[1] && engine->ice_in.cands[i][1].component_id == 2 &&
|
|
||||||
!engine->ice_in.cands[i][1].rport && ip_possible(smh, engine->ice_in.cands[i][1].con_addr) &&
|
|
||||||
switch_check_network_list_ip(engine->ice_in.cands[i][1].con_addr, "localnet.auto")) {
|
|
||||||
engine->ice_in.chosen[1] = i;
|
|
||||||
engine->ice_in.is_chosen[1] = 1;
|
|
||||||
engine->ice_in.cands[engine->ice_in.chosen[1]][1].ready++;
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session),SWITCH_LOG_NOTICE,
|
|
||||||
"No %s RTCP candidate found; defaulting to the first local one.\n", type2str(type));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* look for candidates with srflx */
|
for (cid = 0; cid < 2; cid++) {
|
||||||
if (!engine->ice_in.is_chosen[0] || !engine->ice_in.is_chosen[1]) {
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG, "Searching for %s candidate.\n", cid ? "rtcp" : "rtp");
|
||||||
for (i = 0; i <= engine->ice_in.cand_idx && (!engine->ice_in.is_chosen[0] || !engine->ice_in.is_chosen[1]); i++) {
|
|
||||||
if (!engine->ice_in.is_chosen[0] &&
|
for (ai = 0; ai < engine->cand_acl_count; ai++) {
|
||||||
engine->ice_in.cands[i][0].component_id == 1 && engine->ice_in.cands[i][0].rport && ip_possible(smh, engine->ice_in.cands[i][0].con_addr)) {
|
for (i = 0; i < engine->ice_in.cand_idx[cid]; i++) {
|
||||||
engine->ice_in.chosen[0] = i;
|
if (switch_check_network_list_ip(engine->ice_in.cands[i][cid].con_addr, engine->cand_acl[ai])) {
|
||||||
engine->ice_in.chosen[1] = 1;
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
|
||||||
engine->ice_in.cands[engine->ice_in.chosen[0]][0].ready++;
|
"Choose %s candidate, index %d, %s:%d\n", cid ? "rtcp" : "rtp", i,
|
||||||
ip_choose_family(smh, engine->ice_in.cands[i][0].con_addr);
|
engine->ice_in.cands[i][cid].con_addr, engine->ice_in.cands[i][cid].con_port);
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_NOTICE,
|
|
||||||
"No %s RTP candidate found; defaulting to the first srflx one.\n", type2str(type));
|
engine->ice_in.chosen[cid] = i;
|
||||||
}
|
engine->ice_in.is_chosen[cid] = 1;
|
||||||
if (!engine->ice_in.is_chosen[1] && engine->ice_in.cands[i][1].component_id == 2 && engine->ice_in.cands[i][1].rport &&
|
engine->ice_in.cands[i][cid].ready++;
|
||||||
ip_possible(smh, engine->ice_in.cands[i][1].con_addr)) {
|
ip_choose_family(smh, engine->ice_in.cands[i][cid].con_addr);
|
||||||
engine->ice_in.chosen[1] = i;
|
|
||||||
engine->ice_in.is_chosen[1] = 1;
|
if (cid == 0 && got_rtcp_mux && engine->ice_in.cand_idx[1] < MAX_CAND) {
|
||||||
engine->ice_in.cands[engine->ice_in.chosen[1]][1].ready++;
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session),SWITCH_LOG_NOTICE,
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
|
||||||
"No %s RTCP candidate found; defaulting to the first srflx one.\n", type2str(type));
|
"Choose same candidate, index %d, for rtcp based on rtcp-mux attribute %s:%d\n", engine->ice_in.cand_idx[1],
|
||||||
|
engine->ice_in.cands[i][cid].con_addr, engine->ice_in.cands[i][cid].con_port);
|
||||||
|
|
||||||
|
|
||||||
|
engine->ice_in.cands[engine->ice_in.cand_idx[1]][1] = engine->ice_in.cands[i][0];
|
||||||
|
engine->ice_in.chosen[1] = engine->ice_in.cand_idx[1];
|
||||||
|
engine->ice_in.is_chosen[1] = 1;
|
||||||
|
engine->ice_in.cand_idx[1]++;
|
||||||
|
|
||||||
|
goto done_choosing;
|
||||||
|
}
|
||||||
|
|
||||||
|
goto next_cid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
next_cid:
|
||||||
|
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Got RTP but not RTCP, probably mux */
|
done_choosing:
|
||||||
if (engine->ice_in.is_chosen[0] && !engine->ice_in.is_chosen[1] && got_rtcp_mux) {
|
|
||||||
engine->ice_in.chosen[1] = engine->ice_in.chosen[0];
|
|
||||||
engine->ice_in.is_chosen[1] = 1;
|
|
||||||
|
|
||||||
memcpy(&engine->ice_in.cands[engine->ice_in.chosen[1]][1], &engine->ice_in.cands[engine->ice_in.chosen[0]][0],
|
|
||||||
sizeof(engine->ice_in.cands[engine->ice_in.chosen[0]][0]));
|
|
||||||
engine->ice_in.cands[engine->ice_in.chosen[1]][1].ready++;
|
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_NOTICE,
|
|
||||||
"No %s RTCP candidate found; defaulting to the same as RTP [%s:%d]\n", type2str(type),
|
|
||||||
engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_addr, engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* look for any candidates and hope for auto-adjust */
|
|
||||||
if (!engine->ice_in.is_chosen[0] || !engine->ice_in.is_chosen[1]) {
|
|
||||||
for (i = 0; i <= engine->ice_in.cand_idx && (!engine->ice_in.is_chosen[0] || !engine->ice_in.is_chosen[1]); i++) {
|
|
||||||
if (!engine->ice_in.is_chosen[0] && engine->ice_in.cands[i][0].component_id == 1 && ip_possible(smh, engine->ice_in.cands[i][0].con_addr)) {
|
|
||||||
engine->ice_in.chosen[0] = i;
|
|
||||||
engine->ice_in.is_chosen[0] = 1;
|
|
||||||
engine->ice_in.cands[engine->ice_in.chosen[0]][0].ready++;
|
|
||||||
ip_choose_family(smh, engine->ice_in.cands[i][0].con_addr);
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_NOTICE,
|
|
||||||
"No %s RTP candidate found; defaulting to the first one.\n", type2str(type));
|
|
||||||
}
|
|
||||||
if (!engine->ice_in.is_chosen[1] && engine->ice_in.cands[i][1].component_id == 2) {
|
|
||||||
engine->ice_in.chosen[1] = i;
|
|
||||||
engine->ice_in.is_chosen[1] = 1;
|
|
||||||
engine->ice_in.cands[engine->ice_in.chosen[1]][1].ready++;
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_NOTICE,
|
|
||||||
"No %s RTCP candidate found; defaulting to the first one.\n", type2str(type));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!engine->ice_in.is_chosen[0] || !engine->ice_in.is_chosen[1]) {
|
if (!engine->ice_in.is_chosen[0] || !engine->ice_in.is_chosen[1]) {
|
||||||
/* PUNT */
|
/* PUNT */
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG, "%s no suitable candidates found.\n",
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG, "%s no suitable candidates found.\n",
|
||||||
switch_channel_get_name(smh->session->channel));
|
switch_channel_get_name(smh->session->channel));
|
||||||
return;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
|
@ -3362,8 +3303,8 @@ static void check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_
|
||||||
if (engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr && engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port) {
|
if (engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr && engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port) {
|
||||||
char tmp[80] = "";
|
char tmp[80] = "";
|
||||||
engine->cur_payload_map->remote_sdp_ip = switch_core_session_strdup(smh->session, (char *) engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr);
|
engine->cur_payload_map->remote_sdp_ip = switch_core_session_strdup(smh->session, (char *) engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr);
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_NOTICE,
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
|
||||||
"setting remote %s ice addr to %s:%d based on candidate\n", type2str(type),
|
"setting remote %s ice addr to index %d %s:%d based on candidate\n", type2str(type), engine->ice_in.chosen[0],
|
||||||
engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr, engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port);
|
engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr, engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port);
|
||||||
engine->ice_in.cands[engine->ice_in.chosen[0]][0].ready++;
|
engine->ice_in.cands[engine->ice_in.chosen[0]][0].ready++;
|
||||||
|
|
||||||
|
@ -3377,31 +3318,19 @@ static void check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_
|
||||||
smh->mparams->remote_ip = engine->cur_payload_map->remote_sdp_ip;
|
smh->mparams->remote_ip = engine->cur_payload_map->remote_sdp_ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (engine->remote_rtcp_port) {
|
switch_snprintf(tmp, sizeof(tmp), "%d", engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port);
|
||||||
engine->remote_rtcp_port = engine->cur_payload_map->remote_sdp_port;
|
switch_channel_set_variable(smh->session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr);
|
||||||
}
|
|
||||||
|
|
||||||
switch_snprintf(tmp, sizeof(tmp), "%d", engine->cur_payload_map->remote_sdp_port);
|
|
||||||
switch_channel_set_variable(smh->session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, engine->cur_payload_map->remote_sdp_ip);
|
|
||||||
switch_channel_set_variable(smh->session->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp);
|
switch_channel_set_variable(smh->session->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port) {
|
if (engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port) {
|
||||||
if (engine->rtcp_mux) {
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
|
||||||
engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port = engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port;
|
"Setting remote rtcp %s addr to %s:%d based on candidate\n", type2str(type),
|
||||||
engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_addr = engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr;
|
engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_addr, engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port);
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_NOTICE,
|
engine->remote_rtcp_ice_port = engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port;
|
||||||
"Asked by candidate to set remote rtcp %s addr to %s:%d but this is rtcp-mux so no thanks\n", type2str(type),
|
engine->remote_rtcp_ice_addr = switch_core_session_strdup(smh->session, engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_addr);
|
||||||
engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_addr, engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port);
|
|
||||||
} else {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_NOTICE,
|
|
||||||
"Setting remote rtcp %s addr to %s:%d based on candidate\n", type2str(type),
|
|
||||||
engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_addr, engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port);
|
|
||||||
engine->remote_rtcp_ice_port = engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port;
|
|
||||||
engine->remote_rtcp_ice_addr = switch_core_session_strdup(smh->session, engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_addr);
|
|
||||||
|
|
||||||
engine->remote_rtcp_port = engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port;
|
engine->remote_rtcp_port = engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3489,6 +3418,9 @@ static void check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return ice_seen ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_BREAK;
|
||||||
}
|
}
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
@ -4358,8 +4290,11 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_core_media_set_codec(session, 0, smh->mparams->codec_flags) == SWITCH_STATUS_SUCCESS) {
|
if (switch_core_media_set_codec(session, 0, smh->mparams->codec_flags) == SWITCH_STATUS_SUCCESS) {
|
||||||
got_audio = 1;
|
if (check_ice(smh, SWITCH_MEDIA_TYPE_AUDIO, sdp, m) == SWITCH_STATUS_FALSE) {
|
||||||
check_ice(smh, SWITCH_MEDIA_TYPE_AUDIO, sdp, m);
|
match = 0;
|
||||||
|
} else {
|
||||||
|
got_audio = 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
match = 0;
|
match = 0;
|
||||||
}
|
}
|
||||||
|
@ -4632,7 +4567,9 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_core_media_set_video_codec(session, 0) == SWITCH_STATUS_SUCCESS) {
|
if (switch_core_media_set_video_codec(session, 0) == SWITCH_STATUS_SUCCESS) {
|
||||||
check_ice(smh, SWITCH_MEDIA_TYPE_VIDEO, sdp, m);
|
if (check_ice(smh, SWITCH_MEDIA_TYPE_VIDEO, sdp, m) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
vmatch = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5067,7 +5004,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_start_video_thread(switch_co
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "%s Starting Video thread\n", switch_core_session_get_name(session));
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Starting Video thread\n", switch_core_session_get_name(session));
|
||||||
|
|
||||||
if (v_engine->rtp_session) {
|
if (v_engine->rtp_session) {
|
||||||
switch_rtp_set_default_payload(v_engine->rtp_session, v_engine->cur_payload_map->agreed_pt);
|
switch_rtp_set_default_payload(v_engine->rtp_session, v_engine->cur_payload_map->agreed_pt);
|
||||||
|
|
|
@ -1038,7 +1038,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
|
||||||
if (!icep[j] || !icep[j]->ice_params) {
|
if (!icep[j] || !icep[j]->ice_params) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (i = 0; i < icep[j]->ice_params->cand_idx; i++) {
|
for (i = 0; i < icep[j]->ice_params->cand_idx[icep[j]->proto]; i++) {
|
||||||
if (icep[j]->ice_params && icep[j]->ice_params->cands[i][icep[j]->proto].priority == *pri) {
|
if (icep[j]->ice_params && icep[j]->ice_params->cands[i][icep[j]->proto].priority == *pri) {
|
||||||
if (j == IPR_RTP) {
|
if (j == IPR_RTP) {
|
||||||
icep[j]->ice_params->chosen[j] = i;
|
icep[j]->ice_params->chosen[j] = i;
|
||||||
|
@ -1191,7 +1191,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i <= ice->ice_params->cand_idx; i++) {
|
for (i = 0; i <= ice->ice_params->cand_idx[ice->proto]; i++) {
|
||||||
if (ice->ice_params->cands[i][ice->proto].con_port == port) {
|
if (ice->ice_params->cands[i][ice->proto].con_port == port) {
|
||||||
if (!strcmp(ice->ice_params->cands[i][ice->proto].con_addr, host) &&
|
if (!strcmp(ice->ice_params->cands[i][ice->proto].con_addr, host) &&
|
||||||
!strcmp(ice->ice_params->cands[i][ice->proto].cand_type, "relay")) {
|
!strcmp(ice->ice_params->cands[i][ice->proto].cand_type, "relay")) {
|
||||||
|
@ -2404,7 +2404,7 @@ static switch_status_t enable_remote_rtcp_socket(switch_rtp_t *rtp_session, cons
|
||||||
host = switch_get_addr(bufa, sizeof(bufa), rtp_session->rtcp_remote_addr);
|
host = switch_get_addr(bufa, sizeof(bufa), rtp_session->rtcp_remote_addr);
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG,
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG,
|
||||||
"Setting RTCP remote addr to %s:%d\n", host, rtp_session->remote_rtcp_port);
|
"Setting RTCP remote addr to %s:%d %d\n", host, rtp_session->remote_rtcp_port, rtp_session->rtcp_remote_addr->family);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rtp_session->rtcp_sock_input && switch_sockaddr_get_family(rtp_session->rtcp_remote_addr) ==
|
if (rtp_session->rtcp_sock_input && switch_sockaddr_get_family(rtp_session->rtcp_remote_addr) ==
|
||||||
|
@ -2846,25 +2846,26 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP] && !rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) {
|
if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP]) {
|
||||||
if (remote_rtcp_port) {
|
if (rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) {
|
||||||
rtp_session->remote_rtcp_port = remote_rtcp_port;
|
rtp_session->rtcp_remote_addr = rtp_session->remote_addr;
|
||||||
|
rtp_session->rtcp_sock_output = rtp_session->sock_output;
|
||||||
} else {
|
} else {
|
||||||
rtp_session->remote_rtcp_port = rtp_session->eff_remote_port + 1;
|
if (remote_rtcp_port) {
|
||||||
}
|
rtp_session->remote_rtcp_port = remote_rtcp_port;
|
||||||
status = enable_remote_rtcp_socket(rtp_session, err);
|
} else {
|
||||||
|
rtp_session->remote_rtcp_port = rtp_session->eff_remote_port + 1;
|
||||||
|
}
|
||||||
|
status = enable_remote_rtcp_socket(rtp_session, err);
|
||||||
|
|
||||||
if (rtp_session->rtcp_dtls) {
|
if (rtp_session->rtcp_dtls) {
|
||||||
//switch_sockaddr_info_get(&rtp_session->rtcp_dtls->remote_addr, host, SWITCH_UNSPEC, port, 0, rtp_session->pool);
|
//switch_sockaddr_info_get(&rtp_session->rtcp_dtls->remote_addr, host, SWITCH_UNSPEC, port, 0, rtp_session->pool);
|
||||||
rtp_session->rtcp_dtls->remote_addr = rtp_session->rtcp_remote_addr;
|
rtp_session->rtcp_dtls->remote_addr = rtp_session->rtcp_remote_addr;
|
||||||
rtp_session->rtcp_dtls->sock_output = rtp_session->rtcp_sock_output;
|
rtp_session->rtcp_dtls->sock_output = rtp_session->rtcp_sock_output;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP] && rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) {
|
|
||||||
rtp_session->rtcp_remote_addr = rtp_session->remote_addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch_mutex_unlock(rtp_session->write_mutex);
|
switch_mutex_unlock(rtp_session->write_mutex);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
@ -4113,7 +4114,9 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_rtcp(switch_rtp_t *rtp_sessi
|
||||||
|
|
||||||
rtp_session->rtcp_recv_msg_p = (rtcp_msg_t *) &rtp_session->recv_msg;
|
rtp_session->rtcp_recv_msg_p = (rtcp_msg_t *) &rtp_session->recv_msg;
|
||||||
|
|
||||||
return enable_remote_rtcp_socket(rtp_session, &err);
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
|
//return enable_remote_rtcp_socket(rtp_session, &err);
|
||||||
} else {
|
} else {
|
||||||
rtp_session->rtcp_recv_msg_p = (rtcp_msg_t *) &rtp_session->rtcp_recv_msg;
|
rtp_session->rtcp_recv_msg_p = (rtcp_msg_t *) &rtp_session->rtcp_recv_msg;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue