mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
tests: aspectratiocrop: Port to 0.11
This commit is contained in:
parent
12534340fd
commit
2490d39a90
1 changed files with 33 additions and 44 deletions
|
@ -25,42 +25,17 @@
|
|||
#include <gst/video/video.h>
|
||||
#include <gst/check/gstcheck.h>
|
||||
|
||||
#define ASPECT_RATIO_CROP_CAPS \
|
||||
GST_VIDEO_CAPS_RGBx ";" \
|
||||
GST_VIDEO_CAPS_xRGB ";" \
|
||||
GST_VIDEO_CAPS_BGRx ";" \
|
||||
GST_VIDEO_CAPS_xBGR ";" \
|
||||
GST_VIDEO_CAPS_RGBA ";" \
|
||||
GST_VIDEO_CAPS_ARGB ";" \
|
||||
GST_VIDEO_CAPS_BGRA ";" \
|
||||
GST_VIDEO_CAPS_ABGR ";" \
|
||||
GST_VIDEO_CAPS_RGB ";" \
|
||||
GST_VIDEO_CAPS_BGR ";" \
|
||||
GST_VIDEO_CAPS_YUV ("AYUV") ";" \
|
||||
GST_VIDEO_CAPS_YUV ("YUY2") ";" \
|
||||
GST_VIDEO_CAPS_YUV ("YVYU") ";" \
|
||||
GST_VIDEO_CAPS_YUV ("UYVY") ";" \
|
||||
GST_VIDEO_CAPS_YUV ("Y800") ";" \
|
||||
GST_VIDEO_CAPS_YUV ("I420") ";" \
|
||||
GST_VIDEO_CAPS_YUV ("YV12") ";" \
|
||||
GST_VIDEO_CAPS_RGB_16 ";" \
|
||||
GST_VIDEO_CAPS_RGB_15
|
||||
#define ASPECT_RATIO_CROP_CAPS \
|
||||
GST_VIDEO_CAPS_MAKE ("{ RGBx, xRGB, BGRx, xBGR, " \
|
||||
"RGBA, ARGB, BGRA, ABGR, RGB, BGR, AYUV, " \
|
||||
"YUY2, YVYU, UYVY, Y800, I420, YV12, RGB16 " \
|
||||
"RGB15 }")
|
||||
|
||||
static GstBuffer *
|
||||
make_buffer_with_caps (const gchar * caps_string, int buffer_size)
|
||||
{
|
||||
GstCaps *caps;
|
||||
GstBuffer *temp;
|
||||
|
||||
caps = gst_caps_from_string (caps_string);
|
||||
temp = gst_buffer_new_and_alloc (buffer_size);
|
||||
fail_if (caps == NULL);
|
||||
fail_if (temp == NULL);
|
||||
gst_buffer_set_caps (temp, caps);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
return temp;
|
||||
}
|
||||
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (ASPECT_RATIO_CROP_CAPS)
|
||||
);
|
||||
|
||||
static void
|
||||
check_aspectratiocrop (const gchar * in_string, const gchar * out_string,
|
||||
|
@ -73,10 +48,13 @@ check_aspectratiocrop (const gchar * in_string, const gchar * out_string,
|
|||
GstBuffer *new;
|
||||
GstBuffer *buffer;
|
||||
GstBuffer *buffer_out;
|
||||
GstCaps *sink_caps;
|
||||
GstCaps *incaps;
|
||||
GstCaps *outcaps;
|
||||
|
||||
buffer = make_buffer_with_caps (in_string, in_size);
|
||||
buffer_out = make_buffer_with_caps (out_string, out_size);
|
||||
incaps = gst_caps_from_string (in_string);
|
||||
buffer = gst_buffer_new_and_alloc (in_size);
|
||||
outcaps = gst_caps_from_string (out_string);
|
||||
buffer_out = gst_buffer_new_and_alloc (out_size);
|
||||
|
||||
/* check that there are no buffers waiting */
|
||||
gst_check_drop_buffers ();
|
||||
|
@ -89,7 +67,6 @@ check_aspectratiocrop (const gchar * in_string, const gchar * out_string,
|
|||
|
||||
/* create the src pad */
|
||||
src_pad = gst_pad_new (NULL, GST_PAD_SRC);
|
||||
gst_pad_set_caps (src_pad, GST_BUFFER_CAPS (buffer));
|
||||
pad_peer = gst_element_get_static_pad (element, "sink");
|
||||
fail_if (pad_peer == NULL);
|
||||
fail_unless (gst_pad_link (src_pad, pad_peer) == GST_PAD_LINK_OK,
|
||||
|
@ -99,9 +76,7 @@ check_aspectratiocrop (const gchar * in_string, const gchar * out_string,
|
|||
|
||||
/* create the sink pad */
|
||||
pad_peer = gst_element_get_static_pad (element, "src");
|
||||
sink_caps = gst_caps_from_string (ASPECT_RATIO_CROP_CAPS);
|
||||
sink_pad = gst_pad_new (NULL, GST_PAD_SINK);
|
||||
GST_PAD_CAPS (sink_pad) = sink_caps;
|
||||
sink_pad = gst_pad_new_from_static_template (&sinktemplate, "sink");
|
||||
fail_unless (gst_pad_link (pad_peer, sink_pad) == GST_PAD_LINK_OK,
|
||||
"Could not link sink and %s source pads", GST_ELEMENT_NAME (element));
|
||||
gst_object_unref (pad_peer);
|
||||
|
@ -112,6 +87,10 @@ check_aspectratiocrop (const gchar * in_string, const gchar * out_string,
|
|||
fail_unless (gst_element_set_state (element,
|
||||
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
||||
"could not set to playing");
|
||||
|
||||
fail_unless (gst_pad_set_caps (src_pad, incaps),
|
||||
"Couldn't set input caps %" GST_PTR_FORMAT, incaps);
|
||||
|
||||
fail_unless (gst_pad_push (src_pad, buffer) == GST_FLOW_OK,
|
||||
"Failed to push buffer");
|
||||
fail_unless (gst_element_set_state (element,
|
||||
|
@ -121,11 +100,21 @@ check_aspectratiocrop (const gchar * in_string, const gchar * out_string,
|
|||
fail_unless (g_list_length (buffers) == 1);
|
||||
new = GST_BUFFER (buffers->data);
|
||||
buffers = g_list_remove (buffers, new);
|
||||
fail_unless (GST_BUFFER_SIZE (buffer_out) == GST_BUFFER_SIZE (new),
|
||||
fail_unless (gst_buffer_get_size (buffer_out) == gst_buffer_get_size (new),
|
||||
"size of the buffers are not the same");
|
||||
gst_check_caps_equal (GST_BUFFER_CAPS (buffer_out), GST_BUFFER_CAPS (new));
|
||||
{
|
||||
GstCaps *sinkpad_caps;
|
||||
|
||||
sinkpad_caps = gst_pad_get_current_caps (sink_pad);
|
||||
|
||||
gst_check_caps_equal (sinkpad_caps, outcaps);
|
||||
|
||||
gst_caps_unref (sinkpad_caps);
|
||||
}
|
||||
gst_buffer_unref (new);
|
||||
gst_buffer_unref (buffer_out);
|
||||
gst_caps_unref (outcaps);
|
||||
gst_caps_unref (incaps);
|
||||
|
||||
/* teardown the element and pads */
|
||||
gst_pad_set_active (src_pad, FALSE);
|
||||
|
|
Loading…
Reference in a new issue