mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
tests: fix some tests
This commit is contained in:
parent
667c84b59c
commit
9fb2e9d6be
6 changed files with 71 additions and 68 deletions
|
@ -264,6 +264,13 @@ libs_vc1parser_LDADD = \
|
|||
$(GST_PLUGINS_BAD_LIBS) -lgstcodecparsers-@GST_MAJORMINOR@ \
|
||||
$(GST_BASE_LIBS) $(GST_LIBS) $(LDADD)
|
||||
|
||||
elements_faac_CFLAGS = \
|
||||
$(GST_PLUGINS_BASE_CFLAGS) \
|
||||
$(GST_BASE_CFLAGS) $(GST_CFLAGS) $(AM_CFLAGS)
|
||||
elements_faac_LDADD = \
|
||||
$(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) $(LDADD) \
|
||||
-lgstaudio-@GST_MAJORMINOR@
|
||||
|
||||
elements_voaacenc_CFLAGS = \
|
||||
$(GST_PLUGINS_BASE_CFLAGS) \
|
||||
$(GST_BASE_CFLAGS) $(GST_CFLAGS) $(AM_CFLAGS)
|
||||
|
|
|
@ -99,22 +99,21 @@ sink_handoff_cb_xRGB (GstElement * object, GstBuffer * buffer, GstPad * pad,
|
|||
guint *sink_pos = (guint *) user_data;
|
||||
gboolean contains_text = (*sink_pos == 1 || *sink_pos == 2);
|
||||
guint i, j;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
gboolean all_red = TRUE;
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
fail_unless_equals_int (size, 640 * 480 * 4);
|
||||
fail_unless_equals_int (map.size, 640 * 480 * 4);
|
||||
|
||||
for (i = 0; i < 640; i++) {
|
||||
for (j = 0; j < 480; j++) {
|
||||
all_red = all_red && (data[i * 480 * 4 + j * 4 + 1] == 255 &&
|
||||
data[i * 480 * 4 + j * 4 + 2] == 0 &&
|
||||
data[i * 480 * 4 + j * 4 + 3] == 0);
|
||||
all_red = all_red && (map.data[i * 480 * 4 + j * 4 + 1] == 255 &&
|
||||
map.data[i * 480 * 4 + j * 4 + 2] == 0 &&
|
||||
map.data[i * 480 * 4 + j * 4 + 3] == 0);
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
fail_unless (contains_text != all_red,
|
||||
"Frame %d is incorrect (all red %d, contains text %d)", *sink_pos,
|
||||
|
|
|
@ -48,23 +48,26 @@ static GstStaticPadTemplate gst_test_scope_src_template =
|
|||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB_HOST_ENDIAN)
|
||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("xRGB"))
|
||||
);
|
||||
|
||||
static GstStaticPadTemplate gst_test_scope_sink_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS)
|
||||
GST_STATIC_CAPS ("audio/x-raw, "
|
||||
"format = (string) " GST_AUDIO_NE (S16) ", "
|
||||
"layout = (string) interleaved, "
|
||||
"channels = (int) 2, "
|
||||
"channel-mask = (bitmask) 3, " "rate = (int) 44100")
|
||||
);
|
||||
|
||||
static GType gst_test_scope_get_type (void);
|
||||
|
||||
GST_BOILERPLATE (GstTestScope, gst_test_scope, GstBaseAudioVisualizer,
|
||||
GST_TYPE_BASE_AUDIO_VISUALIZER);
|
||||
G_DEFINE_TYPE (GstTestScope, gst_test_scope, GST_TYPE_BASE_AUDIO_VISUALIZER);
|
||||
|
||||
static void
|
||||
gst_test_scope_base_init (gpointer g_class)
|
||||
gst_test_scope_class_init (GstTestScopeClass * g_class)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||
|
||||
|
@ -79,43 +82,31 @@ gst_test_scope_base_init (gpointer g_class)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_test_scope_class_init (GstTestScopeClass * g_class)
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
static void
|
||||
gst_test_scope_init (GstTestScope * scope, GstTestScopeClass * g_class)
|
||||
gst_test_scope_init (GstTestScope * scope)
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
/* tests */
|
||||
#define CAPS "audio/x-raw, " \
|
||||
"format = (string) " GST_AUDIO_NE (S16) ", " \
|
||||
"layout = (string) interleaved, " \
|
||||
"rate = (int) 44100, " \
|
||||
"channels = (int) 2, " \
|
||||
"channel-mask = (bitmask) 3"
|
||||
|
||||
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("video/x-raw-rgb, "
|
||||
"bpp = (int) 32, "
|
||||
"depth = (int) 24, " "endianness = (int) BIG_ENDIAN, "
|
||||
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||
"red_mask = (int) 0xFF000000, "
|
||||
"green_mask = (int) 0x00FF0000, " "blue_mask = (int) 0x0000FF00, "
|
||||
#else
|
||||
"red_mask = (int) 0x0000FF00, "
|
||||
"green_mask = (int) 0x00FF0000, " "blue_mask = (int) 0xFF000000, "
|
||||
#endif
|
||||
GST_STATIC_CAPS ("video/x-raw, "
|
||||
"format = (string) xRGB, "
|
||||
"width = (int) 320, "
|
||||
"height = (int) 240, " "framerate = (fraction) 30/1")
|
||||
);
|
||||
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
||||
"rate = (int) 44100, "
|
||||
"channels = (int) 2, "
|
||||
"endianness = (int) BYTE_ORDER, "
|
||||
"width = (int) 16, " "depth = (int) 16, " "signed = (boolean) true")
|
||||
GST_STATIC_CAPS (CAPS)
|
||||
);
|
||||
|
||||
GST_START_TEST (count_in_out)
|
||||
|
@ -123,6 +114,7 @@ GST_START_TEST (count_in_out)
|
|||
GstElement *elem;
|
||||
GstPad *srcpad, *sinkpad;
|
||||
GstBuffer *buffer;
|
||||
GstCaps *caps;
|
||||
|
||||
/* setup up */
|
||||
elem = gst_check_setup_element ("testscope");
|
||||
|
@ -130,13 +122,17 @@ GST_START_TEST (count_in_out)
|
|||
sinkpad = gst_check_setup_sink_pad (elem, &sinktemplate);
|
||||
gst_pad_set_active (srcpad, TRUE);
|
||||
gst_pad_set_active (sinkpad, TRUE);
|
||||
|
||||
fail_unless (gst_element_set_state (elem,
|
||||
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
||||
"could not set to playing");
|
||||
|
||||
caps = gst_caps_from_string (CAPS);
|
||||
gst_pad_set_caps (srcpad, caps);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
/* push 1s audio to get 30 video-frames */
|
||||
buffer = gst_buffer_new_and_alloc (44100 * 2 * sizeof (gint16));
|
||||
gst_buffer_set_caps (buffer, GST_PAD_CAPS (srcpad));
|
||||
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
|
||||
|
||||
/* pushing gives away my reference ... */
|
||||
|
|
|
@ -23,19 +23,19 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include <gst/check/gstcheck.h>
|
||||
#include <gst/audio/audio.h>
|
||||
|
||||
/* For ease of programming we use globals to keep refs for our floating
|
||||
* src and sink pads we create; otherwise we always have to do get_pad,
|
||||
* get_peer, and then remove references in every test function */
|
||||
static GstPad *mysrcpad, *mysinkpad;
|
||||
|
||||
#define AUDIO_CAPS_STRING "audio/x-raw-int, " \
|
||||
#define AUDIO_CAPS_STRING "audio/x-raw, " \
|
||||
"format = (string) " GST_AUDIO_NE (S16) \
|
||||
"layout = (string) interleaved, " \
|
||||
"rate = (int) 48000, " \
|
||||
"channels = (int) 2, " \
|
||||
"width = (int) 16, " \
|
||||
"depth = (int) 16, " \
|
||||
"signed = (boolean) true, " \
|
||||
"endianness = (int) BYTE_ORDER "
|
||||
"channel-mask = (bitmask) 3"
|
||||
|
||||
#define AAC_RAW_CAPS_STRING "audio/mpeg, " \
|
||||
"mpegversion = (int) 4, " \
|
||||
|
@ -134,13 +134,16 @@ do_test (gboolean adts)
|
|||
/* clean up buffers */
|
||||
for (i = 0; i < num_buffers; ++i) {
|
||||
gint header = 0, id;
|
||||
GstMapInfo map;
|
||||
gsize size;
|
||||
guint8 *data;
|
||||
|
||||
outbuffer = GST_BUFFER (buffers->data);
|
||||
fail_if (outbuffer == NULL);
|
||||
|
||||
data = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
|
||||
if (adts) {
|
||||
gboolean protection;
|
||||
|
@ -175,8 +178,7 @@ do_test (gboolean adts)
|
|||
const GValue *value;
|
||||
GstBuffer *buf;
|
||||
gint k;
|
||||
gsize csize;
|
||||
guint8 *cdata;
|
||||
GstMapInfo cmap;
|
||||
|
||||
caps = gst_pad_get_current_caps (mysinkpad);
|
||||
fail_if (caps == NULL);
|
||||
|
@ -186,10 +188,10 @@ do_test (gboolean adts)
|
|||
fail_if (value == NULL);
|
||||
buf = gst_value_get_buffer (value);
|
||||
fail_if (buf == NULL);
|
||||
cdata = gst_buffer_map (buf, &csize, NULL, GST_MAP_READ);
|
||||
fail_if (csize < 2);
|
||||
k = GST_READ_UINT16_BE (cdata);
|
||||
gst_buffer_unmap (buf, cdata, csize);
|
||||
gst_buffer_map (buf, &cmap, GST_MAP_READ);
|
||||
fail_if (cmap.size < 2);
|
||||
k = GST_READ_UINT16_BE (cmap.data);
|
||||
gst_buffer_unmap (buf, &cmap);
|
||||
/* profile, rate, channels */
|
||||
fail_unless ((k & 0xFFF8) == ((0x02 << 11) | (0x3 << 7) | (0x02 << 3)));
|
||||
gst_caps_unref (caps);
|
||||
|
@ -199,7 +201,7 @@ do_test (gboolean adts)
|
|||
id = data[header] & (0x7 << 5);
|
||||
/* allow all but ID_END or ID_LFE */
|
||||
fail_if (id == 7 || id == 3);
|
||||
gst_buffer_unmap (outbuffer, data, size);
|
||||
gst_buffer_unmap (outbuffer, &map);
|
||||
|
||||
buffers = g_list_remove (buffers, outbuffer);
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ static GCond *mpeg2enc_cond;
|
|||
static gboolean arrived_eos;
|
||||
|
||||
static gboolean
|
||||
test_sink_event (GstPad * pad, GstEvent * event)
|
||||
test_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
||||
{
|
||||
|
||||
switch (GST_EVENT_TYPE (event)) {
|
||||
|
@ -71,7 +71,7 @@ test_sink_event (GstPad * pad, GstEvent * event)
|
|||
break;
|
||||
}
|
||||
|
||||
return gst_pad_event_default (pad, event);
|
||||
return gst_pad_event_default (pad, parent, event);
|
||||
}
|
||||
|
||||
static GstElement *
|
||||
|
@ -81,8 +81,8 @@ setup_mpeg2enc (void)
|
|||
|
||||
GST_DEBUG ("setup_mpeg2enc");
|
||||
mpeg2enc = gst_check_setup_element ("mpeg2enc");
|
||||
mysrcpad = gst_check_setup_src_pad (mpeg2enc, &srctemplate, NULL);
|
||||
mysinkpad = gst_check_setup_sink_pad (mpeg2enc, &sinktemplate, NULL);
|
||||
mysrcpad = gst_check_setup_src_pad (mpeg2enc, &srctemplate);
|
||||
mysinkpad = gst_check_setup_sink_pad (mpeg2enc, &sinktemplate);
|
||||
gst_pad_set_active (mysrcpad, TRUE);
|
||||
gst_pad_set_active (mysinkpad, TRUE);
|
||||
|
||||
|
@ -129,9 +129,9 @@ GST_START_TEST (test_video_pad)
|
|||
/* corresponds to I420 buffer for the size mentioned in the caps */
|
||||
inbuffer = gst_buffer_new_and_alloc (384 * 288 * 3 / 2);
|
||||
/* makes valgrind's memcheck happier */
|
||||
memset (GST_BUFFER_DATA (inbuffer), 0, GST_BUFFER_SIZE (inbuffer));
|
||||
gst_buffer_memset (inbuffer, 0, 0, -1);
|
||||
caps = gst_caps_from_string (VIDEO_CAPS_STRING);
|
||||
gst_buffer_set_caps (inbuffer, caps);
|
||||
gst_pad_set_caps (mysrcpad, caps);
|
||||
gst_caps_unref (caps);
|
||||
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
|
@ -156,8 +156,8 @@ GST_START_TEST (test_video_pad)
|
|||
|
||||
switch (i) {
|
||||
case 0:
|
||||
fail_unless (GST_BUFFER_SIZE (outbuffer) >= sizeof (data0));
|
||||
fail_unless (memcmp (data0, GST_BUFFER_DATA (outbuffer),
|
||||
fail_unless (gst_buffer_get_size (outbuffer) >= sizeof (data0));
|
||||
fail_unless (gst_buffer_memcmp (outbuffer, 0, data0,
|
||||
sizeof (data0)) == 0);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -98,7 +98,7 @@ guint8 mp2_data[] = /* 384 */
|
|||
/* end binary data. size = 384 bytes */
|
||||
|
||||
static gboolean
|
||||
test_sink_event (GstPad * pad, GstEvent * event)
|
||||
test_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
||||
{
|
||||
|
||||
switch (GST_EVENT_TYPE (event)) {
|
||||
|
@ -112,7 +112,7 @@ test_sink_event (GstPad * pad, GstEvent * event)
|
|||
break;
|
||||
}
|
||||
|
||||
return gst_pad_event_default (pad, event);
|
||||
return gst_pad_event_default (pad, parent, event);
|
||||
}
|
||||
|
||||
/* setup and teardown needs some special handling for muxer */
|
||||
|
@ -183,7 +183,7 @@ setup_mplex (void)
|
|||
GST_DEBUG ("setup_mplex");
|
||||
mplex = gst_check_setup_element ("mplex");
|
||||
mysrcpad = setup_src_pad (mplex, &srctemplate, NULL, "audio_%u");
|
||||
mysinkpad = gst_check_setup_sink_pad (mplex, &sinktemplate, NULL);
|
||||
mysinkpad = gst_check_setup_sink_pad (mplex, &sinktemplate);
|
||||
gst_pad_set_active (mysrcpad, TRUE);
|
||||
gst_pad_set_active (mysinkpad, TRUE);
|
||||
|
||||
|
@ -234,10 +234,9 @@ GST_START_TEST (test_audio_pad)
|
|||
|
||||
/* corresponds to I420 buffer for the size mentioned in the caps */
|
||||
inbuffer = gst_buffer_new ();
|
||||
GST_BUFFER_DATA (inbuffer) = mp2_data;
|
||||
GST_BUFFER_SIZE (inbuffer) = sizeof (mp2_data);
|
||||
gst_buffer_fill (inbuffer, 0, mp2_data, sizeof (mp2_data));
|
||||
caps = gst_caps_from_string (AUDIO_CAPS_STRING);
|
||||
gst_buffer_set_caps (inbuffer, caps);
|
||||
gst_pad_set_caps (mysrcpad, caps);
|
||||
gst_caps_unref (caps);
|
||||
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
|
@ -261,14 +260,14 @@ GST_START_TEST (test_audio_pad)
|
|||
fail_if (outbuffer == NULL);
|
||||
|
||||
if (i == 0) {
|
||||
fail_unless (GST_BUFFER_SIZE (outbuffer) >= sizeof (data0));
|
||||
fail_unless (memcmp (data0, GST_BUFFER_DATA (outbuffer),
|
||||
fail_unless (gst_buffer_get_size (outbuffer) >= sizeof (data0));
|
||||
fail_unless (gst_buffer_memcmp (outbuffer, 0, data0,
|
||||
sizeof (data0)) == 0);
|
||||
}
|
||||
if (i == num_buffers - 1) {
|
||||
fail_unless (GST_BUFFER_SIZE (outbuffer) >= sizeof (data1));
|
||||
fail_unless (memcmp (data1, GST_BUFFER_DATA (outbuffer) +
|
||||
GST_BUFFER_SIZE (outbuffer) - sizeof (data1),
|
||||
fail_unless (gst_buffer_get_size (outbuffer) >= sizeof (data1));
|
||||
fail_unless (gst_buffer_memcmp (outbuffer,
|
||||
gst_buffer_get_size (outbuffer) - sizeof (data1), data1,
|
||||
sizeof (data1)) == 0);
|
||||
}
|
||||
buffers = g_list_remove (buffers, outbuffer);
|
||||
|
|
Loading…
Reference in a new issue