mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 02:31:03 +00:00
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.
This commit is contained in:
parent
d8ba5624ce
commit
65ddcd6d5d
4 changed files with 44 additions and 40 deletions
|
@ -3,4 +3,4 @@
|
||||||
|
|
||||||
VOID:INT,INT,INT,INT
|
VOID:INT,INT,INT,INT
|
||||||
VOID:INT,INT
|
VOID:INT,INT
|
||||||
BOOLEAN:POINTER
|
BOOLEAN:STRING
|
||||||
|
|
|
@ -868,22 +868,37 @@ camerabin_dispose_elements (GstCameraBin * camera)
|
||||||
/*
|
/*
|
||||||
* gst_camerabin_image_capture_continue:
|
* gst_camerabin_image_capture_continue:
|
||||||
* @camera: camerabin object
|
* @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
|
static gboolean
|
||||||
gst_camerabin_image_capture_continue (GstCameraBin * camera, GString * filename,
|
gst_camerabin_image_capture_continue (GstCameraBin * camera)
|
||||||
gboolean * cont)
|
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (camera, "emitting img_done signal, filename: %s",
|
gchar *filename = NULL;
|
||||||
filename->str);
|
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,
|
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",
|
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
|
* @name: new filename for capture
|
||||||
*
|
*
|
||||||
* Change filename for image or video capture.
|
* Change filename for image or video capture.
|
||||||
* Changing filename will stop ongoing capture.
|
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
gst_camerabin_change_filename (GstCameraBin * camera, const gchar * name)
|
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)) {
|
if (0 != strcmp (camera->filename->str, name)) {
|
||||||
GST_DEBUG_OBJECT (camera, "changing filename from %s to %s",
|
GST_DEBUG_OBJECT (camera, "changing filename from %s to %s",
|
||||||
camera->filename->str, name);
|
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);
|
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 */
|
/* Close the file of saved image */
|
||||||
gst_element_set_state (camera->imgbin, GST_STATE_READY);
|
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 */
|
/* 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) {
|
if (ret && !camera->stop_requested) {
|
||||||
GST_DEBUG_OBJECT (camera, "capturing image \"%s\"", camera->filename->str);
|
GST_DEBUG_OBJECT (camera, "capturing image \"%s\"", camera->filename->str);
|
||||||
|
@ -1568,8 +1577,6 @@ gst_camerabin_have_img_buffer (GstPad * pad, GstBuffer * buffer,
|
||||||
} else {
|
} else {
|
||||||
GST_DEBUG_OBJECT (camera, "not continuing (cont:%d, stop_req:%d)",
|
GST_DEBUG_OBJECT (camera, "not continuing (cont:%d, stop_req:%d)",
|
||||||
ret, camera->stop_requested);
|
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
|
/* Block dataflow to the output-selector to show preview image in
|
||||||
view finder. Continue and unblock when capture is stopped */
|
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:
|
* gst_camerabin_default_signal_img_done:
|
||||||
* @camera: camerabin object
|
* @camera: camerabin object
|
||||||
* @fname: new filename
|
* @fname: filename of the recently saved image
|
||||||
*
|
*
|
||||||
* Default handler for #GstCameraBin::img-done signal,
|
* Default handler for #GstCameraBin::img-done signal,
|
||||||
* stops always capture.
|
* stops always capture.
|
||||||
|
@ -1723,7 +1730,8 @@ gst_camerabin_do_stop (GstCameraBin * camera)
|
||||||
* Returns: FALSE always
|
* Returns: FALSE always
|
||||||
*/
|
*/
|
||||||
static gboolean
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2290,10 +2298,11 @@ gst_camerabin_class_init (GstCameraBinClass * klass)
|
||||||
/**
|
/**
|
||||||
* GstCameraBin::img-done:
|
* GstCameraBin::img-done:
|
||||||
* @camera: the camera bin element
|
* @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
|
* Signal emitted when the file has just been saved. To continue taking
|
||||||
* pictures just update @filename and return TRUE, otherwise return FALSE.
|
* 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
|
* Don't call any #GstCameraBin method from this signal, if you do so there
|
||||||
* will be a deadlock.
|
* 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_new ("img-done", G_TYPE_FROM_CLASS (klass),
|
||||||
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstCameraBinClass, img_done),
|
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstCameraBinClass, img_done),
|
||||||
g_signal_accumulator_true_handled, NULL,
|
g_signal_accumulator_true_handled, NULL,
|
||||||
__gst_camerabin_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1,
|
__gst_camerabin_marshal_BOOLEAN__STRING, G_TYPE_BOOLEAN, 1,
|
||||||
G_TYPE_POINTER);
|
G_TYPE_STRING);
|
||||||
|
|
||||||
klass->user_start = gst_camerabin_user_start;
|
klass->user_start = gst_camerabin_user_start;
|
||||||
klass->user_stop = gst_camerabin_user_stop;
|
klass->user_stop = gst_camerabin_user_stop;
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include "camerabinvideo.h"
|
#include "camerabinvideo.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/* #defines don't like whitespacey bits */
|
/* #defines don't like whitespacey bits */
|
||||||
#define GST_TYPE_CAMERABIN \
|
#define GST_TYPE_CAMERABIN \
|
||||||
(gst_camerabin_get_type())
|
(gst_camerabin_get_type())
|
||||||
|
@ -44,7 +43,6 @@ G_BEGIN_DECLS
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CAMERABIN))
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CAMERABIN))
|
||||||
#define GST_IS_CAMERABIN_CLASS(klass) \
|
#define GST_IS_CAMERABIN_CLASS(klass) \
|
||||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CAMERABIN))
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CAMERABIN))
|
||||||
|
|
||||||
typedef struct _GstCameraBin GstCameraBin;
|
typedef struct _GstCameraBin GstCameraBin;
|
||||||
typedef struct _GstCameraBinClass GstCameraBinClass;
|
typedef struct _GstCameraBinClass GstCameraBinClass;
|
||||||
|
|
||||||
|
@ -147,7 +145,7 @@ struct _GstCameraBinClass
|
||||||
|
|
||||||
/* signals (callback) */
|
/* 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);
|
GType gst_camerabin_get_type (void);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* #ifndef __GST_CAMERABIN_H__ */
|
#endif /* #ifndef __GST_CAMERABIN_H__ */
|
||||||
|
|
|
@ -76,7 +76,7 @@ make_test_seq_file_name (const gchar * base_name)
|
||||||
/* signal handlers */
|
/* signal handlers */
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
capture_done (GstElement * elem, GString * filename, gpointer user_data)
|
capture_done (GstElement * elem, const gchar * filename, gpointer user_data)
|
||||||
{
|
{
|
||||||
captured_images++;
|
captured_images++;
|
||||||
|
|
||||||
|
@ -90,11 +90,9 @@ capture_done (GstElement * elem, GString * filename, gpointer user_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (continuous) {
|
if (continuous) {
|
||||||
g_string_assign (filename, make_test_seq_file_name (BURST_IMAGE_FILENAME));
|
/* Must set filename for new picture */
|
||||||
/* on needs to modify the passed GString, the code below won't work
|
g_object_set (G_OBJECT (elem), "filename",
|
||||||
g_object_set (G_OBJECT (elem), "filename",
|
make_test_seq_file_name (BURST_IMAGE_FILENAME), NULL);
|
||||||
make_test_seq_file_name (BURST_IMAGE_FILENAME), NULL);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return continuous;
|
return continuous;
|
||||||
|
|
Loading…
Reference in a new issue