camerabin: Always take photo when preview-caps is set
authorLuciana Fujii Pontello <luciana@fujii.eti.br>
Fri, 4 Feb 2011 03:00:55 +0000 (01:00 -0200)
committerStefan Kost <ensonic@users.sf.net>
Wed, 9 Feb 2011 11:42:07 +0000 (13:42 +0200)
When filename is not set, but preview-caps is set, take the photo and
send its preview.

gst/camerabin/gstcamerabin.c

index 8267500..5704513 100644 (file)
@@ -1816,6 +1816,10 @@ gst_camerabin_have_img_buffer (GstPad * pad, GstMiniObject * obj,
 
     GST_LOG ("got buffer %p with size %d", buffer, GST_BUFFER_SIZE (buffer));
 
+    if (camera->preview_caps) {
+      gst_camerabin_send_preview (camera, buffer);
+    }
+
     /* Image filename should be set by now */
     if (g_str_equal (camera->filename->str, "")) {
       GST_DEBUG_OBJECT (camera, "filename not set, dropping buffer");
@@ -1824,10 +1828,6 @@ gst_camerabin_have_img_buffer (GstPad * pad, GstMiniObject * obj,
       goto done;
     }
 
-    if (camera->preview_caps) {
-      gst_camerabin_send_preview (camera, buffer);
-    }
-
     gst_camerabin_rewrite_tags (camera);
 
     /* Send a custom event which tells the filename to image queue */
@@ -4045,11 +4045,14 @@ gst_camerabin_capture_start (GstCameraBin * camera)
     }
   }
 
-  if (g_str_equal (camera->filename->str, "")) {
-    GST_ELEMENT_ERROR (camera, CORE, FAILED,
-        ("set filename before starting capture"), (NULL));
-    return;
-  }
+  /* We need a filename unless it's a photo and preview_caps is set */
+
+  if (g_str_equal (camera->filename->str, ""))
+    if (camera->active_bin == camera->vidbin || !camera->preview_caps) {
+      GST_ELEMENT_ERROR (camera, CORE, FAILED,
+          ("set filename before starting capture"), (NULL));
+      return;
+    }
 
   g_mutex_lock (camera->capture_mutex);
   if (camera->capturing) {