2009-03-28 09:25:12 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* unit test for videoscale
|
|
|
|
*
|
2010-05-10 15:09:28 +00:00
|
|
|
* Copyright (C) <2009,2010> Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
2009-03-28 09:25:12 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 23:05:09 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2009-03-28 09:25:12 +00:00
|
|
|
*/
|
|
|
|
|
2010-10-28 13:55:12 +00:00
|
|
|
#include <gst/video/video.h>
|
|
|
|
#include <gst/base/gstbasesink.h>
|
|
|
|
|
2009-03-28 09:25:12 +00:00
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2010-06-26 10:38:56 +00:00
|
|
|
/* kids, don't do this at home, skipping checks is *BAD* */
|
|
|
|
#define LINK_CHECK_FLAGS GST_PAD_LINK_CHECK_NOTHING
|
|
|
|
|
2012-07-16 23:31:14 +00:00
|
|
|
static guint
|
|
|
|
get_num_formats (void)
|
|
|
|
{
|
|
|
|
guint i = 2;
|
|
|
|
|
|
|
|
while (gst_video_format_to_string ((GstFormat) i) != NULL)
|
|
|
|
++i;
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
check_pad_template (GstPadTemplate * tmpl)
|
|
|
|
{
|
|
|
|
const GValue *list_val, *fmt_val;
|
|
|
|
GstStructure *s;
|
|
|
|
gboolean *formats_supported;
|
|
|
|
GstCaps *caps;
|
|
|
|
guint i, num_formats;
|
|
|
|
|
|
|
|
num_formats = get_num_formats ();
|
|
|
|
formats_supported = g_new0 (gboolean, num_formats);
|
|
|
|
|
|
|
|
caps = gst_pad_template_get_caps (tmpl);
|
|
|
|
|
|
|
|
/* If this fails, we need to update this unit test */
|
2013-04-09 12:04:47 +00:00
|
|
|
fail_unless_equals_int (gst_caps_get_size (caps), 2);
|
|
|
|
/* Remove the ANY caps features structure */
|
|
|
|
caps = gst_caps_truncate (caps);
|
2012-07-16 23:31:14 +00:00
|
|
|
s = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
fail_unless (gst_structure_has_name (s, "video/x-raw"));
|
|
|
|
|
|
|
|
list_val = gst_structure_get_value (s, "format");
|
|
|
|
fail_unless (list_val != NULL);
|
|
|
|
/* If this fails, we need to update this unit test */
|
|
|
|
fail_unless (GST_VALUE_HOLDS_LIST (list_val));
|
|
|
|
|
|
|
|
for (i = 0; i < gst_value_list_get_size (list_val); ++i) {
|
|
|
|
GstVideoFormat fmt;
|
|
|
|
const gchar *fmt_str;
|
|
|
|
|
|
|
|
fmt_val = gst_value_list_get_value (list_val, i);
|
|
|
|
fail_unless (G_VALUE_HOLDS_STRING (fmt_val));
|
|
|
|
fmt_str = g_value_get_string (fmt_val);
|
|
|
|
GST_LOG ("format string: '%s'", fmt_str);
|
|
|
|
fmt = gst_video_format_from_string (fmt_str);
|
|
|
|
if (fmt == GST_VIDEO_FORMAT_UNKNOWN)
|
|
|
|
g_error ("Unknown raw format '%s' in pad template caps", fmt_str);
|
|
|
|
formats_supported[(guint) fmt] = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
|
|
|
for (i = 2; i < num_formats; ++i) {
|
|
|
|
if (!formats_supported[i]) {
|
|
|
|
const gchar *fmt_str = gst_video_format_to_string ((GstVideoFormat) i);
|
|
|
|
|
|
|
|
switch (i) {
|
|
|
|
case GST_VIDEO_FORMAT_v210:
|
|
|
|
case GST_VIDEO_FORMAT_v216:
|
|
|
|
case GST_VIDEO_FORMAT_NV12:
|
|
|
|
case GST_VIDEO_FORMAT_NV21:
|
|
|
|
case GST_VIDEO_FORMAT_UYVP:
|
|
|
|
case GST_VIDEO_FORMAT_A420:
|
|
|
|
case GST_VIDEO_FORMAT_YUV9:
|
|
|
|
case GST_VIDEO_FORMAT_YVU9:
|
|
|
|
case GST_VIDEO_FORMAT_IYU1:
|
|
|
|
case GST_VIDEO_FORMAT_r210:{
|
|
|
|
static gboolean shown_fixme[100] = { FALSE, };
|
|
|
|
|
|
|
|
if (!shown_fixme[i]) {
|
2012-08-05 16:21:31 +00:00
|
|
|
GST_FIXME ("FIXME: add %s support to videoscale", fmt_str);
|
2012-07-16 23:31:14 +00:00
|
|
|
shown_fixme[i] = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_VIDEO_FORMAT_BGR16:
|
|
|
|
case GST_VIDEO_FORMAT_BGR15:
|
|
|
|
case GST_VIDEO_FORMAT_RGB8P:
|
|
|
|
case GST_VIDEO_FORMAT_I420_10BE:
|
|
|
|
case GST_VIDEO_FORMAT_I420_10LE:
|
2012-09-12 08:12:25 +00:00
|
|
|
case GST_VIDEO_FORMAT_I422_10BE:
|
|
|
|
case GST_VIDEO_FORMAT_I422_10LE:
|
2012-11-27 09:30:08 +00:00
|
|
|
case GST_VIDEO_FORMAT_Y444_10BE:
|
|
|
|
case GST_VIDEO_FORMAT_Y444_10LE:
|
|
|
|
case GST_VIDEO_FORMAT_GBR:
|
|
|
|
case GST_VIDEO_FORMAT_GBR_10BE:
|
|
|
|
case GST_VIDEO_FORMAT_GBR_10LE:
|
2012-07-16 23:31:14 +00:00
|
|
|
GST_LOG ("Ignoring lack of support for format %s", fmt_str);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_error ("videoconvert doesn't support format '%s'", fmt_str);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (formats_supported);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_template_formats)
|
|
|
|
{
|
|
|
|
GstElementFactory *f;
|
|
|
|
GstPadTemplate *t;
|
|
|
|
const GList *pad_templates;
|
|
|
|
|
|
|
|
f = gst_element_factory_find ("videoscale");
|
|
|
|
fail_unless (f != NULL);
|
|
|
|
|
|
|
|
pad_templates = gst_element_factory_get_static_pad_templates (f);
|
|
|
|
fail_unless_equals_int (g_list_length ((GList *) pad_templates), 2);
|
|
|
|
|
|
|
|
t = gst_static_pad_template_get (pad_templates->data);
|
|
|
|
check_pad_template (GST_PAD_TEMPLATE (t));
|
|
|
|
gst_object_unref (t);
|
|
|
|
t = gst_static_pad_template_get (pad_templates->next->data);
|
|
|
|
check_pad_template (GST_PAD_TEMPLATE (t));
|
|
|
|
gst_object_unref (t);
|
|
|
|
|
|
|
|
gst_object_unref (f);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2009-03-28 09:25:12 +00:00
|
|
|
static GstCaps **
|
2012-02-26 17:46:24 +00:00
|
|
|
videoscale_get_allowed_caps_for_method (int method)
|
2009-03-28 09:25:12 +00:00
|
|
|
{
|
2012-02-26 17:46:24 +00:00
|
|
|
GstElement *scale;
|
2009-03-28 09:25:12 +00:00
|
|
|
GstCaps *caps, **ret;
|
2012-02-26 17:46:24 +00:00
|
|
|
GstPad *pad;
|
2009-03-28 09:25:12 +00:00
|
|
|
GstStructure *s;
|
|
|
|
gint i, n;
|
|
|
|
|
2012-02-26 17:46:24 +00:00
|
|
|
scale = gst_element_factory_make ("videoscale", "vscale");
|
|
|
|
g_object_set (scale, "method", method, NULL);
|
|
|
|
pad = gst_element_get_static_pad (scale, "sink");
|
2012-03-02 09:00:55 +00:00
|
|
|
caps = gst_pad_query_caps (pad, NULL);
|
2012-02-26 17:46:24 +00:00
|
|
|
gst_object_unref (pad);
|
|
|
|
gst_object_unref (scale);
|
2009-03-28 09:25:12 +00:00
|
|
|
|
2012-03-08 09:59:48 +00:00
|
|
|
caps = gst_caps_normalize (caps);
|
2009-03-28 09:25:12 +00:00
|
|
|
n = gst_caps_get_size (caps);
|
|
|
|
ret = g_new0 (GstCaps *, n + 1);
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
s = gst_caps_get_structure (caps, i);
|
|
|
|
ret[i] = gst_caps_new_empty ();
|
|
|
|
gst_caps_append_structure (ret[i], gst_structure_copy (s));
|
2012-02-26 17:46:24 +00:00
|
|
|
GST_LOG ("method %d supports: %" GST_PTR_FORMAT, method, s);
|
2009-03-28 09:25:12 +00:00
|
|
|
}
|
|
|
|
|
2011-05-17 11:03:57 +00:00
|
|
|
gst_caps_unref (caps);
|
2009-03-28 09:25:12 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_sink_handoff (GstElement * element, GstBuffer * buffer, GstPad * pad,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
guint *n_buffers = user_data;
|
|
|
|
|
|
|
|
*n_buffers = *n_buffers + 1;
|
|
|
|
}
|
|
|
|
|
2011-02-21 17:55:04 +00:00
|
|
|
static gboolean
|
2012-07-16 23:31:57 +00:00
|
|
|
videoconvert_supports_caps (const GstCaps * caps)
|
2011-02-21 17:55:04 +00:00
|
|
|
{
|
2012-02-03 11:41:10 +00:00
|
|
|
GST_DEBUG ("have caps %" GST_PTR_FORMAT, caps);
|
2012-07-16 23:31:57 +00:00
|
|
|
return TRUE;
|
2011-02-21 17:55:04 +00:00
|
|
|
}
|
|
|
|
|
2009-03-28 09:25:12 +00:00
|
|
|
static void
|
|
|
|
run_test (const GstCaps * caps, gint src_width, gint src_height,
|
|
|
|
gint dest_width, gint dest_height, gint method,
|
|
|
|
GCallback src_handoff, gpointer src_handoff_user_data,
|
|
|
|
GCallback sink_handoff, gpointer sink_handoff_user_data)
|
|
|
|
{
|
|
|
|
GstElement *pipeline;
|
2011-07-07 20:24:38 +00:00
|
|
|
GstElement *src, *videoconvert, *capsfilter1, *identity, *scale,
|
2010-06-13 20:17:18 +00:00
|
|
|
*capsfilter2, *sink;
|
2010-06-26 11:03:54 +00:00
|
|
|
GstMessage *msg;
|
2009-03-28 09:25:12 +00:00
|
|
|
GstBus *bus;
|
|
|
|
GstCaps *copy;
|
|
|
|
guint n_buffers = 0;
|
|
|
|
|
2011-07-07 20:24:38 +00:00
|
|
|
/* skip formats that videoconvert can't handle */
|
2012-07-16 23:31:57 +00:00
|
|
|
if (!videoconvert_supports_caps (caps))
|
2011-02-21 17:55:04 +00:00
|
|
|
return;
|
|
|
|
|
2009-03-28 09:25:12 +00:00
|
|
|
pipeline = gst_element_factory_make ("pipeline", "pipeline");
|
|
|
|
fail_unless (pipeline != NULL);
|
|
|
|
|
|
|
|
src = gst_element_factory_make ("videotestsrc", "src");
|
|
|
|
fail_unless (src != NULL);
|
2010-06-14 14:02:13 +00:00
|
|
|
g_object_set (G_OBJECT (src), "num-buffers", 1, NULL);
|
2009-03-28 09:25:12 +00:00
|
|
|
|
2011-07-07 20:24:38 +00:00
|
|
|
videoconvert = gst_element_factory_make ("videoconvert", "csp");
|
|
|
|
fail_unless (videoconvert != NULL);
|
2010-06-13 20:17:18 +00:00
|
|
|
|
2009-03-28 09:25:12 +00:00
|
|
|
capsfilter1 = gst_element_factory_make ("capsfilter", "filter1");
|
|
|
|
fail_unless (capsfilter1 != NULL);
|
|
|
|
copy = gst_caps_copy (caps);
|
|
|
|
gst_caps_set_simple (copy, "width", G_TYPE_INT, src_width, "height",
|
|
|
|
G_TYPE_INT, src_height, "framerate", GST_TYPE_FRACTION, 30, 1, NULL);
|
|
|
|
g_object_set (G_OBJECT (capsfilter1), "caps", copy, NULL);
|
|
|
|
gst_caps_unref (copy);
|
|
|
|
|
|
|
|
identity = gst_element_factory_make ("identity", "identity");
|
|
|
|
fail_unless (identity != NULL);
|
|
|
|
if (src_handoff) {
|
|
|
|
g_object_set (G_OBJECT (identity), "signal-handoffs", TRUE, NULL);
|
|
|
|
g_signal_connect (identity, "handoff", G_CALLBACK (src_handoff),
|
|
|
|
src_handoff_user_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
scale = gst_element_factory_make ("videoscale", "scale");
|
|
|
|
fail_unless (scale != NULL);
|
|
|
|
g_object_set (G_OBJECT (scale), "method", method, NULL);
|
|
|
|
|
|
|
|
capsfilter2 = gst_element_factory_make ("capsfilter", "filter2");
|
|
|
|
fail_unless (capsfilter2 != NULL);
|
|
|
|
copy = gst_caps_copy (caps);
|
|
|
|
gst_caps_set_simple (copy, "width", G_TYPE_INT, dest_width, "height",
|
|
|
|
G_TYPE_INT, dest_height, NULL);
|
|
|
|
g_object_set (G_OBJECT (capsfilter2), "caps", copy, NULL);
|
|
|
|
gst_caps_unref (copy);
|
|
|
|
|
|
|
|
sink = gst_element_factory_make ("fakesink", "sink");
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
g_object_set (G_OBJECT (sink), "signal-handoffs", TRUE, "async", FALSE, NULL);
|
|
|
|
g_signal_connect (sink, "handoff", G_CALLBACK (on_sink_handoff), &n_buffers);
|
|
|
|
if (sink_handoff) {
|
|
|
|
g_signal_connect (sink, "handoff", G_CALLBACK (sink_handoff),
|
|
|
|
sink_handoff_user_data);
|
|
|
|
}
|
|
|
|
|
2011-07-07 20:24:38 +00:00
|
|
|
gst_bin_add_many (GST_BIN (pipeline), src, videoconvert, capsfilter1,
|
2010-06-13 20:17:18 +00:00
|
|
|
identity, scale, capsfilter2, sink, NULL);
|
2010-06-26 10:38:56 +00:00
|
|
|
|
2011-07-07 20:24:38 +00:00
|
|
|
fail_unless (gst_element_link_pads_full (src, "src", videoconvert, "sink",
|
2010-06-26 10:38:56 +00:00
|
|
|
LINK_CHECK_FLAGS));
|
2011-07-07 20:24:38 +00:00
|
|
|
fail_unless (gst_element_link_pads_full (videoconvert, "src", capsfilter1,
|
2010-06-26 10:38:56 +00:00
|
|
|
"sink", LINK_CHECK_FLAGS));
|
|
|
|
fail_unless (gst_element_link_pads_full (capsfilter1, "src", identity, "sink",
|
|
|
|
LINK_CHECK_FLAGS));
|
|
|
|
fail_unless (gst_element_link_pads_full (identity, "src", scale, "sink",
|
|
|
|
LINK_CHECK_FLAGS));
|
|
|
|
fail_unless (gst_element_link_pads_full (scale, "src", capsfilter2, "sink",
|
|
|
|
LINK_CHECK_FLAGS));
|
|
|
|
fail_unless (gst_element_link_pads_full (capsfilter2, "src", sink, "sink",
|
|
|
|
LINK_CHECK_FLAGS));
|
2009-03-28 09:25:12 +00:00
|
|
|
|
|
|
|
bus = gst_element_get_bus (pipeline);
|
|
|
|
fail_unless (bus != NULL);
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (pipeline,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
2010-06-26 11:03:54 +00:00
|
|
|
msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
|
|
|
|
GST_MESSAGE_EOS | GST_MESSAGE_ERROR | GST_MESSAGE_WARNING);
|
|
|
|
|
|
|
|
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_EOS);
|
2009-03-28 09:25:12 +00:00
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (pipeline,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
2010-06-14 14:07:21 +00:00
|
|
|
fail_unless (n_buffers == 1);
|
2009-03-28 09:25:12 +00:00
|
|
|
|
|
|
|
gst_object_unref (pipeline);
|
2010-06-26 11:03:54 +00:00
|
|
|
gst_message_unref (msg);
|
|
|
|
gst_object_unref (bus);
|
2009-03-28 09:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_sink_handoff_passthrough (GstElement * element, GstBuffer * buffer,
|
|
|
|
GstPad * pad, gpointer user_data)
|
|
|
|
{
|
|
|
|
GList **list = user_data;
|
|
|
|
|
|
|
|
*list = g_list_prepend (*list, gst_buffer_ref (buffer));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_src_handoff_passthrough (GstElement * element, GstBuffer * buffer,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GList **list = user_data;
|
|
|
|
|
|
|
|
*list = g_list_prepend (*list, gst_buffer_ref (buffer));
|
|
|
|
}
|
|
|
|
|
2012-02-26 17:46:24 +00:00
|
|
|
static void
|
|
|
|
test_passthrough (int method)
|
2009-03-28 09:25:12 +00:00
|
|
|
{
|
|
|
|
GList *l1, *l2, *src_buffers = NULL, *sink_buffers = NULL;
|
|
|
|
GstCaps **allowed_caps = NULL, **p;
|
|
|
|
static const gint src_width = 640, src_height = 480;
|
|
|
|
static const gint dest_width = 640, dest_height = 480;
|
|
|
|
|
2012-02-26 17:46:24 +00:00
|
|
|
p = allowed_caps = videoscale_get_allowed_caps_for_method (method);
|
2009-03-28 09:25:12 +00:00
|
|
|
|
|
|
|
while (*p) {
|
|
|
|
GstCaps *caps = *p;
|
|
|
|
|
2012-04-02 15:03:00 +00:00
|
|
|
/* skip formats that videoconvert can't handle */
|
2012-07-16 23:31:57 +00:00
|
|
|
if (!videoconvert_supports_caps (caps))
|
2012-04-02 15:03:00 +00:00
|
|
|
goto next;
|
|
|
|
|
|
|
|
GST_DEBUG ("Running test for caps '%" GST_PTR_FORMAT "'"
|
|
|
|
" from %dx%u to %dx%d with method %d", caps, src_width, src_height,
|
|
|
|
dest_width, dest_height, method);
|
|
|
|
run_test (caps, src_width, src_height,
|
|
|
|
dest_width, dest_height, method,
|
|
|
|
G_CALLBACK (on_src_handoff_passthrough), &src_buffers,
|
|
|
|
G_CALLBACK (on_sink_handoff_passthrough), &sink_buffers);
|
|
|
|
|
|
|
|
fail_unless (src_buffers && sink_buffers);
|
|
|
|
fail_unless_equals_int (g_list_length (src_buffers),
|
|
|
|
g_list_length (sink_buffers));
|
|
|
|
|
|
|
|
for (l1 = src_buffers, l2 = sink_buffers; l1 && l2;
|
|
|
|
l1 = l1->next, l2 = l2->next) {
|
|
|
|
GstBuffer *a = l1->data;
|
|
|
|
GstBuffer *b = l2->data;
|
|
|
|
GstMapInfo mapa, mapb;
|
|
|
|
|
|
|
|
gst_buffer_map (a, &mapa, GST_MAP_READ);
|
|
|
|
gst_buffer_map (b, &mapb, GST_MAP_READ);
|
|
|
|
fail_unless_equals_int (mapa.size, mapb.size);
|
|
|
|
fail_unless (mapa.data == mapb.data);
|
|
|
|
gst_buffer_unmap (b, &mapb);
|
|
|
|
gst_buffer_unmap (a, &mapa);
|
|
|
|
|
|
|
|
gst_buffer_unref (a);
|
|
|
|
gst_buffer_unref (b);
|
|
|
|
}
|
|
|
|
g_list_free (src_buffers);
|
|
|
|
src_buffers = NULL;
|
|
|
|
g_list_free (sink_buffers);
|
|
|
|
sink_buffers = NULL;
|
|
|
|
|
|
|
|
next:
|
2009-03-28 09:25:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
g_free (allowed_caps);
|
|
|
|
}
|
|
|
|
|
2012-02-26 17:46:24 +00:00
|
|
|
GST_START_TEST (test_passthrough_method_0)
|
|
|
|
{
|
|
|
|
test_passthrough (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_passthrough_method_1)
|
|
|
|
{
|
|
|
|
test_passthrough (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_passthrough_method_2)
|
|
|
|
{
|
|
|
|
test_passthrough (2);
|
|
|
|
}
|
|
|
|
|
2009-03-28 09:25:12 +00:00
|
|
|
GST_END_TEST;
|
|
|
|
|
2012-02-26 23:35:06 +00:00
|
|
|
GST_START_TEST (test_passthrough_method_3)
|
|
|
|
{
|
|
|
|
test_passthrough (3);
|
|
|
|
}
|
|
|
|
|
2009-03-28 09:25:12 +00:00
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
#define CREATE_TEST(name,method,src_width,src_height,dest_width,dest_height) \
|
|
|
|
GST_START_TEST (name) \
|
|
|
|
{ \
|
|
|
|
GstCaps **allowed_caps = NULL, **p; \
|
|
|
|
\
|
2012-02-26 17:46:24 +00:00
|
|
|
p = allowed_caps = videoscale_get_allowed_caps_for_method (method); \
|
2009-03-28 09:25:12 +00:00
|
|
|
\
|
|
|
|
while (*p) { \
|
|
|
|
GstCaps *caps = *p; \
|
|
|
|
\
|
|
|
|
GST_DEBUG ("Running test for caps '%" GST_PTR_FORMAT "'" \
|
|
|
|
" from %dx%u to %dx%d with method %d", caps, src_width, src_height, \
|
|
|
|
dest_width, dest_height, method); \
|
|
|
|
run_test (caps, src_width, src_height, \
|
|
|
|
dest_width, dest_height, method, \
|
|
|
|
NULL, NULL, NULL, NULL); \
|
|
|
|
gst_caps_unref (caps); \
|
|
|
|
p++; \
|
|
|
|
} \
|
|
|
|
g_free (allowed_caps); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
CREATE_TEST (test_downscale_640x480_320x240_method_0, 0, 640, 480, 320, 240);
|
|
|
|
CREATE_TEST (test_downscale_640x480_320x240_method_1, 1, 640, 480, 320, 240);
|
|
|
|
CREATE_TEST (test_downscale_640x480_320x240_method_2, 2, 640, 480, 320, 240);
|
2012-02-26 23:35:06 +00:00
|
|
|
CREATE_TEST (test_downscale_640x480_320x240_method_3, 3, 640, 480, 320, 240);
|
2009-03-28 09:25:12 +00:00
|
|
|
CREATE_TEST (test_upscale_320x240_640x480_method_0, 0, 320, 240, 640, 480);
|
|
|
|
CREATE_TEST (test_upscale_320x240_640x480_method_1, 1, 320, 240, 640, 480);
|
|
|
|
CREATE_TEST (test_upscale_320x240_640x480_method_2, 2, 320, 240, 640, 480);
|
2012-02-26 23:35:06 +00:00
|
|
|
CREATE_TEST (test_upscale_320x240_640x480_method_3, 3, 320, 240, 640, 480);
|
2009-03-28 09:25:12 +00:00
|
|
|
CREATE_TEST (test_downscale_640x480_1x1_method_0, 0, 640, 480, 1, 1);
|
|
|
|
CREATE_TEST (test_downscale_640x480_1x1_method_1, 1, 640, 480, 1, 1);
|
|
|
|
CREATE_TEST (test_downscale_640x480_1x1_method_2, 2, 640, 480, 1, 1);
|
2012-02-26 23:35:06 +00:00
|
|
|
CREATE_TEST (test_downscale_640x480_1x1_method_3, 3, 640, 480, 1, 1);
|
2009-03-28 09:25:12 +00:00
|
|
|
CREATE_TEST (test_upscale_1x1_640x480_method_0, 0, 1, 1, 640, 480);
|
|
|
|
CREATE_TEST (test_upscale_1x1_640x480_method_1, 1, 1, 1, 640, 480);
|
|
|
|
CREATE_TEST (test_upscale_1x1_640x480_method_2, 2, 1, 1, 640, 480);
|
2012-02-26 23:35:06 +00:00
|
|
|
CREATE_TEST (test_upscale_1x1_640x480_method_3, 3, 1, 1, 640, 480);
|
2009-03-28 09:25:12 +00:00
|
|
|
CREATE_TEST (test_downscale_641x481_111x30_method_0, 0, 641, 481, 111, 30);
|
|
|
|
CREATE_TEST (test_downscale_641x481_111x30_method_1, 1, 641, 481, 111, 30);
|
|
|
|
CREATE_TEST (test_downscale_641x481_111x30_method_2, 2, 641, 481, 111, 30);
|
2012-02-26 23:35:06 +00:00
|
|
|
CREATE_TEST (test_downscale_641x481_111x30_method_3, 3, 641, 481, 111, 30);
|
2009-03-28 09:25:12 +00:00
|
|
|
CREATE_TEST (test_upscale_111x30_641x481_method_0, 0, 111, 30, 641, 481);
|
|
|
|
CREATE_TEST (test_upscale_111x30_641x481_method_1, 1, 111, 30, 641, 481);
|
|
|
|
CREATE_TEST (test_upscale_111x30_641x481_method_2, 2, 111, 30, 641, 481);
|
2012-02-26 23:35:06 +00:00
|
|
|
CREATE_TEST (test_upscale_111x30_641x481_method_3, 2, 111, 30, 641, 481);
|
2009-03-28 09:25:12 +00:00
|
|
|
CREATE_TEST (test_downscale_641x481_30x111_method_0, 0, 641, 481, 30, 111);
|
|
|
|
CREATE_TEST (test_downscale_641x481_30x111_method_1, 1, 641, 481, 30, 111);
|
|
|
|
CREATE_TEST (test_downscale_641x481_30x111_method_2, 2, 641, 481, 30, 111);
|
2012-02-26 23:35:06 +00:00
|
|
|
CREATE_TEST (test_downscale_641x481_30x111_method_3, 3, 641, 481, 30, 111);
|
2009-03-28 09:25:12 +00:00
|
|
|
CREATE_TEST (test_upscale_30x111_641x481_method_0, 0, 30, 111, 641, 481);
|
|
|
|
CREATE_TEST (test_upscale_30x111_641x481_method_1, 1, 30, 111, 641, 481);
|
|
|
|
CREATE_TEST (test_upscale_30x111_641x481_method_2, 2, 30, 111, 641, 481);
|
2012-02-26 23:35:06 +00:00
|
|
|
CREATE_TEST (test_upscale_30x111_641x481_method_3, 3, 30, 111, 641, 481);
|
2009-03-28 11:48:04 +00:00
|
|
|
CREATE_TEST (test_downscale_640x480_320x1_method_0, 0, 640, 480, 320, 1);
|
|
|
|
CREATE_TEST (test_downscale_640x480_320x1_method_1, 1, 640, 480, 320, 1);
|
|
|
|
CREATE_TEST (test_downscale_640x480_320x1_method_2, 2, 640, 480, 320, 1);
|
2012-02-26 23:35:06 +00:00
|
|
|
CREATE_TEST (test_downscale_640x480_320x1_method_3, 3, 640, 480, 320, 1);
|
2009-03-28 11:48:04 +00:00
|
|
|
CREATE_TEST (test_upscale_320x1_640x480_method_0, 0, 320, 1, 640, 480);
|
|
|
|
CREATE_TEST (test_upscale_320x1_640x480_method_1, 1, 320, 1, 640, 480);
|
|
|
|
CREATE_TEST (test_upscale_320x1_640x480_method_2, 2, 320, 1, 640, 480);
|
2012-02-26 23:35:06 +00:00
|
|
|
CREATE_TEST (test_upscale_320x1_640x480_method_3, 3, 320, 1, 640, 480);
|
2009-03-28 11:48:04 +00:00
|
|
|
CREATE_TEST (test_downscale_640x480_1x240_method_0, 0, 640, 480, 1, 240);
|
|
|
|
CREATE_TEST (test_downscale_640x480_1x240_method_1, 1, 640, 480, 1, 240);
|
|
|
|
CREATE_TEST (test_downscale_640x480_1x240_method_2, 2, 640, 480, 1, 240);
|
2012-02-26 23:35:06 +00:00
|
|
|
CREATE_TEST (test_downscale_640x480_1x240_method_3, 3, 640, 480, 1, 240);
|
2009-03-28 11:48:04 +00:00
|
|
|
CREATE_TEST (test_upscale_1x240_640x480_method_0, 0, 1, 240, 640, 480);
|
|
|
|
CREATE_TEST (test_upscale_1x240_640x480_method_1, 1, 1, 240, 640, 480);
|
|
|
|
CREATE_TEST (test_upscale_1x240_640x480_method_2, 2, 1, 240, 640, 480);
|
2012-02-26 23:35:06 +00:00
|
|
|
CREATE_TEST (test_upscale_1x240_640x480_method_3, 3, 1, 240, 640, 480);
|
2009-03-28 09:25:12 +00:00
|
|
|
|
2010-05-10 15:09:28 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gint width, height;
|
|
|
|
gint par_n, par_d;
|
|
|
|
gboolean ok;
|
|
|
|
GMainLoop *loop;
|
|
|
|
} TestNegotiationData;
|
|
|
|
|
|
|
|
static void
|
|
|
|
_test_negotiation_message (GstBus * bus, GstMessage * message,
|
|
|
|
TestNegotiationData * data)
|
|
|
|
{
|
2010-06-13 20:17:18 +00:00
|
|
|
GError *err = NULL;
|
|
|
|
gchar *debug;
|
|
|
|
|
2010-05-10 15:09:28 +00:00
|
|
|
switch (GST_MESSAGE_TYPE (message)) {
|
|
|
|
case GST_MESSAGE_ERROR:
|
2010-06-13 20:17:18 +00:00
|
|
|
gst_message_parse_error (message, &err, &debug);
|
|
|
|
gst_object_default_error (GST_MESSAGE_SRC (message), err, debug);
|
|
|
|
g_error_free (err);
|
|
|
|
g_free (debug);
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
2010-05-10 15:09:28 +00:00
|
|
|
case GST_MESSAGE_WARNING:
|
2010-06-13 20:17:18 +00:00
|
|
|
gst_message_parse_warning (message, &err, &debug);
|
|
|
|
gst_object_default_error (GST_MESSAGE_SRC (message), err, debug);
|
|
|
|
g_error_free (err);
|
|
|
|
g_free (debug);
|
2010-05-10 15:09:28 +00:00
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
g_main_loop_quit (data->loop);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_test_negotiation_notify_caps (GObject * src, GParamSpec * pspec,
|
|
|
|
TestNegotiationData * data)
|
|
|
|
{
|
|
|
|
GstCaps *caps;
|
|
|
|
GstStructure *s;
|
|
|
|
gint width, height;
|
|
|
|
gint par_n = 0, par_d = 0;
|
|
|
|
|
|
|
|
g_object_get (src, "caps", &caps, NULL);
|
|
|
|
if (caps == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
s = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
fail_unless (gst_structure_get_int (s, "width", &width));
|
|
|
|
fail_unless (gst_structure_get_int (s, "height", &height));
|
|
|
|
fail_unless (gst_structure_get_fraction (s, "pixel-aspect-ratio", &par_n,
|
|
|
|
&par_d) || (data->par_n == 1 && data->par_d == 1));
|
|
|
|
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
|
|
|
fail_unless_equals_int (width, data->width);
|
|
|
|
fail_unless_equals_int (height, data->height);
|
|
|
|
if (par_n != 0 || par_d != 0) {
|
|
|
|
fail_unless_equals_int (par_n, data->par_n);
|
|
|
|
fail_unless_equals_int (par_d, data->par_d);
|
|
|
|
}
|
|
|
|
|
|
|
|
data->ok = (width == data->width) && (height == data->height)
|
|
|
|
&& (par_n == data->par_n) && (par_d == data->par_d);
|
|
|
|
|
|
|
|
g_main_loop_quit (data->loop);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_test_negotiation (const gchar * src_templ, const gchar * sink_templ,
|
|
|
|
gint width, gint height, gint par_n, gint par_d)
|
|
|
|
{
|
|
|
|
GstElement *pipeline;
|
|
|
|
GstElement *src, *capsfilter1, *scale, *capsfilter2, *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
GMainLoop *loop;
|
|
|
|
GstCaps *caps;
|
|
|
|
TestNegotiationData data = { 0, 0, 0, 0, FALSE, NULL };
|
|
|
|
GstPad *pad;
|
|
|
|
|
2010-08-11 15:16:13 +00:00
|
|
|
GST_DEBUG ("Running test for src templ caps '%s' and sink templ caps '%s'",
|
|
|
|
src_templ, sink_templ);
|
|
|
|
|
2010-05-10 15:09:28 +00:00
|
|
|
pipeline = gst_element_factory_make ("pipeline", "pipeline");
|
|
|
|
fail_unless (pipeline != NULL);
|
|
|
|
|
|
|
|
src = gst_element_factory_make ("videotestsrc", "src");
|
|
|
|
fail_unless (src != NULL);
|
|
|
|
g_object_set (G_OBJECT (src), "num-buffers", 1, NULL);
|
|
|
|
|
|
|
|
capsfilter1 = gst_element_factory_make ("capsfilter", "filter1");
|
|
|
|
fail_unless (capsfilter1 != NULL);
|
|
|
|
caps = gst_caps_from_string (src_templ);
|
|
|
|
fail_unless (caps != NULL);
|
|
|
|
g_object_set (G_OBJECT (capsfilter1), "caps", caps, NULL);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
|
|
|
scale = gst_element_factory_make ("videoscale", "scale");
|
|
|
|
fail_unless (scale != NULL);
|
|
|
|
|
|
|
|
capsfilter2 = gst_element_factory_make ("capsfilter", "filter2");
|
|
|
|
fail_unless (capsfilter2 != NULL);
|
|
|
|
caps = gst_caps_from_string (sink_templ);
|
|
|
|
fail_unless (caps != NULL);
|
|
|
|
g_object_set (G_OBJECT (capsfilter2), "caps", caps, NULL);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
|
|
|
pad = gst_element_get_static_pad (capsfilter2, "sink");
|
|
|
|
fail_unless (pad != NULL);
|
|
|
|
g_signal_connect (pad, "notify::caps",
|
|
|
|
G_CALLBACK (_test_negotiation_notify_caps), &data);
|
|
|
|
gst_object_unref (pad);
|
|
|
|
|
|
|
|
sink = gst_element_factory_make ("fakesink", "sink");
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
g_object_set (sink, "async", FALSE, NULL);
|
|
|
|
|
|
|
|
gst_bin_add_many (GST_BIN (pipeline), src, capsfilter1, scale, capsfilter2,
|
|
|
|
sink, NULL);
|
2010-06-26 10:38:56 +00:00
|
|
|
|
|
|
|
fail_unless (gst_element_link_pads_full (src, "src", capsfilter1, "sink",
|
|
|
|
LINK_CHECK_FLAGS));
|
|
|
|
fail_unless (gst_element_link_pads_full (capsfilter1, "src", scale, "sink",
|
|
|
|
LINK_CHECK_FLAGS));
|
|
|
|
fail_unless (gst_element_link_pads_full (scale, "src", capsfilter2, "sink",
|
|
|
|
LINK_CHECK_FLAGS));
|
|
|
|
fail_unless (gst_element_link_pads_full (capsfilter2, "src", sink, "sink",
|
|
|
|
LINK_CHECK_FLAGS));
|
2010-05-10 15:09:28 +00:00
|
|
|
|
|
|
|
loop = g_main_loop_new (NULL, FALSE);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (pipeline);
|
|
|
|
fail_unless (bus != NULL);
|
|
|
|
gst_bus_add_signal_watch (bus);
|
|
|
|
|
|
|
|
data.loop = loop;
|
|
|
|
data.width = width;
|
|
|
|
data.height = height;
|
|
|
|
data.par_n = par_n;
|
|
|
|
data.par_d = par_d;
|
|
|
|
data.ok = FALSE;
|
|
|
|
|
|
|
|
g_signal_connect (bus, "message", G_CALLBACK (_test_negotiation_message),
|
|
|
|
&data);
|
|
|
|
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (pipeline,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
|
|
|
g_main_loop_run (loop);
|
|
|
|
|
|
|
|
fail_unless (data.ok == TRUE);
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (pipeline,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
|
|
|
gst_object_unref (pipeline);
|
|
|
|
g_main_loop_unref (loop);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_negotiation)
|
|
|
|
{
|
|
|
|
_test_negotiation
|
2011-06-16 11:41:25 +00:00
|
|
|
("video/x-raw,format=(string)AYUV,width=720,height=576,pixel-aspect-ratio=16/15",
|
|
|
|
"video/x-raw,format=(string)AYUV,width=768,height=576", 768, 576, 1, 1);
|
2010-05-10 15:09:28 +00:00
|
|
|
|
|
|
|
_test_negotiation
|
2011-06-16 11:41:25 +00:00
|
|
|
("video/x-raw,format=(string)AYUV,width=320,height=240",
|
|
|
|
"video/x-raw,format=(string)AYUV,width=640,height=320", 640, 320, 2, 3);
|
2010-05-10 15:09:28 +00:00
|
|
|
|
|
|
|
_test_negotiation
|
2011-06-16 11:41:25 +00:00
|
|
|
("video/x-raw,format=(string)AYUV,width=320,height=240",
|
|
|
|
"video/x-raw,format=(string)AYUV,width=640,height=320,pixel-aspect-ratio=[0/1, 1/1]",
|
2010-05-10 15:09:28 +00:00
|
|
|
640, 320, 2, 3);
|
|
|
|
|
|
|
|
_test_negotiation
|
2011-06-16 11:41:25 +00:00
|
|
|
("video/x-raw,format=(string)AYUV,width=1920,height=2560,pixel-aspect-ratio=1/1",
|
|
|
|
"video/x-raw,format=(string)AYUV,width=[1, 2048],height=[1, 2048],pixel-aspect-ratio=1/1",
|
2010-05-10 15:09:28 +00:00
|
|
|
1536, 2048, 1, 1);
|
|
|
|
|
|
|
|
_test_negotiation
|
2011-06-16 11:41:25 +00:00
|
|
|
("video/x-raw,format=(string)AYUV,width=1920,height=2560,pixel-aspect-ratio=1/1",
|
|
|
|
"video/x-raw,format=(string)AYUV,width=[1, 2048],height=[1, 2048]",
|
2010-05-10 15:09:28 +00:00
|
|
|
1920, 2048, 4, 5);
|
|
|
|
|
|
|
|
_test_negotiation
|
2011-06-16 11:41:25 +00:00
|
|
|
("video/x-raw,format=(string)AYUV,width=1920,height=2560",
|
|
|
|
"video/x-raw,format=(string)AYUV,width=[1, 2048],height=[1, 2048]",
|
2010-05-10 15:09:28 +00:00
|
|
|
1920, 2048, 4, 5);
|
|
|
|
|
|
|
|
_test_negotiation
|
2011-06-16 11:41:25 +00:00
|
|
|
("video/x-raw,format=(string)AYUV,width=1920,height=2560",
|
|
|
|
"video/x-raw,format=(string)AYUV,width=1200,height=[1, 2048],pixel-aspect-ratio=1/1",
|
2010-05-10 15:09:28 +00:00
|
|
|
1200, 1600, 1, 1);
|
|
|
|
|
|
|
|
/* Doesn't keep DAR but must be possible! */
|
|
|
|
_test_negotiation
|
2011-06-16 11:41:25 +00:00
|
|
|
("video/x-raw,format=(string)AYUV,width=320,height=240,pixel-aspect-ratio=1/1",
|
|
|
|
"video/x-raw,format=(string)AYUV,width=200,height=200,pixel-aspect-ratio=1/2",
|
2010-05-10 15:09:28 +00:00
|
|
|
200, 200, 1, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2010-10-28 13:55:12 +00:00
|
|
|
#define GST_TYPE_TEST_REVERSE_NEGOTIATION_SINK \
|
|
|
|
(gst_test_reverse_negotiation_sink_get_type())
|
|
|
|
#define GST_TEST_REVERSE_NEGOTIATION_SINK(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TEST_REVERSE_NEGOTIATION_SINK,GstTestReverseNegotiationSink))
|
|
|
|
#define GST_TEST_REVERSE_NEGOTIATION_SINK_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TEST_REVERSE_NEGOTIATION_SINK,GstTestReverseNegotiationSinkClass))
|
|
|
|
#define GST_IS_TEST_REVERSE_NEGOTIATION_SINK(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TEST_REVERSE_NEGOTIATION_SINK))
|
|
|
|
#define GST_IS_TEST_REVERSE_NEGOTIATION_SINK_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TEST_REVERSE_NEGOTIATION_SINK))
|
|
|
|
#define GST_TEST_REVERSE_NEGOTIATION_SINK_CAST(obj) ((GstTestReverseNegotiationSink *)obj)
|
|
|
|
|
|
|
|
typedef struct _GstTestReverseNegotiationSink GstTestReverseNegotiationSink;
|
|
|
|
typedef struct _GstTestReverseNegotiationSinkClass
|
|
|
|
GstTestReverseNegotiationSinkClass;
|
|
|
|
struct _GstTestReverseNegotiationSink
|
|
|
|
{
|
|
|
|
GstBaseSink element;
|
|
|
|
gint nbuffers;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GstTestReverseNegotiationSinkClass
|
|
|
|
{
|
|
|
|
GstBaseSinkClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
GType gst_test_reverse_negotiation_sink_get_type (void);
|
|
|
|
|
2011-04-19 12:21:34 +00:00
|
|
|
G_DEFINE_TYPE (GstTestReverseNegotiationSink,
|
|
|
|
gst_test_reverse_negotiation_sink, GST_TYPE_BASE_SINK);
|
2010-10-28 13:55:12 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2012-01-04 15:41:53 +00:00
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("xRGB")));
|
2010-10-28 13:55:12 +00:00
|
|
|
|
2011-04-29 11:48:39 +00:00
|
|
|
#if 0
|
2010-10-28 13:55:12 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_test_reverse_negotiation_sink_buffer_alloc (GstBaseSink * bsink,
|
|
|
|
guint64 offset, guint size, GstCaps * caps, GstBuffer ** buf)
|
|
|
|
{
|
|
|
|
GstTestReverseNegotiationSink *sink =
|
|
|
|
GST_TEST_REVERSE_NEGOTIATION_SINK (bsink);
|
|
|
|
GstVideoFormat fmt;
|
|
|
|
gint width, height;
|
|
|
|
|
|
|
|
fail_unless (gst_video_format_parse_caps (caps, &fmt, &width, &height));
|
|
|
|
|
|
|
|
if (sink->nbuffers < 2) {
|
|
|
|
*buf =
|
|
|
|
gst_buffer_new_and_alloc (gst_video_format_get_size (fmt, width,
|
|
|
|
height));
|
|
|
|
gst_buffer_set_caps (*buf, caps);
|
|
|
|
} else {
|
|
|
|
gint fps_n, fps_d;
|
|
|
|
|
|
|
|
fail_unless (gst_video_parse_caps_framerate (caps, &fps_n, &fps_d));
|
|
|
|
|
|
|
|
width = 512;
|
|
|
|
height = 128;
|
|
|
|
*buf =
|
|
|
|
gst_buffer_new_and_alloc (gst_video_format_get_size (fmt, width,
|
|
|
|
height));
|
|
|
|
caps = gst_video_format_new_caps (fmt, width, height, fps_n, fps_d, 1, 1);
|
|
|
|
gst_buffer_set_caps (*buf, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
}
|
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
2011-04-29 11:48:39 +00:00
|
|
|
#endif
|
2010-10-28 13:55:12 +00:00
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_test_reverse_negotiation_sink_render (GstBaseSink * bsink,
|
|
|
|
GstBuffer * buffer)
|
|
|
|
{
|
|
|
|
GstTestReverseNegotiationSink *sink =
|
|
|
|
GST_TEST_REVERSE_NEGOTIATION_SINK (bsink);
|
2012-01-04 15:41:53 +00:00
|
|
|
GstCaps *caps;
|
|
|
|
GstVideoInfo info;
|
|
|
|
|
|
|
|
caps = gst_pad_get_current_caps (GST_BASE_SINK_PAD (bsink));
|
2010-10-28 13:55:12 +00:00
|
|
|
|
|
|
|
fail_unless (caps != NULL);
|
2012-01-04 15:41:53 +00:00
|
|
|
fail_unless (gst_video_info_from_caps (&info, caps));
|
2010-10-28 13:55:12 +00:00
|
|
|
|
|
|
|
sink->nbuffers++;
|
|
|
|
|
|
|
|
/* The third buffer is still in the old size
|
2011-07-07 20:24:38 +00:00
|
|
|
* because the videoconverts can't convert
|
2010-10-28 13:55:12 +00:00
|
|
|
* the frame sizes
|
|
|
|
*/
|
|
|
|
if (sink->nbuffers > 3) {
|
2012-01-04 15:41:53 +00:00
|
|
|
fail_unless_equals_int (GST_VIDEO_INFO_WIDTH (&info), 512);
|
|
|
|
fail_unless_equals_int (GST_VIDEO_INFO_HEIGHT (&info), 128);
|
2010-10-28 13:55:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_test_reverse_negotiation_sink_class_init (GstTestReverseNegotiationSinkClass
|
|
|
|
* klass)
|
|
|
|
{
|
2011-04-25 09:32:27 +00:00
|
|
|
GstElementClass *gstelement_class;
|
2010-10-28 13:55:12 +00:00
|
|
|
GstBaseSinkClass *gstbase_sink_class;
|
|
|
|
|
2011-04-25 09:32:27 +00:00
|
|
|
gstelement_class = GST_ELEMENT_CLASS (klass);
|
2010-10-28 13:55:12 +00:00
|
|
|
gstbase_sink_class = GST_BASE_SINK_CLASS (klass);
|
|
|
|
|
2012-09-14 15:02:53 +00:00
|
|
|
gst_element_class_set_metadata (gstelement_class,
|
2011-04-19 12:21:34 +00:00
|
|
|
"Test Reverse Negotiation Sink",
|
|
|
|
"Sink",
|
|
|
|
"Some test sink", "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&sinktemplate));
|
|
|
|
|
2011-04-29 11:48:39 +00:00
|
|
|
#if 0
|
2010-10-28 13:55:12 +00:00
|
|
|
gstbase_sink_class->buffer_alloc =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_test_reverse_negotiation_sink_buffer_alloc);
|
2011-04-29 11:48:39 +00:00
|
|
|
#endif
|
2010-10-28 13:55:12 +00:00
|
|
|
gstbase_sink_class->render =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_test_reverse_negotiation_sink_render);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-04-19 12:21:34 +00:00
|
|
|
gst_test_reverse_negotiation_sink_init (GstTestReverseNegotiationSink * sink)
|
2010-10-28 13:55:12 +00:00
|
|
|
{
|
|
|
|
sink->nbuffers = 0;
|
|
|
|
}
|
|
|
|
|
2012-02-03 11:41:10 +00:00
|
|
|
#if 0
|
2010-10-28 13:55:12 +00:00
|
|
|
static void
|
|
|
|
_test_reverse_negotiation_message (GstBus * bus, GstMessage * message,
|
|
|
|
GMainLoop * loop)
|
|
|
|
{
|
|
|
|
GError *err = NULL;
|
|
|
|
gchar *debug;
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (message)) {
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
gst_message_parse_error (message, &err, &debug);
|
|
|
|
gst_object_default_error (GST_MESSAGE_SRC (message), err, debug);
|
|
|
|
g_error_free (err);
|
|
|
|
g_free (debug);
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_WARNING:
|
|
|
|
gst_message_parse_warning (message, &err, &debug);
|
|
|
|
gst_object_default_error (GST_MESSAGE_SRC (message), err, debug);
|
|
|
|
g_error_free (err);
|
|
|
|
g_free (debug);
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
g_main_loop_quit (loop);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-02-03 11:41:10 +00:00
|
|
|
#endif
|
2010-10-28 13:55:12 +00:00
|
|
|
|
2012-02-03 11:41:10 +00:00
|
|
|
#if 0
|
2010-10-28 13:55:12 +00:00
|
|
|
GST_START_TEST (test_reverse_negotiation)
|
|
|
|
{
|
|
|
|
GstElement *pipeline;
|
|
|
|
GstElement *src, *csp1, *scale, *csp2, *sink;
|
|
|
|
GstBus *bus;
|
|
|
|
GMainLoop *loop;
|
|
|
|
|
|
|
|
pipeline = gst_element_factory_make ("pipeline", "pipeline");
|
|
|
|
fail_unless (pipeline != NULL);
|
|
|
|
|
|
|
|
src = gst_element_factory_make ("videotestsrc", "src");
|
|
|
|
fail_unless (src != NULL);
|
|
|
|
g_object_set (G_OBJECT (src), "num-buffers", 8, NULL);
|
|
|
|
|
2011-07-07 20:24:38 +00:00
|
|
|
csp1 = gst_element_factory_make ("videoconvert", "csp1");
|
2010-10-28 13:55:12 +00:00
|
|
|
fail_unless (csp1 != NULL);
|
|
|
|
|
|
|
|
scale = gst_element_factory_make ("videoscale", "scale");
|
|
|
|
fail_unless (scale != NULL);
|
|
|
|
|
2011-07-07 20:24:38 +00:00
|
|
|
csp2 = gst_element_factory_make ("videoconvert", "csp2");
|
2010-10-28 13:55:12 +00:00
|
|
|
fail_unless (csp2 != NULL);
|
|
|
|
|
|
|
|
sink = g_object_new (GST_TYPE_TEST_REVERSE_NEGOTIATION_SINK, NULL);
|
|
|
|
fail_unless (sink != NULL);
|
|
|
|
g_object_set (sink, "async", FALSE, NULL);
|
|
|
|
|
|
|
|
gst_bin_add_many (GST_BIN (pipeline), src, csp1, scale, csp2, sink, NULL);
|
|
|
|
|
|
|
|
fail_unless (gst_element_link_pads_full (src, "src", csp1, "sink",
|
|
|
|
LINK_CHECK_FLAGS));
|
|
|
|
fail_unless (gst_element_link_pads_full (csp1, "src", scale, "sink",
|
|
|
|
LINK_CHECK_FLAGS));
|
|
|
|
fail_unless (gst_element_link_pads_full (scale, "src", csp2, "sink",
|
|
|
|
LINK_CHECK_FLAGS));
|
|
|
|
fail_unless (gst_element_link_pads_full (csp2, "src", sink, "sink",
|
|
|
|
LINK_CHECK_FLAGS));
|
|
|
|
|
|
|
|
loop = g_main_loop_new (NULL, FALSE);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (pipeline);
|
|
|
|
fail_unless (bus != NULL);
|
|
|
|
gst_bus_add_signal_watch (bus);
|
|
|
|
|
|
|
|
g_signal_connect (bus, "message",
|
|
|
|
G_CALLBACK (_test_reverse_negotiation_message), loop);
|
|
|
|
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (pipeline,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
|
|
|
g_main_loop_run (loop);
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (pipeline,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
|
|
|
gst_object_unref (pipeline);
|
|
|
|
g_main_loop_unref (loop);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
2012-02-03 11:41:10 +00:00
|
|
|
#endif
|
2010-10-28 13:55:12 +00:00
|
|
|
|
2011-04-21 13:11:49 +00:00
|
|
|
GST_START_TEST (test_basetransform_negotiation)
|
|
|
|
{
|
|
|
|
GstElement *pipeline, *src, *sink, *scale, *capsfilter1, *capsfilter2;
|
|
|
|
GstMessage *msg;
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new (NULL);
|
|
|
|
src = gst_element_factory_make ("videotestsrc", NULL);
|
|
|
|
capsfilter1 = gst_element_factory_make ("capsfilter", NULL);
|
|
|
|
scale = gst_element_factory_make ("videoscale", NULL);
|
|
|
|
capsfilter2 = gst_element_factory_make ("capsfilter", NULL);
|
|
|
|
sink = gst_element_factory_make ("fakesink", NULL);
|
|
|
|
fail_unless (pipeline && src && capsfilter1 && scale && capsfilter2 && sink);
|
|
|
|
|
|
|
|
g_object_set (src, "num-buffers", 3, NULL);
|
|
|
|
|
2012-01-04 15:41:53 +00:00
|
|
|
caps = gst_caps_new_simple ("video/x-raw", "format", G_TYPE_STRING,
|
|
|
|
"UYVY", "width", G_TYPE_INT, 352,
|
2011-04-21 13:11:49 +00:00
|
|
|
"height", G_TYPE_INT, 288, "framerate", GST_TYPE_FRACTION, 30, 1,
|
|
|
|
"pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, NULL);
|
|
|
|
g_object_set (capsfilter1, "caps", caps, NULL);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
|
|
|
/* same caps, just different pixel-aspect-ratio */
|
2012-01-04 15:41:53 +00:00
|
|
|
caps = gst_caps_new_simple ("video/x-raw", "format", G_TYPE_STRING,
|
|
|
|
"UYVY", "width", G_TYPE_INT, 352,
|
2011-04-21 13:11:49 +00:00
|
|
|
"height", G_TYPE_INT, 288, "framerate", GST_TYPE_FRACTION, 30, 1,
|
|
|
|
"pixel-aspect-ratio", GST_TYPE_FRACTION, 12, 11, NULL);
|
|
|
|
g_object_set (capsfilter2, "caps", caps, NULL);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
|
|
|
gst_bin_add_many (GST_BIN (pipeline), src, capsfilter1, scale, capsfilter2,
|
|
|
|
sink, NULL);
|
|
|
|
fail_unless (gst_element_link_many (src, capsfilter1, scale, capsfilter2,
|
|
|
|
sink, NULL));
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PLAYING),
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
msg = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (pipeline), -1,
|
|
|
|
GST_MESSAGE_EOS | GST_MESSAGE_ERROR);
|
|
|
|
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_EOS);
|
|
|
|
gst_message_unref (msg);
|
|
|
|
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
gst_object_unref (pipeline);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2009-03-28 09:25:12 +00:00
|
|
|
static Suite *
|
|
|
|
videoscale_suite (void)
|
|
|
|
{
|
|
|
|
Suite *s = suite_create ("videoscale");
|
|
|
|
TCase *tc_chain = tcase_create ("general");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
|
|
|
tcase_set_timeout (tc_chain, 180);
|
2012-07-16 23:31:14 +00:00
|
|
|
tcase_add_test (tc_chain, test_template_formats);
|
2012-02-26 17:46:24 +00:00
|
|
|
tcase_add_test (tc_chain, test_passthrough_method_0);
|
|
|
|
tcase_add_test (tc_chain, test_passthrough_method_1);
|
|
|
|
tcase_add_test (tc_chain, test_passthrough_method_2);
|
2012-02-26 23:35:06 +00:00
|
|
|
tcase_add_test (tc_chain, test_passthrough_method_3);
|
2009-03-28 09:25:12 +00:00
|
|
|
tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_0);
|
|
|
|
tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_1);
|
|
|
|
tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_2);
|
2012-02-26 23:35:06 +00:00
|
|
|
tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_3);
|
2009-03-28 09:25:12 +00:00
|
|
|
tcase_add_test (tc_chain, test_upscale_320x240_640x480_method_0);
|
|
|
|
tcase_add_test (tc_chain, test_upscale_320x240_640x480_method_1);
|
|
|
|
tcase_add_test (tc_chain, test_upscale_320x240_640x480_method_2);
|
2012-02-26 23:35:06 +00:00
|
|
|
tcase_add_test (tc_chain, test_upscale_320x240_640x480_method_3);
|
2009-03-28 09:25:12 +00:00
|
|
|
tcase_add_test (tc_chain, test_downscale_640x480_1x1_method_0);
|
|
|
|
tcase_add_test (tc_chain, test_downscale_640x480_1x1_method_1);
|
|
|
|
tcase_add_test (tc_chain, test_downscale_640x480_1x1_method_2);
|
2012-02-26 23:35:06 +00:00
|
|
|
tcase_skip_broken_test (tc_chain, test_downscale_640x480_1x1_method_3);
|
2009-03-28 09:25:12 +00:00
|
|
|
tcase_add_test (tc_chain, test_upscale_1x1_640x480_method_0);
|
|
|
|
tcase_add_test (tc_chain, test_upscale_1x1_640x480_method_1);
|
|
|
|
tcase_add_test (tc_chain, test_upscale_1x1_640x480_method_2);
|
2012-02-26 23:35:06 +00:00
|
|
|
tcase_add_test (tc_chain, test_upscale_1x1_640x480_method_3);
|
2009-03-28 09:25:12 +00:00
|
|
|
tcase_add_test (tc_chain, test_downscale_641x481_111x30_method_0);
|
|
|
|
tcase_add_test (tc_chain, test_downscale_641x481_111x30_method_1);
|
|
|
|
tcase_add_test (tc_chain, test_downscale_641x481_111x30_method_2);
|
2012-02-26 23:35:06 +00:00
|
|
|
tcase_add_test (tc_chain, test_downscale_641x481_111x30_method_3);
|
2009-03-28 09:25:12 +00:00
|
|
|
tcase_add_test (tc_chain, test_upscale_111x30_641x481_method_0);
|
|
|
|
tcase_add_test (tc_chain, test_upscale_111x30_641x481_method_1);
|
|
|
|
tcase_add_test (tc_chain, test_upscale_111x30_641x481_method_2);
|
2012-02-26 23:35:06 +00:00
|
|
|
tcase_add_test (tc_chain, test_upscale_111x30_641x481_method_3);
|
2009-03-28 09:25:12 +00:00
|
|
|
tcase_add_test (tc_chain, test_downscale_641x481_30x111_method_0);
|
|
|
|
tcase_add_test (tc_chain, test_downscale_641x481_30x111_method_1);
|
|
|
|
tcase_add_test (tc_chain, test_downscale_641x481_30x111_method_2);
|
2012-02-26 23:35:06 +00:00
|
|
|
tcase_add_test (tc_chain, test_downscale_641x481_30x111_method_3);
|
2009-03-28 09:25:12 +00:00
|
|
|
tcase_add_test (tc_chain, test_upscale_30x111_641x481_method_0);
|
|
|
|
tcase_add_test (tc_chain, test_upscale_30x111_641x481_method_1);
|
|
|
|
tcase_add_test (tc_chain, test_upscale_30x111_641x481_method_2);
|
2012-02-26 23:35:06 +00:00
|
|
|
tcase_add_test (tc_chain, test_upscale_30x111_641x481_method_3);
|
2009-03-28 11:48:04 +00:00
|
|
|
tcase_add_test (tc_chain, test_downscale_640x480_320x1_method_0);
|
|
|
|
tcase_add_test (tc_chain, test_downscale_640x480_320x1_method_1);
|
|
|
|
tcase_add_test (tc_chain, test_downscale_640x480_320x1_method_2);
|
2012-02-26 23:35:06 +00:00
|
|
|
tcase_skip_broken_test (tc_chain, test_downscale_640x480_320x1_method_3);
|
2009-03-28 11:48:04 +00:00
|
|
|
tcase_add_test (tc_chain, test_upscale_320x1_640x480_method_0);
|
|
|
|
tcase_add_test (tc_chain, test_upscale_320x1_640x480_method_1);
|
|
|
|
tcase_add_test (tc_chain, test_upscale_320x1_640x480_method_2);
|
2012-02-26 23:35:06 +00:00
|
|
|
tcase_skip_broken_test (tc_chain, test_upscale_320x1_640x480_method_3);
|
2009-03-28 11:48:04 +00:00
|
|
|
tcase_add_test (tc_chain, test_downscale_640x480_1x240_method_0);
|
|
|
|
tcase_add_test (tc_chain, test_downscale_640x480_1x240_method_1);
|
|
|
|
tcase_add_test (tc_chain, test_downscale_640x480_1x240_method_2);
|
2012-03-08 14:24:19 +00:00
|
|
|
tcase_skip_broken_test (tc_chain, test_downscale_640x480_1x240_method_3);
|
2009-03-28 11:48:04 +00:00
|
|
|
tcase_add_test (tc_chain, test_upscale_1x240_640x480_method_0);
|
|
|
|
tcase_add_test (tc_chain, test_upscale_1x240_640x480_method_1);
|
|
|
|
tcase_add_test (tc_chain, test_upscale_1x240_640x480_method_2);
|
2012-02-26 23:35:06 +00:00
|
|
|
tcase_add_test (tc_chain, test_upscale_1x240_640x480_method_3);
|
2010-05-10 15:09:28 +00:00
|
|
|
tcase_add_test (tc_chain, test_negotiation);
|
2012-02-03 11:41:10 +00:00
|
|
|
#if 0
|
2010-10-28 13:55:12 +00:00
|
|
|
tcase_add_test (tc_chain, test_reverse_negotiation);
|
2012-02-03 11:41:10 +00:00
|
|
|
#endif
|
2011-04-21 13:11:49 +00:00
|
|
|
tcase_add_test (tc_chain, test_basetransform_negotiation);
|
2009-03-28 09:25:12 +00:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_CHECK_MAIN (videoscale);
|