camerabin2: Add image-done message

Post an image-done message when a new image is saved to disk
This commit is contained in:
Thiago Santos 2011-01-14 08:12:25 -03:00
parent a715b46c7f
commit bccae0f994
3 changed files with 44 additions and 1 deletions

View file

@ -12,3 +12,6 @@ capture.
* Capture signals
The signals were renamed from capture-start/stop to start/stop-capture as
this is the usual naming on actions.
* image-done
In camerabin, image-done is a signal, in camerabin2, it is a bus message

View file

@ -99,6 +99,8 @@ static void gst_camera_bin_init (GstCameraBin * camera);
static void gst_camera_bin_dispose (GObject * object);
static void gst_camera_bin_finalize (GObject * object);
static void gst_camera_bin_handle_message (GstBin * bin, GstMessage * message);
GType
gst_camera_bin_get_type (void)
{
@ -300,10 +302,12 @@ gst_camera_bin_class_init (GstCameraBinClass * klass)
{
GObjectClass *object_class;
GstElementClass *element_class;
GstBinClass *bin_class;
parent_class = g_type_class_peek_parent (klass);
object_class = G_OBJECT_CLASS (klass);
element_class = GST_ELEMENT_CLASS (klass);
bin_class = GST_BIN_CLASS (klass);
object_class->dispose = gst_camera_bin_dispose;
object_class->finalize = gst_camera_bin_finalize;
@ -312,6 +316,8 @@ gst_camera_bin_class_init (GstCameraBinClass * klass)
element_class->change_state = GST_DEBUG_FUNCPTR (gst_camera_bin_change_state);
bin_class->handle_message = gst_camera_bin_handle_message;
klass->start_capture = gst_camera_bin_start_capture;
klass->stop_capture = gst_camera_bin_stop_capture;
@ -433,6 +439,40 @@ gst_camera_bin_init (GstCameraBin * camera)
gst_object_ref (camera->viewfinderbin_capsfilter), NULL);
}
static void
gst_image_capture_bin_post_image_done (GstCameraBin * camera,
const gchar * filename)
{
GstMessage *msg;
g_return_if_fail (filename != NULL);
msg = gst_message_new_element (GST_OBJECT_CAST (camera),
gst_structure_new ("image-done", "filename", G_TYPE_STRING,
filename, NULL));
if (!gst_element_post_message (GST_ELEMENT_CAST (camera), msg))
GST_WARNING_OBJECT (camera, "Failed to post image-done message");
}
static void
gst_camera_bin_handle_message (GstBin * bin, GstMessage * message)
{
if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) {
const GstStructure *structure = gst_message_get_structure (message);
const gchar *filename;
if (gst_structure_has_name (structure, "GstMultiFileSink")) {
filename = gst_structure_get_string (structure, "filename");
if (filename) {
gst_image_capture_bin_post_image_done (GST_CAMERA_BIN_CAST (bin),
filename);
}
}
}
GST_BIN_CLASS (parent_class)->handle_message (bin, message);
}
/**
* gst_camera_bin_create_elements:
* @param camera: the #GstCameraBin

View file

@ -297,7 +297,7 @@ gst_image_capture_bin_create_elements (GstImageCaptureBin * imagebin)
goto error;
g_object_set (imagebin->sink, "location", imagebin->location, "async", FALSE,
NULL);
"post-messages", TRUE, NULL);
/* add ghostpad */
pad = gst_element_get_static_pad (colorspace, "sink");