v4l2: handle unsupported formats
authorWim Taymans <wim.taymans@collabora.co.uk>
Tue, 19 Jul 2011 17:20:43 +0000 (18:20 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Tue, 19 Jul 2011 17:20:43 +0000 (18:20 +0100)
sys/v4l2/gstv4l2object.c
sys/v4l2/gstv4l2sink.c

index 46d09dc..a5edc4e 100644 (file)
@@ -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;
+  }
 }
 
 
index 994def0..87b9809 100644 (file)
@@ -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