mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-09 17:44:14 +00:00
tests: camerabin2: porting to 0.11
This commit is contained in:
parent
44eb631841
commit
d5aaefa59f
1 changed files with 77 additions and 61 deletions
|
@ -38,8 +38,8 @@
|
|||
#define CAPTURE_COUNT 3
|
||||
#define VIDEO_DURATION 5
|
||||
|
||||
#define VIDEO_PAD_SUPPORTED_CAPS GST_VIDEO_CAPS_RGB ", width=600, height=480"
|
||||
#define IMAGE_PAD_SUPPORTED_CAPS GST_VIDEO_CAPS_RGB ", width=800, height=600"
|
||||
#define VIDEO_PAD_SUPPORTED_CAPS "video/x-raw, format=rgb, width=600, height=480"
|
||||
#define IMAGE_PAD_SUPPORTED_CAPS "video/x-raw, format=rgb, width=800, height=600"
|
||||
|
||||
/* custom test camera src element */
|
||||
#define GST_TYPE_TEST_CAMERA_SRC \
|
||||
|
@ -74,8 +74,8 @@ struct _GstTestCameraSrcClass
|
|||
|
||||
GType gst_test_camera_src_get_type (void);
|
||||
|
||||
GST_BOILERPLATE (GstTestCameraSrc,
|
||||
gst_test_camera_src, GstBaseCameraSrc, GST_TYPE_BASE_CAMERA_SRC);
|
||||
#define gst_test_camera_src_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstTestCameraSrc, gst_test_camera_src, GST_TYPE_BASE_CAMERA_SRC);
|
||||
|
||||
static gboolean
|
||||
gst_test_camera_src_set_mode (GstBaseCameraSrc * src, GstCameraBinMode mode)
|
||||
|
@ -86,51 +86,65 @@ gst_test_camera_src_set_mode (GstBaseCameraSrc * src, GstCameraBinMode mode)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_test_camera_src_get_caps (GstPad * pad)
|
||||
static gboolean
|
||||
gst_test_camera_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||
{
|
||||
GstTestCameraSrc *self = (GstTestCameraSrc *) GST_PAD_PARENT (pad);
|
||||
GstCaps *result = NULL;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
if (pad == self->vfpad) {
|
||||
result = gst_caps_new_any ();
|
||||
} else if (pad == self->vidpad) {
|
||||
result = gst_caps_from_string (VIDEO_PAD_SUPPORTED_CAPS);
|
||||
} else if (pad == self->imgpad) {
|
||||
result = gst_caps_from_string (IMAGE_PAD_SUPPORTED_CAPS);
|
||||
} else {
|
||||
g_assert_not_reached ();
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_CAPS:
|
||||
if (pad == self->vfpad) {
|
||||
result = gst_caps_new_any ();
|
||||
} else if (pad == self->vidpad) {
|
||||
result = gst_caps_from_string (VIDEO_PAD_SUPPORTED_CAPS);
|
||||
} else if (pad == self->imgpad) {
|
||||
result = gst_caps_from_string (IMAGE_PAD_SUPPORTED_CAPS);
|
||||
} else {
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
if (result) {
|
||||
GstCaps *filter;
|
||||
|
||||
gst_query_parse_caps (query, &filter);
|
||||
if (filter) {
|
||||
GstCaps *tmp;
|
||||
tmp = gst_caps_intersect (result, filter);
|
||||
gst_caps_replace (&result, tmp);
|
||||
gst_caps_unref (tmp);
|
||||
}
|
||||
gst_query_set_caps_result (query, result);
|
||||
ret = TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_test_camera_src_base_init (gpointer g_class)
|
||||
{
|
||||
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
|
||||
|
||||
gst_element_class_set_details_simple (gstelement_class,
|
||||
"Test Camera Src",
|
||||
"Camera/Src",
|
||||
"Some test camera src",
|
||||
"Thiago Santos <thiago.sousa.santos@collabora.co.uk>");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_test_camera_src_class_init (GstTestCameraSrcClass * klass)
|
||||
{
|
||||
GstBaseCameraSrcClass *gstbasecamera_class;
|
||||
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
gstbasecamera_class = GST_BASE_CAMERA_SRC_CLASS (klass);
|
||||
gstbasecamera_class->set_mode = gst_test_camera_src_set_mode;
|
||||
|
||||
gst_element_class_set_details_simple (gstelement_class,
|
||||
"Test Camera Src",
|
||||
"Camera/Src",
|
||||
"Some test camera src",
|
||||
"Thiago Santos <thiago.sousa.santos@collabora.com>");
|
||||
}
|
||||
|
||||
static void
|
||||
gst_test_camera_src_init (GstTestCameraSrc * self,
|
||||
GstTestCameraSrcClass * g_class)
|
||||
gst_test_camera_src_init (GstTestCameraSrc * self)
|
||||
{
|
||||
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
|
||||
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (parent_class);
|
||||
GstPadTemplate *template;
|
||||
|
||||
/* create pads */
|
||||
|
@ -153,9 +167,9 @@ gst_test_camera_src_init (GstTestCameraSrc * self,
|
|||
gst_element_add_pad (GST_ELEMENT_CAST (self), self->vidpad);
|
||||
|
||||
/* add get caps functions */
|
||||
gst_pad_set_getcaps_function (self->vfpad, gst_test_camera_src_get_caps);
|
||||
gst_pad_set_getcaps_function (self->vidpad, gst_test_camera_src_get_caps);
|
||||
gst_pad_set_getcaps_function (self->imgpad, gst_test_camera_src_get_caps);
|
||||
gst_pad_set_query_function (self->vfpad, gst_test_camera_src_query);
|
||||
gst_pad_set_query_function (self->vidpad, gst_test_camera_src_query);
|
||||
gst_pad_set_query_function (self->imgpad, gst_test_camera_src_query);
|
||||
}
|
||||
|
||||
/* end of custom test camera src element */
|
||||
|
@ -315,9 +329,11 @@ check_preview_image (GstElement * camera, const gchar * filename, gint index)
|
|||
fail_unless (strcmp (preview_filename, prev_filename) == 0);
|
||||
}
|
||||
if (preview_caps) {
|
||||
fail_unless (GST_BUFFER_CAPS (preview_buffer) != NULL);
|
||||
fail_unless (gst_caps_can_intersect (GST_BUFFER_CAPS (preview_buffer),
|
||||
preview_caps));
|
||||
/* TODO porting
|
||||
fail_unless (GST_BUFFER_CAPS (preview_buffer) != NULL);
|
||||
fail_unless (gst_caps_can_intersect (GST_BUFFER_CAPS (preview_buffer),
|
||||
preview_caps));
|
||||
*/
|
||||
}
|
||||
g_free (prev_filename);
|
||||
}
|
||||
|
@ -525,7 +541,7 @@ check_file_validity (const gchar * filename, gint num, GstTagList * taglist,
|
|||
if (width != 0 && height != 0) {
|
||||
g_signal_emit_by_name (playbin, "get-video-pad", 0, &pad, NULL);
|
||||
g_assert (pad != NULL);
|
||||
caps = gst_pad_get_negotiated_caps (pad);
|
||||
caps = gst_pad_get_current_caps (pad);
|
||||
|
||||
g_assert (gst_structure_get_int (gst_caps_get_structure (caps, 0),
|
||||
"width", &caps_width));
|
||||
|
@ -567,14 +583,14 @@ check_file_validity (const gchar * filename, gint num, GstTagList * taglist,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
filter_buffer_count (GstPad * pad, GstMiniObject * obj, gpointer data)
|
||||
static GstPadProbeReturn
|
||||
filter_buffer_count (GstPad * pad, GstPadProbeInfo * info, gpointer data)
|
||||
{
|
||||
gint *counter = data;
|
||||
|
||||
(*counter)++;
|
||||
|
||||
return TRUE;
|
||||
return GST_PAD_PROBE_OK;
|
||||
}
|
||||
|
||||
static GstMessage *
|
||||
|
@ -971,7 +987,7 @@ GST_START_TEST (test_image_capture_with_tags)
|
|||
if (!camera)
|
||||
return;
|
||||
|
||||
taglists[0] = gst_tag_list_new_full (GST_TAG_COMMENT, "test1",
|
||||
taglists[0] = gst_tag_list_new (GST_TAG_COMMENT, "test1",
|
||||
GST_TAG_GEO_LOCATION_LATITUDE, 36.6, GST_TAG_GEO_LOCATION_LONGITUDE,
|
||||
-12.5,
|
||||
GST_TAG_COPYRIGHT, "My copyright notice",
|
||||
|
@ -980,7 +996,7 @@ GST_START_TEST (test_image_capture_with_tags)
|
|||
GST_TAG_DESCRIPTION, "some description",
|
||||
GST_TAG_APPLICATION_NAME, "camerabin2 test",
|
||||
GST_TAG_GEO_LOCATION_ELEVATION, 300.85, NULL);
|
||||
taglists[1] = gst_tag_list_new_full (GST_TAG_COMMENT, "test2",
|
||||
taglists[1] = gst_tag_list_new (GST_TAG_COMMENT, "test2",
|
||||
GST_TAG_GEO_LOCATION_LATITUDE, 1.6, GST_TAG_GEO_LOCATION_LONGITUDE,
|
||||
0.0,
|
||||
GST_TAG_COPYRIGHT, "some cp",
|
||||
|
@ -989,7 +1005,7 @@ GST_START_TEST (test_image_capture_with_tags)
|
|||
GST_TAG_DESCRIPTION, "desc",
|
||||
GST_TAG_APPLICATION_NAME, "another cam test",
|
||||
GST_TAG_GEO_LOCATION_ELEVATION, 10.0, NULL);
|
||||
taglists[2] = gst_tag_list_new_full (GST_TAG_COMMENT, "test3",
|
||||
taglists[2] = gst_tag_list_new (GST_TAG_COMMENT, "test3",
|
||||
GST_TAG_GEO_LOCATION_LATITUDE, 1.3, GST_TAG_GEO_LOCATION_LONGITUDE,
|
||||
-5.0,
|
||||
GST_TAG_COPYRIGHT, "CC",
|
||||
|
@ -1043,9 +1059,9 @@ GST_START_TEST (test_video_capture_with_tags)
|
|||
if (!camera)
|
||||
return;
|
||||
|
||||
taglists[0] = gst_tag_list_new_full (GST_TAG_COMMENT, "test1", NULL);
|
||||
taglists[1] = gst_tag_list_new_full (GST_TAG_COMMENT, "test2", NULL);
|
||||
taglists[2] = gst_tag_list_new_full (GST_TAG_COMMENT, "test3", NULL);
|
||||
taglists[0] = gst_tag_list_new (GST_TAG_COMMENT, "test1", NULL);
|
||||
taglists[1] = gst_tag_list_new (GST_TAG_COMMENT, "test2", NULL);
|
||||
taglists[2] = gst_tag_list_new (GST_TAG_COMMENT, "test3", NULL);
|
||||
|
||||
/* set video mode */
|
||||
g_object_set (camera, "mode", 2, "location", video_filename, NULL);
|
||||
|
@ -1061,7 +1077,7 @@ GST_START_TEST (test_video_capture_with_tags)
|
|||
profile = gst_encoding_container_profile_new ("qt", "jpeg+qt", caps, NULL);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
caps = gst_caps_new_simple ("image/jpeg", NULL);
|
||||
caps = gst_caps_new_simple ("image/jpeg", NULL, NULL);
|
||||
if (!gst_encoding_container_profile_add_profile (profile,
|
||||
(GstEncodingProfile *) gst_encoding_video_profile_new (caps,
|
||||
NULL, NULL, 1))) {
|
||||
|
@ -1230,18 +1246,18 @@ GST_START_TEST (test_image_custom_filter)
|
|||
preview_filter = gst_element_factory_make ("identity", "preview-filter");
|
||||
|
||||
pad = gst_element_get_static_pad (vf_filter, "src");
|
||||
gst_pad_add_buffer_probe (pad, (GCallback) filter_buffer_count,
|
||||
&vf_probe_counter);
|
||||
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER, filter_buffer_count,
|
||||
&vf_probe_counter, NULL);
|
||||
gst_object_unref (pad);
|
||||
|
||||
pad = gst_element_get_static_pad (image_filter, "src");
|
||||
gst_pad_add_buffer_probe (pad, (GCallback) filter_buffer_count,
|
||||
&image_probe_counter);
|
||||
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER, filter_buffer_count,
|
||||
&image_probe_counter, NULL);
|
||||
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_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER, filter_buffer_count,
|
||||
&preview_probe_counter, NULL);
|
||||
gst_object_unref (pad);
|
||||
|
||||
/* set still image mode and filters */
|
||||
|
@ -1303,23 +1319,23 @@ GST_START_TEST (test_video_custom_filter)
|
|||
audio_filter = gst_element_factory_make ("identity", "audio-filter");
|
||||
|
||||
pad = gst_element_get_static_pad (vf_filter, "src");
|
||||
gst_pad_add_buffer_probe (pad, (GCallback) filter_buffer_count,
|
||||
&vf_probe_counter);
|
||||
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER, filter_buffer_count,
|
||||
&vf_probe_counter, NULL);
|
||||
gst_object_unref (pad);
|
||||
|
||||
pad = gst_element_get_static_pad (video_filter, "src");
|
||||
gst_pad_add_buffer_probe (pad, (GCallback) filter_buffer_count,
|
||||
&video_probe_counter);
|
||||
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER, filter_buffer_count,
|
||||
&video_probe_counter, NULL);
|
||||
gst_object_unref (pad);
|
||||
|
||||
pad = gst_element_get_static_pad (audio_filter, "src");
|
||||
gst_pad_add_buffer_probe (pad, (GCallback) filter_buffer_count,
|
||||
&audio_probe_counter);
|
||||
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER, filter_buffer_count,
|
||||
&audio_probe_counter, NULL);
|
||||
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_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER, filter_buffer_count,
|
||||
&preview_probe_counter, NULL);
|
||||
gst_object_unref (pad);
|
||||
|
||||
/* set still image mode and filters */
|
||||
|
|
Loading…
Reference in a new issue