From 44fa0b9cab4afe566e1125cda6abbf7e7abffecf Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 19 Jul 2011 18:20:43 +0100 Subject: [PATCH] v4l2: handle unsupported formats --- sys/v4l2/gstv4l2object.c | 12 +++++++++++- sys/v4l2/gstv4l2sink.c | 10 ++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c index 46d09dc872..a5edc4e66e 100644 --- a/sys/v4l2/gstv4l2object.c +++ b/sys/v4l2/gstv4l2object.c @@ -1376,6 +1376,7 @@ gst_v4l2_object_get_caps_info (GstV4l2Object * v4l2object, GstCaps * caps, GstStructure *structure; guint32 fourcc; const gchar *mimetype; + struct v4l2_fmtdesc *fmt; /* default unknown values */ fourcc = 0; @@ -1503,7 +1504,11 @@ gst_v4l2_object_get_caps_info (GstV4l2Object * v4l2object, GstCaps * caps, if (fourcc == 0) goto unhandled_format; - *format = gst_v4l2_object_get_format_from_fourcc (v4l2object, fourcc); + fmt = gst_v4l2_object_get_format_from_fourcc (v4l2object, fourcc); + if (fmt == NULL) + goto unsupported_format; + + *format = fmt; return TRUE; @@ -1533,6 +1538,11 @@ unhandled_format: GST_DEBUG_OBJECT (v4l2object, "unhandled format"); return FALSE; } +unsupported_format: + { + GST_DEBUG_OBJECT (v4l2object, "unsupported format"); + return FALSE; + } } diff --git a/sys/v4l2/gstv4l2sink.c b/sys/v4l2/gstv4l2sink.c index 994def00b0..87b980954d 100644 --- a/sys/v4l2/gstv4l2sink.c +++ b/sys/v4l2/gstv4l2sink.c @@ -747,9 +747,19 @@ gst_v4l2sink_show_frame (GstBaseSink * bsink, GstBuffer * buf) GST_DEBUG_OBJECT (v4l2sink, "render buffer: %p", buf); + if (G_UNLIKELY (obj->pool == NULL)) + goto not_negotiated; + ret = gst_v4l2_buffer_pool_process (obj->pool, buf); return ret; + + /* ERRORS */ +not_negotiated: + { + GST_ERROR_OBJECT (bsink, "not negotiated"); + return GST_FLOW_NOT_NEGOTIATED; + } } #ifdef HAVE_XVIDEO