diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 9251f88748..53bee92881 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -48,7 +48,7 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess #define MAX_CODEC_CHECK_FRAMES 50//x:mod_sofia.h #define MAX_MISMATCH_FRAMES 5//x:mod_sofia.h #define type2str(type) type == SWITCH_MEDIA_TYPE_VIDEO ? "video" : "audio" -#define VIDEO_REFRESH_FREQ 250000 +#define VIDEO_REFRESH_FREQ 1000000 typedef enum { SMF_INIT = (1 << 0), @@ -8107,10 +8107,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se case SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ: { if (v_engine->rtp_session) { - if (switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_FIR)) { - switch_rtp_video_refresh(v_engine->rtp_session); - } else if (switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PLI)) { + if (switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PLI)) { switch_rtp_video_loss(v_engine->rtp_session); + } else if (switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_FIR)) { + switch_rtp_video_refresh(v_engine->rtp_session); } } } @@ -9950,7 +9950,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core } if (switch_channel_test_flag(session->channel, CF_VIDEO_DECODED_READ)) { - switch_status_t decode_status = switch_core_codec_decode_video((*frame)->codec, *frame); + switch_status_t decode_status; + + (*frame)->img = NULL; + + decode_status = switch_core_codec_decode_video((*frame)->codec, *frame); if ((*frame)->img && switch_channel_test_flag(session->channel, CF_VIDEO_DEBUG_READ)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "IMAGE %dx%d %dx%d\n", @@ -9962,7 +9966,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core switch_clear_flag((*frame), SFF_WAIT_KEY_FRAME); } - if (decode_status == SWITCH_STATUS_MORE_DATA) { + if (decode_status == SWITCH_STATUS_MORE_DATA || !(*frame)->img) { goto top; } } diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 71abc43b35..771a6bed46 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -1919,7 +1919,7 @@ static int check_rtcp_and_ice(switch_rtp_t *rtp_session) ext_hdr->length = htons((uint8_t)(sizeof(switch_rtcp_ext_hdr_t) / 4) - 1); rtcp_bytes += sizeof(switch_rtcp_ext_hdr_t); - rtp_session->pli_count = 0; + rtp_session->pli_count--; } if (rtp_session->flags[SWITCH_RTP_FLAG_NACK] && rtp_session->cur_nack) { @@ -1963,17 +1963,19 @@ static int check_rtcp_and_ice(switch_rtp_t *rtp_session) ext_hdr->pt = 206; ext_hdr->send_ssrc = htonl(rtp_session->ssrc); - ext_hdr->recv_ssrc = htonl(rtp_session->remote_ssrc); + ext_hdr->recv_ssrc = 0; fir->ssrc = htonl(rtp_session->remote_ssrc); - fir->seq = ++rtp_session->fir_seq; + fir->seq = rtp_session->fir_seq; fir->r1 = fir->r2 = fir->r3 = 0; - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG, "Sending RTCP FIR SEQ %d\n\n", rtp_session->fir_seq - 1); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG, "Sending RTCP FIR SEQ %d\n", rtp_session->fir_seq); + + rtp_session->fir_seq++; ext_hdr->length = htons((uint8_t)((sizeof(switch_rtcp_ext_hdr_t) + sizeof(rtcp_fir_t)) / 4) - 1); rtcp_bytes += sizeof(switch_rtcp_ext_hdr_t) + sizeof(rtcp_fir_t); - rtp_session->fir_count = 0; + rtp_session->fir_count--; } } @@ -3520,7 +3522,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG, "Starting video timer.\n"); } - switch_vb_create(&rtp_session->vb, 5, 30); + switch_vb_create(&rtp_session->vb, 5, 30, rtp_session->pool); //switch_vb_debug_level(rtp_session->vb, 10); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG, "Starting video buffer.\n"); @@ -3822,6 +3824,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_debug_jitter_buffer(switch_rtp_t *rtp if (x < 0) x = 0; switch_vb_debug_level(rtp_session->vb, x); + } return SWITCH_STATUS_SUCCESS; @@ -3938,6 +3941,16 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_sessio if (proto == IPR_RTP) { ice = &rtp_session->ice; + + if (ice->ready) { + if (rtp_session->vb) { + switch_vb_reset(rtp_session->vb); + } + if (rtp_session->vbw) { + switch_vb_reset(rtp_session->vbw); + } + } + } else { ice = &rtp_session->rtcp_ice; } @@ -4025,10 +4038,8 @@ SWITCH_DECLARE(void) switch_rtp_video_refresh(switch_rtp_t *rtp_session) return; } - if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && - (rtp_session->ice.ice_user || rtp_session->flags[SWITCH_RTP_FLAG_FIR])) { + if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && (rtp_session->ice.ice_user || rtp_session->flags[SWITCH_RTP_FLAG_FIR])) { rtp_session->fir_count++; - } } @@ -4038,8 +4049,7 @@ SWITCH_DECLARE(void) switch_rtp_video_loss(switch_rtp_t *rtp_session) return; } - if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && - (rtp_session->ice.ice_user || rtp_session->flags[SWITCH_RTP_FLAG_PLI])) { + if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && (rtp_session->ice.ice_user || rtp_session->flags[SWITCH_RTP_FLAG_PLI])) { rtp_session->pli_count++; } } @@ -6943,7 +6953,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session, if (rtp_session->flags[SWITCH_RTP_FLAG_NACK]) { if (!rtp_session->vbw) { - switch_vb_create(&rtp_session->vbw, 5, 5); + switch_vb_create(&rtp_session->vbw, 5, 5, rtp_session->pool); //switch_vb_debug_level(rtp_session->vbw, 10); } switch_vb_put_packet(rtp_session->vbw, (switch_rtp_packet_t *)send_msg, bytes);