mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 05:31:15 +00:00
camerabin2: Improve idle property usage
Use resource warning messages to notify camerabin2 that a capture as aborted or couldn't be started, making it decrement the processing counter and making the idle property more reliable.
This commit is contained in:
parent
6913db30f8
commit
aa7b962891
3 changed files with 32 additions and 10 deletions
|
@ -252,6 +252,9 @@ gst_base_camera_src_start_capture (GstBaseCameraSrc * src)
|
||||||
if (src->capturing) {
|
if (src->capturing) {
|
||||||
GST_WARNING_OBJECT (src, "Capturing already ongoing");
|
GST_WARNING_OBJECT (src, "Capturing already ongoing");
|
||||||
g_mutex_unlock (src->capturing_mutex);
|
g_mutex_unlock (src->capturing_mutex);
|
||||||
|
|
||||||
|
/* post a warning to notify camerabin2 that the capture failed */
|
||||||
|
GST_ELEMENT_WARNING (src, RESOURCE, BUSY, (NULL), (NULL));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -691,20 +691,36 @@ gst_image_capture_bin_post_image_done (GstCameraBin * camera,
|
||||||
static void
|
static void
|
||||||
gst_camera_bin_handle_message (GstBin * bin, GstMessage * message)
|
gst_camera_bin_handle_message (GstBin * bin, GstMessage * message)
|
||||||
{
|
{
|
||||||
if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) {
|
switch (GST_MESSAGE_TYPE (message)) {
|
||||||
const GstStructure *structure = gst_message_get_structure (message);
|
case GST_MESSAGE_ELEMENT:{
|
||||||
const gchar *filename;
|
const GstStructure *structure = gst_message_get_structure (message);
|
||||||
|
const gchar *filename;
|
||||||
|
|
||||||
if (gst_structure_has_name (structure, "GstMultiFileSink")) {
|
if (gst_structure_has_name (structure, "GstMultiFileSink")) {
|
||||||
GST_CAMERA_BIN_PROCESSING_DEC (GST_CAMERA_BIN_CAST (bin));
|
GST_CAMERA_BIN_PROCESSING_DEC (GST_CAMERA_BIN_CAST (bin));
|
||||||
filename = gst_structure_get_string (structure, "filename");
|
filename = gst_structure_get_string (structure, "filename");
|
||||||
if (filename) {
|
if (filename) {
|
||||||
gst_image_capture_bin_post_image_done (GST_CAMERA_BIN_CAST (bin),
|
gst_image_capture_bin_post_image_done (GST_CAMERA_BIN_CAST (bin),
|
||||||
filename);
|
filename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case GST_MESSAGE_WARNING:{
|
||||||
|
GError *err = NULL;
|
||||||
|
gchar *debug = NULL;
|
||||||
|
|
||||||
|
gst_message_parse_warning (message, &err, &debug);
|
||||||
|
if (err->domain == GST_RESOURCE_ERROR) {
|
||||||
|
/* some capturing failed */
|
||||||
|
GST_CAMERA_BIN_PROCESSING_DEC (GST_CAMERA_BIN_CAST (bin));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
GST_BIN_CLASS (parent_class)->handle_message (bin, message);
|
if (message)
|
||||||
|
GST_BIN_CLASS (parent_class)->handle_message (bin, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1059,6 +1059,8 @@ GST_START_TEST (test_idle_property)
|
||||||
|
|
||||||
/* emit a second start-capture that should be ignored */
|
/* emit a second start-capture that should be ignored */
|
||||||
g_signal_emit_by_name (camera, "start-capture", NULL);
|
g_signal_emit_by_name (camera, "start-capture", NULL);
|
||||||
|
g_object_get (camera, "idle", &idle, NULL);
|
||||||
|
fail_unless (!idle);
|
||||||
|
|
||||||
/* Record for one seconds */
|
/* Record for one seconds */
|
||||||
g_timeout_add_seconds (VIDEO_DURATION, (GSourceFunc) g_main_loop_quit,
|
g_timeout_add_seconds (VIDEO_DURATION, (GSourceFunc) g_main_loop_quit,
|
||||||
|
@ -1069,6 +1071,7 @@ GST_START_TEST (test_idle_property)
|
||||||
|
|
||||||
check_preview_image ();
|
check_preview_image ();
|
||||||
|
|
||||||
|
g_usleep (3 * G_USEC_PER_SEC);
|
||||||
g_object_get (camera, "idle", &idle, NULL);
|
g_object_get (camera, "idle", &idle, NULL);
|
||||||
fail_unless (idle);
|
fail_unless (idle);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue