FS-7499: mod vid refresh stuff

This commit is contained in:
Anthony Minessale 2015-01-24 01:55:57 -06:00 committed by Michael Jerris
parent 982d05c30c
commit 59fa1b9ac7
2 changed files with 32 additions and 18 deletions

View File

@ -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_CODEC_CHECK_FRAMES 50//x:mod_sofia.h
#define MAX_MISMATCH_FRAMES 5//x:mod_sofia.h #define MAX_MISMATCH_FRAMES 5//x:mod_sofia.h
#define type2str(type) type == SWITCH_MEDIA_TYPE_VIDEO ? "video" : "audio" #define type2str(type) type == SWITCH_MEDIA_TYPE_VIDEO ? "video" : "audio"
#define VIDEO_REFRESH_FREQ 250000 #define VIDEO_REFRESH_FREQ 1000000
typedef enum { typedef enum {
SMF_INIT = (1 << 0), 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: case SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ:
{ {
if (v_engine->rtp_session) { if (v_engine->rtp_session) {
if (switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_FIR)) { if (switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PLI)) {
switch_rtp_video_refresh(v_engine->rtp_session);
} else if (switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PLI)) {
switch_rtp_video_loss(v_engine->rtp_session); 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)) { 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)) { 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", 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); 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; goto top;
} }
} }

View File

@ -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); ext_hdr->length = htons((uint8_t)(sizeof(switch_rtcp_ext_hdr_t) / 4) - 1);
rtcp_bytes += sizeof(switch_rtcp_ext_hdr_t); 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) { 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->pt = 206;
ext_hdr->send_ssrc = htonl(rtp_session->ssrc); 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->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; 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); 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); 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_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_vb_debug_level(rtp_session->vb, 10);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG, "Starting video buffer.\n"); 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; if (x < 0) x = 0;
switch_vb_debug_level(rtp_session->vb, x); switch_vb_debug_level(rtp_session->vb, x);
} }
return SWITCH_STATUS_SUCCESS; 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) { if (proto == IPR_RTP) {
ice = &rtp_session->ice; 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 { } else {
ice = &rtp_session->rtcp_ice; ice = &rtp_session->rtcp_ice;
} }
@ -4025,10 +4038,8 @@ SWITCH_DECLARE(void) switch_rtp_video_refresh(switch_rtp_t *rtp_session)
return; return;
} }
if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && (rtp_session->ice.ice_user || rtp_session->flags[SWITCH_RTP_FLAG_FIR])) {
(rtp_session->ice.ice_user || rtp_session->flags[SWITCH_RTP_FLAG_FIR])) {
rtp_session->fir_count++; rtp_session->fir_count++;
} }
} }
@ -4038,8 +4049,7 @@ SWITCH_DECLARE(void) switch_rtp_video_loss(switch_rtp_t *rtp_session)
return; return;
} }
if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && (rtp_session->ice.ice_user || rtp_session->flags[SWITCH_RTP_FLAG_PLI])) {
(rtp_session->ice.ice_user || rtp_session->flags[SWITCH_RTP_FLAG_PLI])) {
rtp_session->pli_count++; 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->flags[SWITCH_RTP_FLAG_NACK]) {
if (!rtp_session->vbw) { 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_debug_level(rtp_session->vbw, 10);
} }
switch_vb_put_packet(rtp_session->vbw, (switch_rtp_packet_t *)send_msg, bytes); switch_vb_put_packet(rtp_session->vbw, (switch_rtp_packet_t *)send_msg, bytes);