summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>2011-09-29 18:03:25 -0300
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>2011-09-29 18:21:06 -0300
commit379670e036e91c6f1e44051f8d5d1ab01a7faf19 (patch)
tree253207a5fc01ba122c66e21f70db82bea7f5fae4
parentb03c7478d4df98ebcc3c1a53dfc2caaac0b52a34 (diff)
camerabin2: add location to preview image messages
Makes camerabin2 intercept preview-image messages and add the filename corresponding to the message structure in the 'location' field. Makes easier for applications to track preview images
-rw-r--r--gst/camerabin2/gstcamerabin2.c44
-rw-r--r--gst/camerabin2/gstcamerabin2.h3
2 files changed, 38 insertions, 9 deletions
diff --git a/gst/camerabin2/gstcamerabin2.c b/gst/camerabin2/gstcamerabin2.c
index e990a9508..a91f109c7 100644
--- a/gst/camerabin2/gstcamerabin2.c
+++ b/gst/camerabin2/gstcamerabin2.c
@@ -363,7 +363,8 @@ static void
gst_camera_bin_start_capture (GstCameraBin2 * camerabin)
{
const GstTagList *taglist;
-
+ gint capture_index = camerabin->capture_index;
+ gchar *location = NULL;
GST_DEBUG_OBJECT (camerabin, "Received start-capture");
/* check that we have a valid location */
@@ -376,6 +377,9 @@ gst_camera_bin_start_capture (GstCameraBin2 * camerabin)
GST_CAMERA_BIN2_PROCESSING_INC (camerabin);
+ if (camerabin->location)
+ location = g_strdup_printf (camerabin->location, capture_index);
+
if (camerabin->mode == MODE_VIDEO) {
if (camerabin->audio_src) {
GstClock *clock = gst_pipeline_get_clock (GST_PIPELINE_CAST (camerabin));
@@ -396,16 +400,15 @@ gst_camera_bin_start_capture (GstCameraBin2 * camerabin)
}
}
} else {
- gchar *location = NULL;
-
/* store the next capture buffer filename */
- if (camerabin->location)
- location =
- g_strdup_printf (camerabin->location, camerabin->capture_index++);
camerabin->image_location_list =
- g_slist_append (camerabin->image_location_list, location);
+ g_slist_append (camerabin->image_location_list, g_strdup (location));
}
+ /* store the next preview filename */
+ camerabin->preview_location_list =
+ g_slist_append (camerabin->preview_location_list, location);
+
g_signal_emit_by_name (camerabin->src, "start-capture", NULL);
if (camerabin->mode == MODE_VIDEO && camerabin->audio_src)
gst_element_set_state (camerabin->audio_src, GST_STATE_PLAYING);
@@ -434,7 +437,6 @@ gst_camera_bin_start_capture (GstCameraBin2 * camerabin)
gst_event_new_tag (gst_tag_list_copy (taglist)));
gst_object_unref (active_pad);
}
-
}
static void
@@ -482,7 +484,7 @@ gst_camera_bin_src_notify_readyforcapture (GObject * obj, GParamSpec * pspec,
gst_element_set_state (camera->videosink, GST_STATE_NULL);
gst_element_set_state (camera->video_encodebin, GST_STATE_NULL);
gst_element_set_state (camera->videobin_capsfilter, GST_STATE_NULL);
- location = g_strdup_printf (camera->location, camera->capture_index++);
+ location = g_strdup_printf (camera->location, camera->capture_index);
GST_DEBUG_OBJECT (camera, "Switching videobin location to %s", location);
g_object_set (camera->videosink, "location", location, NULL);
g_free (location);
@@ -495,6 +497,8 @@ gst_camera_bin_src_notify_readyforcapture (GObject * obj, GParamSpec * pspec,
gst_element_set_state (camera->video_encodebin, GST_STATE_PLAYING);
gst_element_set_state (camera->videobin_capsfilter, GST_STATE_PLAYING);
}
+
+ camera->capture_index++;
} else {
if (camera->mode == MODE_VIDEO && camera->audio_src) {
/* FIXME We need to set audiosrc to null to make it resync the ringbuffer
@@ -923,6 +927,8 @@ gst_video_capture_bin_post_video_done (GstCameraBin2 * camera)
static void
gst_camera_bin_handle_message (GstBin * bin, GstMessage * message)
{
+ GstCameraBin2 *camerabin = GST_CAMERA_BIN2_CAST (bin);
+
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_ELEMENT:{
const GstStructure *structure = gst_message_get_structure (message);
@@ -937,6 +943,22 @@ gst_camera_bin_handle_message (GstBin * bin, GstMessage * message)
gst_image_capture_bin_post_image_done (GST_CAMERA_BIN2_CAST (bin),
filename);
}
+ } else if (gst_structure_has_name (structure, "preview-image")) {
+ GValue *value;
+ gchar *location;
+
+ location = camerabin->preview_location_list->data;
+ camerabin->preview_location_list =
+ g_slist_delete_link (camerabin->preview_location_list,
+ camerabin->preview_location_list);
+ GST_DEBUG_OBJECT (camerabin, "Adding preview location to preview "
+ "message '%s'", location);
+
+ value = g_new0 (GValue, 1);
+ g_value_init (value, G_TYPE_STRING);
+ g_value_take_string (value, location);
+ gst_structure_take_value ((GstStructure *) structure, "location",
+ value);
}
}
break;
@@ -1703,6 +1725,10 @@ gst_camera_bin_change_state (GstElement * element, GstStateChange trans)
g_slist_free (camera->image_location_list);
camera->image_location_list = NULL;
+ g_slist_foreach (camera->preview_location_list, (GFunc) g_free, NULL);
+ g_slist_free (camera->preview_location_list);
+ camera->preview_location_list = NULL;
+
/* explicitly set to READY as they might be outside of the bin */
gst_element_set_state (camera->audio_volume, GST_STATE_READY);
gst_element_set_state (camera->audio_capsfilter, GST_STATE_READY);
diff --git a/gst/camerabin2/gstcamerabin2.h b/gst/camerabin2/gstcamerabin2.h
index 46113d037..05af34f4d 100644
--- a/gst/camerabin2/gstcamerabin2.h
+++ b/gst/camerabin2/gstcamerabin2.h
@@ -94,6 +94,9 @@ struct _GstCameraBin2
* each buffer capture */
GSList *image_location_list;
+ /* similar to above, but used for giving names to previews */
+ GSList *preview_location_list;
+
gboolean video_profile_switch;
gboolean image_profile_switch;