tests: fix some unit tests

Remove unit test for GstIndex.
Make some other unit tests compile
This commit is contained in:
Wim Taymans 2012-01-03 10:26:48 +01:00
parent 27ee8931dd
commit 08d8b81005
14 changed files with 372 additions and 424 deletions

View file

@ -99,7 +99,6 @@ endif
check_PROGRAMS = \
generic/index \
generic/states \
elements/aacparse \
elements/ac3parse \
@ -217,14 +216,23 @@ elements_audiodynamic_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMIN
elements_audioecho_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
elements_audioecho_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LDADD)
elements_audioinvert_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
elements_audioinvert_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LDADD)
elements_audiopanorama_LDADD = \
$(GST_BASE_LIBS) $(GST_CONTROLLER_LIBS) \
$(LDADD)
$(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(GST_BASE_LIBS) \
$(GST_CONTROLLER_LIBS) $(LDADD)
elements_audiopanorama_CFLAGS = \
$(GST_BASE_CFLAGS) $(GST_CONTROLLER_CFLAGS) \
$(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CONTROLLER_CFLAGS) \
$(CFLAGS) $(AM_CFLAGS)
elements_audiowsincband_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
elements_audiowsincband_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LDADD)
elements_audiowsinclimit_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
elements_audiowsinclimit_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LDADD)
elements_cmmldec_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
elements_cmmlenc_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)

View file

@ -88,15 +88,20 @@ on_handoff (GstElement * object, GstBuffer * buffer, GstPad * pad,
gpointer user_data)
{
if (!have_data) {
gdouble *data = (gdouble *) GST_BUFFER_DATA (buffer);
gsize size;
gdouble *data;
fail_unless (GST_BUFFER_SIZE (buffer) > 5 * sizeof (gdouble));
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
fail_unless (size > 5 * sizeof (gdouble));
fail_unless (data[0] == 0.0);
fail_unless (data[1] == 0.0);
fail_unless (data[2] == 0.0);
fail_unless (data[3] == 0.0);
fail_unless (data[4] == 0.0);
fail_unless (data[5] != 0.0);
gst_buffer_unmap (buffer, data, size);
have_data = TRUE;
}
}

View file

@ -98,15 +98,20 @@ on_handoff (GstElement * object, GstBuffer * buffer, GstPad * pad,
gpointer user_data)
{
if (!have_data) {
gdouble *data = (gdouble *) GST_BUFFER_DATA (buffer);
gsize size;
gdouble *data;
fail_unless (GST_BUFFER_SIZE (buffer) > 5 * sizeof (gdouble));
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
fail_unless (size > 5 * sizeof (gdouble));
fail_unless (data[0] == 0.0);
fail_unless (data[1] == 0.0);
fail_unless (data[2] == 0.0);
fail_unless (data[3] == 0.0);
fail_unless (data[4] == 0.0);
fail_unless (data[5] != 0.0);
gst_buffer_unmap (buffer, data, size);
have_data = TRUE;
}
}

View file

@ -25,6 +25,7 @@
#include <unistd.h>
#include <gst/audio/audio.h>
#include <gst/base/gstbasetransform.h>
#include <gst/check/gstcheck.h>
@ -102,10 +103,10 @@ GST_START_TEST (test_passthrough)
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (8);
memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 8) == 0);
gst_buffer_fill (inbuffer, 0, in, 8);
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 8) == 0);
caps = gst_caps_from_string (INVERT_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -115,10 +116,12 @@ GST_START_TEST (test_passthrough)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
res = (gint16 *) GST_BUFFER_DATA (outbuffer);
res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d",
in[0], in[1], in[2], in[3], res[0], res[1], res[2], res[3]);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), in, 8) == 0);
gst_buffer_unmap (outbuffer, res, -1);
fail_unless (gst_buffer_memcmp (outbuffer, 0, in, 8) == 0);
/* cleanup */
cleanup_invert (invert);
@ -142,10 +145,10 @@ GST_START_TEST (test_zero)
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (8);
memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 8) == 0);
gst_buffer_fill (inbuffer, 0, in, 8);
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 8) == 0);
caps = gst_caps_from_string (INVERT_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -155,10 +158,12 @@ GST_START_TEST (test_zero)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
res = (gint16 *) GST_BUFFER_DATA (outbuffer);
res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 8) == 0);
gst_buffer_unmap (outbuffer, res, -1);
fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 8) == 0);
/* cleanup */
cleanup_invert (invert);
@ -182,10 +187,10 @@ GST_START_TEST (test_full_inverse)
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (8);
memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 8) == 0);
gst_buffer_fill (inbuffer, 0, in, 8);
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 8) == 0);
caps = gst_caps_from_string (INVERT_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -195,10 +200,12 @@ GST_START_TEST (test_full_inverse)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
res = (gint16 *) GST_BUFFER_DATA (outbuffer);
res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 8) == 0);
gst_buffer_unmap (outbuffer, res, -1);
fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 8) == 0);
/* cleanup */
cleanup_invert (invert);
@ -222,10 +229,10 @@ GST_START_TEST (test_25_inverse)
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (8);
memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 8) == 0);
gst_buffer_fill (inbuffer, 0, in, 8);
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 8) == 0);
caps = gst_caps_from_string (INVERT_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -235,10 +242,12 @@ GST_START_TEST (test_25_inverse)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
res = (gint16 *) GST_BUFFER_DATA (outbuffer);
res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 8) == 0);
gst_buffer_unmap (outbuffer, res, -1);
fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 8) == 0);
/* cleanup */
cleanup_invert (invert);

View file

