tests: make adder test and libgstvideo test compile, disable some tests

Don't fully work yet though
This commit is contained in:
Tim-Philipp Müller 2011-07-07 23:57:33 +01:00
parent dd56714b14
commit 34d1d7a8d4
3 changed files with 139 additions and 106 deletions

View File

@ -105,28 +105,11 @@ check_PROGRAMS = \
$(check_alsa) \ $(check_alsa) \
$(check_gio) \ $(check_gio) \
$(check_ogg) \ $(check_ogg) \
$(check_pango) \
$(check_vorbis) \ $(check_vorbis) \
$(check_theora) \
elements/adder \
elements/appsink \
elements/appsrc \
elements/audioconvert \ elements/audioconvert \
elements/audiorate \
elements/audioresample \
elements/audiotestsrc \ elements/audiotestsrc \
elements/decodebin \ elements/decodebin \
$(check_encodebin) \ $(check_encodebin) \
elements/gdpdepay \
elements/gdppay \
elements/multifdsink \
elements/playbin \
elements/playbin-compressed \
$(check_subparse) \
elements/videorate \
elements/videoscale \
elements/videotestsrc \
elements/volume \
generic/clock-selection \ generic/clock-selection \
generic/states \ generic/states \
gst/typefindfunctions \ gst/typefindfunctions \
@ -160,8 +143,31 @@ VALGRIND_TO_FIX = \
elements/videoconvert \ elements/videoconvert \
libs/video libs/video
# FIXME 0.11: these tests don't even build at the moment
ZERO_11_TO_PORT = \
elements/appsink \
elements/appsrc \
elements/audiorate \
elements/audioresample \
elements/gdpdepay \
elements/gdppay \
elements/multifdsink \
elements/playbin \
elements/playbin-compressed \
$(check_pango) \
$(check_subparse) \
elements/videorate \
elements/videoscale \
elements/videotestsrc \
elements/volume
# FIXME 0.11: these tests don't pass at the moment
ZERO_11_TO_FIX = \
elements/adder \
$(check_theora)
# these tests don't even pass # these tests don't even pass
noinst_PROGRAMS = $(check_libvisual) noinst_PROGRAMS = $(check_libvisual) $(ZERO_11_TO_FIX)
noinst_HEADERS = \ noinst_HEADERS = \
libs/struct_arm.h \ libs/struct_arm.h \

View File

