mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
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:
parent
8ba4f9178f
commit
a34ea4aaae
1 changed files with 21 additions and 12 deletions
|
@ -232,7 +232,7 @@ gst_camera_bin_start_capture (GstCameraBin2 * camerabin)
|
||||||
GST_DEBUG_OBJECT (camerabin, "Received start-capture");
|
GST_DEBUG_OBJECT (camerabin, "Received start-capture");
|
||||||
|
|
||||||
/* check that we have a valid location */
|
/* 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,
|
GST_ELEMENT_ERROR (camerabin, RESOURCE, OPEN_WRITE,
|
||||||
(_("File location is set to NULL, please set it to a valid filename")),
|
(_("File location is set to NULL, please set it to a valid filename")),
|
||||||
(NULL));
|
(NULL));
|
||||||
|
@ -256,9 +256,10 @@ gst_camera_bin_start_capture (GstCameraBin2 * camerabin)
|
||||||
gst_element_sync_state_with_parent (camerabin->audio_volume);
|
gst_element_sync_state_with_parent (camerabin->audio_volume);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gchar *location;
|
gchar *location = NULL;
|
||||||
|
|
||||||
/* store the next capture buffer filename */
|
/* store the next capture buffer filename */
|
||||||
|
if (camerabin->location)
|
||||||
location =
|
location =
|
||||||
g_strdup_printf (camerabin->location, camerabin->capture_index++);
|
g_strdup_printf (camerabin->location, camerabin->capture_index++);
|
||||||
camerabin->image_location_list =
|
camerabin->image_location_list =
|
||||||
|
@ -978,6 +979,7 @@ static gboolean
|
||||||
gst_camera_bin_image_src_buffer_probe (GstPad * pad, GstBuffer * buf,
|
gst_camera_bin_image_src_buffer_probe (GstPad * pad, GstBuffer * buf,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
gboolean ret = TRUE;
|
||||||
GstCameraBin2 *camerabin = data;
|
GstCameraBin2 *camerabin = data;
|
||||||
GstEvent *evt;
|
GstEvent *evt;
|
||||||
gchar *location = NULL;
|
gchar *location = NULL;
|
||||||
|
@ -988,20 +990,27 @@ gst_camera_bin_image_src_buffer_probe (GstPad * pad, GstBuffer * buf,
|
||||||
camerabin->image_location_list =
|
camerabin->image_location_list =
|
||||||
g_slist_delete_link (camerabin->image_location_list,
|
g_slist_delete_link (camerabin->image_location_list,
|
||||||
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);
|
location);
|
||||||
} else {
|
} else {
|
||||||
GST_DEBUG_OBJECT (camerabin, "No filename location change to send");
|
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);
|
evt = gst_camera_bin_new_event_file_location (location);
|
||||||
peer = gst_pad_get_peer (pad);
|
peer = gst_pad_get_peer (pad);
|
||||||
gst_pad_send_event (peer, evt);
|
gst_pad_send_event (peer, evt);
|
||||||
g_free (location);
|
|
||||||
gst_object_unref (peer);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue