mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 16:21:17 +00:00
camerabin: set imagebin to PAUSED on capture and delayed filename setting
We need to set imagebin to PAUSED to not fail the bufferalloc. We also need to keep the filesinks state locked until we have the filename for the run.
This commit is contained in:
parent
1187b88acd
commit
80408b1de2
2 changed files with 25 additions and 6 deletions
|
@ -193,13 +193,22 @@ gst_camerabin_image_change_state (GstElement * element,
|
|||
}
|
||||
/* Allow setting filename when image bin in READY state */
|
||||
gst_element_set_locked_state (img->sink, TRUE);
|
||||
GST_INFO_OBJECT (img, "locking imagebin->sink state to %s",
|
||||
gst_element_state_get_name (GST_STATE (img->sink)));
|
||||
break;
|
||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||
gst_element_set_locked_state (img->sink, FALSE);
|
||||
if (!g_str_equal (img->filename->str, "")) {
|
||||
GST_INFO_OBJECT (img, "preparing image with filename: %s",
|
||||
img->filename->str);
|
||||
gst_element_set_locked_state (img->sink, FALSE);
|
||||
} else {
|
||||
GST_INFO_OBJECT (img, "keep sink locked, we have no filename yet");
|
||||
}
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||
/* Set sink to NULL in order to write the file _now_ */
|
||||
GST_INFO ("write img file: %s", img->filename->str);
|
||||
GST_INFO_OBJECT (img, "write image with filename: %s",
|
||||
img->filename->str);
|
||||
gst_element_set_locked_state (img->sink, TRUE);
|
||||
gst_element_set_state (img->sink, GST_STATE_NULL);
|
||||
break;
|
||||
|
@ -258,11 +267,18 @@ gst_camerabin_image_set_property (GObject * object, guint prop_id,
|
|||
switch (prop_id) {
|
||||
case PROP_FILENAME:
|
||||
g_string_assign (bin->filename, g_value_get_string (value));
|
||||
GST_INFO_OBJECT (bin, "received filename: '%s'", bin->filename->str);
|
||||
if (bin->sink) {
|
||||
g_object_set (G_OBJECT (bin->sink), "location", bin->filename->str,
|
||||
NULL);
|
||||
if (!g_str_equal (bin->filename->str, "")) {
|
||||
g_object_set (G_OBJECT (bin->sink), "location", bin->filename->str,
|
||||
NULL);
|
||||
gst_element_set_locked_state (bin->sink, FALSE);
|
||||
gst_element_sync_state_with_parent (bin->sink);
|
||||
} else {
|
||||
GST_INFO_OBJECT (bin, "empty filename");
|
||||
}
|
||||
} else {
|
||||
GST_INFO ("no sink, not setting name yet");
|
||||
GST_INFO_OBJECT (bin, "no sink, not setting name yet");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -1562,7 +1562,10 @@ gst_camerabin_start_image_capture (GstCameraBin * camera)
|
|||
|
||||
if (!wait_for_prepare) {
|
||||
/* Image queue's srcpad data probe will set imagebin to PLAYING */
|
||||
state_ret = gst_element_set_state (camera->imgbin, GST_STATE_READY);
|
||||
state_ret = gst_element_set_state (camera->imgbin, GST_STATE_PAUSED);
|
||||
GST_DEBUG_OBJECT (camera, "setting imagebin to paused: %s",
|
||||
gst_element_state_change_return_get_name (state_ret));
|
||||
|
||||
if (state_ret != GST_STATE_CHANGE_FAILURE) {
|
||||
g_mutex_lock (camera->capture_mutex);
|
||||
g_object_set (G_OBJECT (camera->src_out_sel), "resend-latest", TRUE,
|
||||
|
|
Loading…
Reference in a new issue