mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-23 22:46:24 +00:00
tests: camerabin2: Adds tests for new image capture properties
Adds tests to check that changing encoder/muxer for image capture works
This commit is contained in:
parent
19628ec3f3
commit
8318174cfc
1 changed files with 76 additions and 0 deletions
|
@ -1140,6 +1140,75 @@ GST_START_TEST (test_video_custom_filter)
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
|
|
||||||
|
GST_START_TEST (test_image_custom_encoder_muxer)
|
||||||
|
{
|
||||||
|
GstElement *enc;
|
||||||
|
GstElement *mux;
|
||||||
|
GstElement *test;
|
||||||
|
GstPad *pad;
|
||||||
|
gint enc_probe_counter = 0;
|
||||||
|
gint mux_probe_counter = 0;
|
||||||
|
|
||||||
|
if (!camera)
|
||||||
|
return;
|
||||||
|
|
||||||
|
enc = gst_element_factory_make ("pngenc", "enc");
|
||||||
|
mux = gst_element_factory_make ("identity", "mux");
|
||||||
|
|
||||||
|
g_object_set (enc, "snapshot", FALSE, NULL);
|
||||||
|
|
||||||
|
pad = gst_element_get_static_pad (enc, "src");
|
||||||
|
gst_pad_add_buffer_probe (pad, (GCallback) filter_buffer_count,
|
||||||
|
&enc_probe_counter);
|
||||||
|
gst_object_unref (pad);
|
||||||
|
|
||||||
|
pad = gst_element_get_static_pad (mux, "src");
|
||||||
|
gst_pad_add_buffer_probe (pad, (GCallback) filter_buffer_count,
|
||||||
|
&mux_probe_counter);
|
||||||
|
gst_object_unref (pad);
|
||||||
|
|
||||||
|
/* set still image mode and filters */
|
||||||
|
g_object_set (camera, "mode", 1,
|
||||||
|
"location", make_test_file_name (IMAGE_FILENAME, -1),
|
||||||
|
"image-capture-encoder", enc, "image-capture-muxer", mux, NULL);
|
||||||
|
|
||||||
|
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 ("starting capture");
|
||||||
|
fail_unless (camera != NULL);
|
||||||
|
|
||||||
|
g_object_get (camera, "image-capture-encoder", &test, NULL);
|
||||||
|
fail_unless (test == enc);
|
||||||
|
g_object_get (camera, "image-capture-muxer", &test, NULL);
|
||||||
|
fail_unless (test == mux);
|
||||||
|
|
||||||
|
g_signal_emit_by_name (camera, "start-capture", NULL);
|
||||||
|
|
||||||
|
g_timeout_add_seconds (3, (GSourceFunc) g_main_loop_quit, main_loop);
|
||||||
|
g_main_loop_run (main_loop);
|
||||||
|
|
||||||
|
/* check that we got a preview image */
|
||||||
|
check_preview_image ();
|
||||||
|
|
||||||
|
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
|
||||||
|
check_file_validity (IMAGE_FILENAME, 0, NULL, 0, 0, NO_AUDIO);
|
||||||
|
|
||||||
|
fail_unless (enc_probe_counter == 1);
|
||||||
|
fail_unless (mux_probe_counter == 1);
|
||||||
|
gst_object_unref (enc);
|
||||||
|
gst_object_unref (mux);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _TestCaseDef
|
typedef struct _TestCaseDef
|
||||||
{
|
{
|
||||||
const gchar *name;
|
const gchar *name;
|
||||||
|
@ -1154,6 +1223,7 @@ static Suite *
|
||||||
camerabin_suite (void)
|
camerabin_suite (void)
|
||||||
{
|
{
|
||||||
GstElementFactory *jpegenc_factory;
|
GstElementFactory *jpegenc_factory;
|
||||||
|
GstElementFactory *pngenc_factory;
|
||||||
Suite *s = suite_create ("camerabin2");
|
Suite *s = suite_create ("camerabin2");
|
||||||
gint i;
|
gint i;
|
||||||
TCase *tc_generic = tcase_create ("generic");
|
TCase *tc_generic = tcase_create ("generic");
|
||||||
|
@ -1163,6 +1233,7 @@ camerabin_suite (void)
|
||||||
GST_WARNING ("Skipping camerabin2 tests because jpegenc is missing");
|
GST_WARNING ("Skipping camerabin2 tests because jpegenc is missing");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
pngenc_factory = gst_element_factory_find ("pngenc");
|
||||||
|
|
||||||
suite_add_tcase (s, tc_generic);
|
suite_add_tcase (s, tc_generic);
|
||||||
tcase_add_checked_fixture (tc_generic, setup_wrappercamerabinsrc_videotestsrc,
|
tcase_add_checked_fixture (tc_generic, setup_wrappercamerabinsrc_videotestsrc,
|
||||||
|
@ -1195,6 +1266,11 @@ camerabin_suite (void)
|
||||||
|
|
||||||
tcase_add_test (tc_basic, test_image_custom_filter);
|
tcase_add_test (tc_basic, test_image_custom_filter);
|
||||||
tcase_add_test (tc_basic, test_video_custom_filter);
|
tcase_add_test (tc_basic, test_video_custom_filter);
|
||||||
|
|
||||||
|
if (pngenc_factory)
|
||||||
|
tcase_add_test (tc_basic, test_image_custom_encoder_muxer);
|
||||||
|
else
|
||||||
|
GST_WARNING ("Skipping custom encoder test because pngenc is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
|
Loading…
Reference in a new issue