提交 fa33b302 authored 作者: Anthony Minessale's avatar Anthony Minessale 提交者: Mike Jerris

FS-10088: [freeswitch-core] Backports #resolve

上级 70f4c411
...@@ -231,8 +231,8 @@ SWITCH_BEGIN_EXTERN_C ...@@ -231,8 +231,8 @@ SWITCH_BEGIN_EXTERN_C
#define SWITCH_MAX_TRANS 2000 #define SWITCH_MAX_TRANS 2000
#define SWITCH_CORE_SESSION_MAX_PRIVATES 2 #define SWITCH_CORE_SESSION_MAX_PRIVATES 2
#define SWITCH_DEFAULT_VIDEO_SIZE 1200 #define SWITCH_DEFAULT_VIDEO_SIZE 1200
#define SWITCH_RTCP_AUDIO_INTERVAL_MSEC "5000" #define SWITCH_RTCP_AUDIO_INTERVAL_MSEC "1000"
#define SWITCH_RTCP_VIDEO_INTERVAL_MSEC "2000" #define SWITCH_RTCP_VIDEO_INTERVAL_MSEC "1000"
#define MAX_FMTP_LEN 256 #define MAX_FMTP_LEN 256
...@@ -773,6 +773,7 @@ typedef enum { ...@@ -773,6 +773,7 @@ typedef enum {
SWITCH_RTP_FLAG_GEN_TS_DELTA, SWITCH_RTP_FLAG_GEN_TS_DELTA,
SWITCH_RTP_FLAG_GEN_TS_MANUAL, SWITCH_RTP_FLAG_GEN_TS_MANUAL,
SWITCH_RTP_FLAG_DETECT_SSRC, SWITCH_RTP_FLAG_DETECT_SSRC,
SWITCH_RTP_FLAG_OLD_FIR,
SWITCH_RTP_FLAG_INVALID SWITCH_RTP_FLAG_INVALID
} switch_rtp_flag_t; } switch_rtp_flag_t;
......
...@@ -3554,6 +3554,8 @@ static switch_status_t check_ice(switch_media_handle_t *smh, switch_media_type_t ...@@ -3554,6 +3554,8 @@ static switch_status_t check_ice(switch_media_handle_t *smh, switch_media_type_t
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] = "";
const char *media_varname = NULL, *port_varname = NULL;
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_DEBUG, switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
"setting remote %s ice addr to index %d %s:%d based on candidate\n", type2str(type), engine->ice_in.chosen[0], "setting remote %s ice addr to index %d %s:%d based on candidate\n", type2str(type), engine->ice_in.chosen[0],
...@@ -3570,12 +3572,23 @@ static switch_status_t check_ice(switch_media_handle_t *smh, switch_media_type_t ...@@ -3570,12 +3572,23 @@ static switch_status_t check_ice(switch_media_handle_t *smh, switch_media_type_t
smh->mparams->remote_ip = engine->cur_payload_map->remote_sdp_ip; smh->mparams->remote_ip = engine->cur_payload_map->remote_sdp_ip;
} }
if (engine->type == SWITCH_MEDIA_TYPE_VIDEO) {
media_varname = "remote_video_rtp_ip";
port_varname = "remote_video_rtp_port";
} else if (engine->type == SWITCH_MEDIA_TYPE_AUDIO) {
media_varname = "remote_audio_rtp_ip";
port_varname = "remote_audio_rtp_port";
}
switch_snprintf(tmp, sizeof(tmp), "%d", engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port); switch_snprintf(tmp, sizeof(tmp), "%d", engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_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_channel_set_variable(smh->session->channel, media_varname, engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr);
switch_channel_set_variable(smh->session->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp); switch_channel_set_variable(smh->session->channel, port_varname, 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) {
char tmp[80] = "";
const char *media_varname = NULL, *port_varname = NULL;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG, switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
"Setting remote rtcp %s addr to %s:%d based on candidate\n", type2str(type), "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->ice_in.cands[engine->ice_in.chosen[1]][1].con_addr, engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port);
...@@ -3583,6 +3596,20 @@ static switch_status_t check_ice(switch_media_handle_t *smh, switch_media_type_t ...@@ -3583,6 +3596,20 @@ static switch_status_t check_ice(switch_media_handle_t *smh, switch_media_type_t
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_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;
if (engine->type == SWITCH_MEDIA_TYPE_VIDEO) {
media_varname = "remote_video_rtcp_ip";
port_varname = "remote_video_rtcp_port";
} else if (engine->type == SWITCH_MEDIA_TYPE_AUDIO) {
media_varname = "remote_audio_rtcp_ip";
port_varname = "remote_audio_rtcp_port";
}
switch_snprintf(tmp, sizeof(tmp), "%d", engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port);
switch_channel_set_variable(smh->session->channel, media_varname, engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_addr);
switch_channel_set_variable(smh->session->channel, port_varname, tmp);
} }
...@@ -5094,6 +5121,32 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s ...@@ -5094,6 +5121,32 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
t38_done: t38_done:
if (v_engine->rtp_session) {
if (v_engine->fir) {
switch_rtp_set_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_FIR);
} else {
switch_rtp_clear_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_FIR);
}
if (v_engine->pli) {
switch_rtp_set_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PLI);
} else {
switch_rtp_clear_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PLI);
}
if (v_engine->nack) {
switch_rtp_set_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_NACK);
} else {
switch_rtp_clear_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_NACK);
}
if (v_engine->tmmbr) {
switch_rtp_set_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_TMMBR);
} else {
switch_rtp_clear_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_TMMBR);
}
}
if (parser) { if (parser) {
sdp_parser_free(parser); sdp_parser_free(parser);
} }
......
...@@ -101,6 +101,8 @@ struct switch_jb_s { ...@@ -101,6 +101,8 @@ struct switch_jb_s {
switch_jb_type_t type; switch_jb_type_t type;
switch_core_session_t *session; switch_core_session_t *session;
switch_channel_t *channel; switch_channel_t *channel;
uint32_t buffer_lag;
uint32_t flush;
}; };
...@@ -600,7 +602,7 @@ static inline void add_node(switch_jb_t *jb, switch_rtp_packet_t *packet, switch ...@@ -600,7 +602,7 @@ static inline void add_node(switch_jb_t *jb, switch_rtp_packet_t *packet, switch
ts_diff = abs((int)((int64_t)ntohl(node->packet.header.ts) - (int64_t)ntohl(jb->highest_wrote_ts))); ts_diff = abs((int)((int64_t)ntohl(node->packet.header.ts) - (int64_t)ntohl(jb->highest_wrote_ts)));
} }
if (((seq_diff >= jb->max_frame_len) || (ts_diff > (900000 * 5)))) { if (((seq_diff >= 100) || (ts_diff > (900000 * 5)))) {
jb_debug(jb, 2, "CHANGE DETECTED, PUNT %u\n", abs(((int)ntohs(packet->header.seq) - ntohs(jb->highest_wrote_seq)))); jb_debug(jb, 2, "CHANGE DETECTED, PUNT %u\n", abs(((int)ntohs(packet->header.seq) - ntohs(jb->highest_wrote_seq))));
switch_jb_reset(jb); switch_jb_reset(jb);
} }
...@@ -622,7 +624,7 @@ static inline void add_node(switch_jb_t *jb, switch_rtp_packet_t *packet, switch ...@@ -622,7 +624,7 @@ static inline void add_node(switch_jb_t *jb, switch_rtp_packet_t *packet, switch
jb->highest_wrote_ts = packet->header.ts; jb->highest_wrote_ts = packet->header.ts;
} }
} else { } else {
if (jb->write_init) { if (jb->write_init || jb->type == SJB_AUDIO) {
jb_debug(jb, 2, "WRITE frame ts: %u complete=%u/%u n:%u\n", ntohl(node->packet.header.ts), jb->complete_frames , jb->frame_len, jb->visible_nodes); jb_debug(jb, 2, "WRITE frame ts: %u complete=%u/%u n:%u\n", ntohl(node->packet.header.ts), jb->complete_frames , jb->frame_len, jb->visible_nodes);
jb->complete_frames++; jb->complete_frames++;
} else { } else {
...@@ -830,7 +832,7 @@ SWITCH_DECLARE(void) switch_jb_clear_flag(switch_jb_t *jb, switch_jb_flag_t flag ...@@ -830,7 +832,7 @@ SWITCH_DECLARE(void) switch_jb_clear_flag(switch_jb_t *jb, switch_jb_flag_t flag
SWITCH_DECLARE(int) switch_jb_poll(switch_jb_t *jb) SWITCH_DECLARE(int) switch_jb_poll(switch_jb_t *jb)
{ {
return (jb->complete_frames >= jb->frame_len); return (jb->complete_frames >= jb->frame_len) || jb->flush;
} }
SWITCH_DECLARE(int) switch_jb_frame_count(switch_jb_t *jb) SWITCH_DECLARE(int) switch_jb_frame_count(switch_jb_t *jb)
...@@ -1203,13 +1205,19 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp ...@@ -1203,13 +1205,19 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp
switch_mutex_lock(jb->mutex); switch_mutex_lock(jb->mutex);
if (jb->complete_frames == 0) { if (jb->complete_frames == 0) {
jb->flush = 0;
switch_goto_status(SWITCH_STATUS_BREAK, end); switch_goto_status(SWITCH_STATUS_BREAK, end);
} }
if (jb->complete_frames < jb->frame_len) { if (jb->complete_frames < jb->frame_len) {
switch_jb_poll(jb);
if (!jb->flush) {
jb_debug(jb, 2, "BUFFERING %u/%u\n", jb->complete_frames , jb->frame_len); jb_debug(jb, 2, "BUFFERING %u/%u\n", jb->complete_frames , jb->frame_len);
switch_goto_status(SWITCH_STATUS_MORE_DATA, end); switch_goto_status(SWITCH_STATUS_MORE_DATA, end);
} }
}
jb_debug(jb, 2, "GET PACKET %u/%u n:%d\n", jb->complete_frames , jb->frame_len, jb->visible_nodes); jb_debug(jb, 2, "GET PACKET %u/%u n:%d\n", jb->complete_frames , jb->frame_len, jb->visible_nodes);
...@@ -1254,9 +1262,9 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp ...@@ -1254,9 +1262,9 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp
} }
} }
} }
} }
jb->period_miss_pct = ((double)jb->period_miss_count / jb->period_count) * 100; jb->period_miss_pct = ((double)jb->period_miss_count / jb->period_count) * 100;
if (jb->period_miss_pct > 60.0f) { if (jb->period_miss_pct > 60.0f) {
...@@ -1272,7 +1280,8 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp ...@@ -1272,7 +1280,8 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp
jb->highest_read_seq = node->packet.header.seq; jb->highest_read_seq = node->packet.header.seq;
} }
if (jb->read_init && htons(node->packet.header.seq) >= htons(jb->highest_read_seq) && (ntohl(node->packet.header.ts) > ntohl(jb->highest_read_ts))) { if (jb->type == SJB_AUDIO ||
(jb->read_init && htons(node->packet.header.seq) >= htons(jb->highest_read_seq) && (ntohl(node->packet.header.ts) > ntohl(jb->highest_read_ts)))) {
jb->complete_frames--; jb->complete_frames--;
jb_debug(jb, 2, "READ frame ts: %u complete=%u/%u n:%u\n", ntohl(node->packet.header.ts), jb->complete_frames , jb->frame_len, jb->visible_nodes); jb_debug(jb, 2, "READ frame ts: %u complete=%u/%u n:%u\n", ntohl(node->packet.header.ts), jb->complete_frames , jb->frame_len, jb->visible_nodes);
jb->highest_read_ts = node->packet.header.ts; jb->highest_read_ts = node->packet.header.ts;
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论