mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-06-18 14:55:58 +00:00
[Core] Fix ICE and media delay.
This commit is contained in:
parent
c7a2e40b0c
commit
945ad43346
@ -266,6 +266,7 @@ typedef struct {
|
|||||||
uint8_t sending;
|
uint8_t sending;
|
||||||
uint8_t ready;
|
uint8_t ready;
|
||||||
uint8_t rready;
|
uint8_t rready;
|
||||||
|
uint8_t init;
|
||||||
int missed_count;
|
int missed_count;
|
||||||
char last_sent_id[13];
|
char last_sent_id[13];
|
||||||
switch_time_t last_ok;
|
switch_time_t last_ok;
|
||||||
@ -965,7 +966,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
|
|||||||
rtp_session->first_stun = rtp_session->last_stun;
|
rtp_session->first_stun = rtp_session->last_stun;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ice->last_ok) {
|
if (ice->last_ok && (!rtp_session->dtls || rtp_session->dtls->state == DS_READY)) {
|
||||||
ref_point = ice->last_ok;
|
ref_point = ice->last_ok;
|
||||||
} else {
|
} else {
|
||||||
ref_point = rtp_session->first_stun;
|
ref_point = rtp_session->first_stun;
|
||||||
@ -1256,19 +1257,29 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
|
|||||||
port2 = switch_sockaddr_get_port(ice->addr);
|
port2 = switch_sockaddr_get_port(ice->addr);
|
||||||
cmp = switch_cmp_addr(from_addr, ice->addr, SWITCH_FALSE);
|
cmp = switch_cmp_addr(from_addr, ice->addr, SWITCH_FALSE);
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG4,
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG2,
|
||||||
"STUN from %s:%d %s\n", host, port, cmp ? "EXPECTED" : "IGNORED");
|
"STUN from %s:%d %s\n", host, port, cmp ? "EXPECTED" : "IGNORED");
|
||||||
|
|
||||||
|
if (ice->init && !cmp && switch_cmp_addr(from_addr, ice->addr, SWITCH_TRUE)) {
|
||||||
|
do_adj++;
|
||||||
|
rtp_session->ice_adj++;
|
||||||
|
rtp_session->wrong_addrs = 0;
|
||||||
|
ice->init = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (cmp) {
|
if (cmp) {
|
||||||
ice->last_ok = now;
|
ice->last_ok = now;
|
||||||
rtp_session->wrong_addrs = 0;
|
rtp_session->wrong_addrs = 0;
|
||||||
} else {
|
} else {
|
||||||
if (((rtp_session->dtls && rtp_session->dtls->state != DS_READY) || !ice->ready || !ice->rready) &&
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG10, "ICE %d dt:%d i:%d i2:%d w:%d cmp:%d adj:%d\n", elapsed, (rtp_session->dtls && rtp_session->dtls->state != DS_READY), !ice->ready, !ice->rready, rtp_session->wrong_addrs, switch_cmp_addr(from_addr, ice->addr, SWITCH_TRUE), rtp_session->ice_adj);
|
||||||
(rtp_session->wrong_addrs > 2 || switch_cmp_addr(from_addr, ice->addr, SWITCH_TRUE)) && rtp_session->ice_adj == 0) {
|
|
||||||
|
if ((rtp_session->dtls && rtp_session->dtls->state != DS_READY) ||
|
||||||
|
((!ice->ready || !ice->rready) && (rtp_session->wrong_addrs > 2 || switch_cmp_addr(from_addr, ice->addr, SWITCH_TRUE)) &&
|
||||||
|
rtp_session->ice_adj < 10)) {
|
||||||
do_adj++;
|
do_adj++;
|
||||||
rtp_session->ice_adj = 1;
|
rtp_session->ice_adj++;
|
||||||
rtp_session->wrong_addrs = 0;
|
rtp_session->wrong_addrs = 0;
|
||||||
} else if (rtp_session->wrong_addrs > 10 || elapsed >= 10000) {
|
} else if (rtp_session->wrong_addrs > 10 || elapsed >= 5000) {
|
||||||
do_adj++;
|
do_adj++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5040,6 +5051,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_sessio
|
|||||||
ice->pass = "";
|
ice->pass = "";
|
||||||
ice->rpass = "";
|
ice->rpass = "";
|
||||||
ice->next_run = switch_micro_time_now();
|
ice->next_run = switch_micro_time_now();
|
||||||
|
ice->init = 1;
|
||||||
|
|
||||||
if (password) {
|
if (password) {
|
||||||
ice->pass = switch_core_strdup(rtp_session->pool, password);
|
ice->pass = switch_core_strdup(rtp_session->pool, password);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user