@ -21,6 +21,7 @@
*/
#include <gst/gst.h>
#include <gst/audio/audio.h>
#include <gst/base/gstbasetransform.h>
#include <gst/check/gstcheck.h>
@ -32,34 +33,32 @@
GstPad *mysrcpad, *mysinkpad;
#define AUDIO_WSINC_BAND_CAPS_STRING_32 \
"audio/x-raw-float, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) 32" \
"audio/x-raw, " \
"format = (string) " GST_AUDIO_NE (F32) ", " \
"channels = (int) 1, " \
"rate = (int) 44100"
#define AUDIO_WSINC_BAND_CAPS_STRING_64 \
"audio/x-raw-float, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) 64" \
"audio/x-raw, " \
"format = (string) " GST_AUDIO_NE (F64) ", " \
"channels = (int) 1, " \
"rate = (int) 44100"
#define FORMATS "{ "GST_AUDIO_NE (F32)","GST_AUDIO_NE (F64)" }"
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-float, "
"channels = (int) 1, "
"rate = (int) 44100, "
"endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 } ")
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " FORMATS ", "
"channels = (int) 1, " "rate = (int) 44100")
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-float, "
"channels = (int) 1, "
"rate = (int) 44100, "
"endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 } ")
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " FORMATS ", "
"channels = (int) 1, " "rate = (int) 44100")
);
static GstElement *
@ -120,12 +119,14 @@ GST_START_TEST (test_32_bp_0hz)
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gfloat *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i++)
in[i] = 1.0;
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_32);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -137,11 +138,13 @@ GST_START_TEST (test_32_bp_0hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gfloat *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gfloat);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
@ -182,16 +185,17 @@ GST_START_TEST (test_32_bp_11025hz)
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gfloat *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 4) {
in[i] = 0.0;
in[i + 1] = 1.0;
in[i + 2] = 0.0;
in[i + 3] = -1.0;
}
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_32);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -203,11 +207,12 @@ GST_START_TEST (test_32_bp_11025hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gfloat *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gfloat);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
@ -249,14 +254,15 @@ GST_START_TEST (test_32_bp_22050hz)
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gfloat *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_32);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -268,11 +274,12 @@ GST_START_TEST (test_32_bp_22050hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gfloat *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gfloat);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
@ -313,12 +320,13 @@ GST_START_TEST (test_32_br_0hz)
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gfloat *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i++)
in[i] = 1.0;
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_32);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -330,11 +338,12 @@ GST_START_TEST (test_32_br_0hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gfloat *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gfloat);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
@ -375,7 +384,7 @@ GST_START_TEST (test_32_br_11025hz)
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gfloat *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 4) {
in[i] = 0.0;
@ -383,9 +392,10 @@ GST_START_TEST (test_32_br_11025hz)
in[i + 2] = 0.0;
in[i + 3] = -1.0;
}
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_32);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -397,11 +407,12 @@ GST_START_TEST (test_32_br_11025hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gfloat *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gfloat);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
@ -443,14 +454,15 @@ GST_START_TEST (test_32_br_22050hz)
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gfloat *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_32);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -462,11 +474,12 @@ GST_START_TEST (test_32_br_22050hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gfloat *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gfloat);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
@ -505,12 +518,13 @@ GST_START_TEST (test_32_small_buffer)
44100 / 4.0 + 44100 / 16.0, NULL);
inbuffer = gst_buffer_new_and_alloc (20 * sizeof (gfloat));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gfloat *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 20; i++)
in[i] = 1.0;
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_32);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -561,12 +575,13 @@ GST_START_TEST (test_64_bp_0hz)
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gdouble *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i++)
in[i] = 1.0;
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -578,11 +593,12 @@ GST_START_TEST (test_64_bp_0hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gdouble *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gdouble);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
@ -623,16 +639,17 @@ GST_START_TEST (test_64_bp_11025hz)
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gdouble *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 4) {
in[i] = 0.0;
in[i + 1] = 1.0;
in[i + 2] = 0.0;
in[i + 3] = -1.0;
}
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -644,11 +661,12 @@ GST_START_TEST (test_64_bp_11025hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gdouble *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gdouble);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
@ -690,14 +708,15 @@ GST_START_TEST (test_64_bp_22050hz)
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gdouble *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -709,11 +728,12 @@ GST_START_TEST (test_64_bp_22050hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gdouble *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gdouble);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
@ -754,12 +774,13 @@ GST_START_TEST (test_64_br_0hz)
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gdouble *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i++)
in[i] = 1.0;
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -771,11 +792,12 @@ GST_START_TEST (test_64_br_0hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gdouble *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gdouble);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
@ -816,7 +838,7 @@ GST_START_TEST (test_64_br_11025hz)
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gdouble *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 4) {
in[i] = 0.0;
@ -824,9 +846,10 @@ GST_START_TEST (test_64_br_11025hz)
in[i + 2] = 0.0;
in[i + 3] = -1.0;
}
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -838,11 +861,12 @@ GST_START_TEST (test_64_br_11025hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gdouble *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gdouble);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
@ -884,14 +908,15 @@ GST_START_TEST (test_64_br_22050hz)
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gdouble *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -903,11 +928,12 @@ GST_START_TEST (test_64_br_22050hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gdouble *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gdouble);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
@ -946,12 +972,13 @@ GST_START_TEST (test_64_small_buffer)
44100 / 4.0 + 44100 / 16.0, NULL);
inbuffer = gst_buffer_new_and_alloc (20 * sizeof (gdouble));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gdouble *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 20; i++)
in[i] = 1.0;
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);

View file