@ -740,6 +740,7 @@ handoff_buffer_cb (GstElement * fakesink, GstBuffer * buffer, GstPad * pad,
/* check if clipping works as expected */ /* check if clipping works as expected */
GST_START_TEST (test_clip) GST_START_TEST (test_clip)
{ {
GstSegment segment;
GstElement *bin, *adder, *sink; GstElement *bin, *adder, *sink;
GstBus *bus; GstBus *bus;
GstPad *sinkpad; GstPad *sinkpad;
@ -747,7 +748,7 @@ GST_START_TEST (test_clip)
GstFlowReturn ret; GstFlowReturn ret;
GstEvent *event; GstEvent *event;
GstBuffer *buffer; GstBuffer *buffer;
GstCaps *caps; //FIXME: GstCaps *caps;
GST_INFO ("preparing test"); GST_INFO ("preparing test");
@ -780,22 +781,26 @@ GST_START_TEST (test_clip)
fail_if (sinkpad == NULL, NULL); fail_if (sinkpad == NULL, NULL);
/* send segment to adder */ /* send segment to adder */
event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, gst_segment_init (&segment, GST_FORMAT_TIME);
GST_SECOND, 2 * GST_SECOND, 0); segment.start = GST_SECOND;
segment.stop = 2 * GST_SECOND;
segment.time = 0;
event = gst_event_new_segment (&segment);
gst_pad_send_event (sinkpad, event); gst_pad_send_event (sinkpad, event);
caps = gst_caps_new_simple ("audio/x-raw-int", /*FIXME: caps = gst_caps_new_simple ("audio/x-raw-int",
"rate", G_TYPE_INT, 44100, "rate", G_TYPE_INT, 44100,
"channels", G_TYPE_INT, 2, "channels", G_TYPE_INT, 2,
"endianness", G_TYPE_INT, G_BYTE_ORDER, "endianness", G_TYPE_INT, G_BYTE_ORDER,
"width", G_TYPE_INT, 16, "width", G_TYPE_INT, 16,
"depth", G_TYPE_INT, 16, "signed", G_TYPE_BOOLEAN, TRUE, NULL); "depth", G_TYPE_INT, 16, "signed", G_TYPE_BOOLEAN, TRUE, NULL);
*/
/* should be clipped and ok */ /* should be clipped and ok */
buffer = gst_buffer_new_and_alloc (44100); buffer = gst_buffer_new_and_alloc (44100);
GST_BUFFER_TIMESTAMP (buffer) = 0; GST_BUFFER_TIMESTAMP (buffer) = 0;
GST_BUFFER_DURATION (buffer) = 250 * GST_MSECOND; GST_BUFFER_DURATION (buffer) = 250 * GST_MSECOND;
gst_buffer_set_caps (buffer, caps); //FIXME: gst_buffer_set_caps (buffer, caps);
GST_DEBUG ("pushing buffer %p", buffer); GST_DEBUG ("pushing buffer %p", buffer);
ret = gst_pad_chain (sinkpad, buffer); ret = gst_pad_chain (sinkpad, buffer);
fail_unless (ret == GST_FLOW_OK); fail_unless (ret == GST_FLOW_OK);
@ -805,7 +810,7 @@ GST_START_TEST (test_clip)
buffer = gst_buffer_new_and_alloc (44100); buffer = gst_buffer_new_and_alloc (44100);
GST_BUFFER_TIMESTAMP (buffer) = 900 * GST_MSECOND; GST_BUFFER_TIMESTAMP (buffer) = 900 * GST_MSECOND;
GST_BUFFER_DURATION (buffer) = 250 * GST_MSECOND; GST_BUFFER_DURATION (buffer) = 250 * GST_MSECOND;
gst_buffer_set_caps (buffer, caps); //FIXME: gst_buffer_set_caps (buffer, caps);
GST_DEBUG ("pushing buffer %p", buffer); GST_DEBUG ("pushing buffer %p", buffer);
ret = gst_pad_chain (sinkpad, buffer); ret = gst_pad_chain (sinkpad, buffer);
fail_unless (ret == GST_FLOW_OK); fail_unless (ret == GST_FLOW_OK);
@ -816,7 +821,7 @@ GST_START_TEST (test_clip)
buffer = gst_buffer_new_and_alloc (44100); buffer = gst_buffer_new_and_alloc (44100);
GST_BUFFER_TIMESTAMP (buffer) = 1 * GST_SECOND; GST_BUFFER_TIMESTAMP (buffer) = 1 * GST_SECOND;
GST_BUFFER_DURATION (buffer) = 250 * GST_MSECOND; GST_BUFFER_DURATION (buffer) = 250 * GST_MSECOND;
gst_buffer_set_caps (buffer, caps); //FIXME: gst_buffer_set_caps (buffer, caps);
GST_DEBUG ("pushing buffer %p", buffer); GST_DEBUG ("pushing buffer %p", buffer);
ret = gst_pad_chain (sinkpad, buffer); ret = gst_pad_chain (sinkpad, buffer);
fail_unless (ret == GST_FLOW_OK); fail_unless (ret == GST_FLOW_OK);
@ -827,7 +832,7 @@ GST_START_TEST (test_clip)
buffer = gst_buffer_new_and_alloc (44100); buffer = gst_buffer_new_and_alloc (44100);
GST_BUFFER_TIMESTAMP (buffer) = 2 * GST_SECOND; GST_BUFFER_TIMESTAMP (buffer) = 2 * GST_SECOND;
GST_BUFFER_DURATION (buffer) = 250 * GST_MSECOND; GST_BUFFER_DURATION (buffer) = 250 * GST_MSECOND;
gst_buffer_set_caps (buffer, caps); //FIXME: gst_buffer_set_caps (buffer, caps);
GST_DEBUG ("pushing buffer %p", buffer); GST_DEBUG ("pushing buffer %p", buffer);
ret = gst_pad_chain (sinkpad, buffer); ret = gst_pad_chain (sinkpad, buffer);
fail_unless (ret == GST_FLOW_OK); fail_unless (ret == GST_FLOW_OK);

View File

@ -363,6 +363,7 @@ GST_START_TEST (test_video_formats)
guint i; guint i;
for (i = 0; i < G_N_ELEMENTS (fourcc_list); ++i) { for (i = 0; i < G_N_ELEMENTS (fourcc_list); ++i) {
const GstVideoFormatInfo *vf_info;
GstVideoFormat fmt; GstVideoFormat fmt;
const gchar *s; const gchar *s;
guint32 fourcc; guint32 fourcc;
@ -375,49 +376,58 @@ GST_START_TEST (test_video_formats)
if (fmt == GST_VIDEO_FORMAT_UNKNOWN) if (fmt == GST_VIDEO_FORMAT_UNKNOWN)
continue; continue;
GST_INFO ("Fourcc %s, packed=%d", fourcc_list[i].fourcc, vf_info = gst_video_format_get_info (fmt);
fail_unless (vf_info != NULL);
fail_unless_equals_int (GST_VIDEO_FORMAT_INFO_FORMAT (vf_info), fmt);
GST_INFO ("Fourcc %s, packed=%", fourcc_list[i].fourcc,
gst_video_format_is_packed (fmt)); gst_video_format_is_packed (fmt));
fail_unless (gst_video_format_is_yuv (fmt)); fail_unless (GST_VIDEO_FORMAT_INFO_IS_YUV (vf_info));
/* use any non-NULL pointer so we can compare against NULL */ /* use any non-NULL pointer so we can compare against NULL */
{ {
paintinfo paintinfo = { 0, }; paintinfo paintinfo = { 0, };
fourcc_list[i].paint_setup (&paintinfo, (unsigned char *) s); fourcc_list[i].paint_setup (&paintinfo, (unsigned char *) s);
if (paintinfo.ap != NULL) { if (paintinfo.ap != NULL) {
fail_unless (gst_video_format_has_alpha (fmt)); fail_unless (GST_VIDEO_FORMAT_INFO_HAS_ALPHA (vf_info));
} else { } else {
fail_if (gst_video_format_has_alpha (fmt)); fail_if (GST_VIDEO_FORMAT_INFO_HAS_ALPHA (vf_info));
} }
} }
for (w = 1; w <= 65; ++w) { for (w = 1; w <= 65; ++w) {
for (h = 1; h <= 65; ++h) { for (h = 1; h <= 65; ++h) {
GstVideoInfo vinfo;
paintinfo paintinfo = { 0, }; paintinfo paintinfo = { 0, };
guint off0, off1, off2, off3; guint off0, off1, off2, off3;
guint size; guint size;
GST_LOG ("%s, %dx%d", fourcc_list[i].fourcc, w, h); GST_LOG ("%s, %dx%d", fourcc_list[i].fourcc, w, h);
gst_video_info_init (&vinfo);
gst_video_info_set_format (&vinfo, fmt, w, h);
paintinfo.width = w; paintinfo.width = w;
paintinfo.height = h; paintinfo.height = h;
fourcc_list[i].paint_setup (&paintinfo, NULL); fourcc_list[i].paint_setup (&paintinfo, NULL);
fail_unless_equals_int (gst_video_format_get_row_stride (fmt, 0, w), fail_unless_equals_int (GST_VIDEO_INFO_COMP_STRIDE (&vinfo, 0),
paintinfo.ystride); paintinfo.ystride);
if (!gst_video_format_is_packed (fmt) if (!gst_video_format_is_packed (fmt)
&& !gst_video_format_is_gray (fmt)) { && !GST_VIDEO_FORMAT_INFO_IS_GRAY (vf_info)) {
/* planar */ /* planar */
fail_unless_equals_int (gst_video_format_get_row_stride (fmt, 1, w), fail_unless_equals_int (GST_VIDEO_INFO_COMP_STRIDE (&vinfo, 1),
paintinfo.ustride); paintinfo.ustride);
fail_unless_equals_int (gst_video_format_get_row_stride (fmt, 2, w), fail_unless_equals_int (GST_VIDEO_INFO_COMP_STRIDE (&vinfo, 2),
paintinfo.vstride); paintinfo.vstride);
/* check component_width * height against offsets/size somehow? */ /* check component_width * height against offsets/size somehow? */
} }
size = gst_video_format_get_size (fmt, w, h); size = GST_VIDEO_INFO_SIZE (&vinfo);
off0 = gst_video_format_get_component_offset (fmt, 0, w, h); off0 = GST_VIDEO_INFO_COMP_OFFSET (&vinfo, 0);
off1 = gst_video_format_get_component_offset (fmt, 1, w, h); off1 = GST_VIDEO_INFO_COMP_OFFSET (&vinfo, 1);
off2 = gst_video_format_get_component_offset (fmt, 2, w, h); off2 = GST_VIDEO_INFO_COMP_OFFSET (&vinfo, 2);
fail_unless_equals_int (size, (unsigned long) paintinfo.endptr); fail_unless_equals_int (size, (unsigned long) paintinfo.endptr);
fail_unless_equals_int (off0, (unsigned long) paintinfo.yp); fail_unless_equals_int (off0, (unsigned long) paintinfo.yp);
@ -425,7 +435,7 @@ GST_START_TEST (test_video_formats)
fail_unless_equals_int (off2, (unsigned long) paintinfo.vp); fail_unless_equals_int (off2, (unsigned long) paintinfo.vp);
/* should be 0 if there's no alpha component */ /* should be 0 if there's no alpha component */
off3 = gst_video_format_get_component_offset (fmt, 3, w, h); off3 = GST_VIDEO_INFO_COMP_OFFSET (&vinfo, 3);
fail_unless_equals_int (off3, (unsigned long) paintinfo.ap); fail_unless_equals_int (off3, (unsigned long) paintinfo.ap);
/* some gstvideo checks ... (FIXME: fails for Y41B and Y42B; not sure /* some gstvideo checks ... (FIXME: fails for Y41B and Y42B; not sure
@ -434,12 +444,12 @@ GST_START_TEST (test_video_formats)
&& fmt != GST_VIDEO_FORMAT_Y800) { && fmt != GST_VIDEO_FORMAT_Y800) {
guint cs0, cs1, cs2, cs3; guint cs0, cs1, cs2, cs3;
cs0 = gst_video_format_get_component_width (fmt, 0, w) * cs0 = GST_VIDEO_INFO_COMP_WIDTH (&vinfo, 0) *
gst_video_format_get_component_height (fmt, 0, h); GST_VIDEO_INFO_COMP_HEIGHT (&vinfo, 0);
cs1 = gst_video_format_get_component_width (fmt, 1, w) * cs1 = GST_VIDEO_INFO_COMP_WIDTH (&vinfo, 1) *
gst_video_format_get_component_height (fmt, 1, h); GST_VIDEO_INFO_COMP_HEIGHT (&vinfo, 1);
cs2 = gst_video_format_get_component_width (fmt, 2, w) * cs2 = GST_VIDEO_INFO_COMP_WIDTH (&vinfo, 2) *
gst_video_format_get_component_height (fmt, 2, h); GST_VIDEO_INFO_COMP_HEIGHT (&vinfo, 2);
/* GST_LOG ("cs0=%d,cs1=%d,cs2=%d,off0=%d,off1=%d,off2=%d,size=%d", /* GST_LOG ("cs0=%d,cs1=%d,cs2=%d,off0=%d,off1=%d,off2=%d,size=%d",
cs0, cs1, cs2, off0, off1, off2, size); */ cs0, cs1, cs2, off0, off1, off2, size); */
@ -447,9 +457,9 @@ GST_START_TEST (test_video_formats)
if (!gst_video_format_is_packed (fmt)) if (!gst_video_format_is_packed (fmt))
fail_unless (cs0 <= off1); fail_unless (cs0 <= off1);
if (gst_video_format_has_alpha (fmt)) { if (GST_VIDEO_FORMAT_INFO_HAS_ALPHA (vinfo.finfo)) {
cs3 = gst_video_format_get_component_width (fmt, 3, w) * cs3 = GST_VIDEO_INFO_COMP_WIDTH (&vinfo, 3) *
gst_video_format_get_component_height (fmt, 3, h); GST_VIDEO_INFO_COMP_HEIGHT (&vinfo, 2);
fail_unless (cs3 < size); fail_unless (cs3 < size);
/* U/V/alpha shouldn't take up more space than the Y component */ /* U/V/alpha shouldn't take up more space than the Y component */
fail_if (cs1 > cs0, "cs1 (%d) should be <= cs0 (%d)", cs1, cs0); fail_if (cs1 > cs0, "cs1 (%d) should be <= cs0 (%d)", cs1, cs0);
@ -478,11 +488,17 @@ GST_END_TEST;
GST_START_TEST (test_video_formats_rgb) GST_START_TEST (test_video_formats_rgb)
{ {
GstVideoInfo vinfo;
gint width, height, framerate_n, framerate_d, par_n, par_d; gint width, height, framerate_n, framerate_d, par_n, par_d;
GstCaps *caps = GstCaps *caps;
gst_video_format_new_caps (GST_VIDEO_FORMAT_RGB, 800, 600, 0, 1, 1, 1);
GstStructure *structure; GstStructure *structure;
gst_video_info_set_format (&vinfo, GST_VIDEO_FORMAT_RGB, 800, 600);
vinfo.par_n = 1;
vinfo.par_d = 1;
vinfo.fps_n = 0;
vinfo.fps_d = 1;
caps = gst_video_info_to_caps (&vinfo);
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
fail_unless (gst_structure_get_int (structure, "width", &width)); fail_unless (gst_structure_get_int (structure, "width", &width));
@ -504,15 +520,6 @@ GST_START_TEST (test_video_formats_rgb)
GST_END_TEST; GST_END_TEST;
GST_START_TEST (test_video_template_caps)
{
GstCaps *caps = gst_video_format_new_template_caps (GST_VIDEO_FORMAT_RGB);
gst_caps_unref (caps);
}
GST_END_TEST;
GST_START_TEST (test_dar_calc) GST_START_TEST (test_dar_calc)
{ {
guint display_ratio_n, display_ratio_d; guint display_ratio_n, display_ratio_d;
@ -546,27 +553,26 @@ GST_START_TEST (test_parse_caps_rgb)
} formats[] = { } formats[] = {
/* 24 bit */ /* 24 bit */
{ {
GST_VIDEO_CAPS_RGB, GST_VIDEO_FORMAT_RGB}, { GST_VIDEO_CAPS_MAKE ("RGB"), GST_VIDEO_FORMAT_RGB}, {
GST_VIDEO_CAPS_BGR, GST_VIDEO_FORMAT_BGR}, GST_VIDEO_CAPS_MAKE ("BGR"), GST_VIDEO_FORMAT_BGR},
/* 32 bit (no alpha) */ /* 32 bit (no alpha) */
{ {
GST_VIDEO_CAPS_RGBx, GST_VIDEO_FORMAT_RGBx}, { GST_VIDEO_CAPS_MAKE ("RGBx"), GST_VIDEO_FORMAT_RGBx}, {
GST_VIDEO_CAPS_xRGB, GST_VIDEO_FORMAT_xRGB}, { GST_VIDEO_CAPS_MAKE ("xRGB"), GST_VIDEO_FORMAT_xRGB}, {
GST_VIDEO_CAPS_BGRx, GST_VIDEO_FORMAT_BGRx}, { GST_VIDEO_CAPS_MAKE ("BGRx"), GST_VIDEO_FORMAT_BGRx}, {
GST_VIDEO_CAPS_xBGR, GST_VIDEO_FORMAT_xBGR}, GST_VIDEO_CAPS_MAKE ("xBGR"), GST_VIDEO_FORMAT_xBGR},
/* 32 bit (with alpha) */ /* 32 bit (with alpha) */
{ {
GST_VIDEO_CAPS_RGBA, GST_VIDEO_FORMAT_RGBA}, { GST_VIDEO_CAPS_MAKE ("RGBA"), GST_VIDEO_FORMAT_RGBA}, {
GST_VIDEO_CAPS_ARGB, GST_VIDEO_FORMAT_ARGB}, { GST_VIDEO_CAPS_MAKE ("ARGB"), GST_VIDEO_FORMAT_ARGB}, {
GST_VIDEO_CAPS_BGRA, GST_VIDEO_FORMAT_BGRA}, { GST_VIDEO_CAPS_MAKE ("BGRA"), GST_VIDEO_FORMAT_BGRA}, {
GST_VIDEO_CAPS_ABGR, GST_VIDEO_FORMAT_ABGR} GST_VIDEO_CAPS_MAKE ("ABGR"), GST_VIDEO_FORMAT_ABGR}
}; };
gint i; gint i;
for (i = 0; i < G_N_ELEMENTS (formats); ++i) { for (i = 0; i < G_N_ELEMENTS (formats); ++i) {
GstVideoFormat fmt = GST_VIDEO_FORMAT_UNKNOWN; GstVideoInfo vinfo;
GstCaps *caps, *caps2; GstCaps *caps, *caps2;
int w = -1, h = -1;
caps = gst_caps_from_string (formats[i].tmpl_caps_string); caps = gst_caps_from_string (formats[i].tmpl_caps_string);
gst_caps_set_simple (caps, "width", G_TYPE_INT, 2 * (i + 1), "height", gst_caps_set_simple (caps, "width", G_TYPE_INT, 2 * (i + 1), "height",
@ -576,13 +582,14 @@ GST_START_TEST (test_parse_caps_rgb)
GST_DEBUG ("testing caps: %" GST_PTR_FORMAT, caps); GST_DEBUG ("testing caps: %" GST_PTR_FORMAT, caps);
fail_unless (gst_video_format_parse_caps (caps, &fmt, &w, &h)); gst_video_info_init (&vinfo);
fail_unless_equals_int (fmt, formats[i].fmt); fail_unless (gst_video_info_from_caps (&vinfo, caps));
fail_unless_equals_int (w, 2 * (i + 1)); fail_unless_equals_int (GST_VIDEO_INFO_FORMAT (&vinfo), formats[i].fmt);
fail_unless_equals_int (h, i + 1); fail_unless_equals_int (GST_VIDEO_INFO_WIDTH (&vinfo), 2 * (i + 1));
fail_unless_equals_int (GST_VIDEO_INFO_HEIGHT (&vinfo), i + 1);
/* make sure they're serialised back correctly */ /* make sure they're serialised back correctly */
caps2 = gst_video_format_new_caps (fmt, w, h, 15, 1, 1, 1); caps2 = gst_video_info_to_caps (&vinfo);
fail_unless (caps != NULL); fail_unless (caps != NULL);
fail_unless (gst_caps_is_equal (caps, caps2)); fail_unless (gst_caps_is_equal (caps, caps2));
@ -621,6 +628,7 @@ GST_END_TEST;
GST_START_TEST (test_convert_frame) GST_START_TEST (test_convert_frame)
{ {
GstVideoInfo vinfo;
GstCaps *from_caps, *to_caps; GstCaps *from_caps, *to_caps;
GstBuffer *from_buffer, *to_buffer; GstBuffer *from_buffer, *to_buffer;
GError *error = NULL; GError *error = NULL;
@ -638,30 +646,38 @@ GST_START_TEST (test_convert_frame)
} }
gst_buffer_unmap (from_buffer, data, 640 * 480 * 4); gst_buffer_unmap (from_buffer, data, 640 * 480 * 4);
from_caps = gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, gst_video_info_init (&vinfo);
640, 480, 25, 1, 1, 1); gst_video_info_set_format (&vinfo, GST_VIDEO_FORMAT_xRGB, 640, 480);
gst_buffer_set_caps (from_buffer, from_caps); vinfo.fps_n = 25;
vinfo.fps_d = 1;
vinfo.par_n = 1;
vinfo.par_d = 1;
from_caps = gst_video_info_to_caps (&vinfo);
to_caps = to_caps =
gst_caps_from_string gst_caps_from_string
("something/that, does=(string)not, exist=(boolean)FALSE"); ("something/that, does=(string)not, exist=(boolean)FALSE");
to_buffer = to_buffer =
gst_video_convert_frame (from_buffer, to_caps, GST_CLOCK_TIME_NONE, gst_video_convert_frame (from_buffer, from_caps, to_caps,
&error); GST_CLOCK_TIME_NONE, &error);
fail_if (to_buffer != NULL); fail_if (to_buffer != NULL);
fail_unless (error != NULL); fail_unless (error != NULL);
g_error_free (error); g_error_free (error);
error = NULL; error = NULL;
gst_caps_unref (to_caps); gst_caps_unref (to_caps);
to_caps = gst_video_info_set_format (&vinfo, GST_VIDEO_FORMAT_I420, 240, 320);
gst_video_format_new_caps (GST_VIDEO_FORMAT_I420, 240, 320, 25, 1, 1, 2); vinfo.fps_n = 25;
vinfo.fps_d = 1;
vinfo.par_n = 1;
vinfo.par_d = 2;
to_caps = gst_video_info_to_caps (&vinfo);
to_buffer = to_buffer =
gst_video_convert_frame (from_buffer, to_caps, GST_CLOCK_TIME_NONE, gst_video_convert_frame (from_buffer, from_caps, to_caps,
&error); GST_CLOCK_TIME_NONE, &error);
fail_unless (to_buffer != NULL); fail_unless (to_buffer != NULL);
fail_unless (gst_caps_can_intersect (to_caps, GST_BUFFER_CAPS (to_buffer)));
fail_unless (error == NULL); fail_unless (error == NULL);
gst_buffer_unref (from_buffer); gst_buffer_unref (from_buffer);
@ -691,6 +707,7 @@ convert_frame_async_callback (GstBuffer * buf, GError * err,
GST_START_TEST (test_convert_frame_async) GST_START_TEST (test_convert_frame_async)
{ {
GstVideoInfo vinfo;
GstCaps *from_caps, *to_caps; GstCaps *from_caps, *to_caps;
GstBuffer *from_buffer; GstBuffer *from_buffer;
gint i; gint i;
@ -709,9 +726,13 @@ GST_START_TEST (test_convert_frame_async)
} }
gst_buffer_unmap (from_buffer, data, 640 * 480 * 4); gst_buffer_unmap (from_buffer, data, 640 * 480 * 4);
from_caps = gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, gst_video_info_init (&vinfo);
640, 480, 25, 1, 1, 1); gst_video_info_set_format (&vinfo, GST_VIDEO_FORMAT_xRGB, 640, 470);
gst_buffer_set_caps (from_buffer, from_caps); vinfo.par_n = 1;
vinfo.par_d = 1;
vinfo.fps_n = 25;
vinfo.fps_d = 1;
from_caps = gst_video_info_to_caps (&vinfo);
to_caps = to_caps =
gst_caps_from_string gst_caps_from_string
@ -719,7 +740,8 @@ GST_START_TEST (test_convert_frame_async)
loop = cf_data.loop = g_main_loop_new (NULL, FALSE); loop = cf_data.loop = g_main_loop_new (NULL, FALSE);
gst_video_convert_frame_async (from_buffer, to_caps, GST_CLOCK_TIME_NONE, gst_video_convert_frame_async (from_buffer, from_caps, to_caps,
GST_CLOCK_TIME_NONE,
(GstVideoConvertFrameCallback) convert_frame_async_callback, &cf_data, (GstVideoConvertFrameCallback) convert_frame_async_callback, &cf_data,
NULL); NULL);
@ -731,15 +753,19 @@ GST_START_TEST (test_convert_frame_async)
cf_data.error = NULL; cf_data.error = NULL;
gst_caps_unref (to_caps); gst_caps_unref (to_caps);
to_caps = gst_video_info_init (&vinfo);
gst_video_format_new_caps (GST_VIDEO_FORMAT_I420, 240, 320, 25, 1, 1, 2); gst_video_info_set_format (&vinfo, GST_VIDEO_FORMAT_I420, 240, 320);
gst_video_convert_frame_async (from_buffer, to_caps, GST_CLOCK_TIME_NONE, vinfo.par_n = 1;
vinfo.par_d = 2;
vinfo.fps_n = 25;
vinfo.fps_d = 1;
to_caps = gst_video_info_to_caps (&vinfo);
gst_video_convert_frame_async (from_buffer, from_caps, to_caps,
GST_CLOCK_TIME_NONE,
(GstVideoConvertFrameCallback) convert_frame_async_callback, &cf_data, (GstVideoConvertFrameCallback) convert_frame_async_callback, &cf_data,
NULL); NULL);
g_main_loop_run (loop); g_main_loop_run (loop);
fail_unless (cf_data.buffer != NULL); fail_unless (cf_data.buffer != NULL);
fail_unless (gst_caps_can_intersect (to_caps,
GST_BUFFER_CAPS (cf_data.buffer)));
fail_unless (cf_data.error == NULL); fail_unless (cf_data.error == NULL);
gst_buffer_unref (from_buffer); gst_buffer_unref (from_buffer);
@ -754,20 +780,17 @@ GST_END_TEST;
GST_START_TEST (test_video_size_from_caps) GST_START_TEST (test_video_size_from_caps)
{ {
gint size; GstVideoInfo vinfo;
GstCaps *caps;
GstCaps *caps = gst_caps_new_simple ("video/x-raw", caps = gst_caps_new_simple ("video/x-raw",
"format", G_TYPE_STRING, "YV12", "format", G_TYPE_STRING, "YV12",
"width", G_TYPE_INT, 640, "width", G_TYPE_INT, 640,
"height", G_TYPE_INT, 480, "height", G_TYPE_INT, 480, "framerate", GST_TYPE_FRACTION, 25, 1, NULL);
"framerate", GST_TYPE_FRACTION, 25, 1,
NULL);
fail_unless (gst_video_get_size_from_caps (caps, &size)); gst_video_info_init (&vinfo);
fail_unless (size == fail_unless (gst_video_info_from_caps (&vinfo, caps));
gst_video_format_get_size (gst_video_format_from_fourcc (fourcc), 640, fail_unless (GST_VIDEO_INFO_SIZE (&vinfo) == (640 * 480 * 12 / 8));
480));
fail_unless (size == (640 * 480 * 12 / 8));
gst_caps_unref (caps); gst_caps_unref (caps);
} }
@ -783,7 +806,6 @@ video_suite (void)
suite_add_tcase (s, tc_chain); suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_video_formats); tcase_add_test (tc_chain, test_video_formats);
tcase_add_test (tc_chain, test_video_formats_rgb); tcase_add_test (tc_chain, test_video_formats_rgb);
tcase_add_test (tc_chain, test_video_template_caps);
tcase_add_test (tc_chain, test_dar_calc); tcase_add_test (tc_chain, test_dar_calc);
tcase_add_test (tc_chain, test_parse_caps_rgb); tcase_add_test (tc_chain, test_parse_caps_rgb);
tcase_add_test (tc_chain, test_events); tcase_add_test (tc_chain, test_events);