diff options
author | Havard Graff <havard@pexip.com> | 2021-04-25 02:16:45 +0200 |
---|---|---|
committer | Havard Graff <havard.graff@gmail.com> | 2021-04-25 02:21:04 +0200 |
commit | d75c67847966ea25a0fb42194fb196a2a2a4e2b6 (patch) | |
tree | 35cbb6f8e0d821dcc78e60fa14fcd1ef44de56a8 /gst | |
parent | 1368b4214b0aefdad387a4a1e6b882a357ec48f1 (diff) |
rtpjitterbuffer: fix divide-by-zero
The estimated packet-duration can sometimes end up as zero, and dividing
by that is never a good idea...
The test reproduces the scenario, and the fix is easy.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/966>
Diffstat (limited to 'gst')
-rw-r--r-- | gst/rtpmanager/gstrtpjitterbuffer.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gst/rtpmanager/gstrtpjitterbuffer.c b/gst/rtpmanager/gstrtpjitterbuffer.c index eec1f9ece..8f318dabb 100644 --- a/gst/rtpmanager/gstrtpjitterbuffer.c +++ b/gst/rtpmanager/gstrtpjitterbuffer.c @@ -2498,7 +2498,7 @@ gst_rtp_jitter_buffer_handle_missing_packets (GstRtpJitterBuffer * jitterbuffer, guint lost_packets; GstClockTime lost_duration; GstClockTimeDiff gap_time; - guint saveable_packets; + guint saveable_packets = 0; GstClockTime saveable_duration; /* gap time represents the total duration of all missing packets */ @@ -2506,7 +2506,9 @@ gst_rtp_jitter_buffer_handle_missing_packets (GstRtpJitterBuffer * jitterbuffer, /* based on the estimated packet duration, we can figure out how many packets we could possibly save */ - saveable_packets = offset / est_pkt_duration; + if (est_pkt_duration) + saveable_packets = offset / est_pkt_duration; + /* and say that the amount of lost packet is the sequence-number gap minus these saveable packets, but at least 1 */ lost_packets = MAX (1, (gint) gap - (gint) saveable_packets); |