From aaec6a730d7e4680824653cde1030754d37ac107 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Thu, 25 Jun 2009 19:21:47 +0300 Subject: camerabin: sync first test more safely Don't use gst_element_get_state() to wait for PLAYING, Use the bus-handler insteader and asynchronously schedule next test. --- tests/examples/camerabin/gst-camera-perf.c | 41 ++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 8 deletions(-) (limited to 'tests/examples/camerabin') diff --git a/tests/examples/camerabin/gst-camera-perf.c b/tests/examples/camerabin/gst-camera-perf.c index b6424181..f923e1ce 100644 --- a/tests/examples/camerabin/gst-camera-perf.c +++ b/tests/examples/camerabin/gst-camera-perf.c @@ -129,14 +129,14 @@ static GstClockTime target[TEST_CASES] = { static const gchar *test_names[TEST_CASES] = { "Camera OFF to VF on", - "(3A latency)", + "(3A latency)", /* time to get AF? */ "Shot to snapshot", "Shot to shot", "Serial shooting", "(Shutter lag)", "Image saved", "Mode change", - "(Video recording)" + "(Video recording)" /* time to get videobin to PLAYING? or first buffer reaching filesink? */ }; /* @@ -276,6 +276,25 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data) g_main_loop_quit (loop); break; } + case GST_MESSAGE_STATE_CHANGED: + if (GST_MESSAGE_SRC (message) == GST_OBJECT (camera_bin)) { + GstState oldstate, newstate; + + gst_message_parse_state_changed (message, &oldstate, &newstate, NULL); + GST_INFO ("state-changed: %s -> %s", + gst_element_state_get_name (oldstate), + gst_element_state_get_name (newstate)); + if (GST_STATE_TRANSITION (oldstate, + newstate) == GST_STATE_CHANGE_PAUSED_TO_PLAYING) { + GET_TIME (t_final[0]); + DIFF_TIME (t_final[0], t_initial, diff); + + result.avg = result.min = result.max = diff; + print_result (); + g_idle_add ((GSourceFunc) run_test, NULL); + } + } + break; case GST_MESSAGE_EOS: /* end-of-stream */ g_main_loop_quit (loop); @@ -466,19 +485,25 @@ error: static gboolean test_01 (void) { + gboolean res; + GET_TIME (t_initial); if (setup_pipeline ()) { /* MAKE SURE THE PIPELINE IS IN PLAYING STATE BEFORE START TAKING PICTURES AND SO ON (otherwise it will deadlock) */ - gst_element_get_state (camera_bin, NULL, NULL, GST_CLOCK_TIME_NONE); - } - GET_TIME (t_final[0]); - DIFF_TIME (t_final[0], t_initial, diff); + //gst_element_get_state (camera_bin, NULL, NULL, GST_CLOCK_TIME_NONE); + /* the actual results are fetched in bus_callback::state-changed */ + res = FALSE; + } else { + GET_TIME (t_final[0]); + DIFF_TIME (t_final[0], t_initial, diff); - result.avg = result.min = result.max = diff; + result.avg = result.min = result.max = diff; + res = TRUE; + } result.times = 1; - return TRUE; + return res; } -- cgit v1.2.1 From e4bc1e31ef85c71e1d8b1ca8bf4db9c74b066a07 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Fri, 26 Jun 2009 16:07:43 +0300 Subject: camerabin: make shot2shot test more reliable We can only trigger next shot (in the test) when current is captured and saved. --- tests/examples/camerabin/gst-camera-perf.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'tests/examples/camerabin') diff --git a/tests/examples/camerabin/gst-camera-perf.c b/tests/examples/camerabin/gst-camera-perf.c index f923e1ce..858e60cd 100644 --- a/tests/examples/camerabin/gst-camera-perf.c +++ b/tests/examples/camerabin/gst-camera-perf.c @@ -105,7 +105,9 @@ static guint test_ix = 0; static gboolean signal_sink = FALSE; static gboolean signal_shot = FALSE; static gboolean signal_cont = FALSE; -//static gboolean signal_save = FALSE; + +static gboolean have_img_captured = FALSE; +static gboolean have_img_done = FALSE; /* time samples and test results */ static GstClockTime t_initial = G_GUINT64_CONSTANT (0); @@ -199,7 +201,14 @@ img_capture_done (GstElement * camera, GString * fname, gpointer user_data) GST_INFO ("%2d cont new filename '%s'", test_ix, filename->str); g_object_set (camera_bin, "filename", filename->str, NULL); // FIXME: is burst capture broken? new filename and return TRUE should be enough - g_signal_emit_by_name (camera_bin, "user-start", NULL); + // as a workaround we will kick next image from here + // but this needs sync so that we have received "image-captured" message already + if (have_img_captured) { + have_img_captured = FALSE; + g_signal_emit_by_name (camera_bin, "user-start", NULL); + } else { + have_img_done = TRUE; + } ret = TRUE; } else { GstClockTime max = 0; @@ -310,6 +319,15 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data) DIFF_TIME (t_final[num_pics_cont], t_initial, diff); result.avg = result.min = result.max = diff; break; + case 4: + // we need to have this received before we can take next one + if (have_img_done) { + have_img_done = FALSE; + g_signal_emit_by_name (camera_bin, "user-start", NULL); + } else { + have_img_captured = TRUE; + } + break; } } else if (gst_structure_has_name (st, "preview-image")) { GST_INFO ("%2d preview-image", test_ix); @@ -337,8 +355,8 @@ static void cleanup_pipeline (void) { if (camera_bin) { + GST_INFO_OBJECT (camera_bin, "stopping and destroying"); gst_element_set_state (camera_bin, GST_STATE_NULL); - gst_element_get_state (camera_bin, NULL, NULL, GST_CLOCK_TIME_NONE); gst_object_unref (camera_bin); camera_bin = NULL; } @@ -465,6 +483,7 @@ setup_pipeline (void) g_warning ("can't set camerabin to playing\n"); goto error; } + GST_INFO_OBJECT (camera_bin, "created and started"); return TRUE; error: cleanup_pipeline (); @@ -553,6 +572,7 @@ static gboolean test_05 (void) { signal_cont = TRUE; + have_img_captured = have_img_done = FALSE; GET_TIME (t_initial); g_signal_emit_by_name (camera_bin, "user-start", 0); @@ -570,7 +590,6 @@ test_05 (void) static gboolean test_07 (void) { - // signal_save = TRUE; signal_shot = TRUE; GET_TIME (t_initial); -- cgit v1.2.1