From 860a9d7af0868af639409deab2e3292969fa29ad Mon Sep 17 00:00:00 2001 From: Jakub Karolczyk Date: Thu, 10 Jun 2021 12:36:52 +0100 Subject: [PATCH] [CORE] Fix video disruptions caused by dropping entire frame when only single packet is missed Currently when single packet is missed and there is subsequent packet already available in buffer, which belongs to the same frame, or missed packet is marked, the entire frame is dropped. Together with buffer resync, that causes video disruptions. With this fix, we don't drop any frame, just because of loss of single packet. We carry on and pass the broken frame to decoder, which does all it's best to conceals errors. Because one step back we've requested new keyframe, video will recover anyway in a moment and there will be smooth transition from the bad state we've encountered. --- src/switch_jitterbuffer.c | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/switch_jitterbuffer.c b/src/switch_jitterbuffer.c index 54e9fc1c5e..96078a1be5 100644 --- a/src/switch_jitterbuffer.c +++ b/src/switch_jitterbuffer.c @@ -743,8 +743,6 @@ static inline switch_status_t jb_next_packet_by_seq(switch_jb_t *jb, switch_jb_n { switch_jb_node_t *node = NULL; - top: - if (jb->type == SJB_VIDEO) { if (jb->dropped) { jb->dropped = 0; @@ -774,38 +772,13 @@ static inline switch_status_t jb_next_packet_by_seq(switch_jb_t *jb, switch_jb_n jb_miss(jb); if (jb->type == SJB_VIDEO) { - int x; if (jb->session) { switch_core_session_request_video_refresh(jb->session); } - for (x = 0; x < 10; x++) { - increment_seq(jb); - if ((node = switch_core_inthash_find(jb->node_hash, jb->target_seq))) { - jb_debug(jb, 2, "FOUND incremental seq: %u\n", ntohs(jb->target_seq)); + increment_seq(jb); - if (node->packet.header.m || node->packet.header.ts == jb->highest_read_ts) { - jb_debug(jb, 2, "%s", "SAME FRAME DROPPING\n"); - jb->dropped++; - drop_ts(jb, node->packet.header.ts); - jb->highest_dropped_ts = ntohl(node->packet.header.ts); - - - if (jb->period_miss_count > 2 && jb->period_miss_inc < 1) { - jb->period_miss_inc++; - jb_frame_inc(jb, 1); - } - - node = NULL; - goto top; - } - break; - } else { - jb_debug(jb, 2, "MISSING incremental seq: %u\n", ntohs(jb->target_seq)); - } - } - } else { increment_seq(jb); }