summaryrefslogtreecommitdiffstats
path: root/gst/rtp
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-05-06 23:56:44 +0200
committerWim Taymans <wim@metal.(none)>2009-05-06 23:56:44 +0200
commite2a483f0f96b2919f214dfcdae924cf0cbd9063b (patch)
tree309eb092b64469f17df0d326891c1bf62d9f1ff0 /gst/rtp
parent4ef9eee8b4d0eef693216a38a2159a79b72ddc42 (diff)
rtpjpegpay: refuse some unsupported jpeg formats
Diffstat (limited to 'gst/rtp')
-rw-r--r--gst/rtp/gstrtpjpegpay.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/gst/rtp/gstrtpjpegpay.c b/gst/rtp/gstrtpjpegpay.c
index 33fe310d..b7080d37 100644
--- a/gst/rtp/gstrtpjpegpay.c
+++ b/gst/rtp/gstrtpjpegpay.c
@@ -481,7 +481,7 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
guint jpeg_header_size = 0;
guint offset;
gboolean frame_done;
- gboolean sos_found;
+ gboolean sos_found, sof_found, dqt_found;
gint i;
pay = GST_RTP_JPEG_PAY (basepayload);
@@ -497,6 +497,8 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
/* parse the jpeg header for 'start of scan' and read quant tables if needed */
sos_found = FALSE;
+ dqt_found = FALSE;
+ sof_found = FALSE;
while (!sos_found && (offset < size)) {
GST_LOG_OBJECT (pay, "checking from offset %u", offset);
switch (gst_rtp_jpeg_pay_scan_marker (data, size, &offset)) {
@@ -508,20 +510,18 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
case JPEG_MARKER_SOF:
if (!gst_rtp_jpeg_pay_read_sof (pay, data, &offset, info))
goto invalid_format;
+ sof_found = TRUE;
break;
case JPEG_MARKER_DQT:
- {
GST_LOG ("DQT found");
offset += gst_rtp_jpeg_pay_read_quant_table (data, offset, tables);
+ dqt_found = TRUE;
break;
- }
case JPEG_MARKER_SOS:
- {
sos_found = TRUE;
GST_LOG_OBJECT (pay, "SOS found");
jpeg_header_size = offset + gst_rtp_jpeg_pay_header_size (data, offset);
break;
- }
case JPEG_MARKER_EOI:
GST_WARNING_OBJECT (pay, "EOI reached before SOS!");
break;
@@ -532,6 +532,9 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
break;
}
}
+ if (!dqt_found || !sof_found)
+ goto unsupported_jpeg;
+
/* by now we should either have negotiated the width/height or the SOF header
* should have filled us in */
if (pay->width == 0 || pay->height == 0)
@@ -652,6 +655,12 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
return ret;
/* ERRORS */
+unsupported_jpeg:
+ {
+ GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("Unsupported JPEG"), (NULL));
+ gst_buffer_unref (buffer);
+ return GST_FLOW_NOT_SUPPORTED;
+ }
no_dimension:
{
GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("No size given"), (NULL));