@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
@ -21,6 +21,7 @@
*/
#include <gst/gst.h>
#include <gst/audio/audio.h>
#include <gst/base/gstbasetransform.h>
#include <gst/check/gstcheck.h>
@ -32,34 +33,32 @@
GstPad *mysrcpad, *mysinkpad;
#define AUDIO_WSINC_LIMIT_CAPS_STRING_32 \
"audio/x-raw-float, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) 32" \
"audio/x-raw, " \
"format = (string) " GST_AUDIO_NE (F32) ", " \
"channels = (int) 1, " \
"rate = (int) 44100"
#define AUDIO_WSINC_LIMIT_CAPS_STRING_64 \
"audio/x-raw-float, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) 64" \
"audio/x-raw, " \
"format = (string) " GST_AUDIO_NE (F64) ", " \
"channels = (int) 1, " \
"rate = (int) 44100"
#define FORMATS "{ "GST_AUDIO_NE (F32)","GST_AUDIO_NE (F64)" }"
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-float, "
"channels = (int) 1, "
"rate = (int) 44100, "
"endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 } ")
GST_STATIC_CAPS ("audio/x-raw, "
"channels = (string) " FORMATS ", "
"channels = (int) 1, " "rate = (int) 44100")
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-float, "
"channels = (int) 1, "
"rate = (int) 44100, "
"endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 } ")
GST_STATIC_CAPS ("audio/x-raw, "
"channels = (string) " FORMATS ", "
"channels = (int) 1, " "rate = (int) 44100")
);
static GstElement *
@ -118,12 +117,13 @@ GST_START_TEST (test_32_lp_0hz)
g_object_set (G_OBJECT (audiowsinclimit), "cutoff", 44100 / 4.0, NULL);
inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gfloat *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i++)
in[i] = 1.0;
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_LIMIT_CAPS_STRING_32);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -135,15 +135,17 @@ GST_START_TEST (test_32_lp_0hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gfloat *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gfloat);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
rms = sqrt (rms / buffer_length);
gst_buffer_unmap (outbuffer, res, size);
fail_unless (rms >= 0.9);
}
@ -177,14 +179,15 @@ GST_START_TEST (test_32_lp_22050hz)
g_object_set (G_OBJECT (audiowsinclimit), "cutoff", 44100 / 4.0, NULL);
inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gfloat *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_LIMIT_CAPS_STRING_32);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -196,15 +199,17 @@ GST_START_TEST (test_32_lp_22050hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gfloat *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gfloat);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
rms = sqrt (rms / buffer_length);
gst_buffer_unmap (outbuffer, res, size);
fail_unless (rms <= 0.1);
}
@ -238,12 +243,13 @@ GST_START_TEST (test_32_hp_0hz)
g_object_set (G_OBJECT (audiowsinclimit), "cutoff", 44100 / 4.0, NULL);
inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gfloat *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i++)
in[i] = 1.0;
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_LIMIT_CAPS_STRING_32);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -255,15 +261,17 @@ GST_START_TEST (test_32_hp_0hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gfloat *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gfloat);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
rms = sqrt (rms / buffer_length);
gst_buffer_unmap (outbuffer, res, size);
fail_unless (rms <= 0.1);
}
@ -297,14 +305,15 @@ GST_START_TEST (test_32_hp_22050hz)
g_object_set (G_OBJECT (audiowsinclimit), "cutoff", 44100 / 4.0, NULL);
inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gfloat *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_LIMIT_CAPS_STRING_32);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -317,15 +326,17 @@ GST_START_TEST (test_32_hp_22050hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gfloat *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gfloat);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
rms = sqrt (rms / buffer_length);
gst_buffer_unmap (outbuffer, res, size);
fail_unless (rms >= 0.9);
}
@ -357,12 +368,13 @@ GST_START_TEST (test_32_small_buffer)
g_object_set (G_OBJECT (audiowsinclimit), "cutoff", 44100 / 4.0, NULL);
inbuffer = gst_buffer_new_and_alloc (20 * sizeof (gfloat));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gfloat *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 20; i++)
in[i] = 1.0;
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_LIMIT_CAPS_STRING_32);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -404,12 +416,13 @@ GST_START_TEST (test_64_lp_0hz)
g_object_set (G_OBJECT (audiowsinclimit), "cutoff", 44100 / 4.0, NULL);
inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gdouble *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i++)
in[i] = 1.0;
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_LIMIT_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -421,15 +434,17 @@ GST_START_TEST (test_64_lp_0hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gdouble *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gdouble);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
rms = sqrt (rms / buffer_length);
gst_buffer_unmap (outbuffer, res, size);
fail_unless (rms >= 0.9);
}
@ -463,14 +478,15 @@ GST_START_TEST (test_64_lp_22050hz)
g_object_set (G_OBJECT (audiowsinclimit), "cutoff", 44100 / 4.0, NULL);
inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gdouble *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_LIMIT_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -482,15 +498,17 @@ GST_START_TEST (test_64_lp_22050hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gdouble *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gdouble);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
rms = sqrt (rms / buffer_length);
gst_buffer_unmap (outbuffer, res, size);
fail_unless (rms <= 0.1);
}
@ -524,12 +542,13 @@ GST_START_TEST (test_64_hp_0hz)
g_object_set (G_OBJECT (audiowsinclimit), "cutoff", 44100 / 4.0, NULL);
inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gdouble *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i++)
in[i] = 1.0;
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_LIMIT_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -541,15 +560,17 @@ GST_START_TEST (test_64_hp_0hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gdouble *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gdouble);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
rms = sqrt (rms / buffer_length);
gst_buffer_unmap (outbuffer, res, size);
fail_unless (rms <= 0.1);
}
@ -583,14 +604,15 @@ GST_START_TEST (test_64_hp_22050hz)
g_object_set (G_OBJECT (audiowsinclimit), "cutoff", 44100 / 4.0, NULL);
inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gdouble *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_LIMIT_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -603,15 +625,17 @@ GST_START_TEST (test_64_hp_22050hz)
for (node = buffers; node; node = node->next) {
gint buffer_length;
gsize size;
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
res = (gdouble *) GST_BUFFER_DATA (outbuffer);
buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gdouble);
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
buffer_length = size / sizeof (gfloat);
rms = 0.0;
for (i = 0; i < buffer_length; i++)
rms += res[i] * res[i];
rms = sqrt (rms / buffer_length);
gst_buffer_unmap (outbuffer, res, size);
fail_unless (rms >= 0.9);
}
@ -643,12 +667,13 @@ GST_START_TEST (test_64_small_buffer)
g_object_set (G_OBJECT (audiowsinclimit), "cutoff", 44100 / 4.0, NULL);
inbuffer = gst_buffer_new_and_alloc (20 * sizeof (gdouble));
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
in = (gdouble *) GST_BUFFER_DATA (inbuffer);
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 20; i++)
in[i] = 1.0;
gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (AUDIO_WSINC_LIMIT_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);

