#define DEFAULT_V4L2CAMSRC_DRIVER_NAME "omap3cam"
#define DEFAULT_BLOCK_VIEWFINDER FALSE
+#define DEFAULT_READY_FOR_CAPTURE TRUE
/* message names */
#define PREVIEW_MESSAGE_NAME "preview-image"
/* our work is done, disconnect */
gst_pad_remove_buffer_probe (pad, camera->image_captured_id);
+ /* Image captured, notify that preparing a new capture is possible */
+ g_object_notify (G_OBJECT (camera), "ready-for-capture");
+
return TRUE;
}
DEFAULT_FPS_N, DEFAULT_FPS_D,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ /**
+ * GstCameraBin:ready-for-capture:
+ *
+ * When TRUE new capture can be prepared. If FALSE capturing is ongoing
+ * and starting a new capture immediately is not possible.
+ */
+
+ g_object_class_install_property (gobject_class, ARG_READY_FOR_CAPTURE,
+ g_param_spec_boolean ("ready-for-capture",
+ "Indicates if preparing a new capture is possible",
+ "Indicates if preparing a new capture is possible",
+ DEFAULT_READY_FOR_CAPTURE,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
/**
* GstCameraBin::capture-start:
* @camera: the camera bin element
case ARG_BLOCK_VIEWFINDER:
g_value_set_boolean (value, camera->block_viewfinder_prop);
break;
+ case ARG_READY_FOR_CAPTURE:
+ g_mutex_lock (camera->capture_mutex);
+ g_value_set_boolean (value, !camera->capturing);
+ g_mutex_unlock (camera->capture_mutex);
+ break;
case ARG_IMAGE_CAPTURE_WIDTH:
g_value_set_int (value, camera->image_capture_width);
break;
gst_camerabin_start_video_recording (camera);
}
}
+ /* Capturing is now ongoing, notify that new capture isn't possible */
+ g_object_notify (G_OBJECT (camera), "ready-for-capture");
}
static void
GST_INFO_OBJECT (camera, "stopping video capture");
gst_camerabin_do_stop (camera);
gst_camerabin_reset_to_view_finder (camera);
+ /* Video capture stopped, notify that preparing a new capture is possible */
+ g_object_notify (G_OBJECT (camera), "ready-for-capture");
} else {
GST_INFO_OBJECT (camera, "stopping image capture isn't needed");
}
default:
st = gst_message_get_structure (message);
if (st && gst_structure_has_name (st, "image-captured")) {
+ gboolean ready = FALSE;
GST_INFO ("image captured");
+ g_object_get (camera, "ready-for-capture", &ready, NULL);
+ fail_if (!ready, "not ready for capture");
}
break;
}
GST_START_TEST (test_single_image_capture)
{
+ gboolean ready = FALSE;
if (!camera)
return;
/* don't run viewfinder after capture */
g_object_set (camera, "block-after-capture", TRUE, NULL);
+ /* check that capturing is possible */
+ g_object_get (camera, "ready-for-capture", &ready, NULL);
+ fail_if (!ready, "not ready for capture");
+
GST_INFO ("starting capture");
g_signal_emit_by_name (camera, "capture-start", NULL);
+ g_object_get (camera, "ready-for-capture", &ready, NULL);
+ fail_if (ready, "ready for capture during capture");
+
g_main_loop_run (main_loop);
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);