From 5c112d4286553aa07615faad518839fdc3c39e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 4 Jun 2009 08:56:14 +0200 Subject: shapewipe: Increase timeout of the unit test --- tests/check/elements/shapewipe.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/check/elements/shapewipe.c b/tests/check/elements/shapewipe.c index 6fcb0698..d0ec63f9 100644 --- a/tests/check/elements/shapewipe.c +++ b/tests/check/elements/shapewipe.c @@ -298,6 +298,7 @@ shapewipe_suite (void) TCase *tc_chain = tcase_create ("general"); suite_add_tcase (s, tc_chain); + tcase_set_timeout (tc_chain, 180); tcase_add_test (tc_chain, test_general); return s; -- cgit v1.2.1 From 6a47f6f594740e28dcf9176fb88260114a94f8b3 Mon Sep 17 00:00:00 2001 From: Lasse Laukkanen Date: Wed, 27 May 2009 11:33:01 +0300 Subject: camerabin: preview image sending optimization * decouple image capturing from image post-processing and encoding * post image-captured message after image is captured * post preview-image message with snapshot of captured image --- tests/check/elements/camerabin.c | 185 ++++++++++++++++++++++----------------- 1 file changed, 104 insertions(+), 81 deletions(-) (limited to 'tests') diff --git a/tests/check/elements/camerabin.c b/tests/check/elements/camerabin.c index 7c6187d2..2b72c6ff 100644 --- a/tests/check/elements/camerabin.c +++ b/tests/check/elements/camerabin.c @@ -40,13 +40,11 @@ #define MAX_BURST_IMAGES 10 #define PHOTO_SETTING_DELAY_US 0 -static gboolean continuous = FALSE; -static guint captured_images = 0; - static GstElement *camera; static GCond *cam_cond; static GMutex *cam_mutex; - +static GMainLoop *main_loop; +static guint cycle_count = 0; /* helper function for filenames */ static const gchar * @@ -61,6 +59,8 @@ make_test_file_name (const gchar * base_name) return file_name; } +/* burst capture is not supported in camerabin for the moment */ +#ifdef ENABLE_BURST_CAPTURE static const gchar * make_test_seq_file_name (const gchar * base_name) { @@ -72,30 +72,49 @@ make_test_seq_file_name (const gchar * base_name) GST_INFO ("capturing to: %s", file_name); return file_name; } - +#endif /* signal handlers */ static gboolean -capture_done (GstElement * elem, const gchar * filename, gpointer user_data) +handle_image_captured_cb (gpointer data) { - captured_images++; - - if (captured_images >= MAX_BURST_IMAGES) { - /* release the shutter button */ - GST_DEBUG ("signal for img-done"); - g_mutex_lock (cam_mutex); - g_cond_signal (cam_cond); - g_mutex_unlock (cam_mutex); - continuous = FALSE; - } + GMainLoop *loop = (GMainLoop *) data; + + GST_DEBUG ("handle_image_captured_cb, cycle: %d", cycle_count); + if (cycle_count == 0) { + g_main_loop_quit (loop); + } else { + /* Set video recording mode */ + g_object_set (camera, "mode", 1, + "filename", make_test_file_name (CYCLE_VIDEO_FILENAME), NULL); + /* Record video */ + g_signal_emit_by_name (camera, "user-start", 0); + g_usleep (G_USEC_PER_SEC); + g_signal_emit_by_name (camera, "user-stop", 0); + GST_DEBUG ("video captured"); + + /* Set still image mode */ + g_object_set (camera, "mode", 0, + "filename", make_test_file_name (CYCLE_IMAGE_FILENAME), NULL); + /* Take a picture */ + g_signal_emit_by_name (camera, "user-start", 0); - if (continuous) { - /* Must set filename for new picture */ - g_object_set (G_OBJECT (elem), "filename", - make_test_seq_file_name (BURST_IMAGE_FILENAME), NULL); + cycle_count--; } + GST_DEBUG ("handle_image_captured_cb done"); + return FALSE; +} + +static gboolean +capture_done (GstElement * elem, const gchar * filename, gpointer user_data) +{ + GMainLoop *loop = (GMainLoop *) user_data; - return continuous; + g_idle_add ((GSourceFunc) handle_image_captured_cb, loop); + + GST_DEBUG ("image saved"); + + return FALSE; } /* configuration */ @@ -103,7 +122,8 @@ capture_done (GstElement * elem, const gchar * filename, gpointer user_data) static void setup_camerabin_elements (GstElement * camera) { - GstElement *vfsink, *audiosrc, *videosrc; + GstElement *vfsink, *audiosrc, *videosrc, *audioenc, *videoenc, *imageenc, + *videomux; /* Use fakesink for view finder */ vfsink = gst_element_factory_make ("fakesink", NULL); @@ -111,9 +131,42 @@ setup_camerabin_elements (GstElement * camera) g_object_set (audiosrc, "is-live", TRUE, NULL); videosrc = gst_element_factory_make ("videotestsrc", NULL); g_object_set (videosrc, "is-live", TRUE, NULL); + audioenc = gst_element_factory_make ("vorbisenc", NULL); + videoenc = gst_element_factory_make ("theoraenc", NULL); + videomux = gst_element_factory_make ("oggmux", NULL); + imageenc = gst_element_factory_make ("jpegenc", NULL); + + if (vfsink && audiosrc && videosrc && audioenc && videoenc && videomux + && imageenc) { + g_object_set (camera, "vfsink", vfsink, "audiosrc", audiosrc, "videosrc", + videosrc, "audioenc", audioenc, "videoenc", videoenc, "imageenc", + imageenc, "videomux", videomux, NULL); + } +} + +static gboolean +capture_bus_cb (GstBus * bus, GstMessage * message, gpointer data) +{ + GMainLoop *loop = (GMainLoop *) data; + const GstStructure *st; - g_object_set (camera, "vfsink", vfsink, "audiosrc", audiosrc, - "videosrc", videosrc, NULL); + switch (GST_MESSAGE_TYPE (message)) { + case GST_MESSAGE_ERROR: + fail_if (TRUE, "error while capturing"); + g_main_loop_quit (loop); + break; + case GST_MESSAGE_EOS: + GST_DEBUG ("eos"); + g_main_loop_quit (loop); + break; + default: + st = gst_message_get_structure (message); + if (st && gst_structure_has_name (st, "image-captured")) { + GST_DEBUG ("image-captured"); + } + break; + } + return TRUE; } static void @@ -121,6 +174,10 @@ setup (void) { GstTagSetter *setter; gchar *desc_str; + GstCaps *filter_caps; + GstBus *bus; + + main_loop = g_main_loop_new (NULL, TRUE); cam_cond = g_cond_new (); cam_mutex = g_mutex_new (); @@ -129,9 +186,15 @@ setup (void) setup_camerabin_elements (camera); - g_signal_connect (camera, "img-done", G_CALLBACK (capture_done), NULL); + g_signal_connect (camera, "img-done", G_CALLBACK (capture_done), main_loop); + + bus = gst_pipeline_get_bus (GST_PIPELINE (camera)); + gst_bus_add_watch (bus, (GstBusFunc) capture_bus_cb, main_loop); + gst_object_unref (bus); - captured_images = 0; + filter_caps = gst_caps_from_string ("video/x-raw-yuv,format=(fourcc)I420"); + g_object_set (G_OBJECT (camera), "filter-caps", filter_caps, NULL); + gst_caps_unref (filter_caps); /* Set some default tags */ setter = GST_TAG_SETTER (camera); @@ -141,8 +204,8 @@ setup (void) GST_TAG_DESCRIPTION, desc_str, NULL); g_free (desc_str); - if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) != - GST_STATE_CHANGE_SUCCESS) { + if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) == + GST_STATE_CHANGE_FAILURE) { gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL); gst_object_unref (camera); camera = NULL; @@ -314,39 +377,13 @@ GST_START_TEST (test_single_image_capture) g_object_set (camera, "mode", 0, "filename", make_test_file_name (SINGLE_IMAGE_FILENAME), NULL); - continuous = FALSE; - /* Test photography iface settings */ gst_element_get_state (GST_ELEMENT (camera), NULL, NULL, (2 * GST_SECOND)); test_photography_settings (camera); - g_signal_emit_by_name (camera, "user-start", 0); - g_signal_emit_by_name (camera, "user-stop", 0); -} - -GST_END_TEST; - -GST_START_TEST (test_burst_image_capture) -{ - if (!camera) - return; - - /* set still image mode */ - g_object_set (camera, "mode", 0, - "filename", make_test_seq_file_name (BURST_IMAGE_FILENAME), NULL); - - /* set burst mode */ - continuous = TRUE; - g_signal_emit_by_name (camera, "user-start", 0); - GST_DEBUG ("waiting for img-done"); - g_mutex_lock (cam_mutex); - g_cond_wait (cam_cond, cam_mutex); - g_mutex_unlock (cam_mutex); - GST_DEBUG ("received img-done"); - - g_signal_emit_by_name (camera, "user-stop", 0); + g_main_loop_run (main_loop); } GST_END_TEST; @@ -370,48 +407,35 @@ GST_END_TEST; GST_START_TEST (test_image_video_cycle) { - guint i; - if (!camera) return; - continuous = FALSE; - - for (i = 0; i < 2; i++) { - /* Set still image mode */ - g_object_set (camera, "mode", 0, - "filename", make_test_file_name (CYCLE_IMAGE_FILENAME), NULL); + cycle_count = 2; - /* Take a picture */ - g_signal_emit_by_name (camera, "user-start", 0); - g_signal_emit_by_name (camera, "user-stop", 0); - GST_DEBUG ("image captured"); + /* set still image mode */ + g_object_set (camera, "mode", 0, + "filename", make_test_file_name (CYCLE_IMAGE_FILENAME), NULL); - /* Set video recording mode */ - g_object_set (camera, "mode", 1, - "filename", make_test_file_name (CYCLE_VIDEO_FILENAME), NULL); + g_signal_emit_by_name (camera, "user-start", 0); - /* Record video */ - g_signal_emit_by_name (camera, "user-start", 0); - g_usleep (G_USEC_PER_SEC); - g_signal_emit_by_name (camera, "user-stop", 0); - GST_DEBUG ("video captured"); - } + g_main_loop_run (main_loop); } GST_END_TEST; GST_START_TEST (validate_captured_image_files) { - GString *filename; - gint i; - if (!camera) return; /* validate single image */ check_file_validity (SINGLE_IMAGE_FILENAME); +/* burst capture is not supported in camerabin for the moment */ +#ifdef ENABLE_BURST_CAPTURE + GString *filename; + gint i; + /* validate burst mode images */ filename = g_string_new (""); for (i = 0; i < MAX_BURST_IMAGES; i++) { @@ -419,7 +443,7 @@ GST_START_TEST (validate_captured_image_files) check_file_validity (filename->str); } g_string_free (filename, TRUE); - +#endif /* validate cycled image */ check_file_validity (CYCLE_IMAGE_FILENAME); } @@ -453,7 +477,6 @@ camerabin_suite (void) tcase_set_timeout (tc_basic, 20); tcase_add_checked_fixture (tc_basic, setup, teardown); tcase_add_test (tc_basic, test_single_image_capture); - tcase_add_test (tc_basic, test_burst_image_capture); tcase_add_test (tc_basic, test_video_recording); tcase_add_test (tc_basic, test_image_video_cycle); -- cgit v1.2.1 From 4d9a0e832cfc69c612e32902017390560024cd7e Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Fri, 5 Jun 2009 21:17:55 +0300 Subject: camerabin: fix link order Move local version up in the link order. --- tests/check/Makefile.am | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index cbc228e2..940d1f4b 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -108,9 +108,10 @@ AM_CFLAGS = $(GST_OBJ_CFLAGS) $(GST_CHECK_CFLAGS) $(CHECK_CFLAGS) $(GST_OPTION_ LDADD = $(GST_OBJ_LIBS) $(GST_CHECK_LIBS) $(CHECK_LIBS) elements_camerabin_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CHECK_CFLAGS) -elements_camerabin_LDADD = $(GST_LIBS) $(GST_BASE_LIBS) $(GST_CHECK_LIBS) \ - -lgstinterfaces-@GST_MAJORMINOR@ \ - $(top_builddir)/gst-libs/gst/interfaces/libgstphotography-@GST_MAJORMINOR@.la +elements_camerabin_LDADD = \ + $(top_builddir)/gst-libs/gst/interfaces/libgstphotography-@GST_MAJORMINOR@.la \ + $(GST_LIBS) $(GST_BASE_LIBS) $(GST_CHECK_LIBS) \ + -lgstinterfaces-@GST_MAJORMINOR@ elements_camerabin_SOURCES = elements/camerabin.c elements_timidity_CFLAGS = $(GST_BASE_CFLAGS) $(AM_CFLAGS) -- cgit v1.2.1 From 271788c9ae2a5126994d9dc45e777c3b15f3b802 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Fri, 5 Jun 2009 19:32:26 +0100 Subject: Moved 'x264enc' from -bad to -ugly --- tests/check/Makefile.am | 11 +---------- tests/check/elements/.gitignore | 1 - 2 files changed, 1 insertion(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index 940d1f4b..bc2d8fd0 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -63,17 +63,9 @@ else check_timidity= endif -if USE_X264 -check_x264enc=elements/x264enc -else -check_x264enc= -endif - - VALGRIND_TO_FIX = \ elements/mpeg2enc \ - elements/mplex \ - elements/x264enc + elements/mplex # valgrind testing VALGRIND_TESTS_DISABLE = \ @@ -86,7 +78,6 @@ check_PROGRAMS = \ $(check_neon) \ $(check_ofa) \ $(check_timidity) \ - $(check_x264enc) \ elements/aacparse \ elements/amrparse \ elements/camerabin \ diff --git a/tests/check/elements/.gitignore b/tests/check/elements/.gitignore index 091fb4e5..e97fc57f 100644 --- a/tests/check/elements/.gitignore +++ b/tests/check/elements/.gitignore @@ -26,5 +26,4 @@ videocrop wavpackdec wavpackenc wavpackparse -x264enc y4menc -- cgit v1.2.1 From 743bd6cc1049de0d29616645b468da031b5c8c01 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Fri, 5 Jun 2009 19:53:09 +0100 Subject: gitignore: Ignore shapewipe unit test binary --- tests/check/elements/.gitignore | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/check/elements/.gitignore b/tests/check/elements/.gitignore index e97fc57f..5f268d3b 100644 --- a/tests/check/elements/.gitignore +++ b/tests/check/elements/.gitignore @@ -20,6 +20,7 @@ rglimiter rgvolume rtpbin selector +shapewipe spectrum timidity videocrop -- cgit v1.2.1 From 833a81af75c5b2303231fd3c523616176c43db40 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Sat, 6 Jun 2009 13:53:04 +0100 Subject: examples: Don't build the mxf example if GTK isn't present. --- tests/examples/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/examples/Makefile.am b/tests/examples/Makefile.am index b36232de..e68204e3 100644 --- a/tests/examples/Makefile.am +++ b/tests/examples/Makefile.am @@ -1,5 +1,5 @@ if HAVE_GTK -GTK_EXAMPLES=scaletempo +GTK_EXAMPLES=scaletempo mxf else GTK_EXAMPLES= endif @@ -10,5 +10,5 @@ else DIRECTFB_DIR= endif -SUBDIRS= $(DIRECTFB_DIR) $(GTK_EXAMPLES) switch shapewipe mxf +SUBDIRS= $(DIRECTFB_DIR) $(GTK_EXAMPLES) switch shapewipe DIST_SUBDIRS= directfb switch scaletempo shapewipe mxf -- cgit v1.2.1 From 34100ce1c702207c12d5e339d668572b06778d6c Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Sun, 7 Jun 2009 10:55:59 +0200 Subject: tests/metadata: Don't try tags we can't handle. Fixes #584945 --- tests/check/pipelines/metadata.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/check/pipelines/metadata.c b/tests/check/pipelines/metadata.c index a632df44..1a16a4a7 100644 --- a/tests/check/pipelines/metadata.c +++ b/tests/check/pipelines/metadata.c @@ -190,7 +190,13 @@ test_tags (const gchar * tag_str) GST_START_TEST (test_common_tags) { + /* The title tag will only work if the XMP backend is enabled. + * And since we don't have any programmatic feedback on whether + * a tag is properly handled or not... we need to do this kind + * of hack. */ +#if HAVE_XMP test_tags ("taglist,title=\"test image\""); +#endif } GST_END_TEST; -- cgit v1.2.1 From 1658384381a7e6e253bcab6106417c7502b7cec8 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Fri, 12 Jun 2009 10:29:20 +0300 Subject: camerabin: cleanups in the tests Sprinkle more logging to make it easier to follow. Specify a low framerate and capture resolution to avoid tests timing out. Make the sinks sync to test closer to reality. Fix Makefile to use uninstalled interface. --- tests/check/Makefile.am | 7 +++-- tests/check/elements/camerabin.c | 63 ++++++++++++++++++++++++++++++---------- 2 files changed, 52 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index bc2d8fd0..3791b753 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -95,10 +95,13 @@ noinst_HEADERS = elements/mxfdemux.h elements/amrparse_data.h elements/aacparse_ TESTS = $(check_PROGRAMS) -AM_CFLAGS = $(GST_OBJ_CFLAGS) $(GST_CHECK_CFLAGS) $(CHECK_CFLAGS) $(GST_OPTION_CFLAGS) +AM_CFLAGS = $(GST_OBJ_CFLAGS) $(GST_CHECK_CFLAGS) $(CHECK_CFLAGS) $(GST_OPTION_CFLAGS) LDADD = $(GST_OBJ_LIBS) $(GST_CHECK_LIBS) $(CHECK_LIBS) -elements_camerabin_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CHECK_CFLAGS) +elements_camerabin_CFLAGS = \ + -I$(top_builddir)/gst-libs \ + $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CHECK_CFLAGS) \ + -DGST_USE_UNSTABLE_API elements_camerabin_LDADD = \ $(top_builddir)/gst-libs/gst/interfaces/libgstphotography-@GST_MAJORMINOR@.la \ $(GST_LIBS) $(GST_BASE_LIBS) $(GST_CHECK_LIBS) \ diff --git a/tests/check/elements/camerabin.c b/tests/check/elements/camerabin.c index 2b72c6ff..795fb4f0 100644 --- a/tests/check/elements/camerabin.c +++ b/tests/check/elements/camerabin.c @@ -27,10 +27,7 @@ #include #include #include - -#ifdef HAVE_GST_PHOTO_IFACE_H #include -#endif #define SINGLE_IMAGE_FILENAME "image.cap" #define BURST_IMAGE_FILENAME "burst_image.cap" @@ -55,7 +52,7 @@ make_test_file_name (const gchar * base_name) g_snprintf (file_name, 999, "%s" G_DIR_SEPARATOR_S "%s", g_get_tmp_dir (), base_name); - GST_INFO ("capturing to: %s", file_name); + GST_INFO ("capturing to: %s (cycle_count=%d)", file_name, cycle_count); return file_name; } @@ -88,18 +85,19 @@ handle_image_captured_cb (gpointer data) g_object_set (camera, "mode", 1, "filename", make_test_file_name (CYCLE_VIDEO_FILENAME), NULL); /* Record video */ - g_signal_emit_by_name (camera, "user-start", 0); + g_signal_emit_by_name (camera, "user-start", NULL); g_usleep (G_USEC_PER_SEC); - g_signal_emit_by_name (camera, "user-stop", 0); + g_signal_emit_by_name (camera, "user-stop", NULL); GST_DEBUG ("video captured"); /* Set still image mode */ g_object_set (camera, "mode", 0, "filename", make_test_file_name (CYCLE_IMAGE_FILENAME), NULL); /* Take a picture */ - g_signal_emit_by_name (camera, "user-start", 0); + g_signal_emit_by_name (camera, "user-start", NULL); cycle_count--; + GST_DEBUG ("next cycle"); } GST_DEBUG ("handle_image_captured_cb done"); return FALSE; @@ -127,6 +125,7 @@ setup_camerabin_elements (GstElement * camera) /* Use fakesink for view finder */ vfsink = gst_element_factory_make ("fakesink", NULL); + g_object_set (vfsink, "sync", TRUE, NULL); audiosrc = gst_element_factory_make ("audiotestsrc", NULL); g_object_set (audiosrc, "is-live", TRUE, NULL); videosrc = gst_element_factory_make ("videotestsrc", NULL); @@ -141,6 +140,8 @@ setup_camerabin_elements (GstElement * camera) g_object_set (camera, "vfsink", vfsink, "audiosrc", audiosrc, "videosrc", videosrc, "audioenc", audioenc, "videoenc", videoenc, "imageenc", imageenc, "videomux", videomux, NULL); + } else { + GST_WARNING ("error setting up test plugins"); } } @@ -151,10 +152,28 @@ capture_bus_cb (GstBus * bus, GstMessage * message, gpointer data) const GstStructure *st; switch (GST_MESSAGE_TYPE (message)) { - case GST_MESSAGE_ERROR: + case GST_MESSAGE_ERROR:{ + GError *err = NULL; + gchar *debug = NULL; + + gst_message_parse_error (message, &err, &debug); + GST_WARNING ("ERROR: %s [%s]", err->message, debug); + g_error_free (err); + g_free (debug); fail_if (TRUE, "error while capturing"); g_main_loop_quit (loop); break; + } + case GST_MESSAGE_WARNING:{ + GError *err = NULL; + gchar *debug = NULL; + + gst_message_parse_warning (message, &err, &debug); + GST_WARNING ("WARNING: %s [%s]", err->message, debug); + g_error_free (err); + g_free (debug); + break; + } case GST_MESSAGE_EOS: GST_DEBUG ("eos"); g_main_loop_quit (loop); @@ -162,7 +181,7 @@ capture_bus_cb (GstBus * bus, GstMessage * message, gpointer data) default: st = gst_message_get_structure (message); if (st && gst_structure_has_name (st, "image-captured")) { - GST_DEBUG ("image-captured"); + GST_INFO ("image-captured"); } break; } @@ -177,6 +196,8 @@ setup (void) GstCaps *filter_caps; GstBus *bus; + GST_INFO ("init"); + main_loop = g_main_loop_new (NULL, TRUE); cam_cond = g_cond_new (); @@ -196,6 +217,10 @@ setup (void) g_object_set (G_OBJECT (camera), "filter-caps", filter_caps, NULL); gst_caps_unref (filter_caps); + /* force a low framerate here to not timeout the tests because of the + * encoders */ + g_signal_emit_by_name (camera, "user-res-fps", 320, 240, 5, 1, NULL); + /* Set some default tags */ setter = GST_TAG_SETTER (camera); desc_str = g_strdup_printf ("Created by %s", g_get_real_name ()); @@ -206,10 +231,12 @@ setup (void) if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) { + GST_WARNING ("setting camerabin to PLAYING failed"); gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL); gst_object_unref (camera); camera = NULL; } + GST_INFO ("init finished"); } static void @@ -219,6 +246,8 @@ teardown (void) g_cond_free (cam_cond); if (camera) gst_check_teardown_element (camera); + + GST_INFO ("done"); } static void @@ -343,13 +372,13 @@ static gboolean check_file_validity (const gchar * filename) { GstBus *bus; - GMainLoop *loop = g_main_loop_new (NULL, TRUE); + GMainLoop *loop = g_main_loop_new (NULL, FALSE); GstElement *playbin = gst_element_factory_make ("playbin2", NULL); GstElement *fakevideo = gst_element_factory_make ("fakesink", NULL); GstElement *fakeaudio = gst_element_factory_make ("fakesink", NULL); gchar *uri = g_strconcat ("file://", make_test_file_name (filename), NULL); - GST_DEBUG ("setting uri: %s", uri); + GST_DEBUG ("checking uri: %s", uri); g_object_set (G_OBJECT (playbin), "uri", uri, "video-sink", fakevideo, "audio-sink", fakeaudio, NULL); @@ -357,7 +386,6 @@ check_file_validity (const gchar * filename) gst_bus_add_watch (bus, (GstBusFunc) validity_bus_cb, loop); gst_element_set_state (playbin, GST_STATE_PLAYING); - g_main_loop_run (loop); gst_element_set_state (playbin, GST_STATE_NULL); @@ -381,7 +409,8 @@ GST_START_TEST (test_single_image_capture) gst_element_get_state (GST_ELEMENT (camera), NULL, NULL, (2 * GST_SECOND)); test_photography_settings (camera); - g_signal_emit_by_name (camera, "user-start", 0); + GST_INFO ("starting capture"); + g_signal_emit_by_name (camera, "user-start", NULL); g_main_loop_run (main_loop); } @@ -397,10 +426,11 @@ GST_START_TEST (test_video_recording) g_object_set (camera, "mode", 1, "filename", make_test_file_name (VIDEO_FILENAME), NULL); - g_signal_emit_by_name (camera, "user-start", 0); + GST_INFO ("starting capture"); + g_signal_emit_by_name (camera, "user-start", NULL); /* Record for one seconds */ g_usleep (G_USEC_PER_SEC); - g_signal_emit_by_name (camera, "user-stop", 0); + g_signal_emit_by_name (camera, "user-stop", NULL); } GST_END_TEST; @@ -416,7 +446,8 @@ GST_START_TEST (test_image_video_cycle) g_object_set (camera, "mode", 0, "filename", make_test_file_name (CYCLE_IMAGE_FILENAME), NULL); - g_signal_emit_by_name (camera, "user-start", 0); + GST_INFO ("starting capture"); + g_signal_emit_by_name (camera, "user-start", NULL); g_main_loop_run (main_loop); } -- cgit v1.2.1 From c70dbe94b5ff9a0993d852605d40c21020c59552 Mon Sep 17 00:00:00 2001 From: Branko Subasic Date: Fri, 19 Jun 2009 19:09:19 +0200 Subject: rtpbin: add support for buffer-list Add support for sending buffer-lists. Add unit test for testing that the buffer-list passed through rtpbin. fixes #585839 --- tests/check/Makefile.am | 8 + tests/check/elements/rtpbin_buffer_list.c | 331 ++++++++++++++++++++++++++++++ 2 files changed, 339 insertions(+) create mode 100644 tests/check/elements/rtpbin_buffer_list.c (limited to 'tests') diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index 3791b753..bf4f07ce 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -84,6 +84,7 @@ check_PROGRAMS = \ elements/legacyresample \ elements/qtmux \ elements/rtpbin \ + elements/rtpbin_buffer_list \ elements/selector \ elements/shapewipe \ elements/mxfdemux \ @@ -108,6 +109,13 @@ elements_camerabin_LDADD = \ -lgstinterfaces-@GST_MAJORMINOR@ elements_camerabin_SOURCES = elements/camerabin.c +elements_rtpbin_buffer_list_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \ + $(ERROR_CFLAGS) $(GST_CHECK_CFLAGS) +elements_rtpbin_buffer_list_LDADD = $(GST_PLUGINS_BASE_LIBS) \ + -lgstnetbuffer-@GST_MAJORMINOR@ -lgstrtp-@GST_MAJORMINOR@ \ + $(GST_BASE_LIBS) $(GST_LIBS_LIBS) $(GST_CHECK_LIBS) +elements_rtpbin_buffer_list_SOURCES = elements/rtpbin_buffer_list.c + elements_timidity_CFLAGS = $(GST_BASE_CFLAGS) $(AM_CFLAGS) elements_timidity_LDADD = $(GST_BASE_LIBS) $(LDADD) diff --git a/tests/check/elements/rtpbin_buffer_list.c b/tests/check/elements/rtpbin_buffer_list.c new file mode 100644 index 00000000..af4003dd --- /dev/null +++ b/tests/check/elements/rtpbin_buffer_list.c @@ -0,0 +1,331 @@ +/* GStreamer + * + * Unit test for gstrtpbin sending rtp packets using GstBufferList. + * Copyright (C) 2009 Branko Subasic + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include + +#include + + + +/* This test makes sure that RTP packets sent as buffer lists are sent through + * the rtpbin as they are supposed to, and not corrupted in any way. + */ + + +#define TEST_CAPS \ + "application/x-rtp, " \ + "media=(string)video, " \ + "clock-rate=(int)90000, " \ + "encoding-name=(string)H264, " \ + "profile-level-id=(string)4d4015, " \ + "payload=(int)96, " \ + "ssrc=(guint)2633237432, " \ + "clock-base=(guint)1868267015, " \ + "seqnum-base=(guint)54229" + + +/* RTP headers and the first 2 bytes of the payload (FU indicator and FU header) + */ +static const guint8 rtp_header[2][14] = { + {0x80, 0x60, 0xbb, 0xb7, 0x5c, 0xe9, 0x09, + 0x0d, 0xf5, 0x9c, 0x43, 0x55, 0x1c, 0x86}, + {0x80, 0x60, 0xbb, 0xb8, 0x5c, 0xe9, 0x09, + 0x0d, 0xf5, 0x9c, 0x43, 0x55, 0x1c, 0x46} +}; + +static const guint rtp_header_len[] = { + sizeof rtp_header[0], + sizeof rtp_header[1] +}; + +static GstBuffer *header_buffer[2] = { NULL, NULL }; + + +/* Some payload. + */ +static char *payload = + "0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF" + "0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF" + "0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF" + "0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF" + "0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF" + "0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF" + "0123456789ABSDEF0123456"; + +static const guint payload_offset[] = { + 0, 498 +}; + +static const guint payload_len[] = { + 498, 5 +}; + + +static GstBuffer *original_buffer = NULL; + +static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/x-rtp")); + +static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/x-rtp")); + + +static GstBuffer * +_create_original_buffer (void) +{ + GstCaps *caps; + + if (original_buffer != NULL) + return original_buffer; + + original_buffer = gst_buffer_new (); + fail_unless (original_buffer != NULL); + + gst_buffer_set_data (original_buffer, (guint8 *) payload, strlen (payload)); + GST_BUFFER_TIMESTAMP (original_buffer) = + gst_clock_get_internal_time (gst_system_clock_obtain ()); + + caps = gst_caps_from_string (TEST_CAPS); + fail_unless (caps != NULL); + gst_buffer_set_caps (original_buffer, caps); + gst_caps_unref (caps); + + return original_buffer; +} + +static GstBufferList * +_create_buffer_list (void) +{ + GstBufferList *list; + GstBufferListIterator *it; + GstBuffer *orig_buffer; + GstBuffer *buffer; + + orig_buffer = _create_original_buffer (); + fail_if (orig_buffer == NULL); + + list = gst_buffer_list_new (); + fail_if (list == NULL); + + it = gst_buffer_list_iterate (list); + fail_if (it == NULL); + + /*** First group, i.e. first packet. **/ + gst_buffer_list_iterator_add_group (it); + + /* Create buffer with RTP header and add it to the 1st group */ + buffer = gst_buffer_new (); + GST_BUFFER_MALLOCDATA (buffer) = g_memdup (&rtp_header[0], rtp_header_len[0]); + GST_BUFFER_DATA (buffer) = GST_BUFFER_MALLOCDATA (buffer); + GST_BUFFER_SIZE (buffer) = rtp_header_len[0]; + gst_buffer_copy_metadata (buffer, orig_buffer, GST_BUFFER_COPY_ALL); + header_buffer[0] = buffer; + gst_buffer_list_iterator_add (it, buffer); + + /* Create the payload buffer and add it to the 1st group + */ + buffer = + gst_buffer_create_sub (orig_buffer, payload_offset[0], payload_len[0]); + fail_if (buffer == NULL); + gst_buffer_list_iterator_add (it, buffer); + + + /*** Second group, i.e. second packet. ***/ + + /* Create a new group to hold the rtp header and the payload */ + gst_buffer_list_iterator_add_group (it); + + /* Create buffer with RTP header and add it to the 2nd group */ + buffer = gst_buffer_new (); + GST_BUFFER_MALLOCDATA (buffer) = g_memdup (&rtp_header[1], rtp_header_len[1]); + GST_BUFFER_DATA (buffer) = GST_BUFFER_MALLOCDATA (buffer); + GST_BUFFER_SIZE (buffer) = rtp_header_len[1]; + gst_buffer_copy_metadata (buffer, orig_buffer, GST_BUFFER_COPY_ALL); + header_buffer[1] = buffer; + + /* Add the rtp header to the buffer list */ + gst_buffer_list_iterator_add (it, buffer); + + /* Create the payload buffer and add it to the 2d group + */ + buffer = + gst_buffer_create_sub (orig_buffer, payload_offset[1], payload_len[1]); + fail_if (buffer == NULL); + gst_buffer_list_iterator_add (it, buffer); + + gst_buffer_list_iterator_free (it); + + return list; +} + + +static void +_check_header (GstBuffer * buffer, guint index) +{ + guint8 *data; + + fail_if (buffer == NULL); + fail_unless (index < 2); + + fail_unless (GST_BUFFER_SIZE (buffer) == rtp_header_len[index]); + + /* Can't do a memcmp() on the whole header, cause the SSRC (bytes 8-11) will + * most likely be changed in gstrtpbin. + */ + fail_unless ((data = GST_BUFFER_DATA (buffer)) != NULL); + fail_unless_equals_uint64 (*(guint64 *) data, *(guint64 *) rtp_header[index]); + fail_unless (*(guint16 *) (data + 12) == + *(guint16 *) (rtp_header[index] + 12)); +} + + +static void +_check_payload (GstBuffer * buffer, guint index) +{ + fail_if (buffer == NULL); + fail_unless (index < 2); + + fail_unless (GST_BUFFER_SIZE (buffer) == payload_len[index]); + fail_if (GST_BUFFER_DATA (buffer) != + (gpointer) (payload + payload_offset[index])); + fail_if (memcmp (GST_BUFFER_DATA (buffer), payload + payload_offset[index], + payload_len[index])); +} + + +static void +_check_group (GstBufferListIterator * it, guint index, GstCaps * caps) +{ + GstBuffer *buffer; + + fail_unless (it != NULL); + fail_unless (gst_buffer_list_iterator_n_buffers (it) == 2); + fail_unless (caps != NULL); + + fail_unless ((buffer = gst_buffer_list_iterator_next (it)) != NULL); + + fail_unless (GST_BUFFER_TIMESTAMP (buffer) == + GST_BUFFER_TIMESTAMP (original_buffer)); + + fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (original_buffer), + GST_BUFFER_CAPS (buffer))); + + _check_header (buffer, index); + + fail_unless ((buffer = gst_buffer_list_iterator_next (it)) != NULL); + _check_payload (buffer, index); +} + + +static GstFlowReturn +_sink_chain_list (GstPad * pad, GstBufferList * list) +{ + GstCaps *caps; + GstBufferListIterator *it; + + caps = gst_caps_from_string (TEST_CAPS); + fail_unless (caps != NULL); + + fail_unless (GST_IS_BUFFER_LIST (list)); + fail_unless (gst_buffer_list_n_groups (list) == 2); + + it = gst_buffer_list_iterate (list); + fail_if (it == NULL); + + fail_unless (gst_buffer_list_iterator_next_group (it)); + _check_group (it, 0, caps); + + fail_unless (gst_buffer_list_iterator_next_group (it)); + _check_group (it, 1, caps); + + gst_caps_unref (caps); + gst_buffer_list_iterator_free (it); + + gst_buffer_list_unref (list); + + return GST_FLOW_OK; +} + + +static void +_set_chain_functions (GstPad * pad) +{ + gst_pad_set_chain_list_function (pad, _sink_chain_list); +} + + +GST_START_TEST (test_bufferlist) +{ + GstElement *rtpbin; + GstPad *sinkpad; + GstPad *srcpad; + GstBufferList *list; + + list = _create_buffer_list (); + fail_unless (list != NULL); + + rtpbin = gst_check_setup_element ("gstrtpbin"); + + srcpad = + gst_check_setup_src_pad_by_name (rtpbin, &srctemplate, "send_rtp_sink_0"); + fail_if (srcpad == NULL); + sinkpad = + gst_check_setup_sink_pad_by_name (rtpbin, &sinktemplate, + "send_rtp_src_0"); + fail_if (sinkpad == NULL); + + _set_chain_functions (sinkpad); + + gst_pad_set_active (sinkpad, TRUE); + gst_element_set_state (rtpbin, GST_STATE_PLAYING); + fail_unless (gst_pad_push_list (srcpad, list) == GST_FLOW_OK); + gst_pad_set_active (sinkpad, FALSE); + + gst_check_teardown_pad_by_name (rtpbin, "send_rtp_src_0"); + gst_check_teardown_pad_by_name (rtpbin, "send_rtp_sink_0"); + gst_check_teardown_element (rtpbin); +} + +GST_END_TEST; + + + +static Suite * +bufferlist_suite (void) +{ + Suite *s = suite_create ("BufferList"); + + TCase *tc_chain = tcase_create ("general"); + + /* time out after 30s. */ + tcase_set_timeout (tc_chain, 10); + + suite_add_tcase (s, tc_chain); + tcase_add_test (tc_chain, test_bufferlist); + + return s; +} + +GST_CHECK_MAIN (bufferlist); -- cgit v1.2.1