mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
tests: audiodynamic: port to 0.11
This commit is contained in:
parent
24300315e7
commit
b44647c043
1 changed files with 43 additions and 56 deletions
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <gst/audio/audio.h>
|
||||
#include <gst/base/gstbasetransform.h>
|
||||
#include <gst/check/gstcheck.h>
|
||||
|
||||
|
@ -37,32 +38,25 @@ GstPad *mysrcpad, *mysinkpad;
|
|||
|
||||
|
||||
#define DYNAMIC_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_dynamic (void)
|
||||
|
@ -101,18 +95,17 @@ GST_START_TEST (test_passthrough)
|
|||
GstBuffer *inbuffer, *outbuffer;
|
||||
GstCaps *caps;
|
||||
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
|
||||
gint16 *res;
|
||||
gint16 res[6];
|
||||
|
||||
dynamic = setup_dynamic ();
|
||||
fail_unless (gst_element_set_state (dynamic,
|
||||
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);
|
||||
inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
|
||||
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
|
||||
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
|
||||
gst_buffer_set_caps (inbuffer, caps);
|
||||
fail_unless (gst_pad_set_caps (mysrcpad, caps));
|
||||
gst_caps_unref (caps);
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
|
||||
|
@ -122,12 +115,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_dynamic (dynamic);
|
||||
|
@ -141,7 +134,7 @@ GST_START_TEST (test_compress_hard_50_50)
|
|||
GstBuffer *inbuffer, *outbuffer;
|
||||
GstCaps *caps;
|
||||
gint16 in[8] = { -30000, 24576, -16384, 256, -128, 0, -24576, 30000 };
|
||||
gint16 *res;
|
||||
gint16 res[8];
|
||||
|
||||
dynamic = setup_dynamic ();
|
||||
g_object_set (G_OBJECT (dynamic), "mode", 0, NULL);
|
||||
|
@ -152,11 +145,10 @@ GST_START_TEST (test_compress_hard_50_50)
|
|||
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
||||
"could not set to playing");
|
||||
|
||||
inbuffer = gst_buffer_new_and_alloc (16);
|
||||
memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
|
||||
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
|
||||
inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
|
||||
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
|
||||
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
|
||||
gst_buffer_set_caps (inbuffer, caps);
|
||||
fail_unless (gst_pad_set_caps (mysrcpad, caps));
|
||||
gst_caps_unref (caps);
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
|
||||
|
@ -166,7 +158,7 @@ GST_START_TEST (test_compress_hard_50_50)
|
|||
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, 16) == 16);
|
||||
|
||||
fail_unless (res[0] > in[0]);
|
||||
fail_unless (res[1] < in[1]);
|
||||
|
@ -189,7 +181,7 @@ GST_START_TEST (test_compress_soft_50_50)
|
|||
GstBuffer *inbuffer, *outbuffer;
|
||||
GstCaps *caps;
|
||||
gint16 in[8] = { -30000, 24576, -16384, 256, -128, 0, -24576, 30000 };
|
||||
gint16 *res;
|
||||
gint16 res[8];
|
||||
|
||||
dynamic = setup_dynamic ();
|
||||
g_object_set (G_OBJECT (dynamic), "mode", 0, NULL);
|
||||
|
@ -200,11 +192,10 @@ GST_START_TEST (test_compress_soft_50_50)
|
|||
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
||||
"could not set to playing");
|
||||
|
||||
inbuffer = gst_buffer_new_and_alloc (16);
|
||||
memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
|
||||
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
|
||||
inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
|
||||
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
|
||||
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
|
||||
gst_buffer_set_caps (inbuffer, caps);
|
||||
fail_unless (gst_pad_set_caps (mysrcpad, caps));
|
||||
gst_caps_unref (caps);
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
|
||||
|
@ -214,7 +205,7 @@ GST_START_TEST (test_compress_soft_50_50)
|
|||
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, 16) == 16);
|
||||
|
||||
fail_unless (res[0] > in[0]);
|
||||
fail_unless (res[1] < in[1]);
|
||||
|
@ -237,7 +228,7 @@ GST_START_TEST (test_compress_hard_100_50)
|
|||
GstBuffer *inbuffer, *outbuffer;
|
||||
GstCaps *caps;
|
||||
gint16 in[8] = { -30000, 24576, -16384, 256, -128, 0, -24576, 30000 };
|
||||
gint16 *res;
|
||||
gint16 res[8];
|
||||
|
||||
dynamic = setup_dynamic ();
|
||||
g_object_set (G_OBJECT (dynamic), "mode", 0, NULL);
|
||||
|
@ -248,11 +239,10 @@ GST_START_TEST (test_compress_hard_100_50)
|
|||
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
||||
"could not set to playing");
|
||||
|
||||
inbuffer = gst_buffer_new_and_alloc (16);
|
||||
memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
|
||||
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
|
||||
inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
|
||||
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
|
||||
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
|
||||
gst_buffer_set_caps (inbuffer, caps);
|
||||
fail_unless (gst_pad_set_caps (mysrcpad, caps));
|
||||
gst_caps_unref (caps);
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
|
||||
|
@ -262,7 +252,7 @@ GST_START_TEST (test_compress_hard_100_50)
|
|||
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, 16) == 16);
|
||||
|
||||
fail_unless (res[0] == in[0]);
|
||||
fail_unless (res[1] == in[1]);
|
||||
|
@ -286,7 +276,7 @@ GST_START_TEST (test_expand_hard_50_200)
|
|||
GstBuffer *inbuffer, *outbuffer;
|
||||
GstCaps *caps;
|
||||
gint16 in[8] = { -30000, 24576, -16383, 256, -128, 0, -24576, 30000 };
|
||||
gint16 *res;
|
||||
gint16 res[8];
|
||||
|
||||
dynamic = setup_dynamic ();
|
||||
g_object_set (G_OBJECT (dynamic), "mode", 1, NULL);
|
||||
|
@ -297,11 +287,10 @@ GST_START_TEST (test_expand_hard_50_200)
|
|||
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
||||
"could not set to playing");
|
||||
|
||||
inbuffer = gst_buffer_new_and_alloc (16);
|
||||
memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
|
||||
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
|
||||
inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
|
||||
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
|
||||
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
|
||||
gst_buffer_set_caps (inbuffer, caps);
|
||||
fail_unless (gst_pad_set_caps (mysrcpad, caps));
|
||||
gst_caps_unref (caps);
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
|
||||
|
@ -311,7 +300,7 @@ GST_START_TEST (test_expand_hard_50_200)
|
|||
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, 16) == 16);
|
||||
|
||||
fail_unless (res[0] == in[0]);
|
||||
fail_unless (res[1] == in[1]);
|
||||
|
@ -334,7 +323,7 @@ GST_START_TEST (test_expand_soft_50_200)
|
|||
GstBuffer *inbuffer, *outbuffer;
|
||||
GstCaps *caps;
|
||||
gint16 in[8] = { -30000, 24576, -16383, 256, -128, 0, -24576, 30000 };
|
||||
gint16 *res;
|
||||
gint16 res[8];
|
||||
|
||||
dynamic = setup_dynamic ();
|
||||
g_object_set (G_OBJECT (dynamic), "mode", 1, NULL);
|
||||
|
@ -345,11 +334,10 @@ GST_START_TEST (test_expand_soft_50_200)
|
|||
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
||||
"could not set to playing");
|
||||
|
||||
inbuffer = gst_buffer_new_and_alloc (16);
|
||||
memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
|
||||
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
|
||||
inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
|
||||
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
|
||||
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
|
||||
gst_buffer_set_caps (inbuffer, caps);
|
||||
fail_unless (gst_pad_set_caps (mysrcpad, caps));
|
||||
gst_caps_unref (caps);
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
|
||||
|
@ -359,7 +347,7 @@ GST_START_TEST (test_expand_soft_50_200)
|
|||
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, 16) == 16);
|
||||
|
||||
fail_unless (res[0] == in[0]);
|
||||
fail_unless (res[1] == in[1]);
|
||||
|
@ -382,7 +370,7 @@ GST_START_TEST (test_expand_hard_0_200)
|
|||
GstBuffer *inbuffer, *outbuffer;
|
||||
GstCaps *caps;
|
||||
gint16 in[8] = { -30000, 24576, -16383, 256, -128, 0, -24576, 30000 };
|
||||
gint16 *res;
|
||||
gint16 res[8];
|
||||
|
||||
dynamic = setup_dynamic ();
|
||||
g_object_set (G_OBJECT (dynamic), "mode", 1, NULL);
|
||||
|
@ -393,11 +381,10 @@ GST_START_TEST (test_expand_hard_0_200)
|
|||
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
||||
"could not set to playing");
|
||||
|
||||
inbuffer = gst_buffer_new_and_alloc (16);
|
||||
memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
|
||||
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
|
||||
inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
|
||||
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
|
||||
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
|
||||
gst_buffer_set_caps (inbuffer, caps);
|
||||
fail_unless (gst_pad_set_caps (mysrcpad, caps));
|
||||
gst_caps_unref (caps);
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
|
||||
|
@ -407,7 +394,7 @@ GST_START_TEST (test_expand_hard_0_200)
|
|||
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, 16) == 16);
|
||||
|
||||
fail_unless (res[0] == in[0]);
|
||||
fail_unless (res[1] == in[1]);
|
||||
|
|
Loading…
Reference in a new issue