Commit 0b3f685d authored by René Stadler's avatar René Stadler
Browse files

tests: audioamplify: port to 0.11

parent 65c71b07
......@@ -27,6 +27,7 @@
#include <gst/base/gstbasetransform.h>
#include <gst/check/gstcheck.h>
#include <gst/audio/audio.h>
gboolean have_eos = FALSE;
......@@ -37,32 +38,25 @@ GstPad *mysrcpad, *mysinkpad;
#define AMPLIFY_CAPS_STRING \
"audio/x-raw-int, " \
"audio/x-raw, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) 16, " \
"depth = (int) 16, " \
"signed = (bool) TRUE"
"format = (string) " GST_AUDIO_NE(S16)
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, "
GST_STATIC_CAPS ("audio/x-raw, "
"channels = (int) 1, "
"rate = (int) [ 1, MAX ], "
"endianness = (int) BYTE_ORDER, "
"width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
);
"format = (string) " GST_AUDIO_NE(S16)));
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, "
GST_STATIC_CAPS ("audio/x-raw, "
"channels = (int) 1, "
"rate = (int) [ 1, MAX ], "
"endianness = (int) BYTE_ORDER, "
"width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
);
"format = (string) " GST_AUDIO_NE(S16)));
static GstElement *
setup_amplify (void)
......@@ -101,19 +95,19 @@ GST_START_TEST (test_passthrough)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
gint16 *res;
gint16 res[6];
amplify = setup_amplify ();
fail_unless (gst_element_set_state (amplify,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (12);
memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
caps = gst_caps_from_string (AMPLIFY_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
......@@ -122,12 +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);
fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
in[0], in[1], in[2], in[3], in[4], in[5], res[0], res[1], res[2], res[3],
res[4], res[5]);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), in, 12) == 0);
fail_unless (gst_buffer_memcmp (outbuffer, 0, in, 12) == 0);
/* cleanup */
cleanup_amplify (amplify);
......@@ -142,7 +136,7 @@ GST_START_TEST (test_zero)
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
gint16 out[6] = { 0, 0, 0, 0, 0, 0 };
gint16 *res;
gint16 res[6];
amplify = setup_amplify ();
g_object_set (G_OBJECT (amplify), "amplification", 0.0, NULL);
......@@ -150,12 +144,12 @@ GST_START_TEST (test_zero)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (12);
memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
caps = gst_caps_from_string (AMPLIFY_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
......@@ -164,12 +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);
fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], out[4], out[5], res[0], res[1], res[2],
res[3], res[4], res[5]);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 12) == 0);
fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 12) == 0);
/* cleanup */
cleanup_amplify (amplify);
......@@ -184,7 +178,7 @@ GST_START_TEST (test_050_clip)
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
gint16 out[6] = { 12288, -8192, 128, -64, 0, -12288 };
gint16 *res;
gint16 res[6];
amplify = setup_amplify ();
g_object_set (G_OBJECT (amplify), "amplification", 0.5, NULL);
......@@ -192,12 +186,12 @@ GST_START_TEST (test_050_clip)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (12);
memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
caps = gst_caps_from_string (AMPLIFY_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
......@@ -206,12 +200,12 @@ GST_START_TEST (test_050_clip)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
res = (gint16 *) GST_BUFFER_DATA (outbuffer);
fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], out[4], out[5], res[0], res[1], res[2],
res[3], res[4], res[5]);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 12) == 0);
fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 12) == 0);
/* cleanup */
cleanup_amplify (amplify);
......@@ -226,7 +220,7 @@ GST_START_TEST (test_200_clip)
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
gint16 out[6] = { G_MAXINT16, -32768, 512, -256, 0, G_MININT16 };
gint16 *res;
gint16 res[6];
amplify = setup_amplify ();
g_object_set (G_OBJECT (amplify), "amplification", 2.0, NULL);
......@@ -234,12 +228,12 @@ GST_START_TEST (test_200_clip)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (12);
memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
caps = gst_caps_from_string (AMPLIFY_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
......@@ -248,12 +242,12 @@ GST_START_TEST (test_200_clip)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
res = (gint16 *) GST_BUFFER_DATA (outbuffer);
fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], out[4], out[5], res[0], res[1], res[2],
res[3], res[4], res[5]);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 12) == 0);
fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 12) == 0);
/* cleanup */
cleanup_amplify (amplify);
......@@ -268,7 +262,7 @@ GST_START_TEST (test_050_wrap_negative)
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
gint16 out[6] = { 12288, -8192, 128, -64, 0, -12288 };
gint16 *res;
gint16 res[6];
amplify = setup_amplify ();
g_object_set (G_OBJECT (amplify), "amplification", 0.5, NULL);
......@@ -277,12 +271,12 @@ GST_START_TEST (test_050_wrap_negative)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (12);
memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
caps = gst_caps_from_string (AMPLIFY_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
......@@ -291,12 +285,12 @@ GST_START_TEST (test_050_wrap_negative)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
res = (gint16 *) GST_BUFFER_DATA (outbuffer);
fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], out[4], out[5], res[0], res[1], res[2],
res[3], res[4], res[5]);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 12) == 0);
fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 12) == 0);
/* cleanup */
cleanup_amplify (amplify);
......@@ -311,7 +305,7 @@ GST_START_TEST (test_200_wrap_negative)
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
gint16 out[6] = { -16384, -32768, 512, -256, 0, 16384 };
gint16 *res;
gint16 res[6];
amplify = setup_amplify ();
g_object_set (G_OBJECT (amplify), "amplification", 2.0, NULL);
......@@ -320,12 +314,12 @@ GST_START_TEST (test_200_wrap_negative)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (12);
memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
caps = gst_caps_from_string (AMPLIFY_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
......@@ -334,12 +328,12 @@ GST_START_TEST (test_200_wrap_negative)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
res = (gint16 *) GST_BUFFER_DATA (outbuffer);
fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], out[4], out[5], res[0], res[1], res[2],
res[3], res[4], res[5]);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 12) == 0);
fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 12) == 0);
/* cleanup */
cleanup_amplify (amplify);
......@@ -354,7 +348,7 @@ GST_START_TEST (test_050_wrap_positive)
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
gint16 out[6] = { 12288, -8192, 128, -64, 0, -12288 };
gint16 *res;
gint16 res[6];
amplify = setup_amplify ();
g_object_set (G_OBJECT (amplify), "amplification", 0.5, NULL);
......@@ -363,12 +357,12 @@ GST_START_TEST (test_050_wrap_positive)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (12);
memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
caps = gst_caps_from_string (AMPLIFY_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
......@@ -377,12 +371,12 @@ GST_START_TEST (test_050_wrap_positive)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
res = (gint16 *) GST_BUFFER_DATA (outbuffer);
fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], out[4], out[5], res[0], res[1], res[2],
res[3], res[4], res[5]);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 12) == 0);
fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 12) == 0);
/* cleanup */
cleanup_amplify (amplify);
......@@ -397,7 +391,7 @@ GST_START_TEST (test_200_wrap_positive)
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
gint16 out[6] = { 16382, -32768, 512, -256, 0, -16384 };
gint16 *res;
gint16 res[6];
amplify = setup_amplify ();
g_object_set (G_OBJECT (amplify), "amplification", 2.0, NULL);
......@@ -406,12 +400,12 @@ GST_START_TEST (test_200_wrap_positive)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (12);
memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
caps = gst_caps_from_string (AMPLIFY_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
......@@ -420,12 +414,12 @@ GST_START_TEST (test_200_wrap_positive)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
res = (gint16 *) GST_BUFFER_DATA (outbuffer);
fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], out[4], out[5], res[0], res[1], res[2],
res[3], res[4], res[5]);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 12) == 0);
fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 12) == 0);
/* cleanup */
cleanup_amplify (amplify);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment