diff options
author | Thiago Santos <thiago.sousa.santos@collabora.co.uk> | 2011-01-27 10:19:42 -0300 |
---|---|---|
committer | Thiago Santos <thiago.sousa.santos@collabora.co.uk> | 2011-02-03 19:09:20 -0300 |
commit | b2a45f6f21f44ca0d0c127c6a7f1fe25a206dea0 (patch) | |
tree | 81f57f9c390b92fdda2a6611633e3f6ef4abab78 | |
parent | 675632b38237549dc68effd1caeaa836aa4e933c (diff) |
tests: camerabin2: Add tests for custom filters
Adds tests to check that custom filters elements receive buffers
-rw-r--r-- | tests/check/elements/camerabin2.c | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/tests/check/elements/camerabin2.c b/tests/check/elements/camerabin2.c index 23c937994..1b0ddf455 100644 --- a/tests/check/elements/camerabin2.c +++ b/tests/check/elements/camerabin2.c | |||
@@ -505,6 +505,16 @@ check_file_validity (const gchar * filename, gint num, GstTagList * taglist, | |||
505 | return TRUE; | 505 | return TRUE; |
506 | } | 506 | } |
507 | 507 | ||
508 | static gboolean | ||
509 | filter_buffer_count (GstPad * pad, GstMiniObject * obj, gpointer data) | ||
510 | { | ||
511 | gint *counter = data; | ||
512 | |||
513 | (*counter)++; | ||
514 | |||
515 | return TRUE; | ||
516 | } | ||
517 | |||
508 | GST_START_TEST (test_single_image_capture) | 518 | GST_START_TEST (test_single_image_capture) |
509 | { | 519 | { |
510 | if (!camera) | 520 | if (!camera) |
@@ -974,6 +984,120 @@ GST_START_TEST (test_supported_caps) | |||
974 | GST_END_TEST; | 984 | GST_END_TEST; |
975 | 985 | ||
976 | 986 | ||
987 | GST_START_TEST (test_image_custom_filter) | ||
988 | { | ||
989 | GstElement *vf_filter; | ||
990 | GstElement *image_filter; | ||
991 | GstPad *pad; | ||
992 | gint vf_probe_counter = 0; | ||
993 | gint image_probe_counter = 0; | ||
994 | |||
995 | if (!camera) | ||
996 | return; | ||
997 | |||
998 | vf_filter = gst_element_factory_make ("identity", "vf-filter"); | ||
999 | image_filter = gst_element_factory_make ("identity", "img-filter"); | ||
1000 | |||
1001 | pad = gst_element_get_static_pad (vf_filter, "src"); | ||
1002 | gst_pad_add_buffer_probe (pad, (GCallback) filter_buffer_count, | ||
1003 | &vf_probe_counter); | ||
1004 | gst_object_unref (pad); | ||
1005 | |||
1006 | pad = gst_element_get_static_pad (image_filter, "src"); | ||
1007 | gst_pad_add_buffer_probe (pad, (GCallback) filter_buffer_count, | ||
1008 | &image_probe_counter); | ||
1009 | gst_object_unref (pad); | ||
1010 | |||
1011 | /* set still image mode and filters */ | ||
1012 | g_object_set (camera, "mode", 1, | ||
1013 | "location", make_test_file_name (IMAGE_FILENAME, -1), | ||
1014 | "viewfinder-filter", vf_filter, "image-filter", image_filter, NULL); | ||
1015 | |||
1016 | if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) == | ||
1017 | GST_STATE_CHANGE_FAILURE) { | ||
1018 | GST_WARNING ("setting camerabin to PLAYING failed"); | ||
1019 | gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL); | ||
1020 | gst_object_unref (camera); | ||
1021 | camera = NULL; | ||
1022 | } | ||
1023 | GST_INFO ("starting capture"); | ||
1024 | fail_unless (camera != NULL); | ||
1025 | g_signal_emit_by_name (camera, "start-capture", NULL); | ||
1026 | |||
1027 | g_timeout_add_seconds (3, (GSourceFunc) g_main_loop_quit, main_loop); | ||
1028 | g_main_loop_run (main_loop); | ||
1029 | |||
1030 | /* check that we got a preview image */ | ||
1031 | check_preview_image (); | ||
1032 | |||
1033 | gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL); | ||
1034 | check_file_validity (IMAGE_FILENAME, 0, NULL, 0, 0); | ||
1035 | |||
1036 | fail_unless (vf_probe_counter > 0); | ||
1037 | fail_unless (image_probe_counter == 1); | ||
1038 | } | ||
1039 | |||
1040 | GST_END_TEST; | ||
1041 | |||
1042 | |||
1043 | GST_START_TEST (test_video_custom_filter) | ||
1044 | { | ||
1045 | GstElement *vf_filter; | ||
1046 | GstElement *video_filter; | ||
1047 | GstPad *pad; | ||
1048 | gint vf_probe_counter = 0; | ||
1049 | gint video_probe_counter = 0; | ||
1050 | |||
1051 | if (!camera) | ||
1052 | return; | ||
1053 | |||
1054 | vf_filter = gst_element_factory_make ("identity", "vf-filter"); | ||
1055 | video_filter = gst_element_factory_make ("identity", "video-filter"); | ||
1056 | |||
1057 | pad = gst_element_get_static_pad (vf_filter, "src"); | ||
1058 | gst_pad_add_buffer_probe (pad, (GCallback) filter_buffer_count, | ||
1059 | &vf_probe_counter); | ||
1060 | gst_object_unref (pad); | ||
1061 | |||
1062 | pad = gst_element_get_static_pad (video_filter, "src"); | ||
1063 | gst_pad_add_buffer_probe (pad, (GCallback) filter_buffer_count, | ||
1064 | &video_probe_counter); | ||
1065 | gst_object_unref (pad); | ||
1066 | |||
1067 | /* set still image mode and filters */ | ||
1068 | g_object_set (camera, "mode", 2, | ||
1069 | "location", make_test_file_name (VIDEO_FILENAME, -1), | ||
1070 | "viewfinder-filter", vf_filter, "video-filter", video_filter, NULL); | ||
1071 | |||
1072 | if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) == | ||
1073 | GST_STATE_CHANGE_FAILURE) { | ||
1074 | GST_WARNING ("setting camerabin to PLAYING failed"); | ||
1075 | gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL); | ||
1076 | gst_object_unref (camera); | ||
1077 | camera = NULL; | ||
1078 | } | ||
1079 | GST_INFO ("starting capture"); | ||
1080 | fail_unless (camera != NULL); | ||
1081 | g_signal_emit_by_name (camera, "start-capture", NULL); | ||
1082 | |||
1083 | g_timeout_add_seconds (VIDEO_DURATION, (GSourceFunc) g_main_loop_quit, | ||
1084 | main_loop); | ||
1085 | g_main_loop_run (main_loop); | ||
1086 | g_signal_emit_by_name (camera, "stop-capture", NULL); | ||
1087 | |||
1088 | /* check that we got a preview image */ | ||
1089 | check_preview_image (); | ||
1090 | |||
1091 | gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL); | ||
1092 | check_file_validity (VIDEO_FILENAME, 0, NULL, 0, 0); | ||
1093 | |||
1094 | fail_unless (vf_probe_counter > 0); | ||
1095 | fail_unless (video_probe_counter > 0); | ||
1096 | } | ||
1097 | |||
1098 | GST_END_TEST; | ||
1099 | |||
1100 | |||
977 | typedef struct _TestCaseDef | 1101 | typedef struct _TestCaseDef |
978 | { | 1102 | { |
979 | const gchar *name; | 1103 | const gchar *name; |
@@ -1026,6 +1150,9 @@ camerabin_suite (void) | |||
1026 | tcase_add_test (tc_basic, test_image_capture_with_tags); | 1150 | tcase_add_test (tc_basic, test_image_capture_with_tags); |
1027 | 1151 | ||
1028 | tcase_add_test (tc_basic, test_video_capture_with_tags); | 1152 | tcase_add_test (tc_basic, test_video_capture_with_tags); |
1153 | |||
1154 | tcase_add_test (tc_basic, test_image_custom_filter); | ||
1155 | tcase_add_test (tc_basic, test_video_custom_filter); | ||
1029 | } | 1156 | } |
1030 | 1157 | ||
1031 | end: | 1158 | end: |