tests: camerabin2: preview filter tests

Adds tests to the preview-filter property of camerabin2
This commit is contained in:
Thiago Santos 2011-01-27 15:35:14 -03:00
parent 869a61343c
commit 4a7dc81782

View file

@ -988,15 +988,18 @@ GST_START_TEST (test_image_custom_filter)
{ {
GstElement *vf_filter; GstElement *vf_filter;
GstElement *image_filter; GstElement *image_filter;
GstElement *preview_filter;
GstPad *pad; GstPad *pad;
gint vf_probe_counter = 0; gint vf_probe_counter = 0;
gint image_probe_counter = 0; gint image_probe_counter = 0;
gint preview_probe_counter = 0;
if (!camera) if (!camera)
return; return;
vf_filter = gst_element_factory_make ("identity", "vf-filter"); vf_filter = gst_element_factory_make ("identity", "vf-filter");
image_filter = gst_element_factory_make ("identity", "img-filter"); image_filter = gst_element_factory_make ("identity", "img-filter");
preview_filter = gst_element_factory_make ("identity", "preview-filter");
pad = gst_element_get_static_pad (vf_filter, "src"); pad = gst_element_get_static_pad (vf_filter, "src");
gst_pad_add_buffer_probe (pad, (GCallback) filter_buffer_count, gst_pad_add_buffer_probe (pad, (GCallback) filter_buffer_count,
@ -1008,10 +1011,20 @@ GST_START_TEST (test_image_custom_filter)
&image_probe_counter); &image_probe_counter);
gst_object_unref (pad); gst_object_unref (pad);
pad = gst_element_get_static_pad (preview_filter, "src");
gst_pad_add_buffer_probe (pad, (GCallback) filter_buffer_count,
&preview_probe_counter);
gst_object_unref (pad);
/* set still image mode and filters */ /* set still image mode and filters */
g_object_set (camera, "mode", 1, g_object_set (camera, "mode", 1,
"location", make_test_file_name (IMAGE_FILENAME, -1), "location", make_test_file_name (IMAGE_FILENAME, -1),
"viewfinder-filter", vf_filter, "image-filter", image_filter, NULL); "viewfinder-filter", vf_filter, "image-filter", image_filter,
"preview-filter", preview_filter, NULL);
gst_object_unref (vf_filter);
gst_object_unref (preview_filter);
gst_object_unref (image_filter);
if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) == if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) ==
GST_STATE_CHANGE_FAILURE) { GST_STATE_CHANGE_FAILURE) {
@ -1035,6 +1048,7 @@ GST_START_TEST (test_image_custom_filter)
fail_unless (vf_probe_counter > 0); fail_unless (vf_probe_counter > 0);
fail_unless (image_probe_counter == 1); fail_unless (image_probe_counter == 1);
fail_unless (preview_probe_counter == 1);
} }
GST_END_TEST; GST_END_TEST;
@ -1044,15 +1058,18 @@ GST_START_TEST (test_video_custom_filter)
{ {
GstElement *vf_filter; GstElement *vf_filter;
GstElement *video_filter; GstElement *video_filter;
GstElement *preview_filter;
GstPad *pad; GstPad *pad;
gint vf_probe_counter = 0; gint vf_probe_counter = 0;
gint video_probe_counter = 0; gint video_probe_counter = 0;
gint preview_probe_counter = 0;
if (!camera) if (!camera)
return; return;
vf_filter = gst_element_factory_make ("identity", "vf-filter"); vf_filter = gst_element_factory_make ("identity", "vf-filter");
video_filter = gst_element_factory_make ("identity", "video-filter"); video_filter = gst_element_factory_make ("identity", "video-filter");
preview_filter = gst_element_factory_make ("identity", "preview-filter");
pad = gst_element_get_static_pad (vf_filter, "src"); pad = gst_element_get_static_pad (vf_filter, "src");
gst_pad_add_buffer_probe (pad, (GCallback) filter_buffer_count, gst_pad_add_buffer_probe (pad, (GCallback) filter_buffer_count,
@ -1064,10 +1081,20 @@ GST_START_TEST (test_video_custom_filter)
&video_probe_counter); &video_probe_counter);
gst_object_unref (pad); gst_object_unref (pad);
pad = gst_element_get_static_pad (preview_filter, "src");
gst_pad_add_buffer_probe (pad, (GCallback) filter_buffer_count,
&preview_probe_counter);
gst_object_unref (pad);
/* set still image mode and filters */ /* set still image mode and filters */
g_object_set (camera, "mode", 2, g_object_set (camera, "mode", 2,
"location", make_test_file_name (VIDEO_FILENAME, -1), "location", make_test_file_name (VIDEO_FILENAME, -1),
"viewfinder-filter", vf_filter, "video-filter", video_filter, NULL); "viewfinder-filter", vf_filter, "video-filter", video_filter,
"preview-filter", preview_filter, NULL);
gst_object_unref (vf_filter);
gst_object_unref (preview_filter);
gst_object_unref (video_filter);
if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) == if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) ==
GST_STATE_CHANGE_FAILURE) { GST_STATE_CHANGE_FAILURE) {
@ -1093,6 +1120,7 @@ GST_START_TEST (test_video_custom_filter)
fail_unless (vf_probe_counter > 0); fail_unless (vf_probe_counter > 0);
fail_unless (video_probe_counter > 0); fail_unless (video_probe_counter > 0);
fail_unless (preview_probe_counter == 1);
} }
GST_END_TEST; GST_END_TEST;