camerabin2: If location is NULL do not encode images

Using a NULL string for location means that the application
doesn't want the image to be encoded, but wants to receive
the preview image. (Only works for image captures)

Useful for application that want the capture in memory only, like
displaying to the user before it choses to encode or take another
picture in avatar capturing scenarios.

https://bugzilla.gnome.org/show_bug.cgi?id=641918
This commit is contained in:
Thiago Santos 2011-07-22 11:38:30 +03:00
parent 8ba4f9178f
commit a34ea4aaae

View file

@ -232,7 +232,7 @@ gst_camera_bin_start_capture (GstCameraBin2 * camerabin)
GST_DEBUG_OBJECT (camerabin, "Received start-capture");
/* check that we have a valid location */
if (camerabin->location == NULL) {
if (camerabin->mode == MODE_VIDEO && camerabin->location == NULL) {
GST_ELEMENT_ERROR (camerabin, RESOURCE, OPEN_WRITE,
(_("File location is set to NULL, please set it to a valid filename")),
(NULL));
@ -256,9 +256,10 @@ gst_camera_bin_start_capture (GstCameraBin2 * camerabin)
gst_element_sync_state_with_parent (camerabin->audio_volume);
}
} else {
gchar *location;
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 =
@ -978,6 +979,7 @@ static gboolean
gst_camera_bin_image_src_buffer_probe (GstPad * pad, GstBuffer * buf,
gpointer data)
{
gboolean ret = TRUE;
GstCameraBin2 *camerabin = data;
GstEvent *evt;
gchar *location = NULL;
@ -988,20 +990,27 @@ gst_camera_bin_image_src_buffer_probe (GstPad * pad, GstBuffer * buf,
camerabin->image_location_list =
g_slist_delete_link (camerabin->image_location_list,
camerabin->image_location_list);
GST_DEBUG_OBJECT (camerabin, "Sending image location change to %s",
GST_DEBUG_OBJECT (camerabin, "Sending image location change to '%s'",
location);
} else {
GST_DEBUG_OBJECT (camerabin, "No filename location change to send");
return TRUE;
return ret;
}
if (location) {
evt = gst_camera_bin_new_event_file_location (location);
peer = gst_pad_get_peer (pad);
gst_pad_send_event (peer, evt);
g_free (location);
gst_object_unref (peer);
g_free (location);
} else {
/* This means we don't have to encode the capture, it is used for
* signaling the application just wants the preview */
ret = FALSE;
GST_CAMERA_BIN2_PROCESSING_DEC (camerabin);
}
return TRUE;
return ret;
}