Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/include/switch_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ typedef struct {
uint32_t last_rpt_ext_seq; /* Packet loss calculation, extended sequence number at the begining of this RTCP report interval */
uint16_t last_rpt_cycle; /* Packet loss calculation, sequence number cycle at the begining of the current RTCP report interval */
uint16_t period_pkt_count; /* Packet loss calculation, packet count received during this RTCP report interval */
switch_size_t last_rpt_flush_count; /* inbound.flush_packet_count at the start of this RTCP report interval (RTP_BUG_DONT_REPORT_FLUSHED_AS_LOST) */
uint16_t pkt_count; /* Packet loss calculation, packet count received during this session */
uint16_t sent_pkt_count;
uint32_t rtcp_rtp_count; /* RTCP report generated count */
Expand Down Expand Up @@ -975,13 +976,21 @@ typedef enum {
*/


RTP_BUG_ALWAYS_AUTO_ADJUST = (1 << 12)
RTP_BUG_ALWAYS_AUTO_ADJUST = (1 << 12),

/*
Leave the auto-adjust behavior enableed permenantly rather than only at appropriate times. (IMPLICITLY sets RTP_BUG_ACCEPT_ANY_PACKETS)

*/

RTP_BUG_DONT_REPORT_FLUSHED_AS_LOST = (1 << 13)

/*
Do not count packets FreeSWITCH itself flushed (do_flush) as lost in the RTCP
receiver report. They arrived over the network; discarding them locally is not
transport loss. Genuine network loss (packets that never arrived) is still reported.
*/

} switch_rtp_bug_flag_t;

#ifdef _MSC_VER
Expand Down
8 changes: 8 additions & 0 deletions src/switch_core_media.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,14 @@ SWITCH_DECLARE(void) switch_core_media_parse_rtp_bugs(switch_rtp_bug_flag_t *fla
*flag_pole &= ~RTP_BUG_FLUSH_JB_ON_DTMF;
}

if (switch_stristr("DONT_REPORT_FLUSHED_AS_LOST", str)) {
*flag_pole |= RTP_BUG_DONT_REPORT_FLUSHED_AS_LOST;
}

if (switch_stristr("~DONT_REPORT_FLUSHED_AS_LOST", str)) {
*flag_pole &= ~RTP_BUG_DONT_REPORT_FLUSHED_AS_LOST;
}

if (switch_stristr("ALWAYS_AUTO_ADJUST", str)) {
*flag_pole |= (RTP_BUG_ALWAYS_AUTO_ADJUST | RTP_BUG_ACCEPT_ANY_PACKETS);
}
Expand Down
10 changes: 10 additions & 0 deletions src/switch_rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1854,6 +1854,14 @@ static void rtcp_generate_report_block(switch_rtp_t *rtp_session, struct switch_
}

pkt_lost = expected_pkt - stats->period_pkt_count;

if (rtp_session->rtp_bugs & RTP_BUG_DONT_REPORT_FLUSHED_AS_LOST) {
switch_size_t fc = rtp_session->stats.inbound.flush_packet_count;
if (fc > stats->last_rpt_flush_count) {
pkt_lost -= (int32_t)(fc - stats->last_rpt_flush_count); /* flushed by FS = arrived, not transport loss */
}
}

if (pkt_lost < 0) pkt_lost = 0;

stats->cum_lost=stats->cum_lost+pkt_lost;
Expand Down Expand Up @@ -1920,6 +1928,7 @@ static void rtcp_stats_init(switch_rtp_t *rtp_session)
stats->bad_seq = (1<<16) + 1; /* Make sure we wont missmatch 2 consecutive packets, so seq == bad_seq is false */
stats->cum_lost = 0;
stats->period_pkt_count = 0;
stats->last_rpt_flush_count = rtp_session->stats.inbound.flush_packet_count;
stats->sent_pkt_count = 0;
stats->pkt_count = 0;
stats->rtcp_rtp_count = 0;
Expand Down Expand Up @@ -2468,6 +2477,7 @@ static int check_rtcp_and_ice(switch_rtp_t *rtp_session)
stats->last_rpt_ext_seq = stats->high_ext_seq_recv;
stats->last_rpt_ts = rtp_session->write_timer.samplecount;
stats->period_pkt_count = 0;
stats->last_rpt_flush_count = rtp_session->stats.inbound.flush_packet_count;
}


Expand Down