#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),
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);
}
}
}
}
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",
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;
}
}
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) {
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--;
}
}
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");
if (x < 0) x = 0;
switch_vb_debug_level(rtp_session->vb, x);
+
}
return SWITCH_STATUS_SUCCESS;
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;
}
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++;
-
}
}
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++;
}
}
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);