summaryrefslogtreecommitdiffstats
path: root/gst
diff options
context:
space:
mode:
authorLasse Laukkanen <ext-lasse.2.laukkanen@nokia.com>2009-02-27 17:12:38 +0200
committerDave Robillard <dave@drobilla.net>2009-05-03 12:03:15 -0400
commit9c333d003a5e1c922e5e87ae41e5ad11859e396f (patch)
tree4bd538145fec118db7f2d96780a764e425032248 /gst
parent9418a3c2c7854b0d89fba0a186689ddbee04e275 (diff)
downloadgst-plugins-bad-9c333d003a5e1c922e5e87ae41e5ad11859e396f.tar.gz
gst-plugins-bad-9c333d003a5e1c922e5e87ae41e5ad11859e396f.tar.bz2
gst-plugins-bad-9c333d003a5e1c922e5e87ae41e5ad11859e396f.zip
camerabin: change img-done signal parameter from GString* to const gchar*
Don't allow setting filename via img-done signal parameter but force app use filename property. Don't stop capture when setting filename property. Update check unit test based on the change.
Diffstat (limited to 'gst')
-rw-r--r--gst/camerabin/gstcamerabin-marshal.list2
-rw-r--r--gst/camerabin/gstcamerabin.c67
-rw-r--r--gst/camerabin/gstcamerabin.h5
3 files changed, 40 insertions, 34 deletions
diff --git a/gst/camerabin/gstcamerabin-marshal.list b/gst/camerabin/gstcamerabin-marshal.list
index 4c1670ef..40829e54 100644
--- a/gst/camerabin/gstcamerabin-marshal.list
+++ b/gst/camerabin/gstcamerabin-marshal.list
@@ -3,4 +3,4 @@
VOID:INT,INT,INT,INT
VOID:INT,INT
-BOOLEAN:POINTER
+BOOLEAN:STRING
diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c
index bdc4f28b..ddd08e3b 100644
--- a/gst/camerabin/gstcamerabin.c
+++ b/gst/camerabin/gstcamerabin.c
@@ -868,22 +868,37 @@ camerabin_dispose_elements (GstCameraBin * camera)
/*
* gst_camerabin_image_capture_continue:
* @camera: camerabin object
- * @filename: new filename set by user
- * @cont: TRUE to continue image capture, FALSE otherwise
*
- * Check if user wants to continue image capturing by using g_signal.
+ * Check if application wants to continue image capturing by using g_signal.
+ *
+ * Returns TRUE if another image should be captured, FALSE otherwise.
*/
-static void
-gst_camerabin_image_capture_continue (GstCameraBin * camera, GString * filename,
- gboolean * cont)
+static gboolean
+gst_camerabin_image_capture_continue (GstCameraBin * camera)
{
- GST_DEBUG_OBJECT (camera, "emitting img_done signal, filename: %s",
- filename->str);
+ gchar *filename = NULL;
+ gboolean cont = FALSE;
+
+ /* Check the filename of the written image */
+ g_object_get (G_OBJECT (camera->imgbin), "filename", &filename, NULL);
+
+ GST_DEBUG_OBJECT (camera, "emitting img_done signal, filename: %s", filename);
g_signal_emit (G_OBJECT (camera), camerabin_signals[IMG_DONE_SIGNAL], 0,
- filename, cont);
+ filename, &cont);
+
+ g_free (filename);
GST_DEBUG_OBJECT (camera, "emitted img_done, new filename: %s, continue: %d",
- filename->str, *cont);
+ camera->filename->str, cont);
+
+ /* If the app wants to continue make sure new filename has been set */
+ if (cont && g_str_equal (camera->filename->str, "")) {
+ GST_ELEMENT_ERROR (camera, RESOURCE, NOT_FOUND,
+ ("cannot continue capture, no filename has been set"), (NULL));
+ cont = FALSE;
+ }
+
+ return cont;
}
/*
@@ -920,7 +935,6 @@ gst_camerabin_change_mode (GstCameraBin * camera, gint mode)
* @name: new filename for capture
*
* Change filename for image or video capture.
- * Changing filename will stop ongoing capture.
*/
static void
gst_camerabin_change_filename (GstCameraBin * camera, const gchar * name)
@@ -928,14 +942,6 @@ gst_camerabin_change_filename (GstCameraBin * camera, const gchar * name)
if (0 != strcmp (camera->filename->str, name)) {
GST_DEBUG_OBJECT (camera, "changing filename from %s to %s",
camera->filename->str, name);
- /* Interrupt ongoing capture */
- gst_camerabin_do_stop (camera);
- gst_camerabin_reset_to_view_finder (camera);
-
- if (camera->active_bin) {
- g_object_set (G_OBJECT (camera->active_bin), "filename", name, NULL);
- }
-
g_string_assign (camera->filename, name);
}
}
@@ -1557,8 +1563,11 @@ gst_camerabin_have_img_buffer (GstPad * pad, GstBuffer * buffer,
/* Close the file of saved image */
gst_element_set_state (camera->imgbin, GST_STATE_READY);
+ /* Reset filename to force application set new filename */
+ g_string_assign (camera->filename, "");
+
/* Check if the application wants to continue */
- gst_camerabin_image_capture_continue (camera, camera->filename, &ret);
+ ret = gst_camerabin_image_capture_continue (camera);
if (ret && !camera->stop_requested) {
GST_DEBUG_OBJECT (camera, "capturing image \"%s\"", camera->filename->str);
@@ -1568,8 +1577,6 @@ gst_camerabin_have_img_buffer (GstPad * pad, GstBuffer * buffer,
} else {
GST_DEBUG_OBJECT (camera, "not continuing (cont:%d, stop_req:%d)",
ret, camera->stop_requested);
- /* Reset filename to force application set new filename */
- g_string_assign (camera->filename, "");
/* Block dataflow to the output-selector to show preview image in
view finder. Continue and unblock when capture is stopped */
@@ -1715,7 +1722,7 @@ gst_camerabin_do_stop (GstCameraBin * camera)
/*
* gst_camerabin_default_signal_img_done:
* @camera: camerabin object
- * @fname: new filename
+ * @fname: filename of the recently saved image
*
* Default handler for #GstCameraBin::img-done signal,
* stops always capture.
@@ -1723,7 +1730,8 @@ gst_camerabin_do_stop (GstCameraBin * camera)
* Returns: FALSE always
*/
static gboolean
-gst_camerabin_default_signal_img_done (GstCameraBin * camera, GString * fname)
+gst_camerabin_default_signal_img_done (GstCameraBin * camera,
+ const gchar * fname)
{
return FALSE;
}
@@ -2290,10 +2298,11 @@ gst_camerabin_class_init (GstCameraBinClass * klass)
/**
* GstCameraBin::img-done:
* @camera: the camera bin element
- * @filename: the name of the file just saved as a GString*
+ * @filename: the name of the file just saved
*
- * Signal emited when the file has just been saved. To continue taking
- * pictures just update @filename and return TRUE, otherwise return FALSE.
+ * Signal emitted when the file has just been saved. To continue taking
+ * pictures set new filename using #GstCameraBin:filename property and return
+ * TRUE, otherwise return FALSE.
*
* Don't call any #GstCameraBin method from this signal, if you do so there
* will be a deadlock.
@@ -2303,8 +2312,8 @@ gst_camerabin_class_init (GstCameraBinClass * klass)
g_signal_new ("img-done", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstCameraBinClass, img_done),
g_signal_accumulator_true_handled, NULL,
- __gst_camerabin_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1,
- G_TYPE_POINTER);
+ __gst_camerabin_marshal_BOOLEAN__STRING, G_TYPE_BOOLEAN, 1,
+ G_TYPE_STRING);
klass->user_start = gst_camerabin_user_start;
klass->user_stop = gst_camerabin_user_stop;
diff --git a/gst/camerabin/gstcamerabin.h b/gst/camerabin/gstcamerabin.h
index f4eefe91..1bb3f489 100644
--- a/gst/camerabin/gstcamerabin.h
+++ b/gst/camerabin/gstcamerabin.h
@@ -32,7 +32,6 @@
#include "camerabinvideo.h"
G_BEGIN_DECLS
-
/* #defines don't like whitespacey bits */
#define GST_TYPE_CAMERABIN \
(gst_camerabin_get_type())
@@ -44,7 +43,6 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CAMERABIN))
#define GST_IS_CAMERABIN_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CAMERABIN))
-
typedef struct _GstCameraBin GstCameraBin;
typedef struct _GstCameraBinClass GstCameraBinClass;
@@ -147,7 +145,7 @@ struct _GstCameraBinClass
/* signals (callback) */
- gboolean (*img_done) (GstCameraBin * camera, GString * filename);
+ gboolean (*img_done) (GstCameraBin * camera, const gchar * filename);
};
/**
@@ -166,5 +164,4 @@ typedef enum
GType gst_camerabin_get_type (void);
G_END_DECLS
-
#endif /* #ifndef __GST_CAMERABIN_H__ */