diff options
author | Dave Robillard <dave@drobilla.net> | 2009-07-03 20:01:36 -0400 |
---|---|---|
committer | Dave Robillard <dave@drobilla.net> | 2009-07-03 20:01:36 -0400 |
commit | e289c875a5e0ee56dd8289e78b63f36f709b6534 (patch) | |
tree | 9bd2b450261bbc0fa522bf27d9a89d017308687e /tests | |
parent | ed06ed3b658b49b1313df38909bcb2f907be83a7 (diff) | |
parent | caba48f261421d397900471b19350da2e5a4a4e5 (diff) | |
download | gst-plugins-bad-e289c875a5e0ee56dd8289e78b63f36f709b6534.tar.gz gst-plugins-bad-e289c875a5e0ee56dd8289e78b63f36f709b6534.tar.bz2 gst-plugins-bad-e289c875a5e0ee56dd8289e78b63f36f709b6534.zip |
Merge branch 'fdo' into lv2
Diffstat (limited to 'tests')
-rw-r--r-- | tests/check/elements/rtpbin.c | 84 | ||||
-rw-r--r-- | tests/examples/Makefile.am | 2 | ||||
-rw-r--r-- | tests/examples/camerabin/gst-camera-perf.c | 68 |
3 files changed, 141 insertions, 13 deletions
diff --git a/tests/check/elements/rtpbin.c b/tests/check/elements/rtpbin.c index bc30c918..8764da54 100644 --- a/tests/check/elements/rtpbin.c +++ b/tests/check/elements/rtpbin.c @@ -306,6 +306,89 @@ GST_START_TEST (test_cleanup_recv) GST_END_TEST; +GST_START_TEST (test_cleanup_recv2) +{ + GstElement *rtpbin; + GstPad *rtp_sink; + CleanupData data; + GstStateChangeReturn ret; + GstFlowReturn res; + GstBuffer *buffer; + gint count = 2; + + init_data (&data); + + rtpbin = gst_element_factory_make ("gstrtpbin", "rtpbin"); + + g_signal_connect (rtpbin, "pad-added", (GCallback) pad_added_cb, &data); + g_signal_connect (rtpbin, "pad-removed", (GCallback) pad_removed_cb, &data); + + ret = gst_element_set_state (rtpbin, GST_STATE_PLAYING); + fail_unless (ret == GST_STATE_CHANGE_SUCCESS); + + /* request session 0 */ + rtp_sink = gst_element_get_request_pad (rtpbin, "recv_rtp_sink_0"); + fail_unless (rtp_sink != NULL); + ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 2); + + while (count--) { + /* no sourcepads are created yet */ + fail_unless (rtpbin->numsinkpads == 1); + fail_unless (rtpbin->numsrcpads == 0); + + buffer = make_rtp_packet (&data); + res = gst_pad_chain (rtp_sink, buffer); + GST_DEBUG ("res %d, %s\n", res, gst_flow_get_name (res)); + fail_unless (res == GST_FLOW_OK); + + buffer = make_rtp_packet (&data); + res = gst_pad_chain (rtp_sink, buffer); + GST_DEBUG ("res %d, %s\n", res, gst_flow_get_name (res)); + fail_unless (res == GST_FLOW_OK); + + /* we wait for the new pad to appear now */ + g_mutex_lock (data.lock); + while (!data.pad_added) + g_cond_wait (data.cond, data.lock); + g_mutex_unlock (data.lock); + + /* sourcepad created now */ + fail_unless (rtpbin->numsinkpads == 1); + fail_unless (rtpbin->numsrcpads == 1); + + /* change state */ + ret = gst_element_set_state (rtpbin, GST_STATE_NULL); + fail_unless (ret == GST_STATE_CHANGE_SUCCESS); + + /* pad should be gone now */ + g_mutex_lock (data.lock); + while (data.pad_added) + g_cond_wait (data.cond, data.lock); + g_mutex_unlock (data.lock); + + /* back to playing for the next round */ + ret = gst_element_set_state (rtpbin, GST_STATE_PLAYING); + fail_unless (ret == GST_STATE_CHANGE_SUCCESS); + } + + /* remove the session */ + gst_element_release_request_pad (rtpbin, rtp_sink); + gst_object_unref (rtp_sink); + + /* nothing left anymore now */ + fail_unless (rtpbin->numsinkpads == 0); + fail_unless (rtpbin->numsrcpads == 0); + + ret = gst_element_set_state (rtpbin, GST_STATE_NULL); + fail_unless (ret == GST_STATE_CHANGE_SUCCESS); + + gst_object_unref (rtpbin); + + clean_data (&data); +} + +GST_END_TEST; + Suite * gstrtpbin_suite (void) { @@ -315,6 +398,7 @@ gstrtpbin_suite (void) suite_add_tcase (s, tc_chain); tcase_add_test (tc_chain, test_cleanup_send); tcase_add_test (tc_chain, test_cleanup_recv); + tcase_add_test (tc_chain, test_cleanup_recv2); return s; } diff --git a/tests/examples/Makefile.am b/tests/examples/Makefile.am index 45d94378..42ffa481 100644 --- a/tests/examples/Makefile.am +++ b/tests/examples/Makefile.am @@ -11,4 +11,4 @@ DIRECTFB_DIR= endif SUBDIRS= $(DIRECTFB_DIR) $(GTK_EXAMPLES) shapewipe switch -DIST_SUBDIRS= directfb mxf scaletempo shapewipe switch +DIST_SUBDIRS= camerabin directfb mxf scaletempo shapewipe switch diff --git a/tests/examples/camerabin/gst-camera-perf.c b/tests/examples/camerabin/gst-camera-perf.c index b6424181..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); @@ -129,14 +131,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? */ }; /* @@ -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; @@ -276,6 +285,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); @@ -291,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); @@ -318,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; } @@ -446,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 (); @@ -466,19 +504,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; } @@ -528,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); @@ -545,7 +590,6 @@ test_05 (void) static gboolean test_07 (void) { - // signal_save = TRUE; signal_shot = TRUE; GET_TIME (t_initial); |