View file

@ -35,8 +35,8 @@ GST_START_TEST (test_autovideosink_ghostpad_error_case)
filter = gst_element_factory_make ("capsfilter", NULL);
sink = gst_element_factory_make ("autovideosink", NULL);
caps = gst_caps_new_simple ("video/x-raw-yuv", "format", GST_TYPE_FOURCC,
GST_MAKE_FOURCC ('A', 'C', 'D', 'C'), NULL);
caps = gst_caps_new_simple ("video/x-raw", "format", G_TYPE_STRING,
"ABCD", NULL);
g_object_set (filter, "caps", caps, NULL);
gst_caps_unref (caps);

View file

@ -169,7 +169,7 @@ check_avimux_pad (GstStaticPadTemplate * srctemplate,
inbuffer = gst_buffer_new_and_alloc (1);
caps = gst_caps_from_string (src_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);
@ -186,7 +186,10 @@ check_avimux_pad (GstStaticPadTemplate * srctemplate,
switch (i) {
case 0:{ /* check riff header */
/* avi header */
guint8 *data = GST_BUFFER_DATA (outbuffer);
gsize size;
guint8 *data, *orig;
data = orig = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
fail_unless (memcmp (data, data0, sizeof (data0)) == 0);
fail_unless (memcmp (data + 8, data1, sizeof (data1)) == 0);
@ -197,22 +200,23 @@ check_avimux_pad (GstStaticPadTemplate * srctemplate,
fail_unless (memcmp (data + 8, data4, sizeof (data4)) == 0);
fail_unless (memcmp (data + 76, data5, sizeof (data5)) == 0);
/* avi data header */
data = GST_BUFFER_DATA (outbuffer);
data += GST_BUFFER_SIZE (outbuffer) - 12;
data = orig;
data += size - 12;
fail_unless (memcmp (data, data6, sizeof (data6)) == 0);
data += 8;
fail_unless (memcmp (data, data7, sizeof (data7)) == 0);
gst_buffer_unmap (outbuffer, orig, size);
break;
}
case 1: /* chunk header */
fail_unless (GST_BUFFER_SIZE (outbuffer) == 8);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), chunk_id, 4) == 0);
fail_unless (gst_buffer_get_size (outbuffer) == 8);
fail_unless (gst_buffer_memcmp (outbuffer, 0, chunk_id, 4) == 0);
break;
case 2:
fail_unless (GST_BUFFER_SIZE (outbuffer) == 1);
fail_unless (gst_buffer_get_size (outbuffer) == 1);
break;
case 3: /* buffer we put in, must be padded to even size */
fail_unless (GST_BUFFER_SIZE (outbuffer) == 1);
fail_unless (gst_buffer_get_size (outbuffer) == 1);
break;
default:
break;

View file

@ -100,10 +100,10 @@ cleanup_avisubtitle (GstElement * avisubtitle)
static void
check_wrong_buffer (guint8 * data, guint length)
{
GstBuffer *buffer = gst_buffer_new ();
GstBuffer *buffer = gst_buffer_new_allocate (NULL, length, 0);
GstElement *avisubtitle = setup_avisubtitle ();
gst_buffer_set_data (buffer, data, length);
gst_buffer_fill (buffer, 0, data, length);
fail_unless (gst_element_set_state (avisubtitle,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
@ -124,13 +124,13 @@ static void
check_correct_buffer (guint8 * src_data, guint src_size, guint8 * dst_data,
guint dst_size)
{
GstBuffer *buffer = gst_buffer_new ();
GstBuffer *buffer = gst_buffer_new_allocate (NULL, src_size, 0);
GstBuffer *newBuffer;
GstElement *avisubtitle = setup_avisubtitle ();
GstEvent *event;
fail_unless (g_list_length (buffers) == 0, "Buffers list needs to be empty");
gst_buffer_set_data (buffer, src_data, src_size);
gst_buffer_fill (buffer, 0, src_data, src_size);
fail_unless (gst_element_set_state (avisubtitle,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
@ -155,10 +155,10 @@ check_correct_buffer (guint8 * src_data, guint src_size, guint8 * dst_data,
newBuffer = GST_BUFFER (buffers->data);
buffers = g_list_remove (buffers, newBuffer);
fail_unless (g_list_length (buffers) == 1, "Buffers list needs to be empty");
fail_unless (GST_BUFFER_SIZE (newBuffer) == dst_size,
fail_unless (gst_buffer_get_size (newBuffer) == dst_size,
"size of the new buffer is wrong ( %d != %d)",
GST_BUFFER_SIZE (newBuffer), dst_size);
fail_unless (memcmp (GST_BUFFER_DATA (newBuffer), dst_data, dst_size) == 0,
gst_buffer_get_size (newBuffer), dst_size);
fail_unless (gst_buffer_memcmp (newBuffer, 0, dst_data, dst_size) == 0,
"data of the buffer is not correct");
gst_buffer_unref (newBuffer);
/* free the buffer from seeking */

View file

@ -74,24 +74,25 @@ push_and_test (GstCaps * prop_caps, gboolean join, gboolean replace,
{
GstElement *capssetter;
GstBuffer *buffer;
GstCaps *current_out;
capssetter = setup_capssetter ();
fail_unless (gst_element_set_state (capssetter,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
buffer = gst_buffer_new_and_alloc (4);
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
memcpy (GST_BUFFER_DATA (buffer), "data", 4);
gst_buffer_set_caps (buffer, in_caps);
gst_caps_unref (in_caps);
g_object_set (capssetter, "join", join, NULL);
g_object_set (capssetter, "replace", replace, NULL);
g_object_set (capssetter, "caps", prop_caps, NULL);
gst_caps_unref (prop_caps);
buffer = gst_buffer_new_and_alloc (4);
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
gst_buffer_fill (buffer, 0, "data", 4);
gst_pad_set_caps (mysrcpad, in_caps);
gst_caps_unref (in_caps);
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK,
"Failed pushing buffer to capssetter");
@ -103,7 +104,9 @@ push_and_test (GstCaps * prop_caps, gboolean join, gboolean replace,
buffer = g_list_first (buffers)->data;
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
fail_unless (gst_caps_is_equal (out_caps, GST_BUFFER_CAPS (buffer)));
current_out = gst_pad_get_current_caps (mysinkpad);
fail_unless (gst_caps_is_equal (out_caps, current_out));
gst_caps_unref (current_out);
gst_caps_unref (out_caps);
/* cleanup */

View file

@ -28,13 +28,12 @@
static gboolean
gst_caps_is_interlaced (GstCaps * caps)
{
GstStructure G_GNUC_UNUSED *structure;
gboolean interlaced = FALSE;
GstVideoInfo info;
fail_unless (gst_caps_is_fixed (caps));
structure = gst_caps_get_structure (caps, 0);
fail_unless (gst_video_format_parse_caps_interlaced (caps, &interlaced));
return interlaced;
fail_unless (gst_video_info_from_caps (&info, caps));
return GST_VIDEO_INFO_IS_INTERLACED (&info);
}
GST_START_TEST (test_create_and_unref)
@ -57,40 +56,40 @@ GST_END_TEST;
"width=(int)3200, height=(int)3400, framerate=(fraction)0/1"
#define CAPS_YUY2 \
"video/x-raw-yuv, " \
"video/x-raw, " \
CAPS_VIDEO_COMMON ", " \
"format=(fourcc)YUY2"
"format=(string)YUY2"
#define CAPS_YUY2_INTERLACED \
CAPS_YUY2 ", " \
"interlaced=(boolean)true"
"interlace-mode=interleaved"
#define CAPS_YVYU \
"video/x-raw-yuv, " \
"video/x-raw, " \
CAPS_VIDEO_COMMON ", " \
"format=(fourcc)YVYU"
"format=(string)YVYU"
#define CAPS_YVYU_INTERLACED \
CAPS_YVYU ", " \
"interlaced=(boolean)true"
"interlace-mode=interleaved"
#define CAPS_YUY2_IMAGE \
"video/x-raw-yuv, " \
"video/x-raw, " \
CAPS_IMAGE_COMMON ", " \
"format=(fourcc)YUY2"
"format=(string)YUY2"
#define CAPS_YUY2_INTERLACED_IMAGE \
CAPS_YUY2_IMAGE ", " \
"interlaced=(boolean)true"
"interlace-mode=interleaved"
#define CAPS_YVYU_IMAGE \
"video/x-raw-yuv, " \
"video/x-raw, " \
CAPS_IMAGE_COMMON ", " \
"format=(fourcc)YVYU"
"format=(string)YVYU"
#define CAPS_YVYU_INTERLACED_IMAGE \
CAPS_YVYU_IMAGE ", " \
"interlaced=(boolean)true"
"interlace-mode=interleaved"
static GstElement *deinterlace;
static GstPad *srcpad;
@ -168,49 +167,46 @@ setup_test_pipeline (gint mode, GstCaps * infiltercaps, GstCaps * outfiltercaps,
/*
* Checks if 2 buffers are equal
*
* Equals means same caps and same data
* Equals means same data
*/
static gboolean
test_buffer_equals (GstBuffer * buf_a, GstBuffer * buf_b)
{
GstCaps *caps_a;
GstCaps *caps_b;
gsize s1, s2;
gpointer d1, d2;
gboolean res = FALSE;
if (GST_BUFFER_SIZE (buf_a) != GST_BUFFER_SIZE (buf_b))
return FALSE;
d1 = gst_buffer_map (buf_a, &s1, NULL, GST_MAP_READ);
d2 = gst_buffer_map (buf_b, &s2, NULL, GST_MAP_READ);
caps_a = gst_buffer_get_caps (buf_a);
caps_b = gst_buffer_get_caps (buf_b);
if (!gst_caps_is_equal (caps_a, caps_b))
return FALSE;
gst_caps_unref (caps_a);
gst_caps_unref (caps_b);
return memcmp (GST_BUFFER_DATA (buf_a), GST_BUFFER_DATA (buf_b),
GST_BUFFER_SIZE (buf_a)) == 0;
if (s1 == s2) {
res = memcmp (d1, d2, s1) == 0;
}
return res;
}
static gboolean
sinkpad_enqueue_buffer (GstPad * pad, GstBuffer * buf, gpointer data)
static GstPadProbeReturn
sinkpad_enqueue_buffer (GstPad * pad, GstPadProbeInfo * info, gpointer data)
{
GQueue *queue = (GQueue *) data;
GstBuffer *buf = GST_PAD_PROBE_INFO_BUFFER (info);
/* enqueue a copy for being compared later */
g_queue_push_tail (queue, gst_buffer_copy (buf));
return TRUE;
return GST_PAD_PROBE_OK;
}
/*
* pad buffer probe that compares the buffer with the top one
* in the GQueue passed as the user data
*/
static gboolean
srcpad_dequeue_and_compare_buffer (GstPad * pad, GstBuffer * buf, gpointer data)
static GstPadProbeReturn
srcpad_dequeue_and_compare_buffer (GstPad * pad, GstPadProbeInfo * info,
gpointer data)
{
GQueue *queue = (GQueue *) data;
GstBuffer *buf = GST_PAD_PROBE_INFO_BUFFER (info);
GstBuffer *queue_buf;
queue_buf = (GstBuffer *) g_queue_pop_head (queue);
@ -220,7 +216,7 @@ srcpad_dequeue_and_compare_buffer (GstPad * pad, GstBuffer * buf, gpointer data)
gst_buffer_unref (queue_buf);
return TRUE;
return GST_PAD_PROBE_OK;
}
/*
@ -243,9 +239,10 @@ deinterlace_check_passthrough (gint mode, const gchar * infiltercaps)
queue = g_queue_new ();
/* set up probes for testing */
gst_pad_add_buffer_probe (sinkpad, (GCallback) sinkpad_enqueue_buffer, queue);
gst_pad_add_buffer_probe (srcpad,
(GCallback) srcpad_dequeue_and_compare_buffer, queue);
gst_pad_add_probe (sinkpad, GST_PAD_PROBE_TYPE_BUFFER, sinkpad_enqueue_buffer,
queue, NULL);
gst_pad_add_probe (srcpad, GST_PAD_PROBE_TYPE_BUFFER,
srcpad_dequeue_and_compare_buffer, queue, NULL);
fail_unless (gst_element_set_state (pipeline, GST_STATE_PLAYING) !=
GST_STATE_CHANGE_FAILURE);

View file

@ -46,51 +46,46 @@ static GstElement *deinterleave;
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-float, "
"width = (int) 32, "
"channels = (int) 1, "
"rate = (int) {32000, 48000}, " "endianness = (int) BYTE_ORDER"));
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " GST_AUDIO_NE (F32) ", "
"channels = (int) 1, " "rate = (int) {32000, 48000}"));
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-float, "
"width = (int) 32, "
"channels = (int) { 2, 3 }, "
"rate = (int) {32000, 48000}, " "endianness = (int) BYTE_ORDER"));
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " GST_AUDIO_NE (F32) ", "
"channels = (int) { 2, 3 }, " "rate = (int) {32000, 48000}"));
#define CAPS_32khz \
"audio/x-raw-float, " \
"width = (int) 32, " \
"audio/x-raw, " \
"format = (string) "GST_AUDIO_NE (F32) ", " \
"channels = (int) 2, " \
"rate = (int) 32000, " \
"endianness = (int) BYTE_ORDER"
"rate = (int) 32000"
#define CAPS_48khz \
"audio/x-raw-float, " \
"width = (int) 32, " \
"audio/x-raw, " \
"format = (string) "GST_AUDIO_NE (F32) ", " \
"channels = (int) 2, " \
"rate = (int) 48000, " \
"endianness = (int) BYTE_ORDER"
"rate = (int) 48000"
#define CAPS_48khz_3CH \
"audio/x-raw-float, " \
"width = (int) 32, " \
"audio/x-raw, " \
"format = (string) "GST_AUDIO_NE (F32) ", " \
"channels = (int) 3, " \
"rate = (int) 48000, " \
"endianness = (int) BYTE_ORDER"
"rate = (int) 48000"
static GstFlowReturn
deinterleave_chain_func (GstPad * pad, GstBuffer * buffer)
deinterleave_chain_func (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
gint i;
gsize size;
gfloat *indata;
fail_unless (GST_IS_BUFFER (buffer));
fail_unless_equals_int (GST_BUFFER_SIZE (buffer), 48000 * sizeof (gfloat));
fail_unless (GST_BUFFER_DATA (buffer) != NULL);
indata = (gfloat *) GST_BUFFER_DATA (buffer);
indata = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
fail_unless_equals_int (size, 48000 * sizeof (gfloat));
fail_unless (indata != NULL);
if (strcmp (GST_PAD_NAME (pad), "sink0") == 0) {
for (i = 0; i < 48000; i++)
@ -101,7 +96,7 @@ deinterleave_chain_func (GstPad * pad, GstBuffer * buffer)
} else {
g_assert_not_reached ();
}
gst_buffer_unmap (buffer, indata, size);
gst_buffer_unref (buffer);
return GST_FLOW_OK;
@ -165,12 +160,13 @@ GST_START_TEST (test_2_channels)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS);
inbuf = gst_buffer_new_and_alloc (2 * 48000 * sizeof (gfloat));
indata = (gfloat *) GST_BUFFER_DATA (inbuf);
indata = gst_buffer_map (inbuf, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 2 * 48000; i += 2) {
indata[i] = -1.0;
indata[i + 1] = 1.0;
}
gst_buffer_set_caps (inbuf, caps);
gst_buffer_unmap (inbuf, indata, -1);
gst_pad_set_caps (mysrcpad, caps);
fail_unless (gst_pad_push (mysrcpad, inbuf) == GST_FLOW_OK);
@ -225,12 +221,13 @@ GST_START_TEST (test_2_channels_1_linked)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS);
inbuf = gst_buffer_new_and_alloc (2 * 48000 * sizeof (gfloat));
indata = (gfloat *) GST_BUFFER_DATA (inbuf);
indata = gst_buffer_map (inbuf, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 2 * 48000; i += 2) {
indata[i] = -1.0;
indata[i + 1] = 1.0;
}
gst_buffer_set_caps (inbuf, caps);
gst_buffer_unmap (inbuf, indata, -1);
gst_pad_set_caps (mysrcpad, caps);
fail_unless (gst_pad_push (mysrcpad, inbuf) == GST_FLOW_OK);
@ -285,12 +282,13 @@ GST_START_TEST (test_2_channels_caps_change)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS);
inbuf = gst_buffer_new_and_alloc (2 * 48000 * sizeof (gfloat));
indata = (gfloat *) GST_BUFFER_DATA (inbuf);
indata = gst_buffer_map (inbuf, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 2 * 48000; i += 2) {
indata[i] = -1.0;
indata[i + 1] = 1.0;
}
gst_buffer_set_caps (inbuf, caps);
gst_buffer_unmap (inbuf, indata, -1);
gst_pad_set_caps (mysrcpad, caps);
fail_unless (gst_pad_push (mysrcpad, inbuf) == GST_FLOW_OK);
@ -298,12 +296,13 @@ GST_START_TEST (test_2_channels_caps_change)
gst_pad_set_caps (mysrcpad, caps2);
inbuf = gst_buffer_new_and_alloc (2 * 48000 * sizeof (gfloat));
indata = (gfloat *) GST_BUFFER_DATA (inbuf);
indata = gst_buffer_map (inbuf, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 2 * 48000; i += 2) {
indata[i] = -1.0;
indata[i + 1] = 1.0;
}
gst_buffer_set_caps (inbuf, caps2);
gst_buffer_unmap (inbuf, indata, -1);
gst_pad_set_caps (mysrcpad, caps2);
/* Should work fine because the caps changed in a compatible way */
fail_unless (gst_pad_push (mysrcpad, inbuf) == GST_FLOW_OK);
@ -314,13 +313,14 @@ GST_START_TEST (test_2_channels_caps_change)
gst_pad_set_caps (mysrcpad, caps2);
inbuf = gst_buffer_new_and_alloc (3 * 48000 * sizeof (gfloat));
indata = (gfloat *) GST_BUFFER_DATA (inbuf);
indata = gst_buffer_map (inbuf, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 3 * 48000; i += 3) {
indata[i] = -1.0;
indata[i + 1] = 1.0;
indata[i + 2] = 0.0;
}
gst_buffer_set_caps (inbuf, caps2);
gst_buffer_unmap (inbuf, indata, -1);
gst_pad_set_caps (mysrcpad, caps2);
/* Should break because the caps changed in an incompatible way */
fail_if (gst_pad_push (mysrcpad, inbuf) == GST_FLOW_OK);
@ -376,15 +376,13 @@ src_handoff_float32_8ch (GstElement * src, GstBuffer * buf, GstPad * pad,
{
GstAudioChannelPosition layout[NUM_CHANNELS];
GstCaps *caps;
gfloat *data;
gfloat *data, *p;
guint size, i, c;
caps = gst_caps_new_simple ("audio/x-raw-float",
"width", G_TYPE_INT, 32,
"depth", G_TYPE_INT, 32,
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
"channels", G_TYPE_INT, NUM_CHANNELS,
"rate", G_TYPE_INT, SAMPLE_RATE,
"endianness", G_TYPE_INT, G_BYTE_ORDER, NULL);
"rate", G_TYPE_INT, SAMPLE_RATE, NULL);
for (i = 0; i < NUM_CHANNELS; ++i)
layout[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
@ -392,42 +390,43 @@ src_handoff_float32_8ch (GstElement * src, GstBuffer * buf, GstPad * pad,
set_channel_positions (caps, NUM_CHANNELS, layout);
size = sizeof (gfloat) * SAMPLES_PER_BUFFER * NUM_CHANNELS;
data = (gfloat *) g_malloc (size);
data = p = (gfloat *) g_malloc (size);
GST_BUFFER_MALLOCDATA (buf) = (guint8 *) data;
GST_BUFFER_DATA (buf) = (guint8 *) data;
GST_BUFFER_SIZE (buf) = size;
for (i = 0; i < SAMPLES_PER_BUFFER; ++i) {
for (c = 0; c < NUM_CHANNELS; ++c) {
*p = (gfloat) ((i * NUM_CHANNELS) + c);
++p;
}
}
gst_buffer_take_memory (buf, -1, gst_memory_new_wrapped (0, data, g_free,
size, 0, size));
GST_BUFFER_OFFSET (buf) = 0;
GST_BUFFER_TIMESTAMP (buf) = 0;
GST_BUFFER_CAPS (buf) = caps;
for (i = 0; i < SAMPLES_PER_BUFFER; ++i) {
for (c = 0; c < NUM_CHANNELS; ++c) {
*data = (gfloat) ((i * NUM_CHANNELS) + c);
++data;
}
}
/* FIXME, caps */
}
static gboolean
float_buffer_check_probe (GstPad * pad, GstBuffer * buf, gpointer userdata)
static GstPadProbeReturn
float_buffer_check_probe (GstPad * pad, GstPadProbeInfo * info,
gpointer userdata)
{
gfloat *data;
gsize size;
guint padnum, numpads;
guint num, i;
GstCaps *caps;
GstStructure *s;
GstAudioChannelPosition *pos;
gint channels;
GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info);
fail_unless_equals_int (sscanf (GST_PAD_NAME (pad), "src%u", &padnum), 1);
numpads = pads_created;
/* Check caps */
caps = GST_BUFFER_CAPS (buf);
caps = gst_pad_get_current_caps (pad);
fail_unless (caps != NULL);
s = gst_caps_get_structure (caps, 0);
fail_unless (gst_structure_get_int (s, "channels", &channels));
@ -436,9 +435,10 @@ float_buffer_check_probe (GstPad * pad, GstBuffer * buf, gpointer userdata)
pos = gst_audio_get_channel_positions (s);
fail_unless (pos != NULL && pos[0] == GST_AUDIO_CHANNEL_POSITION_NONE);
g_free (pos);
gst_caps_unref (caps);
data = (gfloat *) GST_BUFFER_DATA (buf);
num = GST_BUFFER_SIZE (buf) / sizeof (gfloat);
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
num = size / sizeof (gfloat);
/* Check buffer content */
for (i = 0; i < num; ++i) {
@ -453,8 +453,9 @@ float_buffer_check_probe (GstPad * pad, GstBuffer * buf, gpointer userdata)
/* check that the first channel is on pad src0, the second on src1 etc. */
fail_unless_equals_int (rest, padnum);
}
gst_buffer_unmap (buffer, data, size);
return TRUE; /* don't drop data */
return GST_PAD_PROBE_OK; /* don't drop data */
}
static void
@ -477,7 +478,8 @@ pad_added_setup_data_check_float32_8ch_cb (GstElement * deinterleave,
fail_unless_equals_int (gst_pad_link (pad, sinkpad), GST_PAD_LINK_OK);
gst_object_unref (sinkpad);
gst_pad_add_buffer_probe (pad, G_CALLBACK (float_buffer_check_probe), NULL);
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER, float_buffer_check_probe,
NULL, NULL);
gst_element_set_state (sink, GST_STATE_PLAYING);
gst_element_set_state (queue, GST_STATE_PLAYING);

View file

@ -1,140 +0,0 @@
/* GStreamer
* unit test for index setting on all elements
* Copyright (C) 2005 Thomas Vander Stichele <thomas at apestaart dot org>
* Copyright (C) 2011 Tim-Philipp Müller <tim centricular net>
*
* 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
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <gst/check/gstcheck.h>
static GList *elements = NULL;
static void
setup (void)
{
GList *features, *f;
GList *plugins, *p;
gchar **ignorelist = NULL;
const gchar *INDEX_IGNORE_ELEMENTS = NULL;
GST_DEBUG ("getting elements for package %s", PACKAGE);
INDEX_IGNORE_ELEMENTS = g_getenv ("GST_INDEX_IGNORE_ELEMENTS");
if (!g_getenv ("GST_NO_INDEX_IGNORE_ELEMENTS") && INDEX_IGNORE_ELEMENTS) {
GST_DEBUG ("Will ignore element factories: '%s'", INDEX_IGNORE_ELEMENTS);
ignorelist = g_strsplit (INDEX_IGNORE_ELEMENTS, " ", 0);
}
plugins = gst_registry_get_plugin_list (gst_registry_get_default ());
for (p = plugins; p; p = p->next) {
GstPlugin *plugin = p->data;
if (strcmp (gst_plugin_get_source (plugin), PACKAGE) != 0)
continue;
features =
gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
gst_plugin_get_name (plugin));
for (f = features; f; f = f->next) {
GstPluginFeature *feature = f->data;
const gchar *name = gst_plugin_feature_get_name (feature);
gboolean ignore = FALSE;
if (!GST_IS_ELEMENT_FACTORY (feature))
continue;
if (ignorelist) {
gchar **s;
for (s = ignorelist; s && *s; ++s) {
if (g_str_has_prefix (name, *s)) {
GST_DEBUG ("ignoring element %s", name);
ignore = TRUE;
}
}
if (ignore)
continue;
}
GST_DEBUG ("adding element %s", name);
elements = g_list_prepend (elements, (gpointer) g_strdup (name));
}
gst_plugin_feature_list_free (features);
}
gst_plugin_list_free (plugins);
g_strfreev (ignorelist);
}
static void
teardown (void)
{
GList *e;
for (e = elements; e; e = e->next) {
g_free (e->data);
}
g_list_free (elements);
elements = NULL;
}
GST_START_TEST (test_set_index)
{
GstElement *element;
GstIndex *idx;
GList *e;
idx = gst_index_factory_make ("memindex");
if (idx == NULL)
return;
gst_object_ref_sink (idx);
for (e = elements; e; e = e->next) {
const gchar *name = e->data;
GST_INFO ("testing element %s", name);
element = gst_element_factory_make (name, name);
fail_if (element == NULL, "Could not make element from factory %s", name);
gst_element_set_index (element, idx);
gst_object_unref (element);
}
gst_object_unref (idx);
}
GST_END_TEST;
static Suite *
index_suite (void)
{
Suite *s = suite_create ("index");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_checked_fixture (tc_chain, setup, teardown);
tcase_add_test (tc_chain, test_set_index);
return s;
}
GST_CHECK_MAIN (index);

View file

@ -37,6 +37,7 @@ setup (void)
GList *plugins, *p;
gchar **ignorelist = NULL;
const gchar *STATE_IGNORE_ELEMENTS = NULL;
GstRegistry *def;
GST_DEBUG ("getting elements for package %s", PACKAGE);
STATE_IGNORE_ELEMENTS = g_getenv ("GST_STATE_IGNORE_ELEMENTS");
@ -45,7 +46,9 @@ setup (void)
ignorelist = g_strsplit (STATE_IGNORE_ELEMENTS, " ", 0);
}
plugins = gst_registry_get_plugin_list (gst_registry_get_default ());
def = gst_registry_get ();
plugins = gst_registry_get_plugin_list (def);
for (p = plugins; p; p = p->next) {
GstPlugin *plugin = p->data;
@ -54,7 +57,7 @@ setup (void)
continue;
features =
gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
gst_registry_get_feature_list_by_plugin (def,
gst_plugin_get_name (plugin));
for (f = features; f; f = f->next) {