rtpjitterbuffer: Change RTX timer availability checks to assertions
authorSebastian Dröge <sebastian@centricular.com>
Fri, 2 Sep 2022 09:19:26 +0000 (12:19 +0300)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Sat, 3 Sep 2022 09:26:24 +0000 (09:26 +0000)
It's impossible to end up in the corresponding code without a timer for
RTX packets because otherwise it would be an unsolicited RTX packet and
we would've already returned early.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2973>

subprojects/gst-plugins-good/gst/rtpmanager/gstrtpjitterbuffer.c

index 40e0ed2..d82b32f 100644 (file)
@@ -3395,8 +3395,12 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstObject * parent,
     priv->last_known_ntpnstime = inband_ntp_time;
   }
 
-  if (is_rtx)
+  if (is_rtx) {
+    /* For RTX there must be a corresponding timer or it would be an
+     * unsolicited RTX packet that would be dropped */
+    g_assert (timer != NULL);
     timer->num_rtx_received++;
+  }
 
   /* At 2^15, we would detect a seqnum rollover too early, therefore
    * limit the queue size. But let's not limit it to a number that is
@@ -3428,7 +3432,11 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstObject * parent,
     /* priv->last_popped_seqnum >= seqnum, we're too late. */
     if (G_UNLIKELY (gap <= 0)) {
       if (priv->do_retransmission) {
-        if (is_rtx && timer) {
+        if (is_rtx) {
+          /* For RTX there must be a corresponding timer or it would be an
+           * unsolicited RTX packet that would be dropped */
+          g_assert (timer != NULL);
+
           update_rtx_stats (jitterbuffer, timer, dts, FALSE);
           /* Only count the retranmitted packet too late if it has been
            * considered lost. If the original packet arrived before the
@@ -3510,8 +3518,12 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstObject * parent,
    * FALSE if a packet with the same seqnum was already in the queue, meaning we
    * have a duplicate. */
   if (G_UNLIKELY (duplicate)) {
-    if (is_rtx && timer)
+    if (is_rtx) {
+      /* For RTX there must be a corresponding timer or it would be an
+       * unsolicited RTX packet that would be dropped */
+      g_assert (timer != NULL);
       update_rtx_stats (jitterbuffer, timer, dts, FALSE);
+    }
     goto duplicate;
   }