rtpvp9depay: detect incomplete frames and bail out
authorKnut Saastad <Knut@bitflow.io>
Wed, 14 Oct 2020 21:17:53 +0000 (23:17 +0200)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 30 Oct 2020 01:31:19 +0000 (01:31 +0000)
If a packet with the B bit set arrives but we haven't received
a packet with the marker or E bits set to end the previous frame,
we know the current frame was incomplete.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/795>

gst/rtp/gstrtpvp8depay.c
gst/rtp/gstrtpvp8pay.c

index 396aa75..6fe65a3 100644 (file)
@@ -238,7 +238,7 @@ gst_rtp_vp8_depay_process (GstRTPBaseDepayload * depay, GstRTPBuffer * rtp)
   guint size = gst_rtp_buffer_get_payload_len (rtp);
 
   if (G_UNLIKELY (GST_BUFFER_IS_DISCONT (rtp->buffer))) {
-    GST_LOG_OBJECT (self, "Discontinuity, flushing adapter");
+    GST_DEBUG_OBJECT (self, "Discontinuity, flushing adapter");
     gst_adapter_clear (self->adapter);
     self->started = FALSE;
 
@@ -275,7 +275,7 @@ gst_rtp_vp8_depay_process (GstRTPBaseDepayload * depay, GstRTPBuffer * rtp)
     if ((data[1] & 0x20) != 0 || (data[1] & 0x10) != 0)
       hdrsize++;
   }
-  GST_DEBUG_OBJECT (depay, "hdrsize %u, size %u, picture id 0x%x", hdrsize,
+  GST_LOG_OBJECT (depay, "hdrsize %u, size %u, picture id 0x%x", hdrsize,
       size, picture_id);
   if (G_UNLIKELY (hdrsize >= size))
     goto too_small;
@@ -293,7 +293,7 @@ gst_rtp_vp8_depay_process (GstRTPBaseDepayload * depay, GstRTPBuffer * rtp)
       goto done;
     }
 
-    GST_DEBUG_OBJECT (depay, "Found the start of the frame");
+    GST_LOG_OBJECT (depay, "Found the start of the frame");
 
     if (self->stop_lost_events) {
       send_last_lost_event_if_needed (self, picture_id);
@@ -312,7 +312,7 @@ gst_rtp_vp8_depay_process (GstRTPBaseDepayload * depay, GstRTPBuffer * rtp)
     GstBuffer *out;
     guint8 header[10];
 
-    GST_DEBUG_OBJECT (depay,
+    GST_LOG_OBJECT (depay,
         "Found the end of the frame (%" G_GSIZE_FORMAT " bytes)",
         gst_adapter_available (self->adapter));
     if (gst_adapter_available (self->adapter) < 10)
@@ -343,6 +343,7 @@ gst_rtp_vp8_depay_process (GstRTPBaseDepayload * depay, GstRTPBuffer * rtp)
       guint profile, width, height;
 
       GST_BUFFER_FLAG_UNSET (out, GST_BUFFER_FLAG_DELTA_UNIT);
+      GST_DEBUG_OBJECT (self, "Processed keyframe");
 
       profile = (header[0] & 0x0e) >> 1;
       width = GST_READ_UINT16_LE (header + 6) & 0x3fff;
@@ -379,7 +380,7 @@ done:
   return NULL;
 
 too_small:
-  GST_LOG_OBJECT (self, "Invalid rtp packet (too small), ignoring");
+  GST_DEBUG_OBJECT (self, "Invalid rtp packet (too small), ignoring");
   gst_adapter_clear (self->adapter);
   self->started = FALSE;
 
index 56edb53..717eaea 100644 (file)
@@ -402,6 +402,10 @@ gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer,
   self->partition_offset[i + 1] = size;
 
   gst_buffer_unmap (buffer, &map);
+
+  if (keyframe)
+    GST_DEBUG_OBJECT (self, "Parsed keyframe");
+
   return TRUE;
 
 error: