summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLasse Laukkanen <ext-lasse.2.laukkanen@nokia.com>2010-05-05 13:58:07 +0300
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>2010-11-04 21:41:07 -0300
commitbc1b09c1c4d48f541235f0da4927c4eb352371fd (patch)
treeaf7195fb9fc879e7ef126e5ce9183a75b00f4992
parent2362acbec3b8fd674521e286ad857277e306aeb1 (diff)
camerabin: Add "ready-for-capture" property
Add "ready-for-capture" property to indicate if preparing a new capture is possible. "ready-for-capture" changes before the 'image-done' signal, so the application can be notified that it can do a new capture even before the previous one has finished encoding/saving.
-rw-r--r--gst/camerabin/gstcamerabin-enum.h3
-rw-r--r--gst/camerabin/gstcamerabin.c27
-rw-r--r--tests/check/elements/camerabin.c11
3 files changed, 40 insertions, 1 deletions
diff --git a/gst/camerabin/gstcamerabin-enum.h b/gst/camerabin/gstcamerabin-enum.h
index 747828af1..aa456144a 100644
--- a/gst/camerabin/gstcamerabin-enum.h
+++ b/gst/camerabin/gstcamerabin-enum.h
@@ -67,7 +67,8 @@ enum
ARG_VIDEO_CAPTURE_WIDTH,
ARG_VIDEO_CAPTURE_HEIGHT,
ARG_VIDEO_CAPTURE_FRAMERATE,
- ARG_PREVIEW_SOURCE_FILTER
+ ARG_PREVIEW_SOURCE_FILTER,
+ ARG_READY_FOR_CAPTURE
};
/**
diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c
index 23b314a8b..4eedcf58b 100644
--- a/gst/camerabin/gstcamerabin.c
+++ b/gst/camerabin/gstcamerabin.c
@@ -218,6 +218,7 @@ static guint camerabin_signals[LAST_SIGNAL];
#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"
@@ -1914,6 +1915,9 @@ gst_camerabin_have_src_buffer (GstPad * pad, GstBuffer * buffer,
/* 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;
}
@@ -3053,6 +3057,20 @@ gst_camerabin_class_init (GstCameraBinClass * klass)
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
*
@@ -3685,6 +3703,11 @@ gst_camerabin_get_property (GObject * object, guint prop_id,
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;
@@ -3930,6 +3953,8 @@ gst_camerabin_capture_start (GstCameraBin * camera)
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
@@ -3939,6 +3964,8 @@ gst_camerabin_capture_stop (GstCameraBin * camera)
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");
}
diff --git a/tests/check/elements/camerabin.c b/tests/check/elements/camerabin.c
index 3930d40d7..613c226f4 100644
--- a/tests/check/elements/camerabin.c
+++ b/tests/check/elements/camerabin.c
@@ -243,7 +243,10 @@ capture_bus_cb (GstBus * bus, GstMessage * message, gpointer data)
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;
}
@@ -489,6 +492,7 @@ check_file_validity (const gchar * filename, gint num, GstTagList * taglist)
GST_START_TEST (test_single_image_capture)
{
+ gboolean ready = FALSE;
if (!camera)
return;
@@ -506,9 +510,16 @@ GST_START_TEST (test_single_image_capture)
/* 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);