rtpvp9depay: detect incomplete frames and bail out

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>
This commit is contained in:
Knut Saastad 2020-10-14 23:17:53 +02:00 committed by GStreamer Merge Bot
parent b22514d469
commit fa505867a9
2 changed files with 10 additions and 5 deletions

View 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;

View 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: